diff options
author | Hugues Fafard <fafardh@posteo.de> | 2021-07-26 22:14:30 +0200 |
---|---|---|
committer | Cole Robinson <crobinso@redhat.com> | 2021-07-27 15:55:00 -0400 |
commit | 20d2376b18edc6132532b22157ea1e165a562f47 (patch) | |
tree | 7e6bf391f5b16508117687f0e128d0737be52978 | |
parent | 4017e761c22385f778ed508454eba50ccb18e556 (diff) | |
download | virt-manager-20d2376b18edc6132532b22157ea1e165a562f47.tar.gz |
cli: --shmem: added support for shared memory devices
This includes support for the following suboptions:
* name (<shmem name=X>)
* role (<shmem role=X>)
* model.type (<shmem><model type=X/>)
* size (<shmem><size>X)
* size.unit (<shmem><size unit=X/>)
* server.path (<shmem><server path=X/>)
* msi.vectors (<shmem><msi vectors=X/>)
* msi.ioeventfd (<shmem><msi ioeventfd=X/>)
-rw-r--r-- | man/virt-install.rst | 13 | ||||
-rw-r--r-- | man/virt-xml.rst | 1 | ||||
-rw-r--r-- | tests/data/cli/compare/virt-install-many-devices.xml | 10 | ||||
-rw-r--r-- | tests/data/cli/compare/virt-install-singleton-config-1.xml | 1 | ||||
-rw-r--r-- | tests/data/cli/compare/virt-install-singleton-config-2.xml | 8 | ||||
-rw-r--r-- | tests/test_cli.py | 5 | ||||
-rw-r--r-- | virtinst/cli.py | 31 | ||||
-rw-r--r-- | virtinst/devices/__init__.py | 5 | ||||
-rw-r--r-- | virtinst/devices/device.py | 1 | ||||
-rw-r--r-- | virtinst/devices/shmem.py | 36 | ||||
-rw-r--r-- | virtinst/guest.py | 3 |
11 files changed, 111 insertions, 3 deletions
diff --git a/man/virt-install.rst b/man/virt-install.rst index f75af635..18a80230 100644 --- a/man/virt-install.rst +++ b/man/virt-install.rst @@ -1886,6 +1886,19 @@ Complete details at https://libvirt.org/formatdomain.html#elementsPanic +``--shmem`` +^^^^^^^^^^^ + +**Syntax:** ``--shmem`` NAME[,OPTS] + +Attach a shared memory device to the guest. The name must not contain ``/`` and must +not be directory-specific to ``.`` or ``..`` + +Use --shmem=? to see a list of all available sub options. +Complete details at https://libvirt.org/formatdomain.html#shared-memory-device + + + ``--memdev`` ^^^^^^^^^^^^ diff --git a/man/virt-xml.rst b/man/virt-xml.rst index 7ff7ceca..0ad57d25 100644 --- a/man/virt-xml.rst +++ b/man/virt-xml.rst @@ -243,6 +243,7 @@ XML OPTIONS * ``--tpm`` * ``--rng`` * ``--panic`` +* ``--shmem`` * ``--memdev`` These options alter the XML for a single class of XML elements. More complete documentation is found in virt-install(1). diff --git a/tests/data/cli/compare/virt-install-many-devices.xml b/tests/data/cli/compare/virt-install-many-devices.xml index 871034c6..3cd14195 100644 --- a/tests/data/cli/compare/virt-install-many-devices.xml +++ b/tests/data/cli/compare/virt-install-many-devices.xml @@ -647,6 +647,16 @@ <panic model="isa"> <address type="isa" iobase="507"/> </panic> + <shmem name="my_shmem0" role="peer"> + <model type="ivshmem-plain"/> + <size unit="M">4</size> + </shmem> + <shmem name="shmem_server"> + <model type="ivshmem-doorbell"/> + <size unit="M">2</size> + <server path="/tmp/socket-shmemm"/> + <msi vectors="32" ioeventfd="on"/> + </shmem> <vsock model="virtio"> <cid address="17"/> </vsock> diff --git a/tests/data/cli/compare/virt-install-singleton-config-1.xml b/tests/data/cli/compare/virt-install-singleton-config-1.xml index 518a0099..49e0cd85 100644 --- a/tests/data/cli/compare/virt-install-singleton-config-1.xml +++ b/tests/data/cli/compare/virt-install-singleton-config-1.xml @@ -88,6 +88,7 @@ <rng model="virtio"> <backend model="random">/dev/random</backend> </rng> + <shmem name="shmem0"/> <vsock model="virtio"> <cid auto="yes"/> </vsock> diff --git a/tests/data/cli/compare/virt-install-singleton-config-2.xml b/tests/data/cli/compare/virt-install-singleton-config-2.xml index 19ac513e..095f97c5 100644 --- a/tests/data/cli/compare/virt-install-singleton-config-2.xml +++ b/tests/data/cli/compare/virt-install-singleton-config-2.xml @@ -214,6 +214,10 @@ <panic model="isa"> <address type="isa" iobase="0x506"/> </panic> + <shmem name="shmem0" role="master"> + <model type="ivshmem-plain"/> + <size unit="M">8</size> + </shmem> <iommu model="intel"> <driver aw_bits="48" intremap="off" caching_mode="on" eim="off" iotlb="off"/> </iommu> @@ -461,6 +465,10 @@ <panic model="isa"> <address type="isa" iobase="0x506"/> </panic> + <shmem name="shmem0" role="master"> + <model type="ivshmem-plain"/> + <size unit="M">8</size> + </shmem> <iommu model="intel"> <driver aw_bits="48" intremap="off" caching_mode="on" eim="off" iotlb="off"/> </iommu> diff --git a/tests/test_cli.py b/tests/test_cli.py index 39bcefb7..c6fea3d7 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -498,6 +498,7 @@ c.add_compare(""" --watchdog default --tpm /dev/tpm0 --rng /dev/random +--shmem shmem0 --vsock default """, "singleton-config-1") @@ -548,6 +549,7 @@ memnode0.cellid=1,memnode0.mode=strict,memnode0.nodeset=2 --tpm passthrough,model=tpm-crb,path=/dev/tpm0,backend.encryption.secret=11111111-2222-3333-4444-5555555555,backend.persistent_state=yes --rng egd,backend_host=127.0.0.1,backend_service=8000,backend_type=udp,backend_mode=bind,backend_connect_host=foo,backend_connect_service=708,rate.bytes=1234,rate.period=1000,model=virtio --panic iobase=0x506 +--shmem shmem0,role=master,model.type=ivshmem-plain,size=8,size.unit=M --iommu model=intel,driver.aw_bits=48,driver.caching_mode=on,driver.eim=off,driver.intremap=off,driver.iotlb=off """, "singleton-config-2") @@ -717,6 +719,9 @@ source.reservations.managed=no,source.reservations.source.type=unix,source.reser --panic iobase=507 +--shmem name=my_shmem0,role=peer,model.type=ivshmem-plain,size=4,size.unit=M +--shmem name=shmem_server,model.type=ivshmem-doorbell,size=2,size.unit=M,server.path=/tmp/socket-shmemm,msi.vectors=32,msi.ioeventfd=on + --vsock cid=17 --tpm emulator,model=tpm-crb,version=2.0 diff --git a/virtinst/cli.py b/virtinst/cli.py index 50309aec..7c436c55 100644 --- a/virtinst/cli.py +++ b/virtinst/cli.py @@ -796,6 +796,10 @@ def add_device_options(devg, sound_back_compat=False): devg.add_argument("--panic", action="append", help=_("Configure a guest panic device. Ex:\n" "--panic default")) + ParserShMem.register() + devg.add_argument("--shmem", action="append", + help=_("Configure a guest shared memory device. Ex:\n" + "--shmem name=shmem0")) ParserMemdev.register() devg.add_argument("--memdev", action="append", help=_("Configure a guest memory device. Ex:\n" @@ -4108,6 +4112,33 @@ class ParserPanic(VirtCLIParser): ################### +# --shmem parsing # +################### + +class ParserShMem(VirtCLIParser): + cli_arg_name = "shmem" + guest_propname = "devices.shmem" + remove_first = "name" + + @classmethod + def _init_class(cls, **kwargs): + VirtCLIParser._init_class(**kwargs) + _add_common_device_args(cls) + + cls.add_arg("name", "name") + cls.add_arg("role", "role") + + cls.add_arg("model.type", "type") + + cls.add_arg("size", "size") + cls.add_arg("size.unit", "size_unit") + + cls.add_arg("server.path", "server_path") + cls.add_arg("msi.vectors", "msi_vectors") + cls.add_arg("msi.ioeventfd", "msi_ioeventfd") + + +################### # --vsock parsing # ################### diff --git a/virtinst/devices/__init__.py b/virtinst/devices/__init__.py index eae4b29b..26267ce4 100644 --- a/virtinst/devices/__init__.py +++ b/virtinst/devices/__init__.py @@ -17,10 +17,11 @@ from .iommu import DeviceIommu from .memballoon import DeviceMemballoon from .memory import DeviceMemory from .panic import DevicePanic -from .smartcard import DeviceSmartcard -from .sound import DeviceSound from .redirdev import DeviceRedirdev from .rng import DeviceRng +from .shmem import DeviceShMem +from .smartcard import DeviceSmartcard +from .sound import DeviceSound from .tpm import DeviceTpm from .video import DeviceVideo from .vsock import DeviceVsock diff --git a/virtinst/devices/device.py b/virtinst/devices/device.py index 132107ef..89d306a4 100644 --- a/virtinst/devices/device.py +++ b/virtinst/devices/device.py @@ -148,6 +148,7 @@ class Device(XMLBuilder): "tpm": ["type", "xmlindex"], "rng": ["backend_model", "xmlindex"], "panic": ["model", "xmlindex"], + "shmem": ["name", "xmlindex"], "vsock": ["model", "xmlindex"], "memballoon": ["model", "xmlindex"], "iommu": ["model", "xmlindex"], diff --git a/virtinst/devices/shmem.py b/virtinst/devices/shmem.py new file mode 100644 index 00000000..bd0b6c6a --- /dev/null +++ b/virtinst/devices/shmem.py @@ -0,0 +1,36 @@ +# +# This work is licensed under the GNU GPLv2 or later. +# See the COPYING file in the top-level directory. + +from .device import Device +from ..xmlbuilder import XMLProperty + + +class DeviceShMem(Device): + XML_NAME = "shmem" + _XML_PROP_ORDER = [ + "name", "role", + "type", "size", "size_unit", + "server_path", "msi_vectors", "msi_ioeventfd", + ] + + MODEL_IVSHMEM = "ivshmem" + MODEL_IVSHMEM_PLAIN = "ivshmem-plain" + MODEL_IVSHMEM_DOORBELL = "ivshmem-doorbell" + MODELS = [MODEL_IVSHMEM, MODEL_IVSHMEM_PLAIN, MODEL_IVSHMEM_DOORBELL] + + ROLE_MASTER = "master" + ROLE_PEER = "peer" + ROLES = [ROLE_MASTER, ROLE_PEER] + + name = XMLProperty("./@name") + role = XMLProperty("./@role") + + type = XMLProperty("./model/@type") + + size = XMLProperty("./size", is_int=True) + size_unit = XMLProperty("./size/@unit") + + server_path = XMLProperty("./server/@path") + msi_vectors = XMLProperty("./msi/@vectors", is_int=True) + msi_ioeventfd = XMLProperty("./msi/@ioeventfd", is_onoff=True) diff --git a/virtinst/guest.py b/virtinst/guest.py index 8b75cd01..560e45e2 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', 'iommu'] + 'shmem', 'memory', 'vsock', 'iommu'] disk = XMLChildProperty(DeviceDisk) @@ -50,6 +50,7 @@ class _DomainDevices(XMLBuilder): memballoon = XMLChildProperty(DeviceMemballoon) rng = XMLChildProperty(DeviceRng) panic = XMLChildProperty(DevicePanic) + shmem = XMLChildProperty(DeviceShMem) memory = XMLChildProperty(DeviceMemory) vsock = XMLChildProperty(DeviceVsock) iommu = XMLChildProperty(DeviceIommu) |