From nobody Tue Feb 10 04:14:00 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1599190916; cv=none; d=zohomail.com; s=zohoarc; b=awfvn05HzYpwYHoBs7TfgR1O1VyjSFQaD9/k6ZmtP6qUc+t3cp+uGlXn9uJ6DuoxwdFDs6eKRiW+QBcJBuzsb7o8sA6KO3Ws4ATmKxZz9P6VSPj8Wj5nP9o+iXO3LfrWKTZ/qRyf2vdiGgIC2/WCnTLrE9qPzvwO7uEq+0zDLy0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1599190916; 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=1sOcUko56nqeaPXtOYKKU7mIP1kl7s2DIQ77gPJHUww=; b=AAMCIcz2ELlbX9AVBOkV7VjpS57KsreXyyoBbiflSNE1+4oNDzRmJQbl/fnrnNLmb8/G1oUn0DRY4va9VS3sn91tj0DiP+Xyy8o01eAlMI8H2TwE/PcVmvg5b0/e6YtSGgpx6Qjq5BP6M73o+ahlXjZo4jg8yAvcO9FZ/h/yXa4= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1599190916522152.9114889995634; Thu, 3 Sep 2020 20:41:56 -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-461-9JIQQg1YNcOkxvf5Ot9PVw-1; Thu, 03 Sep 2020 23:41:53 -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 195A3801AFA; Fri, 4 Sep 2020 03:41:45 +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 E9EB719D61; Fri, 4 Sep 2020 03:41:44 +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 B77651800B72; Fri, 4 Sep 2020 03:41:44 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0843f9NA030554 for ; Thu, 3 Sep 2020 23:41:11 -0400 Received: by smtp.corp.redhat.com (Postfix) id BB3352157F23; Fri, 4 Sep 2020 03:41:09 +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 B1DFA2157F26 for ; Fri, 4 Sep 2020 03:41:08 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) (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 398CA8007D9 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-46-tISeLCyXM3q80CkNCQs_DQ-1; Thu, 03 Sep 2020 23:41:05 -0400 Received: from localhost.localdomain (unknown [58.56.27.130]) by smtp4 (Coremail) with SMTP id JedpCgAHcNgStlFfYHYgCg--.1426S34; Fri, 04 Sep 2020 11:35:56 +0800 (CST) X-MC-Unique: 9JIQQg1YNcOkxvf5Ot9PVw-1 X-MC-Unique: tISeLCyXM3q80CkNCQs_DQ-1 From: Shi Lei To: libvir-list@redhat.com Subject: [RFCv2 32/46] conf: Generate virDomainGraphicsRDPDefFormatAttr Date: Fri, 4 Sep 2020 11:35:24 +0800 Message-Id: <20200904033538.418579-33-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--.1426S34 X-Coremail-Antispam: 1Uf129KBjvJXoWxWr48tryxWw1UKw15Ar1fZwb_yoWrZrWDpF 13WFWFyw48XrsxCr4xG3WjgwsIkFykXrnrAr9Iqw40vrWUJrs3ZryxWFy29r4agr1kZFyF yFWSqw1UWr4jyFJanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0pRoGQkUUUUU= X-Originating-IP: [58.56.27.130] X-CM-SenderInfo: pvklsz1hl6ztxvvfz0xxgvhudrp/1tbiPRyVT1bdHaoh9AAAsS 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.78 on 10.11.54.6 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 | 86 +++++++++++++++++++++++++++++------------- src/conf/domain_conf.h | 3 +- 2 files changed, 61 insertions(+), 28 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 14bb4d3..7709d71 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -27995,6 +27995,28 @@ virDomainGraphicsListenDefFormat(virBufferPtr buf, } =20 =20 +static bool +virDomainGraphicsListenDefCheckAddr(virDomainGraphicsListenDefPtr glisten, + unsigned int flags) +{ + if (!glisten) + return false; + + if (flags & VIR_DOMAIN_DEF_FORMAT_MIGRATABLE && glisten->fromConfig) + return false; + + if (glisten->type =3D=3D VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK && + flags & (VIR_DOMAIN_DEF_FORMAT_INACTIVE | + VIR_DOMAIN_DEF_FORMAT_MIGRATABLE)) + return false; + + if (glisten->address) + return true; + + return false; +} + + /** * virDomainGraphicsListenDefFormatAddr: * @buf: buffer where the output XML is written @@ -28009,19 +28031,10 @@ virDomainGraphicsListenDefFormatAddr(virBufferPtr= buf, virDomainGraphicsListenDefPtr glisten, unsigned int flags) { - if (!glisten) + if (!virDomainGraphicsListenDefCheckAddr(glisten, flags)) return; =20 - if (flags & VIR_DOMAIN_DEF_FORMAT_MIGRATABLE && glisten->fromConfig) - return; - - if (glisten->type =3D=3D VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK && - flags & (VIR_DOMAIN_DEF_FORMAT_INACTIVE | - VIR_DOMAIN_DEF_FORMAT_MIGRATABLE)) - return; - - if (glisten->address) - virBufferAsprintf(buf, " listen=3D'%s'", glisten->address); + virBufferAsprintf(buf, " listen=3D'%s'", glisten->address); } =20 static void @@ -28180,22 +28193,8 @@ virDomainGraphicsDefFormat(virBufferPtr buf, break; =20 case VIR_DOMAIN_GRAPHICS_TYPE_RDP: - if (def->data.rdp.port) - virBufferAsprintf(buf, " port=3D'%d'", - def->data.rdp.port); - else if (def->data.rdp.autoport) - virBufferAddLit(buf, " port=3D'0'"); - - if (def->data.rdp.autoport) - virBufferAddLit(buf, " autoport=3D'yes'"); - - if (def->data.rdp.replaceUser) - virBufferAddLit(buf, " replaceUser=3D'yes'"); - - if (def->data.rdp.multiUser) - virBufferAddLit(buf, " multiUser=3D'yes'"); - - virDomainGraphicsListenDefFormatAddr(buf, glisten, flags); + if (virDomainGraphicsRDPDefFormatAttr(buf, &def->data.rdp, def, NU= LL)) + return -1; =20 break; =20 @@ -32943,3 +32942,36 @@ virHostdevIsVFIODevice(const virDomainHostdevDef *= hostdev) hostdev->source.subsys.type =3D=3D VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_= PCI && hostdev->source.subsys.u.pci.backend =3D=3D VIR_DOMAIN_HOSTDEV_PCI= _BACKEND_VFIO; } + + +bool +virDomainGraphicsRDPDefCheckAttrHook(const virDomainGraphicsRDPDef *def G_= GNUC_UNUSED, + const void *parent, + void *opaque, + bool value) +{ + virDomainGraphicsDefPtr graphic =3D (virDomainGraphicsDefPtr) parent; + virDomainGraphicsListenDefPtr glisten =3D &graphic->listens[0]; + unsigned int flags =3D 0; + if (opaque) + flags =3D *((unsigned int *) opaque); + + return virDomainGraphicsListenDefCheckAddr(glisten, flags) || value; +} + + +int +virDomainGraphicsRDPDefFormatAttrHook(const virDomainGraphicsRDPDef *def G= _GNUC_UNUSED, + const void *parent, + const void *opaque, + virBufferPtr listenBuf) +{ + virDomainGraphicsDefPtr graphic =3D (virDomainGraphicsDefPtr) parent; + virDomainGraphicsListenDefPtr glisten =3D &graphic->listens[0]; + unsigned int flags =3D 0; + if (opaque) + flags =3D *((unsigned int *) opaque); + + virDomainGraphicsListenDefFormatAddr(listenBuf, glisten, flags); + return 0; +} diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 3cdb5f8..1444257 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1695,11 +1695,12 @@ struct _virDomainGraphicsVNCDef { /* genparse:wit= hhook, genformat:separate */ virDomainGraphicsAuthDef auth; /* xmlgroup */ }; =20 -struct _virDomainGraphicsRDPDef { /* genparse:withhook */ +struct _virDomainGraphicsRDPDef { /* genparse:withhook, genformat:separa= te */ int port; /* xmlattr */ bool autoport; /* xmlattr */ bool replaceUser; /* xmlattr */ bool multiUser; /* xmlattr */ + char *_listen; /* xmlattr:listen, formathook */ }; =20 struct _virDomainGraphicsDesktopDef { --=20 2.25.1