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

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

 



On Tuesday, 13 October 2020 07:14:00 CEST Matt Coleman wrote:
> Co-authored-by: Sri Ramanujam <sramanujam@xxxxxxxxx>
> Signed-off-by: Matt Coleman <matt@xxxxxxxxx>
> ---
>  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

Attachment: signature.asc
Description: This is a digitally signed message part.


[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]

  Powered by Linux