From nobody Mon May 13 04:53:15 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=1674677825; cv=none; d=zohomail.com; s=zohoarc; b=l5vITMFdfz2oymeWjS+4ld/z2bqFeW2QHyV/kkDkZOmo+XoS/2Oy1MuUH8F3kLhlYkTTlXUkrvAAGPtW0gZGrGafJtp71QtVoITAD7KePuJybBoHJXQDDxxnVA4OFrYWvbQh4EgLV4mdndVLv9e8nDzuhtz5JAX+4LcEG9NW9KY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1674677825; h=Content-Type:Content-Transfer-Encoding:Cc: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=5FRkkHHFAagDo83ZvZshKywhsoSo65h0wAol3tSuiPE=; b=lCEnJH3MhTMmdh+2YJs3J/RjQFmCI75eotycruJeTgvpmqLDfKvSRrKp7ER1FtoqYfigzY/dz5uvn7wS/VmFUYf+9zllXWvxJNSl4koA+8iIDhbgmx+zGkfkBDVL9ojJnDvPNuGJikE4ICM46gWF1TfQlLgAL7uoTKD+YTS45yg= 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 1674677825078694.4364431884982; Wed, 25 Jan 2023 12:17:05 -0800 (PST) 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-360-wHW3UxjYOGq-LHUQIKOsJA-1; Wed, 25 Jan 2023 15:16:16 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8B976857F4D; Wed, 25 Jan 2023 20:16:11 +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 745A72026D2A; Wed, 25 Jan 2023 20:16:11 +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 250001946A4E; Wed, 25 Jan 2023 20:16:10 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 45C43194658C for ; Wed, 25 Jan 2023 20:16:08 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 28DC0492B02; Wed, 25 Jan 2023 20:16:08 +0000 (UTC) Received: from himantopus.redhat.com (unknown [10.22.18.185]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0037D492B01; Wed, 25 Jan 2023 20:16:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1674677823; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=5FRkkHHFAagDo83ZvZshKywhsoSo65h0wAol3tSuiPE=; b=DiXiMS5oKcaOd9X+E1qzq/zoVL9+l/p3UIpEvpRSK93dXlPcqghQjjIsnHu8p0iekw+Wsv 4GrgHPs3j+27dxVeWDgSvEkz24n6rN8OpXggF9+vVyvapQVft/q/eH6WgQ2pwef12hT2Ww iIFJ5MqZmXnZ4Mpl+dyS97R1oHMDME0= X-MC-Unique: wHW3UxjYOGq-LHUQIKOsJA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jonathon Jongsma To: libvir-list@redhat.com Subject: [libvirt PATCH v6 1/8] conf: explicitly set VIR_DOMAIN_VIDEO_TYPE_DEFAULT to 0 Date: Wed, 25 Jan 2023 14:16:00 -0600 Message-Id: <20230125201607.1378203-2-jjongsma@redhat.com> In-Reply-To: <20230125201607.1378203-1-jjongsma@redhat.com> References: <20230125201607.1378203-1-jjongsma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 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: , Cc: jtomko@redhat.com Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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: 1674677826153100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Ensure that new virDomainVideoDef objects have their 'type' set to VIR_DOMAIN_VIDEO_TYPE_DEFAULT and remove places that this value is set after construction. Since virDomainVideoDefNew() uses g_new0() allocate the instance, all fields are initialized to 0. Signed-off-by: Jonathon Jongsma Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 3 --- src/conf/domain_conf.h | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 89672deb38..42d2f2ed52 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -12871,8 +12871,6 @@ virDomainVideoDefParseXML(virDomainXMLOption *xmlop= t, _("unknown video model '%s'"), type); return NULL; } - } else { - def->type =3D VIR_DOMAIN_VIDEO_TYPE_DEFAULT; } =20 if ((ram =3D virXPathString("string(./model/@ram)", ctxt))) { @@ -21708,7 +21706,6 @@ virDomainDefAddImplicitVideo(virDomainDef *def, vir= DomainXMLOption *xmlopt) =20 if (!(video =3D virDomainVideoDefNew(xmlopt))) return -1; - video->type =3D VIR_DOMAIN_VIDEO_TYPE_DEFAULT; VIR_APPEND_ELEMENT(def->videos, def->nvideos, video); =20 return 0; diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index d99bbbc3ff..e35923e3d7 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1781,7 +1781,7 @@ typedef enum { =20 =20 typedef enum { - VIR_DOMAIN_VIDEO_TYPE_DEFAULT, + VIR_DOMAIN_VIDEO_TYPE_DEFAULT =3D 0, VIR_DOMAIN_VIDEO_TYPE_VGA, VIR_DOMAIN_VIDEO_TYPE_CIRRUS, VIR_DOMAIN_VIDEO_TYPE_VMVGA, --=20 2.39.0 From nobody Mon May 13 04:53:15 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=1674677778; cv=none; d=zohomail.com; s=zohoarc; b=dejJFPklc8RM4i6nQ2+3c4qUkcHp4JL2dt3jTZhGkX9KfygcaJFQNzjN5rgv7in0EM5QyDza81tOYwJjWgqklFQ2DuvY4vy2Lbl5gLVcvP96titslie6gLNQXYs8IM/WCOSSDGbCr9wHoP1iP6UpTs5Rx18lRjhaZ+omxej5JfY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1674677778; h=Content-Type:Content-Transfer-Encoding:Cc: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=fbtdtUJ4aJSNebvJqcDLvbNLTuWjY+KNFCQwViHaZxA=; b=Dh8mdoShlN6owLaf2hs7w3u6R23MX3tnNOD152vgqhM0pDeXDqJzDpzhi4YxR/wNIG/M96u0R0COyzmY7YlDcql8X6Ps7bGGDnMsHGFG/e6hDGXitFz4O/UnkRfnalJV/q+bWQAHCiqKoQyeJv/LR/PJNoFjjYm4S9k32A+BNoY= 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 1674677778636112.39240839851743; Wed, 25 Jan 2023 12:16:18 -0800 (PST) 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-365-xakmqU42MSK5B5J8Js3GgA-1; Wed, 25 Jan 2023 15:16:15 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0539B85C075; Wed, 25 Jan 2023 20:16:11 +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 4915DC15BA0; Wed, 25 Jan 2023 20:16:10 +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 8A9ED1946594; Wed, 25 Jan 2023 20:16:09 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 7FFBA194658C for ; Wed, 25 Jan 2023 20:16:08 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 646E0492B02; Wed, 25 Jan 2023 20:16:08 +0000 (UTC) Received: from himantopus.redhat.com (unknown [10.22.18.185]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3B56B492B01; Wed, 25 Jan 2023 20:16:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1674677777; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=fbtdtUJ4aJSNebvJqcDLvbNLTuWjY+KNFCQwViHaZxA=; b=SkGXHCoou6JpwkE/EbEcFcWRbvxxfG8lZPRJkNmY0XlwEigpfLFhbKi5QMirwjKdSEhCc0 SC1cnuS/55ymkjcq2PFuTkFEjSiiKgJ9Z5Y+gD4tUI9EnSyH6kNYfSlZOGgZm0936qpIt/ im0i/6gtEcmfyqYmuJ0vCQXf2eB7IDQ= X-MC-Unique: xakmqU42MSK5B5J8Js3GgA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jonathon Jongsma To: libvir-list@redhat.com Subject: [libvirt PATCH v6 2/8] conf: Refactor video model parsing Date: Wed, 25 Jan 2023 14:16:01 -0600 Message-Id: <20230125201607.1378203-3-jjongsma@redhat.com> In-Reply-To: <20230125201607.1378203-1-jjongsma@redhat.com> References: <20230125201607.1378203-1-jjongsma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 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: , Cc: jtomko@redhat.com Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1674677780011100001 Factor out a separate function to parse out the element for video devices. Signed-off-by: Jonathon Jongsma Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 91 ++++++++++++++++++++++++++---------------- 1 file changed, 56 insertions(+), 35 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 42d2f2ed52..951c15ac58 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -12821,14 +12821,11 @@ 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) @@ -12840,79 +12837,103 @@ virDomainVideoDefParseXML(virDomainXMLOption *xm= lopt, g_autofree char *vgamem =3D NULL; g_autofree char *primary =3D NULL; =20 - if (!(def =3D virDomainVideoDefNew(xmlopt))) - return NULL; - 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; } } =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; + } + + 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.39.0 From nobody Mon May 13 04:53:15 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=1674677826; cv=none; d=zohomail.com; s=zohoarc; b=lTxJTx1NFUzdxWPhhmhyY/yHReOh+klmSTxU4mDJZaKT52zPh6HCvz+I4i2LyBLnwW8abxi8pjukzHn/MlBOLxgttcADr1DWoAx5A6SfFoEEpqLnocBWpMFwSsdmr1cLsJbKn0S/piyYZkcv+srgtNyxLGMBwObQqZkEOiSC4r8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1674677826; h=Content-Type:Content-Transfer-Encoding:Cc: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=87B6jD8ZxkufO9aJwk7B9gd0y5BA/xSm1MykCiVt+fk=; b=lGNNlIrTqXMqjOmKh0/pocAw4bYqr842Ui1rOW4zDsEe7fV+9cLpzP5+TyvM4/6JmLmoK/d3qJz2BP0yJc+R2hs40Tje5Ap1QkcPc6kQ3TzsdtdDLzsq+y/tpr2/bAMn9/FzlvN41Q6YoCOPxG5Gvqb3+lWOzeeY+0WhKMrOMS4= 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 1674677826204861.7566908645651; Wed, 25 Jan 2023 12:17:06 -0800 (PST) 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-633-rvffepE7NiO9CsUo_dcJjA-1; Wed, 25 Jan 2023 15:16:17 -0500 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 3F8ED3C0D866; Wed, 25 Jan 2023 20:16:11 +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 EC624492B01; Wed, 25 Jan 2023 20:16:10 +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 C21A71946A45; Wed, 25 Jan 2023 20:16:09 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id C9ED7194658C for ; Wed, 25 Jan 2023 20:16:08 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id A0721492B03; Wed, 25 Jan 2023 20:16:08 +0000 (UTC) Received: from himantopus.redhat.com (unknown [10.22.18.185]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 76A8A492B01; Wed, 25 Jan 2023 20:16:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1674677825; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=87B6jD8ZxkufO9aJwk7B9gd0y5BA/xSm1MykCiVt+fk=; b=hh3e7UYrFegnxtDxnTBmN/vo/1tYZflABemwsHXpF+Af0YCxaWMQd2/fzpdC13+jucScs1 YkFimvcF0MI2gpbWnXrrr5eqI7R93btPenX5dUm7lUMLAQFhOizVyL1dTqB+taXnTM0kg5 GNlcfVjnMVhvI+h1lzEN7VsoNvyMxCI= X-MC-Unique: rvffepE7NiO9CsUo_dcJjA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jonathon Jongsma To: libvir-list@redhat.com Subject: [libvirt PATCH v6 3/8] util: add virXMLPropUIntDefault() function Date: Wed, 25 Jan 2023 14:16:02 -0600 Message-Id: <20230125201607.1378203-4-jjongsma@redhat.com> In-Reply-To: <20230125201607.1378203-1-jjongsma@redhat.com> References: <20230125201607.1378203-1-jjongsma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 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: , Cc: jtomko@redhat.com Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 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: 1674677828180100003 Content-Type: text/plain; charset="utf-8"; x-default="true" This function allows you to specify a default value to return if the property is not found rather than always setting *result to 0. Signed-off-by: Jonathon Jongsma Reviewed-by: J=C3=A1n Tomko --- src/conf/cpu_conf.c | 9 +++------ src/conf/domain_conf.c | 6 +----- src/conf/numa_conf.c | 7 +------ src/util/virxml.c | 29 ++++++++++++++++++++++++++++- src/util/virxml.h | 9 +++++++++ 5 files changed, 42 insertions(+), 18 deletions(-) diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c index a33f39ef31..d1d11e3257 100644 --- a/src/conf/cpu_conf.c +++ b/src/conf/cpu_conf.c @@ -570,7 +570,6 @@ virCPUDefParseXML(xmlXPathContextPtr ctxt, } =20 if ((topology =3D virXPathNode("./topology[1]", ctxt))) { - int rc; =20 if (virXMLPropUInt(topology, "sockets", 10, VIR_XML_PROP_REQUIRED | VIR_XML_PROP_NONZERO, @@ -578,12 +577,10 @@ virCPUDefParseXML(xmlXPathContextPtr ctxt, return -1; } =20 - if ((rc =3D virXMLPropUInt(topology, "dies", 10, - VIR_XML_PROP_NONZERO, - &def->dies)) < 0) { + if (virXMLPropUIntDefault(topology, "dies", 10, + VIR_XML_PROP_NONZERO, + &def->dies, 1) < 0) { return -1; - } else if (rc =3D=3D 0) { - def->dies =3D 1; } =20 if (virXMLPropUInt(topology, "cores", 10, diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 951c15ac58..04c9b1d174 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -16971,7 +16971,6 @@ virDomainVcpuParse(virDomainDef *def, unsigned int vcpus; g_autofree char *tmp =3D NULL; g_autofree xmlNodePtr *nodes =3D NULL; - int rc; =20 vcpus =3D maxvcpus =3D 1; =20 @@ -16986,11 +16985,8 @@ virDomainVcpuParse(virDomainDef *def, } VIR_FREE(tmp); =20 - if ((rc =3D virXMLPropUInt(vcpuNode, "current", 10, VIR_XML_PROP_N= ONE, &vcpus)) < 0) { + if (virXMLPropUIntDefault(vcpuNode, "current", 10, VIR_XML_PROP_NO= NE, &vcpus, maxvcpus) < 0) return -1; - } else if (rc =3D=3D 0) { - vcpus =3D maxvcpus; - } =20 if (virXMLPropEnumDefault(vcpuNode, "placement", virDomainCpuPlacementModeTypeFromString, diff --git a/src/conf/numa_conf.c b/src/conf/numa_conf.c index b55bb3ffcb..7ef7aa5138 100644 --- a/src/conf/numa_conf.c +++ b/src/conf/numa_conf.c @@ -916,16 +916,11 @@ virDomainNumaDefParseXML(virDomainNuma *def, for (i =3D 0; i < n; i++) { VIR_XPATH_NODE_AUTORESTORE(ctxt) g_autofree char *tmp =3D NULL; - int rc; unsigned int cur_cell; =20 - if ((rc =3D virXMLPropUInt(cell[i], "id", 10, VIR_XML_PROP_NONE, - &cur_cell)) < 0) + if (virXMLPropUIntDefault(cell[i], "id", 10, VIR_XML_PROP_NONE, &c= ur_cell, i) < 0) return -1; =20 - if (rc =3D=3D 0) - cur_cell =3D i; - /* cells are in order of parsing or explicitly numbered */ if (cur_cell >=3D n) { virReportError(VIR_ERR_XML_ERROR, "%s", diff --git a/src/util/virxml.c b/src/util/virxml.c index 9b6ccfd6c9..af4be4e443 100644 --- a/src/util/virxml.c +++ b/src/util/virxml.c @@ -560,12 +560,39 @@ virXMLPropUInt(xmlNodePtr node, int base, virXMLPropFlags flags, unsigned int *result) +{ + return virXMLPropUIntDefault(node, name, base, flags, result, 0); +} + + +/** + * virXMLPropUIntDefault: + * @node: XML dom node pointer + * @name: Name of the property (attribute) to get + * @base: Number base, see strtol + * @flags: Bitwise-OR of virXMLPropFlags + * @result: The returned value + * @defaultResult: Default value of @result in case the property is not fo= und + * + * Convenience function to return value of an unsigned integer attribute. + * + * Returns 1 in case of success in which case @result is set, + * or 0 if the attribute is not present, + * or -1 and reports an error on failure. + */ +int +virXMLPropUIntDefault(xmlNodePtr node, + const char *name, + int base, + virXMLPropFlags flags, + unsigned int *result, + unsigned int defaultResult) { g_autofree char *tmp =3D NULL; int ret; unsigned int val; =20 - *result =3D 0; + *result =3D defaultResult; =20 if (!(tmp =3D virXMLPropString(node, name))) { if (!(flags & VIR_XML_PROP_REQUIRED)) diff --git a/src/util/virxml.h b/src/util/virxml.h index d5b998263c..cca9f222ab 100644 --- a/src/util/virxml.h +++ b/src/util/virxml.h @@ -132,6 +132,15 @@ virXMLPropUInt(xmlNodePtr node, unsigned int *result) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(5); =20 +int +virXMLPropUIntDefault(xmlNodePtr node, + const char *name, + int base, + virXMLPropFlags flags, + unsigned int *result, + unsigned int defaultResult) + ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(5); + int virXMLPropLongLong(xmlNodePtr node, const char *name, --=20 2.39.0 From nobody Mon May 13 04:53:15 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=1674677781; cv=none; d=zohomail.com; s=zohoarc; b=Z7Rs5+0KOgraWBq43fn3TYJxjT+T1DKRlhyCMCdCvU8zlXu0ZPapw9/xlX+/xqTs9haEaPCftCV/ZelZc7yC/KEUCNcAg8GkHIlCdxpLU5psBuxkNhmBfiN2S9gyG32v4ph5uni/yhwzNJGhc13y01LYiLcoYpFdE9n+baRUiEA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1674677781; h=Content-Type:Content-Transfer-Encoding:Cc: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=ewinvM8bL/SDS/iy1ANHxl2Uhpffl/iIyqpRHkb8cAo=; b=Ag/JKqSG1iKfSBVHKgiLeugNBxcHSCyoaHmlpjSfqqhQ7elBeHGHUgZMFiwitpDBRCCHqxghggMyUGH0/ydMGXZInNCgiRp8BlLB+7dwm6RCJVBK18PqUN7cVarytRnv70p6JBs+uQaBMPQkcTvOrIk9SLA3HgbdKSyMnGHcqDY= 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 1674677781508484.8738088384539; Wed, 25 Jan 2023 12:16:21 -0800 (PST) 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-10-jb1vgta2OBuj6BXOz1fbzA-1; Wed, 25 Jan 2023 15:16:16 -0500 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 F103D2802E44; Wed, 25 Jan 2023 20:16:11 +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 DC61040ED76C; Wed, 25 Jan 2023 20:16:11 +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 5FBF91946A6A; Wed, 25 Jan 2023 20:16:10 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 0528B19465A4 for ; Wed, 25 Jan 2023 20:16:09 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id DBAAC492B02; Wed, 25 Jan 2023 20:16:08 +0000 (UTC) Received: from himantopus.redhat.com (unknown [10.22.18.185]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B2701492B01; Wed, 25 Jan 2023 20:16:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1674677780; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=ewinvM8bL/SDS/iy1ANHxl2Uhpffl/iIyqpRHkb8cAo=; b=O447uSd4ISVnQWy125B8VeBQlIIHJO3nAzBHVYCdJ9GhKPzxsezzvIPaGlpI6x8zaoeCRC 4o4+nsSkgJ2IZAy3nO2C9ZCfB7PL73RngtrzR06KKMc5u+jCM37Q2P7NXHy0gYOI/P57k1 XfLAAKk95amqYMB/owCERZeuX69bizw= X-MC-Unique: jb1vgta2OBuj6BXOz1fbzA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jonathon Jongsma To: libvir-list@redhat.com Subject: [libvirt PATCH v6 4/8] conf: switch to virXMLProp* functions for parsing video Date: Wed, 25 Jan 2023 14:16:03 -0600 Message-Id: <20230125201607.1378203-5-jjongsma@redhat.com> In-Reply-To: <20230125201607.1378203-1-jjongsma@redhat.com> References: <20230125201607.1378203-1-jjongsma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 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: , Cc: jtomko@redhat.com Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1674677782037100005 In virDomainVideoModelDefParseXML(), use the virXMLProp* functions rather than reimplementing them with virXPath* functions. Signed-off-by: Jonathon Jongsma Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 73 ++++++++++++------------------------------ 1 file changed, 20 insertions(+), 53 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 04c9b1d174..48b208fd10 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -12829,18 +12829,13 @@ virDomainVideoModelDefParseXML(virDomainVideoDef = *def, 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; - 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; =20 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) @@ -12850,55 +12845,27 @@ 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; - } - } - - 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 (virXMLPropUIntDefault(node, "heads", 10, VIR_XML_PROP_NONE, &def->= heads, 1) < 0) + return -1; =20 return 0; } --=20 2.39.0 From nobody Mon May 13 04:53:15 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=1674677833; cv=none; d=zohomail.com; s=zohoarc; b=USQGokdeZe88kqk962HxfY4dcNi+dBRQuWA7BTO/pblhSO6Omst4L0W3EZTFJolyigL/mieRxT5wFGPbOzV+gn21GZLdCogt4nw9LiL6SG+2fusE/Eh4ipE2Fm7sO8rTQJfKMvsVjFoyX/gXog+V7PXma7TBE26TOFt54hEwBAM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1674677833; h=Content-Type:Content-Transfer-Encoding:Cc: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=7nZZLtPquaUCw78t5AUemmt8P9LogPuju16/Xjpt81g=; b=oDotCaMzpmZSKT7hQK4NvBfEqBjE1dIQbJYN1qWCRw9TupXAM+xlqvo6gMpCPs9VqiKs9yIIJQIh6W+1/tUJY3BRUe1K6Kb/C0lHI0FVq6YBYysBunCQj0//4ihkMEZGr9EtU6l/7ojPG6oVgC0UZ2IK7/u2ZbK/5Ue/NUDj32s= 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 1674677833907411.8297356613267; Wed, 25 Jan 2023 12:17:13 -0800 (PST) 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-217-SRmP5irLO22aa7CBdQCmaA-1; Wed, 25 Jan 2023 15:16:18 -0500 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 91E6285C087; Wed, 25 Jan 2023 20:16:12 +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 79FF140C200C; Wed, 25 Jan 2023 20:16:12 +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 A701419465B7; Wed, 25 Jan 2023 20:16:11 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id B6AAB1946A42 for ; Wed, 25 Jan 2023 20:16:09 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id A9D9A492D0F; Wed, 25 Jan 2023 20:16:09 +0000 (UTC) Received: from himantopus.redhat.com (unknown [10.22.18.185]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EDC5C492B01; Wed, 25 Jan 2023 20:16:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1674677832; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=7nZZLtPquaUCw78t5AUemmt8P9LogPuju16/Xjpt81g=; b=OX0178M154jtPoOmHbvHpaafCcvWnvO2tcQraTJVOI0PFnsqW9VpcDgkNlsRUod9uD6ZYf j9VQ98hcALQPDoPXAgqUvOFqfZtXKZvaTUW7Kbq8tVO424y/rhVAumZfsThJ2aXcoOVyJQ b5IuZQXNxP6r6HI5xbo2ZzzemqPdc+I= X-MC-Unique: SRmP5irLO22aa7CBdQCmaA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jonathon Jongsma To: libvir-list@redhat.com Subject: [libvirt PATCH v6 5/8] conf: use enum variable for video type Date: Wed, 25 Jan 2023 14:16:04 -0600 Message-Id: <20230125201607.1378203-6-jjongsma@redhat.com> In-Reply-To: <20230125201607.1378203-1-jjongsma@redhat.com> References: <20230125201607.1378203-1-jjongsma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 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: , Cc: jtomko@redhat.com Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1674677834218100003 Rather than storing the video type as an integer, use the proper enum type within the struct. Signed-off-by: Jonathon Jongsma Reviewed-by: J=C3=A1n Tomko --- 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 48b208fd10..fcc65011b0 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -12829,7 +12829,6 @@ virDomainVideoModelDefParseXML(virDomainVideoDef *d= ef, xmlNodePtr accel_node; xmlNodePtr res_node; VIR_XPATH_NODE_AUTORESTORE(ctxt) - virDomainVideoType type; virTristateBool primary; =20 ctxt->node =3D node; @@ -12847,10 +12846,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 e35923e3d7..8890f5a3a5 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1828,7 +1828,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 17ac880634..d72f28c19e 100644 --- a/src/libxl/libxl_conf.c +++ b/src/libxl/libxl_conf.c @@ -2376,6 +2376,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 66a82ca317..f28a6207a3 100644 --- a/src/libxl/libxl_domain.c +++ b/src/libxl/libxl_domain.c @@ -201,6 +201,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 db99017555..278ceb83d3 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -1786,9 +1786,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; } @@ -1826,11 +1833,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 9ac6b45e75..7a1ada6d65 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -3038,9 +3038,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.39.0 From nobody Mon May 13 04:53:15 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=1674677836; cv=none; d=zohomail.com; s=zohoarc; b=axaqiZG1b8bapXfpFvx79vEmbHHYEhaq8BEkrHFUGXZTZ+rX7JE3szLkZTmO9EXoWxQ04CXT/JUCxQh+SH6YUj7pBi3JnO/0dMaQPJjhHQXzQk4ArMSbrZw2is3ZpPUm+1RphISA8UIJKrEn/D1B/MDCTvJsoVuS/O5OgtdwkKE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1674677836; h=Content-Type:Content-Transfer-Encoding:Cc: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=O00HAtmC4iyuf+kTeqpSKoziD6rliRDsdftMEN3pMTI=; b=CtGrXLAaZJZrc8sn/kNwSPKAHzWHbGeE9IH/nwlGwmQ0YhTBRcMsBaLbmNbgZwQ7VtfX720pBZr67CxsyyPRmVi5Kk5LSUH1tmCGnoZzZyUaBrSi9uJE8e4rU7XJKg+XxVj4vUSg8Dz1UoJcRD34obHIYZ09yXyeU0KhSrp52x4= 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 1674677836190619.9432772062527; Wed, 25 Jan 2023 12:17:16 -0800 (PST) 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-157-T4lqdMHONdmAMAgSErD4HA-1; Wed, 25 Jan 2023 15:16:22 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C18FA802534; Wed, 25 Jan 2023 20:16:13 +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 A6C3B2026D33; Wed, 25 Jan 2023 20:16:13 +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 28F1E194658D; Wed, 25 Jan 2023 20:16:13 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id F04361946A4E for ; Wed, 25 Jan 2023 20:16:09 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id E5C8A492B03; Wed, 25 Jan 2023 20:16:09 +0000 (UTC) Received: from himantopus.redhat.com (unknown [10.22.18.185]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BC029492B01; Wed, 25 Jan 2023 20:16:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1674677835; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=O00HAtmC4iyuf+kTeqpSKoziD6rliRDsdftMEN3pMTI=; b=is/555WrJt8zw/aumCEOxw2bPpgQgCUn4p+mMX90KmFfOizAPF+HZXElkrQGweAvjSq388 hiIsyALrWXlG+tmMK8Zhn4MnmgTY7eLC1CgSKWM6sFXZiX6KtiB7HqWVMG8qrqlqW2uFC2 R9g/7QoaSdpZ61ueiKAQUviVNZXdDSM= X-MC-Unique: T4lqdMHONdmAMAgSErD4HA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jonathon Jongsma To: libvir-list@redhat.com Subject: [libvirt PATCH v6 6/8] conf: add support for 'blob' in virtio video device Date: Wed, 25 Jan 2023 14:16:05 -0600 Message-Id: <20230125201607.1378203-7-jjongsma@redhat.com> In-Reply-To: <20230125201607.1378203-1-jjongsma@redhat.com> References: <20230125201607.1378203-1-jjongsma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 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: , Cc: jtomko@redhat.com Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1674677838205100001 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 Reviewed-by: J=C3=A1n Tomko --- docs/formatdomain.rst | 7 +++++++ src/conf/domain_conf.c | 5 +++++ src/conf/domain_conf.h | 1 + src/conf/domain_validate.c | 13 ++++++++++--- src/conf/schemas/domaincommon.rng | 5 +++++ 5 files changed, 28 insertions(+), 3 deletions(-) diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst index fbbee99a80..59d83bdf3c 100644 --- a/docs/formatdomain.rst +++ b/docs/formatdomain.rst @@ -6427,6 +6427,13 @@ A video device. :since:`since 1.3.3` ) extends secondary bar and makes it addressable as 64bit memory. =20 + :since:`Since 8.10.0` (QEMU driver only), devices with type "virtio" ha= ve 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 fcc65011b0..a7ee12defe 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -12865,6 +12865,9 @@ virDomainVideoModelDefParseXML(virDomainVideoDef *d= ef, if (virXMLPropUIntDefault(node, "heads", 10, VIR_XML_PROP_NONE, &def->= heads, 1) < 0) return -1; =20 + if (virXMLPropTristateSwitch(node, "blob", VIR_XML_PROP_NONE, &def->bl= ob) < 0) + return -1; + return 0; } =20 @@ -25177,6 +25180,8 @@ 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'", virTristateSwitchTypeToStri= ng(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 8890f5a3a5..5bd5c0d5e4 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1837,6 +1837,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 5559a71e14..10eeceda74 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 14044811c0..5661b930f7 100644 --- a/src/conf/schemas/domaincommon.rng +++ b/src/conf/schemas/domaincommon.rng @@ -4481,6 +4481,11 @@ + + + + + --=20 2.39.0 From nobody Mon May 13 04:53:15 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=1674677780; cv=none; d=zohomail.com; s=zohoarc; b=e3dpIMMvmc3qxOgNZ1s68v+AGhMa9t2UWvq/2uDEAPsJbtJ/iymZ1Q21YYIgpoLwO9sGLkUKLj81zQ3Fuve25QDUd5wXiEhpRNRHG3BzI8xBMTI/LH5+xHV3kJGGCBM/dUu2TLYD3O0Y9uFz4+XMEx8wQD47zMwAqoXs/BaF11I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1674677780; h=Content-Type:Content-Transfer-Encoding:Cc: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=37POQDx43Kw4xAwQxVBxJ3NNiVHZRSyARuD4Ly59ie0=; b=RXqneC6Km3qniflJi4izP/7DQYiSH8WJIDyEjLqa68OuUp7ds476+Xg4u5eAqQVtG5fzDkP+N9Dt96zRKJGNogvWXvsx5aWAvuorlcDzbM3Esvg6+XfLldJf/KEtWDW5MRJzv8wyC5lp7vtEGT1mpSdzhWwbRjBQ0Vn1FKt5eak= 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 1674677780226869.5602217110284; Wed, 25 Jan 2023 12:16:20 -0800 (PST) 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-58-kpO-bkkEOEeBa6vPspGL-w-1; Wed, 25 Jan 2023 15:16:17 -0500 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 DCF1E1C06914; Wed, 25 Jan 2023 20:16:12 +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 C9A2040C200E; Wed, 25 Jan 2023 20:16:12 +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 DEED91946A47; Wed, 25 Jan 2023 20:16:11 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 471FA1946A66 for ; Wed, 25 Jan 2023 20:16:10 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 3829F492B03; Wed, 25 Jan 2023 20:16:10 +0000 (UTC) Received: from himantopus.redhat.com (unknown [10.22.18.185]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 06437483EC0; Wed, 25 Jan 2023 20:16:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1674677779; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=37POQDx43Kw4xAwQxVBxJ3NNiVHZRSyARuD4Ly59ie0=; b=hh+QgIRx6i2ybJQCMMRR/nFbT8XfMtMxtTRw4bJPAIYOVj04xuoDU9k1oshLJr1Irn4KBN 8Etl3EQgD9NP7F3M7PbsZIvzcxwH8rpFUC3nPQlD/+pAfXQFDcZiJ+bM6fNOnPuekh4GwB lnW1zzonQO51HVG1aR2Ej1Q0MFZZJXM= X-MC-Unique: kpO-bkkEOEeBa6vPspGL-w-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jonathon Jongsma To: libvir-list@redhat.com Subject: [libvirt PATCH v6 7/8] qemu: Add capability for virtio-gpu.blob Date: Wed, 25 Jan 2023 14:16:06 -0600 Message-Id: <20230125201607.1378203-8-jjongsma@redhat.com> In-Reply-To: <20230125201607.1378203-1-jjongsma@redhat.com> References: <20230125201607.1378203-1-jjongsma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 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: , Cc: jtomko@redhat.com Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1674677782028100004 Capability to determine whether this qemu supports the 'blob' option for virtio-gpu. Signed-off-by: Jonathon Jongsma Reviewed-by: J=C3=A1n Tomko --- 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.ppc64.xml | 1 + tests/qemucapabilitiesdata/caps_7.1.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_7.2.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_8.0.0.riscv64.xml | 1 + tests/qemucapabilitiesdata/caps_8.0.0.x86_64.xml | 1 + 14 files changed, 15 insertions(+) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 9c3650e022..b9646608df 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -686,6 +686,7 @@ VIR_ENUM_IMPL(virQEMUCaps, "netdev.stream", /* QEMU_CAPS_NETDEV_STREAM */ "virtio-crypto", /* QEMU_CAPS_DEVICE_VIRTIO_CRYPTO */ "cryptodev-backend-lkcf", /* QEMU_CAPS_OBJECT_CRYPTO_LKCF */ + "virtio-gpu.blob", /* QEMU_CAPS_VIRTIO_GPU_BLOB */ ); =20 =20 @@ -1507,6 +1508,7 @@ static struct virQEMUCapsDevicePropsFlags virQEMUCaps= DevicePropsQxl[] =3D { static struct virQEMUCapsDevicePropsFlags virQEMUCapsDevicePropsVirtioGpu[= ] =3D { { "virgl", QEMU_CAPS_VIRTIO_GPU_VIRGL, 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 5bf87c2f8d..f8551f5473 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -665,6 +665,7 @@ typedef enum { /* virQEMUCapsFlags grouping marker for = syntax-check */ QEMU_CAPS_NETDEV_STREAM, /* -netdev stream */ QEMU_CAPS_DEVICE_VIRTIO_CRYPTO, /* virtio-crypto device */ QEMU_CAPS_OBJECT_CRYPTO_LKCF, /* -object cryptodev-backend-lkcf */ + 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 f303f439d6..99c33d1590 100644 --- a/tests/qemucapabilitiesdata/caps_6.1.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_6.1.0.x86_64.xml @@ -189,6 +189,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 a573d465fb..b6c1504662 100644 --- a/tests/qemucapabilitiesdata/caps_6.2.0.aarch64.xml +++ b/tests/qemucapabilitiesdata/caps_6.2.0.aarch64.xml @@ -156,6 +156,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 56269483c0..261385cc76 100644 --- a/tests/qemucapabilitiesdata/caps_6.2.0.ppc64.xml +++ b/tests/qemucapabilitiesdata/caps_6.2.0.ppc64.xml @@ -150,6 +150,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 e9f65434ee..f33b8d1034 100644 --- a/tests/qemucapabilitiesdata/caps_6.2.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_6.2.0.x86_64.xml @@ -191,6 +191,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 16c4df09c2..6118d3cf4b 100644 --- a/tests/qemucapabilitiesdata/caps_7.0.0.aarch64.xml +++ b/tests/qemucapabilitiesdata/caps_7.0.0.aarch64.xml @@ -164,6 +164,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 302ab8dacb..66f03a4427 100644 --- a/tests/qemucapabilitiesdata/caps_7.0.0.ppc64.xml +++ b/tests/qemucapabilitiesdata/caps_7.0.0.ppc64.xml @@ -168,6 +168,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 893b5670e5..3422867e1d 100644 --- a/tests/qemucapabilitiesdata/caps_7.0.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_7.0.0.x86_64.xml @@ -197,6 +197,7 @@ + 7000000 0 43100243 diff --git a/tests/qemucapabilitiesdata/caps_7.1.0.ppc64.xml b/tests/qemuca= pabilitiesdata/caps_7.1.0.ppc64.xml index 5ffc2213c1..06a7544c8d 100644 --- a/tests/qemucapabilitiesdata/caps_7.1.0.ppc64.xml +++ b/tests/qemucapabilitiesdata/caps_7.1.0.ppc64.xml @@ -168,6 +168,7 @@ + 7001000 0 42900244 diff --git a/tests/qemucapabilitiesdata/caps_7.1.0.x86_64.xml b/tests/qemuc= apabilitiesdata/caps_7.1.0.x86_64.xml index 5d7d98bb56..5649eab014 100644 --- a/tests/qemucapabilitiesdata/caps_7.1.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_7.1.0.x86_64.xml @@ -200,6 +200,7 @@ + 7001000 0 43100244 diff --git a/tests/qemucapabilitiesdata/caps_7.2.0.x86_64.xml b/tests/qemuc= apabilitiesdata/caps_7.2.0.x86_64.xml index fccf9b7923..39aaa7513e 100644 --- a/tests/qemucapabilitiesdata/caps_7.2.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_7.2.0.x86_64.xml @@ -204,6 +204,7 @@ + 7002000 0 43100245 diff --git a/tests/qemucapabilitiesdata/caps_8.0.0.riscv64.xml b/tests/qemu= capabilitiesdata/caps_8.0.0.riscv64.xml index 0e273f168a..4d562bb1f1 100644 --- a/tests/qemucapabilitiesdata/caps_8.0.0.riscv64.xml +++ b/tests/qemucapabilitiesdata/caps_8.0.0.riscv64.xml @@ -143,6 +143,7 @@ + 7002050 0 0 diff --git a/tests/qemucapabilitiesdata/caps_8.0.0.x86_64.xml b/tests/qemuc= apabilitiesdata/caps_8.0.0.x86_64.xml index c8b7f95c4a..082412bf1a 100644 --- a/tests/qemucapabilitiesdata/caps_8.0.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_8.0.0.x86_64.xml @@ -204,6 +204,7 @@ + 7002050 0 43100244 --=20 2.39.0 From nobody Mon May 13 04:53:15 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=1674677830; cv=none; d=zohomail.com; s=zohoarc; b=egp7ELqnmA7rT9EHya0ctQPVhbCiNTPjvFwtSlU9VpdHDusLsSAtOGcndRSWRDOQP2JehDSREgEQpKUWO3HWJcqCNp7R9ZaHeVcFsa49S8bBIr1KKgt/g/lL9J92s6MBiaI13OC1DErSUOX+ypq6TaRe7I4vIJoWjHbpXmRj+BE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1674677830; h=Content-Type:Content-Transfer-Encoding:Cc: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=R+dUqmG8tYqeZkDW+GteTTGCTq77HnAr5QoF52QBzSE=; b=TD7J5lztqwBwlho37RfEVGxx8Jua4vDPRtz4HhXp1ygTKmjXh1R0s9NY0lyABS7AqBp0KlH8+waDM66UiwZdHAyDBz19A39KBnu8QGQo/hVlcg9VdZxvba/MxWgeonXCu9QsN64ElNhknsMbGBJPt4SA9Y1aPq9Og+lgyKptd38= 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 1674677830833332.1084652745293; Wed, 25 Jan 2023 12:17:10 -0800 (PST) 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-421-JgGUUJF9MPSq8rqppZZ19Q-1; Wed, 25 Jan 2023 15:16:18 -0500 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 3C8CE100F920; Wed, 25 Jan 2023 20:16:13 +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 24194492B04; Wed, 25 Jan 2023 20:16:13 +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 10B501946A54; Wed, 25 Jan 2023 20:16:12 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 95D2C1946A72 for ; Wed, 25 Jan 2023 20:16:10 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 7CBD1492D8B; Wed, 25 Jan 2023 20:16:10 +0000 (UTC) Received: from himantopus.redhat.com (unknown [10.22.18.185]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4A925492B01; Wed, 25 Jan 2023 20:16:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1674677829; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=R+dUqmG8tYqeZkDW+GteTTGCTq77HnAr5QoF52QBzSE=; b=J8xqf8yjJwMHKXDE+oItnIl6RhEKnZ4cOee16fX+/k0WOetqcND6ZWElqAEhINTsqhc1fF VLizG6EXTtnm7AKbiJ3W9hYQDJzu32im8pjKcPaoySB5bV58WcMODH93RDxbNhw/kucn8j HDlzzWla9Q2Xo1soYK1rzabG+ljuWGs= X-MC-Unique: JgGUUJF9MPSq8rqppZZ19Q-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jonathon Jongsma To: libvir-list@redhat.com Subject: [libvirt PATCH v6 8/8] qemu: Implement 'blob' support for virtio gpu Date: Wed, 25 Jan 2023 14:16:07 -0600 Message-Id: <20230125201607.1378203-9-jjongsma@redhat.com> In-Reply-To: <20230125201607.1378203-1-jjongsma@redhat.com> References: <20230125201607.1378203-1-jjongsma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 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: , Cc: jtomko@redhat.com Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1674677832228100001 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 Reviewed-by: J=C3=A1n Tomko --- 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 ++++ .../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 | 2 + .../video-virtio-blob-off.x86_64-latest.xml | 48 +++++++++++++++++++ .../video-virtio-blob-on.x86_64-latest.xml | 48 +++++++++++++++++++ tests/qemuxml2xmltest.c | 2 + 13 files changed, 300 insertions(+), 7 deletions(-) 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-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 aac7c70054..b1178e0146 100644 --- a/src/qemu/qemu_cgroup.c +++ b/src/qemu/qemu_cgroup.c @@ -629,16 +629,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 4ba978f3e6..efccdf505f 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -4527,6 +4527,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 eca5404cdc..ca191f7041 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -84,6 +84,7 @@ struct _qemuDomainUnpluggingDevice { #define QEMU_DEV_SGX_VEPVC "/dev/sgx_vepc" #define QEMU_DEV_SGX_PROVISION "/dev/sgx_provision" #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 5769a4dfe0..e2d705d56c 100644 --- a/src/qemu/qemu_namespace.c +++ b/src/qemu/qemu_namespace.c @@ -517,6 +517,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) @@ -688,6 +707,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 9829c4e7ff..4858fed68c 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -2723,6 +2723,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 (video->type =3D=3D VIR_DOMAIN_VIDEO_TYPE_RAMFB && video->info.type !=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", 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 3e58a73e41..2a8dc22025 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -2165,6 +2165,8 @@ 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-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-off.x86_64-latest.x= ml b/tests/qemuxml2xmloutdata/video-virtio-blob-off.x86_64-latest.xml new file mode 100644 index 0000000000..d8de97a642 --- /dev/null +++ b/tests/qemuxml2xmloutdata/video-virtio-blob-off.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 + + + + +
+ + +
+ + +
+ + + + +