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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> +    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

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




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]