qemu-img convert image incompatability in alpine linux

Bug #1634156 reported by Jakub Pavlik
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
Medium
Jakub Pavlik

Bug Description

Alpine linux runs qemu-img version 2.5.1-r4, where you cannot put parameter "-f qcow2" in the end of the line, because it expects location. Parameter must be included before source and destination.

Step to reproduce
==================

you can try it in container

1) docker run -it gliderlabs/alpine:3.4 sh
2) apk update; apk add qemu-img wget
3) wget http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-i386-disk.img
4) mkdir /var/lib/nova/instances/_base/
5) qemu-img convert -O raw cirros-0.3.4-i386-disk.img /var/lib/nova/instances/_base/sample -f qcow2
qemu-img: Could not open '/var/lib/nova/instances/_base/sample': Could not open '/var/lib/nova/instances/_base/hovno': No such file or directory

correct way

qemu-img convert -f qcow2 -O raw cirros-0.3.4-i386-disk.img /var/lib/nova/instances/_base/sample

I verified this on Ubuntu and Centos as well.

Proposed change
=================

diff --git a/nova/virt/images.py b/nova/virt/images.py
index 8242d2f..4e676b4 100644
--- a/nova/virt/images.py
+++ b/nova/virt/images.py
@@ -96,7 +96,7 @@ def convert_image_unsafe(source, dest, out_format, run_as_root=False):
 def _convert_image(source, dest, in_format, out_format, run_as_root):
     cmd = ('qemu-img', 'convert', '-O', out_format, source, dest)
     if in_format is not None:
- cmd = cmd + ('-f', in_format)
+ cmd = cmd[:-2] + ('-f', in_format) + cmd[-2:]
     try:
         utils.execute(*cmd, run_as_root=run_as_root)
     except processutils.ProcessExecutionError as exp:

Logs error
==============

2016-10-14 13:27:20.678 63743 ERROR nova.compute.manager [req-2d77222d-766c-41f9-86b3-57f0319ae6e9 573e69f9429749fc84d1c89d56e7ee4f cbf99832c4ca4feb8a17adbab21f78e7 - - -] [instance: 568c6af
a-d164-43fb-bd95-97f9dd48fa26] Instance failed to spawn
2016-10-14 13:27:20.678 63743 ERROR nova.compute.manager [instance: 568c6afa-d164-43fb-bd95-97f9dd48fa26] Traceback (most recent call last):
2016-10-14 13:27:20.678 63743 ERROR nova.compute.manager [instance: 568c6afa-d164-43fb-bd95-97f9dd48fa26] File "/opt/nova/lib/python2.7/site-packages/nova/compute/manager.py", line 2218, i
n _build_resources
2016-10-14 13:27:20.678 63743 ERROR nova.compute.manager [instance: 568c6afa-d164-43fb-bd95-97f9dd48fa26] yield resources
2016-10-14 13:27:20.678 63743 ERROR nova.compute.manager [instance: 568c6afa-d164-43fb-bd95-97f9dd48fa26] File "/opt/nova/lib/python2.7/site-packages/nova/compute/manager.py", line 2064, i
n _build_and_run_instance
2016-10-14 13:27:20.678 63743 ERROR nova.compute.manager [instance: 568c6afa-d164-43fb-bd95-97f9dd48fa26] block_device_info=block_device_info)
2016-10-14 13:27:20.678 63743 ERROR nova.compute.manager [instance: 568c6afa-d164-43fb-bd95-97f9dd48fa26] File "/opt/nova/lib/python2.7/site-packages/nova/virt/libvirt/driver.py", line 277
2, in spawn
2016-10-14 13:27:20.678 63743 ERROR nova.compute.manager [instance: 568c6afa-d164-43fb-bd95-97f9dd48fa26] admin_pass=admin_password)
2016-10-14 13:27:20.678 63743 ERROR nova.compute.manager [instance: 568c6afa-d164-43fb-bd95-97f9dd48fa26] File "/opt/nova/lib/python2.7/site-packages/nova/virt/libvirt/driver.py", line 319
0, in _create_image
2016-10-14 13:27:20.678 63743 ERROR nova.compute.manager [instance: 568c6afa-d164-43fb-bd95-97f9dd48fa26] instance, size, fallback_from_host)
2016-10-14 13:27:20.678 63743 ERROR nova.compute.manager [instance: 568c6afa-d164-43fb-bd95-97f9dd48fa26] File "/opt/nova/lib/python2.7/site-packages/nova/virt/libvirt/driver.py", line 678
7, in _try_fetch_image_cache
2016-10-14 13:27:20.678 63743 ERROR nova.compute.manager [instance: 568c6afa-d164-43fb-bd95-97f9dd48fa26] size=size)
2016-10-14 13:27:20.678 63743 ERROR nova.compute.manager [instance: 568c6afa-d164-43fb-bd95-97f9dd48fa26] File "/opt/nova/lib/python2.7/site-packages/nova/virt/libvirt/imagebackend.py", li
ne 251, in cache
2016-10-14 13:27:20.678 63743 ERROR nova.compute.manager [instance: 568c6afa-d164-43fb-bd95-97f9dd48fa26] *args, **kwargs)
2016-10-14 13:27:20.678 63743 ERROR nova.compute.manager [instance: 568c6afa-d164-43fb-bd95-97f9dd48fa26] File "/opt/nova/lib/python2.7/site-packages/nova/virt/libvirt/imagebackend.py", li
ne 593, in create_image
2016-10-14 13:27:20.678 63743 ERROR nova.compute.manager [instance: 568c6afa-d164-43fb-bd95-97f9dd48fa26] prepare_template(target=base, max_size=size, *args, **kwargs)
2016-10-14 13:27:20.678 63743 ERROR nova.compute.manager [instance: 568c6afa-d164-43fb-bd95-97f9dd48fa26] File "/opt/nova/lib/python2.7/site-packages/oslo_concurrency/lockutils.py", line 2
71, in inner
2016-10-14 13:27:20.678 63743 ERROR nova.compute.manager [instance: 568c6afa-d164-43fb-bd95-97f9dd48fa26] return f(*args, **kwargs)
2016-10-14 13:27:20.678 63743 ERROR nova.compute.manager [instance: 568c6afa-d164-43fb-bd95-97f9dd48fa26] File "/opt/nova/lib/python2.7/site-packages/nova/virt/libvirt/imagebackend.py", li
ne 241, in fetch_func_sync
2016-10-14 13:27:20.678 63743 ERROR nova.compute.manager [instance: 568c6afa-d164-43fb-bd95-97f9dd48fa26] fetch_func(target=target, *args, **kwargs)
2016-10-14 13:27:20.678 63743 ERROR nova.compute.manager [instance: 568c6afa-d164-43fb-bd95-97f9dd48fa26] File "/opt/nova/lib/python2.7/site-packages/nova/virt/libvirt/utils.py", line 429,
 in fetch_image
2016-10-14 13:27:20.678 63743 ERROR nova.compute.manager [instance: 568c6afa-d164-43fb-bd95-97f9dd48fa26] max_size=max_size)
2016-10-14 13:27:20.678 63743 ERROR nova.compute.manager [instance: 568c6afa-d164-43fb-bd95-97f9dd48fa26] File "/opt/nova/lib/python2.7/site-packages/nova/virt/images.py", line 165, in fet
ch_to_raw
2016-10-14 13:27:20.678 63743 ERROR nova.compute.manager [instance: 568c6afa-d164-43fb-bd95-97f9dd48fa26] % {'exp': exp})
2016-10-14 13:27:20.678 63743 ERROR nova.compute.manager [instance: 568c6afa-d164-43fb-bd95-97f9dd48fa26] ImageUnacceptable: Image 4c7d8a04-fcb6-4c25-bd18-749361d47637 is unacceptable: Unabl
e to convert image to raw: Image /var/lib/nova/instances/_base/594054a605f6d769702d6ab0d13ac7537a86b174.part is unacceptable: Unable to convert image to raw: Unexpected error while running c
ommand.
2016-10-14 13:27:20.678 63743 ERROR nova.compute.manager [instance: 568c6afa-d164-43fb-bd95-97f9dd48fa26] Command: qemu-img convert -O raw /var/lib/nova/instances/_base/594054a605f6d769702d6
ab0d13ac7537a86b174.part /var/lib/nova/instances/_base/594054a605f6d769702d6ab0d13ac7537a86b174.converted -f qcow2
2016-10-14 13:27:20.678 63743 ERROR nova.compute.manager [instance: 568c6afa-d164-43fb-bd95-97f9dd48fa26] Exit code: 1
2016-10-14 13:27:20.678 63743 ERROR nova.compute.manager [instance: 568c6afa-d164-43fb-bd95-97f9dd48fa26] Stdout: u''
2016-10-14 13:27:20.678 63743 ERROR nova.compute.manager [instance: 568c6afa-d164-43fb-bd95-97f9dd48fa26] Stderr: u"qemu-img: Could not open '/var/lib/nova/instances/_base/594054a605f6d76970
2d6ab0d13ac7537a86b174.converted': Could not open '/var/lib/nova/instances/_base/594054a605f6d769702d6ab0d13ac7537a86b174.converted': No such file or directory\n"
2016-10-14 13:27:20.678 63743 ERROR nova.compute.manager [instance: 568c6afa-d164-43fb-bd95-97f9dd48fa26]

Tags: libvirt
Changed in nova:
assignee: nobody → Jakub Pavlik (pavlk-jakub)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (master)

Fix proposed to branch: master
Review: https://review.openstack.org/387485

Changed in nova:
status: New → In Progress
tags: added: libvirt
Changed in nova:
importance: Undecided → Medium
Revision history for this message
Jakub Pavlik (pavlk-jakub) wrote :

Tested on ubuntu 16.10 with latest qemu-version, where this remains same. So it only affects version on Alpine linux.

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

Reviewed: https://review.openstack.org/387485
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=ce257366438e09ed8e6be53f01ee00552fa94da3
Submitter: Jenkins
Branch: master

commit ce257366438e09ed8e6be53f01ee00552fa94da3
Author: Jakub Pavlik <email address hidden>
Date: Mon Oct 17 16:28:01 2016 +0200

    Fix qemu-img convert image incompatability in alpine linux

    Alpine linux runs qemu-img version, where you cannot put
    parameter for convert "-f qcow2" in the end of the line,
    because it expects location. Parameter must be included
    before source and destination.

    Change-Id: I7f75eb62c19190c0d523b49dd371d603cafd753f
    Closes-Bug: 1634156

Changed in nova:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/nova 15.0.0.0b2

This issue was fixed in the openstack/nova 15.0.0.0b2 development milestone.

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.