Bug 1810016

Summary: Inspect libvirt for use of fields/commands deprecated in QMP
Product: Red Hat Enterprise Linux Advanced Virtualization Reporter: Peter Krempa <pkrempa>
Component: libvirtAssignee: Peter Krempa <pkrempa>
Status: CLOSED ERRATA QA Contact: Han Han <hhan>
Severity: low Docs Contact:
Priority: low    
Version: 8.2CC: chhu, jdenemar, lmen, virt-maint, xuzhang, yalzhang
Target Milestone: rcKeywords: Triaged
Target Release: 8.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: libvirt-7.3.0-1.el8 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-11-16 07:49:57 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: 7.3.0
Embargoed:

Description Peter Krempa 2020-03-04 12:05:49 UTC
Description of problem:
QEMU now exposes deprecation also using QMP. We need to explore how to use it at least for making sure that new interfaces are used.

https://lists.gnu.org/archive/html/qemu-devel/2020-03/msg00645.html

Comment 2 Peter Krempa 2021-04-06 15:24:48 UTC
We handle checking of deprecation twofold now:

1) Libvirt's unit tests for monitor interaction now validate that the the code isn't using deprecated fileds:

commit de8216af137590801f320f7284338d2c65b8474b
Author: Peter Krempa <pkrempa>
Date:   Wed Mar 4 09:02:54 2020 +0100

    testQEMUSchemaValidate*: Reject usage of fields with 'deprecated' set
    
    Make our QMP schema validator reject any use of schema entries which
    were deprecated by QEMU except for those whitelisted.
    
    This will allow us to catch this before qemu actually removed what we'd
    still use.

2) libvirt now exposes a debug interface which can be used to enable '-compat' in qemu. The compat flag allows to configure behavior when an deprecated field is used.

The qemu.conf setting 'deprecation_behavior' which should be set to 'crash' in CI environments instructs qemu to crash when a deprecated option is used thus making it very obvious that something like that happened. Additionally the option can be used also for older setups since it's ignored if qemu doesn't support '-compat' to remove the need to fiddle with CI envs.

commit c54b1bdcfb9c812a42ff48fe41e2fc8d9a0af86d
Author: Peter Krempa <pkrempa>
Date:   Thu Apr 30 13:34:28 2020 +0200

    qemu: command: Handle formatting of '-compat' options
    
    Enable '-compat' if requested in qemu.conf and supported by qemu to
    instruct qemu to crash when a deprecated command is used and stop
    returning deprecated fields.
    
    This setting is meant for libvirt developers and such.
    
    Signed-off-by: Peter Krempa <pkrempa>
    Reviewed-by: Martin Kletzander <mkletzan>

commit a6444c80195f6b9ad4fe49a6826376c163a02fa5
Author: Peter Krempa <pkrempa>
Date:   Mon Mar 15 15:06:29 2021 +0100

    qemu: Add per-VM control of deprecation behavior
    
    Similar to the qemu.conf knob 'deprecation_behavior' add a per-VM knob
    in the QEMU namespace:
    
      <qemu:deprecation behavior='...'/>
    
    Signed-off-by: Peter Krempa <pkrempa>
    Reviewed-by: Martin Kletzander <mkletzan>

commit 700450449377be4bf923e91d00f8fe8cf0975f66
Author: Peter Krempa <pkrempa>
Date:   Thu Apr 30 13:27:58 2020 +0200

    qemu: conf: Add 'deprecation_behavior' setting to qemu.conf
    
    New QEMU supports a harsh, but hard to ignore way to notify that the
    QMP user used a deprecated command. This is useful e.g. for developers
    to see that something needs to be fixed.
    
    This patch introduces a qemu.conf option to enable the setting in cases
    when qemu supports it so that developers and continiuous integration
    efforts are notified about use of deprecated fields before it's too
    late.
    
    The option is deliberately stored as string and not validated to prevent
    failures when downgrading qemu or libvirt versions. While we don't
    support this, the knob isn't meant for public consumption anyways.
    
    Signed-off-by: Peter Krempa <pkrempa>
    Reviewed-by: Martin Kletzander <mkletzan>

Comment 3 Han Han 2021-04-07 03:23:20 UTC
Set to low Priority&Severity since the comment "# DO NOT use in production".

Comment 4 Peter Krempa 2021-04-07 06:54:33 UTC
Indeed, it's specifically designed for testing and CI :)

Comment 8 Han Han 2021-05-19 03:22:30 UTC
Since this configuration is aimed for testing not production, I just test it simply to make sure the value of deprecation_behavior will be corresponded to the qemu cmdline
Version:
libvirt-7.3.0-1.module+el8.5.0+11004+f4810536.x86_64
qemu-kvm-6.0.0-16.module+el8.5.0+10848+2dccc46d.x86_64

Steps
1. Set deprecation_behavior = "crash" in qemu.conf and restart libvirtd
2. Start an VM and check the qemu cmdline. It will be like "/usr/libexec/qemu-kvm ... -compat deprecated-output=hide,deprecated-input=crash ..."

Comment 10 errata-xmlrpc 2021-11-16 07:49:57 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:av 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-2021:4684