Skip to content

Commit 15f2620

Browse files
authored
Merge pull request #2109 from r2d4/kvm-stop
DOM_SHUTDOWN should return state.Running
2 parents ea31492 + 2c2c45d commit 15f2620

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

Diff for: pkg/drivers/kvm/kvm.go

+17-3
Original file line numberDiff line numberDiff line change
@@ -129,14 +129,28 @@ func (d *Driver) GetState() (state.State, error) {
129129
return state.None, errors.Wrap(err, "getting domain state")
130130
}
131131

132+
// Possible States:
133+
//
134+
// VIR_DOMAIN_NOSTATE no state
135+
// VIR_DOMAIN_RUNNING the domain is running
136+
// VIR_DOMAIN_BLOCKED the domain is blocked on resource
137+
// VIR_DOMAIN_PAUSED the domain is paused by user
138+
// VIR_DOMAIN_SHUTDOWN the domain is being shut down
139+
// VIR_DOMAIN_SHUTOFF the domain is shut off
140+
// VIR_DOMAIN_CRASHED the domain is crashed
141+
// VIR_DOMAIN_PMSUSPENDED the domain is suspended by guest power management
142+
// VIR_DOMAIN_LAST this enum value will increase over time as new events are added to the libvirt API. It reflects the last state supported by this version of the libvirt API.
143+
132144
switch libvirtState {
133-
case libvirt.DOMAIN_RUNNING:
145+
// DOMAIN_SHUTDOWN technically means the VM is still running, but in the
146+
// process of being shutdown, so we return state.Running
147+
case libvirt.DOMAIN_RUNNING, libvirt.DOMAIN_SHUTDOWN:
134148
return state.Running, nil
135149
case libvirt.DOMAIN_BLOCKED, libvirt.DOMAIN_CRASHED:
136150
return state.Error, nil
137151
case libvirt.DOMAIN_PAUSED:
138152
return state.Paused, nil
139-
case libvirt.DOMAIN_SHUTDOWN, libvirt.DOMAIN_SHUTOFF:
153+
case libvirt.DOMAIN_SHUTOFF:
140154
return state.Stopped, nil
141155
case libvirt.DOMAIN_PMSUSPENDED:
142156
return state.Saved, nil
@@ -299,7 +313,7 @@ func (d *Driver) Stop() error {
299313
if s == state.Stopped {
300314
return nil
301315
}
302-
log.Info("Waiting for machine to stop %d/%d", i, 60)
316+
log.Infof("Waiting for machine to stop %d/%d", i, 60)
303317
time.Sleep(1 * time.Second)
304318
}
305319

0 commit comments

Comments
 (0)