On Wed, Nov 02, 2016 at 05:13:42PM +0100, Peter Krempa wrote:
> Allow detecting capabilities according to the qemu QMP schema. This is
> necessary as sometimes the availability of certain options depends on
> the presence of a field in the schema.
> 
> This patch adds support for loading the QMP schema when detecting qemu
> capabilities and adds a very simple query language to allow traversing
> the schema and selecting a certain element from it.
> 
> The infrastructure in this patch uses a query path to set a specific
> capability flag according to the availability of the given element in
> the schema.
> ---
> 
> Notes:
>     v2:
>     - fixed typos
>     - added docs for one of the helper functions and changed param order
>     - added hint for query string format docs
> 
>  src/qemu/qemu_capabilities.c                      | 191 
> ++++++++++++++++++++++
>  src/qemu/qemu_capabilities.h                      |   1 +
>  tests/qemucapabilitiesdata/caps_2.5.0.x86_64.xml  |   1 +
>  tests/qemucapabilitiesdata/caps_2.6.0.ppc64le.xml |   1 +
>  tests/qemucapabilitiesdata/caps_2.6.0.x86_64.xml  |   1 +
>  tests/qemucapabilitiesdata/caps_2.7.0.x86_64.xml  |   1 +
>  6 files changed, 196 insertions(+)
> 
> diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
> index 7a8202a..56c9deb 100644
> --- a/src/qemu/qemu_capabilities.c
> +++ b/src/qemu/qemu_capabilities.c
> @@ -347,6 +347,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
>                "machine-iommu",
>                "virtio-vga",
>                "drive-iotune-max-length",
> +              "query-qmp-schema",
>      );
> 
> 
> @@ -1488,6 +1489,7 @@ struct virQEMUCapsStringFlags virQEMUCapsCommands[] = {
>      { "rtc-reset-reinjection", QEMU_CAPS_RTC_RESET_REINJECTION },
>      { "migrate-incoming", QEMU_CAPS_INCOMING_DEFER },
>      { "query-hotpluggable-cpus", QEMU_CAPS_QUERY_HOTPLUGGABLE_CPUS },
> +    { "query-qmp-schema", QEMU_CAPS_QUERY_QMP_SCHEMA }
>  };
> 
>  struct virQEMUCapsStringFlags virQEMUCapsMigration[] = {
> @@ -1692,6 +1694,11 @@ static struct virQEMUCapsStringFlags 
> virQEMUCapsObjectPropsUSBNECXHCI[] = {
>      { "p3", QEMU_CAPS_NEC_USB_XHCI_PORTS },
>  };
> 
> +/* see documentation for virQEMUCapsQMPSchemaGetByPath for the query format 
> */
> +static struct virQEMUCapsStringFlags virQEMUCapsQMPSchemaQueries[] = {
> +    { "bogus/path/to/satisfy/compiler", 0 },
> +};
> +
>  struct virQEMUCapsObjectTypeProps {
>      const char *type;
>      struct virQEMUCapsStringFlags *props;
> @@ -3696,6 +3703,187 @@ virQEMUCapsInitArchQMPBasic(virQEMUCapsPtr qemuCaps,
>      return ret;
>  }
> 
> +
> +/**
> + * virQEMUCapsQMPSchemaObjectGetType:
> + * @field: name of the object containing the requested type
> + * @name: name of the requested type
> + * @namefield: name of the object property holding @name
> + *
> + * Helper that selects the type of a QMP schema object or it's variant. 
> Returns

s/schema object or it's variant/schema object member or it's variant member/

> + * the  type string on success or NULL on error.

s/the  type/the type/

ACK

Attachment: signature.asc
Description: Digital signature

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

Reply via email to