Bug 1835662 - Allow snapshot creation and blockCopy on read-only drives [rhel-8.2.0.z]
Summary: Allow snapshot creation and blockCopy on read-only drives [rhel-8.2.0.z]
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux Advanced Virtualization
Classification: Red Hat
Component: libvirt
Version: 8.2
Hardware: Unspecified
OS: Unspecified
high
unspecified
Target Milestone: rc
: 8.3
Assignee: Peter Krempa
QA Contact: yisun
URL:
Whiteboard:
Depends On: 1832204
Blocks: 1759933
TreeView+ depends on / blocked
 
Reported: 2020-05-14 09:55 UTC by Oneata Mircea Teodor
Modified: 2020-11-06 03:58 UTC (History)
15 users (show)

Fixed In Version: libvirt-6.0.0-17.2.el8
Doc Type: If docs needed, set a value
Doc Text:
Clone Of: 1832204
Environment:
Last Closed: 2020-06-15 14:10:17 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2020:2552 0 None None None 2020-06-15 14:10:28 UTC

Comment 7 yisun 2020-05-25 08:21:59 UTC
tested with libvirt-6.0.0-17.2.module+el8.2.0+6629+3fc0f2c2.x86_64 and result is PASS

1. start a vm with two disks, we'll use vdb to test this, which is a readonly disk
[root@dell-per730-67 ~]# qemu-img create -f qcow2 /var/lib/libvirt/images/vdb.qcow2 1G
Formatting '/var/lib/libvirt/images/vdb.qcow2', fmt=qcow2 size=1073741824 cluster_size=65536 lazy_refcounts=off refcount_bits=16

[root@dell-per730-67 ~]# virsh start vm1
virsDomain vm1 started

[root@dell-per730-67 ~]# virsh domblklist vm1
 Target   Source
--------------------------------------------------------
 vda      /var/lib/libvirt/images/jeos-27-x86_64.qcow2
 vdb      /var/lib/libvirt/images/vdb.qcow2


[root@dell-per730-67 ~]# virsh dumpxml vm1 | awk '/<disk/,/<\/disk/'
    <disk type='file' device='disk' snapshot='no'>
      <driver name='qemu' type='qcow2'/>
      <source file='/var/lib/libvirt/images/jeos-27-x86_64.qcow2' index='2'/>
      <backingStore/>
      <target dev='vda' bus='virtio'/>
      <alias name='virtio-disk0'/>
      <address type='pci' domain='0x0000' bus='0x04' slot='0x00' function='0x0'/>
    </disk>
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/var/lib/libvirt/images/vdb.qcow2' index='1'/>
      <backingStore/>
      <target dev='vdb' bus='virtio'/>
      <readonly/>
      <alias name='virtio-disk1'/>
      <address type='pci' domain='0x0000' bus='0x07' slot='0x00' function='0x0'/>
    </disk>

2. create external snapshot for it
[root@dell-per730-67 ~]# qemu-img create -f qcow2 /var/lib/libvirt/images/vdb.snap1 1G
Formatting '/var/lib/libvirt/images/vdb.snap1', fmt=qcow2 size=1073741824 cluster_size=65536 lazy_refcounts=off refcount_bits=16


[root@dell-per730-67 ~]# virsh snapshot-create-as vm1 snap1 --disk-only --diskspec vdb,snapshot=external,file=/var/lib/libvirt/images/vdb.snap1 --no-metadata --reuse-external
Domain snapshot snap1 created

3. copy the base image with qemu-img convert
[root@dell-per730-67 ~]# qemu-img convert -f qcow2 /var/lib/libvirt/images/vdb.qcow2 -O qcow2 /tmp/vdb_copy.qcow2

4. do blockcopy --shallow
[root@dell-per730-67 ~]# virsh blockcopy vm1 vdb /tmp/vdb_shallow.qcow2 --shallow --transient-job
Block Copy started

[root@dell-per730-67 ~]# virsh dumpxml vm1 | awk '/<disk/,/<\/disk/'
    <disk type='file' device='disk' snapshot='no'>
      <driver name='qemu' type='qcow2'/>
      <source file='/var/lib/libvirt/images/jeos-27-x86_64.qcow2' index='2'/>
      <backingStore/>
      <target dev='vda' bus='virtio'/>
      <alias name='virtio-disk0'/>
      <address type='pci' domain='0x0000' bus='0x04' slot='0x00' function='0x0'/>
    </disk>
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/var/lib/libvirt/images/vdb.snap1' index='3'/>
      <backingStore type='file' index='1'>
        <format type='qcow2'/>
        <source file='/var/lib/libvirt/images/vdb.qcow2'/>
        <backingStore/>
      </backingStore>
      <mirror type='file' file='/tmp/vdb_shallow.qcow2' format='qcow2' job='copy' ready='yes'>
        <format type='qcow2'/>
        <source file='/tmp/vdb_shallow.qcow2' index='4'/>
      </mirror>
      <target dev='vdb' bus='virtio'/>
      <readonly/>
      <alias name='virtio-disk1'/>
      <address type='pci' domain='0x0000' bus='0x07' slot='0x00' function='0x0'/>
    </disk>

5. move to the copied target
[root@dell-per730-67 ~]# virsh blockjob vm1 vdb --pivot

[root@dell-per730-67 ~]# virsh dumpxml vm1 | awk '/<disk/,/<\/disk/'
    <disk type='file' device='disk' snapshot='no'>
      <driver name='qemu' type='qcow2'/>
      <source file='/var/lib/libvirt/images/jeos-27-x86_64.qcow2' index='2'/>
      <backingStore/>
      <target dev='vda' bus='virtio'/>
      <alias name='virtio-disk0'/>
      <address type='pci' domain='0x0000' bus='0x04' slot='0x00' function='0x0'/>
    </disk>
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/tmp/vdb_shallow.qcow2' index='4'/>
      <backingStore type='file' index='1'>
        <format type='qcow2'/>
        <source file='/var/lib/libvirt/images/vdb.qcow2'/>
        <backingStore/>
      </backingStore>
      <target dev='vdb' bus='virtio'/>
      <readonly/>
      <alias name='virtio-disk1'/>
      <address type='pci' domain='0x0000' bus='0x07' slot='0x00' function='0x0'/>
    </disk>

6. do blockcommit to remove the active layer
[root@dell-per730-67 ~]# virsh blockcommit vm1 vdb --top vdb[4] --base vdb[1] --active --pivot
Successfully pivoted

Comment 9 errata-xmlrpc 2020-06-15 14:10:17 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:2552


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