Uploaded image for project: 'RHEL'
  1. RHEL
  2. RHEL-22797

[libvirt] creating external disk snapshot for offline VM does not require disk-only flag

    • libvirt-10.0.0-3.el9
    • sst_virtualization_storage
    • ssg_virtualization
    • 26
    • Dev ack
    • False
    • Hide

      None

      Show
      None

      What were you trying to do that didn't work?

      The libvirt team asked cockpit-machines in https://issues.redhat.com/browse/RHELBU-1675 to switch from internal to external snapshots when supported (with libvirt ≥ 9.9.0, which is in RHEL 9.4 and Fedora rawhide now; not yet in RHEL 8, 9.3, and Fedora ≤ 39). RHEL-7528 gives some motivation for external snapshots, but they still seem to be somewhat of a stepchild? virsh snapshot-create still creates internal snapshots, https://wiki.libvirt.org/Snapshots.html doesn't talk about this at all, and the only hint that I can find is https://access.redhat.com/documentation/de-de/red_hat_enterprise_linux/7/html/virtualization_deployment_and_administration_guide/sect-troubleshooting-workaround_for_creating_external_snapshots_with_libvirt for how to create an external snapshot on the CLI.

      Simon Kobyda started https://github.com/cockpit-project/cockpit-machines/pull/1280 a while ago to enable external snapshots, but it had been blocked by the availability of libvirt 9.9 in some OSes. That happened recently now, so we can go ahead with this, especially if you want this in RHEL 9.4. I took over that PR, as Simon is no longer at RH – so please assume I don't know any background which isn't written down in Jira

      I noticed that creating external snapshots only works for running VMs (i.e. including a memory snapshot), not for stopped ones. This seems unintuitive to me – a disk snapshot format should be independent on that?

      Please provide the package NVR for which bug is seen:

      Tested on both current RHEL 9.4 nightly (libvirt-client-9.10.0-1.el9.x86_64) and Fedora Rawhide (libvirt-daemon-driver-storage-core-10.0.0-1.fc40.x86_64)

      How reproducible:

      Always

      Steps to reproduce

      Prepare a running VM:

      qemu-img create -f qcow2 /var/lib/libvirt/images/test1.qcow2 10G
      virt-install --memory 50 --pxe --virt-type qemu --os-variant alpinelinux3.8 --wait 0 --name test1 --disk target=vda,path=/var/lib/libvirt/images/test1.qcow2
      

      Now create a snapshot with memory:

      virsh snapshot-create-as --domain test1 --name snap1 --diskspec vda,snapshot=external,file=/var/lib/libvirt/images/test1-snap1 --memspec file=/var/lib/libvirt/qemu/snapshot/test1-snap1-memory
      

      This works fine.

      Now try to create a snapshot without memory. It doesn't matter if you virsh destroy test1 first (but of course it's more realistic to do that):

      virsh destroy test1
      virsh snapshot-create-as --domain test1 --name snap2 --diskspec vda,snapshot=external,file=/var/lib/libvirt/images/test1-snap2
      

      This fails with

      error: unsupported configuration: disk 'vda' must use snapshot mode 'internal'
      

      C-machines uses the API of course and creates the snapshot via XML, but it amounts to the same thing.

            phrdina@redhat.com Pavel Hrdina
            rhn-engineering-mpitt Martin Pitt
            Nannan Li
            Pavel Hrdina Pavel Hrdina
            Meina Li Meina Li
            Votes:
            0 Vote for this issue
            Watchers:
            11 Start watching this issue

              Created:
              Updated:
              Resolved: