mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 10:11:27 +01:00
[XEND] Save device updates to VM configuration via Xen API
Signed-off-by: Alastair Tse <atse@xensource.com>
This commit is contained in:
1 parent
4abcfe99ad
commit
1e66d26cbd
3 files changed
+13
-6
No files matched your search
@@ -963,6 +963,7 @@ class XendAPI:
|
||||
dom = xendom.get_vm_by_uuid(vbd_struct['VM'])
|
||||
try:
|
||||
vbd_ref = dom.create_vbd(vbd_struct)
|
||||
xendom.managed_config_save(dom)
|
||||
return xen_api_success(vbd_ref)
|
||||
except XendError:
|
||||
return xen_api_error(XEND_ERROR_TODO)
|
||||
@@ -1029,6 +1030,7 @@ class XendAPI:
|
||||
dom = xendom.get_vm_by_uuid(vif_struct['VM'])
|
||||
try:
|
||||
vif_ref = dom.create_vif(vif_struct)
|
||||
xendom.managed_config_save(dom)
|
||||
return xen_api_success(vif_ref)
|
||||
except XendError:
|
||||
return xen_api_error(XEND_ERROR_TODO)
|
||||
|
||||
@@ -143,7 +143,7 @@ class XendDomain:
|
||||
running = self._running_domains()
|
||||
managed = self._managed_domains()
|
||||
|
||||
# add all active domains, replacing managed ones
|
||||
# add all active domains
|
||||
for dom in running:
|
||||
if dom['domid'] != DOM0_ID:
|
||||
try:
|
||||
@@ -160,12 +160,14 @@ class XendDomain:
|
||||
dom_name = dom.get('name', 'Domain-%s' % dom_uuid)
|
||||
|
||||
try:
|
||||
# instantiate domain if not started.
|
||||
if not self.domain_lookup_nr(dom_name):
|
||||
running_dom = self.domain_lookup_nr(dom_name)
|
||||
if not running_dom:
|
||||
# instantiate domain if not started.
|
||||
new_dom = XendDomainInfo.createDormant(dom)
|
||||
self._add_domain(new_dom)
|
||||
# keep track of maanged domains
|
||||
self._managed_domain_register(new_dom)
|
||||
self._managed_domain_register(new_dom)
|
||||
else:
|
||||
self._managed_domain_register(running_dom)
|
||||
except Exception:
|
||||
log.exception("Failed to create reference to managed "
|
||||
"domain: %s" % dom_name)
|
||||
@@ -237,6 +239,9 @@ class XendDomain:
|
||||
@raise XendError: fails to save configuration.
|
||||
@rtype: None
|
||||
"""
|
||||
if not self.is_domain_managed(dominfo):
|
||||
return # refuse to save configuration this domain isn't managed
|
||||
|
||||
if dominfo:
|
||||
domains_dir = self._managed_path()
|
||||
dom_uuid = dominfo.get_uuid()
|
||||
|
||||
@@ -265,7 +265,7 @@ def createDormant(xeninfo):
|
||||
|
||||
log.debug("XendDomainInfo.createDormant(%s)", xeninfo)
|
||||
|
||||
# Remove domid and uuid do not make sense for non-running domains.
|
||||
# domid does not make sense for non-running domains.
|
||||
xeninfo.pop('domid', None)
|
||||
vm = XendDomainInfo(XendConfig(cfg = xeninfo))
|
||||
return vm
|
||||
|
||||