From nobody Fri Apr 26 23:37:54 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.24 as permitted sender) client-ip=209.132.183.24; envelope-from=libvir-list-bounces@redhat.com; helo=mx3-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.24 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx3-phx2.redhat.com (mx3-phx2.redhat.com [209.132.183.24]) by mx.zohomail.com with SMTPS id 1486987336020324.1826244864019; Mon, 13 Feb 2017 04:02:16 -0800 (PST) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx3-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v1DBwTVi006286; Mon, 13 Feb 2017 06:58:30 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v1DBq58P010952 for ; Mon, 13 Feb 2017 06:52:05 -0500 Received: from localhost (ovpn-116-13.phx2.redhat.com [10.3.116.13]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1DBq3WA023101; Mon, 13 Feb 2017 06:52:04 -0500 From: marcandre.lureau@redhat.com To: libvir-list@redhat.com Date: Mon, 13 Feb 2017 15:51:48 +0400 Message-Id: <20170213115148.20405-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-loop: libvir-list@redhat.com Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [libvirt] [PATCH] RFC: qemu: add spice/virgl rendernode X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-ZohoMail: RSF_0 Z_629925259 SPT_0 From: Marc-Andr=C3=A9 Lureau I am working on a WIP series to add QEMU Spice/virgl rendernode option. Since rendernodes are not stable across reboots, I propose that QEMU accepts also a PCI address (other bus types may be added in the future). This is how I translated it to libvirt. I picked over , since it seems more generic. Comments welcome! Signed-off-by: Marc-Andr=C3=A9 Lureau --- docs/formatdomain.html.in | 13 ++++++- docs/schemas/domaincommon.rng | 5 +++ src/conf/domain_conf.c | 45 ++++++++++++++++++= ++-- src/conf/domain_conf.h | 1 + src/qemu/qemu_capabilities.c | 2 + src/qemu/qemu_capabilities.h | 1 + src/qemu/qemu_command.c | 22 +++++++++++ .../qemuxml2argv-video-virtio-gpu-spice-gl.args | 2 +- .../qemuxml2argv-video-virtio-gpu-spice-gl.xml | 6 ++- tests/qemuxml2argvtest.c | 1 + .../qemuxml2xmlout-video-virtio-gpu-spice-gl.xml | 6 ++- 11 files changed, 97 insertions(+), 7 deletions(-) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 0a115f5dc..5c0f80b3c 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -5619,7 +5619,11 @@ qemu-kvm -net nic,model=3D? /dev/null <clipboard copypaste=3D'no'/> <mouse mode=3D'client'/> <filetransfer enable=3D'no'/> - <gl enable=3D'yes'/> + <gl enable=3D'yes'> + <gpu> + <address type=3D'pci' domain=3D'0x0000' bus=3D'0x06' slot=3D'0x12= ' function=3D'0x5'/> + </gpu> + </gl> </graphics>

Spice supports variable compression settings for audio, imag= es and @@ -5665,6 +5669,13 @@ qemu-kvm -net nic,model=3D? /dev/null the gl element, by setting the enable property. (QEMU only, since 1.3.3).

+

+ By default, QEMU will pick the first available GPU. You + may specify a host GPU to use for rendering with the + gpu element that supports a PCI + address child element. (QEMU only, since 3.1). +

rdp
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index d715bff29..cc85e07d8 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -3033,6 +3033,11 @@ + + + + + diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 1bc72a4e9..a18db6dd9 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -1300,6 +1300,7 @@ void virDomainGraphicsDefFree(virDomainGraphicsDefPtr= def) break; =20 case VIR_DOMAIN_GRAPHICS_TYPE_SPICE: + virDomainDeviceInfoClear(&def->data.spice.gpu); VIR_FREE(def->data.spice.keymap); virDomainGraphicsAuthDefClear(&def->data.spice.auth); break; @@ -12159,6 +12160,13 @@ virDomainGraphicsDefParseXMLSpice(virDomainGraphic= sDefPtr def, VIR_FREE(enable); =20 def->data.spice.gl =3D enableVal; + + if (cur->children && cur->children->type =3D=3D XML_ELEMEN= T_NODE && + xmlStrEqual(cur->children->name, BAD_CAST "gpu") && + virDomainDeviceInfoParseXML(cur->children, NULL, + &def->data.spice.gpu, flag= s) < 0) + goto error; + } else if (xmlStrEqual(cur->name, BAD_CAST "mouse")) { char *mode =3D virXMLPropString(cur, "mode"); int modeVal; @@ -22839,6 +22847,36 @@ virDomainGraphicsListenDefFormatAddr(virBufferPtr = buf, virBufferAsprintf(buf, " listen=3D'%s'", glisten->address); } =20 +static int +virDomainSpiceGLDefFormat(virBufferPtr buf, virDomainGraphicsDefPtr def) +{ + virBuffer childrenBuf =3D VIR_BUFFER_INITIALIZER; + int indent =3D virBufferGetIndent(buf, false); + + if (def->data.spice.gl =3D=3D VIR_TRISTATE_BOOL_ABSENT) { + return 0; + } + + virBufferAsprintf(buf, "data.spice.gl)); + + virBufferAdjustIndent(&childrenBuf, indent + 4); + if (virDomainDeviceInfoFormat(&childrenBuf, &def->data.spice.gpu, 0) <= 0) + return -1; + if (virBufferUse(&childrenBuf)) { + virBufferAddLit(buf, ">\n"); + virBufferAdjustIndent(buf, 2); + virBufferAddLit(buf, "\n"); + virBufferAddBuffer(buf, &childrenBuf); + virBufferAddLit(buf, "\n"); + virBufferAdjustIndent(buf, -2); + virBufferAddLit(buf, "\n"); + } else { + virBufferAddLit(buf, "/>\n"); + } + virBufferFreeAndReset(&childrenBuf); + return 0; +} =20 static int virDomainGraphicsDefFormat(virBufferPtr buf, @@ -23082,9 +23120,10 @@ virDomainGraphicsDefFormat(virBufferPtr buf, if (def->data.spice.filetransfer) virBufferAsprintf(buf, "\n", virTristateBoolTypeToString(def->data.spice.= filetransfer)); - if (def->data.spice.gl) - virBufferAsprintf(buf, "\n", - virTristateBoolTypeToString(def->data.spice.= gl)); + + if (virDomainSpiceGLDefFormat(buf, def) < 0) { + return -1; + } } =20 if (children) { diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index dd79206f6..04bdf8914 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1544,6 +1544,7 @@ struct _virDomainGraphicsDef { virTristateBool copypaste; virTristateBool filetransfer; virTristateBool gl; + virDomainDeviceInfo gpu; } spice; } data; /* nListens, listens, and *port are only useful if type is vnc, diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 399e31447..e851eec7a 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -357,6 +357,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST, =20 "query-cpu-model-expansion", /* 245 */ "virtio-net.host_mtu", + "spice-rendernode", ); =20 =20 @@ -2950,6 +2951,7 @@ static struct virQEMUCapsCommandLineProps virQEMUCaps= CommandLine[] =3D { { "spice", "unix", QEMU_CAPS_SPICE_UNIX }, { "drive", "throttling.bps-total-max-length", QEMU_CAPS_DRIVE_IOTUNE_M= AX_LENGTH }, { "drive", "throttling.group", QEMU_CAPS_DRIVE_IOTUNE_GROUP }, + { "spice", "rendernode", QEMU_CAPS_SPICE_RENDERNODE }, }; =20 static int diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index 95bb67d44..0f998c473 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -393,6 +393,7 @@ typedef enum { /* 245 */ QEMU_CAPS_QUERY_CPU_MODEL_EXPANSION, /* qmp query-cpu-model-expansion = */ QEMU_CAPS_VIRTIO_NET_HOST_MTU, /* virtio-net-*.host_mtu */ + QEMU_CAPS_SPICE_RENDERNODE, /* -spice rendernode */ =20 QEMU_CAPS_LAST /* this must always be the last item */ } virQEMUCapsFlags; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index c00a47a91..3c1de3862 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -7920,6 +7920,28 @@ qemuBuildGraphicsSPICECommandLine(virQEMUDriverConfi= gPtr cfg, * TristateSwitch helper */ virBufferAsprintf(&opt, "gl=3D%s,", virTristateSwitchTypeToString(graphics->data.spi= ce.gl)); + + if (graphics->data.spice.gpu.type !=3D + VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) { + virDomainDeviceInfo *info =3D &graphics->data.spice.gpu; + char *devstr; + + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_SPICE_RENDERNODE)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("This QEMU doesn't support spice OpenGL r= endernode")); + goto error; + } + if (info->type !=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("only 'pci' addresses are supported for t= he gpu device")); + goto error; + } + if (!(devstr =3D virDomainPCIAddressAsString(&info->addr.pci))) + goto error; + + virBufferAsprintf(&opt, "rendernode=3D%s,", devstr); + VIR_FREE(devstr); + } } =20 if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_SEAMLESS_MIGRATION)) { diff --git a/tests/qemuxml2argvdata/qemuxml2argv-video-virtio-gpu-spice-gl.= args b/tests/qemuxml2argvdata/qemuxml2argv-video-virtio-gpu-spice-gl.args index f1ebb62e4..1e0728fb5 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-video-virtio-gpu-spice-gl.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-video-virtio-gpu-spice-gl.args @@ -19,6 +19,6 @@ QEMU_AUDIO_DRV=3Dspice \ -drive file=3D/var/lib/libvirt/images/QEMUGuest1,format=3Dqcow2,if=3Dnone,\ id=3Ddrive-ide0-0-0,cache=3Dnone \ -device ide-drive,bus=3Dide.0,unit=3D0,drive=3Ddrive-ide0-0-0,id=3Dide0-0-= 0 \ --spice port=3D0,gl=3Don \ +-spice port=3D0,gl=3Don,rendernode=3D0000:06:12.5 \ -device virtio-gpu-pci,id=3Dvideo0,virgl=3Don,bus=3Dpci.0,addr=3D0x2 \ -device virtio-balloon-pci,id=3Dballoon0,bus=3Dpci.0,addr=3D0x3 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-video-virtio-gpu-spice-gl.= xml b/tests/qemuxml2argvdata/qemuxml2argv-video-virtio-gpu-spice-gl.xml index b9c7c8af0..fdd3939d2 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-video-virtio-gpu-spice-gl.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-video-virtio-gpu-spice-gl.xml @@ -26,7 +26,11 @@ - + + +
+ +