Bug 2030437

Summary: Error using NULL monitor when querying launch security info for shutoff guest
Product: Red Hat Enterprise Linux 8 Reporter: Daniel Berrangé <berrange>
Component: libvirtAssignee: Daniel Berrangé <berrange>
Status: CLOSED ERRATA QA Contact: Luyao Huang <lhuang>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 8.6CC: jdenemar, lmen, pkrempa, virt-maint, xuzhang
Target Milestone: rcKeywords: Triaged
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: libvirt-8.0.0-1.el8 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-05-10 13:24:21 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: 8.0.0
Embargoed:

Description Daniel Berrangé 2021-12-08 18:57:08 UTC
Description of problem:
If you call the 'virDomainGetLaunchSecurityInfo' method on a guest with SEV config that is shutoff, libvirt tries to use a NULL monitor resulting in
an error:

 libvirt: QEMU Driver error : invalid argument: monitor must not be NULL

This can be demonstrated with:

$ cat sev.py 
#!/usr/bin/python3

import libvirt
import sys

c = libvirt.open(None)

d = c.lookupByName(sys.argv[1])

print (d.launchSecurityInfo())

# python3 sev.py fedora34
libvirt: QEMU Driver error : invalid argument: monitor must not be NULL
Traceback (most recent call last):
  File "sev.py", line 10, in <module>
    print (d.launchSecurityInfo())
  File "/usr/lib64/python3.6/site-packages/libvirt.py", line 1749, in launchSecurityInfo
    raise libvirtError('virDomainGetLaunchSecurityInfo() failed')
libvirt.libvirtError: invalid argument: monitor must not be NULL

Addressed in

https://listman.redhat.com/archives/libvir-list/2021-December/msg00233.html

Version-Release number of selected component (if applicable):
7.10.0-1.el8

How reproducible:
Always

Steps to Reproduce:
1. Configure a guest with SEV <launchSecurity>
2. Do NOT start the guest
3. Run the above python demo

Actual results:
Error about NULL monitor

Expected results:
Error that the guest is not running

Additional info:

Comment 1 Peter Krempa 2022-01-26 11:46:54 UTC
Fixed upstream by:

commit 5842163910e8b8d320a896d9485b321d553bad3f
Author: Daniel P. Berrangé <berrange>
Date:   Wed Dec 8 07:51:43 2021 -0500

    qemu: report error querying launch params for inactive guest
    
    Querying launch params on a inactive guest currently triggers
    a warning about the monitor being NULL.
    
    https://bugzilla.redhat.com/show_bug.cgi?id=2030437
    
    Reviewed-by: Peter Krempa <pkrempa>
    Signed-off-by: Daniel P. Berrangé <berrange>

v7.10.0-299-g5842163910

Comment 4 Luyao Huang 2022-01-29 02:08:47 UTC
Verify this bug with libvirt-daemon-8.0.0-2.module+el8.6.0+14025+ca131e0a.x86_64:

1. prepare a inactive guest which enable SEV

# virsh list --all
 Id   Name   State
-----------------------
 -    vm1    shut off
 -    vm2    shut off

2. use python launchSecurityInfo api get guest SEV related information:

# cat tmp.py 
#!/usr/bin/python3

import libvirt
import sys

c = libvirt.open(None)

d = c.lookupByName(sys.argv[1])

print (d.launchSecurityInfo())


# python3 tmp.py vm1
libvirt: QEMU Driver error : Requested operation is not valid: domain is not running
Traceback (most recent call last):
  File "tmp.py", line 10, in <module>
    print (d.launchSecurityInfo())
  File "/usr/lib64/python3.6/site-packages/libvirt.py", line 1749, in launchSecurityInfo
    raise libvirtError('virDomainGetLaunchSecurityInfo() failed')
libvirt.libvirtError: Requested operation is not valid: domain is not running

Comment 6 errata-xmlrpc 2022-05-10 13:24:21 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: virt:rhel and virt-devel:rhel 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-2022:1759