From nobody Mon May 13 00:40:59 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=weirdnatto.in Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1649867540636473.4120635811463; Wed, 13 Apr 2022 09:32:20 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-554-k1jKYuQFPO2mC0TwW7EGaw-1; Wed, 13 Apr 2022 12:32:17 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7890182A682; Wed, 13 Apr 2022 16:32:15 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id E1E14200BCCC; Wed, 13 Apr 2022 16:32:14 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 791431940345; Wed, 13 Apr 2022 16:32:14 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 41D561940340 for ; Wed, 13 Apr 2022 16:32:13 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 30C2B7ADF; Wed, 13 Apr 2022 16:32:13 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast01.extmail.prod.ext.rdu2.redhat.com [10.11.55.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2C49D9D7E for ; Wed, 13 Apr 2022 16:32:09 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 95BFC86B8A1 for ; Wed, 13 Apr 2022 16:32:09 +0000 (UTC) Received: from mail.weirdnatto.in (140.238.230.155 [140.238.230.155]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-448-AfDIrzmNNIu4WdbAwVMEYg-1; Wed, 13 Apr 2022 12:32:07 -0400 X-MC-Unique: k1jKYuQFPO2mC0TwW7EGaw-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: AfDIrzmNNIu4WdbAwVMEYg-1 From: Amneesh Singh To: libvir-list@redhat.com Subject: [PATCH v2] conf: virDomainGraphicsDefValidate: validate attribute 'network' for listen type 'network' Date: Wed, 13 Apr 2022 22:01:37 +0530 Message-Id: <20220413163137.282909-1-natto@weirdnatto.in> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Amneesh Singh Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1649867542754100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Related: https://gitlab.com/libvirt/libvirt/-/issues/93 Signed-off-by: Amneesh Singh Reviewed-by: Martin Kletzander --- v1 PATCH: https://listman.redhat.com/archives/libvir-list/2022-April/230021= .html src/conf/domain_validate.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c index 68190fc..e58b84e 100644 --- a/src/conf/domain_validate.c +++ b/src/conf/domain_validate.c @@ -2347,10 +2347,35 @@ virDomainAudioDefValidate(const virDomainDef *def, return 0; } =20 +static int +virDomainGraphicsDefListensValidate(const virDomainGraphicsDef *def) +{ + size_t i; + + for (i =3D 0; i < def->nListens; i++) { + if (def->listens[i].type =3D=3D VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NE= TWORK && + !def->listens[i].network) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("'network' attribute is required for " + "listen type 'network'")); + return -1; + } + } + + return 0; +} + static int virDomainGraphicsDefValidate(const virDomainDef *def, const virDomainGraphicsDef *graphics) { + if (graphics->type =3D=3D VIR_DOMAIN_GRAPHICS_TYPE_VNC || + graphics->type =3D=3D VIR_DOMAIN_GRAPHICS_TYPE_SPICE || + graphics->type =3D=3D VIR_DOMAIN_GRAPHICS_TYPE_RDP) { + if (virDomainGraphicsDefListensValidate(graphics) < 0) + return -1; + } + if (graphics->type =3D=3D VIR_DOMAIN_GRAPHICS_TYPE_VNC) return virDomainEnsureAudioID(def, graphics->data.vnc.audioId); =20 --=20 2.35.1