mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-09 06:25:19 +00:00
qemu: add spice opengl support
Add Spice graphics gl attribute. qemu 2.6 should have -spice gl=on argument to enable opengl rendering context (patches on the ML). This is necessary to actually enable virgl rendering. Add a qemuxml2argv test for virtio-gpu + spice with virgl. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
d0e9d23e9e
commit
937ebba00e
@ -5002,6 +5002,7 @@ qemu-kvm -net nic,model=? /dev/null
|
|||||||
<clipboard copypaste='no'/>
|
<clipboard copypaste='no'/>
|
||||||
<mouse mode='client'/>
|
<mouse mode='client'/>
|
||||||
<filetransfer enable='no'/>
|
<filetransfer enable='no'/>
|
||||||
|
<gl enable='yes'/>
|
||||||
</graphics></pre>
|
</graphics></pre>
|
||||||
<p>
|
<p>
|
||||||
Spice supports variable compression settings for audio,
|
Spice supports variable compression settings for audio,
|
||||||
@ -5048,6 +5049,13 @@ qemu-kvm -net nic,model=? /dev/null
|
|||||||
<code>enable</code> property to <code>no</code> ,
|
<code>enable</code> property to <code>no</code> ,
|
||||||
since <span class="since">since 1.2.2</span>.
|
since <span class="since">since 1.2.2</span>.
|
||||||
</p>
|
</p>
|
||||||
|
<p>
|
||||||
|
Spice may provide accelerated server-side rendering with
|
||||||
|
OpenGL. You can enable or disable OpenGL support explicitly with
|
||||||
|
the <code>gl</code> element, by setting the
|
||||||
|
<code>enable</code> property. (QEMU
|
||||||
|
only, <span class="since">since 1.3.2</span>).
|
||||||
|
</p>
|
||||||
</dd>
|
</dd>
|
||||||
<dt><code>"rdp"</code></dt>
|
<dt><code>"rdp"</code></dt>
|
||||||
<dd>
|
<dd>
|
||||||
|
@ -2823,6 +2823,14 @@
|
|||||||
<empty/>
|
<empty/>
|
||||||
</element>
|
</element>
|
||||||
</optional>
|
</optional>
|
||||||
|
<optional>
|
||||||
|
<element name="gl">
|
||||||
|
<attribute name="enable">
|
||||||
|
<ref name="virYesNo"/>
|
||||||
|
</attribute>
|
||||||
|
<empty/>
|
||||||
|
</element>
|
||||||
|
</optional>
|
||||||
</interleave>
|
</interleave>
|
||||||
</group>
|
</group>
|
||||||
<group>
|
<group>
|
||||||
|
@ -11034,6 +11034,26 @@ virDomainGraphicsDefParseXML(xmlNodePtr node,
|
|||||||
VIR_FREE(enable);
|
VIR_FREE(enable);
|
||||||
|
|
||||||
def->data.spice.filetransfer = enableVal;
|
def->data.spice.filetransfer = enableVal;
|
||||||
|
} else if (xmlStrEqual(cur->name, BAD_CAST "gl")) {
|
||||||
|
char *enable = virXMLPropString(cur, "enable");
|
||||||
|
int enableVal;
|
||||||
|
|
||||||
|
if (!enable) {
|
||||||
|
virReportError(VIR_ERR_XML_ERROR, "%s",
|
||||||
|
_("spice gl element missing enable"));
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((enableVal =
|
||||||
|
virTristateBoolTypeFromString(enable)) <= 0) {
|
||||||
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||||
|
_("unknown enable value '%s'"), enable);
|
||||||
|
VIR_FREE(enable);
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
VIR_FREE(enable);
|
||||||
|
|
||||||
|
def->data.spice.gl = enableVal;
|
||||||
} else if (xmlStrEqual(cur->name, BAD_CAST "mouse")) {
|
} else if (xmlStrEqual(cur->name, BAD_CAST "mouse")) {
|
||||||
char *mode = virXMLPropString(cur, "mode");
|
char *mode = virXMLPropString(cur, "mode");
|
||||||
int modeVal;
|
int modeVal;
|
||||||
@ -21093,7 +21113,8 @@ virDomainGraphicsDefFormat(virBufferPtr buf,
|
|||||||
if (!children && (def->data.spice.image || def->data.spice.jpeg ||
|
if (!children && (def->data.spice.image || def->data.spice.jpeg ||
|
||||||
def->data.spice.zlib || def->data.spice.playback ||
|
def->data.spice.zlib || def->data.spice.playback ||
|
||||||
def->data.spice.streaming || def->data.spice.copypaste ||
|
def->data.spice.streaming || def->data.spice.copypaste ||
|
||||||
def->data.spice.mousemode || def->data.spice.filetransfer)) {
|
def->data.spice.mousemode || def->data.spice.filetransfer ||
|
||||||
|
def->data.spice.gl)) {
|
||||||
virBufferAddLit(buf, ">\n");
|
virBufferAddLit(buf, ">\n");
|
||||||
virBufferAdjustIndent(buf, 2);
|
virBufferAdjustIndent(buf, 2);
|
||||||
children = true;
|
children = true;
|
||||||
@ -21122,6 +21143,9 @@ virDomainGraphicsDefFormat(virBufferPtr buf,
|
|||||||
if (def->data.spice.filetransfer)
|
if (def->data.spice.filetransfer)
|
||||||
virBufferAsprintf(buf, "<filetransfer enable='%s'/>\n",
|
virBufferAsprintf(buf, "<filetransfer enable='%s'/>\n",
|
||||||
virTristateBoolTypeToString(def->data.spice.filetransfer));
|
virTristateBoolTypeToString(def->data.spice.filetransfer));
|
||||||
|
if (def->data.spice.gl)
|
||||||
|
virBufferAsprintf(buf, "<gl enable='%s'/>\n",
|
||||||
|
virTristateBoolTypeToString(def->data.spice.gl));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (children) {
|
if (children) {
|
||||||
|
@ -1586,6 +1586,7 @@ struct _virDomainGraphicsDef {
|
|||||||
int streaming;
|
int streaming;
|
||||||
int copypaste; /* enum virTristateBool */
|
int copypaste; /* enum virTristateBool */
|
||||||
int filetransfer; /* enum virTristateBool */
|
int filetransfer; /* enum virTristateBool */
|
||||||
|
int gl; /* enum virTristateBool */
|
||||||
} spice;
|
} spice;
|
||||||
} data;
|
} data;
|
||||||
/* nListens, listens, and *port are only useful if type is vnc,
|
/* nListens, listens, and *port are only useful if type is vnc,
|
||||||
|
@ -315,6 +315,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
|
|||||||
"vserport-change-event", /* 210 */
|
"vserport-change-event", /* 210 */
|
||||||
"virtio-balloon-pci.deflate-on-oom",
|
"virtio-balloon-pci.deflate-on-oom",
|
||||||
"mptsas1068",
|
"mptsas1068",
|
||||||
|
"spice-gl",
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
@ -2627,6 +2628,7 @@ static struct virQEMUCapsCommandLineProps virQEMUCapsCommandLine[] = {
|
|||||||
{ "machine", "aes-key-wrap", QEMU_CAPS_AES_KEY_WRAP },
|
{ "machine", "aes-key-wrap", QEMU_CAPS_AES_KEY_WRAP },
|
||||||
{ "machine", "dea-key-wrap", QEMU_CAPS_DEA_KEY_WRAP },
|
{ "machine", "dea-key-wrap", QEMU_CAPS_DEA_KEY_WRAP },
|
||||||
{ "chardev", "append", QEMU_CAPS_CHARDEV_FILE_APPEND },
|
{ "chardev", "append", QEMU_CAPS_CHARDEV_FILE_APPEND },
|
||||||
|
{ "spice", "gl", QEMU_CAPS_SPICE_GL },
|
||||||
};
|
};
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -344,6 +344,7 @@ typedef enum {
|
|||||||
QEMU_CAPS_VIRTIO_BALLOON_AUTODEFLATE, /* virtio-balloon-{device,pci,ccw}.
|
QEMU_CAPS_VIRTIO_BALLOON_AUTODEFLATE, /* virtio-balloon-{device,pci,ccw}.
|
||||||
* deflate-on-oom */
|
* deflate-on-oom */
|
||||||
QEMU_CAPS_SCSI_MPTSAS1068, /* -device mptsas1068 */
|
QEMU_CAPS_SCSI_MPTSAS1068, /* -device mptsas1068 */
|
||||||
|
QEMU_CAPS_SPICE_GL, /* -spice gl */
|
||||||
|
|
||||||
QEMU_CAPS_LAST /* this must always be the last item */
|
QEMU_CAPS_LAST /* this must always be the last item */
|
||||||
} virQEMUCapsFlags;
|
} virQEMUCapsFlags;
|
||||||
|
@ -6049,6 +6049,19 @@ qemuBuildGraphicsSPICECommandLine(virQEMUDriverConfigPtr cfg,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (graphics->data.spice.gl == VIR_TRISTATE_SWITCH_ON) {
|
||||||
|
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_SPICE_GL)) {
|
||||||
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||||
|
_("This QEMU doesn't support spice OpenGL"));
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* spice.gl is a TristateBool, but qemu expects on/off: use
|
||||||
|
* TristateSwitch helper */
|
||||||
|
virBufferAsprintf(&opt, ",gl=%s",
|
||||||
|
virTristateSwitchTypeToString(graphics->data.spice.gl));
|
||||||
|
}
|
||||||
|
|
||||||
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_SEAMLESS_MIGRATION)) {
|
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_SEAMLESS_MIGRATION)) {
|
||||||
/* If qemu supports seamless migration turn it
|
/* If qemu supports seamless migration turn it
|
||||||
* unconditionally on. If migration destination
|
* unconditionally on. If migration destination
|
||||||
|
@ -174,4 +174,5 @@
|
|||||||
<flag name='ich9-disable-s4'/>
|
<flag name='ich9-disable-s4'/>
|
||||||
<flag name='vserport-change-event'/>
|
<flag name='vserport-change-event'/>
|
||||||
<flag name='virtio-balloon-pci.deflate-on-oom'/>
|
<flag name='virtio-balloon-pci.deflate-on-oom'/>
|
||||||
|
<flag name='spice-gl'/>
|
||||||
</qemuCaps>
|
</qemuCaps>
|
||||||
|
@ -3344,6 +3344,10 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"parameters": [
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "gl",
|
||||||
|
"type": "boolean"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "seamless-migration",
|
"name": "seamless-migration",
|
||||||
"type": "boolean"
|
"type": "boolean"
|
||||||
|
@ -0,0 +1,24 @@
|
|||||||
|
LC_ALL=C \
|
||||||
|
PATH=/bin \
|
||||||
|
HOME=/home/test \
|
||||||
|
USER=test \
|
||||||
|
LOGNAME=test \
|
||||||
|
QEMU_AUDIO_DRV=spice \
|
||||||
|
/usr/bin/qemu \
|
||||||
|
-name QEMUGuest1 \
|
||||||
|
-S \
|
||||||
|
-M pc \
|
||||||
|
-m 1024 \
|
||||||
|
-smp 1 \
|
||||||
|
-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
|
||||||
|
-nodefaults \
|
||||||
|
-monitor unix:/tmp/lib/domain--1-QEMUGuest1/monitor.sock,server,nowait \
|
||||||
|
-no-acpi \
|
||||||
|
-boot c \
|
||||||
|
-usb \
|
||||||
|
-drive file=/var/lib/libvirt/images/QEMUGuest1,format=qcow2,if=none,\
|
||||||
|
id=drive-ide0-0-0,cache=none \
|
||||||
|
-device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \
|
||||||
|
-spice port=0,gl=on \
|
||||||
|
-device virtio-vga,id=video0,virgl=on,bus=pci.0,addr=0x2 \
|
||||||
|
-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
|
@ -0,0 +1,38 @@
|
|||||||
|
<domain type='qemu'>
|
||||||
|
<name>QEMUGuest1</name>
|
||||||
|
<uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
|
||||||
|
<memory unit='KiB'>1048576</memory>
|
||||||
|
<currentMemory unit='KiB'>1048576</currentMemory>
|
||||||
|
<vcpu placement='static'>1</vcpu>
|
||||||
|
<os>
|
||||||
|
<type arch='i686' machine='pc'>hvm</type>
|
||||||
|
<boot dev='hd'/>
|
||||||
|
</os>
|
||||||
|
<clock offset='utc'/>
|
||||||
|
<on_poweroff>destroy</on_poweroff>
|
||||||
|
<on_reboot>restart</on_reboot>
|
||||||
|
<on_crash>destroy</on_crash>
|
||||||
|
<devices>
|
||||||
|
<emulator>/usr/bin/qemu</emulator>
|
||||||
|
<disk type='file' device='disk'>
|
||||||
|
<driver name='qemu' type='qcow2' cache='none'/>
|
||||||
|
<source file='/var/lib/libvirt/images/QEMUGuest1'/>
|
||||||
|
<target dev='hda' bus='ide'/>
|
||||||
|
<address type='drive' controller='0' bus='0' target='0' unit='0'/>
|
||||||
|
</disk>
|
||||||
|
<controller type='ide' index='0'/>
|
||||||
|
<controller type='usb' index='0'/>
|
||||||
|
<controller type='pci' index='0' model='pci-root'/>
|
||||||
|
<input type='mouse' bus='ps2'/>
|
||||||
|
<input type='keyboard' bus='ps2'/>
|
||||||
|
<graphics type='spice' autoport='no'>
|
||||||
|
<gl enable='yes'/>
|
||||||
|
</graphics>
|
||||||
|
<video>
|
||||||
|
<model type='virtio' heads='1'>
|
||||||
|
<acceleration accel3d='yes'/>
|
||||||
|
</model>
|
||||||
|
</video>
|
||||||
|
<memballoon model='virtio'/>
|
||||||
|
</devices>
|
||||||
|
</domain>
|
@ -1480,6 +1480,12 @@ mymain(void)
|
|||||||
QEMU_CAPS_DEVICE_VIRTIO_GPU,
|
QEMU_CAPS_DEVICE_VIRTIO_GPU,
|
||||||
QEMU_CAPS_DEVICE_VIRTIO_GPU_VIRGL,
|
QEMU_CAPS_DEVICE_VIRTIO_GPU_VIRGL,
|
||||||
QEMU_CAPS_DEVICE_VIDEO_PRIMARY);
|
QEMU_CAPS_DEVICE_VIDEO_PRIMARY);
|
||||||
|
DO_TEST("video-virtio-gpu-spice-gl",
|
||||||
|
QEMU_CAPS_DEVICE_VIRTIO_GPU,
|
||||||
|
QEMU_CAPS_DEVICE_VIRTIO_GPU_VIRGL,
|
||||||
|
QEMU_CAPS_SPICE,
|
||||||
|
QEMU_CAPS_SPICE_GL,
|
||||||
|
QEMU_CAPS_DEVICE_VIDEO_PRIMARY);
|
||||||
DO_TEST_PARSE_ERROR("video-invalid", NONE);
|
DO_TEST_PARSE_ERROR("video-invalid", NONE);
|
||||||
|
|
||||||
DO_TEST("virtio-rng-default", QEMU_CAPS_DEVICE_VIRTIO_RNG,
|
DO_TEST("virtio-rng-default", QEMU_CAPS_DEVICE_VIRTIO_RNG,
|
||||||
|
@ -0,0 +1,45 @@
|
|||||||
|
<domain type='qemu'>
|
||||||
|
<name>QEMUGuest1</name>
|
||||||
|
<uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
|
||||||
|
<memory unit='KiB'>1048576</memory>
|
||||||
|
<currentMemory unit='KiB'>1048576</currentMemory>
|
||||||
|
<vcpu placement='static'>1</vcpu>
|
||||||
|
<os>
|
||||||
|
<type arch='i686' machine='pc'>hvm</type>
|
||||||
|
<boot dev='hd'/>
|
||||||
|
</os>
|
||||||
|
<clock offset='utc'/>
|
||||||
|
<on_poweroff>destroy</on_poweroff>
|
||||||
|
<on_reboot>restart</on_reboot>
|
||||||
|
<on_crash>destroy</on_crash>
|
||||||
|
<devices>
|
||||||
|
<emulator>/usr/bin/qemu</emulator>
|
||||||
|
<disk type='file' device='disk'>
|
||||||
|
<driver name='qemu' type='qcow2' cache='none'/>
|
||||||
|
<source file='/var/lib/libvirt/images/QEMUGuest1'/>
|
||||||
|
<target dev='hda' bus='ide'/>
|
||||||
|
<address type='drive' controller='0' bus='0' target='0' unit='0'/>
|
||||||
|
</disk>
|
||||||
|
<controller type='ide' index='0'>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='usb' index='0'>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='pci' index='0' model='pci-root'/>
|
||||||
|
<input type='mouse' bus='ps2'/>
|
||||||
|
<input type='keyboard' bus='ps2'/>
|
||||||
|
<graphics type='spice' autoport='no'>
|
||||||
|
<gl enable='yes'/>
|
||||||
|
</graphics>
|
||||||
|
<video>
|
||||||
|
<model type='virtio' heads='1'>
|
||||||
|
<acceleration accel3d='yes'/>
|
||||||
|
</model>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
|
||||||
|
</video>
|
||||||
|
<memballoon model='virtio'>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
|
||||||
|
</memballoon>
|
||||||
|
</devices>
|
||||||
|
</domain>
|
@ -757,6 +757,7 @@ mymain(void)
|
|||||||
|
|
||||||
DO_TEST("video-virtio-gpu-device");
|
DO_TEST("video-virtio-gpu-device");
|
||||||
DO_TEST("video-virtio-gpu-virgl");
|
DO_TEST("video-virtio-gpu-virgl");
|
||||||
|
DO_TEST("video-virtio-gpu-spice-gl");
|
||||||
DO_TEST("virtio-input");
|
DO_TEST("virtio-input");
|
||||||
DO_TEST("virtio-input-passthrough");
|
DO_TEST("virtio-input-passthrough");
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user