Bug 760547

Summary: [RFE] specifying the entire image chain as a qemu drive (blockdev-add) (libvirt)
Product: Red Hat Enterprise Linux Advanced Virtualization Reporter: Dave Allan <dallan>
Component: libvirtAssignee: Peter Krempa <pkrempa>
Status: CLOSED ERRATA QA Contact: Han Han <hhan>
Severity: urgent Docs Contact:
Priority: urgent    
Version: 8.0CC: areis, chhu, coli, cpelland, cwei, dfediuck, dyuan, dzheng, eblake, fduthill, fjin, fsimonce, guillaume.pavese, hhan, hhuang, hpopal, jcall, jdenemar, jsuchane, juzhang, kchamart, knoel, kwolf, lmen, meili, migawa, mkenneth, moddi, mtessun, mzhan, pkrempa, rcyriac, tburke, virt-maint, xuzhang, yafu, yfu, zpeng
Target Milestone: pre-dev-freezeKeywords: Automation, FutureFeature
Target Release: 8.1   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: libvirt-5.10.0-1.el8 Doc Type: Enhancement
Doc Text:
Story Points: ---
Clone Of: 750801 Environment:
Last Closed: 2020-05-05 09:43:16 UTC Type: Feature Request
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: 750801, 1505701, 1513543, 1518738, 1545155, 1557995, 1561960, 1596511, 1623986, 1626061, 1658981    
Bug Blocks: 773650, 773651, 773665, 773677, 773696, 1035038, 1171569, 1207659, 1301026, 1306562, 1375855, 1406796, 1406805, 1436245, 1445598, 1465810, 1518998, 1518999, 1541702, 1582202, 1582249, 1623877, 1631239, 1636224, 1688814, 1731522, 1734975, 1734976, 1821539    
Attachments:
Description Flags
The libvirtd log of comment 30
none
The xml and script in comment41 none

Comment 5 Eric Blake 2012-02-18 17:55:48 UTC
Live snapshot and block pull also need to interact with an explicit backing file chain notation in the domain XML.  My current solution for block pull (see bug 638506) is currently quite weak, relying on the user to pass in a correct name; but if libvirt were properly tracking the backing chain, then libvirt could validate that the user is actually passing in a valid name.

Comment 21 Peter Krempa 2018-01-22 08:46:10 UTC
*** Bug 1534490 has been marked as a duplicate of this bug. ***

Comment 31 Han Han 2018-08-10 06:14:01 UTC
Created attachment 1474884 [details]
The libvirtd log of comment 30

After the eject failure, the media is still in the xml:
# virsh dumpxml A|awk '/<disk/,/<\/disk/'          
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source file='/var/lib/libvirt/images/Fedora.iso' index='1'/>
      <backingStore/>
      <target dev='sdb' bus='scsi'/>
      <readonly/>
      <alias name='scsi0-0-0-1'/>
      <address type='drive' controller='0' bus='0' target='0' unit='1'/>
    </disk>

And the cdrom media could be found in VM.

Comment 40 Han Han 2018-08-31 02:04:12 UTC
> But the domblkinfo Physical value is equal to the virtual size of qcow2.

Sorry in comment38 and comment39. It should be 'NOT equal to' there. Because the physical size from domblkinfo is 10737418240 while the virtual size from qcow2 file is 9663676416.

Comment 41 Han Han 2018-08-31 06:50:20 UTC
Update the testing of various backends of cdrom update:
Version: libvirt-4.5.0-7.el7_rc.0518ef33a7.x86_64 qemu-kvm-rhev-2.12.0-11.el7.x86_64
I. Test cdrom live insert 
1. Start a VM with empty cdrom:
...
    <disk type='file' device='cdrom'>                                                                                                                              
      <driver name='qemu' type='raw'/>
      <source index='1'/>
      <target dev='sdb' bus='scsi'/>
      <readonly/>
      <alias name='ua-cdrom'/>
      <address type='drive' controller='0' bus='0' target='0' unit='1'/>
    </disk>
...

2. Try to update instert iso from various backends: file,luks,block,gluster,iscsi,rbd,https,nbd

for i in file-file.xml file-luks.xml network-gluster.xml network-iscsi.xml network-rbd.xml network-https.xml network-nbd.xml;do
    virsh update-device $VM $i
    virsh dumpxml $VM|awk '/<disk/,/<\/disk/'
done

But get error from all the backends:
error: Failed to update device from file-file.xml
error: internal error: argument key 'id' must not have null value


II. Try to update media:
1. Start a VM with file backend cdrom media:
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source file='/var/lib/libvirt/images/boot.iso'/>
      <target dev='sdb' bus='scsi'/>
      <readonly/>
      <alias name='ua-cdrom'/>
      <address type='drive' controller='0' bus='0' target='0' unit='1'/>
    </disk>

2. Update the media to different backends:
for i in file-luks.xml block-block.xml network-gluster.xml network-iscsi.xml network-rbd.xml network-https.xml network-nbd.xml;do
    virsh update-device $VM $i
    virsh dumpxml $VM|awk '/<disk/,/<\/disk/'
done

Get error from all backends:
error: Failed to complete action eject on media
error: internal error: argument key 'id' must not have null value

III. Eject the media from different backends:
1. Prepare the empty cdrom xml
# cat file-empty.xml 
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <target dev='sdb' bus='scsi'/>
      <readonly/>
      <alias name='ua-cdrom'/>
      <address type='drive' controller='0' bus='0' target='0' unit='1'/>
    </disk>

2. Run following script:
for i in file-file.xml file-luks.xml block-block.xml network-gluster.xml network-iscsi.xml network-rbd.xml network-https.xml network-nbd.xml;do
    virsh update-device $VM $i --config
    virsh start $VM && sleep 50
    virsh update-device $VM $EMPTY
    virsh destroy $VM
done

Get the error above, too.
error: Failed to update device from file-empty.xml
error: internal error: argument key 'id' must not have null value

Comment 42 Han Han 2018-08-31 06:55:27 UTC
Created attachment 1479976 [details]
The xml and script in comment41

Here are the XMLs and scripts of updating cdrom. You can run ./run.sh to reproduce the issues in comment41.

Comment 46 Jaroslav Suchanek 2018-09-25 08:02:47 UTC
From usptream perspective following missing pieces needs to done
* handling of block jobs events
* execute modification of backing chain when event is populated
* create snapshots, blockdev-create is already done
* ...
* and finally switch on the blockdev-add

Comment 47 Jaroslav Suchanek 2018-12-14 21:55:35 UTC
Blockjob data storing and handling of blockjob events refactoring is done in this upstream patches:
https://www.redhat.com/archives/libvir-list/2018-December/msg00319.html

This is one of the major prerequisite for enabling blockdev-add support in libvirt.

Comment 53 Peter Krempa 2019-11-27 09:25:47 UTC
commit c6a9e54ce3252196f1fc6aa9e57537a659646d18
Author: Peter Krempa <pkrempa>
Date:   Mon Jan 7 11:45:19 2019 +0100

    qemu: enable blockdev support

    Now that all pieces are in place (hopefully) let's enable -blockdev.

    We base the capability on presence of the fix for 'auto-read-only' on
    files so that blockdev works properly, mandate that qemu supports
    explicit SCSI id strings to avoid ABI regression and that the fix for
    'savevm' is present so that internal snapshots work.

v5.9.0-390-gc6a9e54ce3

This requires upstream qemu-4.2 or appropriate downstream.

Note that there are hundreds commits which implement various bits needed for this feature which are not isted here.

Comment 55 Han Han 2020-04-15 02:13:05 UTC
Since libvirt-5.6, QE have tested blockdev for many times. The test matrix:
- disk xml
    variants:
    - iotune
    - without_iotune

    - source
        variants:
        - no_slices
        - slices

        variants:
        - file
            variants:
            - * block
                variants:
                - common
            - pr-helper
            - * file
        - network
            variants:
            - * multi_host_rbd_cephx
                variants:
                - * no_ceph_snapshot(default)
                - * ceph_snapshot(<readonly/> required)
            - * multi_host_gluster
            - chap_iscsi
            - * https(readonly)
				- cookie, sslverify, query, readahead, timeout
            - * nbd                
                variants:
                - no_tls(default)
                - * tls
        - * nvme
        - pool_volume
            variants:        
            - Directory pool
            - Filesystem pool
            - Network file system pool
            - Logical volume pool
            - Disk pool
            - iSCSI pool
            - iSCSI direct pool
            - SCSI pool
            - Multipath pool
            - RBD pool
            - Gluster pool

        
    - driver
        variants:
        - * format_qcow2
        - * format_raw
        - * format_raw_luks
        - format_vmdk(<readonly/> required)
        - format_vhd(<readonly/> required)
        - format_vpc(<readonly/> required)
        
        variants:
        - * copy_on_read_on
        - copy_on_read_off(default)
   
        variants:
        - default
        - cache_directsync
        - * cache_none
        - cache_unsafe
        - * cache_writeback
        - * cache_writethrough
    
        variants:
        - default
        - discard_ignore
        - * discard_unmap
        
        variants:
        - default
        - * detect_zeroes_on
        - detect_zeroes_unmap
        
        variants:
        - default
        - * readonly_yes(exclude block*, snapshot* operations)
        
        variants:
        - default
        - * io_native
        - * io_threads
        
        variants:
        - * custom_alias
        - default
    
        variants:
        - * backing store: Refer to source matrix
        
- operations
    variants:
    - snapshot-create
        variants:
        - * disk_only
        - * disk_memory
        
        variants:
        - no_reuse_external
        - * reuse_external
        
        variants(type):
        - * file
        - * block
        - * multihost_gluster
        
    - * attach
        variants:
        - active
            - xml: refer to source matrix
        - inactive
            - xml: refer to source matrix
            
    - detach
        variants:
        - * active
            - xml: refer to disk xml matrix
        - inactive
            - xml: refer to disk xml matrix
    
    - update-device
        - * cdrom
            - xml: refer to disk xml matrix
                variants:
                - eject
                - insert
        - floppy(not supported in latest q35)
            - xml: refer to disk xml matrix
                variants:
                - eject
                - insert
            
    - * detach_alias
        variants:
        - active
            - xml: refer to disk xml matrix
        - inactive
            - xml: refer to disk xml matrix
    
    - blockcommit
        variants:
        - * commit_from_active_layer
            variants:
            - pivot
            - finish
        - * commit_from_inactive_layer

        variants:
        - * shallow
        - no_shallow(default)
        
        variants:
        - * bandwidth
        - no_bandwidth(default)

        variants:
        - * keep_relative
        - no_keep_relative(default)
        
    - blockcopy
        - * dest_xml: Refer to disk xml matrix
        
        variants:
        - * shallow
        - * no_shallow(default)
        
        variants:
        - * bandwidth
        - no_bandwidth(default)

        variants:
        - * keep_relative
        - no_keep_relative(default)
        
        variants:
        - * pivot
        - * finish

        variants:
        - * timeout
        - * granularity
        - * buf-size
        - transient-job
    
    - blockpull
        variants:
        - * bandwidth
        - no_bandwidth(default)

        variants:
        - * keep_relative
        - no_keep_relative(default)
        
    - * blkthreshold
    
    - * blkdeviotune
        - * inactive set(by xml)
        - * active set
      
    - block-resize
    
    - * domblkstat
    
    - * domblkinfo

    - * storage-migration
        - dest_xml: Refer to source xml
        variants:
        - * tls
        - no_tls

Known issues:
1. copy_on_read_on with blockcommit, blocked by https://bugzilla.redhat.com/show_bug.cgi?id=1594747
2. gluster external snapshots with multi-hosts xml, https://bugzilla.redhat.com/show_bug.cgi?id=1447694

Verified on libvirt-6.0.0-17.module+el8.2.0+6257+0d066c28.x86_64 qemu-kvm-4.2.0-17.module+el8.2.0+6141+0f540f16.x86_64

Comment 57 errata-xmlrpc 2020-05-05 09:43:16 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, 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:2017

Comment 58 Han Han 2020-05-11 03:05:13 UTC
Covered in following tp-libvirt cases:
virtual_disk*
*block_copy*
*block_commit*
*snapshot*
*attach*

Comment 59 Peter Krempa 2020-09-15 15:36:54 UTC
*** Bug 1856244 has been marked as a duplicate of this bug. ***