Comment 4 for bug 1262914

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

Dmitry,

Is this what you're referring to? : when creating an offline Nova
snapshot, the Nova instance's (that's being snapshotted) disk is copied
into a temporary location before uploading it to the the Glance.

Tested with a week's old Nova git and a qcow2 CirrOS image:

    $ git describe
    2015.1.0rc1-300-g39bbc0d

Test
----

When you run an `image-create` on an offline Nova instance:

    $ nova boot --flavor 1 --key_name oskey1 \
        --image cirros-0.3.3-x86_64-disk cirrvm
    $ nova shutdown cirrvm
    $ nova image-create cirrvm snap --poll

A copy of the Nova instance being snapshotted is placed in a temporary
directory (before it is uploaded to Glance):

    "qemu-img convert -f qcow2 -O qcow2 \
      /home/kashyapc/src/cloud/data/nova/instances/aa20be6e-de39-4a15-9f95-9844ec9af5a9/disk \
      /home/kashyapc/src/cloud/data/nova/instances/snapshots/tmp2h6al2/1e00639002e2420ba3747145f06511d8"

NOTE: In this case, the above 'convert' command essentially just means
the file called 'disk' is just copied to the "snapshots/tmp2h6al2"
directory, because both the source _and_ destination formats are qcow2
-- so no format conversion is going on.

Where the 'snapshot()' function from nova/virt/libvirt/driver.py is
calling 'snapshot_extract()' from libvirt/imagebackend.py:

    . . .
    1363 snapshot_backend = self.image_backend.snapshot(instance,
    1364 disk_path,
    1365 image_type=source_format)
    . . .
    1380 if live_snapshot:

    . . . . . .

    1385 else:
    1386 snapshot_backend.snapshot_extract(out_path, image_format)
    . . .

Where the 'snapshot_extract()' calls the 'extract_snapshot()' from
libvirt/utils.py:

    . . .
    510 def snapshot_extract(self, target, out_format):
    511 libvirt_utils.extract_snapshot(self.path, 'qcow2',
    512 target,
    513 out_format)
    . . .

Where the 'extract_snapshot()' from libvirt/utils.py, finally executes
the `qemu-img convert` command:

    . . .
    387 qemu_img_cmd = ('qemu-img', 'convert', '-f', source_fmt, '-O', dest_fmt)
    . . .

After this, the converted (i.e. copied) image is uploaded to Glance.