From nobody Fri May 10 11:58:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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 170.10.129.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=1645735673; cv=none; d=zohomail.com; s=zohoarc; b=SNKBfOVVR6Du0RnMTN5FhKJGkAGIgVF+kTiPOI/Ng8FuKIkkCOxkQL36eOCXWqJCEhOUosZquJiLZ/BYRRESNbXhQZXuTXT3k2DfcOccwAuOB9tbKNLm8+slkHBYoJpipgK8jkUxqaSXzc1dyTxcyoHvpNQcd15NPyx3vjOxBG4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1645735673; 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=ecwfhl7HC9fiYbFQ5GUNZqOLlMjRSQeQ8fsKdPH5rjQ=; b=Q/qghHY/WcZa4OCiSOtOOFnHXSrHwoTZ/IizvkwtbF8UNlGF5nOgbqg75709n2rvG3N+S+wGcEICDe0J8E1Zi4OO3BdFvykKQrzOxO85SEXZ17rv8uaRAIHl3uR6oKkBFfrEboQ6PGoXf5Dss5D616SOR/FdZl7xhZlph9itJek= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1645735673638629.0605221637683; Thu, 24 Feb 2022 12:47:53 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-75-fp-viI14NEO8GorbK7gc_w-1; Thu, 24 Feb 2022 15:47:49 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D4A3380D6AC; Thu, 24 Feb 2022 20:47:43 +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 B37C24CECD; Thu, 24 Feb 2022 20:47:43 +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 297C14A701; Thu, 24 Feb 2022 20:47:43 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 21OKlfHN007894 for ; Thu, 24 Feb 2022 15:47:41 -0500 Received: by smtp.corp.redhat.com (Postfix) id 28E1A6ABA7; Thu, 24 Feb 2022 20:47:41 +0000 (UTC) Received: from himantopus.redhat.com (unknown [10.22.33.139]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D69066ABAC for ; Thu, 24 Feb 2022 20:47:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1645735672; 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=ecwfhl7HC9fiYbFQ5GUNZqOLlMjRSQeQ8fsKdPH5rjQ=; b=PkyQdKVD2ZR2+/3UfhUmG5kLXAw4P+fe35Hz+PnUV0OmZ9gGW+UBMMViwsy5O+SVzxTQNy ld8uuKuEuq/4z5gWv5xuW1KGKMDfBj0nm0EFnY1KEKdRsaBcDnYr954bfvEd7aUb7qB0rs LcuV4DhKNWlhsMKVMldCwHAo2hxydqs= X-MC-Unique: fp-viI14NEO8GorbK7gc_w-1 From: Jonathon Jongsma To: libvir-list@redhat.com Subject: [libvirt PATCH v2 1/6] conf: Refactor video model parsing Date: Thu, 24 Feb 2022 14:47:30 -0600 Message-Id: <20220224204735.684086-2-jjongsma@redhat.com> In-Reply-To: <20220224204735.684086-1-jjongsma@redhat.com> References: <20220224204735.684086-1-jjongsma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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.15 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) X-ZM-MESSAGEID: 1645735675493100001 Content-Type: text/plain; charset="utf-8" Factor out a separate function to parse out the element for video devices. Signed-off-by: Jonathon Jongsma --- src/conf/domain_conf.c | 95 ++++++++++++++++++++++++++---------------- 1 file changed, 59 insertions(+), 36 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 34fec887a3..1d0698d9fe 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -14067,17 +14067,13 @@ virDomainVideoDriverDefParseXML(xmlNodePtr node, return g_steal_pointer(&def); } =20 -static virDomainVideoDef * -virDomainVideoDefParseXML(virDomainXMLOption *xmlopt, - xmlNodePtr node, - xmlXPathContextPtr ctxt, - unsigned int flags) +static int +virDomainVideoModelDefParseXML(virDomainVideoDef *def, + xmlNodePtr node, + xmlXPathContextPtr ctxt) { - g_autoptr(virDomainVideoDef) def =3D NULL; - xmlNodePtr driver; xmlNodePtr accel_node; xmlNodePtr res_node; - VIR_XPATH_NODE_AUTORESTORE(ctxt) g_autofree char *type =3D NULL; g_autofree char *heads =3D NULL; g_autofree char *vram =3D NULL; @@ -14086,81 +14082,108 @@ virDomainVideoDefParseXML(virDomainXMLOption *xm= lopt, g_autofree char *vgamem =3D NULL; g_autofree char *primary =3D NULL; =20 - if (!(def =3D virDomainVideoDefNew(xmlopt))) - return NULL; - + VIR_XPATH_NODE_AUTORESTORE(ctxt); ctxt->node =3D node; =20 - if ((primary =3D virXPathString("string(./model/@primary)", ctxt)) != =3D NULL) + if ((primary =3D virXPathString("string(./@primary)", ctxt)) !=3D NULL) ignore_value(virStringParseYesNo(primary, &def->primary)); =20 - if ((accel_node =3D virXPathNode("./model/acceleration", ctxt)) && + if ((accel_node =3D virXPathNode("./acceleration", ctxt)) && (def->accel =3D virDomainVideoAccelDefParseXML(accel_node)) =3D=3D= NULL) - return NULL; + return -1; =20 - if ((res_node =3D virXPathNode("./model/resolution", ctxt)) && + if ((res_node =3D virXPathNode("./resolution", ctxt)) && (def->res =3D virDomainVideoResolutionDefParseXML(res_node)) =3D= =3D NULL) - return NULL; + return -1; =20 - if ((driver =3D virXPathNode("./driver", ctxt))) { - if (virXMLPropEnum(driver, "name", - virDomainVideoBackendTypeFromString, - VIR_XML_PROP_NONZERO, &def->backend) < 0) - return NULL; - if (virDomainVirtioOptionsParseXML(driver, &def->virtio) < 0) - return NULL; - } =20 - if ((type =3D virXPathString("string(./model/@type)", ctxt))) { + + if ((type =3D virXPathString("string(./@type)", ctxt))) { if ((def->type =3D virDomainVideoTypeFromString(type)) < 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown video model '%s'"), type); - return NULL; + return -1; } } else { def->type =3D VIR_DOMAIN_VIDEO_TYPE_DEFAULT; } =20 - if ((ram =3D virXPathString("string(./model/@ram)", ctxt))) { + if ((ram =3D virXPathString("string(./@ram)", ctxt))) { if (virStrToLong_uip(ram, NULL, 10, &def->ram) < 0) { virReportError(VIR_ERR_XML_ERROR, _("cannot parse video ram '%s'"), ram); - return NULL; + return -1; } } =20 - if ((vram =3D virXPathString("string(./model/@vram)", ctxt))) { + if ((vram =3D virXPathString("string(./@vram)", ctxt))) { if (virStrToLong_uip(vram, NULL, 10, &def->vram) < 0) { virReportError(VIR_ERR_XML_ERROR, _("cannot parse video vram '%s'"), vram); - return NULL; + return -1; } } =20 - if ((vram64 =3D virXPathString("string(./model/@vram64)", ctxt))) { + if ((vram64 =3D virXPathString("string(./@vram64)", ctxt))) { if (virStrToLong_uip(vram64, NULL, 10, &def->vram64) < 0) { virReportError(VIR_ERR_XML_ERROR, _("cannot parse video vram64 '%s'"), vram64); - return NULL; + return -1; } } =20 - if ((vgamem =3D virXPathString("string(./model/@vgamem)", ctxt))) { + if ((vgamem =3D virXPathString("string(./@vgamem)", ctxt))) { if (virStrToLong_uip(vgamem, NULL, 10, &def->vgamem) < 0) { virReportError(VIR_ERR_XML_ERROR, _("cannot parse video vgamem '%s'"), vgamem); - return NULL; + return -1; } } =20 - if ((heads =3D virXPathString("string(./model/@heads)", ctxt))) { + if ((heads =3D virXPathString("string(./@heads)", ctxt))) { if (virStrToLong_uip(heads, NULL, 10, &def->heads) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("cannot parse video heads '%s'"), heads); - return NULL; + return -1; } } =20 + return 0; +} + +static virDomainVideoDef * +virDomainVideoDefParseXML(virDomainXMLOption *xmlopt, + xmlNodePtr node, + xmlXPathContextPtr ctxt, + unsigned int flags) +{ + g_autoptr(virDomainVideoDef) def =3D NULL; + xmlNodePtr driver; + xmlNodePtr model; + + VIR_XPATH_NODE_AUTORESTORE(ctxt) + + if (!(def =3D virDomainVideoDefNew(xmlopt))) + return NULL; + + ctxt->node =3D node; + + if ((model =3D virXPathNode("./model", ctxt))) { + if (virDomainVideoModelDefParseXML(def, model, ctxt) < 0) + return NULL; + } else { + def->type =3D VIR_DOMAIN_VIDEO_TYPE_DEFAULT; + } + + if ((driver =3D virXPathNode("./driver", ctxt))) { + if (virXMLPropEnum(driver, "name", + virDomainVideoBackendTypeFromString, + VIR_XML_PROP_NONZERO, &def->backend) < 0) + return NULL; + if (virDomainVirtioOptionsParseXML(driver, &def->virtio) < 0) + return NULL; + } + if (virDomainDeviceInfoParseXML(xmlopt, node, ctxt, &def->info, flags)= < 0) return NULL; =20 --=20 2.35.1 From nobody Fri May 10 11:58:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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 170.10.133.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=1645735686; cv=none; d=zohomail.com; s=zohoarc; b=O9WPyS4wEMdN+MFFOS5AY2UAalv+dxcrNK42WnvB547lG48wZoCygYc6W1SjkhjMVVf2bnV23yGbsVdtTxMKKcpfQaHykOL4vfuvAxZCSalSqc6HmNQVpPWNLyrvIKF2fZrO5mvsHZPEv1GyVpQqi0Q1Cb/3GWLN++s32ZEDlfU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1645735686; 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=gzZn2JV4FkMmc0ovzc8Sly9FdC91WcHDrwRg9gHJdG4=; b=feXfI/uu/fZYUtsrqY4CMdVdARrNp0MlacF09HquFCezJsHNc52rXgP1n57gay9a+g4F75MIALq0d3CRVfDaPYGnZn01QD2sGR6RyWEnJy4+6HKHI9S/Gq/vTyh8z28+V1uEX8vLEYUZ10F/cM7Ka4Uhwr8RbUsokfzD9b6ZqEQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1645735686116641.6254059561126; Thu, 24 Feb 2022 12:48:06 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-628-XrJVMg_CPRqd9QGtfrEASQ-1; Thu, 24 Feb 2022 15:48:01 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BCDC31091DA1; Thu, 24 Feb 2022 20:47:56 +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 6BC584CED9; Thu, 24 Feb 2022 20:47:56 +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 392231809CB5; Thu, 24 Feb 2022 20:47:56 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 21OKlfbn007899 for ; Thu, 24 Feb 2022 15:47:41 -0500 Received: by smtp.corp.redhat.com (Postfix) id 9D2056ABA9; Thu, 24 Feb 2022 20:47:41 +0000 (UTC) Received: from himantopus.redhat.com (unknown [10.22.33.139]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 565B16ABA7 for ; Thu, 24 Feb 2022 20:47:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1645735685; 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=gzZn2JV4FkMmc0ovzc8Sly9FdC91WcHDrwRg9gHJdG4=; b=izjWnKfBq0n3wXUaQX91oYO8hc88lAlNIx0s6to20FQoJZk2fuArVOklmB6UNwoeauBS2r /Yr/RB7UFiGyqDrXsCCZRKHS11B6DZDiwha5O22rhJYL6PHNVhYdg0rCMCIlPcU8likrZ7 5wd8BPgm/l++YvjJMLxqfkI4uY8fIVM= X-MC-Unique: XrJVMg_CPRqd9QGtfrEASQ-1 From: Jonathon Jongsma To: libvir-list@redhat.com Subject: [libvirt PATCH v2 2/6] conf: switch to virXMLProp* functions Date: Thu, 24 Feb 2022 14:47:31 -0600 Message-Id: <20220224204735.684086-3-jjongsma@redhat.com> In-Reply-To: <20220224204735.684086-1-jjongsma@redhat.com> References: <20220224204735.684086-1-jjongsma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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.15 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) X-ZM-MESSAGEID: 1645735687600100003 Content-Type: text/plain; charset="utf-8" In virDomainVideoModelDefParseXML(), use the virXMLProp* functions rather than reimplementing them with virXPath* functions. Signed-off-by: Jonathon Jongsma --- src/conf/domain_conf.c | 78 +++++++++++++----------------------------- 1 file changed, 23 insertions(+), 55 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 1d0698d9fe..3a97358a11 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -14074,19 +14074,15 @@ virDomainVideoModelDefParseXML(virDomainVideoDef = *def, { xmlNodePtr accel_node; xmlNodePtr res_node; - g_autofree char *type =3D NULL; - g_autofree char *heads =3D NULL; - g_autofree char *vram =3D NULL; - g_autofree char *vram64 =3D NULL; - g_autofree char *ram =3D NULL; - g_autofree char *vgamem =3D NULL; - g_autofree char *primary =3D NULL; + virDomainVideoType type; + virTristateBool primary; + int rc =3D 0; =20 VIR_XPATH_NODE_AUTORESTORE(ctxt); ctxt->node =3D node; =20 - if ((primary =3D virXPathString("string(./@primary)", ctxt)) !=3D NULL) - ignore_value(virStringParseYesNo(primary, &def->primary)); + if (virXMLPropTristateBool(node, "primary", VIR_XML_PROP_NONE, &primar= y) >=3D 0) + def->primary =3D (primary =3D=3D VIR_TRISTATE_BOOL_YES); =20 if ((accel_node =3D virXPathNode("./acceleration", ctxt)) && (def->accel =3D virDomainVideoAccelDefParseXML(accel_node)) =3D=3D= NULL) @@ -14096,57 +14092,29 @@ virDomainVideoModelDefParseXML(virDomainVideoDef = *def, (def->res =3D virDomainVideoResolutionDefParseXML(res_node)) =3D= =3D NULL) return -1; =20 + if (virXMLPropEnumDefault(node, "type", + virDomainVideoTypeFromString, + VIR_XML_PROP_NONE, &type, + VIR_DOMAIN_VIDEO_TYPE_DEFAULT) < 0) + return -1; + def->type =3D type; =20 + if (virXMLPropUInt(node, "ram", 10, VIR_XML_PROP_NONE, &def->ram) < 0) + return -1; =20 - if ((type =3D virXPathString("string(./@type)", ctxt))) { - if ((def->type =3D virDomainVideoTypeFromString(type)) < 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown video model '%s'"), type); - return -1; - } - } else { - def->type =3D VIR_DOMAIN_VIDEO_TYPE_DEFAULT; - } - - if ((ram =3D virXPathString("string(./@ram)", ctxt))) { - if (virStrToLong_uip(ram, NULL, 10, &def->ram) < 0) { - virReportError(VIR_ERR_XML_ERROR, - _("cannot parse video ram '%s'"), ram); - return -1; - } - } - - if ((vram =3D virXPathString("string(./@vram)", ctxt))) { - if (virStrToLong_uip(vram, NULL, 10, &def->vram) < 0) { - virReportError(VIR_ERR_XML_ERROR, - _("cannot parse video vram '%s'"), vram); - return -1; - } - } + if (virXMLPropUInt(node, "vram", 10, VIR_XML_PROP_NONE, &def->vram) < = 0) + return -1; =20 - if ((vram64 =3D virXPathString("string(./@vram64)", ctxt))) { - if (virStrToLong_uip(vram64, NULL, 10, &def->vram64) < 0) { - virReportError(VIR_ERR_XML_ERROR, - _("cannot parse video vram64 '%s'"), vram64); - return -1; - } - } + if (virXMLPropUInt(node, "vram64", 10, VIR_XML_PROP_NONE, &def->vram64= ) < 0) + return -1; =20 - if ((vgamem =3D virXPathString("string(./@vgamem)", ctxt))) { - if (virStrToLong_uip(vgamem, NULL, 10, &def->vgamem) < 0) { - virReportError(VIR_ERR_XML_ERROR, - _("cannot parse video vgamem '%s'"), vgamem); - return -1; - } - } + if (virXMLPropUInt(node, "vgamem", 10, VIR_XML_PROP_NONE, &def->vgamem= ) < 0) + return -1; =20 - if ((heads =3D virXPathString("string(./@heads)", ctxt))) { - if (virStrToLong_uip(heads, NULL, 10, &def->heads) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("cannot parse video heads '%s'"), heads); - return -1; - } - } + if ((rc =3D virXMLPropUInt(node, "heads", 10, VIR_XML_PROP_NONE, &def-= >heads)) < 0) + return -1; + else if (rc =3D=3D 0) + def->heads =3D 1; =20 return 0; } --=20 2.35.1 From nobody Fri May 10 11:58:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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 170.10.133.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=1645735757; cv=none; d=zohomail.com; s=zohoarc; b=LdVEwbuiNnqk7D9224ux9iPHoEGjKN1od7cUVvT2zNrS2WBmECtG3xfP9oo7gH+T9O3IxHtR4+02mVJsLD/I84Uh8s+8QhFLSAn4ZMLGdPBG5IIaAtlIEpWg7KcwJumHb/XlKNW6ELmT8oWoGdvUP8t2+Z6LM3kDS3Qjc6geKaU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1645735757; 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=9diLLBc/pJxesv/3feUKO3vbBbXSG3hmTe5F6OveQRc=; b=PZRskxO+tDc+cWNDHVNgyvdlQwoNRCMcvsenfcIg7+fHluahSiFp8566Tc3voiR5ASPUhtgQ6HvSRCW88k10vu7/8RBwHw0iz1At9kH14hVoKIzykoN9mDwxdd093t5buhTCk+OerSVSJMAWhV5xu8MJDPGAf14KSn770HjHD8w= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1645735757825219.7378113377722; Thu, 24 Feb 2022 12:49:17 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-137-V_c4_rpPPqSeoYyUCu4HPA-1; Thu, 24 Feb 2022 15:48:02 -0500 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 08C991091DA0; Thu, 24 Feb 2022 20:47:57 +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 AEDB35BC3D; Thu, 24 Feb 2022 20:47:56 +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 42C9318087F1; Thu, 24 Feb 2022 20:47:56 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 21OKlg7x007904 for ; Thu, 24 Feb 2022 15:47:42 -0500 Received: by smtp.corp.redhat.com (Postfix) id 1D1B66ABA9; Thu, 24 Feb 2022 20:47:42 +0000 (UTC) Received: from himantopus.redhat.com (unknown [10.22.33.139]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C9D626ABA7 for ; Thu, 24 Feb 2022 20:47:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1645735756; 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=9diLLBc/pJxesv/3feUKO3vbBbXSG3hmTe5F6OveQRc=; b=dZ5nGUhhTuZuCjXO/HD5c9F9pFdQ94WWDqm/AM5uUqGJSXnaqmaKLBb/Kr+EfJ1dOzyYjM MmXr9gSjFQV4/wcT5la4uYJMxKNOBAS+iyefoouDj8f7urOKsSBYb3lDL//Fe6ImH3W5af ukp4PF3D0lI+2r0zAjQ1Og7UoddqoVE= X-MC-Unique: V_c4_rpPPqSeoYyUCu4HPA-1 From: Jonathon Jongsma To: libvir-list@redhat.com Subject: [libvirt PATCH v2 3/6] conf: use enum variable for video type Date: Thu, 24 Feb 2022 14:47:32 -0600 Message-Id: <20220224204735.684086-4-jjongsma@redhat.com> In-Reply-To: <20220224204735.684086-1-jjongsma@redhat.com> References: <20220224204735.684086-1-jjongsma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1645735759945100001 Content-Type: text/plain; charset="utf-8" Rather than storing the video type as an integer, use the proper enum type within the struct. Signed-off-by: Jonathon Jongsma --- src/conf/domain_conf.c | 4 +--- src/conf/domain_conf.h | 2 +- src/libxl/libxl_conf.c | 10 ++++++++++ src/libxl/libxl_domain.c | 11 +++++++++++ src/qemu/qemu_monitor_json.c | 16 +++++++++++++++- src/qemu/qemu_process.c | 7 +++++++ 6 files changed, 45 insertions(+), 5 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 3a97358a11..39aa6a1058 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -14074,7 +14074,6 @@ virDomainVideoModelDefParseXML(virDomainVideoDef *d= ef, { xmlNodePtr accel_node; xmlNodePtr res_node; - virDomainVideoType type; virTristateBool primary; int rc =3D 0; =20 @@ -14094,10 +14093,9 @@ virDomainVideoModelDefParseXML(virDomainVideoDef *= def, =20 if (virXMLPropEnumDefault(node, "type", virDomainVideoTypeFromString, - VIR_XML_PROP_NONE, &type, + VIR_XML_PROP_NONE, &def->type, VIR_DOMAIN_VIDEO_TYPE_DEFAULT) < 0) return -1; - def->type =3D type; =20 if (virXMLPropUInt(node, "ram", 10, VIR_XML_PROP_NONE, &def->ram) < 0) return -1; diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 9fcf842ee7..fa64491978 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1727,7 +1727,7 @@ struct _virDomainVideoDriverDef { struct _virDomainVideoDef { virObject *privateData; =20 - int type; /* enum virDomainVideoType */ + virDomainVideoType type; unsigned int ram; /* kibibytes (multiples of 1024) */ unsigned int vram; /* kibibytes (multiples of 1024) */ unsigned int vram64; /* kibibytes (multiples of 1024) */ diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c index a0fc51c74a..1a608960b1 100644 --- a/src/libxl/libxl_conf.c +++ b/src/libxl/libxl_conf.c @@ -2364,6 +2364,16 @@ libxlMakeVideo(virDomainDef *def, libxl_domain_confi= g *d_config) } break; =20 + case VIR_DOMAIN_VIDEO_TYPE_DEFAULT: + case VIR_DOMAIN_VIDEO_TYPE_VMVGA: + case VIR_DOMAIN_VIDEO_TYPE_VBOX: + case VIR_DOMAIN_VIDEO_TYPE_PARALLELS: + case VIR_DOMAIN_VIDEO_TYPE_VIRTIO: + case VIR_DOMAIN_VIDEO_TYPE_GOP: + case VIR_DOMAIN_VIDEO_TYPE_NONE: + case VIR_DOMAIN_VIDEO_TYPE_BOCHS: + case VIR_DOMAIN_VIDEO_TYPE_RAMFB: + case VIR_DOMAIN_VIDEO_TYPE_LAST: default: virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("video type %s is not supported by libxl"), diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c index ee031267ca..d4ba030c2a 100644 --- a/src/libxl/libxl_domain.c +++ b/src/libxl/libxl_domain.c @@ -331,6 +331,17 @@ libxlDomainDeviceDefPostParse(virDomainDeviceDef *dev, if (dev->data.video->vram =3D=3D 0) dev->data.video->vram =3D 128 * 1024; break; + case VIR_DOMAIN_VIDEO_TYPE_DEFAULT: + case VIR_DOMAIN_VIDEO_TYPE_VMVGA: + case VIR_DOMAIN_VIDEO_TYPE_VBOX: + case VIR_DOMAIN_VIDEO_TYPE_PARALLELS: + case VIR_DOMAIN_VIDEO_TYPE_VIRTIO: + case VIR_DOMAIN_VIDEO_TYPE_GOP: + case VIR_DOMAIN_VIDEO_TYPE_NONE: + case VIR_DOMAIN_VIDEO_TYPE_BOCHS: + case VIR_DOMAIN_VIDEO_TYPE_RAMFB: + case VIR_DOMAIN_VIDEO_TYPE_LAST: + break; } } } diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 4d339f29b8..791463e2bb 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -1897,9 +1897,16 @@ qemuMonitorJSONUpdateVideoMemorySize(qemuMonitor *mo= n, } video->vram =3D prop.val.ul * 1024; break; + case VIR_DOMAIN_VIDEO_TYPE_DEFAULT: case VIR_DOMAIN_VIDEO_TYPE_CIRRUS: case VIR_DOMAIN_VIDEO_TYPE_XEN: case VIR_DOMAIN_VIDEO_TYPE_VBOX: + case VIR_DOMAIN_VIDEO_TYPE_PARALLELS: + case VIR_DOMAIN_VIDEO_TYPE_VIRTIO: + case VIR_DOMAIN_VIDEO_TYPE_GOP: + case VIR_DOMAIN_VIDEO_TYPE_NONE: + case VIR_DOMAIN_VIDEO_TYPE_BOCHS: + case VIR_DOMAIN_VIDEO_TYPE_RAMFB: case VIR_DOMAIN_VIDEO_TYPE_LAST: break; } @@ -1937,11 +1944,18 @@ qemuMonitorJSONUpdateVideoVram64Size(qemuMonitor *m= on, video->vram64 =3D prop.val.ul * 1024; } break; + case VIR_DOMAIN_VIDEO_TYPE_DEFAULT: case VIR_DOMAIN_VIDEO_TYPE_VGA: - case VIR_DOMAIN_VIDEO_TYPE_VMVGA: case VIR_DOMAIN_VIDEO_TYPE_CIRRUS: + case VIR_DOMAIN_VIDEO_TYPE_VMVGA: case VIR_DOMAIN_VIDEO_TYPE_XEN: case VIR_DOMAIN_VIDEO_TYPE_VBOX: + case VIR_DOMAIN_VIDEO_TYPE_PARALLELS: + case VIR_DOMAIN_VIDEO_TYPE_VIRTIO: + case VIR_DOMAIN_VIDEO_TYPE_GOP: + case VIR_DOMAIN_VIDEO_TYPE_NONE: + case VIR_DOMAIN_VIDEO_TYPE_BOCHS: + case VIR_DOMAIN_VIDEO_TYPE_RAMFB: case VIR_DOMAIN_VIDEO_TYPE_LAST: break; } diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 5af925e521..bdb213b7c8 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -3097,9 +3097,16 @@ qemuProcessUpdateVideoRamSize(virQEMUDriver *driver, goto error; } break; + case VIR_DOMAIN_VIDEO_TYPE_DEFAULT: case VIR_DOMAIN_VIDEO_TYPE_CIRRUS: case VIR_DOMAIN_VIDEO_TYPE_XEN: case VIR_DOMAIN_VIDEO_TYPE_VBOX: + case VIR_DOMAIN_VIDEO_TYPE_PARALLELS: + case VIR_DOMAIN_VIDEO_TYPE_VIRTIO: + case VIR_DOMAIN_VIDEO_TYPE_GOP: + case VIR_DOMAIN_VIDEO_TYPE_NONE: + case VIR_DOMAIN_VIDEO_TYPE_BOCHS: + case VIR_DOMAIN_VIDEO_TYPE_RAMFB: case VIR_DOMAIN_VIDEO_TYPE_LAST: break; } --=20 2.35.1 From nobody Fri May 10 11:58:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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 170.10.129.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=1645735673; cv=none; d=zohomail.com; s=zohoarc; b=GqSA0fi3nagO/w2JmTZzp2UXQilH1ZBbb2s38RcVRJzufdcjd7KxQmbBLwT+uh8YgUNxpfyzRjJGWxJI+TA2/6hyEdSODgZS2uA11wbg5llbkJOXLIFmnmMX97zwkZOOhJcB5X+XB8yRgxbwq7U2KyDTHwAFAdordyo6O8aIrTw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1645735673; 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=XBD6p9kvCBPHS9VdohIfXr0B+iwL6sq8Q5IDVGsr61w=; b=UJpLu4RwQ+aPeHsjVtQNY/R3g7DfXUMkkUnXiSdfmMoM5IVB0WxjibdwPFIlj5pGcZ8iPXsyDysJR7Z8+GbxoKbR7KOixD1zO1U3oYDF9CLp2EgPmWSeniyDbvoH/JTOZYyQIbreGiNmas+jpei2iNjyh9rXqefNQIbrryrl/Ng= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1645735673721561.8049365613144; Thu, 24 Feb 2022 12:47:53 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-37-nzonmUDLNoGESt4SguBr8g-1; Thu, 24 Feb 2022 15:47:49 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 034BC1854E26; Thu, 24 Feb 2022 20:47:44 +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 B94FC45CA6; Thu, 24 Feb 2022 20:47:43 +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 5E08B4EA37; Thu, 24 Feb 2022 20:47:43 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 21OKlgkt007912 for ; Thu, 24 Feb 2022 15:47:42 -0500 Received: by smtp.corp.redhat.com (Postfix) id 910FA6ABA9; Thu, 24 Feb 2022 20:47:42 +0000 (UTC) Received: from himantopus.redhat.com (unknown [10.22.33.139]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4AC016ABA7 for ; Thu, 24 Feb 2022 20:47:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1645735672; 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=XBD6p9kvCBPHS9VdohIfXr0B+iwL6sq8Q5IDVGsr61w=; b=hwQoWJ5UIa6m7xDnAnzyr9Ks+wHR9KvPGkkohS0LJBv5qLerHCMmRHFBJ8mbzH6V42mHqe tHxt7TO2EQjHlCSR1ggObMeZOPBFY93UOB96mwCpxM4CjNTy3kq8UgRzZl6Yd/NNkmj+aG srIpkwIeh82L3kCVeRF3ePthed1q3l8= X-MC-Unique: nzonmUDLNoGESt4SguBr8g-1 From: Jonathon Jongsma To: libvir-list@redhat.com Subject: [libvirt PATCH v2 4/6] conf: add support for 'blob' in virtio video device Date: Thu, 24 Feb 2022 14:47:33 -0600 Message-Id: <20220224204735.684086-5-jjongsma@redhat.com> In-Reply-To: <20220224204735.684086-1-jjongsma@redhat.com> References: <20220224204735.684086-1-jjongsma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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.13 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) X-ZM-MESSAGEID: 1645735675502100002 Content-Type: text/plain; charset="utf-8" Add the ability to enable blob resources for the virtio video device. This will accelerate the display path due to less or no copying of pixel data. Blob resource support can be enabled with e.g.: Some additional background information about blob resources: https://lists.freedesktop.org/archives/dri-devel/2020-August/275972.html https://www.kraxel.org/blog/2021/05/virtio-gpu-qemu-graphics-update/ Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=3D2032406 Signed-off-by: Jonathon Jongsma --- docs/formatdomain.rst | 6 ++++++ docs/schemas/domaincommon.rng | 5 +++++ src/conf/domain_conf.c | 6 ++++++ src/conf/domain_conf.h | 1 + src/conf/domain_validate.c | 13 ++++++++++--- 5 files changed, 28 insertions(+), 3 deletions(-) diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst index 9202cd3107..62edcea7a7 100644 --- a/docs/formatdomain.rst +++ b/docs/formatdomain.rst @@ -6239,6 +6239,12 @@ A video device. :since:`since 1.3.3` ) extends secondary bar and makes it addressable as 64bit memory. =20 + :since:`Since 8.1.0`, devices with type "virtio" have an optional ``blo= b`` + attribute that can be set to "on" or "off". Setting ``blob`` to "on" wi= ll + enable the use of blob resources in the device. This can accelerate the + display path by reducing or eliminating copying of pixel data between t= he + guest and host. + :since:`Since 5.9.0` , the ``model`` element may also have an optional ``resolution`` sub-element. The ``resolution`` element has attributes `= `x`` and ``y`` to set the minimum resolution for the video device. This diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 964b0c9e2f..372376820a 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -4191,6 +4191,11 @@ + + + + + diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 39aa6a1058..6ea5e62655 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -14114,6 +14114,9 @@ virDomainVideoModelDefParseXML(virDomainVideoDef *d= ef, else if (rc =3D=3D 0) def->heads =3D 1; =20 + if (virXMLPropTristateSwitch(node, "blob", VIR_XML_PROP_NONE, &def->bl= ob) < 0) + return -1; + return 0; } =20 @@ -26000,6 +26003,9 @@ virDomainVideoDefFormat(virBuffer *buf, virBufferAsprintf(buf, " heads=3D'%u'", def->heads); if (def->primary) virBufferAddLit(buf, " primary=3D'yes'"); + if (def->blob !=3D VIR_TRISTATE_SWITCH_ABSENT) + virBufferAsprintf(buf, " blob=3D'%s'", + virTristateSwitchTypeToString(def->blob)); if (def->accel || def->res) { virBufferAddLit(buf, ">\n"); virBufferAdjustIndent(buf, 2); diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index fa64491978..e66f8381e5 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1736,6 +1736,7 @@ struct _virDomainVideoDef { bool primary; virDomainVideoAccelDef *accel; virDomainVideoResolutionDef *res; + virTristateSwitch blob; virDomainVideoDriverDef *driver; virDomainDeviceInfo info; virDomainVirtioOptions *virtio; diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c index f0b8aa2655..c5c6f7df15 100644 --- a/src/conf/domain_validate.c +++ b/src/conf/domain_validate.c @@ -226,9 +226,16 @@ virDomainVideoDefValidate(const virDomainVideoDef *vid= eo, } } =20 - if (video->type !=3D VIR_DOMAIN_VIDEO_TYPE_VIRTIO && - (virDomainCheckVirtioOptionsAreAbsent(video->virtio) < 0)) - return -1; + if (video->type !=3D VIR_DOMAIN_VIDEO_TYPE_VIRTIO) { + if (virDomainCheckVirtioOptionsAreAbsent(video->virtio) < 0) + return -1; + if (video->blob !=3D VIR_TRISTATE_SWITCH_ABSENT) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("video type '%s' does not support blob resour= ces"), + virDomainVideoTypeToString(video->type)); + return -1; + } + } =20 return 0; } --=20 2.35.1 From nobody Fri May 10 11:58:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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 170.10.133.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=1645735688; cv=none; d=zohomail.com; s=zohoarc; b=bIGq0ZCR/hU3iSC+NQUjCj9/zrgKqDXE6jlWWlrUppMeoZNZ61AnozTecX8ZyY6SsLbrtxoX0vNhNsSv8j6AC9UC6rEKoeZcWEicW02P8BhqilD57EUKvYkoZmpdb7Iy9OMA4OkfWwWm35wlCwN0zHKMKZOVitNALtJixehDyww= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1645735688; 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=k0fA/6gU2jmQa5/hvzwiPPe0vO2g4Q5Mdrbq0lGKHlk=; b=lKAQ/1jBliSysqt+pYACLW2G9UGKHQwRWM3MN3hcF4neJoSYlkbtGJZvfuJnnH9L0IS376SoOszwuf3DT9ZYflmK0NWPU8Wn21MYVZf8SpSzwWLdiyb1bg/kPecMF/DQ/ZOxXuknycyN6WSw3NItEeQ//5Ld4a1godwMdA/6TWE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1645735688969323.45980248630474; Thu, 24 Feb 2022 12:48:08 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-308-OqzfgX6ZO0-FzUtDaEZMBQ-1; Thu, 24 Feb 2022 15:48:04 -0500 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 3CC9E1006AA8; Thu, 24 Feb 2022 20:47:59 +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 1BD849BEC6; Thu, 24 Feb 2022 20:47:59 +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 DFEEC46FA8; Thu, 24 Feb 2022 20:47:58 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 21OKlhIY007919 for ; Thu, 24 Feb 2022 15:47:43 -0500 Received: by smtp.corp.redhat.com (Postfix) id 103E26ABA7; Thu, 24 Feb 2022 20:47:43 +0000 (UTC) Received: from himantopus.redhat.com (unknown [10.22.33.139]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BE8BE6ABAC for ; Thu, 24 Feb 2022 20:47:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1645735688; 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=k0fA/6gU2jmQa5/hvzwiPPe0vO2g4Q5Mdrbq0lGKHlk=; b=UwTwSqkw/mAVrddXtZGYk8Vpm+/0lw9rLPsMLyFwsz00xZ2PVpbCElPPGxreY82sjsXlb7 jz9PZjqgtdCMV0wamQTdAQeprwjW131D8y2mPHlWRjja65/iUsumVCwIIydcvDrjmZ7G5Y v14SQ7Il9LKaBUC470qxxj3z+P6Jv0w= X-MC-Unique: OqzfgX6ZO0-FzUtDaEZMBQ-1 From: Jonathon Jongsma To: libvir-list@redhat.com Subject: [libvirt PATCH v2 5/6] qemu: Add capability for virtio-gpu.blob Date: Thu, 24 Feb 2022 14:47:34 -0600 Message-Id: <20220224204735.684086-6-jjongsma@redhat.com> In-Reply-To: <20220224204735.684086-1-jjongsma@redhat.com> References: <20220224204735.684086-1-jjongsma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1645735689812100001 Content-Type: text/plain; charset="utf-8" Capability to determine whether this qemu supports the 'blob' option for virtio-gpu. Signed-off-by: Jonathon Jongsma --- src/qemu/qemu_capabilities.c | 4 ++++ src/qemu/qemu_capabilities.h | 3 +++ tests/qemucapabilitiesdata/caps_6.1.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_6.2.0.aarch64.xml | 1 + tests/qemucapabilitiesdata/caps_6.2.0.ppc64.xml | 1 + tests/qemucapabilitiesdata/caps_6.2.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_7.0.0.ppc64.xml | 1 + tests/qemucapabilitiesdata/caps_7.0.0.x86_64.xml | 1 + 8 files changed, 13 insertions(+) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 529e9ceaf5..0b52967c75 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -665,6 +665,9 @@ VIR_ENUM_IMPL(virQEMUCaps, "virtio-mem-pci.prealloc", /* QEMU_CAPS_DEVICE_VIRTIO_MEM_PC= I_PREALLOC */ "calc-dirty-rate", /* QEMU_CAPS_CALC_DIRTY_RATE */ "dirtyrate-param.mode", /* QEMU_CAPS_DIRTYRATE_MODE */ + + /* 425 */ + "virtio-gpu.blob", /* QEMU_CAPS_VIRTIO_GPU_BLOB */ ); =20 =20 @@ -1546,6 +1549,7 @@ static struct virQEMUCapsDevicePropsFlags virQEMUCaps= DevicePropsVirtioGpu[] =3D { { "disable-legacy", QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY, NULL }, { "packed", QEMU_CAPS_VIRTIO_PACKED_QUEUES, NULL }, { "acpi-index", QEMU_CAPS_ACPI_INDEX, NULL }, + { "blob", QEMU_CAPS_VIRTIO_GPU_BLOB, NULL }, }; =20 static struct virQEMUCapsDevicePropsFlags virQEMUCapsDevicePropsICH9[] =3D= { diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index f6188b42de..ff8e599ea7 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -641,6 +641,9 @@ typedef enum { /* virQEMUCapsFlags grouping marker for = syntax-check */ QEMU_CAPS_CALC_DIRTY_RATE, /* accepts calc-dirty-rate */ QEMU_CAPS_DIRTYRATE_MODE , /* calc-dirty-rate accepts mode parameter */ =20 + /* 425 */ + QEMU_CAPS_VIRTIO_GPU_BLOB, /* -device virtio-gpu-*.blob=3D */ + QEMU_CAPS_LAST /* this must always be the last item */ } virQEMUCapsFlags; =20 diff --git a/tests/qemucapabilitiesdata/caps_6.1.0.x86_64.xml b/tests/qemuc= apabilitiesdata/caps_6.1.0.x86_64.xml index ba1aecc37e..49071b1ef1 100644 --- a/tests/qemucapabilitiesdata/caps_6.1.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_6.1.0.x86_64.xml @@ -239,6 +239,7 @@ + 6001000 0 43100243 diff --git a/tests/qemucapabilitiesdata/caps_6.2.0.aarch64.xml b/tests/qemu= capabilitiesdata/caps_6.2.0.aarch64.xml index 17d563eb5b..487f38f5d7 100644 --- a/tests/qemucapabilitiesdata/caps_6.2.0.aarch64.xml +++ b/tests/qemucapabilitiesdata/caps_6.2.0.aarch64.xml @@ -203,6 +203,7 @@ + 6001050 0 61700244 diff --git a/tests/qemucapabilitiesdata/caps_6.2.0.ppc64.xml b/tests/qemuca= pabilitiesdata/caps_6.2.0.ppc64.xml index 9fe9c27d14..e3f31d1809 100644 --- a/tests/qemucapabilitiesdata/caps_6.2.0.ppc64.xml +++ b/tests/qemucapabilitiesdata/caps_6.2.0.ppc64.xml @@ -201,6 +201,7 @@ + 6002000 0 42900244 diff --git a/tests/qemucapabilitiesdata/caps_6.2.0.x86_64.xml b/tests/qemuc= apabilitiesdata/caps_6.2.0.x86_64.xml index d77907af55..6a0b969113 100644 --- a/tests/qemucapabilitiesdata/caps_6.2.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_6.2.0.x86_64.xml @@ -241,6 +241,7 @@ + 6002000 0 43100244 diff --git a/tests/qemucapabilitiesdata/caps_7.0.0.ppc64.xml b/tests/qemuca= pabilitiesdata/caps_7.0.0.ppc64.xml index 5d7f283a73..0780f95f6f 100644 --- a/tests/qemucapabilitiesdata/caps_7.0.0.ppc64.xml +++ b/tests/qemucapabilitiesdata/caps_7.0.0.ppc64.xml @@ -202,6 +202,7 @@ + 6002050 0 42900243 diff --git a/tests/qemucapabilitiesdata/caps_7.0.0.x86_64.xml b/tests/qemuc= apabilitiesdata/caps_7.0.0.x86_64.xml index ae800abcc4..7e882dee40 100644 --- a/tests/qemucapabilitiesdata/caps_7.0.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_7.0.0.x86_64.xml @@ -243,6 +243,7 @@ + 6002050 0 43100243 --=20 2.35.1 From nobody Fri May 10 11:58:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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 170.10.133.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=1645735690; cv=none; d=zohomail.com; s=zohoarc; b=HqRmh1GNSxpKVFE88Ylo3DUDJ55TWWlEp+JYpAdsQxYIgMkBUApPP8YA3QlsQg9ohS+XVptfxN/QgQcECnkvaKA7CIqtT9ekeChdjvXEp94wujMF6v+m3JdjC5zbIDwarsK8mps/PRAokvoZOqkVjp0ImvP4CGj7OR1665SwPUE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1645735690; 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=c6i10vMdxWDDCkRuL6UGuWwLAC5gTa+2ltcckZcsgKc=; b=WuTXnbsorw5NxzOXIIagtgHUyLL+XgcxDa6P1mF2cK/2ovgcI9XuxGgfV6CBUW/CVT+YdHEdNg+idvni9VkJJGNASMPnC72yJNdKgv4rVZO2HR5dMX/+upZuCVSJL2mQ2JY6tpLpFdYo1bTOY/gZScVMkkW+KlVEVuU/Ize6URo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 16457356900451003.9220954084414; Thu, 24 Feb 2022 12:48:10 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-312-z3rARkH6NSuFdZFS8kNFsg-1; Thu, 24 Feb 2022 15:48:05 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EABA01091DA3; Thu, 24 Feb 2022 20:47:59 +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 CA7774CED9; Thu, 24 Feb 2022 20:47:59 +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 97F781807D60; Thu, 24 Feb 2022 20:47:59 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 21OKlhpL007924 for ; Thu, 24 Feb 2022 15:47:43 -0500 Received: by smtp.corp.redhat.com (Postfix) id B501A6ABA9; Thu, 24 Feb 2022 20:47:43 +0000 (UTC) Received: from himantopus.redhat.com (unknown [10.22.33.139]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 414EF6ABA7 for ; Thu, 24 Feb 2022 20:47:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1645735688; 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=c6i10vMdxWDDCkRuL6UGuWwLAC5gTa+2ltcckZcsgKc=; b=hQOGgb/rYzJaHTxYz7hsPY7C2lt6BMTufoIig1quHmZMuoYDe09UNq6mDfqd3VhhTxjR8Q Yp4laoS2zafpm2RKoykLd2TjVW/Idw2v4KX0+nNdh4XmsNFRzay0fXLqfLVqOOrxQvG3ix /iOwCEZh51mx+pQBCM0Fyc7a1tpl6CI= X-MC-Unique: z3rARkH6NSuFdZFS8kNFsg-1 From: Jonathon Jongsma To: libvir-list@redhat.com Subject: [libvirt PATCH v2 6/6] qemu: Implement 'blob' support for virtio gpu Date: Thu, 24 Feb 2022 14:47:35 -0600 Message-Id: <20220224204735.684086-7-jjongsma@redhat.com> In-Reply-To: <20220224204735.684086-1-jjongsma@redhat.com> References: <20220224204735.684086-1-jjongsma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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.15 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) X-ZM-MESSAGEID: 1645735691686100003 Content-Type: text/plain; charset="utf-8" This can improve performance for some guests since it reduces copying of display data between host and guest. Requires udmabuf on the host. Signed-off-by: Jonathon Jongsma --- src/qemu/qemu_cgroup.c | 28 ++++++++----- src/qemu/qemu_command.c | 3 ++ src/qemu/qemu_domain.h | 1 + src/qemu/qemu_namespace.c | 22 ++++++++++ src/qemu/qemu_validate.c | 9 ++++ .../video-virtio-blob-absent.args | 34 +++++++++++++++ .../video-virtio-blob-absent.xml | 33 +++++++++++++++ .../video-virtio-blob-off.args | 34 +++++++++++++++ .../video-virtio-blob-off.xml | 33 +++++++++++++++ .../video-virtio-blob-on.args | 34 +++++++++++++++ .../qemuxml2argvdata/video-virtio-blob-on.xml | 33 +++++++++++++++ .../video-virtio-vga-blob-on.args | 34 +++++++++++++++ .../video-virtio-vga-blob-on.xml | 33 +++++++++++++++ tests/qemuxml2argvtest.c | 12 ++++++ .../video-virtio-blob-absent.xml | 41 +++++++++++++++++++ .../video-virtio-blob-off.xml | 41 +++++++++++++++++++ .../video-virtio-blob-on.xml | 41 +++++++++++++++++++ .../video-virtio-vga-blob-on.xml | 41 +++++++++++++++++++ tests/qemuxml2xmltest.c | 12 ++++++ 19 files changed, 509 insertions(+), 10 deletions(-) create mode 100644 tests/qemuxml2argvdata/video-virtio-blob-absent.args create mode 100644 tests/qemuxml2argvdata/video-virtio-blob-absent.xml create mode 100644 tests/qemuxml2argvdata/video-virtio-blob-off.args create mode 100644 tests/qemuxml2argvdata/video-virtio-blob-off.xml create mode 100644 tests/qemuxml2argvdata/video-virtio-blob-on.args create mode 100644 tests/qemuxml2argvdata/video-virtio-blob-on.xml create mode 100644 tests/qemuxml2argvdata/video-virtio-vga-blob-on.args create mode 100644 tests/qemuxml2argvdata/video-virtio-vga-blob-on.xml create mode 100644 tests/qemuxml2xmloutdata/video-virtio-blob-absent.xml create mode 100644 tests/qemuxml2xmloutdata/video-virtio-blob-off.xml create mode 100644 tests/qemuxml2xmloutdata/video-virtio-blob-on.xml create mode 100644 tests/qemuxml2xmloutdata/video-virtio-vga-blob-on.xml diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c index 34b50ddd1d..e8f982b146 100644 --- a/src/qemu/qemu_cgroup.c +++ b/src/qemu/qemu_cgroup.c @@ -579,18 +579,26 @@ qemuSetupVideoCgroup(virDomainObj *vm, virDomainVideoAccelDef *accel =3D def->accel; int ret; =20 - if (!accel) - return 0; - - if (!accel->rendernode || - !virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_DEVICE= S)) + if (!virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_DEVICE= S)) return 0; =20 - ret =3D virCgroupAllowDevicePath(priv->cgroup, accel->rendernode, - VIR_CGROUP_DEVICE_RW, false); - virDomainAuditCgroupPath(vm, priv->cgroup, "allow", accel->rendernode, - "rw", ret); - return ret; + if (accel && accel->rendernode) { + ret =3D virCgroupAllowDevicePath(priv->cgroup, accel->rendernode, + VIR_CGROUP_DEVICE_RW, false); + virDomainAuditCgroupPath(vm, priv->cgroup, "allow", accel->rendern= ode, + "rw", ret); + if (ret !=3D 0) + return ret; + } + if (def->blob =3D=3D VIR_TRISTATE_SWITCH_ON) { + ret =3D virCgroupAllowDevicePath(priv->cgroup, QEMU_DEV_UDMABUF, + VIR_CGROUP_DEVICE_RW, false); + virDomainAuditCgroupPath(vm, priv->cgroup, "allow", QEMU_DEV_UDMAB= UF, + "rw", ret); + if (ret !=3D 0) + return ret; + } + return 0; } =20 static int diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index c836799888..b64c9e3b12 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -4854,6 +4854,9 @@ qemuBuildDeviceVideoCmd(virCommand *cmd, "p:vgamem", video->vram * 1024, NULL) < 0) return -1; + } else if (video->type =3D=3D VIR_DOMAIN_VIDEO_TYPE_VIRTIO) { + if (virJSONValueObjectAdd(&props, "T:blob", video->blob, NULL) < 0) + return -1; } =20 if (video->res) { diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index be56b5dbb3..8ff0dafaa0 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -89,6 +89,7 @@ struct _qemuDomainUnpluggingDevice { #define QEMU_DEV_VFIO "/dev/vfio/vfio" #define QEMU_DEV_SEV "/dev/sev" #define QEMU_DEVICE_MAPPER_CONTROL_PATH "/dev/mapper/control" +#define QEMU_DEV_UDMABUF "/dev/udmabuf" =20 =20 #define QEMU_DOMAIN_AES_IV_LEN 16 /* 16 bytes for 128 bit random */ diff --git a/src/qemu/qemu_namespace.c b/src/qemu/qemu_namespace.c index 3b41d72630..0a1118ac33 100644 --- a/src/qemu/qemu_namespace.c +++ b/src/qemu/qemu_namespace.c @@ -485,6 +485,25 @@ qemuDomainSetupAllGraphics(virDomainObj *vm, } =20 =20 +static int +qemuDomainSetupAllVideos(virDomainObj *vm, + GSList **paths) +{ + size_t i; + + VIR_DEBUG("Setting up video devices"); + for (i =3D 0; i < vm->def->nvideos; i++) { + virDomainVideoDef *video =3D vm->def->videos[i]; + if (video->blob =3D=3D VIR_TRISTATE_SWITCH_ON) { + *paths =3D g_slist_prepend(*paths, g_strdup(QEMU_DEV_UDMABUF)); + break; + } + } + + return 0; +} + + static int qemuDomainSetupInput(virDomainInputDef *input, GSList **paths) @@ -654,6 +673,9 @@ qemuDomainBuildNamespace(virQEMUDriverConfig *cfg, if (qemuDomainSetupAllGraphics(vm, &paths) < 0) return -1; =20 + if (qemuDomainSetupAllVideos(vm, &paths) < 0) + return -1; + if (qemuDomainSetupAllInputs(vm, &paths) < 0) return -1; =20 diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index f27e480696..14ca81a080 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -2570,6 +2570,15 @@ qemuValidateDomainDeviceDefVideo(const virDomainVide= oDef *video, } } =20 + if (video->type =3D=3D VIR_DOMAIN_VIDEO_TYPE_VIRTIO) { + if (video->blob !=3D VIR_TRISTATE_SWITCH_ABSENT && + !virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_GPU_BLOB)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("this QEMU does not support 'blob' for virtio= -gpu devices")); + return -1; + } + } + if (qemuValidateDomainVirtioOptions(video->virtio, qemuCaps) < 0) return -1; =20 diff --git a/tests/qemuxml2argvdata/video-virtio-blob-absent.args b/tests/q= emuxml2argvdata/video-virtio-blob-absent.args new file mode 100644 index 0000000000..36a5b9bba8 --- /dev/null +++ b/tests/qemuxml2argvdata/video-virtio-blob-absent.args @@ -0,0 +1,34 @@ +LC_ALL=3DC \ +PATH=3D/bin \ +HOME=3D/tmp/lib/domain--1-QEMUGuest1 \ +USER=3Dtest \ +LOGNAME=3Dtest \ +XDG_DATA_HOME=3D/tmp/lib/domain--1-QEMUGuest1/.local/share \ +XDG_CACHE_HOME=3D/tmp/lib/domain--1-QEMUGuest1/.cache \ +XDG_CONFIG_HOME=3D/tmp/lib/domain--1-QEMUGuest1/.config \ +QEMU_AUDIO_DRV=3Dnone \ +/usr/bin/qemu-system-i386 \ +-name guest=3DQEMUGuest1,debug-threads=3Don \ +-S \ +-object secret,id=3DmasterKey0,format=3Draw,file=3D/tmp/lib/domain--1-QEMU= Guest1/master-key.aes \ +-machine pc,usb=3Doff,dump-guest-core=3Doff \ +-accel tcg \ +-m 1024 \ +-realtime mlock=3Doff \ +-smp 1,sockets=3D1,cores=3D1,threads=3D1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=3Dcharmonitor,path=3D/tmp/lib/domain--1-QEMUGuest1/moni= tor.sock,server=3Don,wait=3Doff \ +-mon chardev=3Dcharmonitor,id=3Dmonitor,mode=3Dcontrol \ +-rtc base=3Dutc \ +-no-shutdown \ +-no-acpi \ +-boot strict=3Don \ +-usb \ +-drive file=3D/var/lib/libvirt/images/QEMUGuest1,format=3Dqcow2,if=3Dnone,= id=3Ddrive-ide0-0-0,cache=3Dnone \ +-device ide-hd,bus=3Dide.0,unit=3D0,drive=3Ddrive-ide0-0-0,id=3Dide0-0-0,b= ootindex=3D1 \ +-device virtio-gpu-pci,id=3Dvideo0,max_outputs=3D1,bus=3Dpci.0,addr=3D0x2 \ +-device virtio-balloon-pci,id=3Dballoon0,bus=3Dpci.0,addr=3D0x3 \ +-msg timestamp=3Don diff --git a/tests/qemuxml2argvdata/video-virtio-blob-absent.xml b/tests/qe= muxml2argvdata/video-virtio-blob-absent.xml new file mode 100644 index 0000000000..a9354d77a2 --- /dev/null +++ b/tests/qemuxml2argvdata/video-virtio-blob-absent.xml @@ -0,0 +1,33 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 1048576 + 1048576 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu-system-i386 + + + + +
+ + + + + + + + + + diff --git a/tests/qemuxml2argvdata/video-virtio-blob-off.args b/tests/qemu= xml2argvdata/video-virtio-blob-off.args new file mode 100644 index 0000000000..eadae278ce --- /dev/null +++ b/tests/qemuxml2argvdata/video-virtio-blob-off.args @@ -0,0 +1,34 @@ +LC_ALL=3DC \ +PATH=3D/bin \ +HOME=3D/tmp/lib/domain--1-QEMUGuest1 \ +USER=3Dtest \ +LOGNAME=3Dtest \ +XDG_DATA_HOME=3D/tmp/lib/domain--1-QEMUGuest1/.local/share \ +XDG_CACHE_HOME=3D/tmp/lib/domain--1-QEMUGuest1/.cache \ +XDG_CONFIG_HOME=3D/tmp/lib/domain--1-QEMUGuest1/.config \ +QEMU_AUDIO_DRV=3Dnone \ +/usr/bin/qemu-system-i386 \ +-name guest=3DQEMUGuest1,debug-threads=3Don \ +-S \ +-object secret,id=3DmasterKey0,format=3Draw,file=3D/tmp/lib/domain--1-QEMU= Guest1/master-key.aes \ +-machine pc,usb=3Doff,dump-guest-core=3Doff \ +-accel tcg \ +-m 1024 \ +-realtime mlock=3Doff \ +-smp 1,sockets=3D1,cores=3D1,threads=3D1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=3Dcharmonitor,path=3D/tmp/lib/domain--1-QEMUGuest1/moni= tor.sock,server=3Don,wait=3Doff \ +-mon chardev=3Dcharmonitor,id=3Dmonitor,mode=3Dcontrol \ +-rtc base=3Dutc \ +-no-shutdown \ +-no-acpi \ +-boot strict=3Don \ +-usb \ +-drive file=3D/var/lib/libvirt/images/QEMUGuest1,format=3Dqcow2,if=3Dnone,= id=3Ddrive-ide0-0-0,cache=3Dnone \ +-device ide-hd,bus=3Dide.0,unit=3D0,drive=3Ddrive-ide0-0-0,id=3Dide0-0-0,b= ootindex=3D1 \ +-device virtio-gpu-pci,id=3Dvideo0,max_outputs=3D1,blob=3Doff,bus=3Dpci.0,= addr=3D0x2 \ +-device virtio-balloon-pci,id=3Dballoon0,bus=3Dpci.0,addr=3D0x3 \ +-msg timestamp=3Don diff --git a/tests/qemuxml2argvdata/video-virtio-blob-off.xml b/tests/qemux= ml2argvdata/video-virtio-blob-off.xml new file mode 100644 index 0000000000..7b51762e9a --- /dev/null +++ b/tests/qemuxml2argvdata/video-virtio-blob-off.xml @@ -0,0 +1,33 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 1048576 + 1048576 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu-system-i386 + + + + +
+ + + + + + + + + + diff --git a/tests/qemuxml2argvdata/video-virtio-blob-on.args b/tests/qemux= ml2argvdata/video-virtio-blob-on.args new file mode 100644 index 0000000000..6fbb0d5bb2 --- /dev/null +++ b/tests/qemuxml2argvdata/video-virtio-blob-on.args @@ -0,0 +1,34 @@ +LC_ALL=3DC \ +PATH=3D/bin \ +HOME=3D/tmp/lib/domain--1-QEMUGuest1 \ +USER=3Dtest \ +LOGNAME=3Dtest \ +XDG_DATA_HOME=3D/tmp/lib/domain--1-QEMUGuest1/.local/share \ +XDG_CACHE_HOME=3D/tmp/lib/domain--1-QEMUGuest1/.cache \ +XDG_CONFIG_HOME=3D/tmp/lib/domain--1-QEMUGuest1/.config \ +QEMU_AUDIO_DRV=3Dnone \ +/usr/bin/qemu-system-i386 \ +-name guest=3DQEMUGuest1,debug-threads=3Don \ +-S \ +-object secret,id=3DmasterKey0,format=3Draw,file=3D/tmp/lib/domain--1-QEMU= Guest1/master-key.aes \ +-machine pc,usb=3Doff,dump-guest-core=3Doff \ +-accel tcg \ +-m 1024 \ +-realtime mlock=3Doff \ +-smp 1,sockets=3D1,cores=3D1,threads=3D1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=3Dcharmonitor,path=3D/tmp/lib/domain--1-QEMUGuest1/moni= tor.sock,server=3Don,wait=3Doff \ +-mon chardev=3Dcharmonitor,id=3Dmonitor,mode=3Dcontrol \ +-rtc base=3Dutc \ +-no-shutdown \ +-no-acpi \ +-boot strict=3Don \ +-usb \ +-drive file=3D/var/lib/libvirt/images/QEMUGuest1,format=3Dqcow2,if=3Dnone,= id=3Ddrive-ide0-0-0,cache=3Dnone \ +-device ide-hd,bus=3Dide.0,unit=3D0,drive=3Ddrive-ide0-0-0,id=3Dide0-0-0,b= ootindex=3D1 \ +-device virtio-gpu-pci,id=3Dvideo0,max_outputs=3D1,blob=3Don,bus=3Dpci.0,a= ddr=3D0x2 \ +-device virtio-balloon-pci,id=3Dballoon0,bus=3Dpci.0,addr=3D0x3 \ +-msg timestamp=3Don diff --git a/tests/qemuxml2argvdata/video-virtio-blob-on.xml b/tests/qemuxm= l2argvdata/video-virtio-blob-on.xml new file mode 100644 index 0000000000..187347fac0 --- /dev/null +++ b/tests/qemuxml2argvdata/video-virtio-blob-on.xml @@ -0,0 +1,33 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 1048576 + 1048576 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu-system-i386 + + + + +
+ + + + + + + + + + diff --git a/tests/qemuxml2argvdata/video-virtio-vga-blob-on.args b/tests/q= emuxml2argvdata/video-virtio-vga-blob-on.args new file mode 100644 index 0000000000..8b7085e1a3 --- /dev/null +++ b/tests/qemuxml2argvdata/video-virtio-vga-blob-on.args @@ -0,0 +1,34 @@ +LC_ALL=3DC \ +PATH=3D/bin \ +HOME=3D/tmp/lib/domain--1-QEMUGuest1 \ +USER=3Dtest \ +LOGNAME=3Dtest \ +XDG_DATA_HOME=3D/tmp/lib/domain--1-QEMUGuest1/.local/share \ +XDG_CACHE_HOME=3D/tmp/lib/domain--1-QEMUGuest1/.cache \ +XDG_CONFIG_HOME=3D/tmp/lib/domain--1-QEMUGuest1/.config \ +QEMU_AUDIO_DRV=3Dnone \ +/usr/bin/qemu-system-i386 \ +-name guest=3DQEMUGuest1,debug-threads=3Don \ +-S \ +-object secret,id=3DmasterKey0,format=3Draw,file=3D/tmp/lib/domain--1-QEMU= Guest1/master-key.aes \ +-machine pc,usb=3Doff,dump-guest-core=3Doff \ +-accel tcg \ +-m 1024 \ +-realtime mlock=3Doff \ +-smp 1,sockets=3D1,cores=3D1,threads=3D1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=3Dcharmonitor,path=3D/tmp/lib/domain--1-QEMUGuest1/moni= tor.sock,server=3Don,wait=3Doff \ +-mon chardev=3Dcharmonitor,id=3Dmonitor,mode=3Dcontrol \ +-rtc base=3Dutc \ +-no-shutdown \ +-no-acpi \ +-boot strict=3Don \ +-usb \ +-drive file=3D/var/lib/libvirt/images/QEMUGuest1,format=3Dqcow2,if=3Dnone,= id=3Ddrive-ide0-0-0,cache=3Dnone \ +-device ide-hd,bus=3Dide.0,unit=3D0,drive=3Ddrive-ide0-0-0,id=3Dide0-0-0,b= ootindex=3D1 \ +-device virtio-vga,id=3Dvideo0,max_outputs=3D1,blob=3Don,bus=3Dpci.0,addr= =3D0x2 \ +-device virtio-balloon-pci,id=3Dballoon0,bus=3Dpci.0,addr=3D0x3 \ +-msg timestamp=3Don diff --git a/tests/qemuxml2argvdata/video-virtio-vga-blob-on.xml b/tests/qe= muxml2argvdata/video-virtio-vga-blob-on.xml new file mode 100644 index 0000000000..00aed31d28 --- /dev/null +++ b/tests/qemuxml2argvdata/video-virtio-vga-blob-on.xml @@ -0,0 +1,33 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 1048576 + 1048576 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu-system-i386 + + + + +
+ + + + + + + + + + diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index ce475df466..991cfd6ab0 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -2462,6 +2462,18 @@ mymain(void) DO_TEST("video-virtio-vga", QEMU_CAPS_DEVICE_VIRTIO_GPU, QEMU_CAPS_DEVICE_VIRTIO_VGA); + DO_TEST("video-virtio-blob-on", + QEMU_CAPS_DEVICE_VIRTIO_GPU, + QEMU_CAPS_VIRTIO_GPU_BLOB); + DO_TEST("video-virtio-vga-blob-on", + QEMU_CAPS_DEVICE_VIRTIO_GPU, + QEMU_CAPS_DEVICE_VIRTIO_VGA, + QEMU_CAPS_VIRTIO_GPU_BLOB); + DO_TEST("video-virtio-blob-off", + QEMU_CAPS_DEVICE_VIRTIO_GPU, + QEMU_CAPS_VIRTIO_GPU_BLOB); + DO_TEST("video-virtio-blob-absent", + QEMU_CAPS_DEVICE_VIRTIO_GPU); DO_TEST_CAPS_LATEST("video-virtio-vga-gpu-gl"); DO_TEST_CAPS_LATEST("video-bochs-display-device"); DO_TEST_CAPS_LATEST("video-ramfb-display-device"); diff --git a/tests/qemuxml2xmloutdata/video-virtio-blob-absent.xml b/tests/= qemuxml2xmloutdata/video-virtio-blob-absent.xml new file mode 100644 index 0000000000..827ed19153 --- /dev/null +++ b/tests/qemuxml2xmloutdata/video-virtio-blob-absent.xml @@ -0,0 +1,41 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 1048576 + 1048576 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu-system-i386 + + + + +
+ + +
+ + +
+ + + + +