[libvirt] [PATCH 2/3] qemu: improve device flag parsing

Wen Congyang wency at cn.fujitsu.com
Tue Jan 18 05:39:14 UTC 2011


At 01/14/2011 03:10 AM, Eric Blake Write:
> * src/qemu/qemu_capabilities.h (qemuCapsParseDeviceStr): New
> prototype.
> * src/qemu/qemu_capabilities.c (qemuCapsParsePCIDeviceStrs)
> Rename and split...
> (qemuCapsExtractDeviceStr, qemuCapsParseDeviceStr): ...to make it
> easier to add and test device-specific checks.
> (qemuCapsExtractVersionInfo): Update caller.
> * tests/qemuhelptest.c (testHelpStrParsing): Also test parsing of
> device-related flags.
> (mymain): Update expected flags.
> * tests/qemuhelpdata/qemu-0.12.1-device: New file.
> * tests/qemuhelpdata/qemu-kvm-0.12.1.2-rhel60-device: New file.
> * tests/qemuhelpdata/qemu-kvm-0.12.3-device: New file.
> * tests/qemuhelpdata/qemu-kvm-0.13.0-device: New file.
> ---
>  src/qemu/qemu_capabilities.c                       |   41 ++++++++---
>  src/qemu/qemu_capabilities.h                       |    2 +
>  tests/qemuhelpdata/qemu-kvm-0.12.1.2-rhel60-device |   57 ++++++++++++++++
>  tests/qemuhelpdata/qemu-kvm-0.13.0-device          |   70 ++++++++++++++++++++
>  tests/qemuhelptest.c                               |   48 ++++++++++----
>  5 files changed, 195 insertions(+), 23 deletions(-)
>  create mode 100644 tests/qemuhelpdata/qemu-0.12.1-device
>  create mode 100644 tests/qemuhelpdata/qemu-kvm-0.12.1.2-rhel60-device
>  create mode 100644 tests/qemuhelpdata/qemu-kvm-0.12.3-device
>  create mode 100644 tests/qemuhelpdata/qemu-kvm-0.13.0-device
> 
> diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
> index 9bab317..f967255 100644
> --- a/src/qemu/qemu_capabilities.c
> +++ b/src/qemu/qemu_capabilities.c
> @@ -1032,28 +1032,46 @@ fail:
>      return -1;
>  }
> 
> -static void
> -qemuCapsParsePCIDeviceStrs(const char *qemu,
> -                           unsigned long long *flags)
> +static int
> +qemuCapsExtractDeviceStr(const char *qemu,
> +                         unsigned long long *flags)
>  {
> -    char *pciassign = NULL;
> +    char *output = NULL;
>      virCommandPtr cmd;
> +    int ret = -1;
> 
> -    cmd = virCommandNewArgList(qemu, "-device", "pci-assign,?", NULL);
> +    /* Cram together all device-related queries into one invocation;
> +     * the output format makes it possible to distinguish what we
> +     * need.  Unrecognized '-device bogus,?' cause an error in
> +     * isolation, but are silently ignored in combination with
> +     * '-device ?'.  */
> +    cmd = virCommandNewArgList(qemu,
> +                               "-device", "pci-assign,?",
> +                               NULL);

The qemu that I used does not support '-device pci-assign,?'...
So, I can not start the guest with this patch.

The qemu is cloned from here:
http://git.qemu.org/git/qemu.git

>      virCommandAddEnvPassCommon(cmd);
>      /* qemu -help goes to stdout, but qemu -device ? goes to stderr.  */
> -    virCommandSetErrorBuffer(cmd, &pciassign);
> +    virCommandSetErrorBuffer(cmd, &output);
>      virCommandClearCaps(cmd);
> 
>      if (virCommandRun(cmd, NULL) < 0)
>          goto cleanup;
> 
> -    if (strstr(pciassign, "pci-assign.configfd"))
> -        *flags |= QEMUD_CMD_FLAG_PCI_CONFIGFD;
> +    ret = qemuCapsParseDeviceStr(output, flags);
> 
>  cleanup:
> -    VIR_FREE(pciassign);
> +    VIR_FREE(output);
>      virCommandFree(cmd);
> +    return ret;
> +}
> +
> +




More information about the libvir-list mailing list