From nobody Mon Feb 9 13:39:00 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1599190941; cv=none; d=zohomail.com; s=zohoarc; b=lNqGGQhZbsR4QtsF0brj5mB3lpswhtAP2lhx2pLDJ2I+Bvkh5oGP5OJwvlqlM5F8OioLudz7vtLJS+Szv4CMsxQjHVmwR+tAeauRQyN74CYvk28I1cNTX7CeW4/oE1+cRaUt68eqx/ytRvSpyHDNek0Vg6F/OzakTLtYkywEi1A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1599190941; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=7l5n9iRoht5BXaoch4XP9rjLyzNFCTVIkCPMuN9yTYc=; b=K1pUMvTsFzFPmFYOWaV10rj19VIFi4+PRziiGDEap9eYcLOA+LeIVkJ5IvOgup6q39Jpi2/4XtkiVZIHCf/LnqWxsOTs8/Lg/810ER59nNDduSSwVf6652LcnM+4jN0c3fzoqABtYZlohrcRw0pYOb9UbDd6A7ipzAR88nA3IBI= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1599190941446751.2062116932067; Thu, 3 Sep 2020 20:42:21 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-65-89GrzH4hPpqnraqzrCNOQA-1; Thu, 03 Sep 2020 23:42:19 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5B19A800462; Fri, 4 Sep 2020 03:42:13 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 390261A7C8; Fri, 4 Sep 2020 03:42:13 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 05274181A894; Fri, 4 Sep 2020 03:42:13 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0843fBRY030648 for ; Thu, 3 Sep 2020 23:41:11 -0400 Received: by smtp.corp.redhat.com (Postfix) id 21FE0103791; Fri, 4 Sep 2020 03:41:10 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast02.extmail.prod.ext.rdu2.redhat.com [10.11.55.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1602C1037A0 for ; Fri, 4 Sep 2020 03:41:08 +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-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 39EBE80118B for ; Fri, 4 Sep 2020 03:41:08 +0000 (UTC) Received: from mail-m24147.qiye.163.com (mail-m24147.qiye.163.com [220.194.24.147]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-56-TEx1HvU4Pfu2PL2ihdEblw-1; Thu, 03 Sep 2020 23:41:03 -0400 Received: from localhost.localdomain (unknown [58.56.27.130]) by smtp4 (Coremail) with SMTP id JedpCgAHcNgStlFfYHYgCg--.1426S29; Fri, 04 Sep 2020 11:35:55 +0800 (CST) X-MC-Unique: 89GrzH4hPpqnraqzrCNOQA-1 X-MC-Unique: TEx1HvU4Pfu2PL2ihdEblw-1 From: Shi Lei To: libvir-list@redhat.com Subject: [RFCv2 27/46] conf: Extract error-checking code from virDomainGraphicsDefParseXMLVNC Date: Fri, 4 Sep 2020 11:35:19 +0800 Message-Id: <20200904033538.418579-28-shi_lei@massclouds.com> In-Reply-To: <20200904033538.418579-1-shi_lei@massclouds.com> References: <20200904033538.418579-1-shi_lei@massclouds.com> MIME-Version: 1.0 X-CM-TRANSID: JedpCgAHcNgStlFfYHYgCg--.1426S29 X-Coremail-Antispam: 1Uf129KBjvJXoWxWr47JF13Ar13Kw15Ww45Wrg_yoWrXF13pF s3XFZ8tFWYqrnxC392gan8uws0kF1kJwsrJrWfZ34DXrW5Grs5Aw4FqF1qgw1jkr97ZrW3 AF48KFWjgF4DZaDanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0zEdcTPUUUUU= X-Originating-IP: [58.56.27.130] X-CM-SenderInfo: pvklsz1hl6ztxvvfz0xxgvhudrp/1tbiQxuVT1bdHJ2LGwAAsY 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-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0.002 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Signed-off-by: Shi Lei --- src/conf/domain_conf.c | 77 +++++++++++++++++++++++++++++------------- 1 file changed, 53 insertions(+), 24 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index be07b40..aedf278 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -14356,10 +14356,55 @@ virDomainGraphicsListensParseXML(virDomainGraphic= sDefPtr def, } =20 =20 +static int +virDomainGraphicsVNCDefParseXMLHook(xmlNodePtr node G_GNUC_UNUSED, + virDomainGraphicsVNCDefPtr def, + const char *instname G_GNUC_UNUSED, + void *parent G_GNUC_UNUSED, + void *opaque, + const char *port, + const char *websocket G_GNUC_UNUSED, + const char *websocketGenerated G_GNUC_= UNUSED, + const char *autoport, + const char *sharePolicy G_GNUC_UNUSED) +{ + unsigned int flags =3D *((unsigned int *) opaque); + + /* Legacy compat syntax, used -1 for auto-port */ + if (port) { + if (def->port =3D=3D -1) { + if (flags & VIR_DOMAIN_DEF_PARSE_INACTIVE) + def->port =3D 0; + if (autoport =3D=3D NULL) + def->autoport =3D true; + } + } else { + def->port =3D 0; + if (autoport =3D=3D NULL) + def->autoport =3D true; + } + + if (autoport) { + if (def->autoport && flags & VIR_DOMAIN_DEF_PARSE_INACTIVE) + def->port =3D 0; + } + + /* VNC supports connected=3D'keep' only */ + if (def->auth.connected && + def->auth.connected !=3D VIR_DOMAIN_GRAPHICS_AUTH_CONNECTED_KEEP) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("VNC supports connected=3D'keep' only")); + return -1; + } + + return 0; +} + + static int virDomainGraphicsDefParseXMLVNC(virDomainGraphicsDefPtr def, xmlNodePtr node, - xmlXPathContextPtr ctxt, + xmlXPathContextPtr ctxt G_GNUC_UNUSED, unsigned int flags) { g_autofree char *port =3D virXMLPropString(node, "port"); @@ -14368,33 +14413,17 @@ virDomainGraphicsDefParseXMLVNC(virDomainGraphics= DefPtr def, g_autofree char *sharePolicy =3D virXMLPropString(node, "sharePolicy"); g_autofree char *autoport =3D virXMLPropString(node, "autoport"); =20 - if (virDomainGraphicsListensParseXML(def, node, ctxt, flags) < 0) - return -1; - if (port) { if (virStrToLong_i(port, NULL, 10, &def->data.vnc.port) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("cannot parse vnc port %s"), port); return -1; } - /* Legacy compat syntax, used -1 for auto-port */ - if (def->data.vnc.port =3D=3D -1) { - if (flags & VIR_DOMAIN_DEF_PARSE_INACTIVE) - def->data.vnc.port =3D 0; - def->data.vnc.autoport =3D true; - } - } else { - def->data.vnc.port =3D 0; - def->data.vnc.autoport =3D true; } =20 - if (autoport) { + if (autoport) ignore_value(virStringParseYesNo(autoport, &def->data.vnc.autoport= )); =20 - if (def->data.vnc.autoport && flags & VIR_DOMAIN_DEF_PARSE_INACTIV= E) - def->data.vnc.port =3D 0; - } - if (websocket) { if (virStrToLong_i(websocket, NULL, 10, @@ -14429,13 +14458,11 @@ virDomainGraphicsDefParseXMLVNC(virDomainGraphics= DefPtr def, NULL, def, NULL) < 0) return -1; =20 - /* VNC supports connected=3D'keep' only */ - if (def->data.vnc.auth.connected && - def->data.vnc.auth.connected !=3D VIR_DOMAIN_GRAPHICS_AUTH_CONNECT= ED_KEEP) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("VNC supports connected=3D'keep' only")); + if (virDomainGraphicsVNCDefParseXMLHook(node, &def->data.vnc, NULL, de= f, &flags, + port, websocket, + websocketGenerated, autoport, + sharePolicy) < 0) return -1; - } =20 return 0; } @@ -14867,6 +14894,8 @@ virDomainGraphicsDefParseXML(virDomainXMLOptionPtr = xmlopt, case VIR_DOMAIN_GRAPHICS_TYPE_VNC: if (virDomainGraphicsDefParseXMLVNC(def, node, ctxt, flags) < 0) goto error; + if (virDomainGraphicsListensParseXML(def, node, ctxt, flags) < 0) + goto error; break; case VIR_DOMAIN_GRAPHICS_TYPE_SDL: if (virDomainGraphicsSDLDefParseXML(node, &def->data.sdl, NULL, de= f, NULL) < 0) --=20 2.25.1