[virt-tools-list] [virt-manager] [PATCH 5/7] cli: Add --memdev target.address_base for virtio-mem and virtio-pmem

Lin Ma lma at suse.de
Tue Jul 11 00:26:50 UTC 2023


Libvirt(since 9.4.0) allows to control this attribute for virtio-{mem,pmem}.
Now add it into virt-install.

Example:
virt-install \
--name test \
--os-variant opensusetumbleweed \
--cdrom /isos/openSUSE-Tumbleweed-DVD-x86_64-Current.iso \
--disk /vms/tw/disk0.qcow2 \
--vcpu 2 \
--cpu cell0.cpus=0,cell0.memory=4194304,\
cell1.cpus=1,cell1.memory=4194304 \
--memory maxMemory=65536,maxMemory.slots=8 \
--memdev model=virtio-mem,\
target.node=0,\
target.block=2048,\
target.size=8192,\
target.requested=2097152,\
target.address_base=0x280000000 \
--memdev model=virtio-pmem,\
source.path=/tmp/virtio_pmem,\
target.size=4096,\
target.address_base=0x480000000

It results in the following domain XML snippet:
    <memory model='virtio-mem'>
      <target>
        <size unit='KiB'>8388608</size>
        <node>0</node>
        <block unit='KiB'>2048</block>
        <requested unit='KiB'>2097152</requested>
        <current unit='KiB'>0</current>
        <address base='0x280000000'/>
      </target>
      <alias name='virtiomem0'/>
      <address type='pci' domain='0x0000' bus='0x07' slot='0x00' function='0x0'/>
    </memory>
    <memory model='virtio-pmem' access='shared'>
      <source>
        <path>/tmp/virtio_pmem</path>
      </source>
      <target>
        <size unit='KiB'>2097152</size>
        <address base='0x480000000'/>
      </target>
      <alias name='virtiopmem0'/>
      <address type='pci' domain='0x0000' bus='0x08' slot='0x00' function='0x0'/>
    </memory>

Signed-off-by: Lin Ma <lma at suse.de>
---
 .../compare/virt-install-memory-hotplug.xml   | 40 ++++++++++++++++++-
 tests/test_cli.py                             |  8 +++-
 virtinst/cli.py                               |  1 +
 virtinst/devices/memory.py                    |  1 +
 4 files changed, 47 insertions(+), 3 deletions(-)

diff --git a/tests/data/cli/compare/virt-install-memory-hotplug.xml b/tests/data/cli/compare/virt-install-memory-hotplug.xml
index 585e3f7c..31e06c7c 100644
--- a/tests/data/cli/compare/virt-install-memory-hotplug.xml
+++ b/tests/data/cli/compare/virt-install-memory-hotplug.xml
@@ -6,7 +6,7 @@
       <libosinfo:os id="http://fedoraproject.org/fedora/unknown"/>
     </libosinfo:libosinfo>
   </metadata>
-  <maxMemory slots="3">2097152</maxMemory>
+  <maxMemory slots="3">4194304</maxMemory>
   <vcpu>2</vcpu>
   <os>
     <type arch="x86_64" machine="q35">hvm</type>
@@ -122,6 +122,24 @@
         <readonly/>
       </target>
     </memory>
+    <memory model="virtio-mem">
+      <target>
+        <size>524288</size>
+        <node>0</node>
+        <block>2048</block>
+        <requested>524288</requested>
+        <address base="0x180000000"/>
+      </target>
+    </memory>
+    <memory model="virtio-pmem">
+      <source>
+        <path>/tmp/virtio_pmem</path>
+      </source>
+      <target>
+        <size>524288</size>
+        <address base="0x1a0000000"/>
+      </target>
+    </memory>
   </devices>
   <on_reboot>destroy</on_reboot>
 </domain>
@@ -133,7 +151,7 @@
       <libosinfo:os id="http://fedoraproject.org/fedora/unknown"/>
     </libosinfo:libosinfo>
   </metadata>
-  <maxMemory slots="3">2097152</maxMemory>
+  <maxMemory slots="3">4194304</maxMemory>
   <vcpu>2</vcpu>
   <os>
     <type arch="x86_64" machine="q35">hvm</type>
@@ -248,5 +266,23 @@
         <readonly/>
       </target>
     </memory>
+    <memory model="virtio-mem">
+      <target>
+        <size>524288</size>
+        <node>0</node>
+        <block>2048</block>
+        <requested>524288</requested>
+        <address base="0x180000000"/>
+      </target>
+    </memory>
+    <memory model="virtio-pmem">
+      <source>
+        <path>/tmp/virtio_pmem</path>
+      </source>
+      <target>
+        <size>524288</size>
+        <address base="0x1a0000000"/>
+      </target>
+    </memory>
   </devices>
 </domain>
diff --git a/tests/test_cli.py b/tests/test_cli.py
index 5de9a60b..7fee4d0e 100644
--- a/tests/test_cli.py
+++ b/tests/test_cli.py
@@ -873,7 +873,7 @@ c.add_compare(""
 
 # --memdev setup has a lot of interconnected validation, it's easier to keep this separate
 c.add_compare("--pxe "
-"--memory hotplugmemorymax=2048,hotplugmemoryslots=3 "
+"--memory hotplugmemorymax=4096,hotplugmemoryslots=3 "
 "--cpu cell0.cpus=0,cell0.memory=1048576 "
 
 "--memdev dimm,access=private,target_size=256,target_node=0,"
@@ -887,6 +887,12 @@ c.add_compare("--pxe "
 "address.type=dimm,address.base=0x100000000,address.slot=1,"
 "source.pmem=on,source.alignsize=2048,target.readonly=on "
 
+"--memdev virtio-mem,target_node=0,target.block=2048,"
+"target_size=512,target.requested=524288,target.address_base=0x180000000 "
+
+"--memdev virtio-pmem,source.path=/tmp/virtio_pmem,"
+"target_size=512,target.address_base=0x1a0000000 "
+
 "", "memory-hotplug", precompare_check="5.3.0")
 
 
diff --git a/virtinst/cli.py b/virtinst/cli.py
index a998746d..694b9255 100644
--- a/virtinst/cli.py
+++ b/virtinst/cli.py
@@ -4321,6 +4321,7 @@ class ParserMemdev(VirtCLIParser):
         cls.add_arg("target.current", "target.current")
         cls.add_arg("target.requested", "target.requested")
         cls.add_arg("target.readonly", "target.readonly", is_onoff=True)
+        cls.add_arg("target.address_base", "target.address_base")
         cls.add_arg("source.pagesize", "source.pagesize")
         cls.add_arg("source.path", "source.path")
         cls.add_arg("source.nodemask", "source.nodemask", can_comma=True)
diff --git a/virtinst/devices/memory.py b/virtinst/devices/memory.py
index 812b4dbc..edc274e0 100644
--- a/virtinst/devices/memory.py
+++ b/virtinst/devices/memory.py
@@ -19,6 +19,7 @@ class _DeviceMemoryTarget(XMLBuilder):
     block = XMLProperty("./block", is_int=True)
     requested = XMLProperty("./requested", is_int=True)
     current = XMLProperty("./current", is_int=True)
+    address_base = XMLProperty("./address/@base")
 
 
 class _DeviceMemorySource(XMLBuilder):
-- 
2.41.0



More information about the virt-tools-list mailing list