Bug 2193315 - Fail to hot-plug a qcow2 image with fdgroup
Summary: Fail to hot-plug a qcow2 image with fdgroup
Keywords:
Status: VERIFIED
Alias: None
Product: Red Hat Enterprise Linux 9
Classification: Red Hat
Component: libvirt
Version: 9.3
Hardware: All
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: Peter Krempa
QA Contact: Han Han
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2023-05-05 07:36 UTC by Han Han
Modified: 2023-08-10 02:15 UTC (History)
6 users (show)

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


Attachments (Terms of Use)
reproducing script, domain XML and virtqemud log (40.99 KB, application/gzip)
2023-05-05 07:36 UTC, Han Han
no flags Details


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker RHELPLAN-156478 0 None None None 2023-05-05 07:37:16 UTC

Description Han Han 2023-05-05 07:36:36 UTC
Created attachment 1962497 [details]
reproducing script, domain XML and virtqemud log

Description of problem:
As subject

Version-Release number of selected component (if applicable):
libvirt-9.2.0-1.el9
qemu-kvm-8.0.0-1.el9.x86_64
kernel-5.14.0-306.el9.x86_64

How reproducible:
100%

Steps to Reproduce:
1. Start an VM
+ /root/libvirt/build/tools/virsh create rhel.xml
Domain 'rhel' created from rhel.xml

+ /root/libvirt/build/tools/virsh event --domain rhel --event agent-lifecycle
event 'agent-lifecycle' for domain 'rhel': state: 'connected' reason: 'channel event'
events received: 1   

2. Open the target qcow2 disk file as fd. Associate the FD with a fdgroup. Attach the disk to the running VM with fdgroup
+ DISK_XML='<disk type='\''file'\'' device='\''disk'\''>
      <driver name='\''qemu'\'' type='\''qcow2'\''/>
      <source file='\''/var/lib/libvirt/images/vdc'\'' fdgroup='\''test'\''/>
      <target dev='\''vdf'\'' bus='\''virtio'\''/>
    </disk>'
+ qemu-img create /var/lib/libvirt/images/vdc -f qcow2 10M -o preallocation=falloc
Formatting '/var/lib/libvirt/images/vdc', fmt=qcow2 cluster_size=65536 extended_l2=off preallocation=falloc compression_type=zlib size=10485760 lazy_refcounts=off refcount_bits=16

+ echo '<disk' 'type='\''file'\''' 'device='\''disk'\''>' '<driver' 'name='\''qemu'\''' 'type='\''qcow2'\''/>' '<source' 'file=
'\''/var/lib/libvirt/images/vdc'\''' 'fdgroup='\''test'\''/>' '<target' 'dev='\''vdf'\''' 'bus='\''virtio'\''/>' '</disk>'
+ /root/libvirt/build/tools/virsh 'dom-fd-associate rhel test 3; attach-device rhel /tmp/tmp.ODdbidggCI'

error: Failed to attach device from /tmp/tmp.ODdbidggCI
error: internal error: fd passed image source not initialized

Actual results:
As above

Expected results:
No error for hot-plug

Additional info:
Reproduced on v9.1.0 and v9.3.0-32-g4419e74117
Not produced when create the VM with fdgroup of qcow2 disk
Not produced for the hot-plug of raw disk with fdgroup
For the reproducing script, domain XML and virtqemud log, see the attachment

Comment 1 Peter Krempa 2023-05-05 14:36:54 UTC
Fixed upstream:

commit c 
Author: Peter Krempa <pkrempa>
Date:   Fri May 5 14:43:17 2023 +0200

    qemu: hotplug: Reorder setup of disk backend metadata
    
    The regular VM startup code first calls the setup of the disk backing
    chain as defined in the XML and then calls the function to load the
    rest of the backing chain from the image metadata. The hotplug code
    did it the other way around, thus causing a failure when attempting
    to attach a QCOW2 image via FD passing.
    
    Reorder the hotplug code to have the same order.
    
    Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2193315
    Signed-off-by: Peter Krempa <pkrempa>
    Reviewed-by: Ján Tomko <jtomko>

v9.3.0-38-g9b8bb536ff

Comment 2 Han Han 2023-05-08 06:04:54 UTC
PASS on qemu-kvm-8.0.0-1.el9.x86_64 libvirt-v9.3.0-38-g9b8bb536ff

+ DISK_XML='<disk type='\''file'\'' device='\''disk'\''>                                                                       
      <driver name='\''qemu'\'' type='\''qcow2'\''/>                                                                           
      <source file='\''/var/lib/libvirt/images/vdc'\'' fdgroup='\''test'\''/>                                                  
      <target dev='\''vdf'\'' bus='\''virtio'\''/>                                                                             
    </disk>'                                                                                                                   
+ qemu-img create /var/lib/libvirt/images/vdc -f qcow2 10M -o preallocation=falloc                                             
Formatting '/var/lib/libvirt/images/vdc', fmt=qcow2 cluster_size=65536 extended_l2=off preallocation=falloc compression_type=zl
ib size=10485760 lazy_refcounts=off refcount_bits=16
+ /root/libvirt/build/tools/virsh create rhel.xml
Domain 'rhel' created from rhel.xml                                                                                            
                               
+ /root/libvirt/build/tools/virsh event --domain rhel --event agent-lifecycle
event 'agent-lifecycle' for domain 'rhel': state: 'connected' reason: 'channel event'
events received: 1                                                                                                             
                               
+ exec
++ mktemp
+ disk_xml_file=/tmp/tmp.5ZsgAppEuB           
+ echo '<disk' 'type='\''file'\''' 'device='\''disk'\''>' '<driver' 'name='\''qemu'\''' 'type='\''qcow2'\''/>' '<source' 'file=
'\''/var/lib/libvirt/images/vdc'\''' 'fdgroup='\''test'\''/>' '<target' 'dev='\''vdf'\''' 'bus='\''virtio'\''/>' '</disk>'
+ /root/libvirt/build/tools/virsh 'dom-fd-associate rhel test 3; attach-device rhel /tmp/tmp.5ZsgAppEuB'
                               
Device attached successfully

+ /root/libvirt/build/tools/virsh dumpxml rhel --xpath //disk                                                                  
<disk type="file" device="disk">                                                                                               
  <driver name="qemu" type="qcow2"/>                                                                                           
  <source file="/var/lib/libvirt/images/rhel.qcow2" index="1"/>                                                                
  <backingStore/>                                                                                                              
  <target dev="vda" bus="virtio"/>                                                                                             
  <alias name="virtio-disk0"/>                                                                                                 
  <address type="pci" domain="0x0000" bus="0x02" slot="0x00" function="0x0"/>
</disk>                                                        
<disk type="file" device="disk">                                                                                               
  <driver name="qemu" type="qcow2"/>
  <source file="/var/lib/libvirt/images/vdc" fdgroup="test" index="2"/>      
  <backingStore/>                                                                                                              
  <target dev="vdf" bus="virtio"/>                                                                                             
  <alias name="virtio-disk5"/> 
  <address type="pci" domain="0x0000" bus="0x01" slot="0x00" function="0x0"/>
</disk>

Comment 3 Han Han 2023-05-08 07:54:37 UTC
Since the hot-plug of qcow2 image is common, I think it is better to backport this bug to RHEL9.2.
Peter, what do you think of it?

Comment 4 Peter Krempa 2023-05-09 12:37:19 UTC
(In reply to Han Han from comment #3)
> Since the hot-plug of qcow2 image is common, I think it is better to
> backport this bug to RHEL9.2.
> Peter, what do you think of it?

I'll ask whether CNV wants to use the feature in 9.2. If yes I'll ask for a backport, but until then I don't think it's necessary.

Comment 5 Han Han 2023-05-24 09:02:12 UTC
Hi, Stu,
Will CNV use this feature on RHEL9.2?

Comment 6 sgott 2023-05-24 13:40:00 UTC
Forwarding the question to Adam, who is more focused in this area.

Comment 7 Adam Litke 2023-07-05 14:00:21 UTC
No we have no plans to use this feature at the moment.  In CNV, we allow the qemu process to open the disk image file directly.

Comment 8 Han Han 2023-07-06 07:56:30 UTC
Test PASS on libvirt-9.5.0-0rc1.1.el9.x86_64 libvirt-9.5.0-0rc1.1.el9.x86_64 as comment2

Comment 12 Han Han 2023-08-10 02:15:00 UTC
Test PASS on libvirt-9.5.0-5.el9.x86_64 qemu-kvm-8.0.0-11.el9.x86_64 as comment2


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