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

Re: [libvirt] [PATCH 28/34] Convert USB input devices to -device



On Fri, Jan 08, 2010 at 05:23:24PM +0000, Daniel P. Berrange wrote:
> ---
>  src/qemu/qemu_conf.c |   34 ++++++++++++++++++++++++++++++++--
>  1 files changed, 32 insertions(+), 2 deletions(-)
> 
> diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
> index 1ea61a9..3b39a91 100644
> --- a/src/qemu/qemu_conf.c
> +++ b/src/qemu/qemu_conf.c
> @@ -2268,6 +2268,28 @@ error:
>  }
>  
>  
> +static char *qemuBuildUSBInputDevStr(virDomainInputDefPtr dev)
> +{
> +    virBuffer buf = VIR_BUFFER_INITIALIZER;
> +
> +    virBufferVSprintf(&buf, "%s",
> +                      dev->type == VIR_DOMAIN_INPUT_TYPE_MOUSE ?
> +                      "usb-mouse" : "usb-tablet");
> +    virBufferVSprintf(&buf, ",id=%s", dev->info.alias);
> +
> +    if (virBufferError(&buf)) {
> +        virReportOOMError(NULL);
> +        goto error;
> +    }
> +
> +    return virBufferContentAndReset(&buf);
> +
> +error:
> +    virBufferFreeAndReset(&buf);
> +    return NULL;
> +}
> +
> +
>  static char *
>  qemuBuildSoundDevStr(virDomainSoundDefPtr sound)
>  {
> @@ -3273,8 +3295,16 @@ int qemudBuildCommandLine(virConnectPtr conn,
>          virDomainInputDefPtr input = def->inputs[i];
>  
>          if (input->bus == VIR_DOMAIN_INPUT_BUS_USB) {
> -            ADD_ARG_LIT("-usbdevice");
> -            ADD_ARG_LIT(input->type == VIR_DOMAIN_INPUT_TYPE_MOUSE ? "mouse" : "tablet");
> +            if (qemuCmdFlags & QEMUD_CMD_FLAG_DEVICE) {
> +                char *optstr;
> +                ADD_ARG_LIT("-device");
> +                if (!(optstr = qemuBuildUSBInputDevStr(input)))
> +                    goto error;
> +                ADD_ARG(optstr);
> +            } else {
> +                ADD_ARG_LIT("-usbdevice");
> +                ADD_ARG_LIT(input->type == VIR_DOMAIN_INPUT_TYPE_MOUSE ? "mouse" : "tablet");
> +            }
>          }
>      }

  ACK,

Daniel

-- 
Daniel Veillard      | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
daniel veillard com  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/


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