Skip to contentSkip to conversation

Fix xm save command for a inactive managed domain

PATCH In review Masaki Kanno 1 participant 2 messages Jul 5, 2007 – Jul 9, 2007

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix xm save command for a inactive managed domain

Hi,

I tried to test wrong operations on purpose.

1. When I tried xm save command to a inactive managed domain, I saw the following error message. The error message did not have a domain name.

 # xm list vm1
 Name                                        ID   Mem VCPUs      State   Time(s)
 vm1                                              512     2                 0.0
 # xm save vm1 /xen/save.vm1
 Error: Domain '' does not exist.

2. When I tried xm save command to Domain-0, I saw the following error message.

 # xm save Domain-0 /xen/save.Domain-0
 Error: int argument required
 Usage: xm save [-c] <Domain> <CheckpointFile>

Save a domain state to restore later.
-c, --checkpoint Leave domain running after creating
snapshot

I made a patch. It solved the problems.

Best regards,
Kan

tools/python/xen/xend/XendDomain.py +5 -1
diff -r e7d40fadbf17 tools/python/xen/xend/XendDomain.py
@@ -1253,7 +1253,11 @@ class XendDomain:
                 raise XendInvalidDomain(str(domid))
 
             if dominfo.getDomid() == DOM0_ID:
-                raise XendError("Cannot save privileged domain %i" % domid)
+                raise XendError("Cannot save privileged domain %s" % str(domid))
+            if dominfo._stateGet() != DOM_STATE_RUNNING:
+                raise VMBadState("Domain is not running",
+                                 POWER_STATE_NAMES[DOM_STATE_RUNNING],
+                                 POWER_STATE_NAMES[dominfo._stateGet()])
 
             oflags = os.O_WRONLY | os.O_CREAT | os.O_TRUNC
             if hasattr(os, "O_LARGEFILE"):
tools/python/xen/xm/main.py +1 -7
diff -r e7d40fadbf17 tools/python/xen/xm/main.py
@@ -700,13 +700,7 @@ def xm_save(args):
     if serverType == SERVER_XEN_API:       
         server.xenapi.VM.save(get_single_vm(dom), savefile, checkpoint)
     else:
-        try:
-            dominfo = parse_doms_info(server.xend.domain(dom))
-        except xmlrpclib.Fault, ex:
-            raise ex
-    
-        domid = dominfo['domid']
-        server.xend.domain.save(domid, savefile, checkpoint)
+        server.xend.domain.save(dom, savefile, checkpoint)
     
 def xm_restore(args):
     arg_check(args, "restore", 1, 2)

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

#1 lore raw

Re: [PATCH] Fix xm save command for a inactive manageddomain

Hi,

Could you comment this patch?
To solve the problems, should I use XendError(), not VMBadState()?

tools/python/xen/xend/XendDomain.py +5 -1
diff -r e7d40fadbf17 tools/python/xen/xend/XendDomain.py
@@ -1253,7 +1253,11 @@ class XendDomain:
                 raise XendInvalidDomain(str(domid))
 
             if dominfo.getDomid() == DOM0_ID:
-                raise XendError("Cannot save privileged domain %i" % domid)
+                raise XendError("Cannot save privileged domain %s" % str(domid))
+            if dominfo._stateGet() != DOM_STATE_RUNNING:
+                raise VMBadState("Domain is not running",
+                                 POWER_STATE_NAMES[DOM_STATE_RUNNING],
+                                 POWER_STATE_NAMES[dominfo._stateGet()])
 
             oflags = os.O_WRONLY | os.O_CREAT | os.O_TRUNC
             if hasattr(os, "O_LARGEFILE"):

Best regards,
Kan

Quoted 40 lines

Hi,

I tried to test wrong operations on purpose.

1. When I tried xm save command to a inactive managed domain, I saw the following error message. The error message did not have a domain name.

# xm list vm1
Name                                        ID   Mem VCPUs      State   
Time(s)
vm1                                              512     2                
0.0
# xm save vm1 /xen/save.vm1
Error: Domain '' does not exist.

2. When I tried xm save command to Domain-0, I saw the following error message.

# xm save Domain-0 /xen/save.Domain-0
Error: int argument required
Usage: xm save [-c] <Domain> <CheckpointFile>

Save a domain state to restore later.
-c, --checkpoint Leave domain running after creating
snapshot

I made a patch. It solved the problems.

Best regards,
Kan

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