<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hello Everyone,<div><br></div><div>I've been trying to come up with a solution for libvirt snapshots to fix the issue with snapshotting when a volume is attached:</div><div><br></div><div><a href="https://bugs.launchpad.net/nova/+bug/946830">https://bugs.launchpad.net/nova/+bug/946830</a></div><div><br></div><div>The main issue here is that calling snapshot in libvirt makes an internal snapshot of the entire vm, which a) doesn't work for attached volumes b) wastes a bunch of space while snapshotting memory and ephemeral disks which aren't used.</div><div><br></div><div>There are two potential approaches to solving the issue, and I've prototyped them below. I need feedback on which approach is better.</div><div><br></div><div>OPTION A --> snapshot using qemu-img  </div><div><br></div><div>This method shuts down the vm and uses qemu-img to create the snapshot in the disk image</div><div><br></div><div>Pros:</div><div>works with older versions of libvirt</div><div><br></div><div>Cons:</div><div>shutting off the vm during snapshotting is overkill and annoying</div><div><br></div><div>Caveats:</div><div>  if it is safe to create disk file snapshots while libvirt has a file handle open, i can use suspend/resume which is better than managedSave.</div><div> If it is safe to delete snapshots while the disk is being written to, i can resume sooner, minimizing pause time</div><div> if it is additionally safe to create snapshots while the disk is being written to, we can avoid pausing the vm altogether! (sounds dangerous though)</div><div><br></div><div><a href="https://github.com/vishvananda/nova/blob/fix-libvirt-snapshot-old/nova/virt/libvirt/connection.py#L619">https://github.com/vishvananda/nova/blob/fix-libvirt-snapshot-old/nova/virt/libvirt/connection.py#L619</a></div><div><br></div><div>OPTION B --> libvirt 9.5 snapshots</div><div><br></div><div>This method uses the newer snapshot xml in libvirt 9.5 to snapshot only the root disk.</div><div><br></div><div>Pros:</div><div>plays nicely with libvirt, so the vm is only paused for the minimum amount of time</div><div>Cons:</div><div>requires libvirt 9.5, which doesn't exist in oneiric</div><div><br></div><div>Caveats:</div><div> This code is untested and a couple tests don't pass yet because I haven't made an oneiric vm. I want to make sure this is the right approach before I go through the hassle of updating.</div><div><br></div><div><a href="https://github.com/vishvananda/nova/blob/fix-libvirt-snapshot/nova/virt/libvirt/connection.py#L619">https://github.com/vishvananda/nova/blob/fix-libvirt-snapshot/nova/virt/libvirt/connection.py#L619</a></div><div><br></div><div>So I could use some specific feedback from kvm/libvirt folks on the following questions:</div><div><br></div><div>a) is it safe to use qemu-img to create/delete a snapshot in a disk file that libvirt is writing to.</div><div>if not:</div><div>b) is it safe to use qemu-img to delete a snapshot in a disk file that libvirt is writing to but not actively using.</div><div>if not:</div><div>c) is it safe to use qemu-img to create/delete a snapshot in a disk file that libvirt has an open file handle to.</div><div><br></div><div>And I could use input from the community on which of the approaches above to use:</div><div><br></div><div><b>Do we standardize on libvirt 9.5+? or do we use the compatible version that causes a bigger outage during the snapshot?</b></div><div><br></div><div>Ideal for me would be that at least b) above is true and we can get by with the compatible version.</div><div><br></div><div>Vish</div></body></html>