From 167cc3b1989497377affee9af27cfd49bd48310e Mon Sep 17 00:00:00 2001 From: "Dustin C. Hatch" Date: Wed, 22 Jul 2015 23:09:42 -0500 Subject: [PATCH] vmdesc: Add minimal support for CPU model selection The `cpu` property of `VirtualMachine` objects indicates the value of the `mode` attribute of the `cpu` element in the domain XML configuration. The possible values are * host-model (default) * host-passthrough * custom --- src/mkvm/vmdesc.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/mkvm/vmdesc.py b/src/mkvm/vmdesc.py index 3f6e2d9..4fe69f5 100644 --- a/src/mkvm/vmdesc.py +++ b/src/mkvm/vmdesc.py @@ -74,6 +74,7 @@ class VirtualMachine(object): 'fqdn', 'ram', 'vcpus', + 'cpu', 'net_ifaces', 'console', 'graphics', @@ -101,6 +102,7 @@ class VirtualMachine(object): self.fqdn = None self.ram = 256 * 2 ** 20 self.vcpus = 1 + self.cpu = 'host-model' self.net_ifaces = [] self.console = 'virtio' self.graphics = 'spice' @@ -279,6 +281,9 @@ class VirtualMachine(object): elm_vcpu = etree.SubElement(root, 'vcpu', placement='static') elm_vcpu.text = str(self.vcpus) + if self.cpu: + elm_cpu = etree.SubElement(root, 'cpu', mode=self.cpu) + elm_os = etree.SubElement(root, 'os') elm_type = etree.SubElement(elm_os, 'type', arch='x86_64') elm_type.text = 'hvm'