From nobody Mon Feb 9 19:53:03 2026 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 + + + + +
+ + +
+ + +
+ + + + +