WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] xend: Give "xm start" a -c parameter for

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] xend: Give "xm start" a -c parameter for connecting to the console
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Mon, 04 Jun 2007 03:15:46 -0700
Delivery-date: Mon, 04 Jun 2007 03:34:57 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User kfraser@xxxxxxxxxxxxxxxxxxxxx
# Date 1180017373 -3600
# Node ID e046da853ffc4488c843ea7ac3f15852af81d4bf
# Parent  21f1a7a7ea30cd2c6855df2842fe0843bf7dfc1a
xend: Give "xm start" a -c parameter for connecting to the console
From: Chris Lalancette <clalance@xxxxxxxxxx>
Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx>
---
 tools/python/xen/xm/main.py |   69 ++++++++++++++++++++++++++++++++++----------
 1 files changed, 54 insertions(+), 15 deletions(-)

diff -r 21f1a7a7ea30 -r e046da853ffc tools/python/xen/xm/main.py
--- a/tools/python/xen/xm/main.py       Thu May 24 15:30:05 2007 +0100
+++ b/tools/python/xen/xm/main.py       Thu May 24 15:36:13 2007 +0100
@@ -231,6 +231,7 @@ SUBCOMMAND_OPTIONS = {
     ),
     'start': (
       ('-p', '--paused', 'Do not unpause domain after starting it'),
+      ('-c', '--console_autoconnect', 'Connect to the console after the domain 
is created'),
     ),
     'resume': (
       ('-p', '--paused', 'Do not unpause domain after resuming it'),
@@ -1125,29 +1126,67 @@ def xm_vcpu_list(args):
 
             print format % locals()
 
+def start_do_console(domain_name):
+    cpid = os.fork() 
+    if cpid != 0:
+        for i in range(10):
+            # Catch failure of the create process 
+            time.sleep(1)
+            (p, rv) = os.waitpid(cpid, os.WNOHANG)
+            if os.WIFEXITED(rv):
+                if os.WEXITSTATUS(rv) != 0:
+                    sys.exit(os.WEXITSTATUS(rv))
+            try:
+                # Acquire the console of the created dom
+                if serverType == SERVER_XEN_API:
+                    domid = server.xenapi.VM.get_domid(
+                               get_single_vm(domain_name))
+                else:
+                    dom = server.xend.domain(domain_name)
+                    domid = int(sxp.child_value(dom, 'domid', '-1'))
+                console.execConsole(domid)
+            except:
+                pass
+        print("Could not start console\n");
+        sys.exit(0)
+
 def xm_start(args):
-    arg_check(args, "start", 1, 2)
+
+    paused = False
+    console_autoconnect = False
 
     try:
-        (options, params) = getopt.gnu_getopt(args, 'p', ['paused'])
+        (options, params) = getopt.gnu_getopt(args, 'cp', 
['console_autoconnect','paused'])
+        for (k, v) in options:
+            if k in ('-p', '--paused'):
+                paused = True
+            if k in ('-c', '--console_autoconnect'):
+                console_autoconnect = True
+
+        if len(params) != 1:
+            raise OptionError("Expects 1 argument")
     except getopt.GetoptError, opterr:
         err(opterr)
         usage('start')
 
-    paused = False
-    for (k, v) in options:
-        if k in ['-p', '--paused']:
-            paused = True
-
-    if len(params) != 1:
-        err("Wrong number of parameters")
-        usage('start')
-
     dom = params[0]
-    if serverType == SERVER_XEN_API:
-        server.xenapi.VM.start(get_single_vm(dom), paused)
-    else:
-        server.xend.domain.start(dom, paused)
+
+    if console_autoconnect:
+        start_do_console(dom)
+
+    try:
+        if serverType == SERVER_XEN_API:
+            server.xenapi.VM.start(get_single_vm(dom), paused)
+            domid = int(server.xenapi.VM.get_domid(get_single_vm(dom)))
+        else:
+            server.xend.domain.start(dom, paused)
+            info = server.xend.domain(dom)
+            domid = int(sxp.child_value(info, 'domid', '-1'))
+    except:
+        raise
+        
+    if domid == -1:
+        raise xmlrpclib.Fault(0, "Domain '%s' is not started" % dom)
 
 def xm_delete(args):
     arg_check(args, "delete", 1)

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] xend: Give "xm start" a -c parameter for connecting to the console, Xen patchbot-unstable <=