Note: This is a beta release of Red Hat Bugzilla 5.0. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Also email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback here.

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: ASSIGNED --- QA Contact: Han Han <hhan>
Severity: medium Docs Contact:
Priority: high    
Version: 8.0CC: areis, coli, cpelland, cwei, dchaplyg, dfediuck, dwojslaw, dyuan, dzheng, eblake, fjin, fsimonce, guillaume.pavese, hhan, hhuang, hpopal, jcall, jsuchane, juzhang, kchamart, knoel, kwolf, lmen, meili, michen, mkenneth, moddi, mtessun, mzhan, pkrempa, rcyriac, tburke, virt-maint, xuzhang, yafu, yfu, zpeng
Target Milestone: pre-dev-freezeKeywords: FutureFeature
Target Release: 8.1   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Enhancement
Doc Text:
Story Points: ---
Clone Of: 750801 Environment:
Last Closed: Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Bug Depends On: 1623986, 750801, 1505701, 1513543, 1518738, 1545155, 1557995, 1561960, 1596511, 1626061    
Bug Blocks: 1035038, 1171569, 1436245, 1465810, 1518998, 1518999, 1541702, 1582202, 1582249, 1623877, 1631239, 1688814, 1306562, 1406796, 1406805, 1445598, 1636224    
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.