testdrive calls kvm-img to create disk image on trusty, command doesn't exist

Bug #1297377 reported by Ryan Beisner
44
This bug affects 8 people
Affects Status Importance Assigned to Milestone
TestDrive
In Progress
Medium
pawciobiel

Bug Description

While using Testdrive on Trusty to run the required iso test case of i386 and amd64 Trusty server installers for qa-tracker, I reach the following error:
'[!] Detect disks No disk drive was detected. If you know the name of the driver needed by your disk drive, you can select it from the list.'

The Testdrive script is calling the kvm-img command to create a qcow2 file prior to invoking a new virtual machine instance, however kvm-img doesn't exist. The qemu-img tool from the qemu-utils package is present and would work to create the qcow2 disk image file if called.

After the disk image creation fails, Testdrive proceeds anyway, which results in a 0kb raw disk image being created by qemu.

Additionally, Trusty incorrectly advises the following, which does not install kvm-img:

rbeisner@bcu:~$ kvm-img
The program 'kvm-img' is currently not installed. You can install it by typing:
sudo apt-get install qemu-utils

Libvirt, KVM and qemu are otherwise normal and functional on the host box ("bcu") with other unrelated VMs in place.

To confirm, I created a new pristine Trusty VM from ISO ("nest"), then installed Testdrive per qa-tracker iso guide. Same result: kvm-img command is absent.

The impact is that community members who help out in Trusty iso qa testing may not be able to complete the test cases.

As a test/work-around, I created a sym link of qemu-img to kvm-img. Testdrive was then able to create the qcow2 and spawn the test VM with a virtual disk present as originally expected.

Old/Related bugs:
https://bugs.launchpad.net/testdrive/+bug/543329

rbeisner@bcu:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu Trusty Tahr (development branch)
Release: 14.04
Codename: trusty

rbeisner@bcu:~$ uname -a
Linux bcu 3.13.0-18-generic #38-Ubuntu SMP Mon Mar 17 21:40:06 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

rbeisner@bcu:~$ kvm-ok
INFO: /dev/kvm exists
KVM acceleration can be used

rbeisner@bcu:/var/lib/libvirt/images$ sudo testdrive
[sudo] password for rbeisner:
INFO: version passed: False
INFO: config passed: None
INFO: Trying config in /etc/testdriverc
INFO: Using configuration in /etc/testdriverc
INFO: Trying config in /home/rbeisner/.testdriverc
INFO: Using configuration in /home/rbeisner/.testdriverc
INFO: Trying config in /home/rbeisner/.config/testdrive/testdriverc
INFO: Using KVM for virtual machine hosting...
INFO: Retrieving the Ubuntu ISO list from cache...

Welcome to Testdrive!

  1. Ubuntu Desktop (trusty-amd64)
  2. Ubuntu Desktop (trusty-i386)
  3. Ubuntu Server (trusty-amd64)
     +-cache--> [2014-03-18 11:47:52] trusty-server-amd64.iso
  4. Ubuntu Server (trusty-i386)
  5. Other (prompt for ISO URL)

Select an image to testdrive [1]: 3
INFO: Syncing the specified ISO...
      rsync://cdimage.ubuntu.com/cdimage/ubuntu-server/daily/current/trusty-server-amd64.iso

receiving incremental file list
trusty-server-amd64.iso
    584,056,832 100% 2.83MB/s 0:03:16 (xfr#1, to-chk=0/1)
INFO: Validating Virtualization Method....
INFO: Setting up Virtual Machine...
INFO: Creating disk image [/home/rbeisner/.cache/testdrive/img/testdrive-disk-a6gsRM.img]...
sh: 1: kvm-img: not found
ERROR: Command failed
    `kvm-img create -f qcow2 /home/rbeisner/.cache/testdrive/img/testdrive-disk-a6gsRM.img 6G`
INFO: Launching Virtual Machine...
INFO: Running the Virtual Machine...
        qemu-system-x86_64 -uuid f1ed6288-b71c-470c-8189-1d2114b0f3ec -m 2048 -smp 6 -cdrom /home/rbeisner/.cache/testdrive/iso/ubuntu_trusty-server-amd64.iso -drive file=/home/rbeisner/.cache/testdrive/img/testdrive-disk-a6gsRM.img,if=virtio,cache=writeback,index=0 -usb -usbdevice tablet -net nic,model=virtio -net user -soundhw es1370 -vga cirrus -enable-kvm

rbeisner@bcu:~$ dpkg -l | egrep 'qemu|kvm|libvirt|testdrive' | sort
ii ipxe-qemu 1.0.0+git-20131111.c3d1e78-2ubuntu1 all PXE boot firmware - ROM images for qemu
ii libvirt0 1.2.2-0ubuntu5 amd64 library for interfacing with different virtualization systems
ii libvirt-bin 1.2.2-0ubuntu5 amd64 programs for the libvirt library
ii python-libvirt 1.2.2-0ubuntu1 amd64 libvirt Python bindings
ii qemu-common 1.7.0+dfsg-3ubuntu7 all dummy transitional package from qemu-common to qemu-keymaps
ii qemu-keymaps 1.7.0+dfsg-3ubuntu7 all QEMU keyboard maps
ii qemu-kvm 1.7.0+dfsg-3ubuntu7 amd64 QEMU Full virtualization on x86 hardware (transitional package)
ii qemu-system-common 1.7.0+dfsg-3ubuntu7 amd64 QEMU full system emulation binaries (common files)
ii qemu-system-x86 1.7.0+dfsg-3ubuntu7 amd64 QEMU full system emulation binaries (x86)
ii qemu-utils 1.7.0+dfsg-3ubuntu7 amd64 QEMU utilities
ii testdrive 3.26-0ubuntu1 all run the daily Ubuntu ISO in a virtual machine (meta-package)
ii testdrive-cli 3.26-0ubuntu1 all run the daily Ubuntu ISO in a virtual machine (command line)
ii testdrive-common 3.26-0ubuntu1 all run the daily Ubuntu ISO in a virtual machine (common files)
ii testdrive-gtk 3.26-0ubuntu1 all run the daily Ubuntu ISO in a virtual machine (GTK Front-end)

rbeisner@bcu:~$ sudo qemu-img info /home/rbeisner/.cache/testdrive/img/testdrive-disk-a6gsRM.img
image: /home/rbeisner/.cache/testdrive/img/testdrive-disk-a6gsRM.img
file format: raw
virtual size: 0 (0 bytes)
disk size: 0
rbeisner@bcu:~$

rbeisner@bcu:~$ ls /home/rbeisner/.cache/testdrive/img/ -alh
total 8.0K
drwx------ 2 rbeisner rbeisner 4.0K Mar 24 10:37 .
drwx------ 4 rbeisner rbeisner 4.0K Mar 18 11:46 ..
-rw------- 1 root root 0 Mar 24 10:37 testdrive-disk-a6gsRM.img

Related branches

Revision history for this message
Ryan Beisner (1chb1n) wrote :

The hacky workaround confirmation (sym linking qemu-img to kvm-img):

rbeisner@bcu:~$ sudo testdrive
[sudo] password for rbeisner:
INFO: version passed: False
INFO: config passed: None
INFO: Trying config in /etc/testdriverc
INFO: Using configuration in /etc/testdriverc
INFO: Trying config in /home/rbeisner/.testdriverc
INFO: Using configuration in /home/rbeisner/.testdriverc
INFO: Trying config in /home/rbeisner/.config/testdrive/testdriverc
INFO: Using KVM for virtual machine hosting...
INFO: Retrieving the Ubuntu ISO list from cache...

Welcome to Testdrive!

  1. Ubuntu Desktop (trusty-amd64)
  2. Ubuntu Desktop (trusty-i386)
  3. Ubuntu Server (trusty-amd64)
     +-cache--> [2014-03-25 02:08:50] trusty-server-amd64.iso
  4. Ubuntu Server (trusty-i386)
  5. Other (prompt for ISO URL)

Select an image to testdrive [1]: 3
INFO: Syncing the specified ISO...
      rsync://cdimage.ubuntu.com/cdimage/ubuntu-server/daily/current/trusty-server-amd64.iso

receiving incremental file list
INFO: Validating Virtualization Method....
INFO: Setting up Virtual Machine...
INFO: Creating disk image [/home/rbeisner/.cache/testdrive/img/testdrive-disk-MXKnPn.img]...
Formatting '/home/rbeisner/.cache/testdrive/img/testdrive-disk-MXKnPn.img', fmt=qcow2 size=6442450944 encryption=off cluster_size=65536 lazy_refcounts=off
INFO: Launching Virtual Machine...
INFO: Running the Virtual Machine...
        qemu-system-x86_64 -uuid 28bccc39-f725-4a0e-9f9e-e4d613b36f2b -m 2048 -smp 6 -cdrom /home/rbeisner/.cache/testdrive/iso/ubuntu_trusty-server-amd64.iso -drive file=/home/rbeisner/.cache/testdrive/img/testdrive-disk-MXKnPn.img,if=virtio,cache=writeback,index=0 -usb -usbdevice tablet -net nic,model=virtio -net user -soundhw es1370 -vga cirrus -enable-kvm

rbeisner@bcu:~/.cache/testdrive/img$ sudo qemu-img info testdrive-disk-MXKnPn.img
[sudo] password for rbeisner:
image: testdrive-disk-MXKnPn.img
file format: qcow2
virtual size: 6.0G (6442450944 bytes)
disk size: 1.1G
cluster_size: 65536
Format specific information:
    compat: 1.1
    lazy refcounts: false

Revision history for this message
Ryan Beisner (1chb1n) wrote :

FYI the symlink command:

sudo ln -s /usr/bin/qemu-img /usr/bin/kvm-img

Doing this may not be advisable in general, ymmv, but it lets you proceed with test cases in qa iso testing for Trusty.

Revision history for this message
Ubuntu QA Website (ubuntuqa) wrote :

This bug has been reported on the Ubuntu ISO testing tracker.

A list of all reports related to this bug can be found here:
http://iso.qa.ubuntu.com/qatracker/reports/bugs/1297377

tags: added: iso-testing
Revision history for this message
Jackson Doak (noskcaj) wrote :

So this should just need an added qemu-utils depend?

Changed in testdrive:
status: New → Triaged
importance: Undecided → Medium
Revision history for this message
Ryan Beisner (1chb1n) wrote :

Actually, I don't think that will resolve it. The qemu-utils package is already installed, and it provides qemu-img instead of kvm-img.

My suggestions are:

1. Since not all testdrive users will be using KVM/qemu, and some may be using virtualbox, Testdrive should probably not assume one over the other. I wouldn't make it dependent on qemu-utils for this reason.

2. When KVM is the user's selected virtualization, Testdrive should check for existence of qemu-img or kvm-img and use the one present.

3. Testdrive should halt upon image creation failure. ie. Bail out before launching a VM and getting ~80% through the setup process.

pawciobiel (pawciobiel)
Changed in testdrive:
assignee: nobody → pawciobiel (pawciobiel)
pawciobiel (pawciobiel)
Changed in testdrive:
status: Triaged → In Progress
tags: added: utopic
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

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