Bug 1813852

Summary: report proper error if 'memfd' is requested as memory backing but qemu doesn't support it
Product: Red Hat Enterprise Linux Advanced Virtualization Reporter: Jing Qi <jinqi>
Component: libvirtAssignee: Ján Tomko <jtomko>
Status: CLOSED ERRATA QA Contact: Jing Qi <jinqi>
Severity: low Docs Contact:
Priority: low    
Version: 8.2CC: areis, chayang, ddepaula, dgilbert, dyuan, jdenemar, jinqi, jinzhao, jtomko, juzhang, marcandre.lureau, mdeng, virt-maint, xuzhang, yuhuang
Target Milestone: pre-dev-freezeKeywords: Triaged
Target Release: 8.3   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: libvirt-6.2.0-1.el8 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: 1738626 Environment:
Last Closed: 2020-11-17 17:47:36 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1738626    
Bug Blocks: 1740797    

Comment 2 Jing Qi 2020-03-16 10:18:23 UTC
Additional information, with libvirt-libs-6.0.0-9.virtcov.el8.x86_64 & qemu-kvm-core-4.2.0-10.module+el8.2.0+5740+c3dff59e.x86_64

1. Config a domain xml with memoryBacking as memfd set and there are numa cells in the domain.
   
<memoryBacking>
    <source type='memfd'/>
  </memoryBacking>
  <vcpu placement='static'>4</vcpu>
...
    <numa>
      <cell id='0' cpus='0-1' memory='512000' unit='KiB'/>
      <cell id='1' cpus='2-3' memory='512000' unit='KiB'/>
    </numa>

#virsh start avocado-vt
error: Failed to start domain avocado-vt
error: internal error: process exited while connecting to monitor: 2020-03-16T09:37:58.331359Z qemu-kvm: -object memory-backend-memfd,id=ram-node0,size=1073741824: invalid object type: memory-backend-memfd

2.  Config a domain xml with memoryBacking as memfd set and there is no numa cell.
the domain can be started successfully.

Comment 3 Peter Krempa 2020-03-16 12:01:54 UTC
Could you please run:

 grep -e '\(memfd\|packa\)' /var/cache/libvirt/qemu/capabilities/*

and paste the output here.

Then please delete everything in /var/cache/libvirt/qemu/capabilities/ and restart libvirtd and try again.

If it fails please paste the output of the above command again.

Comment 4 Jing Qi 2020-03-17 00:20:01 UTC
Here is the result as you request, please have a look.

# grep -e '\(memfd\|packa\)' /var/cache/libvirt/qemu/capabilities/*
  <package>qemu-kvm-4.2.0-10.module+el8.2.0+5740+c3dff59e</package>

# rm -rf /var/cache/libvirt/qemu/capabilities/*

# systemctl restart libvirtd

# grep -e '\(memfd\|packa\)' /var/cache/libvirt/qemu/capabilities/*
  <package>qemu-kvm-4.2.0-10.module+el8.2.0+5740+c3dff59e</package>

Comment 5 Peter Krempa 2020-03-17 07:39:33 UTC
Ok, so this boils down to validation not being done on the input definition as the capability is not present but we'll attempt to start the VM.

Comment 6 Ján Tomko 2020-03-17 09:05:24 UTC
Case #1 was fixed upstream by:
commit 8400b6c1983dd1e4504fe19d3421fff0e5866091
Author:     Ján Tomko <jtomko>
CommitDate: 2020-02-24 13:46:51 +0100

    qemu: use correct backendType when checking memfd capability
    
    The backend name is memory-backend-memfd but we've been checking
    for memory-backend-memory.
    
    Reported by GCC on rawhide:
    ../../../src/internal.h:75:22: error: 'strcmp' of a string of length 21 and
    an array of size 21 evaluates to nonzero [-Werror=string-compare]
    ../../../src/qemu/qemu_command.c:3525:20: note: in expansion of macro 'STREQ'
     3525 |         } else if (STREQ(backendType, "memory-backend-memory") &&
          |                    ^~~~~
    
    Signed-off-by: Ján Tomko <jtomko>
    Fixes: 24b74d187cab48a9dc9f409ea78900154c709579
    Reviewed-by: Daniel P. Berrangé <berrange>

git describe: v6.0.0-468-g8400b6c198 contains: v6.1.0-rc1~62

Case #2 is a separate problem common for all memory backends.

Comment 9 Jing Qi 2020-06-18 03:13:16 UTC
Verified with libvirt-6.4.0-1.module+el8.3.0+6881+88468c00.x86_64 & qemu-kvm-5.0.0-0.module+el8.3.0+6620+5d5e1420.x86_64

1. The domain xml has below part:
      
<memoryBacking>
    <source type='memfd'/>
  </memoryBacking>
  <vcpu placement='static'>4</vcpu>
...
    <numa>
      <cell id='0' cpus='0-1' memory='512000' unit='KiB'/>
      <cell id='1' cpus='2-3' memory='512000' unit='KiB'/>
    </numa>

2. # virsh start avocado-vt-vm1
error: Failed to start domain avocado-vt-vm1
error: unsupported configuration: this qemu doesn't support the memory-backend-memfd object

There is no libvirt error message reported.

Comment 12 errata-xmlrpc 2020-11-17 17:47:36 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 (virt:8.3 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/RHBA-2020:5137