"Daniel P. Berrange" <[EMAIL PROTECTED]> wrote:
> The Xenner virtual machine supportes a bus type of 'xen' for input devices,
> corresponding to the paravirtualized mouse device. QEMU currently rejects
> any bus type which isn't ps2 or usb. This patch makes it allow 'xen' as a
> valid bus type for Xenner guests.
>
>  b/tests/qemuxml2argvdata/qemuxml2argv-input-xen.args |    1
>  b/tests/qemuxml2argvdata/qemuxml2argv-input-xen.xml  |   24 ++++++
>  src/qemu_conf.c                                      |   72 
> ++++++++++++-------
>  src/qemu_conf.h                                      |    3
>  src/qemu_driver.c                                    |    2
>  tests/qemuxml2argvtest.c                             |    2
>  tests/qemuxml2xmltest.c                              |    1
>  7 files changed, 78 insertions(+), 27 deletions(-)

ACK.

> diff -r f00771a60241 src/qemu_conf.c
> --- a/src/qemu_conf.c Sat May 10 12:57:47 2008 -0400
> +++ b/src/qemu_conf.c Sat May 10 13:00:01 2008 -0400
> @@ -1365,6 +1365,7 @@
>
>  /* Parse the XML definition for a network interface */
>  static int qemudParseInputXML(virConnectPtr conn,
> +                              struct qemud_vm_def *vm,

This new parameter can be "const".

>                                struct qemud_vm_input_def *input,
>                                xmlNodePtr node) {
>      xmlChar *type = NULL;
> @@ -1391,26 +1392,46 @@
>      }
>
>      if (bus) {
> -        if (STREQ((const char*)bus, "ps2")) { /* Only allow mouse */
> -            if (input->type == QEMU_INPUT_TYPE_TABLET) {
> -                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 & 
> 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;
> -        }
> -    } else {
> -        if (input->type == QEMU_INPUT_TYPE_MOUSE)
> -            input->bus = QEMU_INPUT_BUS_PS2;
> -        else
> -            input->bus = QEMU_INPUT_BUS_USB;
> +        if (STREQ(vm->os.type, "hvm")) {
> +            if (STREQ((const char*)bus, "ps2")) { /* Only allow mouse */
> +                if (input->type == QEMU_INPUT_TYPE_TABLET) {

The only change here is to indent, but it'd be slightly
more maintainable (proof against addition of new input types)
to test "if (input->type != QEMU_INPUT_TYPE_MOUSE)".
That way, if we ever add a third input type, this code would
remain in sync with the "mouse only" comment with no change required.
Same below.

> +                    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,
> +                                 _("unsupported input bus %s"), (const 
> char*)bus);
> +                goto error;
> +            }
> +        } else {
> +            if (STREQ((const char *)bus, "xen")) { /* Allow mouse only */
> +                input->bus = QEMU_INPUT_BUS_XEN;
> +                if (input->type == QEMU_INPUT_TYPE_TABLET) {
...
>  struct qemud_vm_device_def *
>  qemudParseVMDeviceDef(virConnectPtr conn,
> -                      struct qemud_driver *driver ATTRIBUTE_UNUSED,
> +                      struct qemud_vm_def *def,

"const" here, too.

>                        const char *xmlStr)

--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Reply via email to