libvirt extract snapshot fails if qemu-img >= 0.12.1

Bug #1247185 reported by Matt Riedemann
16
This bug affects 3 people
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
Undecided
Vladan Popovic
Havana
Fix Released
Undecided
Unassigned

Bug Description

Running stable/havana tempest against havana 2013.2 nova with this test:

tempest/tempest/api/compute/images/test_images_oneserver.py:test_create_second_image_when_first_image_is_being_saved

Using the libvirt driver on x86_64 RHEL 6.5 fails with this:

http://paste.openstack.org/show/50398/

Essentially: Stderr: "convert: invalid option -- 's'\n"

This is the code:

https://github.com/openstack/nova/blob/2013.2/nova/virt/libvirt/utils.py#L549

Looks like it's not a new change, it's just incompatible with the latest qemu-img:

https://github.com/openstack/nova/commit/b216ed51914986087ea7dee57bc29904fda001a0

Looks like in the latest qemu-img the snapshot was moved into it's own sub-command:

[root@rhel62 ~]# qemu-img --help
qemu-img version 0.12.1, Copyright (c) 2004-2008 Fabrice Bellard
usage: qemu-img command [command options]
QEMU disk image utility

Command syntax:
  check [-f fmt] filename
  create [-f fmt] [-o options] filename [size]
  commit [-f fmt] [-t cache] filename
  convert [-c] [-p] [-f fmt] [-t cache] [-O output_fmt] [-o options] [-S sparse_size] filename [filename2 [...]] output_filename
  info [-f fmt] filename
  snapshot [-l | -a snapshot | -c snapshot | -d snapshot] filename
  rebase [-f fmt] [-t cache] [-p] [-u] -b backing_file [-F backing_fmt] filename
  resize filename [+ | -]size

Revision history for this message
Yang Yu (yuyangbj) wrote :

It is curious, the '-s' works well on qemu-img-0.12.1.2-2.355.el6.x86_64 on RHEL6.4 even though qemu-img does not recommend the option 's'. On RHEL6.5 beta, it does not work. The version is qemu-img-0.12.1.2-2.402.el6.x86_64

Revision history for this message
Xavier Queralt (xqueralt-deactivatedaccount) wrote :

The version of qemu-img in RHEL 6.4 did list the '-s' option for the convert command although it didn't implement it and has been removed in the version shipped in RHEL 6.5 to avoid confusion. Even when using the '-s' option in RHEL 6.4, nova was extracting an snapshot from the image instead of doing it from an snapshot. This was working properly because nova stops the instance before taking the snapshot so there is no danger on making a copy directly from the image instead of first doing an internal snapshot.

Bug 1242819 proposes the removal of this extra steps (create, extract and delete an internal snapshot) for libvirt, check the proposed patch for a more detailed explanation.

Revision history for this message
Kashyap Chamarthy (kashyapc) wrote :

Just to add to Xavier's description, a few months ago, I was trying to understand [*] what kind of snapshots OpenStack tries to use (via 'nova image-create') and here's my notes

  1. If the guest -- based on which snapshot is to be taken -- is running, nova calls libvirt’s virsh managedsave, which saves and stops a running guest, to be restarted later from the saved state.

  2. Next, it creates a qcow2 internal disk snapshot of the guest (now offline).

  3. Then, extracts the internal named snapshot from the qcow2 file & exports it to a RAW format and temporarily places in $instances_path/snapshots.

  4. Deletes the internal named snapshot from the qcow2 file.

  5. Finally, uploads that image into OpenStack glance service — which can be confirmed by running glance image-list.

[*] http://kashyapc.wordpress.com/2013/03/11/openstack-nova-image-create-under-the-hood/

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to nova (master)

Reviewed: https://review.openstack.org/52363
Committed: http://github.com/openstack/nova/commit/8c985874c7885f31871204d3f83ce547fefc5fb6
Submitter: Jenkins
Branch: master

commit 8c985874c7885f31871204d3f83ce547fefc5fb6
Author: Vladan Popovic <email address hidden>
Date: Thu Oct 17 07:41:20 2013 -0400

    Remove unnecessary steps for cold snapshots

    Up until now when we created cold snapshots we were stopping the
    instance, create an internal snapshot, extract the snapshot to a file
    and then delete the internal snapshot before bringing up the instance.

    If the instance is shut down, there's no concurrent writer, so the image
    can be directly extracted without taking an internal snapshot first,
    because the snapshot and the current state are the same.

    In this patch the creation and deletion of the internal snapshot are
    removed to eliminate the extra steps and optimize the creation of
    snapshots a bit.

    Closes-Bug: #1242819
    Closes-Bug: #1247185

    Change-Id: I429fa2e1e26aea321eecbf14edd11263fff525ae

Changed in nova:
status: New → Fix Committed
Changed in nova:
assignee: nobody → Vladan Popovic (vpopovic)
Revision history for this message
Vladan Popovic (vpopovic) wrote :

@kchamart quick note: with this patch, steps 2) and 4) are completely removed from the image backend

Revision history for this message
Kashyap Chamarthy (kashyapc) wrote :

Thanks Vladen, I noticed it from the commit message.

Changed in nova:
milestone: none → icehouse-1
Thierry Carrez (ttx)
Changed in nova:
status: Fix Committed → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (stable/havana)

Fix proposed to branch: stable/havana
Review: https://review.openstack.org/78529

Thierry Carrez (ttx)
Changed in nova:
milestone: icehouse-1 → 2014.1
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to nova (stable/havana)

Reviewed: https://review.openstack.org/78529
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=d1356f7d2ab1fb3a91e7602153f0c8ce1073f1e5
Submitter: Jenkins
Branch: stable/havana

commit d1356f7d2ab1fb3a91e7602153f0c8ce1073f1e5
Author: QingXin Meng <email address hidden>
Date: Tue Mar 4 05:20:40 2014 -0800

    Remove unnecessary steps for cold snapshots

    Up until now when we created cold snapshots we were stopping the
    instance, create an internal snapshot, extract the snapshot to a file
    and then delete the internal snapshot before bringing up the instance.

    If the instance is shut down, there's no concurrent writer, so the image
    can be directly extracted without taking an internal snapshot first,
    because the snapshot and the current state are the same.

    In this patch the creation and deletion of the internal snapshot are
    removed to eliminate the extra steps and optimize the creation of
    snapshots a bit.

    Closes-Bug: #1242819
    Closes-Bug: #1247185

    Change-Id: I429fa2e1e26aea321eecbf14edd11263fff525ae
    (cherry picked from commit 8c985874c7885f31871204d3f83ce547fefc5fb6)

tags: added: in-stable-havana
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.