[PATCH v2 3/7] hyperv: implement domainReboot and domainReset

Pino Toscano ptoscano at redhat.com
Tue Oct 13 07:40:57 UTC 2020


On Tuesday, 13 October 2020 07:14:00 CEST Matt Coleman wrote:
> Co-authored-by: Sri Ramanujam <sramanujam at datto.com>
> Signed-off-by: Matt Coleman <matt at datto.com>
> ---
>  src/hyperv/hyperv_driver.c      | 48 +++++++++++++++++++++++++++++++++
>  src/hyperv/hyperv_wmi_classes.h |  1 +
>  2 files changed, 49 insertions(+)
> 
> diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c
> index c4fca4685e..7182340f74 100644
> --- a/src/hyperv/hyperv_driver.c
> +++ b/src/hyperv/hyperv_driver.c
> @@ -917,6 +917,52 @@ hypervDomainResume(virDomainPtr domain)
>  
>  
>  
> +static int
> +hypervDomainReboot(virDomainPtr domain, unsigned int flags)
> +{
> +    int result = -1;
> +    hypervPrivate *priv = domain->conn->privateData;
> +    Msvm_ComputerSystem *computerSystem = NULL;
> +
> +    virCheckFlags(0, -1);
> +
> +    if (hypervMsvmComputerSystemFromDomain(domain, &computerSystem) < 0)
> +        goto cleanup;
> +
> +    result = hypervInvokeMsvmComputerSystemRequestStateChange(domain,
> +                                    MSVM_COMPUTERSYSTEM_REQUESTEDSTATE_REBOOT);
> +
> + cleanup:
> +    hypervFreeObject(priv, (hypervObject *)computerSystem);
> +
> +    return result;
> +}
> +
> +
> +
> +static int
> +hypervDomainReset(virDomainPtr domain, unsigned int flags)
> +{
> +    int result = -1;
> +    hypervPrivate *priv = domain->conn->privateData;
> +    Msvm_ComputerSystem *computerSystem = NULL;
> +
> +    virCheckFlags(0, -1);
> +
> +    if (hypervMsvmComputerSystemFromDomain(domain, &computerSystem) < 0)
> +        goto cleanup;
> +
> +    result = hypervInvokeMsvmComputerSystemRequestStateChange(domain,
> +                                    MSVM_COMPUTERSYSTEM_REQUESTEDSTATE_RESET);
> +
> + cleanup:
> +    hypervFreeObject(priv, (hypervObject *)computerSystem);
> +
> +    return result;
> +}

What about making a common helper function that calls
hypervMsvmComputerSystemFromDomain +
hypervInvokeMsvmComputerSystemRequestStateChange?

Note that virDomainReboot() can take various flags, however none is
used ATM.

-- 
Pino Toscano
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part.
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20201013/f11a1bb1/attachment-0001.sig>


More information about the libvir-list mailing list