Add support for Xen input device in QEMU driver for xenner

This commit is contained in:
Daniel P. Berrange 2008-05-15 16:11:40 +00:00
parent 2c37f47985
commit 3a7b528d4b
8 changed files with 81 additions and 21 deletions

View File

@ -1,3 +1,13 @@
Thu May 15 12:08:08 EST 2008 Daniel P. Berrange <berrange@redhat.com>
Support paravirt framebuffer input configuration for xenner guests
* src/qemu_drive.c, src/qemu_conf.c, src/qemu_conf.h: Add support
for 'xen' input device type for Xenner PVFB
* tests/qemuxml2argv-input-xen.{args,xml}: Test case data
files for xen input devices
* tests/qemuxml2argvtest.c, tests/qemuxml2xmltest.c: Add
test case for xen input devices
Thu May 15 11:57:08 EST 2008 Daniel P. Berrange <berrange@redhat.com>
Support paravirt disk configuration for xenner guests

View File

@ -1365,6 +1365,7 @@ cleanup:
/* Parse the XML definition for a network interface */
static int qemudParseInputXML(virConnectPtr conn,
const struct qemud_vm_def *vm,
struct qemud_vm_input_def *input,
xmlNodePtr node) {
xmlChar *type = NULL;
@ -1391,26 +1392,46 @@ static int qemudParseInputXML(virConnectPtr conn,
}
if (bus) {
if (STREQ((const char*)bus, "ps2")) { /* Only allow mouse */
if (input->type == QEMU_INPUT_TYPE_TABLET) {
if (STREQ(vm->os.type, "hvm")) {
if (STREQ((const char*)bus, "ps2")) { /* Only allow mouse */
if (input->type != QEMU_INPUT_TYPE_MOUSE) {
qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
_("ps2 bus does not support %s input device"),
(const char*)type);
goto error;
}
input->bus = QEMU_INPUT_BUS_PS2;
} else if (STREQ((const char *)bus, "usb")) { /* Allow mouse & tablet */
input->bus = QEMU_INPUT_BUS_USB;
} else {
qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
_("ps2 bus does not support %s input device"),
(const char*)type);
_("unsupported input bus %s"), (const char*)bus);
goto error;
}
input->bus = QEMU_INPUT_BUS_PS2;
} else if (STREQ((const char *)bus, "usb")) { /* Allow mouse & keyboard */
input->bus = QEMU_INPUT_BUS_USB;
} else {
qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
_("unsupported input bus %s"), (const char*)bus);
goto error;
if (STREQ((const char *)bus, "xen")) { /* Allow mouse only */
input->bus = QEMU_INPUT_BUS_XEN;
if (input->type != QEMU_INPUT_TYPE_MOUSE) {
qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
_("xen bus does not support %s input device"),
(const char*)type);
goto error;
}
} else {
qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
_("unsupported input bus %s"), (const char*)bus);
goto error;
}
}
} else {
if (input->type == QEMU_INPUT_TYPE_MOUSE)
input->bus = QEMU_INPUT_BUS_PS2;
else
input->bus = QEMU_INPUT_BUS_USB;
if (!strcmp(vm->os.type, "hvm")) {
if (input->type == QEMU_INPUT_TYPE_MOUSE)
input->bus = QEMU_INPUT_BUS_PS2;
else
input->bus = QEMU_INPUT_BUS_USB;
} else {
input->bus = QEMU_INPUT_BUS_XEN;
}
}
xmlFree(type);
@ -1998,7 +2019,7 @@ static struct qemud_vm_def *qemudParseXML(virConnectPtr conn,
"%s", _("failed to allocate space for input string"));
goto error;
}
if (qemudParseInputXML(conn, input, obj->nodesetval->nodeTab[i]) < 0) {
if (qemudParseInputXML(conn, def, input, obj->nodesetval->nodeTab[i]) < 0) {
free(input);
goto error;
}
@ -2852,7 +2873,7 @@ static int qemudSaveConfig(virConnectPtr conn,
struct qemud_vm_device_def *
qemudParseVMDeviceDef(virConnectPtr conn,
struct qemud_driver *driver ATTRIBUTE_UNUSED,
const struct qemud_vm_def *def,
const char *xmlStr)
{
xmlDocPtr xml;
@ -2880,7 +2901,7 @@ qemudParseVMDeviceDef(virConnectPtr conn,
qemudParseInterfaceXML(conn, &(dev->data.net), node);
} else if (xmlStrEqual(node->name, BAD_CAST "input")) {
dev->type = QEMUD_DEVICE_DISK;
qemudParseInputXML(conn, &(dev->data.input), node);
qemudParseInputXML(conn, def, &(dev->data.input), node);
} else if (xmlStrEqual(node->name, BAD_CAST "sound")) {
dev->type = QEMUD_DEVICE_SOUND;
qemudParseSoundXML(conn, &(dev->data.sound), node);
@ -3950,14 +3971,15 @@ char *qemudGenerateXML(virConnectPtr conn,
input = def->inputs;
while (input) {
if (input->bus != QEMU_INPUT_BUS_PS2)
if (input->bus == QEMU_INPUT_BUS_USB)
virBufferVSprintf(&buf, " <input type='%s' bus='usb'/>\n",
input->type == QEMU_INPUT_TYPE_MOUSE ? "mouse" : "tablet");
input = input->next;
}
/* If graphics is enable, add implicit mouse */
if (def->graphicsType != QEMUD_GRAPHICS_NONE)
virBufferAddLit(&buf, " <input type='mouse' bus='ps2'/>\n");
virBufferVSprintf(&buf, " <input type='mouse' bus='%s'/>\n",
STREQ(def->os.type, "hvm") ? "ps2" : "xen");
switch (def->graphicsType) {
case QEMUD_GRAPHICS_VNC:

View File

@ -189,6 +189,7 @@ enum qemu_vm_input_type {
enum qemu_vm_input_bus {
QEMU_INPUT_BUS_PS2,
QEMU_INPUT_BUS_USB,
QEMU_INPUT_BUS_XEN,
};
struct qemud_vm_input_def {
@ -474,7 +475,7 @@ void qemudRemoveInactiveVM (struct qemud_driver *driver,
struct qemud_vm_device_def *
qemudParseVMDeviceDef (virConnectPtr conn,
struct qemud_driver *driver,
const struct qemud_vm_def *def,
const char *xmlStr);
struct qemud_vm_def *

View File

@ -2516,7 +2516,7 @@ static int qemudDomainAttachDevice(virDomainPtr dom,
return -1;
}
dev = qemudParseVMDeviceDef(dom->conn, driver, xml);
dev = qemudParseVMDeviceDef(dom->conn, vm->def, xml);
if (dev == NULL) {
return -1;
}

View File

@ -0,0 +1 @@
/usr/bin/xenner -M xenner -m 214 -smp 1 -monitor pty -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -serial none -parallel none -usb -vnc :-5901

View File

@ -0,0 +1,24 @@
<domain type='kvm'>
<name>QEMUGuest1</name>
<uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
<memory>219200</memory>
<currentMemory>219200</currentMemory>
<vcpu>1</vcpu>
<os>
<type>xen</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/xenner</emulator>
<disk type='block' device='disk'>
<source dev='/dev/HostVG/QEMUGuest1'/>
<target dev='hda' bus='ide'/>
</disk>
<input type='mouse' bus='xen'/>
<graphics type='vnc' port='-1'/>
</devices>
</domain>

View File

@ -158,6 +158,7 @@ main(int argc, char **argv)
DO_TEST("graphics-sdl", 0);
DO_TEST("input-usbmouse", 0);
DO_TEST("input-usbtablet", 0);
DO_TEST("input-xen", 0);
DO_TEST("misc-acpi", 0);
DO_TEST("misc-no-reboot", 0);
DO_TEST("net-user", 0);

View File

@ -107,6 +107,7 @@ main(int argc, char **argv)
DO_TEST("graphics-sdl");
DO_TEST("input-usbmouse");
DO_TEST("input-usbtablet");
DO_TEST("input-xen");
DO_TEST("misc-acpi");
DO_TEST("misc-no-reboot");
DO_TEST("net-user");