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

Add blockcommit support #27

Closed dguerri closed 8 years ago

dguerri commented 8 years ago

Needs to be tested

AJRepo commented 8 years ago

Two issues:

  1. The image which is created is blocked from access by apparmor .Workaround here https://bugs.launchpad.net/ubuntu/+source/libvirt/+bug/696318/comments/9
  2. Deletes everything, including the actual image.
$ls /var/lib/libvirt/images/test*
test_webserver_copy.bimg-20151203-093924

$sudo ./fi-backup.sh -C -v -d testserver

[INF] libVirt version '1.2.16' support is experimental [DEB] /usr/bin/qemu-img version '2.3.0' is supported [DEB] QEMU/KVM version '2.3.0' is supported [DEB] Domains NOTRUNNING: [DEB] Domains RUNNING: testserver [DEB] Snapshot for domain 'testserver' requested [DEB] Using timestamp '20151203-104950' [DEB] Snapshotting block devices for 'testserver' using suffix 'bimg-20151203-104950' [VER] Snapshot for block devices of 'testserver' successful [DEB] No backup directory specified [DEB] Consolidation of block devices for 'testserver' requested [DEB] Block devices to be consolidated: /var/lib/libvirt/images/test_webserver_copy.bimg-20151203-104950 [DEB] Consolidation method: blockcommit
[DEB] Consolidation of block device: '/var/lib/libvirt/images/test_webserver_copy.bimg-20151203-104950' for 'testserver'
[DEB] Parent block device: '/var/lib/libvirt/images/test_webserver_copy.bimg-20151203-093924'
[DEB] ABOUT TO RUN:
/usr/bin/virsh blockcommit testserver /var/lib/libvirt/images/test_webserver_copy.bimg-20151203-104950 --wait --pivot --active
[VER] Consolidation of block device '/var/lib/libvirt/images/test_webserver_copy.bimg-20151203-104950' for 'testserver' successful
[VER] Deleting old backup files for 'testserver' [DEB] Processing old backing file '/var/lib/libvirt/images/test_webserver_copy.bimg-20151203-104950' for 'testserver' [DEB] Parent backing file: '/var/lib/libvirt/images/test_webservercopy.bimg-20151203-093924' **[VER] Deleting backing file '/var/lib/libvirt/images/test_webservercopy.bimg-20151203-104950'** [DEB] Next file in backing file chain: '/var/lib/libvirt/images/test_webserver_copy.bimg-20151203-093924' [DEB] Processing old backing file '/var/lib/libvirt/images/test_webserver_copy.bimg-20151203-093924' for 'testserver' [DEB] Parent backing file: '' [VER] Deleting backing file '/var/lib/libvirt/images/test_webserver_copy.bimg-20151203-093924' [DEB] Next file in backing file chain: ''

$ls /var/lib/libvirt/images/test*
ls: cannot access test*: No such file or directory
dguerri commented 8 years ago

Good catch @AJRepo. About base image deletion, the problem here is that the base image name contained the pattern used to create snapshots. Starting from a different filename, don't trigger that bug. But, yes, that's must be fixed! I think that, bedside the image name, we should also check whether the image has a backing file or not. If not, we can assume it's a base image.

About app armour.. well ¯(ツ)/¯ :D

AJRepo commented 8 years ago

Apparmor: I think part of the problem was that in Ubuntu there's no profile for qemu-system-x86_64 which was being called from libvirtd. So I messed around with

$sudo /usr/sbin/aa-genprof qemu-system-x86_64
$sudo /usr/sbin/aa-complain /usr/bin/qemu-system-x86_64

and overriding libvirtd profile rules in /etc/apparmor.d/local/usr.sbin.libvirtd
but there are a number of qemu-system-* program files so I ultimately just disabled libvirt apparmor profile via creating a soft link in /etc/apparmor.d/disable

$sudo ln -s /etc/apparmor.d/usr.sbin.libvirtd /etc/apparmor.d/disable/usr.sbin.libvirtd

I've started looking at the script to see about iterating through snapshots without pattern recognition.

AJRepo commented 8 years ago

In looking into this, what's reported is that blockcommit isn't necessarily faster than blockpull, but which to use depends on how large the original vs snapshot images are. So I

Commit: https://github.com/AJRepo/LibVirtKvm-scripts/commit/1f230839d40cf0f76f1a3d35bb8c3fa24026def7

Did some basic testing and it seems to work.

dguerri commented 8 years ago

@AJRepo I have pushed your master to mine. Thanks!!!