From nobody Wed May 15 19:14:16 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=1660848001; cv=none; d=zohomail.com; s=zohoarc; b=f36KG1n2l200FUn0dc534D/3+fVhNJzOtq34uD4oBpSyhrtnCFOeithQDRShghbBotSMUlYM1D9n0clXngLwRaJiKiwZ1+6iB55i919ufQTpDLvOwcbpmhAIGO6ggkuJWRndlftgamktXeNEugZgEEjjG5g2mDVGvvcjeuWvjUU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1660848001; 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=KCJdG3lbF0Giv+HD40lguyXfIw1lMhTlXggOHiIJ1XA=; b=ZTv3554/+PfDsD8eTkFPC8n6LrxFtvy0BIOY2SdWttBY2KZn6hbDgkIiSW0Ojmp+30aMlLnAz1SyuWjOWiex0DFJ6dSG4hv3MdW0j2CrLxvjWmPLBJzdvZS4uKPo+f5Uys0C1ipspWIkjNCTlBhiHyJJdQH8HhoZfyQzza6U+xU= 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 1660848001560612.8782700458219; Thu, 18 Aug 2022 11:40:01 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-516-58zqx69QP0i1qTCzHtTqkg-1; Thu, 18 Aug 2022 14:39:56 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9AF6F3C0F394; Thu, 18 Aug 2022 18:39:52 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7F3AC492C3B; Thu, 18 Aug 2022 18:39:52 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id BAB8A194F4AD; Thu, 18 Aug 2022 18:39:50 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 433AE1946A41 for ; Thu, 18 Aug 2022 18:39:48 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 289C7492C3B; Thu, 18 Aug 2022 18:39:48 +0000 (UTC) Received: from himantopus.redhat.com (unknown [10.22.9.8]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 06C3B492CA5 for ; Thu, 18 Aug 2022 18:39:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660848000; 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=KCJdG3lbF0Giv+HD40lguyXfIw1lMhTlXggOHiIJ1XA=; b=I0WX6XpqtXkijxnJHBh4tu7nSIcgZ7wxbXzt0/bN4MXWiZQIC/FHc/PtWkxM8kr0mh8ctc lmcwqDRbIqaiQ7DgjKdNOeIbfqefexeQrWeJMg3fO7llr3llGugxgdisP6curPoWZq8mTk 5VBnKfffZfjBIwp15La+/Ii7lpGDbj4= X-MC-Unique: 58zqx69QP0i1qTCzHtTqkg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jonathon Jongsma To: libvir-list@redhat.com Subject: [libvirt PATCH v4 1/6] conf: Refactor video model parsing Date: Thu, 18 Aug 2022 13:39:42 -0500 Message-Id: <20220818183947.2812228-2-jjongsma@redhat.com> In-Reply-To: <20220818183947.2812228-1-jjongsma@redhat.com> References: <20220818183947.2812228-1-jjongsma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 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: 1660848003775100006 Content-Type: text/plain; charset="utf-8"; x-default="true" 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 2fc94b40ef..a15079629d 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -12847,17 +12847,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; @@ -12866,81 +12862,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.37.1 From nobody Wed May 15 19:14:16 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=1660848002; cv=none; d=zohomail.com; s=zohoarc; b=DKokortfnPjIOTjXTj2zvGUDAekX9pO201mhmn++05IGOuGprSgoVtZV3qFT6ZS9qLx9874EJRdzRCxY0KrZKU8zLZzea1T7U8VDwySoOy7kuHr4kNcm9eiKgLgg7Qv7kCoQ9HAYDGYxkPNvh2fWf7pexz5JatN6vvEacJbRVM8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1660848002; 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=nHvO/xG6pOH/mIVkyTQsG4KZ5eC2KQIEgQIAKxNzBPc=; b=mXyKxRJgC8QrYdp4JluCOMvXuiwD4Z5tkRPTLX3EHyD7xL7a3vDTg2EXGo4KCKUSaU7OD96QTk4mwfzJzncIh7cVKt7AZ0TRRSP2oAhNoW3BlyPSGI5oX0HN7qCOJXfzhu/RyPDR4QX6NK56EdGhoa0AqzRg5L/FL2rVh/u7zzY= 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 1660848002404473.5542245149553; Thu, 18 Aug 2022 11:40:02 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-590-dens2EThNGqgBU9UZrIghw-1; Thu, 18 Aug 2022 14:39:56 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 641DF29324AD; Thu, 18 Aug 2022 18:39:51 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5100C14152E4; Thu, 18 Aug 2022 18:39:51 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id EDA8B1953550; Thu, 18 Aug 2022 18:39:49 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 7920E1946A41 for ; Thu, 18 Aug 2022 18:39:48 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 5EB62492C3B; Thu, 18 Aug 2022 18:39:48 +0000 (UTC) Received: from himantopus.redhat.com (unknown [10.22.9.8]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3DEE7492CA4 for ; Thu, 18 Aug 2022 18:39:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660848001; 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=nHvO/xG6pOH/mIVkyTQsG4KZ5eC2KQIEgQIAKxNzBPc=; b=BLs3kckVRk5v81+nz9lSqs2NCqS5MUn+B/AFu7wp/30bFc+h24+Evb/jjwfmJ5ej/nZzSQ JcOU11TAQiOqU5Yx+Eme/GPwVjK15FlA93Jgzw2ZFo3Lu1+6tZ6Sthw5FW3o0eTOjMrdYz We1ZQOJVupNcFYamsCxL9iVrU32a5D8= X-MC-Unique: dens2EThNGqgBU9UZrIghw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jonathon Jongsma To: libvir-list@redhat.com Subject: [libvirt PATCH v4 2/6] conf: switch to virXMLProp* functions Date: Thu, 18 Aug 2022 13:39:43 -0500 Message-Id: <20220818183947.2812228-3-jjongsma@redhat.com> In-Reply-To: <20220818183947.2812228-1-jjongsma@redhat.com> References: <20220818183947.2812228-1-jjongsma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 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: 1660848003772100005 Content-Type: text/plain; charset="utf-8"; x-default="true" 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 a15079629d..d7ae09211e 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -12854,19 +12854,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) @@ -12876,57 +12872,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.37.1 From nobody Wed May 15 19:14:16 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=1660848007; cv=none; d=zohomail.com; s=zohoarc; b=BJGkxHaJ7pK81c6k3VknEut24CuqF+yYYzVWFbx8QAaF8/tR8brEIP9doJKhUwqSMt99vq2hQsenJeYSFEbBIjvHqLjNC2qixmD129+zPGWg9qA2zZw4bU4mBWMN9VSiR3r4NDTjOVE7cJXWY9G4uX0qn+NDLjuUBTaPAZ4AR64= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1660848007; 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=F6Dd8zHPRZNZZoVg7o7ptveISp3ifG4zOc+gat5XarE=; b=Frez5l7q3o1cFu7vwR2iTtAG09WhEoa8ScrFDyUFJ+jhkPx9gwJdNpc23+xKFMFjx/cvsx9ugnFte5yD+LaDz30JQ67iM4A32PqsCy/d4/3FmiEGo0mBW7QOIqelyC9Eoudg7tChOLl1N/SyteHU3nancZX/6hhfw6vaa/3h0ME= 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 1660848007139593.4086949029429; Thu, 18 Aug 2022 11:40:07 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-564-4WuvRNgTMXKv5d_CGlP-PQ-1; Thu, 18 Aug 2022 14:39:53 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4D8371019C97; Thu, 18 Aug 2022 18:39:51 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id A327F492C3B; Thu, 18 Aug 2022 18:39:50 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 8A7BE1953544; Thu, 18 Aug 2022 18:39:49 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id AF3EB1946A41 for ; Thu, 18 Aug 2022 18:39:48 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 9572E492C3B; Thu, 18 Aug 2022 18:39:48 +0000 (UTC) Received: from himantopus.redhat.com (unknown [10.22.9.8]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 74102492CA4 for ; Thu, 18 Aug 2022 18:39:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660848005; 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=F6Dd8zHPRZNZZoVg7o7ptveISp3ifG4zOc+gat5XarE=; b=Us8JCiGD/O0WkgOvgYUh2paaiYOdQr3WaxJXukFfxwuBsqrr/QUEb60ybbZ5FiUwSqe6me JibjNY3uE5vyCbJoDUMUD6KPuPNQiW/r8Qwbgu71kBWFEWox6uhWAN7ha4nOQtAJ5X8eoI NWDnOon9nksEBwu2t63SRhpYKYRZJo8= X-MC-Unique: 4WuvRNgTMXKv5d_CGlP-PQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jonathon Jongsma To: libvir-list@redhat.com Subject: [libvirt PATCH v4 3/6] conf: use enum variable for video type Date: Thu, 18 Aug 2022 13:39:44 -0500 Message-Id: <20220818183947.2812228-4-jjongsma@redhat.com> In-Reply-To: <20220818183947.2812228-1-jjongsma@redhat.com> References: <20220818183947.2812228-1-jjongsma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 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: 1660848007729100011 Content-Type: text/plain; charset="utf-8"; x-default="true" 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 d7ae09211e..c39602ec75 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -12854,7 +12854,6 @@ virDomainVideoModelDefParseXML(virDomainVideoDef *d= ef, { xmlNodePtr accel_node; xmlNodePtr res_node; - virDomainVideoType type; virTristateBool primary; int rc =3D 0; =20 @@ -12874,10 +12873,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 a1f6cf7a6f..7d293f1d8a 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1780,7 +1780,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 ab73671327..ccb5a884a6 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 52e0aa1e60..f26a13e9cb 100644 --- a/src/libxl/libxl_domain.c +++ b/src/libxl/libxl_domain.c @@ -296,6 +296,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 70fba50e6c..cdd235563e 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -1776,9 +1776,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; } @@ -1816,11 +1823,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 5c8413a6b6..7e09333c93 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -3023,9 +3023,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.37.1 From nobody Wed May 15 19:14:16 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=1660847999; cv=none; d=zohomail.com; s=zohoarc; b=EY77PjypfXtIRqRlGj8T8lpOZ083sh9KG31P3UdRB9Nr8LP0Y3I4JtE8e5lK4GWJvb6ZDafXHDGfCRW3NaDj0KAXkplbDTtZagB0f+2T837pOSw753/WQCbeF/DtfwFGDv6aPBzTCDIO3eev2IWYZNbKEeild8pm7gUQKcSRrNM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1660847999; 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=LsYxroove/apfZKni5KCfNOQ7fJIHKF9plsXDIhUNjI=; b=UBLX7wteO4PiJ7ZqDZHmapG3+TV4SlufDtxVKoLWflG1dDCDWv2TsQSkfxE+nNZfm+u4Uo0rSj+QzR56VPcyrw2hEB5aX2V0QAkCOKy6imGl2MbU8GK28BHRebIHRyfh+KvqGX9MQKPV5juW8z/E3rAzxSlR/gvptE8xbACNEtw= 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 1660847999356327.5257646554278; Thu, 18 Aug 2022 11:39:59 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-79-xAAKa-14PeC3Bj8vRXhpAg-1; Thu, 18 Aug 2022 14:39:56 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 11AD829324A5; Thu, 18 Aug 2022 18:39:52 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id F0E5A404C6DE; Thu, 18 Aug 2022 18:39:51 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 3E20E195355E; Thu, 18 Aug 2022 18:39:50 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id D69F51946A41 for ; Thu, 18 Aug 2022 18:39:48 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id CB0BC492C3B; Thu, 18 Aug 2022 18:39:48 +0000 (UTC) Received: from himantopus.redhat.com (unknown [10.22.9.8]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A9CD4492CA4 for ; Thu, 18 Aug 2022 18:39:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660847998; 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=LsYxroove/apfZKni5KCfNOQ7fJIHKF9plsXDIhUNjI=; b=VInqMj2CgeOyKOkFQRAL8AAtzNDwbPtfV+T8S8mBDgCAozS8JuuLeRpwp31JBt6ifUyDfo dFSdINH2/enb8cLg93desdJC9elMdAsiDm/dLQSxOuWyxde+W25fjioe/p/43/AvaRziZc CK82+YoHTaW55bKCIUhMbxDxZ4l6/uE= X-MC-Unique: xAAKa-14PeC3Bj8vRXhpAg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jonathon Jongsma To: libvir-list@redhat.com Subject: [libvirt PATCH v4 4/6] conf: add support for 'blob' in virtio video device Date: Thu, 18 Aug 2022 13:39:45 -0500 Message-Id: <20220818183947.2812228-5-jjongsma@redhat.com> In-Reply-To: <20220818183947.2812228-1-jjongsma@redhat.com> References: <20220818183947.2812228-1-jjongsma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 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: 1660847999706100001 Content-Type: text/plain; charset="utf-8"; x-default="true" 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 | 7 +++++++ src/conf/domain_conf.c | 6 ++++++ src/conf/domain_conf.h | 1 + src/conf/domain_validate.c | 13 ++++++++++--- src/conf/schemas/domaincommon.rng | 5 +++++ 5 files changed, 29 insertions(+), 3 deletions(-) diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst index 212104fe1f..cf8a09adec 100644 --- a/docs/formatdomain.rst +++ b/docs/formatdomain.rst @@ -6346,6 +6346,13 @@ A video device. :since:`since 1.3.3` ) extends secondary bar and makes it addressable as 64bit memory. =20 + :since:`Since 8.7.0` (QEMU driver only), devices with type "virtio" hav= e an + optional ``blob`` attribute that can be set to "on" or "off". Setting + ``blob`` to "on" will enable the use of blob resources in the device. T= his + can accelerate the display path by reducing or eliminating copying of p= ixel + data between the guest and host. Note that blob resource support requir= es + QEMU version 6.1 or newer. + :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/src/conf/domain_conf.c b/src/conf/domain_conf.c index c39602ec75..57177b1544 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -12894,6 +12894,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 @@ -24973,6 +24976,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 7d293f1d8a..8ab14d6a3c 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1789,6 +1789,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 1c78a3d31c..1908d4459e 100644 --- a/src/conf/domain_validate.c +++ b/src/conf/domain_validate.c @@ -225,9 +225,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; } diff --git a/src/conf/schemas/domaincommon.rng b/src/conf/schemas/domaincom= mon.rng index 7f6ea1d888..80eb8d9ee9 100644 --- a/src/conf/schemas/domaincommon.rng +++ b/src/conf/schemas/domaincommon.rng @@ -4378,6 +4378,11 @@ + + + + + --=20 2.37.1 From nobody Wed May 15 19:14:16 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=1660848005; cv=none; d=zohomail.com; s=zohoarc; b=Sh2HyTImHj2Z+CblZzeg9EiMF8QpKGbjA0M6Qcifr0pn03bWJcy05Obkfqkf9WjoULsZTCrAnmI2YaORL1EHnHVYzLGTr0S0jk4j396I2+1I7ooxRNpF49wR4fHlgcS65ZW9wVnv0mxrvVRGXXDQ5qi5UapC1btNy2in5EFdax8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1660848005; 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=fwPLqh9PEwZ+mI7enBy3p25HOZfWGBp8dhjgwzMfMrg=; b=I7sDC1S7rc1VlJfkw26Uy3+Zs0Q9VRi+rcCaOCQEjx82/h482vCcGhcmxc93SRDIkkeMjUJoZ+nmGdoPZfs6uqNHMOPlXCU4ZfsrnGk3aYJ+AC+fd71Y3PBCcWR20W5jNOsf+VSa3a1UNU3F65cfWSubryNiW6gtYKtyUmL84tM= 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 1660848005127440.1883825768691; Thu, 18 Aug 2022 11:40:05 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-611-ZeICaNJMMmWP_Ryeg7xl7w-1; Thu, 18 Aug 2022 14:39:56 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 20D941C06EF2; Thu, 18 Aug 2022 18:39:53 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0B7A440D2833; Thu, 18 Aug 2022 18:39:53 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 0FFE9195356E; Thu, 18 Aug 2022 18:39:51 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 2C5CA194E12A for ; Thu, 18 Aug 2022 18:39:49 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 0DE66492CA4; Thu, 18 Aug 2022 18:39:49 +0000 (UTC) Received: from himantopus.redhat.com (unknown [10.22.9.8]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E12E2492C3B for ; Thu, 18 Aug 2022 18:39:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660848003; 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=fwPLqh9PEwZ+mI7enBy3p25HOZfWGBp8dhjgwzMfMrg=; b=LfbyoCSh0b4t5mPqmMso0wVfVQD5ydvUkEUauK1pqGByEMdtOxrEVBqM+CICCPIG4HA57y zRnRh7SUqsR4PYbKLPflP5zUy0OnvAUWwNssllePRtQg1t8NqqshMpiCB8Kx7BaD/Ly4Cm xZ3rbqdAlTEqCETWfolS/97wSiuYn68= X-MC-Unique: ZeICaNJMMmWP_Ryeg7xl7w-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jonathon Jongsma To: libvir-list@redhat.com Subject: [libvirt PATCH v4 5/6] qemu: Add capability for virtio-gpu.blob Date: Thu, 18 Aug 2022 13:39:46 -0500 Message-Id: <20220818183947.2812228-6-jjongsma@redhat.com> In-Reply-To: <20220818183947.2812228-1-jjongsma@redhat.com> References: <20220818183947.2812228-1-jjongsma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 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: 1660848005727100009 Content-Type: text/plain; charset="utf-8"; x-default="true" Capability to determine whether this qemu supports the 'blob' option for virtio-gpu. Signed-off-by: Jonathon Jongsma --- src/qemu/qemu_capabilities.c | 2 ++ src/qemu/qemu_capabilities.h | 1 + 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.aarch64.xml | 1 + tests/qemucapabilitiesdata/caps_7.0.0.ppc64.xml | 1 + tests/qemucapabilitiesdata/caps_7.0.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_7.1.0.x86_64.xml | 1 + 10 files changed, 11 insertions(+) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index f7986ef938..43e8be720e 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -676,6 +676,7 @@ VIR_ENUM_IMPL(virQEMUCaps, =20 /* 435 */ "query-stats", /* QEMU_CAPS_QUERY_STATS */ + "virtio-gpu.blob", /* QEMU_CAPS_VIRTIO_GPU_BLOB */ ); =20 =20 @@ -1537,6 +1538,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 cccb3659aa..7d08e24e3a 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -655,6 +655,7 @@ typedef enum { /* virQEMUCapsFlags grouping marker for = syntax-check */ =20 /* 435 */ QEMU_CAPS_QUERY_STATS, /* accepts query-stats */ + QEMU_CAPS_VIRTIO_GPU_BLOB, /* -device virtio-gpu-*.blob=3D */ =20 QEMU_CAPS_LAST /* this must always be the last item */ } virQEMUCapsFlags; diff --git a/tests/qemucapabilitiesdata/caps_6.1.0.x86_64.xml b/tests/qemuc= apabilitiesdata/caps_6.1.0.x86_64.xml index 35bd9b6327..021b25b1d6 100644 --- a/tests/qemucapabilitiesdata/caps_6.1.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_6.1.0.x86_64.xml @@ -217,6 +217,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 663b94b1ff..a732ca204f 100644 --- a/tests/qemucapabilitiesdata/caps_6.2.0.aarch64.xml +++ b/tests/qemucapabilitiesdata/caps_6.2.0.aarch64.xml @@ -182,6 +182,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 2468780a51..47097d2d56 100644 --- a/tests/qemucapabilitiesdata/caps_6.2.0.ppc64.xml +++ b/tests/qemucapabilitiesdata/caps_6.2.0.ppc64.xml @@ -176,6 +176,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 e3f9ee47bd..64458e4df2 100644 --- a/tests/qemucapabilitiesdata/caps_6.2.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_6.2.0.x86_64.xml @@ -219,6 +219,7 @@ + 6002000 0 43100244 diff --git a/tests/qemucapabilitiesdata/caps_7.0.0.aarch64.xml b/tests/qemu= capabilitiesdata/caps_7.0.0.aarch64.xml index 5ca77807ef..1be98050e5 100644 --- a/tests/qemucapabilitiesdata/caps_7.0.0.aarch64.xml +++ b/tests/qemucapabilitiesdata/caps_7.0.0.aarch64.xml @@ -190,6 +190,7 @@ + 6002092 0 61700243 diff --git a/tests/qemucapabilitiesdata/caps_7.0.0.ppc64.xml b/tests/qemuca= pabilitiesdata/caps_7.0.0.ppc64.xml index cd41a08fa9..ab8234ce34 100644 --- a/tests/qemucapabilitiesdata/caps_7.0.0.ppc64.xml +++ b/tests/qemucapabilitiesdata/caps_7.0.0.ppc64.xml @@ -194,6 +194,7 @@ + 7000000 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 86fe88b878..6b74165b70 100644 --- a/tests/qemucapabilitiesdata/caps_7.0.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_7.0.0.x86_64.xml @@ -224,6 +224,7 @@ + 7000000 0 43100243 diff --git a/tests/qemucapabilitiesdata/caps_7.1.0.x86_64.xml b/tests/qemuc= apabilitiesdata/caps_7.1.0.x86_64.xml index 7f17b2360a..c71e57a246 100644 --- a/tests/qemucapabilitiesdata/caps_7.1.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_7.1.0.x86_64.xml @@ -226,6 +226,7 @@ + 7000050 0 43100244 --=20 2.37.1 From nobody Wed May 15 19:14:16 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=1660848078; cv=none; d=zohomail.com; s=zohoarc; b=lIRx8lXRDxbE3AX8zT3kaoK59z8JGdNIhYCK+kASlapVn1eJrqVAr3KapRyw9L3EUIEQqovL21ejocRHybGBpaejF0SlrnRNNkz7UvOu+ffUzpQtmH2Kk5x7elGgPSpq1Vkv4sE23HtiHiYqI+MDT8kK36kHgCoA3r3H/vPAZCI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1660848078; 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=iJ2+1MlHmC3/49HXl1LTTIkO1qdUPH2CqJ/aFVT2haE=; b=bN6xwBMCYsCEV7AuOfxOQKiEWUUL2xHIv+NN5NaeXodeNbs4MbKdY9scKwpD1OxbHEFMunc2LkmKTSvTjURPWWmBc/k45DF13U9CU2hvxrP1VH+fLZZz36hVofkATRkIcfa86NATXp2f6pW7POMviXX/CiPASq+spRwVEKrKFME= 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 1660848078910561.2941392937386; Thu, 18 Aug 2022 11:41:18 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-54-rZNUNOtzN4u15T7odQRilg-1; Thu, 18 Aug 2022 14:39:57 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 248712919EA0; Thu, 18 Aug 2022 18:39:53 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0BF98492C3B; Thu, 18 Aug 2022 18:39:53 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 107CC195356F; Thu, 18 Aug 2022 18:39:51 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 72D9A1953542 for ; Thu, 18 Aug 2022 18:39:49 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 4EBC8492C3B; Thu, 18 Aug 2022 18:39:49 +0000 (UTC) Received: from himantopus.redhat.com (unknown [10.22.9.8]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2412E492CA5 for ; Thu, 18 Aug 2022 18:39:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660848076; 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=iJ2+1MlHmC3/49HXl1LTTIkO1qdUPH2CqJ/aFVT2haE=; b=DpsDfWEu7BINP0Eou4AsPyry553UOkEQbg5NVXqjsiudxsfFnKiKIhujDQIc0uPCB4l7Wa ILOXuzon7Nq/02IlU141UauY/o90s1hTKveeq2MMxQFiEXoh9Tk5sAzYAaFKt0O2WyoOgb nqniBslopYp9zdYjOtWBLfhTy4d6pAI= X-MC-Unique: rZNUNOtzN4u15T7odQRilg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jonathon Jongsma To: libvir-list@redhat.com Subject: [libvirt PATCH v4 6/6] qemu: Implement 'blob' support for virtio gpu Date: Thu, 18 Aug 2022 13:39:47 -0500 Message-Id: <20220818183947.2812228-7-jjongsma@redhat.com> In-Reply-To: <20220818183947.2812228-1-jjongsma@redhat.com> References: <20220818183947.2812228-1-jjongsma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 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: 1660848080268100001 Content-Type: text/plain; charset="utf-8"; x-default="true" 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 | 22 ++++++--- src/qemu/qemu_command.c | 3 ++ src/qemu/qemu_domain.h | 1 + src/qemu/qemu_namespace.c | 22 +++++++++ src/qemu/qemu_validate.c | 9 ++++ ...ideo-virtio-blob-absent.x86_64-latest.args | 39 +++++++++++++++ .../video-virtio-blob-absent.xml | 36 ++++++++++++++ .../video-virtio-blob-off.x86_64-latest.args | 39 +++++++++++++++ .../video-virtio-blob-off.xml | 36 ++++++++++++++ .../video-virtio-blob-on.x86_64-latest.args | 39 +++++++++++++++ .../qemuxml2argvdata/video-virtio-blob-on.xml | 36 ++++++++++++++ tests/qemuxml2argvtest.c | 3 ++ ...video-virtio-blob-absent.x86_64-latest.xml | 48 +++++++++++++++++++ .../video-virtio-blob-off.x86_64-latest.xml | 48 +++++++++++++++++++ .../video-virtio-blob-on.x86_64-latest.xml | 48 +++++++++++++++++++ tests/qemuxml2xmltest.c | 3 ++ 16 files changed, 425 insertions(+), 7 deletions(-) create mode 100644 tests/qemuxml2argvdata/video-virtio-blob-absent.x86_64-= latest.args create mode 100644 tests/qemuxml2argvdata/video-virtio-blob-absent.xml create mode 100644 tests/qemuxml2argvdata/video-virtio-blob-off.x86_64-lat= est.args create mode 100644 tests/qemuxml2argvdata/video-virtio-blob-off.xml create mode 100644 tests/qemuxml2argvdata/video-virtio-blob-on.x86_64-late= st.args create mode 100644 tests/qemuxml2argvdata/video-virtio-blob-on.xml create mode 100644 tests/qemuxml2xmloutdata/video-virtio-blob-absent.x86_6= 4-latest.xml create mode 100644 tests/qemuxml2xmloutdata/video-virtio-blob-off.x86_64-l= atest.xml create mode 100644 tests/qemuxml2xmloutdata/video-virtio-blob-on.x86_64-la= test.xml diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c index d6f27a5a4d..72511ab5f6 100644 --- a/src/qemu/qemu_cgroup.c +++ b/src/qemu/qemu_cgroup.c @@ -572,16 +572,24 @@ qemuSetupVideoCgroup(virDomainObj *vm, { qemuDomainObjPrivate *priv =3D vm->privateData; 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 - return qemuCgroupAllowDevicePath(vm, accel->rendernode, - VIR_CGROUP_DEVICE_RW, false); + if (accel && accel->rendernode) { + ret =3D qemuCgroupAllowDevicePath(vm, accel->rendernode, + VIR_CGROUP_DEVICE_RW, false); + if (ret !=3D 0) + return ret; + } + if (def->blob =3D=3D VIR_TRISTATE_SWITCH_ON) { + ret =3D qemuCgroupAllowDevicePath(vm, QEMU_DEV_UDMABUF, + VIR_CGROUP_DEVICE_RW, false); + 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 1523ca7047..da46b96a25 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -4475,6 +4475,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 592ee9805b..3c1b365ab9 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -82,6 +82,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 98cd794666..42229b656d 100644 --- a/src/qemu/qemu_namespace.c +++ b/src/qemu/qemu_namespace.c @@ -484,6 +484,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) @@ -655,6 +674,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 41765bba37..a1518afc1b 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -2828,6 +2828,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.x86_64-latest.= args b/tests/qemuxml2argvdata/video-virtio-blob-absent.x86_64-latest.args new file mode 100644 index 0000000000..ef055235dd --- /dev/null +++ b/tests/qemuxml2argvdata/video-virtio-blob-absent.x86_64-latest.args @@ -0,0 +1,39 @@ +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 \ +/usr/bin/qemu-system-x86_64 \ +-name guest=3DQEMUGuest1,debug-threads=3Don \ +-S \ +-object '{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/tm= p/lib/domain--1-QEMUGuest1/master-key.aes"}' \ +-machine pc,usb=3Doff,dump-guest-core=3Doff,memory-backend=3Dpc.ram \ +-accel tcg \ +-cpu qemu64 \ +-m 1024 \ +-object '{"qom-type":"memory-backend-ram","id":"pc.ram","size":1073741824}= ' \ +-overcommit mem-lock=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,fd=3D1729,server=3Don,wait=3Doff \ +-mon chardev=3Dcharmonitor,id=3Dmonitor,mode=3Dcontrol \ +-rtc base=3Dutc \ +-no-shutdown \ +-no-acpi \ +-boot strict=3Don \ +-device '{"driver":"piix3-usb-uhci","id":"usb","bus":"pci.0","addr":"0x1.0= x2"}' \ +-blockdev '{"driver":"file","filename":"/var/lib/libvirt/images/QEMUGuest1= ","node-name":"libvirt-1-storage","cache":{"direct":true,"no-flush":false},= "auto-read-only":true,"discard":"unmap"}' \ +-blockdev '{"node-name":"libvirt-1-format","read-only":false,"cache":{"dir= ect":true,"no-flush":false},"driver":"qcow2","file":"libvirt-1-storage"}' \ +-device '{"driver":"ide-hd","bus":"ide.0","unit":0,"drive":"libvirt-1-form= at","id":"ide0-0-0","bootindex":1,"write-cache":"on"}' \ +-audiodev '{"id":"audio1","driver":"none"}' \ +-device '{"driver":"virtio-vga","id":"video0","max_outputs":1,"bus":"pci.0= ","addr":"0x2"}' \ +-device '{"driver":"virtio-gpu-pci","id":"video1","max_outputs":1,"bus":"p= ci.0","addr":"0x4"}' \ +-device '{"driver":"virtio-balloon-pci","id":"balloon0","bus":"pci.0","add= r":"0x3"}' \ +-sandbox on,obsolete=3Ddeny,elevateprivileges=3Ddeny,spawn=3Ddeny,resource= control=3Ddeny \ +-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..faa9b2e729 --- /dev/null +++ b/tests/qemuxml2argvdata/video-virtio-blob-absent.xml @@ -0,0 +1,36 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 1048576 + 1048576 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu-system-x86_64 + + + + +
+ + + + + + + + + + + diff --git a/tests/qemuxml2argvdata/video-virtio-blob-off.x86_64-latest.arg= s b/tests/qemuxml2argvdata/video-virtio-blob-off.x86_64-latest.args new file mode 100644 index 0000000000..61bb5f2193 --- /dev/null +++ b/tests/qemuxml2argvdata/video-virtio-blob-off.x86_64-latest.args @@ -0,0 +1,39 @@ +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 \ +/usr/bin/qemu-system-x86_64 \ +-name guest=3DQEMUGuest1,debug-threads=3Don \ +-S \ +-object '{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/tm= p/lib/domain--1-QEMUGuest1/master-key.aes"}' \ +-machine pc,usb=3Doff,dump-guest-core=3Doff,memory-backend=3Dpc.ram \ +-accel tcg \ +-cpu qemu64 \ +-m 1024 \ +-object '{"qom-type":"memory-backend-ram","id":"pc.ram","size":1073741824}= ' \ +-overcommit mem-lock=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,fd=3D1729,server=3Don,wait=3Doff \ +-mon chardev=3Dcharmonitor,id=3Dmonitor,mode=3Dcontrol \ +-rtc base=3Dutc \ +-no-shutdown \ +-no-acpi \ +-boot strict=3Don \ +-device '{"driver":"piix3-usb-uhci","id":"usb","bus":"pci.0","addr":"0x1.0= x2"}' \ +-blockdev '{"driver":"file","filename":"/var/lib/libvirt/images/QEMUGuest1= ","node-name":"libvirt-1-storage","cache":{"direct":true,"no-flush":false},= "auto-read-only":true,"discard":"unmap"}' \ +-blockdev '{"node-name":"libvirt-1-format","read-only":false,"cache":{"dir= ect":true,"no-flush":false},"driver":"qcow2","file":"libvirt-1-storage"}' \ +-device '{"driver":"ide-hd","bus":"ide.0","unit":0,"drive":"libvirt-1-form= at","id":"ide0-0-0","bootindex":1,"write-cache":"on"}' \ +-audiodev '{"id":"audio1","driver":"none"}' \ +-device '{"driver":"virtio-vga","id":"video0","max_outputs":1,"blob":false= ,"bus":"pci.0","addr":"0x2"}' \ +-device '{"driver":"virtio-gpu-pci","id":"video1","max_outputs":1,"blob":f= alse,"bus":"pci.0","addr":"0x4"}' \ +-device '{"driver":"virtio-balloon-pci","id":"balloon0","bus":"pci.0","add= r":"0x3"}' \ +-sandbox on,obsolete=3Ddeny,elevateprivileges=3Ddeny,spawn=3Ddeny,resource= control=3Ddeny \ +-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..78b7180b35 --- /dev/null +++ b/tests/qemuxml2argvdata/video-virtio-blob-off.xml @@ -0,0 +1,36 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 1048576 + 1048576 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu-system-x86_64 + + + + +
+ + + + + + + + + + + diff --git a/tests/qemuxml2argvdata/video-virtio-blob-on.x86_64-latest.args= b/tests/qemuxml2argvdata/video-virtio-blob-on.x86_64-latest.args new file mode 100644 index 0000000000..72f7b86017 --- /dev/null +++ b/tests/qemuxml2argvdata/video-virtio-blob-on.x86_64-latest.args @@ -0,0 +1,39 @@ +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 \ +/usr/bin/qemu-system-x86_64 \ +-name guest=3DQEMUGuest1,debug-threads=3Don \ +-S \ +-object '{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/tm= p/lib/domain--1-QEMUGuest1/master-key.aes"}' \ +-machine pc,usb=3Doff,dump-guest-core=3Doff,memory-backend=3Dpc.ram \ +-accel tcg \ +-cpu qemu64 \ +-m 1024 \ +-object '{"qom-type":"memory-backend-ram","id":"pc.ram","size":1073741824}= ' \ +-overcommit mem-lock=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,fd=3D1729,server=3Don,wait=3Doff \ +-mon chardev=3Dcharmonitor,id=3Dmonitor,mode=3Dcontrol \ +-rtc base=3Dutc \ +-no-shutdown \ +-no-acpi \ +-boot strict=3Don \ +-device '{"driver":"piix3-usb-uhci","id":"usb","bus":"pci.0","addr":"0x1.0= x2"}' \ +-blockdev '{"driver":"file","filename":"/var/lib/libvirt/images/QEMUGuest1= ","node-name":"libvirt-1-storage","cache":{"direct":true,"no-flush":false},= "auto-read-only":true,"discard":"unmap"}' \ +-blockdev '{"node-name":"libvirt-1-format","read-only":false,"cache":{"dir= ect":true,"no-flush":false},"driver":"qcow2","file":"libvirt-1-storage"}' \ +-device '{"driver":"ide-hd","bus":"ide.0","unit":0,"drive":"libvirt-1-form= at","id":"ide0-0-0","bootindex":1,"write-cache":"on"}' \ +-audiodev '{"id":"audio1","driver":"none"}' \ +-device '{"driver":"virtio-vga","id":"video0","max_outputs":1,"blob":true,= "bus":"pci.0","addr":"0x2"}' \ +-device '{"driver":"virtio-gpu-pci","id":"video1","max_outputs":1,"blob":t= rue,"bus":"pci.0","addr":"0x4"}' \ +-device '{"driver":"virtio-balloon-pci","id":"balloon0","bus":"pci.0","add= r":"0x3"}' \ +-sandbox on,obsolete=3Ddeny,elevateprivileges=3Ddeny,spawn=3Ddeny,resource= control=3Ddeny \ +-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..2b8a913f49 --- /dev/null +++ b/tests/qemuxml2argvdata/video-virtio-blob-on.xml @@ -0,0 +1,36 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 1048576 + 1048576 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu-system-x86_64 + + + + +
+ + + + + + + + + + + diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 8933e373f7..7668035961 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -2403,6 +2403,9 @@ mymain(void) DO_TEST("video-virtio-vga", QEMU_CAPS_DEVICE_VIRTIO_GPU, QEMU_CAPS_DEVICE_VIRTIO_VGA); + DO_TEST_CAPS_LATEST("video-virtio-blob-on"); + DO_TEST_CAPS_LATEST("video-virtio-blob-off"); + DO_TEST_CAPS_LATEST("video-virtio-blob-absent"); 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.x86_64-lates= t.xml b/tests/qemuxml2xmloutdata/video-virtio-blob-absent.x86_64-latest.xml new file mode 100644 index 0000000000..1fa18a505c --- /dev/null +++ b/tests/qemuxml2xmloutdata/video-virtio-blob-absent.x86_64-latest.xml @@ -0,0 +1,48 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 1048576 + 1048576 + 1 + + hvm + + + + qemu64 + + + destroy + restart + destroy + + /usr/bin/qemu-system-x86_64 + + + + +
+ + +
+ + +
+ + + + +