diff options
author | emellor@ewan <emellor@ewan> | 2005-10-04 18:23:58 +0100 |
---|---|---|
committer | emellor@ewan <emellor@ewan> | 2005-10-04 18:23:58 +0100 |
commit | 186b17976c76e2f18b2a91148baf964d18014774 (patch) | |
tree | 1650a01b32fc0fa7065a54895576998024800a2d /tools | |
parent | 186e5727bae4429484dd68c0791fc0f8f6c0bf26 (diff) | |
download | xen-186b17976c76e2f18b2a91148baf964d18014774.tar.gz xen-186b17976c76e2f18b2a91148baf964d18014774.tar.bz2 xen-186b17976c76e2f18b2a91148baf964d18014774.zip |
Clean up domains if creation/restoration fails.
Signed-off-by: Ewan Mellor <ewan@xensource.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/python/xen/xend/XendDomainInfo.py | 34 |
1 files changed, 24 insertions, 10 deletions
diff --git a/tools/python/xen/xend/XendDomainInfo.py b/tools/python/xen/xend/XendDomainInfo.py index 994cd4e130..782a1b7d68 100644 --- a/tools/python/xen/xend/XendDomainInfo.py +++ b/tools/python/xen/xend/XendDomainInfo.py @@ -129,9 +129,13 @@ def create(config): 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 @@ def restore(config): 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): |