From nobody Mon Feb 9 15:11:16 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1599191043; cv=none; d=zohomail.com; s=zohoarc; b=fK1EBMYTruBa2VyV/6t5KcrnzlgPB71cuMDKEgMafkCX4iROg7pGeCdaPTKuWnP81uLlbsIJP/afRwVGQahZyirhW0G27s4/LtRTYa8P+KdJfbJb+ZbssnCFKg6y7Q/EbtOLalnPUke4w2ADqLHV1/R7cfgX0Y3IeqVXf78v4P8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1599191043; 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=Zs79mJkfXr1YEUtrK/OSwdIFLS6KTjyjC10G3PbFVP8=; b=bkhML6CeWEmoldSMdd5fZKkctkuGlkBnUJvyqibYX13iK6FsXEmouvaGgsHyEolMwx2P2r0OhBtImfFnWRWl2hT+WPdpLFOGJvtr3gh84VLb5v0IviPfvP5gBRNfo9NQQ9LxINJN5eigoMGVEBmhwmOZt2jc51UQyJly9720xl8= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1599191043675433.0983791530641; Thu, 3 Sep 2020 20:44:03 -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-60-Z4tiT-WcPAaBkLe0Hb7jbA-1; Thu, 03 Sep 2020 23:43:27 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 191FF8712FD; Fri, 4 Sep 2020 03:43:22 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EC69860C13; Fri, 4 Sep 2020 03:43:21 +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 BB54C972E6; Fri, 4 Sep 2020 03:43:21 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0843fOje030924 for ; Thu, 3 Sep 2020 23:41:24 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0F41E20244F7; Fri, 4 Sep 2020 03:41:24 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast06.extmail.prod.ext.rdu2.redhat.com [10.11.55.22]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0A665200AE6E for ; Fri, 4 Sep 2020 03:41:24 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.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 E3E88185A78B for ; Fri, 4 Sep 2020 03:41:23 +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-48-kMXm5xv8NGCvi8DCt3M65Q-1; Thu, 03 Sep 2020 23:41:21 -0400 Received: from localhost.localdomain (unknown [58.56.27.130]) by smtp4 (Coremail) with SMTP id JedpCgAHcNgStlFfYHYgCg--.1426S45; Fri, 04 Sep 2020 11:35:58 +0800 (CST) X-MC-Unique: Z4tiT-WcPAaBkLe0Hb7jbA-1 X-MC-Unique: kMXm5xv8NGCvi8DCt3M65Q-1 From: Shi Lei To: libvir-list@redhat.com Subject: [RFCv2 43/46] conf: Generate virDomainGraphicsListenDefFormatBuf Date: Fri, 4 Sep 2020 11:35:35 +0800 Message-Id: <20200904033538.418579-44-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--.1426S45 X-Coremail-Antispam: 1Uf129KBjvJXoW3XFykWF43tF15GF17Cw1rZwb_yoWxCw48pF 4fXayUtayUJF1fArs7X3WqgrWF9F97XasrJr9Iqw1j9rWUGrWxZw1IgFyjvw13WF1kZFWS yFWSgw4Uuw4YvFDanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0pRrgA3UUUUU= X-Originating-IP: [58.56.27.130] X-CM-SenderInfo: pvklsz1hl6ztxvvfz0xxgvhudrp/1tbiQx6VT1bdHJ2LIwAAsl 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.4 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.79 on 10.5.11.12 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 | 114 +++++++++++++++++++++++------------------ src/conf/domain_conf.h | 12 ++--- 2 files changed, 70 insertions(+), 56 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 507679b..007ee44 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -27614,19 +27614,64 @@ virDomainTimerDefFormat(virBufferPtr buf, } =20 =20 -static void -virDomainGraphicsListenDefFormat(virBufferPtr buf, - virDomainGraphicsListenDefPtr def, - unsigned int flags) +static bool +virDomainGraphicsListenDefValid(const virDomainGraphicsListenDef *def, + const virDomainGraphicsDef *graphics, + unsigned int flags) { - /* If generating migratable XML, skip listen address - * dragged in from config file */ - if ((flags & VIR_DOMAIN_DEF_FORMAT_MIGRATABLE) && def->fromConfig) - return; + if (flags & VIR_DOMAIN_DEF_FORMAT_MIGRATABLE) { + /* If the listen is based on config options from qemu.conf we need + * to skip it. It's up to user to properly configure both hosts f= or + * migration. */ + if (def->fromConfig) + return false; + + /* If the socket is provided by user in the XML we need to skip th= is + * listen type to support migration back to old libvirt since old + * libvirt supports specifying socket path inside graphics element + * as 'socket' attribute. Auto-generated socket is a new feature + * thus we can generate it in the migrateble XML. */ + if (graphics->type =3D=3D VIR_DOMAIN_GRAPHICS_TYPE_VNC && + def->type =3D=3D VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_SOCKET && + def->socket && !def->autoGenerated) + return false; + + /* The new listen type none is in the migratable XML represented as + * port=3D0 and autoport=3Dno because old libvirt support this + * configuration for spice. */ + if (graphics->type =3D=3D VIR_DOMAIN_GRAPHICS_TYPE_SPICE && + def->type =3D=3D VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NONE) + return false; + } + + return true; +} + + +bool +virDomainGraphicsListenDefCheckHook(const virDomainGraphicsListenDef *def, + const void *parent, + void *opaque, + bool value G_GNUC_UNUSED) +{ + virDomainGraphicsDefPtr graphics =3D (virDomainGraphicsDefPtr) parent; + unsigned int flags =3D 0; + if (opaque) + flags =3D *((unsigned int *) opaque); + return virDomainGraphicsListenDefValid(def, graphics, flags); +} =20 - virBufferAddLit(buf, "type)); + +int +virDomainGraphicsListenDefFormatHook(const virDomainGraphicsListenDef *def, + const void *parent G_GNUC_UNUSED, + const void *opaque, + virBufferPtr addressBuf, + virBufferPtr socketBuf) +{ + unsigned int flags =3D 0; + if (opaque) + flags =3D *((unsigned int *) opaque); =20 if (def->address && (def->type =3D=3D VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS || @@ -27634,28 +27679,17 @@ virDomainGraphicsListenDefFormat(virBufferPtr buf, !(flags & VIR_DOMAIN_DEF_FORMAT_INACTIVE)))) { /* address may also be set to show current status when type=3D'net= work', * but we don't want to print that if INACTIVE data is requested. = */ - virBufferAsprintf(buf, " address=3D'%s'", def->address); - } - - if (def->network && - (def->type =3D=3D VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK)) { - virBufferEscapeString(buf, " network=3D'%s'", def->network); + virBufferAsprintf(addressBuf, " address=3D'%s'", def->address); } =20 if (def->socket && def->type =3D=3D VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_SOCKET && !(def->autoGenerated && (flags & VIR_DOMAIN_DEF_FORMAT_MIGRATABLE))) { - virBufferEscapeString(buf, " socket=3D'%s'", def->socket); - } - - if (flags & VIR_DOMAIN_DEF_FORMAT_STATUS) { - virBufferAsprintf(buf, " fromConfig=3D'%d'", def->fromConfig); - virBufferAsprintf(buf, " autoGenerated=3D'%s'", - def->autoGenerated ? "yes" : "no"); + virBufferEscapeString(socketBuf, " socket=3D'%s'", def->socket); } =20 - virBufferAddLit(buf, "/>\n"); + return 0; } =20 =20 @@ -27883,37 +27917,17 @@ virDomainGraphicsDefFormat(virBufferPtr buf, } =20 for (i =3D 0; i < def->nListens; i++) { - if (flags & VIR_DOMAIN_DEF_FORMAT_MIGRATABLE) { - /* If the listen is based on config options from qemu.conf we = need - * to skip it. It's up to user to properly configure both hos= ts for - * migration. */ - if (def->listens[i].fromConfig) - continue; - - /* If the socket is provided by user in the XML we need to ski= p this - * listen type to support migration back to old libvirt since = old - * libvirt supports specifying socket path inside graphics ele= ment - * as 'socket' attribute. Auto-generated socket is a new feat= ure - * thus we can generate it in the migrateble XML. */ - if (def->type =3D=3D VIR_DOMAIN_GRAPHICS_TYPE_VNC && - def->listens[i].type =3D=3D VIR_DOMAIN_GRAPHICS_LISTEN_TYP= E_SOCKET && - def->listens[i].socket && - !def->listens[i].autoGenerated) - continue; + if (!virDomainGraphicsListenDefValid(&def->listens[i], def, flags)) + continue; =20 - /* The new listen type none is in the migratable XML represent= ed as - * port=3D0 and autoport=3Dno because old libvirt support this - * configuration for spice. */ - if (def->type =3D=3D VIR_DOMAIN_GRAPHICS_TYPE_SPICE && - def->listens[i].type =3D=3D VIR_DOMAIN_GRAPHICS_LISTEN_TYP= E_NONE) - continue; - } if (!children) { virBufferAddLit(buf, ">\n"); virBufferAdjustIndent(buf, 2); children =3D true; } - virDomainGraphicsListenDefFormat(buf, &def->listens[i], flags); + + virDomainGraphicsListenDefFormatBuf(buf, "listen", + &def->listens[i], def, &flags); } =20 if (def->type =3D=3D VIR_DOMAIN_GRAPHICS_TYPE_SPICE) { diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index fc4aae2..d78cdbb 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1668,14 +1668,14 @@ typedef enum { VIR_DOMAIN_HUB_TYPE_LAST } virDomainHubType; =20 -struct _virDomainGraphicsListenDef { /* genparse:withhook */ +struct _virDomainGraphicsListenDef { /* genparse:withhook, genformat */ virDomainGraphicsListenType type; /* xmlattr */ - char *address; /* xmlattr */ - char *network; /* xmlattr */ - char *socket; /* xmlattr */ + char *address; /* xmlattr, formathook */ + char *network; /* xmlattr, formatflag:VIR_DOMAIN_= GRAPHICS_LISTEN_TYPE_NETWORK */ + char *socket; /* xmlattr, formathook */ /* true if the @address is config file originated */ - int fromConfig; /* xmlattr */ - bool autoGenerated; /* xmlattr */ + int fromConfig; /* xmlattr, formatflag:%VIR_DOMAIN= _DEF_FORMAT_STATUS */ + bool autoGenerated; /* xmlattr, formatflag:%VIR_DOMAIN= _DEF_FORMAT_STATUS */ }; =20 struct _virDomainGraphicsSDLDef { /* genparse, genformat:separate */ --=20 2.25.1