Re: [PATCH v2 3/7] hyperv: implement domainReboot and domainReset
> On Oct 13, 2020, at 3:40 AM, Pino Toscano wrote: > > What about making a common helper function that calls > hypervMsvmComputerSystemFromDomain + > hypervInvokeMsvmComputerSystemRequestStateChange? I’ll include that in the next version of this patchset. > Note that virDomainReboot() can take various flags, however none is > used ATM. Would it be okay to stick with what I’ve got, now, and look at adding support for the flags in a future commit? -- Matt
Re: [PATCH v2 3/7] hyperv: implement domainReboot and domainReset
On Wednesday, 14 October 2020 05:23:21 CEST Matt Coleman wrote: > > Note that virDomainReboot() can take various flags, however none is > > used ATM. > > Would it be okay to stick with what I’ve got, now, and look at adding > support for the flags in a future commit? Sorry, I did not express myself properly: I did not want to say you have to add support for these flags, but merely that the functions implemented by this patch do not. Hence, depending on what you plan to add to them (or even whether any of the flags can be supported), my earlier suggestion of a common helper might make sense or not. -- Pino Toscano signature.asc Description: This is a digitally signed message part.
[PATCH v2 3/7] hyperv: implement domainReboot and domainReset
Co-authored-by: Sri Ramanujam Signed-off-by: Matt Coleman --- 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, ) < 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, ) < 0) +goto cleanup; + +result = hypervInvokeMsvmComputerSystemRequestStateChange(domain, +MSVM_COMPUTERSYSTEM_REQUESTEDSTATE_RESET); + + cleanup: +hypervFreeObject(priv, (hypervObject *)computerSystem); + +return result; +} + + + static int hypervDomainDestroyFlags(virDomainPtr domain, unsigned int flags) { @@ -1967,6 +2013,8 @@ static virHypervisorDriver hypervHypervisorDriver = { .domainLookupByName = hypervDomainLookupByName, /* 0.9.5 */ .domainSuspend = hypervDomainSuspend, /* 0.9.5 */ .domainResume = hypervDomainResume, /* 0.9.5 */ +.domainReboot = hypervDomainReboot, /* 6.9.0 */ +.domainReset = hypervDomainReset, /* 6.9.0 */ .domainDestroy = hypervDomainDestroy, /* 0.9.5 */ .domainDestroyFlags = hypervDomainDestroyFlags, /* 0.9.5 */ .domainGetOSType = hypervDomainGetOSType, /* 0.9.5 */ diff --git a/src/hyperv/hyperv_wmi_classes.h b/src/hyperv/hyperv_wmi_classes.h index d32711589a..7f4159dd8e 100644 --- a/src/hyperv/hyperv_wmi_classes.h +++ b/src/hyperv/hyperv_wmi_classes.h @@ -74,6 +74,7 @@ enum _Msvm_ComputerSystem_RequestedState { MSVM_COMPUTERSYSTEM_REQUESTEDSTATE_ENABLED = 2, MSVM_COMPUTERSYSTEM_REQUESTEDSTATE_DISABLED = 3, MSVM_COMPUTERSYSTEM_REQUESTEDSTATE_REBOOT = 10, +MSVM_COMPUTERSYSTEM_REQUESTEDSTATE_RESET = 11, MSVM_COMPUTERSYSTEM_REQUESTEDSTATE_PAUSED = 32768, MSVM_COMPUTERSYSTEM_REQUESTEDSTATE_SUSPENDED = 32769, }; -- 2.27.0
Re: [PATCH v2 3/7] hyperv: implement domainReboot and domainReset
On Tuesday, 13 October 2020 07:14:00 CEST Matt Coleman wrote: > Co-authored-by: Sri Ramanujam > Signed-off-by: Matt Coleman > --- > 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, ) < 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, ) < 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 signature.asc Description: This is a digitally signed message part.