[virt-tools-list] [PATCH v2 1/3] Add support for cpu mode attribute and cpu host-passthrough
Hu Tao
hutao at cn.fujitsu.com
Thu Apr 11 05:45:45 UTC 2013
From: Ken ICHIKAWA <ichikawa.ken at jp.fujitsu.com>
With this patch, users can use cpu host-passthrough like this:
virt-install --cpu host-passthrough ...
Signed-off-by: Ken ICHIKAWA <ichikawa.ken at jp.fujitsu.com>
Signed-off-by: Hu Tao <hutao at cn.fujitsu.com>
---
Cole,
v2 is rebased on top of latest virt-manager. Please review.
Regards,
Hu Tao
virtinst/CPU.py | 23 ++++++++++++++++++++++-
1 file changed, 22 insertions(+), 1 deletion(-)
diff --git a/virtinst/CPU.py b/virtinst/CPU.py
index 6ada5bc..c1c47e8 100644
--- a/virtinst/CPU.py
+++ b/virtinst/CPU.py
@@ -81,6 +81,7 @@ class CPU(XMLBuilderDomain.XMLBuilderDomain):
self._model = None
self._match = None
self._vendor = None
+ self._mode = None
self._features = []
self._sockets = None
@@ -130,6 +131,8 @@ class CPU(XMLBuilderDomain.XMLBuilderDomain):
def _get_model(self):
return self._model
def _set_model(self, val):
+ if val:
+ self.mode = "custom"
if val and not self.match:
self.match = "exact"
self._model = val
@@ -150,6 +153,13 @@ class CPU(XMLBuilderDomain.XMLBuilderDomain):
vendor = _xml_property(_get_vendor, _set_vendor,
xpath="./cpu/vendor")
+ def _get_mode(self):
+ return self._mode
+ def _set_mode(self, val):
+ self._mode = val
+ mode = _xml_property(_get_mode, _set_mode,
+ xpath="./cpu/@mode")
+
# Topology properties
def _get_sockets(self):
return self._sockets
@@ -184,6 +194,7 @@ class CPU(XMLBuilderDomain.XMLBuilderDomain):
if not cpu.model:
raise ValueError(_("No host CPU reported in capabilities"))
+ self.mode = "custom"
self.match = "exact"
self.model = cpu.model
self.vendor = cpu.vendor
@@ -261,16 +272,26 @@ class CPU(XMLBuilderDomain.XMLBuilderDomain):
def _get_xml_config(self):
top_xml = self._get_topology_xml()
feature_xml = self._get_feature_xml()
+ mode_xml = ""
match_xml = ""
if self.match:
match_xml = " match='%s'" % self.match
xml = ""
+ if self.model == "host-passthrough":
+ self.mode = "host-passthrough"
+ mode_xml = " mode='%s'" % self.mode
+ xml += " <cpu%s/>" % mode_xml
+ return xml
+ else:
+ self.mode = "custom"
+ mode_xml = " mode='%s'" % self.mode
+
if not (self.model or top_xml or feature_xml):
return ""
# Simple topology XML mode
- xml += " <cpu%s>\n" % match_xml
+ xml += " <cpu%s%s>\n" % (mode_xml, match_xml)
if self.model:
xml += " <model>%s</model>\n" % self.model
if self.vendor:
--
1.8.1.4
More information about the virt-tools-list
mailing list