FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Redhat > Fedora/Linux Management Tools

 
 
LinkBack Thread Tools
 
Old 02-05-2009, 06:21 PM
 
Default Kill console process if control-C is pressed

# HG changeset patch
# User john.levon@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@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:
%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

_______________________________________________
et-mgmt-tools mailing list
et-mgmt-tools@redhat.com
https://www.redhat.com/mailman/listinfo/et-mgmt-tools
 

Thread Tools




All times are GMT. The time now is 01:06 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org