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

[Xen-changelog] Switch vcpu hotplugging to use xstransact.



# HG changeset patch
# User cl349@xxxxxxxxxxxxxxxxxxxx
# Node ID 26cf3cfd3bedcc958baaa3366cb804efd2b3e457
# Parent  f562c0f1d2226ece0593eaa9e373a54b116ae0d0
Switch vcpu hotplugging to use xstransact.
Signed-off-by: Christian Limpach <Christian.Limpach@xxxxxxxxxxxx>

diff -r f562c0f1d222 -r 26cf3cfd3bed tools/python/xen/xend/XendDomainInfo.py
--- a/tools/python/xen/xend/XendDomainInfo.py   Tue Sep 13 16:57:45 2005
+++ b/tools/python/xen/xend/XendDomainInfo.py   Tue Sep 13 17:31:13 2005
@@ -262,7 +262,6 @@
         self.restart_count = 0
         
         self.vcpus = 1
-        self.vcpusdb = {}
         self.bootloader = None
         self.device_model_pid = 0
 
@@ -657,15 +656,11 @@
         except:
             raise VmError('invalid vcpus value')
 
-    def exportVCPUSToDB(self, vcpus):
-        for v in range(0,vcpus):
-            path = "/cpu/%d"%(v)
-            if not self.vcpusdb.has_key(path):
-                self.vcpusdb[path] = self.db.addChild(path)
-            db = self.vcpusdb[path]
-            log.debug("writing key availability=online to path %s in 
store"%(path))
-            db['availability'] = "online"
-            db.saveDB(save=True)
+    def configure_vcpus(self, vcpus):
+        d = {}
+        for v in range(0, vcpus):
+            d["cpu/%d/availability" % v] = "online"
+        xstransact.Write(self.path, d)
 
     def init_image(self):
         """Create boot image handler for the domain.
@@ -685,7 +680,7 @@
             IntroduceDomain(self.id, self.store_mfn, self.store_channel.port1,
                             self.path)
         # get the configured value of vcpus and update store
-        self.exportVCPUSToDB(self.vcpus)
+        self.configure_vcpus(self.vcpus)
 
     def delete(self):
         """Delete the vm's db.
@@ -1051,20 +1046,14 @@
     def vcpu_hotplug(self, vcpu, state):
         """Disable or enable VCPU in domain.
         """
-        db = ""
-        try:
-            db = self.vcpusdb['/cpu/%d'%(vcpu)]
-        except:
-            log.error("Invalid VCPU")
+        if vcpu > self.vcpus:
+            log.error("Invalid VCPU %d" % vcpu)
             return
-
-        if self.store_channel:
-            if int(state) == 0:
-                db['availability'] = "offline"
-            else:
-                db['availability'] = "online"
-
-        db.saveDB(save=True)
+        if int(state) == 0:
+            availability = "offline"
+        else:
+            availability = "online"
+        xstransact.Write(self.path, "cpu/%d/availability" % vcpu, availability)
 
     def shutdown(self, reason):
         if not reason in shutdown_reasons.values():
@@ -1107,7 +1096,7 @@
                 else:
                     raise
             # get run-time value of vcpus and update store
-            self.exportVCPUSToDB(dom_get(self.id)['vcpus'])
+            self.configure_vcpus(dom_get(self.id)['vcpus'])
 
 
 def vm_field_ignore(_, _1, _2, _3):

_______________________________________________
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®.