RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 2216212 - [RHEL9] Libvirt still requires a (DIMM) slot for virtio-mem devices
Summary: [RHEL9] Libvirt still requires a (DIMM) slot for virtio-mem devices
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 9
Classification: Red Hat
Component: libvirt
Version: 9.2
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: Peter Krempa
QA Contact: liang cong
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2023-06-20 14:08 UTC by David Hildenbrand
Modified: 2023-11-07 09:42 UTC (History)
6 users (show)

Fixed In Version: libvirt-9.5.0-0rc1.1.el9
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2023-11-07 08:31:41 UTC
Type: Bug
Target Upstream Version: 9.5.0
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker RHELPLAN-160293 0 None None None 2023-06-20 14:12:51 UTC
Red Hat Product Errata RHSA-2023:6409 0 None None None 2023-11-07 08:32:01 UTC

Description David Hildenbrand 2023-06-20 14:08:57 UTC
Ever since QEMU commit 951f2269af2d ("vl: allow 'maxmem' without 'slot'") in 2018, QEMU has supported setting the "maxmem" option without the "slots" option.

That was a preparation for virtio-pmem and virtio-mem devices, that do not consume DIMM/NVDIMM slots.

Currently, in Libvirt, it's still required to reserve one slot for each virtio-mem and virtio-pmem device.


For example, specifying two virtio-mem devices with only 1 slot:

  <maxMemory slots='1' unit='KiB'>16777216</maxMemory>

results in

"error: unsupported configuration: memory device count '2' exceeds slots 
count '1'"


Specifying maxMemory without "slots" makes Libvirt angry:

  <maxMemory unit='KiB'>16777216</maxMemory>

"
error: XML document failed to validate against schema: Unable to 
validate doc against /usr/share/libvirt/schemas/domain.rng
Extra element maxMemory in interleave
Invalid sequence in interleave
Element domain failed to validate content
"

virtio-mem (and virtio-pmem) devices don't require a DIMM slot. To increase usability, virtio-based memory devices should not require/consume a slot in Libvirt, and it should be possible to define a domain using the maxMemory option and no slots. Old QEMU versions will report an error like "invalid value of -m option: maxmem was specified, but no hotplug slots were specified".

Comment 1 Peter Krempa 2023-06-28 14:53:00 UTC
Fixed upstream:

commit 91856be29bb38e218c9bfe29ca08a9fef57dc64f
Author: Peter Krempa <pkrempa>
Date:   Thu Jun 22 13:56:06 2023 +0200

    qemuxml2(argv|xml)test: Add case for validating proper DIMM slot validation
    
    Add a config where both DIMM and non-DIMM <memory> devices are used so
    that it validates that only DIMMs require memory slots.
    
    Signed-off-by: Peter Krempa <pkrempa>
    Reviewed-by: Ján Tomko <jtomko>

commit e4b4765f4f2b24035402510263021bcf55bbea38
Author: Peter Krempa <pkrempa>
Date:   Wed Jun 21 16:01:26 2023 +0200

    conf: Allow omitting 'slots' attribute of <maxMemory>
    
    Memory slots are required only for DIMM-like devices, but the maximum
    memory address space is relevant also for other non-DIMM memory devices
    such as virtio-mem. Allow configurations where no slots are added.
    
    Signed-off-by: Peter Krempa <pkrempa>
    Reviewed-by: Ján Tomko <jtomko>

commit e3ce39195c82c4e8f54ddad73e192d9317c9bb39
Author: Peter Krempa <pkrempa>
Date:   Wed Jun 21 15:31:24 2023 +0200

    qemu_domain: Properly validate count of memory slots
    
    Memory slots are required only for DIMM-like devices, while other
    devices defined via <memory> such as virtio-mem may use the PCI bus and
    thus do not require/consume a memory slot.
    
    Fix the validation code to calculate the required count of memory
    devices only for DIMMs and NVDIMMs.
    
    Signed-off-by: Peter Krempa <pkrempa>
    Reviewed-by: Ján Tomko <jtomko>

commit a52c68443d12e0c9be98137150b7e9314d87dac6
Author: Peter Krempa <pkrempa>
Date:   Wed Jun 21 16:31:46 2023 +0200

    qemu_command: Always use modern syntax of '-m'
    
    Specify the memory size by using '-m size=2048k' instead of just '-m 2'.
    
    The new syntax is used when memory hotplug is enabled. To preserve
    memory sizing, if memory hotplug is disabled the size is rounded down to
    the nearest mebibyte.
    
    Signed-off-by: Peter Krempa <pkrempa>
    Reviewed-by: Ján Tomko <jtomko>

v9.4.0-71-g91856be29b

Comment 2 liang cong 2023-07-05 06:58:18 UTC
Pre-verify on upstream build libvirt v9.5.0-10-gcd4bdcb8cf 

Test scenarios:
1.Virtio-mem cold plug with no slot
1.1 Define and start a guest with below config:
<maxMemory unit='KiB'>15242880</maxMemory>
<memory unit='KiB'>2097152</memory>
<currentMemory unit='KiB'>2097152</currentMemory>
...
<numa>
    <cell id='0' cpus='0' memory='1048576' unit='KiB' />
    <cell id='1' cpus='1' memory='1048576' unit='KiB' />
</numa>
...
<memory model='virtio-mem'>
     <target>
       <size unit='KiB'>2097152</size>
       <node>0</node>
       <block unit='KiB'>2048</block>
       <requested unit='KiB'>1048576</requested>
     </target>
</memory>

# virsh define vm1.xml
Domain 'vm1' defined from vm1.xml

# virsh start vm1
Domain 'vm1' started


1.2 Check the virsh dumpxml
# virsh dumpxml vm1 | xmllint --xpath '//devices/memory' -
<memory model="virtio-mem">
      <target>
        <size unit="KiB">2097152</size>
        <node>0</node>
        <block unit="KiB">2048</block>
        <requested unit="KiB">1048576</requested>
        <current unit="KiB">1048576</current>
        <address base="0x100000000"/>
      </target>
      <alias name="virtiomem0"/>
      <address type="pci" domain="0x0000" bus="0x07" slot="0x00" function="0x0"/>
    </memory>

1.3 Attach a dimm memory device
# virsh attach-device vm1 dimm.xml 
error: Failed to attach device from dimm.xml
error: unsupported configuration: count of memory devices requiring memory slots '1' exceeds slots count '0'

1.4 Attach another virtio-mem device
# virsh attach-device vm1 virtio.xml 
Device attached successfully


2 Virtio-mem cold plug with 1 slot
2.1 Define and start a guest with below config:
<maxMemory unit='KiB' slots='1'>15242880</maxMemory>
<memory unit='KiB'>2097152</memory>
<currentMemory unit='KiB'>2097152</currentMemory>
...
<numa>
    <cell id='0' cpus='0' memory='1048576' unit='KiB' />
    <cell id='1' cpus='1' memory='1048576' unit='KiB' />
</numa>
...
<memory model='virtio-mem'>
     <target>
       <size unit='KiB'>2097152</size>
       <node>0</node>
       <block unit='KiB'>2048</block>
       <requested unit='KiB'>1048576</requested>
     </target>
</memory>

# virsh define vm1.xml
Domain 'vm1' defined from vm1.xml

# virsh start vm1
Domain 'vm1' started

2.2 Check the virsh dumpxml
# virsh dumpxml vm1 | xmllint --xpath '//devices/memory' -
<memory model="virtio-mem">
      <target>
        <size unit="KiB">2097152</size>
        <node>0</node>
        <block unit="KiB">2048</block>
        <requested unit="KiB">1048576</requested>
        <current unit="KiB">1048576</current>
        <address base="0x100000000"/>
      </target>
      <alias name="virtiomem0"/>
      <address type="pci" domain="0x0000" bus="0x07" slot="0x00" function="0x0"/>
    </memory>

2.3 Attach a dimm memory device
# virsh attach-device vm1 dimm.xml 
Device attached successfully

2.4 Attach a nvdimm memory device
# virsh attach-device vm1 nvdimm.xml 
error: Failed to attach device from nvdimm.xml
error: unsupported configuration: count of memory devices requiring memory slots '2' exceeds slots count '1'

2.5 Attach another virtio-mem device
# virsh attach-device vm1 virtio.xml 
Device attached successfully


Also test other scenarios, such as: dimm|nvdimm device with no|scarcy slot

Comment 3 liang cong 2023-07-25 09:45:25 UTC
Verified on build:
# rpm -q libvirt qemu-kvm
libvirt-9.5.0-3.el9.x86_64
qemu-kvm-8.0.0-9.el9.x86_64

Test scenarios:
1.Virtio-mem cold plug with no slot
1.1 Define and start a guest with below config:
<maxMemory unit='KiB'>15242880</maxMemory>
<memory unit='KiB'>2097152</memory>
<currentMemory unit='KiB'>2097152</currentMemory>
...
<numa>
    <cell id='0' cpus='0' memory='1048576' unit='KiB' />
    <cell id='1' cpus='1' memory='1048576' unit='KiB' />
</numa>
...
<memory model='virtio-mem'>
     <target>
       <size unit='KiB'>2097152</size>
       <node>0</node>
       <block unit='KiB'>2048</block>
       <requested unit='KiB'>1048576</requested>
     </target>
</memory>

# virsh define vm1.xml
Domain 'vm1' defined from vm1.xml

# virsh start vm1
Domain 'vm1' started


1.2 Check the virsh dumpxml
# virsh dumpxml vm1 | xmllint --xpath '//devices/memory' -
<memory model="virtio-mem">
      <target>
        <size unit="KiB">2097152</size>
        <node>0</node>
        <block unit="KiB">2048</block>
        <requested unit="KiB">1048576</requested>
        <current unit="KiB">1048576</current>
        <address base="0x100000000"/>
      </target>
      <alias name="virtiomem0"/>
      <address type="pci" domain="0x0000" bus="0x07" slot="0x00" function="0x0"/>
    </memory>


1.3 Attach a dimm memory device
# virsh attach-device vm1 mem.xml 
error: Failed to attach device from mem.xml
error: unsupported configuration: count of memory devices requiring memory slots '1' exceeds slots count '0'

1.4 Attach another virtio-mem device
# virsh attach-device vm1 virtio-mem.xml 
Device attached successfully


2 Virtio-mem cold plug with 1 slot
2.1 Define and start a guest with below config:
<maxMemory unit='KiB' slots='1'>15242880</maxMemory>
<memory unit='KiB'>2097152</memory>
<currentMemory unit='KiB'>2097152</currentMemory>
...
<numa>
    <cell id='0' cpus='0' memory='1048576' unit='KiB' />
    <cell id='1' cpus='1' memory='1048576' unit='KiB' />
</numa>
...
<memory model='virtio-mem'>
     <target>
       <size unit='KiB'>2097152</size>
       <node>0</node>
       <block unit='KiB'>2048</block>
       <requested unit='KiB'>1048576</requested>
     </target>
</memory>

# virsh define vm1.xml
Domain 'vm1' defined from vm1.xml

# virsh start vm1
Domain 'vm1' started

2.2 Check the virsh dumpxml
# virsh dumpxml vm1 | xmllint --xpath '//devices/memory' -
<memory model="virtio-mem">
      <target>
        <size unit="KiB">2097152</size>
        <node>0</node>
        <block unit="KiB">2048</block>
        <requested unit="KiB">1048576</requested>
        <current unit="KiB">1048576</current>
        <address base="0x100000000"/>
      </target>
      <alias name="virtiomem0"/>
      <address type="pci" domain="0x0000" bus="0x07" slot="0x00" function="0x0"/>
    </memory>

2.3 Attach a dimm and a virtio-mem memory device
# virsh attach-device vm1 virtio-mem.xml 
Device attached successfully

# virsh attach-device vm1 mem.xml 
Device attached successfully

2.4 Attach a nvdimm memory device
# virsh attach-device vm1 nvdimm.xml 
error: Failed to attach device from nvdimm.xml
error: unsupported configuration: count of memory devices requiring memory slots '2' exceeds slots count '1'


2.5 Attach another virtio-mem device
# virsh attach-device vm1 virtio-mem.xml 
Device attached successfully


Also test other scenarios, such as: dimm|nvdimm device with no|scarcy slot

Comment 6 liang cong 2023-08-07 03:25:47 UTC
mark it verified per comment 3

Comment 8 errata-xmlrpc 2023-11-07 08:31:41 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (Moderate: libvirt security, bug fix, and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2023:6409


Note You need to log in before you can comment on or make changes to this bug.