Skip to contentSkip to conversation

Fix xm dump-core command for paused domain

PATCH New Masaki Kanno 1 participant 1 message Sep 13, 2007

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix xm dump-core command for paused domain

Hi,

When I got a core dump of a paused domain by xm dump-core command, the domain began to run automatically.

# xm pause vm1
# xm list
Name                                        ID   Mem VCPUs      State   Time(s)
Domain-0                                     0   747     2     r-----    121.1
vm1                                          1   256     1     --p---     26.6
# xm dump-core vm1
Dumping core of domain: vm1 ...
# xm list
Name                                        ID   Mem VCPUs      State   Time(s)
Domain-0                                     0   747     2     r-----    129.5
vm1                                          1   256     1     -b----     26.6

This patch keeps the domain state before getting a core dump of a domain by xm dump-core command. The test results are as follows.

# xm list
Name                                        ID   Mem VCPUs      State   Time(s)
Domain-0                                     0   747     2     r-----     64.8
vm1                                          1   128     1     r-----     94.0
vm2                                          2   128     1     --p---     80.9
# xm dump-core vm1
Dumping core of domain: vm1 ...
# xm list
Name                                        ID   Mem VCPUs      State   Time(s)
Domain-0                                     0   747     2     r-----     70.1
vm1                                          1   128     1     r-----    109.4
vm2                                          2   128     1     --p---     80.9
# xm dump-core vm2
Dumping core of domain: vm2 ...
# xm list
Name                                        ID   Mem VCPUs      State   Time(s)
Domain-0                                     0   747     2     r-----     75.2
vm1                                          1   128     1     r-----    131.1
vm2                                          2   128     1     --p---     80.9

Best regards,
Kan

tools/python/xen/xend/XendDomain.py +11 -4
diff -r a00cc97b392a tools/python/xen/xend/XendDomain.py
@@ -1176,12 +1176,16 @@ class XendDomain:
             log.exception("domain_unpause")
             raise XendError(str(ex))
 
-    def domain_pause(self, domid):
+    def domain_pause(self, domid, state=False):
         """Pause domain execution.
 
         @param domid: Domain ID or Name
         @type domid: int or string.
-        @rtype: None
+        @keyword state: If True, will return the domain state before pause
+        @type state: bool
+        @rtype: int if state is True
+        @return: Domain state (DOM_STATE_*)
+        @rtype: None if state is False
         @raise XendError: Failed to pause
         @raise XendInvalidDomain: Domain is not valid
         """        
@@ -1191,13 +1195,16 @@ class XendDomain:
                 raise XendInvalidDomain(str(domid))
             if dominfo.getDomid() == DOM0_ID:
                 raise XendError("Cannot pause privileged domain %s" % domid)
-            if dominfo._stateGet() not in (DOM_STATE_RUNNING, DOM_STATE_PAUSED):
+            ds = dominfo._stateGet()
+            if ds not in (DOM_STATE_RUNNING, DOM_STATE_PAUSED):
                 raise VMBadState("Domain '%s' is not started" % domid,
                                  POWER_STATE_NAMES[DOM_STATE_RUNNING],
-                                 POWER_STATE_NAMES[dominfo._stateGet()])
+                                 POWER_STATE_NAMES[ds])
             log.info("Domain %s (%d) paused.", dominfo.getName(),
                      int(dominfo.getDomid()))
             dominfo.pause()
+            if state:
+                return ds
         except XendInvalidDomain:
             log.exception("domain_pause")
             raise
tools/python/xen/xm/main.py +2 -2
diff -r a00cc97b392a tools/python/xen/xm/main.py
@@ -1287,13 +1287,13 @@ def xm_dump_core(args):
         filename = None
 
     if not live:
-        server.xend.domain.pause(dom)
+        ds = server.xend.domain.pause(dom, True)
 
     try:
         print "Dumping core of domain: %s ..." % str(dom)
         server.xend.domain.dump(dom, filename, live, crash)
     finally:
-        if not live:
+        if not live and ds == DOM_STATE_RUNNING:
             server.xend.domain.unpause(dom)
 
     if crash:

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel