[et-mgmt-tools] [PATCH] Kill console process if control-C is pressed
john.levon at sun.com
john.levon at sun.com
Thu Feb 5 19:21:40 UTC 2009
# HG changeset patch
# User john.levon at sun.com
# Date 1233790091 28800
# Node ID 43ef4509832aea50d4812aa33fa46a1f650c196d
# Parent 507b2f948f3b1f4a1a844493e4de67a1f8938f6c
Kill console process if control-C is pressed
Signed-off-by: John Levon <john.levon at sun.com>
diff --git a/virt-install b/virt-install
--- a/virt-install
+++ b/virt-install
@@ -709,6 +709,9 @@ def main():
print _("Guest installation complete... restarting guest.")
dom.create()
guest.connect_console(conscb)
+ except KeyboardInterrupt, e:
+ guest.terminate_console()
+ print _("Guest install interrupted.")
except RuntimeError, e:
fail(e)
except SystemExit, e:
diff --git a/virtinst/Guest.py b/virtinst/Guest.py
--- a/virtinst/Guest.py
+++ b/virtinst/Guest.py
@@ -36,8 +36,8 @@ import osdict
import osdict
from VirtualDisk import VirtualDisk
from virtinst import _virtinst as _
-
import logging
+import signal
XEN_SCRATCH="/var/lib/xen"
LIBVIRT_SCRATCH="/var/lib/libvirt/boot"
@@ -550,6 +550,7 @@ class Guest(object):
self._vcpus = None
self._cpuset = None
self._graphics_dev = None
+ self._consolechild = None
self._os_type = None
self._os_variant = None
@@ -940,6 +941,7 @@ class Guest(object):
wait=True):
"""Do the startup of the guest installation."""
self.validate_parms()
+ self._consolechild = None
if meter is None:
# BaseMeter does nothing, but saves a lot of null checking
@@ -1002,6 +1004,7 @@ class Guest(object):
if consolecb:
logging.debug("Launching console callback")
child = consolecb(self.domain)
+ self._consolechild = child
boot_xml = self.get_config_xml(install = False)
logging.debug("Saving XML boot config:\n%s" % boot_xml)
@@ -1038,6 +1041,7 @@ class Guest(object):
if consolecb:
logging.debug("Launching console callback")
child = consolecb(self.domain)
+ self._consolechild = child
if child and wait: # if we connected the console, wait for it to finish
try:
@@ -1102,6 +1106,10 @@ class Guest(object):
raise RuntimeError(_("Invalid dictionary entry for device '%s %s'" % \
(device_key, param)))
+ def terminate_console(self):
+ if self._consolechild:
+ os.kill(self._consolechild, signal.SIGKILL)
+
def _wait_for_domain(conn, name):
# sleep in .25 second increments until either a) we get running
# domain ID or b) it's been 5 seconds. this is so that
More information about the et-mgmt-tools
mailing list