Bug 2176215

Summary: [libvirt] allow configuring host-phys-bits-limit
Product: Red Hat Enterprise Linux 9 Reporter: Ján Tomko <jtomko>
Component: libvirtAssignee: Ján Tomko <jtomko>
libvirt sub component: Live Migration QA Contact: Luyao Huang <lhuang>
Status: CLOSED ERRATA Docs Contact:
Severity: unspecified    
Priority: unspecified CC: dzheng, jdenemar, lmen, smitterl, virt-maint, xuwei
Version: 9.2Keywords: FutureFeature, Triaged
Target Milestone: rc   
Target Release: 9.3   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: libvirt-9.3.0-1.el9 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-11-07 08:31:00 UTC Type: Feature Request
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version: 9.3.0
Embargoed:
Bug Depends On:    
Bug Blocks: 2171860    

Description Ján Tomko 2023-03-07 16:43:08 UTC
Description of problem:
For migration compatibility, libvirt needs a knob to set the host-phys-bits-limit.
See bug 2171860 for more details.

Upstream issue:
https://gitlab.com/libvirt/libvirt/-/issues/450
Upstream patches:
https://listman.redhat.com/archives/libvir-list/2023-March/238231.html

Comment 2 Ján Tomko 2023-04-25 09:22:44 UTC
Pushed upstream as:
commit e3d95a1eba78f2b797dbdce7d8bd604a8e004961
Author:     Ján Tomko <jtomko>
CommitDate: 2023-04-25 11:19:37 +0200

    qemu: add support for setting host-phys-bits-limit
    
    Translate <maxphysaddr limit='39'/> to:
    host-phys-bits-limit=39
    
    https://gitlab.com/libvirt/libvirt/-/issues/450
    https://bugzilla.redhat.com/show_bug.cgi?id=2171860
    
    Signed-off-by: Ján Tomko <jtomko>
    Reviewed-by: Martin Kletzander <mkletzan>

git describe: v9.2.0-304-g03ca889b15

Comment 6 Luyao Huang 2023-05-19 02:30:20 UTC
Verify this bug with libvirt-9.3.0-2.el9.x86_64:

S1: Test set guest maxphysaddr limit < host Address sizes

1. check host Address sizes:
# lscpu |grep "Address sizes:"
Address sizes:                   46 bits physical, 48 bits virtual

2. Add limit in maxphysaddr element
# virsh edit vm1
...
  <cpu mode='host-model' check='partial'>
    <maxphysaddr mode='passthrough' limit='36'/>
    <numa>
      <cell id='0' cpus='0-5' memory='1048576' unit='KiB'/>
      <cell id='1' cpus='6-11' memory='1048576' unit='KiB'/>
    </numa>
  </cpu>
...

3. start guest
# virsh start vm1
Domain 'vm1' started

4. check qemu command line:
# ps aux|grep qemu
...host-phys-bits=on,host-phys-bits-limit=36

5. login guest and check guest Address sizes:
IN GUEST:
# lscpu|grep Address
Address sizes:                   36 bits physical, 48 bits virtual


S2: Test set guest maxphysaddr limit >= host Address sizes

1. check host Address sizes:
# lscpu |grep "Address sizes:"
Address sizes:                   46 bits physical, 48 bits virtual

2. Add limit in maxphysaddr element
# virsh edit vm1
...
  <cpu mode='host-model' check='partial'>
    <maxphysaddr mode='passthrough' limit='50'/>
    <numa>
      <cell id='0' cpus='0-5' memory='1048576' unit='KiB'/>
      <cell id='1' cpus='6-11' memory='1048576' unit='KiB'/>
    </numa>
  </cpu>
...

3. start guest
# virsh start vm1
Domain 'vm1' started

4. check qemu command line:
# ps aux|grep qemu
...host-phys-bits=on,host-phys-bits-limit=50


5. login guest and check guest Address sizes:

IN GUEST:
# lscpu|grep Address
Address sizes:                   46 bits physical, 48 bits virtual

S3: some negative scenarios

1. 
xml: <maxphysaddr mode='emulate' limit='50'/>

# virsh edit vm1
error: unsupported configuration: attribute 'limit' is only supported for maxphysaddr mode 'passthrough'
Failed. Try again? [y,n,i,f,?]: 

2.
xml: <maxphysaddr mode='passthrough' limit='0'/>

# virsh edit vm1
error: XML error: Invalid value for attribute 'limit' in element 'maxphysaddr': Zero is not permitted
Failed. Try again? [y,n,i,f,?]: 

3.
xml: <maxphysaddr mode='passthrough' limit='-1'/>

# virsh edit vm1
error: XML error: Invalid value for attribute 'limit' in element 'maxphysaddr': '-1'. Expected non-negative integer value
Failed. Try again? [y,n,f,?]: 


Migration and cross migration related scenarios will be tested in bug 2171860

Comment 7 smitterl 2023-08-07 12:45:49 UTC
Note: this is not supported on s390x:

error: unsupported configuration: CPU maximum physical address bits specification is not supported for 's390x' architecture

Comment 9 errata-xmlrpc 2023-11-07 08:31:00 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