mirror of
https://github.com/xen-project/xen.git
synced 2026-10-29 02:30:03 +01:00
Switch vcpu hotplugging to use xstransact.
Signed-off-by: Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
This commit is contained in:
1 parent
d0b30dab40
commit
8fabb88101
1 file changed
+14
-25
@@ -262,7 +262,6 @@ class XendDomainInfo:
|
||||
self.restart_count = 0
|
||||
|
||||
self.vcpus = 1
|
||||
self.vcpusdb = {}
|
||||
self.bootloader = None
|
||||
self.device_model_pid = 0
|
||||
|
||||
@@ -657,15 +656,11 @@ class XendDomainInfo:
|
||||
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 @@ class XendDomainInfo:
|
||||
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 @@ class XendDomainInfo:
|
||||
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 @@ class XendDomainInfo:
|
||||
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):
|
||||
|
||||