[PATCH v2 09/10] hyperv: implement domainGetAutostart

Neal Gompa ngompa13 at gmail.com
Tue Oct 6 01:01:45 UTC 2020


On Mon, Oct 5, 2020 at 12:21 PM Matt Coleman <mcoleman at datto.com> wrote:
>
> Co-authored-by: Sri Ramanujam <sramanujam at datto.com>
> Signed-off-by: Matt Coleman <matt at datto.com>
> ---
>  src/hyperv/hyperv_driver.c | 40 ++++++++++++++++++++++++++++++++++++++
>  1 file changed, 40 insertions(+)
>
> diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c
> index 528c826e16..dcde469442 100644
> --- a/src/hyperv/hyperv_driver.c
> +++ b/src/hyperv/hyperv_driver.c
> @@ -1274,6 +1274,45 @@ hypervDomainCreate(virDomainPtr domain)
>
>
>
> +static int
> +hypervDomainGetAutostart(virDomainPtr domain, int *autostart)
> +{
> +    int result = -1;
> +    char uuid_string[VIR_UUID_STRING_BUFLEN];
> +    hypervPrivate *priv = domain->conn->privateData;
> +    g_auto(virBuffer) query = VIR_BUFFER_INITIALIZER;
> +    Msvm_VirtualSystemGlobalSettingData *vsgsd = NULL;
> +    Msvm_VirtualSystemSettingData *vssd = NULL;
> +
> +    virUUIDFormat(domain->uuid, uuid_string);
> +
> +    if (priv->wmiVersion == HYPERV_WMI_VERSION_V1) {
> +        virBufferEscapeSQL(&query,
> +                           MSVM_VIRTUALSYSTEMGLOBALSETTINGDATA_WQL_SELECT
> +                           "WHERE SystemName = \"%s\"", uuid_string);
> +
> +        if (hypervGetWmiClass(Msvm_VirtualSystemGlobalSettingData, &vsgsd) < 0)
> +            goto cleanup;
> +
> +        *autostart = vsgsd->data.common->AutomaticStartupAction == 2;
> +        result = 0;
> +    } else {
> +        if (hypervGetVSSDFromUUID(priv, uuid_string, &vssd) < 0)
> +            goto cleanup;
> +
> +        *autostart = vssd->data.v2->AutomaticStartupAction == 4;
> +        result = 0;
> +    }
> +
> +    cleanup:
> +    hypervFreeObject(priv, (hypervObject *) vsgsd);
> +    hypervFreeObject(priv, (hypervObject *) vssd);
> +
> +    return result;
> +}
> +
> +
> +
>  static int
>  hypervConnectIsEncrypted(virConnectPtr conn)
>  {
> @@ -1824,6 +1863,7 @@ static virHypervisorDriver hypervHypervisorDriver = {
>      .connectNumOfDefinedDomains = hypervConnectNumOfDefinedDomains, /* 0.9.5 */
>      .domainCreate = hypervDomainCreate, /* 0.9.5 */
>      .domainCreateWithFlags = hypervDomainCreateWithFlags, /* 0.9.5 */
> +    .domainGetAutostart = hypervDomainGetAutostart, /* 6.9.0 */
>      .connectIsEncrypted = hypervConnectIsEncrypted, /* 0.9.5 */
>      .connectIsSecure = hypervConnectIsSecure, /* 0.9.5 */
>      .domainIsActive = hypervDomainIsActive, /* 0.9.5 */
> --
> 2.27.0
>
>

Reviewed-by: Neal Gompa <ngompa13 at gmail.com>


-- 
真実はいつも一つ!/ Always, there's only one truth!





More information about the libvir-list mailing list