Bug 1810016 - Inspect libvirt for use of fields/commands deprecated in QMP
Summary: Inspect libvirt for use of fields/commands deprecated in QMP
Keywords:
Status: VERIFIED
Alias: None
Product: Red Hat Enterprise Linux Advanced Virtualization
Classification: Red Hat
Component: libvirt
Version: 8.2
Hardware: Unspecified
OS: Unspecified
low
low
Target Milestone: rc
: 8.0
Assignee: Peter Krempa
QA Contact: Han Han
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2020-03-04 12:05 UTC by Peter Krempa
Modified: 2021-05-19 03:22 UTC (History)
6 users (show)

Fixed In Version: libvirt-7.3.0-1.el8
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed:
Type: Bug
Target Upstream Version: 7.3.0


Attachments (Terms of Use)

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@redhat.com>
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@redhat.com>
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@redhat.com>
    Reviewed-by: Martin Kletzander <mkletzan@redhat.com>

commit a6444c80195f6b9ad4fe49a6826376c163a02fa5
Author: Peter Krempa <pkrempa@redhat.com>
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@redhat.com>
    Reviewed-by: Martin Kletzander <mkletzan@redhat.com>

commit 700450449377be4bf923e91d00f8fe8cf0975f66
Author: Peter Krempa <pkrempa@redhat.com>
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@redhat.com>
    Reviewed-by: Martin Kletzander <mkletzan@redhat.com>

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 ..."


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