summaryrefslogtreecommitdiffstats
path: root/nova/virt
diff options
context:
space:
mode:
authorDaniel P. Berrange <berrange@redhat.com>2012-03-07 12:49:38 -0500
committerDaniel P. Berrange <berrange@redhat.com>2012-03-23 19:23:13 +0000
commit81ac4e729c0ca9e8fdb8064db30ae05eb8ce74a7 (patch)
treeb07ae89e1d2d1cabd2d0e55852759e19b17b02fa /nova/virt
parentc0f678778afefc71649253e685e8f5d6af96b3a9 (diff)
Introduce a class for storing libvirt CPU configuration
Extend the libvirt config APIs to include a new class LibvirtConfigCPU for storing host/guest CPU configuration data blueprint libvirt-xml-config-apis Change-Id: Ib508637c1e0ca69860d461b0a480347c59165e6b Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Diffstat (limited to 'nova/virt')
-rw-r--r--nova/virt/libvirt/config.py40
1 files changed, 40 insertions, 0 deletions
diff --git a/nova/virt/libvirt/config.py b/nova/virt/libvirt/config.py
index 44790a068..e4f99a7ba 100644
--- a/nova/virt/libvirt/config.py
+++ b/nova/virt/libvirt/config.py
@@ -356,3 +356,43 @@ class LibvirtConfigGuest(LibvirtConfigObject):
def add_device(self, dev):
self.devices.append(dev)
+
+
+class LibvirtConfigCPU(LibvirtConfigObject):
+
+ def __init__(self, **kwargs):
+ super(LibvirtConfigCPU, self).__init__(root_name="cpu",
+ **kwargs)
+
+ self.arch = None
+ self.model = None
+ self.vendor = None
+ self.sockets = None
+ self.cores = None
+ self.threads = None
+ self.features = []
+
+ def add_feature(self, name):
+ self.features.append(name)
+
+ def format_dom(self):
+ cpu = super(LibvirtConfigCPU, self).format_dom()
+ if self.arch:
+ cpu.append(self._text_node("arch", self.arch))
+ if self.model:
+ cpu.append(self._text_node("model", self.model))
+ if self.vendor:
+ cpu.append(self._text_node("vendor", self.vendor))
+ if (self.sockets is not None and
+ self.cores is not None and
+ self.threads is not None):
+ cpu.append(etree.Element("topology",
+ sockets=str(self.sockets),
+ cores=str(self.cores),
+ threads=str(self.threads)))
+
+ for f in self.features:
+ cpu.append(etree.Element("feature",
+ name=f))
+
+ return cpu