ia64/xen-unstable

changeset 12114:f5912c42fbc3

[XEND] Save device updates to VM configuration via Xen API

Signed-off-by: Alastair Tse <atse@xensource.com>
author Alastair Tse <atse@xensource.com>
date Fri Oct 06 17:34:49 2006 +0100 (2006-10-06)
parents c21f4949a746
children 53b8f2b74ab2
files tools/python/xen/xend/XendAPI.py tools/python/xen/xend/XendDomain.py tools/python/xen/xend/XendDomainInfo.py
line diff
     1.1 --- a/tools/python/xen/xend/XendAPI.py	Fri Oct 06 16:40:39 2006 +0100
     1.2 +++ b/tools/python/xen/xend/XendAPI.py	Fri Oct 06 17:34:49 2006 +0100
     1.3 @@ -963,6 +963,7 @@ class XendAPI:
     1.4              dom = xendom.get_vm_by_uuid(vbd_struct['VM'])
     1.5              try:
     1.6                  vbd_ref = dom.create_vbd(vbd_struct)
     1.7 +                xendom.managed_config_save(dom)
     1.8                  return xen_api_success(vbd_ref)
     1.9              except XendError:
    1.10                  return xen_api_error(XEND_ERROR_TODO)
    1.11 @@ -1029,6 +1030,7 @@ class XendAPI:
    1.12              dom = xendom.get_vm_by_uuid(vif_struct['VM'])
    1.13              try:
    1.14                  vif_ref = dom.create_vif(vif_struct)
    1.15 +                xendom.managed_config_save(dom)                
    1.16                  return xen_api_success(vif_ref)
    1.17              except XendError:
    1.18                  return xen_api_error(XEND_ERROR_TODO)
     2.1 --- a/tools/python/xen/xend/XendDomain.py	Fri Oct 06 16:40:39 2006 +0100
     2.2 +++ b/tools/python/xen/xend/XendDomain.py	Fri Oct 06 17:34:49 2006 +0100
     2.3 @@ -143,7 +143,7 @@ class XendDomain:
     2.4              running = self._running_domains()
     2.5              managed = self._managed_domains()
     2.6  
     2.7 -            # add all active domains, replacing managed ones
     2.8 +            # add all active domains
     2.9              for dom in running:
    2.10                  if dom['domid'] != DOM0_ID:
    2.11                      try:
    2.12 @@ -160,12 +160,14 @@ class XendDomain:
    2.13                  dom_name = dom.get('name', 'Domain-%s' % dom_uuid)
    2.14                  
    2.15                  try:
    2.16 -                    # instantiate domain if not started.
    2.17 -                    if not self.domain_lookup_nr(dom_name):
    2.18 +                    running_dom = self.domain_lookup_nr(dom_name)
    2.19 +                    if not running_dom:
    2.20 +                        # instantiate domain if not started.
    2.21                          new_dom = XendDomainInfo.createDormant(dom)
    2.22                          self._add_domain(new_dom)
    2.23 -                    # keep track of maanged domains
    2.24 -                    self._managed_domain_register(new_dom)
    2.25 +                        self._managed_domain_register(new_dom)
    2.26 +                    else:
    2.27 +                        self._managed_domain_register(running_dom)
    2.28                  except Exception:
    2.29                      log.exception("Failed to create reference to managed "
    2.30                                    "domain: %s" % dom_name)
    2.31 @@ -237,6 +239,9 @@ class XendDomain:
    2.32          @raise XendError: fails to save configuration.
    2.33          @rtype: None
    2.34          """
    2.35 +        if not self.is_domain_managed(dominfo):
    2.36 +            return # refuse to save configuration this domain isn't managed
    2.37 +        
    2.38          if dominfo:
    2.39              domains_dir = self._managed_path()
    2.40              dom_uuid = dominfo.get_uuid()            
     3.1 --- a/tools/python/xen/xend/XendDomainInfo.py	Fri Oct 06 16:40:39 2006 +0100
     3.2 +++ b/tools/python/xen/xend/XendDomainInfo.py	Fri Oct 06 17:34:49 2006 +0100
     3.3 @@ -265,7 +265,7 @@ def createDormant(xeninfo):
     3.4      
     3.5      log.debug("XendDomainInfo.createDormant(%s)", xeninfo)
     3.6      
     3.7 -    # Remove domid and uuid do not make sense for non-running domains.
     3.8 +    # domid does not make sense for non-running domains.
     3.9      xeninfo.pop('domid', None)
    3.10      vm = XendDomainInfo(XendConfig(cfg = xeninfo))
    3.11      return vm