From nobody Wed Mar 12 17:29:31 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1741263973267952.414533005256; Thu, 6 Mar 2025 04:26:13 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id A519C190D; Thu, 6 Mar 2025 07:26:12 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 4D22418A0; Thu, 6 Mar 2025 07:23:11 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 199FF1853; Thu, 6 Mar 2025 07:23:07 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 98AAA176B for ; Thu, 6 Mar 2025 07:22:49 -0500 (EST) Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-146-9rnqsqukOFychBr_mZYbrg-1; Thu, 06 Mar 2025 07:22:48 -0500 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 407EB18001FA for ; Thu, 6 Mar 2025 12:22:47 +0000 (UTC) Received: from antique-work.redhat.com (unknown [10.44.33.191]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 42E15300019E for ; Thu, 6 Mar 2025 12:22:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1741263769; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=M45kW7ug06fn9Yf8LLXZYaA//K+md0tLzWE0RvqwwoM=; b=KlFCGjFQHClMOxxUmZKq+SFvuY3q46KxIeHccommoKhAl6TBEOSbN8/d+YK22Bdia711pI PfrxVCqONLa3c/AY8ubR8KhpBOiAvNj4lGLikwCM8Z+EgR1b0hcyor6vcsoNJSEvg+f0/4 WwuTcyoAkf3gkDIs+bKuF1aIOLTJg+8= X-MC-Unique: 9rnqsqukOFychBr_mZYbrg-1 X-Mimecast-MFC-AGG-ID: 9rnqsqukOFychBr_mZYbrg_1741263767 From: Pavel Hrdina To: devel@lists.libvirt.org Subject: [libvirt PATCH 11/16] domain_conf: graphics: extract listen formatting to separate function Date: Thu, 6 Mar 2025 13:22:19 +0100 Message-ID: <6c2396a7293329d048e558f3273d1f008f47dcae.1741263715.git.phrdina@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: sU7-kvtWCbfor4AVr_6WjttwCkbY67pzVZqFfhfXdMU_1741263767 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: FBQIOTNLMZOC6K3NJRHBNFQUFI4ASDQ5 X-Message-ID-Hash: FBQIOTNLMZOC6K3NJRHBNFQUFI4ASDQ5 X-MailFrom: phrdina@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1741263973661019000 Content-Type: text/plain; charset="utf-8"; x-default="true" This will be used in specific graphics types that are using listen elements. Signed-off-by: Pavel Hrdina --- src/conf/domain_conf.c | 67 ++++++++++++++++++++++++------------------ 1 file changed, 39 insertions(+), 28 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 81068570a0..d39b885101 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -26328,6 +26328,44 @@ virDomainGraphicsListenDefFormat(virBuffer *buf, } =20 =20 +static void +virDomainGraphicsDefFormatListnes(virBuffer *childBuf, + virDomainGraphicsDef *def, + unsigned int flags) +{ + size_t i; + + 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; + + /* 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; + } + virDomainGraphicsListenDefFormat(childBuf, &def->listens[i], flags= ); + } +} + + /** * virDomainGraphicsListenDefFormatAddr: * @buf: buffer where the output XML is written @@ -26643,34 +26681,7 @@ virDomainGraphicsDefFormat(virBuffer *buf, break; } =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; - - /* 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; - } - virDomainGraphicsListenDefFormat(&childBuf, &def->listens[i], flag= s); - } + virDomainGraphicsDefFormatListnes(&childBuf, def, flags); =20 if (def->type =3D=3D VIR_DOMAIN_GRAPHICS_TYPE_SPICE) { g_auto(virBuffer) spiceBuf =3D VIR_BUFFER_INITIALIZER; --=20 2.48.1