Subject: simple-cdd: Improve qemu support

From: John Franklin <[email-masked]>
Date: Sun, 21 Jun 2020 12:25:39 -0400

Package: simple-cdd
Version: 0.6.7
Severity: normal

While using simple-cdd this weekend, I discovered a few things about the disk
image used with qemu-based testing.

The simple-cdd.conf.detailed file documents two settings for the disk image:
hd_img and hd_size.  These two settings are ignored by simple-cdd.

The default disk is a qcow image with the name qemu-test.hd.img stored in the
project root.  There are four improvements I'd like to make here:

* Change this to a qcow2 format to open up additional capabilities of the qcow2
format.  This may also improve performance (untested).

* Change the name to qemu-test.hd.qcow2 to make it more obvious to a developer
what the file is and its format.

* Move the file to the $simple_cdd_tmp folder, in a qemu subfolder, to better
organize it with the rest fo the temporary build files.

* Change the script to use qemu's -drive option to improve the speed of the
disk emulation.  With the existing -hda setting, even simple tests take hours
to complete, whereas -drive with some extra options reduces it to a couple
minutes.

The PR at https://salsa.debian.org/debian/simple-cdd/-/merge_requests/2
addresses all of the above issues:

* Honor hd_img and hd_size, if they're set.
* Change default hd_img format and extension to qcow2.
* Use -drive instead of -hda for more options and performance.
* If hd_img isn't an absolute path, store it in tmp/qemu.

-- System Information:
Debian Release: 10.4
  APT prefers stable-updates
  APT policy: (500, 'stable-updates'), (500, 'stable')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 5.5.0-0.bpo.2-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages simple-cdd depends on:
ii  dctrl-tools         2.24-3
ii  debian-cd           3.1.25
ii  lsb-release         10.2019051400
ii  python3             3.7.3-1
ii  python3-simple-cdd  0.6.7
ii  reprepro            5.3.0-1
ii  rsync               3.1.3-6
ii  wget                1.20.1-1.1

Versions of packages simple-cdd recommends:
ii  dose-distcheck  5.0.1-12

Versions of packages simple-cdd suggests:
ii  qemu-kvm  1:3.1+dfsg-8+deb10u5

-- no debconf information

---

From: Vagrant Cascadian <[email-masked]>
Date: Sun, 21 Jun 2020 10:32:03 -0700

> image used with qemu-based testing.

Thanks for submitting!

> format.  This may also improve performance (untested).

Sounds good.

> what the file is and its format.

I'd prefer not to change the filename, as then it would have to be
changed whenever the file format changes.

> organize it with the rest fo the temporary build files.

Mixed feelings on this; wondering if it wouldn't make sene to go into
the images folder instead. Or maybe $simple_cdd_tmp is fine.

> to complete, whereas -drive with some extra options reduces it to a couple

Great!

> addresses all of the above issues:

Thanks!

> * Honor hd_img and hd_size, if they're set.

Overall, looks good!

It does seem to change commented out example size, which doesn't seem
necessary, it only being an example? I think I had put an example in
there which was a non-default value for qemu-img at the time... but in
general I'd like to keep the defaults to whatever qemu-img spits out.

> * Change default hd_img format and extension to qcow2.

As mentioned above, fine with changing the format, but would rather not
change the filename extension.

> * Use -drive instead of -hda for more options and performance.

Sounds good; this project was started 15+ years ago and it shows! :)

> * If hd_img isn't an absolute path, store it in tmp/qemu.

Mixed feelings on that, as mentioned above.

Happy to merge most of it; could you re-write the git history so that
the contested points are in separate commits? Then I can merge the
uncontested patches while we sort out the remainder.

live well,
  vagrant

---

From: John Franklin <[email-masked]>
Date: Sun, 21 Jun 2020 19:45:44 -0400

> changed whenever the file format changes.

If the format changes, then the extension should change, too.  That's 
not a heavy lift.

> the images folder instead. Or maybe $simple_cdd_tmp is fine.

The images folder is where final artifacts end up.  All the rest of the 
intermediary files are in the tmp directory.  This patch puts it in a 
place dedicated to the qemu part of the process.  If you're runnig with 
UEFI firmware, you may want to include `-drive 
if=pflash,format=raw,file=profile_OVMF_VARS.fd` to define where the 
UEFI nvram should be stored.  In that case, the nvram file should also 
be in the tmp/qemu directory.  (Future patch coming!)

> general I'd like to keep the defaults to whatever qemu-img spits out.

Size is a required parameter if the file doesn't already exist.

```
$ qemu-img create test.img
qemu-img: test.img: Image creation needs a size parameter
```

> uncontested patches while we sort out the remainder.

Done.

jf
-- 
John Franklin
[email-masked]