From 3ebbeef80ee089cfa8b7f0861828d4e2bf100946 Mon Sep 17 00:00:00 2001 From: Pavel Hrdina Date: Thu, 4 May 2017 13:08:14 +0200 Subject: [PATCH] virtinst: introduce support for element This element controls hot(un)plugable memory for the guest in addition to the initial memory configured by element. One has to configure and guest numa nodes using element to enable hot(un)plug of memory modules. Signed-off-by: Pavel Hrdina --- man/virt-install.pod | 7 ++- .../compare/virt-install-memory-hotplug.xml | 43 +++++++++++++++++++ tests/clitest.py | 7 +++ virtinst/cli.py | 7 ++- virtinst/guest.py | 8 ++-- 5 files changed, 66 insertions(+), 6 deletions(-) create mode 100644 tests/cli-test-xml/compare/virt-install-memory-hotplug.xml diff --git a/man/virt-install.pod b/man/virt-install.pod index e93a79008..4ed9684ee 100644 --- a/man/virt-install.pod +++ b/man/virt-install.pod @@ -93,8 +93,11 @@ running C. =item B<--memory> OPTIONS -Memory to allocate for the guest, in MiB. Sub options are available, -like 'maxmemory' and 'hugepages'. This deprecates the -r/--ram option. +Memory to allocate for the guest, in MiB. This deprecates the -r/--ram option. +Sub options are available, like 'maxmemory', 'hugepages', 'hotplugmemorymax' +and 'hotplugmemoryslots'. The memory parameter is mapped to element, +the 'maxmemory' sub-option is mapped to element and 'hotplugmemorymax' +and 'hotplugmemoryslots' are mapped to element. Use --memory=? to see a list of all available sub options. Complete details at L diff --git a/tests/cli-test-xml/compare/virt-install-memory-hotplug.xml b/tests/cli-test-xml/compare/virt-install-memory-hotplug.xml new file mode 100644 index 000000000..a4c7356d8 --- /dev/null +++ b/tests/cli-test-xml/compare/virt-install-memory-hotplug.xml @@ -0,0 +1,43 @@ + + foobar + 00000000-1111-2222-3333-444444444444 + 2097152 + 1048576 + 1048576 + 1 + + hvm + + + + + + + + + + + + + + + + + /usr/bin/test-hv + + + + + + + + + + + + + + + + + diff --git a/tests/clitest.py b/tests/clitest.py index 5b3dca213..7e76893ab 100644 --- a/tests/clitest.py +++ b/tests/clitest.py @@ -552,6 +552,13 @@ c.add_compare(""" \ """, "spice-gl", compare_check=support.SUPPORT_CONN_VMPORT) +###################################### +# Memory hot(un)plug install options # +###################################### + +c = vinst.add_category("memory-hotplug", "--nographics --noautoconsole --import --disk none") +c.add_compare("--memory 1024,hotplugmemorymax=2048,hotplugmemoryslots=2 --cpu cell0.cpus=0,cell0.memory=1048576", "memory-hotplug") + #################################################### # CPU/RAM/numa and other singleton VM config tests # diff --git a/virtinst/cli.py b/virtinst/cli.py index a87ac038f..7d100bdb0 100644 --- a/virtinst/cli.py +++ b/virtinst/cli.py @@ -595,7 +595,9 @@ def add_memory_option(grp, backcompat=False): grp.add_argument("--memory", help=_("Configure guest memory allocation. Ex:\n" "--memory 1024 (in MiB)\n" - "--memory 512,maxmemory=1024")) + "--memory 512,maxmemory=1024\n" + "--memory 512,maxmemory=1024,hotplugmemorymax=2048," + "hotplugmemoryslots=2")) if backcompat: grp.add_argument("-r", "--ram", type=int, dest="oldmemory", help=argparse.SUPPRESS) @@ -1351,6 +1353,9 @@ _register_virt_parser(ParserMemory) ParserMemory.add_arg("memory", "memory", cb=ParserMemory.set_memory_cb) ParserMemory.add_arg("maxmemory", "maxmemory", cb=ParserMemory.set_memory_cb) ParserMemory.add_arg("memoryBacking.hugepages", "hugepages", is_onoff=True) +ParserMemory.add_arg("hotplugmemorymax", "hotplugmemorymax", + cb=ParserMemory.set_memory_cb) +ParserMemory.add_arg("hotplugmemoryslots", "hotplugmemoryslots") ##################### diff --git a/virtinst/guest.py b/virtinst/guest.py index c7bb5ec1b..bf93432d8 100644 --- a/virtinst/guest.py +++ b/virtinst/guest.py @@ -105,9 +105,9 @@ class Guest(XMLBuilder): _XML_ROOT_NAME = "domain" _XML_PROP_ORDER = ["type", "name", "uuid", "title", "description", - "maxmemory", "memory", "blkiotune", "memtune", "memoryBacking", - "vcpus", "curvcpus", "vcpu_placement", "cpuset", - "numatune", "resource", "sysinfo", "bootloader", "os", "idmap", + "hotplugmemorymax", "hotplugmemoryslots", "maxmemory", "memory", "blkiotune", + "memtune", "memoryBacking", "vcpus", "curvcpus", "vcpu_placement", + "cpuset", "numatune", "resource", "sysinfo", "bootloader", "os", "idmap", "features", "cpu", "clock", "on_poweroff", "on_reboot", "on_crash", "pm", "emulator", "_devices", "seclabels"] @@ -163,6 +163,8 @@ class Guest(XMLBuilder): default_cb=lambda s: 1, set_converter=_set_memory) maxmemory = XMLProperty("./memory", is_int=True) + hotplugmemorymax = XMLProperty("./maxMemory", is_int=True) + hotplugmemoryslots = XMLProperty("./maxMemory/@slots", is_int=True) def _set_vcpus(self, val): if val is None: