mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-11 07:17:44 +00:00
hyperv: implement domainReboot and domainReset
Co-authored-by: Sri Ramanujam <sramanujam@datto.com> Signed-off-by: Matt Coleman <matt@datto.com> Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
7bf302fb63
commit
8943b14838
@ -287,6 +287,29 @@ hypervGetMemSDByVSSDInstanceId(hypervPrivate *priv, const char *id,
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
hypervRequestStateChange(virDomainPtr domain, int state)
|
||||
{
|
||||
int result = -1;
|
||||
hypervPrivate *priv = domain->conn->privateData;
|
||||
Msvm_ComputerSystem *computerSystem = NULL;
|
||||
|
||||
if (hypervMsvmComputerSystemFromDomain(domain, &computerSystem) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (computerSystem->data.common->EnabledState != MSVM_COMPUTERSYSTEM_ENABLEDSTATE_ENABLED) {
|
||||
virReportError(VIR_ERR_OPERATION_INVALID, "%s", _("Domain is not active"));
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
result = hypervInvokeMsvmComputerSystemRequestStateChange(domain, state);
|
||||
|
||||
cleanup:
|
||||
hypervFreeObject(priv, (hypervObject *)computerSystem);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* API-specific utility functions
|
||||
@ -923,6 +946,24 @@ hypervDomainResume(virDomainPtr domain)
|
||||
|
||||
|
||||
|
||||
static int
|
||||
hypervDomainReboot(virDomainPtr domain, unsigned int flags)
|
||||
{
|
||||
virCheckFlags(0, -1);
|
||||
return hypervRequestStateChange(domain, MSVM_COMPUTERSYSTEM_REQUESTEDSTATE_REBOOT);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static int
|
||||
hypervDomainReset(virDomainPtr domain, unsigned int flags)
|
||||
{
|
||||
virCheckFlags(0, -1);
|
||||
return hypervRequestStateChange(domain, MSVM_COMPUTERSYSTEM_REQUESTEDSTATE_RESET);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static int
|
||||
hypervDomainDestroyFlags(virDomainPtr domain, unsigned int flags)
|
||||
{
|
||||
@ -1953,6 +1994,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 */
|
||||
|
@ -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,
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user