Bug 1804593 - incremental-backup: RFE: Allow incremental backups with externally-created snapshots
Summary: incremental-backup: RFE: Allow incremental backups with externally-created sn...
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
unspecified
unspecified
Target Milestone: rc
: 8.0
Assignee: Peter Krempa
QA Contact: yisun
URL:
Whiteboard:
Depends On:
Blocks: 1139877 1799015 1861667
TreeView+ depends on / blocked
 
Reported: 2020-02-19 08:46 UTC by Peter Krempa
Modified: 2020-07-29 08:30 UTC (History)
10 users (show)

Fixed In Version: libvirt-6.0.0-25.el8
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2020-07-28 07:12:15 UTC
Type: Feature Request
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
make_chain.py (1.80 KB, text/plain)
2020-07-01 10:36 UTC, yisun
no flags Details
create_external_snapshot.sh (849 bytes, text/plain)
2020-07-01 10:37 UTC, yisun
no flags Details


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2020:3172 0 None None None 2020-07-28 07:13:29 UTC

Description Peter Krempa 2020-02-19 08:46:00 UTC
For offline VMs oVirt creates snapshots themselves by adding an overlay. Since that overlay does not have the bitmaps from the backing file we would not be able to create an incremental backup.

We will have to use the new feature of qemu which allows conversion of an qcow2 allocation map into a bitmap so that we can re-construct the necessary bitmap topology to allow incremental backups.

Comment 3 Yash Mankad 2020-03-13 18:53:58 UTC
Granting pm_ack, devel_ack

@Yi - could you kindly grant qa_ack ?

Comment 10 yisun 2020-07-01 09:53:26 UTC
Tested with: libvirt-6.0.0-25.module+el8.2.1+7154+47ffd890.x86_64
Result: PASS
Senario 1: a basic full+inc backup process
1. In vm, mkfs+mount vdb and add a file to it
[root@localhost mnt]# cat bkup_content
full backup: todo

2. Prepare full backup xmls
[root@dell-per730-61 bz]# cat bk1.xml ck1.xml
<domainbackup mode="push"><disks><disk backup="no" name="vda" /><disk backup="yes" name="vdb" type="file"><target file="/tmp/vdb.bkup.1" /><driver type="qcow2" /></disk></disks></domainbackup>
<domaincheckpoint><disks><disk checkpoint="no" name="vda" /><disk checkpoint="bitmap" name="vdb" /></disks><name>ck1</name></domaincheckpoint>

3. Start full backup
[root@dell-per730-61 bz]# virsh backup-begin vm1 bk1.xml ck1.xml
Backup started


[root@dell-per730-61 bz]# virsh domjobinfo vm1 --completed
Job type:         Completed
Operation:        Backup
Time elapsed:     125          ms
File processed:   100.000 MiB
File remaining:   0.000 B
File total:       100.000 MiB


[root@dell-per730-61 bz]# virsh checkpoint-list vm1
 Name   Creation Time
-----------------------------------
 ck1    2020-06-29 04:01:28 -0400


4. Check vdb's img has correct bitmap info
[root@dell-per730-61 bz]# qemu-img info /var/lib/libvirt/images/bz/vdb.qcow2 -f qcow2 --output=json
{
    "virtual-size": 104857600,
    "filename": "/var/lib/libvirt/images/bz/vdb.qcow2",
    "cluster-size": 65536,
    "format": "qcow2",
    "actual-size": 1318912,
    "format-specific": {
        "type": "qcow2",
        "data": {
            "compat": "1.1",
            "lazy-refcounts": false,
            "bitmaps": [
                {
                    "flags": [
                        "auto"
                    ],
                    "name": "ck1",
                    "granularity": 65536
                }
            ],
            "refcount-bits": 16,
            "corrupt": false
        }
    },
    "dirty-flag": false
}

5. Modify the file in vdb
[root@localhost ~]# cat /mnt/bkup_content
full backup: done
inc backup 1: todo

6. Start the incremental backup 1
[root@dell-per730-61 bz]# cat bk2.xml ck2.xml
<domainbackup mode="push"><incremental>ck1</incremental><disks><disk backup="no" name="vda" /><disk backup="yes" name="vdb" type="file"><target file="/tmp/vdb.bkup.2" /><driver type="qcow2" /></disk></disks></domainbackup>
<domaincheckpoint><disks><disk checkpoint="no" name="vda" /><disk checkpoint="bitmap" name="vdb" /></disks><name>ck2</name></domaincheckpoint>


[root@dell-per730-61 bz]# virsh backup-begin vm1 bk2.xml ck2.xml
Backup started

[root@dell-per730-61 bz]# virsh domjobinfo vm1 --completed
Job type:         Completed
Operation:        Backup
Time elapsed:     204          ms
File processed:   320.000 KiB
File remaining:   0.000 B
File total:       320.000 KiB

7. Check the vdb's img has correct bitmap info
[root@dell-per730-61 bz]# qemu-img info /var/lib/libvirt/images/bz/vdb.qcow2 -f qcow2 --output=json
{
    "virtual-size": 104857600,
    "filename": "/var/lib/libvirt/images/bz/vdb.qcow2",
    "cluster-size": 65536,
    "format": "qcow2",
    "actual-size": 2494464,
    "format-specific": {
        "type": "qcow2",
        "data": {
            "compat": "1.1",
            "lazy-refcounts": false,
            "bitmaps": [
                {
                    "flags": [
                        "auto"
                    ],
                    "name": "ck1",
                    "granularity": 65536
                },
                {
                    "flags": [
                        "auto"
                    ],
                    "name": "ck2",
                    "granularity": 65536
                }
            ],
            "refcount-bits": 16,
            "corrupt": false
        }
    },
    "dirty-flag": false
}

8. Create a libvirt-controlled snapshot
[root@dell-per730-61 bz]# virsh snapshot-create-as vm1 snap_1 --disk-only --diskspec vda,snapshot=no --diskspec vdb,snapshot=external
Domain snapshot snap_1 created

[root@dell-per730-61 bz]# virsh destroy vm1

9. Check the snapshot img contains correct bitmap info
[root@dell-per730-61 bz]# qemu-img info /var/lib/libvirt/images/bz/vdb.snap_1 --output=json
{
    "backing-filename-format": "qcow2",
    "virtual-size": 104857600,
    "filename": "/var/lib/libvirt/images/bz/vdb.snap_1",
    "cluster-size": 65536,
    "format": "qcow2",
    "actual-size": 397312,
    "format-specific": {
        "type": "qcow2",
        "data": {
            "compat": "1.1",
            "lazy-refcounts": false,
            "bitmaps": [
                {
                    "flags": [
                        "auto"
                    ],
                    "name": "ck1",
                    "granularity": 65536
                },
                {
                    "flags": [
                        "auto"
                    ],
                    "name": "ck2",
                    "granularity": 65536
                }
            ],
            "refcount-bits": 16,
            "corrupt": false
        }
    },
    "full-backing-filename": "/var/lib/libvirt/images/bz/vdb.qcow2",
    "backing-filename": "/var/lib/libvirt/images/bz/vdb.qcow2",
    "dirty-flag": false
}

10. do a externally-craeted snapshot
[root@dell-per730-61 bz]# sh add_bitmap.sh vdb.external_snap.2 vdb.sanp_1
Formatting 'vdb.external_snap.2', fmt=qcow2 size=104857600 backing_file=vdb.snap_1 backing_fmt=qcow2 cluster_size=65536 lazy_refcounts=off refcount_bits=16

[root@dell-per730-61 bz]# qemu-img info /var/lib/libvirt/images/bz/vdb.external_snap.2 --output=json
{
    "backing-filename-format": "qcow2",
    "virtual-size": 104857600,
    "filename": "/var/lib/libvirt/images/bz/vdb.external_snap.2",
    "cluster-size": 65536,
    "format": "qcow2",
    "actual-size": 405504,
    "format-specific": {
        "type": "qcow2",
        "data": {
            "compat": "1.1",
            "lazy-refcounts": false,
            "bitmaps": [
                {
                    "flags": [
                        "auto"
                    ],
                    "name": "ck1",
                    "granularity": 65536
                },
                {
                    "flags": [
                        "auto"
                    ],
                    "name": "ck2",
                    "granularity": 65536
                }
            ],
            "refcount-bits": 16,
            "corrupt": false
        }
    },
    "full-backing-filename": "/var/lib/libvirt/images/bz/vdb.snap_1",
    "backing-filename": "vdb.snap_1",
    "dirty-flag": false
}


11. Use the snapshot as vdb's img
[root@dell-per730-61 bz]# virsh start vm1
Domain vm1 started

[root@dell-per730-61 bz]# virsh dumpxml vm1 | awk '/<disk/,/<\/disk/'
...
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/var/lib/libvirt/images/bz/vdb.external_snap.2' index='1'/>
      <backingStore type='file' index='3'>
        <format type='qcow2'/>
        <source file='/var/lib/libvirt/images/bz/vdb.snap_1'/>
        <backingStore type='file' index='4'>
          <format type='qcow2'/>
          <source file='/var/lib/libvirt/images/bz/vdb.qcow2'/>
          <backingStore/>
        </backingStore>
      </backingStore>
      <target dev='vdb' bus='virtio'/>
      <alias name='virtio-disk1'/>
      <address type='pci' domain='0x0000' bus='0x07' slot='0x00' function='0x0'/>
    </disk>

12. Modify the file in vdb
[root@localhost ~]# cat /mnt/bkup_content
full backup: done
inc backup 1: done
inc backup 2: todo

13. Do incremental backup round 2
[root@dell-per730-61 bz]# cat bk3.xml ck3.xml
<domainbackup mode="push"><incremental>ck2</incremental><disks><disk backup="no" name="vda" /><disk backup="yes" name="vdb" type="file"><target file="/tmp/vdb.bkup.3" /><driver type="qcow2" /></disk></disks></domainbackup>
<domaincheckpoint><disks><disk checkpoint="no" name="vda" /><disk checkpoint="bitmap" name="vdb" /></disks><name>ck3</name></domaincheckpoint>


[root@dell-per730-61 bz]# virsh backup-begin vm1 bk3.xml ck3.xml
Backup started

[root@dell-per730-61 bz]# virsh domjobinfo vm1 --completed
Job type:         Completed
Operation:        Backup
Time elapsed:     114          ms
File processed:   320.000 KiB
File remaining:   0.000 B
File total:       320.000 KiB

14. Do differential backup 
[root@dell-per730-61 bz]# cat bk_diff.xml ck_diff.xml
<domainbackup mode="push"><incremental>ck1</incremental><disks><disk backup="no" name="vda" /><disk backup="yes" name="vdb" type="file"><target file="/tmp/vdb.bkup.diff" /><driver type="qcow2" /></disk></disks></domainbackup>
<domaincheckpoint><disks><disk checkpoint="no" name="vda" /><disk checkpoint="bitmap" name="vdb" /></disks><name>ck_diff</name></domaincheckpoint>

[root@dell-per730-61 bz]# virsh backup-begin vm1 bk_diff.xml ck_diff.xml
Backup started

[root@dell-per730-61 bz]# virsh domjobinfo vm1 --completed
Job type:         Completed
Operation:        Backup
Time elapsed:     110          ms
File processed:   384.000 KiB
File remaining:   0.000 B
File total:       384.000 KiB


Scenario 2. Do blockcommit/blockpull with scenario1's snapshot image
====================================================================
1. Start with scenario 1's steps
[root@dell-per730-61 bz]# virsh dumpxml vm1 | awk '/<disk/,/<\/disk/'
...
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/var/lib/libvirt/images/bz/vdb.external_snap.2' index='1'/>
      <backingStore type='file' index='3'>
        <format type='qcow2'/>
        <source file='/var/lib/libvirt/images/bz/vdb.snap_1'/>
        <backingStore type='file' index='4'>
          <format type='qcow2'/>
          <source file='/var/lib/libvirt/images/bz/vdb.qcow2'/>
          <backingStore/>
        </backingStore>
      </backingStore>
      <target dev='vdb' bus='virtio'/>
      <alias name='virtio-disk1'/>
      <address type='pci' domain='0x0000' bus='0x07' slot='0x00' function='0x0'/>
    </disk>

2. Do a blockcommit job from active layer to a middle layer
[root@dell-per730-61 bz]# virsh blockcommit vm1 vdb --top vdb[1] --base vdb[3] --active --pivot
Successfully pivoted

[root@dell-per730-61 bz]# virsh dumpxml vm1 | awk '/<disk/,/<\/disk/'
...
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/var/lib/libvirt/images/bz/vdb.snap_1' index='3'/>
      <backingStore type='file' index='4'>
        <format type='qcow2'/>
        <source file='/var/lib/libvirt/images/bz/vdb.qcow2'/>
        <backingStore/>
      </backingStore>
      <target dev='vdb' bus='virtio'/>
      <alias name='virtio-disk1'/>
      <address type='pci' domain='0x0000' bus='0x07' slot='0x00' function='0x0'/>
    </disk>

3. Modify the file in vdb
[root@localhost ~]# cat /mnt/bkup_content
full backup: done
inc backup 1: done
inc backup 2: done
inc backup 3: todo

4. Do incremental backup round 3
[root@dell-per730-61 bz]# cat bk4.xml ck4.xml
<domainbackup mode="push"><incremental>ck3</incremental><disks><disk backup="no" name="vda" /><disk backup="yes" name="vdb" type="file"><target file="/tmp/vdb.bkup.4" /><driver type="qcow2" /></disk></disks></domainbackup>
<domaincheckpoint><disks><disk checkpoint="no" name="vda" /><disk checkpoint="bitmap" name="vdb" /></disks><name>ck4</name></domaincheckpoint>


[root@dell-per730-61 bz]# virsh backup-begin vm1 bk4.xml ck4.xml
Backup started

[root@dell-per730-61 bz]# virsh domjobinfo vm1 --completed
Job type:         Completed
Operation:        Backup
Time elapsed:     211          ms
File processed:   320.000 KiB
File remaining:   0.000 B
File total:       320.000 KiB


[root@dell-per730-61 bz]# virsh dumpxml vm1 | awk '/<disk/,/<\/disk/'
...
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/var/lib/libvirt/images/bz/vdb.snap_1' index='1'/>
      <backingStore type='file' index='3'>
        <format type='qcow2'/>
        <source file='/var/lib/libvirt/images/bz/vdb.qcow2'/>
        <backingStore/>
      </backingStore>
      <target dev='vdb' bus='virtio'/>
      <alias name='virtio-disk1'/>
      <address type='pci' domain='0x0000' bus='0x07' slot='0x00' function='0x0'/>
    </disk>

5. Modify the file on vdb
[root@localhost ~]# cat /mnt/bkup_content
full backup: done
inc backup 1: done
inc backup 2: done
inc backup 3: done
inc backup 4: todo

6. Do incremental backup round 4
[root@dell-per730-61 bz]# cat bk5.xml ck5.xml
<domainbackup mode="push"><incremental>ck4</incremental><disks><disk backup="no" name="vda" /><disk backup="yes" name="vdb" type="file"><target file="/tmp/vdb.bkup.5" /><driver type="qcow2" /></disk></disks></domainbackup>
<domaincheckpoint><disks><disk checkpoint="no" name="vda" /><disk checkpoint="bitmap" name="vdb" /></disks><name>ck5</name></domaincheckpoint>

[root@dell-per730-61 bz]# virsh backup-begin vm1 bk5.xml ck5.xml
Backup started

[root@dell-per730-61 bz]# virsh domjobinfo vm1 --completed
Job type:         Completed
Operation:        Backup
Time elapsed:     129          ms
File processed:   320.000 KiB
File remaining:   0.000 B
File total:       320.000 KiB

7. Check the vdb image contains correct bitmap
[root@dell-per730-61 bz]# qemu-img info /var/lib/libvirt/images/bz/vdb.snap_1
image: /var/lib/libvirt/images/bz/vdb.snap_1
file format: qcow2
virtual size: 100 MiB (104857600 bytes)
disk size: 2.45 MiB
cluster_size: 65536
backing file: /var/lib/libvirt/images/bz/vdb.qcow2
backing file format: qcow2
Format specific information:
    compat: 1.1
    lazy refcounts: false
    bitmaps:
        [0]:
            flags:
                [0]: auto
            name: ck1
            granularity: 65536
        [1]:
            flags:
                [0]: auto
            name: ck2
            granularity: 65536
        [2]:
            flags:
                [0]: auto
            name: ck4
            granularity: 65536
        [3]:
            flags:
                [0]: auto
            name: ck3
            granularity: 65536
        [4]:
            flags:
                [0]: auto
            name: ck_diff
            granularity: 65536
        [5]:
            flags:
                [0]: auto
            name: ck5
            granularity: 65536
    refcount bits: 16
    corrupt: false

8. Make a disk chain of all the backup files
[root@dell-per730-61 bz]# python make_chain.py vdb.bkup.1 vdb.bkup.2 vdb.bkup.3 vdb.bkup.4 vdb.bkup.5
Making Chain: 'vdb.bkup.2.copy' based on 'vdb.bkup.1.copy'
Making Chain: 'vdb.bkup.3.copy' based on 'vdb.bkup.2.copy'
Making Chain: 'vdb.bkup.4.copy' based on 'vdb.bkup.3.copy'
Making Chain: 'vdb.bkup.5.copy' based on 'vdb.bkup.4.copy'

NOW THE CHAIN IS:
======================================================================
	vdb.bkup.1.copy <=== vdb.bkup.2.copy <=== vdb.bkup.3.copy <=== vdb.bkup.4.copy <=== vdb.bkup.5.copy
======================================================================

9. Check the content of the backup files
[root@dell-per730-61 bz]# virsh start vm1
Domain vm1 started

[root@dell-per730-61 bz]# virsh domblklist vm1 | grep vdb
 vdb      /var/lib/libvirt/images/bz/vdb.bkup.5.copy

[root@localhost ~]# cat /mnt/bkup_content
full backup: done
inc backup 1: done
inc backup 2: done
inc backup 3: done
inc backup 4: todo

[root@dell-per730-61 bz]# virsh start vm1
Domain vm1 started

[root@dell-per730-61 bz]# virsh domblklist vm1 | grep vdb
 vdb      /var/lib/libvirt/images/bz/vdb.bkup.4.copy

[root@localhost ~]# cat /mnt/bkup_content
full backup: done
inc backup 1: done
inc backup 2: done
inc backup 3: todo


[root@dell-per730-61 bz]# virsh start vm1
Domain vm1 started

[root@dell-per730-61 bz]# virsh domblklist vm1 | grep vdb
 vdb      /var/lib/libvirt/images/bz/vdb.bkup.3.copy

[root@localhost ~]# cat /mnt/bkup_content
full backup: done
inc backup 1: done
inc backup 2: todo

[root@dell-per730-61 bz]# virsh start vm1
dDomain vm1 started

[root@dell-per730-61 bz]# virsh domblklist vm1 | grep vdb
 vdb      /var/lib/libvirt/images/bz/vdb.bkup.2.copy

[root@localhost ~]# cat /mnt/bkup_content
full backup: done
inc backup 1: todo

[root@dell-per730-61 bz]# virsh start vm1
Domain vm1 started

[root@dell-per730-61 bz]# virsh domblklist vm1 | grep vdb
 vdb      /var/lib/libvirt/images/bz/vdb.bkup.1.copy

[root@localhost ~]# cat /mnt/bkup_content
full backup: todo

========================================================================================================================================================================
Scenario 3. Test the externally created snapshot with blockcopy job

blockcopy --reuse-external

[root@localhost ~]# cat /mnt/bkup.file
full backup: todo

[root@dell-per730-61 bz]# virsh backup-begin vm1 bk1.xml ck1.xml
Backup started

[root@dell-per730-61 bz]# virsh domjobinfo vm1 --completed
Job type:         Completed
Operation:        Backup
Time elapsed:     212          ms
File processed:   100.000 MiB
File remaining:   0.000 B
File total:       100.000 MiB



[root@dell-per730-61 bz]# virsh destroy vm1
Domain vm1 destroyed

[root@dell-per730-61 bz]# sh add_bitmap.sh
Formatting 'test.qcow2', fmt=qcow2 size=104857600 backing_file=vdb.qcow2 backing_fmt=qcow2 cluster_size=65536 lazy_refcounts=off refcount_bits=16

[root@dell-per730-61 bz]# virsh start vm1
Domain vm1 started

[root@dell-per730-61 bz]# virsh dumpxml vm1 | awk '/<disk/,/<\/disk/'
...
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/var/lib/libvirt/images/bz/test.qcow2' index='1'/>
      <backingStore type='file' index='3'>
        <format type='qcow2'/>
        <source file='/var/lib/libvirt/images/bz/vdb.qcow2'/>
        <backingStore/>
      </backingStore>
      <target dev='vdb' bus='virtio'/>
      <alias name='virtio-disk1'/>
      <address type='pci' domain='0x0000' bus='0x07' slot='0x00' function='0x0'/>
    </disk>

[root@dell-per730-61 bz]# qemu-img create -f qcow2 vdb.blockcopy 100M
Formatting 'vdb.blockcopy', fmt=qcow2 size=104857600 cluster_size=65536 lazy_refcounts=off refcount_bits=16

[root@dell-per730-61 bz]# virsh blockcopy vm1 vdb /var/lib/libvirt/images/bz/vdb.blockcopy --reuse-external --transient-job
Block job started

[root@dell-per730-61 bz]# virsh dumpxml vm1 | awk '/<disk/,/<\/disk/'
...
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/var/lib/libvirt/images/bz/test.qcow2' index='1'/>
      <backingStore type='file' index='3'>
        <format type='qcow2'/>
        <source file='/var/lib/libvirt/images/bz/vdb.qcow2'/>
        <backingStore/>
      </backingStore>
      <mirror type='file' file='/var/lib/libvirt/images/bz/vdb.blockcopy' format='qcow2' job='copy' ready='yes'>
        <format type='qcow2'/>
        <source file='/var/lib/libvirt/images/bz/vdb.blockcopy' index='4'/>
        <backingStore/>
      </mirror>
      <target dev='vdb' bus='virtio'/>
      <alias name='virtio-disk1'/>
      <address type='pci' domain='0x0000' bus='0x07' slot='0x00' function='0x0'/>
    </disk>


[root@localhost ~]# cat /mnt/bkup.file
full backup: done
inc backup 1: todo


[root@dell-per730-61 bz]# virsh blockjob vm1 vdb --pivot

[root@dell-per730-61 bz]# virsh dumpxml vm1 | awk '/<disk/,/<\/disk/'
...
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/var/lib/libvirt/images/bz/vdb.blockcopy'/>
      <backingStore/>
      <target dev='vdb' bus='virtio'/>
      <address type='pci' domain='0x0000' bus='0x07' slot='0x00' function='0x0'/>
    </disk>

[root@dell-per730-61 bz]# virsh backup-begin vm1 bk2.xml ck2.xml
Backup started

[root@localhost ~]# cat /mnt/bkup.file
full backup: done
inc backup 1: done
Inc backup 2: todo


[root@dell-per730-61 bz]# virsh backup-begin vm1 bk3.xml ck3.xml
Backup started

[root@localhost ~]# cat /mnt/bkup.file
full backup: done
inc backup 1: done
Inc backup 2: done
Inc backup 3: todo

[root@dell-per730-61 bz]# python make_chain.py vdb.bkup.1 vdb.bkup.2 vdb.bkup.3
Making Chain: 'vdb.bkup.2.copy' based on 'vdb.bkup.1.copy'
Making Chain: 'vdb.bkup.3.copy' based on 'vdb.bkup.2.copy'

NOW THE CHAIN IS:
======================================================================
	vdb.bkup.1.copy <=== vdb.bkup.2.copy <=== vdb.bkup.3.copy
======================================================================

vdb.bkup.3.copy
[root@localhost ~]# cat /mnt/bkup.file
full backup: done
inc backup 1: done
inc backup 2: todo

vdb.bkup.2.copy 
[root@localhost ~]# cat /mnt/bkup.file
full backup: done
inc backup 1: todo

vdb.bkup.1.copy
[root@localhost ~]# cat /mnt/bkup.file
full backup: todo

[root@dell-per730-61 bz]# virsh destroy vm1
Domain vm1 destroyed




========================================================================================================================================================================
blockcopy --reuse-external --shallow

[root@localhost ~]# cat /mnt/bkup.file
full backup: todo

[root@dell-per730-61 bz]# virsh backup-begin vm1 bk1.xml ck1.xml
Backup started

[root@localhost ~]# cat /mnt/bkup.file
full backup: done
inc backup 1: todo



[root@dell-per730-61 bz]# sh add_bitmap.sh test.qcow2 vdb.qcow2
Formatting 'test.qcow2', fmt=qcow2 size=104857600 backing_file=vdb.qcow2 backing_fmt=qcow2 cluster_size=65536 lazy_refcounts=off refcount_bits=16


[root@dell-per730-61 bz]# qemu-img create -f qcow2 vdb.blockcopy.shallow 100M
Formatting 'vdb.blockcopy.shallow', fmt=qcow2 size=104857600 cluster_size=65536 lazy_refcounts=off refcount_bits=16

[root@dell-per730-61 bz]# virsh start vm1

[root@dell-per730-61 bz]# virsh domblklist vm1
 Target   Source
--------------------------------------------------------
...
 vdb      /var/lib/libvirt/images/bz/test.qcow2

[root@dell-per730-61 bz]# virsh dumpxml vm1 | awk '/<disk/,/<\/disk/'
...
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/var/lib/libvirt/images/bz/test.qcow2' index='1'/>
      <backingStore type='file' index='3'>
        <format type='qcow2'/>
        <source file='/var/lib/libvirt/images/bz/vdb.qcow2'/>
        <backingStore/>
      </backingStore>
      <target dev='vdb' bus='virtio'/>
      <alias name='virtio-disk1'/>
      <address type='pci' domain='0x0000' bus='0x07' slot='0x00' function='0x0'/>
    </disk>

[root@dell-per730-61 bz]# virsh blockcopy vm1 vdb /var/lib/libvirt/images/bz/vdb.blockcopy.shallow --reuse-external --shallow --transient-job --pivot
Successfully pivoted

[root@dell-per730-61 bz]# virsh backup-begin vm1 bk2.xml ck2.xml
Backup started

[root@dell-per730-61 bz]# python make_chain.py vdb.bkup.1 vdb.bkup.2
Making Chain: 'vdb.bkup.2.copy' based on 'vdb.bkup.1.copy'

NOW THE CHAIN IS:
======================================================================
	vdb.bkup.1.copy <=== vdb.bkup.2.copy
======================================================================
vdb.bkup.2.copy
[root@localhost ~]# cat /mnt/bkup.file
full backup: done
inc backup 1: todo

vdb.bkup.1.copy 
[root@localhost ~]# cat /mnt/bkup.file
full backup: todo

========================================================================================================================================================================
blockcopy 
Same steps as blockcopy --reuse-external, but don't prepare the target file in advance
No error happens

========================================================================================================================================================================
blockcopy --shallow
Same steps as blockcopy --shallow --reuse-external, but don't prepare the target file in advance
No error happens

========================================================================================================================================================================
Create multiple externally shutoff snapshots
1. Vm has vdb to be tested
[root@dell-per730-61 bz]# virsh domblklist vm1
 Target   Source
--------------------------------------------------------
...
 vdb      /var/lib/libvirt/images/bz/vdb.qcow2

2. Create a file in vdb
[root@localhost ~]# cat /mnt/bkup.file
full backup: todo

3. Start the full backup
[root@dell-per730-61 bz]# virsh backup-begin vm1 bk1.xml ck1.xml
Backup started

4. Modify the file in vdb
[root@localhost ~]# cat /mnt/bkup.file
full backup: done
inc backup 1: todo

5. Start inc backup 1
[root@dell-per730-61 bz]# virsh backup-begin vm1 bk2.xml ck2.xml
Backup started

6 modify the file in vdb
[root@localhost ~]# cat /mnt/bkup.file
full backup: done
inc backup 1: done
inc backup 2: todo

7. Create shutoff snapshot for 2 rounds
[root@dell-per730-61 bz]# virsh destroy vm1
Domain vm1 destroyed

[root@dell-per730-61 bz]# sh add_bitmap.sh ext_snap1.qcow2 vdb.qcow2
Formatting 'ext_snap1.qcow2', fmt=qcow2 size=104857600 backing_file=vdb.qcow2 backing_fmt=qcow2 cluster_size=65536 lazy_refcounts=off refcount_bits=16
[root@dell-per730-61 bz]# sh add_bitmap.sh ext_snap2.qcow2 ext_snap1.qcow2
Formatting 'ext_snap2.qcow2', fmt=qcow2 size=104857600 backing_file=ext_snap1.qcow2 backing_fmt=qcow2 cluster_size=65536 lazy_refcounts=off refcount_bits=16

8. Use ext_snap2.qcow2 as vdb's iamge now
[root@dell-per730-61 bz]# virsh dumpxml vm1 | awk '/<disk/,/<\/disk/'
...
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/var/lib/libvirt/images/bz/ext_snap2.qcow2' index='1'/>
      <backingStore type='file' index='3'>
        <format type='qcow2'/>
        <source file='/var/lib/libvirt/images/bz/ext_snap1.qcow2'/>
        <backingStore type='file' index='4'>
          <format type='qcow2'/>
          <source file='/var/lib/libvirt/images/bz/vdb.qcow2'/>
          <backingStore/>
        </backingStore>
      </backingStore>
      <target dev='vdb' bus='virtio'/>
      <alias name='virtio-disk1'/>
      <address type='pci' domain='0x0000' bus='0x07' slot='0x00' function='0x0'/>
    </disk>

9. Do incremental backup 2
[root@dell-per730-61 bz]# virsh backup-begin vm1 bk3.xml ck3.xml
Backup started

10. Delete all the checkpoints/bitmaps
[root@dell-per730-61 bz]# virsh checkpoint-delete vm1 ck2
Domain checkpoint ck2 deleted

[root@dell-per730-61 bz]# virsh checkpoint-delete vm1 ck1
Domain checkpoint ck1 deleted

11. Make a diskchain for all the backup files
[root@dell-per730-61 bz]# python make_chain.py vdb.bkup.1 vdb.bkup.2 vdb.bkup.3
Making Chain: 'vdb.bkup.2.copy' based on 'vdb.bkup.1.copy'
Making Chain: 'vdb.bkup.3.copy' based on 'vdb.bkup.2.copy'

NOW THE CHAIN IS:
======================================================================
	vdb.bkup.1.copy <=== vdb.bkup.2.copy <=== vdb.bkup.3.copy
======================================================================

12. Check the backup files contain correct file
vdb.bkup.3.copy
[root@localhost ~]# cat /mnt/bkup.file
full backup: done
inc backup 1: done
inc backup 2: todo

vdb.bkup.2.copy
[root@localhost ~]# cat /mnt/bkup.file
full backup: done
inc backup 1: todo

vdb.bkup.1.copy
[root@localhost ~]# cat /mnt/bkup.file
full backup: todo

Comment 13 yisun 2020-07-01 10:36:49 UTC
Created attachment 1699469 [details]
make_chain.py

Comment 14 yisun 2020-07-01 10:37:19 UTC
Created attachment 1699470 [details]
create_external_snapshot.sh

Comment 15 yisun 2020-07-01 10:38:38 UTC
script used in the test attached.
pls note the create_external_snapshot.sh in attachment is actually the add_bitmap.sh in the test. And this is from the doc in Peter's patches.

Comment 17 errata-xmlrpc 2020-07-28 07:12:15 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:3172


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