Libvirt/KVM snapshot , disk_format != container_format, is it a bug?

Asked by ezzzehxx

Environment : diablo-released.

steps to reproduce:

1. i upload some images using ec2tools, so the value of disk_format and container_format should be "ami"

2. start an instance

3. snapshot it (direct request to osAPI ) and exception is thrown

Command: qemu-img convert -f qcow2 -O ami -s aa03c01c0c4e4abbb31eca029e268dee /srv/lib/instances/instance-0000000b/disk /tmp/tmpxw9snQ/aa03c01c0c4e4abbb31eca029e268dee

(nova.rpc): TRACE: Exit code: 1
(nova.rpc): TRACE: Stdout: ''
(nova.rpc): TRACE: Stderr: "qemu-img: Unknown file format 'ami'\n"

after digging into the code, i found the function here assume that the previous value of image_format must be raw, qcow2, vmdk, vdi.

if i set "qcow2" in FLAGS.snapshot_image_format, the disk_format will be different with container_format.

it's not a big deal since i can fix it easily with some small changes.

My question is :

is this a bug or i can't use it with ec2 style ?

      # orginal image here
       base = image_service.show(context, image_id)
        (snapshot_image_service, snapshot_image_id) = \
            thor.image.get_image_service(context, image_href)

       .............

       # image_format is "ami"
        image_format = FLAGS.snapshot_image_format or source_format
        if FLAGS.use_cow_images:
            source_format = 'qcow2'
        metadata['disk_format'] = image_format

        if 'container_format' in base:
            metadata['container_format'] = base['container_format']

Question information

Language:
English Edit question
Status:
Solved
For:
OpenStack Compute (nova) Edit question
Assignee:
No assignee Edit question
Solved by:
Vish Ishaya
Solved:
Last query:
Last reply:
Revision history for this message
Best Vish Ishaya (vishvananda) said :
#1

This is a bug. Glance requires disk_format == container_format for ami, so we should be checking for ami and using raw for the qemu-img command, but upload the disk / container format as ami.

Vish

On Oct 7, 2011, at 3:05 AM, ezzzehxx wrote:

> New question #173526 on OpenStack Compute (nova):
> https://answers.launchpad.net/nova/+question/173526
>
> Environment : diablo-released.
>
> steps to reproduce:
>
> 1. i upload some images using ec2tools, so the value of disk_format and container_format should be "ami"
>
> 2. start an instance
>
> 3. snapshot it (direct request to osAPI ) and exception is thrown
>
> Command: qemu-img convert -f qcow2 -O ami -s aa03c01c0c4e4abbb31eca029e268dee /srv/lib/instances/instance-0000000b/disk /tmp/tmpxw9snQ/aa03c01c0c4e4abbb31eca029e268dee
>
> (nova.rpc): TRACE: Exit code: 1
> (nova.rpc): TRACE: Stdout: ''
> (nova.rpc): TRACE: Stderr: "qemu-img: Unknown file format 'ami'\n"
>
>
> after digging into the code, i found the function here assume that the previous value of image_format must be raw, qcow2, vmdk, vdi.
>
> if i set "qcow2" in FLAGS.snapshot_image_format, the disk_format will be different with container_format.
>
> it's not a big deal since i can fix it easily with some small changes.
>
> My question is :
>
> is this a bug or i can't use it with ec2 style ?
>
>
> # orginal image here
> base = image_service.show(context, image_id)
> (snapshot_image_service, snapshot_image_id) = \
> thor.image.get_image_service(context, image_href)
>
>
> .............
>
> # image_format is "ami"
> image_format = FLAGS.snapshot_image_format or source_format
> if FLAGS.use_cow_images:
> source_format = 'qcow2'
> metadata['disk_format'] = image_format
>
> if 'container_format' in base:
> metadata['container_format'] = base['container_format']
>
>
>
>
>
>
>
> --
> You received this question notification because you are a member of Nova
> Core, which is an answer contact for OpenStack Compute (nova).

Revision history for this message
Koji Iida (iida-koji) said :
#2

Is this bug already fixed?

Revision history for this message
ezzzehxx (ezzzehxx) said :
#3

Thanks Vish Ishaya, that solved my question.