[libvirt] [PATCH 1/4] Add USB Keyboard support in libvirt

Nehal J Wani nehaljw.kkd1 at gmail.com
Mon Dec 2 17:43:12 UTC 2013


> +    QEMU_CAPS_DEVICE_USB_KBD = 160, /*-device usb-kbd*/
> +

Why this extra newline?

>
>      QEMU_CAPS_LAST,                   /* this must always be the last item */
>  };
> diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
> index 763417f..318f7a1 100644
> --- a/src/qemu/qemu_command.c
> +++ b/src/qemu/qemu_command.c
> @@ -5280,9 +5280,15 @@ qemuBuildUSBInputDevStr(virDomainDefPtr def,
>  {
>      virBuffer buf = VIR_BUFFER_INITIALIZER;
>
> -    virBufferAsprintf(&buf, "%s,id=%s",
> -                      dev->type == VIR_DOMAIN_INPUT_TYPE_MOUSE ?
> -                      "usb-mouse" : "usb-tablet", dev->info.alias);
> +    if (dev->type == VIR_DOMAIN_INPUT_TYPE_MOUSE) {
> +        virBufferAsprintf(&buf, "usb-mouse,id=%s", dev->info.alias);
> +    } else if (dev->type == VIR_DOMAIN_INPUT_TYPE_TABLET) {
> +        virBufferAsprintf(&buf, "usb-tablet,id=%s", dev->info.alias);
> +    } else if (dev->type == VIR_DOMAIN_INPUT_TYPE_KBD) {
> +        if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_USB_KBD))
> +            goto error;
> +        virBufferAsprintf(&buf, "usb-kbd,id=%s", dev->info.alias);
> +    }

I would've used switch(dev->type) instead of 'if else', to make it look simple.

-- 
Nehal J Wani




More information about the libvir-list mailing list