From nobody Tue Sep 9 23:53:10 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 1738158310510403.498571479636; Wed, 29 Jan 2025 05:45:10 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id C2D601884; Wed, 29 Jan 2025 08:45:09 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 0CC121756; Wed, 29 Jan 2025 08:42:00 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 0BCD61780; Wed, 29 Jan 2025 08:41:55 -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 B94A61651 for ; Wed, 29 Jan 2025 08:41:42 -0500 (EST) Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-492-CKD2Edd2NQC3Zb7O_3ndtQ-1; Wed, 29 Jan 2025 08:41:41 -0500 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 377E6195608D for ; Wed, 29 Jan 2025 13:41:40 +0000 (UTC) Received: from localhost (unknown [10.39.208.35]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id CC743180035E; Wed, 29 Jan 2025 13:41:38 +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=1738158102; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VCjrQ92zwRMRw+wz3XdNBNxYp0hh7WA2OPf2P/Vo1Wg=; b=CEkcP0dSyTMK4XbvQwb4ttnzC7RQOGbbxM5BKVSgsvWVa2BAw9VGVlGGGstAAtcqvG8u74 tjzAQrxwO9C8C1X2RCyLkgi6x8Cwk6F9E9ymam/onjxWMFquH4gfLG1PPRbtnX0D96Ey18 cITEMBL8H8qnkGTbpE9IL/dsj0/OZws= X-MC-Unique: CKD2Edd2NQC3Zb7O_3ndtQ-1 X-Mimecast-MFC-AGG-ID: CKD2Edd2NQC3Zb7O_3ndtQ From: marcandre.lureau@redhat.com To: devel@lists.libvirt.org Subject: [PATCH 09/19] conf: generalize virDomainDefHasSpiceGraphics Date: Wed, 29 Jan 2025 17:40:31 +0400 Message-ID: <20250129134042.1282472-10-marcandre.lureau@redhat.com> In-Reply-To: <20250129134042.1282472-1-marcandre.lureau@redhat.com> References: <20250129134042.1282472-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: wfyDVYsrNRoVZGoc0fx75wcWwZA2FbqBA72RLr_KaGk_1738158100 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: VUAGTKWWA5H536SOJCUUIX6TVE3YPGMH X-Message-ID-Hash: VUAGTKWWA5H536SOJCUUIX6TVE3YPGMH X-MailFrom: marcandre.lureau@redhat.com X-Mailman-Rule-Hits: nonmember-moderation 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 CC: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= 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: 1738158310796019000 Content-Type: text/plain; charset="utf-8" From: Marc-Andr=C3=A9 Lureau Generalize the function, broaden its potential usage. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Daniel P. Berrang=C3=A9 --- src/conf/domain_conf.c | 15 ++++++++++++--- src/conf/domain_conf.h | 2 +- src/libvirt_private.syms | 2 +- src/qemu/qemu_validate.c | 4 ++-- 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 35dbb13106..78878a9685 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -31747,15 +31747,24 @@ virDomainObjGetMessages(virDomainObj *vm, return rv; } =20 + +/** + * virDomainDefHasGraphics: + * @def: domain definition + * @type: a graphics type + * + * Returns true if domain has a graphics of given type. + */ bool -virDomainDefHasSpiceGraphics(const virDomainDef *def) +virDomainDefHasGraphics(const virDomainDef *def, virDomainGraphicsType typ= e) { size_t i =3D 0; =20 for (i =3D 0; i < def->ngraphics; i++) { - if (def->graphics[i]->type =3D=3D VIR_DOMAIN_GRAPHICS_TYPE_SPICE) { + virDomainGraphicsDef *graphics =3D def->graphics[i]; + + if (graphics->type =3D=3D type) return true; - } } =20 return false; diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index e5c2c2157c..b08e2549b7 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -4596,4 +4596,4 @@ virDomainObjGetMessages(virDomainObj *vm, unsigned int flags); =20 bool -virDomainDefHasSpiceGraphics(const virDomainDef *def); +virDomainDefHasGraphics(const virDomainDef *def, virDomainGraphicsType typ= e); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 2fe0a07944..987947975b 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -337,6 +337,7 @@ virDomainDefGetVcpus; virDomainDefGetVcpusMax; virDomainDefGetVcpusTopology; virDomainDefHasDeviceAddress; +virDomainDefHasGraphics; virDomainDefHasManagedPR; virDomainDefHasMdevHostdev; virDomainDefHasMemballoon; @@ -345,7 +346,6 @@ virDomainDefHasNVMeDisk; virDomainDefHasOldStyleROUEFI; virDomainDefHasOldStyleUEFI; virDomainDefHasPCIHostdev; -virDomainDefHasSpiceGraphics; virDomainDefHasUSB; virDomainDefHasVcpusOffline; virDomainDefHasVDPANet; diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index 07a505d106..54226b8c62 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -2097,7 +2097,7 @@ qemuValidateDomainChrSourceDef(const virDomainChrSour= ceDef *def, =20 case VIR_DOMAIN_CHR_TYPE_SPICEVMC: case VIR_DOMAIN_CHR_TYPE_SPICEPORT: - if (!virDomainDefHasSpiceGraphics(vmdef)) { + if (!virDomainDefHasGraphics(vmdef, VIR_DOMAIN_GRAPHICS_TYPE_SPICE= )) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("chardev '%1$s' not supported without spice g= raphics"), virDomainChrTypeToString(def->type)); @@ -4656,7 +4656,7 @@ qemuValidateDomainDeviceDefAudio(virDomainAudioDef *a= udio, break; =20 case VIR_DOMAIN_AUDIO_TYPE_SPICE: - if (!virDomainDefHasSpiceGraphics(def)) { + if (!virDomainDefHasGraphics(def, VIR_DOMAIN_GRAPHICS_TYPE_SPICE))= { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("Spice audio is not supported without spice g= raphics")); return -1; --=20 2.47.0