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] Plumb the "start_paused" flag through for

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] Plumb the "start_paused" flag through for VM.start and VM.resume. Do not
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Tue, 28 Nov 2006 22:10:16 +0000
Delivery-date: Tue, 28 Nov 2006 14:10:02 -0800
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 Ewan Mellor <ewan@xxxxxxxxxxxxx>
# Node ID 33951d547223c368a6dfdaad59e118e25a24adcf
# Parent  39e40ccf7df5ea2e4142ccbece57d56fa64d1b71
Plumb the "start_paused" flag through for VM.start and VM.resume.  Do not
unpause the VM on start by default.  This should fix problems seen recently
whereby devices are not attached to the VM by the time they boot, as
xm create was expecting to be able to wait for the devices before unpausing.

Signed-off-by: Ewan Mellor <ewan@xxxxxxxxxxxxx>
---
 tools/python/xen/xend/XendAPI.py        |   12 +++----
 tools/python/xen/xend/XendDomain.py     |   15 ++++----
 tools/python/xen/xend/XendDomainInfo.py |    5 +-
 tools/python/xen/xm/main.py             |   54 +++++++++++++++++++++++++++-----
 4 files changed, 64 insertions(+), 22 deletions(-)

diff -r 39e40ccf7df5 -r 33951d547223 tools/python/xen/xend/XendAPI.py
--- a/tools/python/xen/xend/XendAPI.py  Tue Nov 28 17:15:22 2006 +0000
+++ b/tools/python/xen/xend/XendAPI.py  Tue Nov 28 17:28:43 2006 +0000
@@ -248,8 +248,8 @@ def valid_sr(func):
 # Bridge to Legacy XM API calls
 # -----------------------------
 
-def do_vm_func(fn_name, vm_ref, *args):
-    """Helper wrapper func to abstract away from repeative code.
+def do_vm_func(fn_name, vm_ref, *args, **kwargs):
+    """Helper wrapper func to abstract away from repetitive code.
 
     @param fn_name: function name for XendDomain instance
     @type fn_name: string
@@ -260,7 +260,7 @@ def do_vm_func(fn_name, vm_ref, *args):
     """
     xendom = XendDomain.instance()
     fn = getattr(xendom, fn_name)
-    xendom.do_legacy_api_with_uuid(fn, vm_ref, *args)
+    xendom.do_legacy_api_with_uuid(fn, vm_ref, *args, **kwargs)
     return xen_api_success_void()
 
 
@@ -1027,9 +1027,9 @@ class XendAPI:
     def vm_pause(self, session, vm_ref):
         return do_vm_func("domain_pause", vm_ref)
     def vm_resume(self, session, vm_ref, start_paused):
-        return do_vm_func("domain_resume", vm_ref)    
-    def vm_start(self, session, vm_ref):
-        return do_vm_func("domain_start", vm_ref)
+        return do_vm_func("domain_resume", vm_ref, start_paused = 
start_paused)    
+    def vm_start(self, session, vm_ref, start_paused):
+        return do_vm_func("domain_start", vm_ref, start_paused = start_paused)
     def vm_suspend(self, session, vm_ref):
         return do_vm_func("domain_suspend", vm_ref)    
     def vm_unpause(self, session, vm_ref):
diff -r 39e40ccf7df5 -r 33951d547223 tools/python/xen/xend/XendDomain.py
--- a/tools/python/xen/xend/XendDomain.py       Tue Nov 28 17:15:22 2006 +0000
+++ b/tools/python/xen/xend/XendDomain.py       Tue Nov 28 17:28:43 2006 +0000
@@ -647,18 +647,18 @@ class XendDomain:
     def is_valid_dev(self, klass, dev_uuid):
         return (self.get_vm_with_dev_uuid(klass, dev_uuid) != None)
 
-    def do_legacy_api_with_uuid(self, fn, vm_uuid, *args):
+    def do_legacy_api_with_uuid(self, fn, vm_uuid, *args, **kwargs):
         self.domains_lock.acquire()
         try:
             for domid, dom in self.domains.items():
                 if dom.get_uuid == vm_uuid:
-                    return fn(domid, *args)
+                    return fn(domid, *args, **kwargs)
                     
             if vm_uuid in self.managed_domains:
                 domid = self.managed_domains[vm_uuid].getDomid()
                 if domid == None:
                     domid = self.managed_domains[vm_uuid].getName()
-                return fn(domid, *args)
+                return fn(domid, *args, **kwargs)
             
             raise XendInvalidDomain("Domain does not exist")
         finally:
@@ -795,7 +795,7 @@ class XendDomain:
             raise XendError("can't write guest state file %s: %s" %
                             (path, ex[1]))
 
-    def domain_resume(self, domname):
+    def domain_resume(self, domname, start_paused = False):
         """Resumes a domain that is persistently managed by Xend.
 
         @param domname: Domain Name
@@ -827,7 +827,8 @@ class XendDomain:
                     log.debug('Current DomainInfo state: %d' % dominfo.state)
                     XendCheckpoint.restore(self,
                                            os.open(chkpath, os.O_RDONLY),
-                                           dominfo)
+                                           dominfo,
+                                           paused = start_paused)
                     self._add_domain(dominfo)
                     os.unlink(chkpath)
                 except OSError, ex:
@@ -886,7 +887,7 @@ class XendDomain:
         finally:
             self.domains_lock.release()
 
-    def domain_start(self, domid):
+    def domain_start(self, domid, start_paused = True):
         """Start a managed domain
 
         @require: Domain must not be running.
@@ -907,7 +908,7 @@ class XendDomain:
             if dominfo.state != DOM_STATE_HALTED:
                 raise XendError("Domain is already running")
             
-            dominfo.start(is_managed = True)
+            dominfo.start(is_managed = True, start_paused = start_paused)
             self._add_domain(dominfo)
         finally:
             self.domains_lock.release()
diff -r 39e40ccf7df5 -r 33951d547223 tools/python/xen/xend/XendDomainInfo.py
--- a/tools/python/xen/xend/XendDomainInfo.py   Tue Nov 28 17:15:22 2006 +0000
+++ b/tools/python/xen/xend/XendDomainInfo.py   Tue Nov 28 17:28:43 2006 +0000
@@ -425,7 +425,7 @@ class XendDomainInfo:
     #
 
 
-    def start(self, is_managed = False):
+    def start(self, is_managed = False, start_paused = True):
         """Attempts to start the VM by do the appropriate
         initialisation if it not started.
         """
@@ -439,7 +439,8 @@ class XendDomainInfo:
                 self._storeDomDetails()
                 self._registerWatches()
                 self.refreshShutdown()
-                self.unpause()
+                if not start_paused:
+                    self.unpause()
 
                 # save running configuration if XendDomains believe domain is
                 # persistent
diff -r 39e40ccf7df5 -r 33951d547223 tools/python/xen/xm/main.py
--- a/tools/python/xen/xm/main.py       Tue Nov 28 17:15:22 2006 +0000
+++ b/tools/python/xen/xm/main.py       Tue Nov 28 17:28:43 2006 +0000
@@ -207,7 +207,13 @@ SUBCOMMAND_OPTIONS = {
        ('-L', '--live', 'Dump core without pausing the domain'),
        ('-C', '--crash', 'Crash domain after dumping core'),
     ),
-    'restore': (
+    'start': (
+      ('-p', '--paused', 'Do not unpause domain after starting it'),
+    ),
+    'resume': (
+      ('-p', '--paused', 'Do not unpause domain after resuming it'),
+    ),
+   'restore': (
       ('-p', '--paused', 'Do not unpause domain after restoring it'),
     ),
 }
@@ -742,9 +748,26 @@ def xm_vcpu_list(args):
             print format % locals()
 
 def xm_start(args):
-    arg_check(args, "start", 1)
-    dom = args[0]
-    server.xend.domain.start(dom)
+    arg_check(args, "start", 1, 2)
+
+    try:
+        (options, params) = getopt.gnu_getopt(args, 'p', ['paused'])
+    except getopt.GetoptError, opterr:
+        err(opterr)
+        sys.exit(1)
+
+    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')
+        sys.exit(1)
+
+    dom = params[0]
+    server.xend.domain.start(dom, paused)
 
 def xm_delete(args):
     arg_check(args, "delete", 1)
@@ -757,9 +780,26 @@ def xm_suspend(args):
     server.xend.domain.suspend(dom)
 
 def xm_resume(args):
-    arg_check(args, "resume", 1)
-    dom = args[0]
-    server.xend.domain.resume(dom)
+    arg_check(args, "resume", 1, 2)
+
+    try:
+        (options, params) = getopt.gnu_getopt(args, 'p', ['paused'])
+    except getopt.GetoptError, opterr:
+        err(opterr)
+        sys.exit(1)
+
+    paused = False
+    for (k, v) in options:
+        if k in ['-p', '--paused']:
+            paused = True
+
+    if len(params) != 1:
+        err("Wrong number of parameters")
+        usage('resume')
+        sys.exit(1)
+
+    dom = params[0]
+    server.xend.domain.resume(dom, paused)
     
 def xm_reboot(args):
     arg_check(args, "reboot", 1, 3)

_______________________________________________
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] Plumb the "start_paused" flag through for VM.start and VM.resume. Do not, Xen patchbot-unstable <=