Bug 1793036

Summary: Use non-nesting replacement for query-named-block-nodes
Product: Red Hat Enterprise Linux Advanced Virtualization Reporter: Peter Krempa <pkrempa>
Component: libvirtAssignee: Peter Krempa <pkrempa>
Status: CLOSED ERRATA QA Contact: yisun
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 8.2CC: hhan, jdenemar, lmen, xuzhang
Target Milestone: rcKeywords: Triaged
Target Release: 8.0   
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: Environment:
Last Closed: 2020-11-17 17:46: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: 1533105    
Bug Blocks:    

Description Peter Krempa 2020-01-20 14:23:35 UTC
Description of problem:
The 'query-named-block-nodes' QMP command may return extremely big JSON replies in cases when the backing chain is too deep due to nesting. Libvirt should use one of the upcoming replacements for this command which behave more sane.

Version-Release number of selected component (if applicable):


How reproducible:


Steps to Reproduce:
1.
2.
3.

Actual results:


Expected results:


Additional info:

Comment 1 Peter Krempa 2020-03-04 14:07:49 UTC
Upstream now uses the 'flat' output of 'query-named-block-nodes':

95080cc8b4 qemu: Don't request nested entries in qemuBlockGetNamedNodeData
855211bbf3 qemu: monitor: Add 'flat' parameter for qemuMonitorJSONQueryNamedBlockNodes
63610bd5fb qemuCheckpointDiscardBitmaps: Use qemuBlockGetNamedNodeData
f886c9f330 qemu: monitor: Refactor variable cleanup in qemuMonitorJSONQueryNamedBlockNodes
b7991c903c qemu: capabilities: Add capability for the 'flat' argument of 'query-named-block-nodes'
7892748350 qemu: monitor: Remove leftovers from password callback
7680f3369a tests: qemucapabilities: Update capabilities of qemu-5.0.0 on x86_64

Comment 6 yisun 2020-07-21 03:14:24 UTC
Test result: PASS
[root@libvirt-rhel-8 ~]# rpm -qa | grep libvirt-6
libvirt-6.5.0-1.module+el8.3.0+7323+d54bb644.x86_64

steps:
1. prepare a running vm
[root@libvirt-rhel-8 ~]# qemu-img create -f qcow2 /var/lib/libvirt/images/256snaps.qcow2 100M
Formatting '/var/lib/libvirt/images/256snaps.qcow2', fmt=qcow2 size=104857600 cluster_size=65536 lazy_refcounts=off refcount_bits=16 compression_type=zlib

[root@libvirt-rhel-8 ~]# virsh start vm
Domain vm started

[root@libvirt-rhel-8 ~]# virsh domblklist vm
 Target   Source
--------------------------------------------------
 vda      /var/lib/libvirt/images/256snaps.qcow2

[root@libvirt-rhel-8 ~]# echo "" > /var/log/libvirtd-debug.log

2. start to create 400 disk only snapshots for it
[root@libvirt-rhel-8 ~]# for i in {1..400}; do virsh snapshot-create-as vm s$i --disk-only; done
Domain snapshot s1 created
Domain snapshot s2 created
Domain snapshot s3 created
Domain snapshot s4 created
Domain snapshot s5 created
Domain snapshot s6 created
Domain snapshot s7 created
Domain snapshot s8 created
Domain snapshot s9 created
Domain snapshot s10 created
Domain snapshot s11 created
Domain snapshot s12 created
Domain snapshot s13 created
Domain snapshot s14 created
Domain snapshot s15 created
Domain snapshot s16 created
Domain snapshot s17 created
Domain snapshot s18 created
Domain snapshot s19 created
...
...
Domain snapshot s197 created
Domain snapshot s198 created
Domain snapshot s199 created
error: Operation not supported: backing chains more than 200 layers deep are not supported for disk 'vda'
error: Operation not supported: backing chains more than 200 layers deep are not supported for disk 'vda'

4. only 200 snapshots created, and the error message after round 200 is clear
now we destroy and start the vm again
[root@libvirt-rhel-8 ~]# virsh destroy vm
Domain vm destroyed

[root@libvirt-rhel-8 ~]# virsh start vm
Domain vm started

[root@libvirt-rhel-8 ~]# virsh domblklist vm
 Target   Source
-------------------------------------------------
 vda      /var/lib/libvirt/images/256snaps.s199

[root@libvirt-rhel-8 ~]# virsh dumpxml vm | awk '/<disk/,/<\/disk/'
Too long, not pasted here, it contains correct disk xml with correct backing chain.

5. check the libvirtd log, the query-named-block-nodes using 'flat' argument
Check libvirtd log:
2020-07-21 03:01:21.869+0000: 402909: info : qemuMonitorSend:946 : QEMU_MONITOR_SEND_MSG: mon=0x7f582008f1d0 msg={"execute":"query-named-block-nodes","arguments":{"flat":true},"id":"libvirt-379"}^M
 fd=-1

Comment 9 errata-xmlrpc 2020-11-17 17:46: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