dguerri / LibVirtKvm-scripts

Libvirt/KVM scripts - online forward incremental backup for libvirt/KVM virtual machines
GNU General Public License v3.0
72 stars 25 forks source link

blockcommit completes successfully if I change virtual disk Cache mode from Hypervisor default to none #42

Open MaxiReglisse opened 6 years ago

MaxiReglisse commented 6 years ago

Consolidation failed this morning, with the following error: "block copy still active: disk 'sda' not ready for pivot yet".

# LANG=en_US.UTF-8 && /usr/local/bin/fi-backup.sh -c -b /var/lib/libvirt/backups/ubuntu  -d ubuntu
[INF] libVirt version '1.3.1' support is experimental
[DEB] /usr/bin/qemu-img version '2.5.0' is supported
[DEB] QEMU/KVM version '2.5.0' is supported
[DEB] Domains NOTRUNNING to backup: 
[DEB] Domains RUNNING to backup:  ubuntu
[DEB] Consolidation of block devices for 'ubuntu' requested
[DEB] Block devices to be consolidated:
/var/lib/libvirt/images/ubuntu.bimg-20180824-161701
[DEB] Consolidation method: blockcommit
[DEB] Consolidation of '0' block device: '/var/lib/libvirt/images/ubuntu.bimg-20180824-161701' for 'ubuntu'
[DEB] Parent block device: '/var/lib/libvirt/images/ubuntu.bimg-20180824-151702'
[ERR] Error consolidating block device '/var/lib/libvirt/images/ubuntu.bimg-20180824-161701' for 'ubuntu':
 error: failed to pivot job for disk /var/lib/libvirt/images/ubuntu.bimg-20180824-161701
error: block copy still active: disk 'sda' not ready for pivot yet

The libvirt images directory contained the following files:

# ls -ltr /var/lib/libvirt/images/ubuntu*
-rw------- 1 libvirt-qemu kvm  1179254784 Aug 24 14:54 /var/lib/libvirt/images/ubuntu.bimg-20180824-144024
-rw------- 1 libvirt-qemu kvm   232194048 Aug 24 15:15 /var/lib/libvirt/images/ubuntu.bimg-20180824-145422
-rw------- 1 libvirt-qemu kvm     5308416 Aug 24 16:17 /var/lib/libvirt/images/ubuntu.bimg-20180824-151702
-rw------- 1 libvirt-qemu kvm   361168896 Aug 27 11:50 /var/lib/libvirt/images/ubuntu.bimg-20180824-161701
-rw-r-xr-- 1 libvirt-qemu kvm 14377746432 Aug 27 11:50 /var/lib/libvirt/images/ubuntu.qcow2

I tried to see if there were some errors in ubuntu.bimg-* files, but everything seemed normal.

# virsh blockjob ubuntu /var/lib/libvirt/images/ubuntu.bimg-20180824-161701 --info
Active Block Commit: [100 %]

# qemu-img info /var/lib/libvirt/images/ubuntu.bimg-20180824-161701
image: /var/lib/libvirt/images/ubuntu.bimg-20180824-161701
file format: qcow2
virtual size: 16G (17179869184 bytes)
disk size: 344M
cluster_size: 65536
backing file: /var/lib/libvirt/images/ubuntu.bimg-20180824-151702 
backing file format: qcow2
Format specific information:
    compat: 1.1
    lazy refcounts: false
    refcount bits: 16
    corrupt: false

I tried different things, but to no avail...

# virsh blockjob ubuntu sda --abort
# /usr/bin/virsh -q blockcommit ubuntu /var/lib/libvirt/images/ubuntu.bimg-20180824-161701 --wait --pivot --active
error: failed to pivot job for disk /var/lib/libvirt/images/ubuntu.bimg-20180824-161701
error: block copy still active: disk 'sda' not ready for pivot yet

Finally, as suggested here, i changed the virtual disk Cache mode from Hypervisor default to none... and then blockcommit completed successfully!

# LANG=en_US.UTF-8 && /usr/local/bin/fi-backup.sh -c -b /var/lib/libvirt/backups/ubuntu  -d ubuntu
[INF] libVirt version '1.3.1' support is experimental
[DEB] /usr/bin/qemu-img version '2.5.0' is supported
[DEB] QEMU/KVM version '2.5.0' is supported
[DEB] Domains NOTRUNNING to backup: 
[DEB] Domains RUNNING to backup:  ubuntu
[DEB] Consolidation of block devices for 'ubuntu' requested
[DEB] Block devices to be consolidated:
/var/lib/libvirt/images/ubuntu.bimg-20180824-161701
[DEB] Consolidation method: blockcommit
[DEB] Consolidation of '0' block device: '/var/lib/libvirt/images/ubuntu.bimg-20180824-161701' for 'ubuntu'
[DEB] Parent block device: '/var/lib/libvirt/images/ubuntu.bimg-20180824-151702'
[VER] Consolidation of block device '/var/lib/libvirt/images/ubuntu.bimg-20180824-161701' for 'ubuntu' successful
[DEB] Not deleting last element of snapshot_chain (top parent) since consolidation method='blockcommit'
[VER] Deleting old backing files for 'ubuntu'
[VER] Deleting old backing file '/var/lib/libvirt/images/ubuntu.bimg-20180824-161701' for 'ubuntu'
[VER] Deleting old backing file '/var/lib/libvirt/images/ubuntu.bimg-20180824-151702' for 'ubuntu'
[VER] Deleting old backing file '/var/lib/libvirt/images/ubuntu.bimg-20180824-145422' for 'ubuntu'
[VER] Deleting old backing file '/var/lib/libvirt/images/ubuntu.bimg-20180824-144024' for 'ubuntu'

What do you think? The proposed solution is 3 years old... Is this bug still relevant?

Thanks in advance.