Revision bbcf7ad0 lib/hypervisor/hv_kvm.py
b/lib/hypervisor/hv_kvm.py | ||
---|---|---|
613 | 613 |
|
614 | 614 |
return result |
615 | 615 |
|
616 |
def StopInstance(self, instance, force=False, retry=False): |
|
616 |
def StopInstance(self, instance, force=False, retry=False, name=None):
|
|
617 | 617 |
"""Stop an instance. |
618 | 618 |
|
619 | 619 |
""" |
620 |
pidfile, pid, alive = self._InstancePidAlive(instance.name) |
|
620 |
if name is not None and not force: |
|
621 |
raise errors.HypervisorError("Cannot shutdown cleanly by name only") |
|
622 |
if name is None: |
|
623 |
name = instance.name |
|
624 |
acpi = instance.hvparams[constants.HV_ACPI] |
|
625 |
else: |
|
626 |
acpi = False |
|
627 |
pidfile, pid, alive = self._InstancePidAlive(name) |
|
621 | 628 |
if pid > 0 and alive: |
622 |
if force or not instance.hvparams[constants.HV_ACPI]:
|
|
629 |
if force or not acpi:
|
|
623 | 630 |
utils.KillProcess(pid) |
624 | 631 |
else: |
625 |
self._CallMonitorCommand(instance.name, 'system_powerdown')
|
|
632 |
self._CallMonitorCommand(name, 'system_powerdown') |
|
626 | 633 |
|
627 |
if not self._InstancePidAlive(instance.name)[2]:
|
|
628 |
self._RemoveInstanceRuntimeFiles(pidfile, instance.name)
|
|
634 |
if not self._InstancePidAlive(name)[2]: |
|
635 |
self._RemoveInstanceRuntimeFiles(pidfile, name) |
|
629 | 636 |
return True |
630 | 637 |
else: |
631 | 638 |
return False |
Also available in: Unified diff