[libvirt] [PATCH v3] hyperv: recognize array property as distinct type.
Matthias Bolte
matthias.bolte at googlemail.com
Tue Apr 18 21:23:54 UTC 2017
2017-04-18 16:56 GMT+02:00 Dawid Zamirski <dzamirski at datto.com>:
> When hyperv code generator for WMI classes identifies common
> properties, it needs to take into account array type as a distinct
> type, i.e string != string[]. This is the case where v1 of the
> Msvm_VirtualSystemSettingData has Notes property as string whereas v2
> uses Notes[], therefore they have to be treated as different fields and
> cannot be placed in the "common" struct.
> ---
>
> changes in v3:
> * add virBufferCheckError before calling virBufferContentAndReset.
>
> src/hyperv/hyperv_driver.c | 28 ++++++++++++++++++++++++++--
> src/hyperv/hyperv_wmi_generator.py | 2 +-
> 2 files changed, 27 insertions(+), 3 deletions(-)
>
> diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c
> index 090ea24..8e5eeda 100644
> --- a/src/hyperv/hyperv_driver.c
> +++ b/src/hyperv/hyperv_driver.c
> @@ -894,8 +894,32 @@ hypervDomainGetXMLDesc(virDomainPtr domain, unsigned int flags)
> if (VIR_STRDUP(def->name, computerSystem->data.common->ElementName) < 0)
> goto cleanup;
>
> - if (VIR_STRDUP(def->description, virtualSystemSettingData->data.common->Notes) < 0)
> - goto cleanup;
> + if (priv->wmiVersion == HYPERV_WMI_VERSION_V1) {
> + if (VIR_STRDUP(def->description,
> + virtualSystemSettingData->data.v1->Notes) < 0)
> + goto cleanup;
> + } else if (priv->wmiVersion == HYPERV_WMI_VERSION_V2 &&
> + virtualSystemSettingData->data.v2->Notes.data != NULL) {
> + char **notes = (char **) virtualSystemSettingData->data.v2->Notes.data;
> + virBuffer buf = VIR_BUFFER_INITIALIZER;
> + size_t i = 0;
> +
> + /* in practice Notes has 1 element */
> + for (i = 0; i < virtualSystemSettingData->data.v2->Notes.count; i++) {
> + /* but if there's more than 1, separate by double new line */
> + if (virBufferUse(&buf) > 0)
> + virBufferAddLit(&buf, "\n\n");
> +
> + virBufferAdd(&buf, *notes, -1);
> + notes++;
> + }
> +
> + if (virBufferCheckError(&buf))
> + cleanup;
This will not compile, the goto is missing.
> +
> + def->description = virBufferContentAndReset(&buf);
> + }
> +
>
Extra whitespace.
ACK. I fixed both problems and pushed the result, thanks.
--
Matthias Bolte
http://photron.blogspot.com
More information about the libvir-list
mailing list