summaryrefslogtreecommitdiff
path: root/virtinst
diff options
context:
space:
mode:
authorMenno Lageman <menno.lageman@oracle.com>2020-07-07 09:55:53 +0200
committerCole Robinson <crobinso@redhat.com>2020-07-12 09:15:52 -0400
commit25419db9caf0e45578e98d85af096fab52a3c7cc (patch)
treef73293d69804213208590c6d9ed8aa09be4d55bb /virtinst
parent4eb7834c6e20360af02fb52da594c338112b542c (diff)
downloadvirt-manager-25419db9caf0e45578e98d85af096fab52a3c7cc.tar.gz
virtinst: add support for configuring the IOMMU
Add a --iommu option to configure IOMMU parameters as described in https://libvirt.org/formatdomain.html#elementsIommu E.g. 'virt-install --iommu model=intel,driver.aw_bits=48,driver.iotlb=on ...' will generate the following domain XML: <devices> <iommu model="intel"> <driver aw_bits="48" iotlb="on"/> </iommu> </devices> Reviewed-by: Cole Robinson <crobinso@redhat.com> Signed-off-by: Menno Lageman <menno.lageman@oracle.com>
Diffstat (limited to 'virtinst')
-rw-r--r--virtinst/cli.py21
-rw-r--r--virtinst/devices/__init__.py1
-rw-r--r--virtinst/devices/device.py1
-rw-r--r--virtinst/devices/iommu.py29
-rw-r--r--virtinst/guest.py3
5 files changed, 54 insertions, 1 deletions
diff --git a/virtinst/cli.py b/virtinst/cli.py
index 14f5f56f..38dfbcc7 100644
--- a/virtinst/cli.py
+++ b/virtinst/cli.py
@@ -811,6 +811,10 @@ def add_device_options(devg, sound_back_compat=False):
help=_("Configure guest vsock sockets. Ex:\n"
"--vsock cid.auto=yes\n"
"--vsock cid.address=7"))
+ ParserIommu.register()
+ devg.add_argument("--iommu", action="append",
+ help=_("Configure an IOMMU device. Ex:\n"
+ "--iommu model=intel,driver.aw_bits=48"))
def add_guest_xml_options(geng):
@@ -3629,6 +3633,23 @@ class ParserInput(VirtCLIParser):
cls.add_arg("bus", "bus", ignore_default=True)
+class ParserIommu(VirtCLIParser):
+ cli_arg_name = "iommu"
+ guest_propname = "devices.iommu"
+ remove_first = "model"
+
+ @classmethod
+ def _init_class(cls, **kwargs):
+ VirtCLIParser._init_class(**kwargs)
+
+ cls.add_arg("model", "model")
+ cls.add_arg("driver.aw_bits", "aw_bits")
+ cls.add_arg("driver.intremap", "intremap", is_onoff=True)
+ cls.add_arg("driver.caching_mode", "caching_mode", is_onoff=True)
+ cls.add_arg("driver.eim", "eim", is_onoff=True)
+ cls.add_arg("driver.iotlb", "iotlb", is_onoff=True)
+
+
#######################
# --smartcard parsing #
#######################
diff --git a/virtinst/devices/__init__.py b/virtinst/devices/__init__.py
index 6120f5d0..eae4b29b 100644
--- a/virtinst/devices/__init__.py
+++ b/virtinst/devices/__init__.py
@@ -13,6 +13,7 @@ from .graphics import DeviceGraphics
from .hostdev import DeviceHostdev
from .input import DeviceInput
from .interface import DeviceInterface
+from .iommu import DeviceIommu
from .memballoon import DeviceMemballoon
from .memory import DeviceMemory
from .panic import DevicePanic
diff --git a/virtinst/devices/device.py b/virtinst/devices/device.py
index c976870d..bb91d33b 100644
--- a/virtinst/devices/device.py
+++ b/virtinst/devices/device.py
@@ -149,6 +149,7 @@ class Device(XMLBuilder):
"panic": ["model", "xmlindex"],
"vsock": ["model", "xmlindex"],
"memballoon": ["model", "xmlindex"],
+ "iommu": ["model", "xmlindex"],
}
if id(self) == id(newdev):
diff --git a/virtinst/devices/iommu.py b/virtinst/devices/iommu.py
new file mode 100644
index 00000000..c7639c6a
--- /dev/null
+++ b/virtinst/devices/iommu.py
@@ -0,0 +1,29 @@
+#
+# Copyright 2020 Oracle Oracle and/or its affiliates. All rights reserved.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; If not, see <http://www.gnu.org/licenses/>.
+
+from .device import Device
+from ..xmlbuilder import XMLProperty
+
+
+class DeviceIommu(Device):
+ XML_NAME = "iommu"
+
+ model = XMLProperty("./@model")
+ aw_bits = XMLProperty("./driver/@aw_bits", is_int=True)
+ intremap = XMLProperty("./driver/@intremap", is_onoff=True)
+ caching_mode = XMLProperty("./driver/@caching_mode", is_onoff=True)
+ eim = XMLProperty("./driver/@eim", is_onoff=True)
+ iotlb = XMLProperty("./driver/@iotlb", is_onoff=True)
diff --git a/virtinst/guest.py b/virtinst/guest.py
index 76dab8b4..6fdb67a1 100644
--- a/virtinst/guest.py
+++ b/virtinst/guest.py
@@ -27,7 +27,7 @@ class _DomainDevices(XMLBuilder):
'smartcard', 'serial', 'parallel', 'console', 'channel',
'input', 'tpm', 'graphics', 'sound', 'video', 'hostdev',
'redirdev', 'watchdog', 'memballoon', 'rng', 'panic',
- 'memory', 'vsock']
+ 'memory', 'vsock', 'iommu']
disk = XMLChildProperty(DeviceDisk)
@@ -52,6 +52,7 @@ class _DomainDevices(XMLBuilder):
panic = XMLChildProperty(DevicePanic)
memory = XMLChildProperty(DeviceMemory)
vsock = XMLChildProperty(DeviceVsock)
+ iommu = XMLChildProperty(DeviceIommu)
def get_all(self):
retlist = []