[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] Clean up domains if creation/restoration fails.



# HG changeset patch
# User emellor@ewan
# Node ID 00037ba13f0bb8efe4b2c3efe40200eac21c68dd
# Parent  db651da378993509fa67e57ded1869c918356f4a
Clean up domains if creation/restoration fails.

Signed-off-by: Ewan Mellor <ewan@xxxxxxxxxxxxx>

diff -r db651da37899 -r 00037ba13f0b tools/python/xen/xend/XendDomainInfo.py
--- a/tools/python/xen/xend/XendDomainInfo.py   Tue Oct  4 16:54:33 2005
+++ b/tools/python/xen/xend/XendDomainInfo.py   Tue Oct  4 17:23:58 2005
@@ -129,9 +129,13 @@
     log.debug("XendDomainInfo.create(%s)", config)
 
     vm = XendDomainInfo(getUuid(), parseConfig(config))
-    vm.construct()
-    vm.refreshShutdown()
-    return vm
+    try:
+        vm.construct()
+        vm.refreshShutdown()
+        return vm
+    except:
+        vm.destroy()
+        raise
 
 
 def recreate(xeninfo):
@@ -195,13 +199,23 @@
     except TypeError, exn:
         raise VmError('Invalid ssidref in config: %s' % exn)
 
-    vm = XendDomainInfo(uuid, parseConfig(config),
-                        xc.domain_create(ssidref = ssidref))
-    vm.storeVmDetails()
-    vm.configure()
-    vm.create_channel()
-    vm.storeDomDetails()
-    return vm
+    domid = xc.domain_create(ssidref = ssidref)
+    if domid <= 0:
+        raise VmError('Creating domain failed for restore')
+    try:
+        vm = XendDomainInfo(uuid, parseConfig(config), domid)
+    except:
+        xc.domain_destroy(domid)
+        raise
+    try:
+        vm.storeVmDetails()
+        vm.configure()
+        vm.create_channel()
+        vm.storeDomDetails()
+        return vm
+    except:
+        vm.destroy()
+        raise
 
 
 def parseConfig(config):

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


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.