Re: [PATCH 04/16] hyperv: implement connectGetVersion

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

 




On 08/09/2016 08:39 AM, Jason Miesionczek wrote:
> ---
>  src/hyperv/hyperv_driver.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 52 insertions(+)
> 
> diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c
> index 4a5e80d..b2d1abf 100644
> --- a/src/hyperv/hyperv_driver.c
> +++ b/src/hyperv/hyperv_driver.c
> @@ -1349,6 +1349,57 @@ hypervConnectGetCapabilities(virConnectPtr conn)
>      return xml;
>  }
>  
> +static int
> +hypervConnectGetVersion(virConnectPtr conn, unsigned long *version)
> +{
> +    int result = -1;
> +    hypervPrivate *priv = conn->privateData;
> +    CIM_DataFile  *datafile = NULL;
> +    virBuffer query = VIR_BUFFER_INITIALIZER;
> +    char *p;
> +
> +    virBufferAddLit(&query, " Select * from CIM_DataFile where Name='c:\\\\windows\\\\system32\\\\vmms.exe' ");

That's too long of a line and there's an issue pointed out by another
reviewer...  Is this typical? To use some sort of CIM query? I assume
that means you require a CIM Server to be running? There really is no
other way?

> +    if (hypervGetCIMDataFileList(priv, &query, &datafile) < 0) {
> +        goto cleanup;
> +    }

More { } issues.

> +
> +    /* Check the result of convertion */

conversion

> +    if (datafile == NULL) {
> +        virReportError(VIR_ERR_INTERNAL_ERROR,
> +                       _("Could not lookup %s for domain %s"),
> +                       "Msvm_VirtualSystemSettingData",
> +                       datafile->data->Version);

Build failure here due to datafile == NULL


> +        goto cleanup;
> +    }
> +
> +    /* Delete release number and last digit of build number 1.1.111x.xxxx */
> +    p = strrchr(datafile->data->Version,'.');

s/Version,'.'/Version, '.'/

> +    if (p == NULL) {
> +        virReportError(VIR_ERR_INTERNAL_ERROR,
> +                       _("Could not parse version number from '%s'"),
> +                       datafile->data->Version);
> +        goto cleanup;
> +    }
> +    p--;
> +    *p = '\0';
> +
> +    /* Parse Version String to Long */

an Unsigned Long

> +    if (virParseVersionString(datafile->data->Version,
> +                              version, true) < 0) {
> +        virReportError(VIR_ERR_INTERNAL_ERROR,
> +                       _("Could not parse version number from '%s'"),
> +                       datafile->data->Version);
> +        goto cleanup;
> +    }
> +
> +    result = 0;
> +
> + cleanup:
> +    hypervFreeObject(priv, (hypervObject *)datafile);
> +    virBufferFreeAndReset(&query);
> +
> +    return result;
> +}
>  
>  static virHypervisorDriver hypervHypervisorDriver = {
>      .name = "Hyper-V",
> @@ -1385,6 +1436,7 @@ static virHypervisorDriver hypervHypervisorDriver = {
>      .domainManagedSaveRemove = hypervDomainManagedSaveRemove, /* 0.9.5 */
>      .connectIsAlive = hypervConnectIsAlive, /* 0.9.8 */
>      .connectGetCapabilities = hypervConnectGetCapabilities, /* 1.2.10 */
> +    .connectGetVersion = hypervConnectGetVersion, /* 1.2.10 */

2.3.0 at the earliest...

John
>  };
>  
>  /* Retrieves host system UUID  */
> 

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



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]