[libvirt] [PATCH v5 5/6] qemu: parse qemu command line for USB keyboard

Ján Tomko jtomko at redhat.com
Mon Feb 3 15:09:16 UTC 2014


On 12/19/2013 08:50 AM, Li Zhang wrote:
> From: Li Zhang <zhlcindy at linux.vnet.ibm.com>
> 
> This patch is to format qemu command line and xen driver for USB keyboard
> and add test cases for it.
> 
> Signed-off-by: Li Zhang <zhlcindy at linux.vnet.ibm.com>
> ---
>  src/qemu/qemu_command.c                            | 41 ++++++++++++++++------
>  src/xenxs/xen_sxpr.c                               | 27 +++++++++-----
>  src/xenxs/xen_xm.c                                 | 30 +++++++++++-----
>  .../qemuxml2argv-pseries-usb-kbd.args              |  9 +++++
>  .../qemuxml2argv-pseries-usb-kbd.xml               | 19 ++++++++++
>  tests/qemuxml2argvtest.c                           |  3 ++
>  6 files changed, 103 insertions(+), 26 deletions(-)
>  create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pseries-usb-kbd.args
>  create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pseries-usb-kbd.xml
> 


> diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c
> index 5e89876..9e19bb7 100644
> --- a/src/xenxs/xen_xm.c
> +++ b/src/xenxs/xen_xm.c
> @@ -886,14 +886,18 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
>              goto cleanup;
>          if (str &&
>              (STREQ(str, "tablet") ||
> -             STREQ(str, "mouse"))) {
> +             STREQ(str, "mouse") ||
> +             STREQ(str, "kbd"))) {
>              virDomainInputDefPtr input;
>              if (VIR_ALLOC(input) < 0)
>                  goto cleanup;
>              input->bus = VIR_DOMAIN_INPUT_BUS_USB;
> -            input->type = STREQ(str, "tablet") ?
> -                VIR_DOMAIN_INPUT_TYPE_TABLET :
> -                VIR_DOMAIN_INPUT_TYPE_MOUSE;
> +            if (STREQ(str, "mouse"))
> +                input->type = VIR_DOMAIN_INPUT_TYPE_MOUSE;
> +            else if (STREQ(str, "tablet"))
> +                input->type = VIR_DOMAIN_INPUT_TYPE_TABLET;
> +            else (STREQ(str, "kbd"))
> +                input->type = VIR_DOMAIN_INPUT_TYPE_KBD;
>              if (VIR_ALLOC_N(def->inputs, 1) < 0) {
>                  virDomainInputDefFree(input);
>                  goto cleanup;
> @@ -1746,10 +1750,20 @@ virConfPtr xenFormatXM(virConnectPtr conn,
>              if (def->inputs[i]->bus == VIR_DOMAIN_INPUT_BUS_USB) {
>                  if (xenXMConfigSetInt(conf, "usb", 1) < 0)
>                      goto cleanup;
> -                if (xenXMConfigSetString(conf, "usbdevice",
> -                                         def->inputs[i]->type == VIR_DOMAIN_INPUT_TYPE_MOUSE ?
> -                                         "mouse" : "tablet") < 0)
> -                    goto cleanup;
> +                switch (def->inputs[i]->type) {
> +                    case VIR_DOMAIN_INPUT_TYPE_MOUSE:
> +                        if (xenXMConfigSetString(conf, "usbdevice", "mouse") < 0)
> +                            goto cleanup;
> +                        break;
> +                    case VIR_DOMAIN_INPUT_TYPE_TABLET:
> +                        if (xenXMConfigSetString(conf, "usbdevice", "tablet") < 0)
> +                            goto cleanup;
> +                        break;
> +                    case VIR_DOMAIN_INPUT_TYPE_KBD:
> +                        if (xenXMConfigSetString(conf, "usbdevice", "kbd") < 0)
> +                            goto cleanup;
> +                        break;
> +                }
>                  break;
>              }
>          }

I'm not familiar with the xen driver, but I'd feel safer just ignoring the
implicit USB keyboard. I think they should also be in a separate commit.

Jan

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20140203/dbaa4332/attachment-0001.sig>


More information about the libvir-list mailing list