[libvirt] [PATCH 09/16] hyperv: add domain shutdown function

John Ferlan jferlan at redhat.com
Thu Sep 15 13:20:03 UTC 2016



On 08/09/2016 08:39 AM, Jason Miesionczek wrote:
> ---
>  src/hyperv/hyperv_driver.c | 35 +++++++++++++++++++++++++++++++++++
>  1 file changed, 35 insertions(+)
> 
> diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c
> index 4c094e7..2623916 100644
> --- a/src/hyperv/hyperv_driver.c
> +++ b/src/hyperv/hyperv_driver.c
> @@ -1704,6 +1704,39 @@ hypervDomainGetAutostart(virDomainPtr domain, int *autostart)
>      return result;
>  }
>  
> +static int
> +hypervDomainShutdownFlags(virDomainPtr domain, unsigned int flags)
> +{
> +    int result = -1;
> +    hypervPrivate *priv = domain->conn->privateData;
> +    Msvm_ComputerSystem *computerSystem = NULL;
> +    bool in_transition = false;
> +
> +    virCheckFlags(0, -1);
> +
> +    if (hypervMsvmComputerSystemFromDomain(domain, &computerSystem) < 0) {
> +        goto cleanup;
> +    }
> +
> +    if (!hypervIsMsvmComputerSystemActive(computerSystem, &in_transition) || in_transition) {
> +        virReportError(VIR_ERR_OPERATION_INVALID, "%s",
> +                       _("Domain is not active or is in state transition"));
> +        goto cleanup;
> +    }
> +
> +    result = hypervInvokeMsvmComputerSystemRequestStateChange(domain, MSVM_COMPUTERSYSTEM_REQUESTEDSTATE_DISABLED);
> +
> + cleanup:
> +    hypervFreeObject(priv, (hypervObject *) computerSystem);
> +    return result;
> +}

Beyond the long lines - it strikes me that shouldn't a DomainShutdown do
some sort of shutdown?  From just the name, it would seem that
hypervInvokeMsvmComputerSystemRequestStateChange doesn't do that
shutdown, but rather inhibits changing state.

Functionally, it's just not clear this is doing all it needs to do.

> +
> +static int
> +hypervDomainShutdown(virDomainPtr dom)
> +{
> +    return hypervDomainShutdownFlags(dom, 0);
> +}
> +
>  static virHypervisorDriver hypervHypervisorDriver = {
>      .name = "Hyper-V",
>      .connectOpen = hypervConnectOpen, /* 0.9.5 */
> @@ -1747,6 +1780,8 @@ static virHypervisorDriver hypervHypervisorDriver = {
>      .domainGetVcpus = hypervDomainGetVcpus, /* 1.2.10 */
>      .domainSetAutostart = hypervDomainSetAutostart, /* 1.2.10 */
>      .domainGetAutostart = hypervDomainGetAutostart, /* 1.2.10 */
> +    .domainShutdownFlags = hypervDomainShutdownFlags, /* 1.2.10 */
> +    .domainShutdown = hypervDomainShutdown, /* 1.2.10 */

2.3.0 at the earliest

John

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




More information about the libvir-list mailing list