mirror of https://gitee.com/openkylin/libvirt.git
Implement QEMU/KVM support for SPICE graphics
This supports the -spice argument posted for review against the latest upstream QEMU/KVM. This supports the bare minimum config with port, TLS port & listen address. The x509 bits are added in a later patch. * src/qemu_conf.c, src/qemu_conf.h: Add SPICE flag. Check for -spice availability. Format -spice arg for command line * qemuhelptest.c: Add SPICE flag * qemuxml2argvdata/qemuxml2argv-graphics-spice.args: Add <graphics> for spice * qemuxml2argvdata/qemuxml2argv-graphics-spice.xml: Add -spice arg * qemuxml2argvtest.c: Add SPICE flag
This commit is contained in:
parent
635f9ca1f3
commit
9b57fa65bd
|
@ -1208,6 +1208,8 @@ static unsigned long long qemudComputeCmdFlags(const char *help,
|
|||
if (strstr(help, "|qxl"))
|
||||
flags |= QEMUD_CMD_FLAG_VGA_QXL;
|
||||
}
|
||||
if (strstr(help, "-spice"))
|
||||
flags |= QEMUD_CMD_FLAG_SPICE;
|
||||
if (strstr(help, "boot=on"))
|
||||
flags |= QEMUD_CMD_FLAG_DRIVE_BOOT;
|
||||
if (strstr(help, "serial=s"))
|
||||
|
@ -5067,6 +5069,41 @@ int qemudBuildCommandLine(virConnectPtr conn,
|
|||
if (qemuCmdFlags & QEMUD_CMD_FLAG_SDL)
|
||||
ADD_ARG_LIT("-sdl");
|
||||
|
||||
} else if ((def->ngraphics == 1) &&
|
||||
def->graphics[0]->type == VIR_DOMAIN_GRAPHICS_TYPE_SPICE) {
|
||||
virBuffer opt = VIR_BUFFER_INITIALIZER;
|
||||
char *optstr;
|
||||
|
||||
if (!(qemuCmdFlags & QEMUD_CMD_FLAG_SPICE)) {
|
||||
qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
_("spice graphics are not supported with this QEMU"));
|
||||
goto error;
|
||||
}
|
||||
|
||||
virBufferVSprintf(&opt, "port=%u", def->graphics[0]->data.spice.port);
|
||||
|
||||
if (def->graphics[0]->data.spice.tlsPort)
|
||||
virBufferVSprintf(&opt, ",tls-port=%u", def->graphics[0]->data.spice.tlsPort);
|
||||
|
||||
if (def->graphics[0]->data.spice.listenAddr)
|
||||
virBufferVSprintf(&opt, ",addr=%s", def->graphics[0]->data.spice.listenAddr);
|
||||
|
||||
if (virBufferError(&opt))
|
||||
goto no_memory;
|
||||
|
||||
optstr = virBufferContentAndReset(&opt);
|
||||
|
||||
ADD_ARG_LIT("-spice");
|
||||
ADD_ARG(optstr);
|
||||
if (def->graphics[0]->data.spice.keymap) {
|
||||
ADD_ARG_LIT("-k");
|
||||
ADD_ARG_LIT(def->graphics[0]->data.spice.keymap);
|
||||
}
|
||||
/* SPICE includes native support for tunnelling audio, so we
|
||||
* set the audio backend to point at SPICE's own driver
|
||||
*/
|
||||
ADD_ENV_LIT("QEMU_AUDIO_DRV=spice");
|
||||
|
||||
} else if ((def->ngraphics == 1)) {
|
||||
qemuReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("unsupported graphics type '%s'"),
|
||||
|
|
|
@ -99,6 +99,7 @@ enum qemud_cmd_flags {
|
|||
QEMUD_CMD_FLAG_DRIVE_READONLY= (1LL << 43), /* -drive readonly=on|off */
|
||||
QEMUD_CMD_FLAG_SMBIOS_TYPE = (1LL << 44), /* Is -smbios type= available */
|
||||
QEMUD_CMD_FLAG_VGA_QXL = (1LL << 45), /* The 'qxl' arg for '-vga' */
|
||||
QEMUD_CMD_FLAG_SPICE = (1LL << 46), /* Is -spice avail */
|
||||
};
|
||||
|
||||
/* Main driver state */
|
||||
|
|
|
@ -1 +1 @@
|
|||
LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -nodefaults -monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -usb -vga qxl -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
|
||||
LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=spice /usr/bin/qemu -S -M pc -m 214 -smp 1 -nodefaults -monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -usb -spice port=5903,tls-port=5904,addr=127.0.0.1 -vga qxl -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
|
||||
|
|
|
@ -20,6 +20,8 @@
|
|||
<address type='drive' controller='0' bus='0' unit='0'/>
|
||||
</disk>
|
||||
<controller type='ide' index='0'/>
|
||||
<input type='mouse' bus='ps2'/>
|
||||
<graphics type='spice' port='5903' tlsPort='5904' autoport='no' listen='127.0.0.1'/>
|
||||
<video>
|
||||
<model type='qxl' vram='65536' heads='1'/>
|
||||
</video>
|
||||
|
|
|
@ -325,7 +325,7 @@ mymain(int argc, char **argv)
|
|||
DO_TEST("nographics-vga", QEMUD_CMD_FLAG_VGA, false);
|
||||
DO_TEST("graphics-spice",
|
||||
QEMUD_CMD_FLAG_VGA | QEMUD_CMD_FLAG_VGA_QXL |
|
||||
QEMUD_CMD_FLAG_DEVICE, false);
|
||||
QEMUD_CMD_FLAG_DEVICE | QEMUD_CMD_FLAG_SPICE, false);
|
||||
|
||||
DO_TEST("input-usbmouse", 0, false);
|
||||
DO_TEST("input-usbtablet", 0, false);
|
||||
|
|
Loading…
Reference in New Issue