ia64/xen-unstable

changeset 7211:00037ba13f0b

Clean up domains if creation/restoration fails.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
author emellor@ewan
date Tue Oct 04 18:23:58 2005 +0100 (2005-10-04)
parents db651da37899
children 2c9e66555ff4
files tools/python/xen/xend/XendDomainInfo.py
line diff
     1.1 --- a/tools/python/xen/xend/XendDomainInfo.py	Tue Oct 04 17:54:33 2005 +0100
     1.2 +++ b/tools/python/xen/xend/XendDomainInfo.py	Tue Oct 04 18:23:58 2005 +0100
     1.3 @@ -129,9 +129,13 @@ def create(config):
     1.4      log.debug("XendDomainInfo.create(%s)", config)
     1.5  
     1.6      vm = XendDomainInfo(getUuid(), parseConfig(config))
     1.7 -    vm.construct()
     1.8 -    vm.refreshShutdown()
     1.9 -    return vm
    1.10 +    try:
    1.11 +        vm.construct()
    1.12 +        vm.refreshShutdown()
    1.13 +        return vm
    1.14 +    except:
    1.15 +        vm.destroy()
    1.16 +        raise
    1.17  
    1.18  
    1.19  def recreate(xeninfo):
    1.20 @@ -195,13 +199,23 @@ def restore(config):
    1.21      except TypeError, exn:
    1.22          raise VmError('Invalid ssidref in config: %s' % exn)
    1.23  
    1.24 -    vm = XendDomainInfo(uuid, parseConfig(config),
    1.25 -                        xc.domain_create(ssidref = ssidref))
    1.26 -    vm.storeVmDetails()
    1.27 -    vm.configure()
    1.28 -    vm.create_channel()
    1.29 -    vm.storeDomDetails()
    1.30 -    return vm
    1.31 +    domid = xc.domain_create(ssidref = ssidref)
    1.32 +    if domid <= 0:
    1.33 +        raise VmError('Creating domain failed for restore')
    1.34 +    try:
    1.35 +        vm = XendDomainInfo(uuid, parseConfig(config), domid)
    1.36 +    except:
    1.37 +        xc.domain_destroy(domid)
    1.38 +        raise
    1.39 +    try:
    1.40 +        vm.storeVmDetails()
    1.41 +        vm.configure()
    1.42 +        vm.create_channel()
    1.43 +        vm.storeDomDetails()
    1.44 +        return vm
    1.45 +    except:
    1.46 +        vm.destroy()
    1.47 +        raise
    1.48  
    1.49  
    1.50  def parseConfig(config):