Comments for commit grabbed from gitorious and apparently not updated as
this commit now inclides the spice activating code and tests too...
Daniel
Author: Daniel P. Berrange <berrange(a)redhat.com>
Implement RHEL-5.4 KVM QXL support in QEMU driver
This supports the -qxl argument in RHEL-5's fork of KVM
which has SPICE support. QXL is a graphics card, but
inexplicably doesn't use the standard -vga syntax for
generic configuration. Also -qxl is rather useless unless
you also supply -spice (coming in next patch)
* src/qemu_conf.c: Probe for -qxl arg in QEMU help. Format a
-qxl arg for launching VMs
* src/qemu_conf.h: Add flag for -qxl arg availability
* tests/qemuhelpdata/kvm-83-rhel, tests/qemuhelptest.c: test
for -qxl arg help parsing
* tests/qemuxml2argvtest.c, tests/qemuxml2xmltest.c,
tests/qemuxml2argvdata/qemuxml2argv-graphics-spice.args,
tests/qemuxml2argvdata/qemuxml2argv-graphics-spice.xml: add
tests for -qxl graphics XML to ARGV handling
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 4baf218..dff39a0 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -91,7 +91,7 @@ VIR_ENUM_IMPL(qemuVideo, VIR_DOMAIN_VIDEO_TYPE_LAST,
"vmware",
"", /* no arg needed for xen */
"", /* don't support vbox */
- "" /* XQL not implemented yet */);
+ "" /* qxl is a bizarre special case */);
int qemudLoadDriverConfig(struct qemud_driver *driver,
const char *filename) {
@@ -1141,6 +1141,10 @@ static unsigned int qemudComputeCmdFlags(const char *help,
}
if (strstr(help, "-vga") && !strstr(help, "-std-vga"))
flags |= QEMUD_CMD_FLAG_VGA;
+ if (strstr(help, "-spice"))
+ flags |= QEMUD_CMD_FLAG_SPICE;
+ if (strstr(help, "-qxl"))
+ flags |= QEMUD_CMD_FLAG_QXL;
if (strstr(help, "boot=on"))
flags |= QEMUD_CMD_FLAG_DRIVE_BOOT;
if (strstr(help, "serial=s"))
@@ -3893,6 +3897,44 @@ int qemudBuildCommandLine(virConnectPtr conn,
* default, since the default changes :-( */
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)) {
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%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, ",sport=%u",
+ def->graphics[0]->data.spice.tlsPort);
+
+ if (def->graphics[0]->data.spice.listenAddr)
+ virBufferVSprintf(&opt, ",host=%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 none, to prevent it opening the
+ * host OS audio devices since that causes security issues
+ * and is non-sensical when using SPICE.
+ */
+ ADD_ENV_LIT("QEMU_AUDIO_DRV=none");
} else if (def->ngraphics) {
qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
"%s", _("unsupported graphics output
requested"));
@@ -3906,9 +3948,15 @@ int qemudBuildCommandLine(virConnectPtr conn,
}
if (qemuCmdFlags & QEMUD_CMD_FLAG_VGA) {
- if (def->videos[0]->type == VIR_DOMAIN_VIDEO_TYPE_XEN) {
+ switch (def->videos[0]->type) {
+ case VIR_DOMAIN_VIDEO_TYPE_XEN:
/* nothing - vga has no effect on Xen pvfb */
- } else {
+ break;
+ case VIR_DOMAIN_VIDEO_TYPE_QXL:
+ /* handle later */
+ break;
+ default:
+ {
const char *vgastr = qemuVideoTypeToString(def->videos[0]->type);
if (!vgastr || STREQ(vgastr, "")) {
qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
@@ -3919,6 +3967,8 @@ int qemudBuildCommandLine(virConnectPtr conn,
ADD_ARG_LIT("-vga");
ADD_ARG_LIT(vgastr);
+ break;
+ }
}
} else {
@@ -3936,6 +3986,10 @@ int qemudBuildCommandLine(virConnectPtr conn,
/* No special args - this is the default */
break;
+ case VIR_DOMAIN_VIDEO_TYPE_QXL:
+ /* handle later */
+ break;
+
default:
qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
_("video type %s is not supported with
QEMU"),
@@ -3943,6 +3997,26 @@ int qemudBuildCommandLine(virConnectPtr conn,
goto error;
}
}
+
+ if (def->videos[0]->type == VIR_DOMAIN_VIDEO_TYPE_QXL) {
+
+ if (qemuCmdFlags & QEMUD_CMD_FLAG_QXL) {
+ char *optstr;
+
+ if (virAsprintf(&optstr, "%u,ram=%u",
+ def->videos[0]->heads,
+ (def->videos[0]->vram /1024)) < 0)
+ goto no_memory;
+
+ ADD_ARG_LIT("-qxl");
+ ADD_ARG(optstr);
+ } else {
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
"%s",
+ _("qxl graphics are not supported with this
QEMU"));
+ goto error;
+ }
+ }
+
} else {
/* If we have -device, then we set -nodefault already */
if (!(qemuCmdFlags & QEMUD_CMD_FLAG_DEVICE) &&
diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h
index 101f187..54b8598 100644
--- a/src/qemu/qemu_conf.h
+++ b/src/qemu/qemu_conf.h
@@ -82,6 +82,8 @@ enum qemud_cmd_flags {
QEMUD_CMD_FLAG_SDL = (1 << 27), /* Is the new -sdl arg available */
QEMUD_CMD_FLAG_SMP_TOPOLOGY = (1 << 28), /* Is sockets=s,cores=c,threads=t
available for -smp? */
QEMUD_CMD_FLAG_NETDEV = (1 << 29), /* The -netdev flag &
netdev_add/remove monitor commands */
+ QEMUD_CMD_FLAG_QXL = (1 << 30), /* Is -qxl avail (RHEL-5/6 custom)
*/
+ QEMUD_CMD_FLAG_SPICE = (1 << 31), /* Is -spice avail (RHEL-5/6 custom)
*/
};
/* Main driver state */
diff --git a/tests/qemuhelptest.c b/tests/qemuhelptest.c
index 34a6048..4998503 100644
--- a/tests/qemuhelptest.c
+++ b/tests/qemuhelptest.c
@@ -204,6 +204,27 @@ mymain(int argc, char **argv)
QEMUD_CMD_FLAG_BALLOON |
QEMUD_CMD_FLAG_SDL,
10092, 1, 0);
+ DO_TEST("kvm-83-rhel",
+ QEMUD_CMD_FLAG_VNC_COLON |
+ QEMUD_CMD_FLAG_NO_REBOOT |
+ QEMUD_CMD_FLAG_DRIVE |
+ QEMUD_CMD_FLAG_DRIVE_BOOT |
+ QEMUD_CMD_FLAG_NAME |
+ QEMUD_CMD_FLAG_UUID |
+ QEMUD_CMD_FLAG_VNET_HDR |
+ QEMUD_CMD_FLAG_MIGRATE_QEMU_TCP |
+ QEMUD_CMD_FLAG_MIGRATE_QEMU_EXEC |
+ QEMUD_CMD_FLAG_DRIVE_CACHE_V2 |
+ QEMUD_CMD_FLAG_KVM |
+ QEMUD_CMD_FLAG_DRIVE_FORMAT |
+ QEMUD_CMD_FLAG_PCIDEVICE |
+ QEMUD_CMD_FLAG_MEM_PATH |
+ QEMUD_CMD_FLAG_DRIVE_SERIAL |
+ QEMUD_CMD_FLAG_BALLOON |
+ QEMUD_CMD_FLAG_VGA |
+ QEMUD_CMD_FLAG_QXL |
+ QEMUD_CMD_FLAG_SPICE,
+ 9001, 1, 83);
DO_TEST("qemu-0.12.1",
QEMUD_CMD_FLAG_VNC_COLON |
QEMUD_CMD_FLAG_NO_REBOOT |
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 67dc47e..0315610 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -269,6 +269,9 @@ mymain(int argc, char **argv)
DO_TEST("graphics-sdl", 0);
DO_TEST("graphics-sdl-fullscreen", 0);
+
+ DO_TEST("graphics-spice", QEMUD_CMD_FLAG_QXL | QEMUD_CMD_FLAG_SPICE);
+
DO_TEST("nographics-vga", QEMUD_CMD_FLAG_VGA);
DO_TEST("input-usbmouse", 0);
DO_TEST("input-usbtablet", 0);
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index 5b706bb..1d1fc52 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -110,6 +110,7 @@ mymain(int argc, char **argv)
DO_TEST("graphics-vnc-tls");
DO_TEST("graphics-sdl");
DO_TEST("graphics-sdl-fullscreen");
+ DO_TEST("graphics-spice");
DO_TEST("input-usbmouse");
DO_TEST("input-usbtablet");
DO_TEST("input-xen");
--
Daniel Veillard | libxml Gnome XML XSLT toolkit
http://xmlsoft.org/
daniel(a)veillard.com | Rpmfind RPM search engine
http://rpmfind.net/
http://veillard.com/ | virtualization library
http://libvirt.org/