There are two domain XML knobs specific to NVDIMMs that virt-install doesn't allow to set: <pmem/> and <alignsize/>. Implement them. Closes: https://github.com/virt-manager/virt-manager/issues/267 Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx> --- v2 of: https://listman.redhat.com/archives/virt-tools-list/2021-June/msg00023.html diff to v1: - Added discard for DIMMs - Added target.readonly for NVDIMMs tests/data/cli/compare/virt-install-singleton-config-3.xml | 5 ++++- tests/test_cli.py | 4 ++-- virtinst/cli.py | 5 +++++ virtinst/devices/memory.py | 4 ++++ 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/tests/data/cli/compare/virt-install-singleton-config-3.xml b/tests/data/cli/compare/virt-install-singleton-config-3.xml index 41a9a347..0cfcb9d0 100644 --- a/tests/data/cli/compare/virt-install-singleton-config-3.xml +++ b/tests/data/cli/compare/virt-install-singleton-config-3.xml @@ -130,7 +130,7 @@ <panic model="isa"> <address type="isa" iobase="0x500" irq="5"/> </panic> - <memory model="dimm" access="private"> + <memory model="dimm" access="private" discard="yes"> <source> <pagesize>4</pagesize> <nodemask>1-2</nodemask> @@ -145,6 +145,8 @@ <address type="dimm" slot="1" base="0x100000000"/> <source> <path>/path/to/nvdimm</path> + <pmem/> + <alignsize>2097152</alignsize> </source> <target> <size>524288</size> @@ -152,6 +154,7 @@ <label> <size>131072</size> </label> + <readonly/> </target> </memory> <vsock model="virtio"> diff --git a/tests/test_cli.py b/tests/test_cli.py index b59eb4a1..2a124569 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -565,8 +565,8 @@ c.add_compare(""" --rng type=egd,backend.type=nmdm,backend.source.master=/dev/foo1,backend.source.slave=/dev/foo2 --panic default,,address.type=isa,address.iobase=0x500,address.irq=5 --cpu topology.sockets=1,topology.cores=3,topology.threads=2,cell0.cpus=0,cell0.memory=1048576 - --memdev dimm,access=private,target.size=512,target.node=0,source.pagesize=4,source.nodemask=1-2 - --memdev nvdimm,source.path=/path/to/nvdimm,target.size=512,target.node=0,target.label_size=128,alias.name=mymemdev3,address.type=dimm,address.base=0x100000000,address.slot=1 +--memdev dimm,access=private,target.size=512,target.node=0,source.pagesize=4,source.nodemask=1-2,discard=on +--memdev nvdimm,source.path=/path/to/nvdimm,target.size=512,target.node=0,target.label_size=128,alias.name=mymemdev3,address.type=dimm,address.base=0x100000000,address.slot=1,source.pmem=on,source.alignsize=2048,target.readonly=on --vsock auto_cid=on --memballoon default diff --git a/virtinst/cli.py b/virtinst/cli.py index b0f679e6..29db54c0 100644 --- a/virtinst/cli.py +++ b/virtinst/cli.py @@ -4030,13 +4030,18 @@ class ParserMemdev(VirtCLIParser): cls.add_arg("model", "model") cls.add_arg("access", "access") + cls.add_arg("discard", "discard", is_onoff=True) cls.add_arg("target.size", "target.size", cb=cls.set_target_size) cls.add_arg("target.node", "target.node") cls.add_arg("target.label_size", "target.label_size", cb=cls.set_target_size) + cls.add_arg("target.readonly", "target.readonly", is_onoff=True) cls.add_arg("source.pagesize", "source.pagesize") cls.add_arg("source.path", "source.path") cls.add_arg("source.nodemask", "source.nodemask", can_comma=True) + cls.add_arg("source.pmem", "source.pmem", is_onoff=True) + cls.add_arg("source.alignsize", "source.alignsize", + cb=cls.set_target_size) ######################## diff --git a/virtinst/devices/memory.py b/virtinst/devices/memory.py index 3c9a6a1a..ad95fcd7 100644 --- a/virtinst/devices/memory.py +++ b/virtinst/devices/memory.py @@ -15,6 +15,7 @@ class _DeviceMemoryTarget(XMLBuilder): size = XMLProperty("./size", is_int=True) node = XMLProperty("./node", is_int=True) label_size = XMLProperty("./label/size", is_int=True) + readonly = XMLProperty("./readonly", is_bool=True) class _DeviceMemorySource(XMLBuilder): @@ -23,6 +24,8 @@ class _DeviceMemorySource(XMLBuilder): pagesize = XMLProperty("./pagesize", is_int=True) nodemask = XMLProperty("./nodemask") path = XMLProperty("./path") + alignsize = XMLProperty("./alignsize", is_int=True) + pmem = XMLProperty("./pmem", is_bool=True) class DeviceMemory(Device): @@ -38,6 +41,7 @@ class DeviceMemory(Device): model = XMLProperty("./@model") access = XMLProperty("./@access") + discard = XMLProperty("./@discard", is_yesno=True) source = XMLChildProperty(_DeviceMemorySource, is_single=True) target = XMLChildProperty(_DeviceMemoryTarget, is_single=True) -- 2.31.1