From nobody Sun Feb 8 17:22:37 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1605612604; cv=none; d=zohomail.com; s=zohoarc; b=iiq7rqcHOSCenN1/e4yM/XZkyUnZRAfXYBW0DPOzGJ5KZWQb2CqAHpswG+5bYKhzTNFCyh9I29zNJ9bSl+XXW+lBJ0hUpFUpi8hcHyNpPvgxI9jojIr6232/s4nbm+If/CvRkcvOpzHr12KDCikIF7SlXRQS4BDbIDvK3Z2RW3g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605612604; 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=Hss0NtfM9L7Fv8RDJKz7sq+nIUh2mZ1Hfjj9RBZ90CI=; b=N7rxNsEYLQyS5SEh7AlNsXtXJhwNx4iGMr+74EECOp/IuSFh5RxjX7JowEwl83/MP/lO4TVRDonc3KfETDmaomMAwJgduNFxr+weqjb8XK2gUBAqkhqLWVi5EK0/+yhHu0g/mmscr7+C6SlYqAhQCyzQakKmgRFp3BXu2df2xJ4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1605612604812389.74971075901976; Tue, 17 Nov 2020 03:30:04 -0800 (PST) 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-360-0al7wcSSPmaoMHFr9i_-rg-1; Tue, 17 Nov 2020 06:29:01 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9918D1007B16; Tue, 17 Nov 2020 11:28:55 +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 72F985D9D2; Tue, 17 Nov 2020 11:28:55 +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 412995813E; Tue, 17 Nov 2020 11:28:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0AHBSc14027278 for ; Tue, 17 Nov 2020 06:28:38 -0500 Received: by smtp.corp.redhat.com (Postfix) id 25F185D9D3; Tue, 17 Nov 2020 11:28:38 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.192.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9B5385D9CC for ; Tue, 17 Nov 2020 11:28:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605612603; h=from:from:sender:sender: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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=Hss0NtfM9L7Fv8RDJKz7sq+nIUh2mZ1Hfjj9RBZ90CI=; b=Rp5wOhvoNsL1mP3Z5RnZZ+DXHEhPpOPEn5UqplqBVZWeu8IW7MW25WqHEEKWXCKmwENRPY fUBk4Yni76TIEb+fgYbpOWrJyQflYT5LdPHEWzb06dG0CsZrglafbW4uFY5Ci9RZZ9Hl0/ eOBSlpxttK8Ap1Wuwhw96sb+xlNK/fI= X-MC-Unique: 0al7wcSSPmaoMHFr9i_-rg-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 5/5] qemu_validate: Deduplicate code for graphics type check Date: Tue, 17 Nov 2020 12:28:27 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Similarly to previous commits, we can utilize domCaps to check if graphics type is supported. Signed-off-by: Michal Privoznik --- src/qemu/qemu_capabilities.c | 2 +- src/qemu/qemu_capabilities.h | 3 +++ src/qemu/qemu_validate.c | 40 ++++++++++++------------------------ 3 files changed, 17 insertions(+), 28 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 7745c968de..0efe5462b5 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -5976,7 +5976,7 @@ virQEMUCapsFillDomainDeviceDiskCaps(virQEMUCapsPtr qe= muCaps, } =20 =20 -static void +void virQEMUCapsFillDomainDeviceGraphicsCaps(virQEMUCapsPtr qemuCaps, virDomainCapsDeviceGraphicsPtr dev) { diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index 0b28c9b635..1194f90140 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -739,6 +739,9 @@ int virQEMUCapsFillDomainCaps(virQEMUCapsPtr qemuCaps, virFirmwarePtr *firmwares, size_t nfirmwares); =20 +void virQEMUCapsFillDomainDeviceGraphicsCaps(virQEMUCapsPtr qemuCaps, + virDomainCapsDeviceGraphicsPt= r dev); + void virQEMUCapsFillDomainDeviceVideoCaps(virQEMUCapsPtr qemuCaps, virDomainCapsDeviceVideoPtr dev); =20 diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index 7e2fe81e08..6ddef3de35 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -3752,12 +3752,6 @@ qemuValidateDomainDeviceDefSPICEGraphics(const virDo= mainGraphicsDef *graphics, virDomainGraphicsListenDefPtr glisten =3D NULL; int tlsPort =3D graphics->data.spice.tlsPort; =20 - if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_SPICE)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("spice graphics are not supported with this QEMU"= )); - return -1; - } - glisten =3D virDomainGraphicsGetListen((virDomainGraphicsDefPtr)graphi= cs, 0); if (!glisten) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", @@ -3823,9 +3817,19 @@ qemuValidateDomainDeviceDefGraphics(const virDomainG= raphicsDef *graphics, virQEMUDriverPtr driver, virQEMUCapsPtr qemuCaps) { + virDomainCapsDeviceGraphics graphicsCaps =3D { 0 }; bool have_egl_headless =3D false; size_t i; =20 + virQEMUCapsFillDomainDeviceGraphicsCaps(qemuCaps, &graphicsCaps); + + if (!VIR_DOMAIN_CAPS_ENUM_IS_SET(graphicsCaps.type, graphics->type)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("%s graphics are not supported with this QEMU"), + virDomainGraphicsTypeToString(graphics->type)); + return -1; + } + for (i =3D 0; i < def->ngraphics; i++) { if (def->graphics[i]->type =3D=3D VIR_DOMAIN_GRAPHICS_TYPE_EGL_HEA= DLESS) { have_egl_headless =3D true; @@ -3838,13 +3842,6 @@ qemuValidateDomainDeviceDefGraphics(const virDomainG= raphicsDef *graphics, * supported by QEMU. */ if (have_egl_headless) { - if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_EGL_HEADLESS)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("egl-headless display is not supported with t= his " - "QEMU binary")); - return -1; - } - if (graphics->type !=3D VIR_DOMAIN_GRAPHICS_TYPE_EGL_HEADLESS && graphics->type !=3D VIR_DOMAIN_GRAPHICS_TYPE_VNC && graphics->type !=3D VIR_DOMAIN_GRAPHICS_TYPE_SPICE) { @@ -3878,14 +3875,6 @@ qemuValidateDomainDeviceDefGraphics(const virDomainG= raphicsDef *graphics, } break; =20 - case VIR_DOMAIN_GRAPHICS_TYPE_VNC: - if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_VNC)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("vnc graphics are not supported with this QEM= U")); - return -1; - } - break; - case VIR_DOMAIN_GRAPHICS_TYPE_SPICE: if (qemuValidateDomainDeviceDefSPICEGraphics(graphics, driver, qemuCaps) < 0) @@ -3903,15 +3892,12 @@ qemuValidateDomainDeviceDefGraphics(const virDomain= GraphicsDef *graphics, } =20 break; + + case VIR_DOMAIN_GRAPHICS_TYPE_VNC: case VIR_DOMAIN_GRAPHICS_TYPE_RDP: case VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP: - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unsupported graphics type '%s'"), - virDomainGraphicsTypeToString(graphics->type)); - return -1; case VIR_DOMAIN_GRAPHICS_TYPE_LAST: - default: - return -1; + break; } =20 return 0; --=20 2.26.2