Project

General

Profile

Actions

action #98117

closed

qemu-img calls fail with qemu 6.1.0 (need to specify format for backing file)

Added by AdamWill over 3 years ago. Updated over 3 years ago.

Status:
Resolved
Priority:
Urgent
Assignee:
Category:
Regressions/Crashes
Target version:
Start date:
2021-09-03
Due date:
2021-09-22
% Done:

0%

Estimated time:

Description

Observation

qemu 6.1.0 requires that, if you specify a backing file for qemu-img create, you must also specify the backing format. Up to 6.0.0 it was warning that not specifying the backing format was deprecated, but it was a warning, not fatal - it would auto-detect the format and proceed. See e.g. this autoinst log:

    [2021-09-02T12:43:17.932 UTC] [debug] Initializing block device images
    [2021-09-02T12:43:17.933 UTC] [debug] running /usr/bin/qemu-img create -f qcow2 /var/lib/openqa/pool/26/raid/hd0 10G
    [2021-09-02T12:43:17.961 UTC] [debug] Formatting '/var/lib/openqa/pool/26/raid/hd0', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=10737418240 lazy_refcounts=off refcount_bits=16
    [2021-09-02T12:43:17.961 UTC] [debug] running /usr/bin/qemu-img create -f qcow2 -b /var/lib/openqa/pool/26/Fedora-Server-dvd-x86_64-35-20210902.n.0.iso /var/lib/openqa/pool/26/raid/cd0-overlay0 2236612608
    [2021-09-02T12:43:17.986 UTC] [debug] qemu-img: warning: Deprecated use of backing file without explicit backing format (detected format of raw)
      Formatting '/var/lib/openqa/pool/26/raid/cd0-overlay0', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=2236612608 backing_file=/var/lib/openqa/pool/26/Fedora-Server-dvd-x86_64-35-20210902.n.0.iso lazy_refcounts=off refcount_bits=16
    [2021-09-02T12:43:17.986 UTC] [debug] running /usr/bin/qemu-img create -f qcow2 -b /usr/share/edk2/ovmf/OVMF_CODE.fd /var/lib/openqa/pool/26/raid/pflash-code-overlay0 1966080
    [2021-09-02T12:43:18.011 UTC] [debug] qemu-img: warning: Deprecated use of backing file without explicit backing format (detected format of raw)
      Formatting '/var/lib/openqa/pool/26/raid/pflash-code-overlay0', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=1966080 backing_file=/usr/share/edk2/ovmf/OVMF_CODE.fd lazy_refcounts=off refcount_bits=16
    [2021-09-02T12:43:18.011 UTC] [debug] running /usr/bin/qemu-img create -f qcow2 -b /usr/share/edk2/ovmf/OVMF_VARS.fd /var/lib/openqa/pool/26/raid/pflash-vars-overlay0 131072
    [2021-09-02T12:43:18.036 UTC] [debug] qemu-img: warning: Deprecated use of backing file without explicit backing format (detected format of raw)
      Formatting '/var/lib/openqa/pool/26/raid/pflash-vars-overlay0', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=131072 backing_file=/usr/share/edk2/ovmf/OVMF_VARS.fd lazy_refcounts=off refcount_bits=16
    [2021-09-02T12:43:18.036 UTC] [debug] init_blockdev_images: Finished creating block devices

Steps to reproduce

This is what you get if you just run the tests from current HEAD with qemu 6.1.0:

 # [2021-08-31T14:48:35.199 UTC] [debug] Initializing block device images
 # [2021-08-31T14:48:35.199 UTC] [debug] running /usr/bin/qemu-img create -f qcow2 /tmp/18-qemu-options.t-8oXw/pool/raid/hd0 10G
 # [2021-08-31T14:48:35.217 UTC] [debug] Formatting '/tmp/18-qemu-options.t-8oXw/pool/raid/hd0', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=10737418240 lazy_refcounts=off refcount_bits=16
 # [2021-08-31T14:48:35.217 UTC] [debug] running /usr/bin/qemu-img create -f qcow2 -b /builddir/build/BUILD/os-autoinst-ad28b4b59369ada5731ebd7f0916bc2e52324988/t/data/Core-7.2.iso /tmp/18-qemu-options.t-8oXw/pool/raid/cd0-overlay0 11116544
 # [2021-08-31T14:48:35.231 UTC] [debug] qemu-img: /tmp/18-qemu-options.t-8oXw/pool/raid/cd0-overlay0: Backing file specified without backing format
 #   Detected format of raw.
 # [2021-08-31T14:48:35.231 UTC] [info] ::: backend::baseclass::die_handler: Backend process died, backend errors are reported below in the following lines:
 #   runcmd '/usr/bin/qemu-img create -f qcow2 -b /builddir/build/BUILD/os-autoinst-ad28b4b59369ada5731ebd7f0916bc2e52324988/t/data/Core-7.2.iso /tmp/18-qemu-options.t-8oXw/pool/raid/cd0-overlay0 11116544' failed with exit code 1: 'qemu-img: /tmp/18-qemu-options.t-8oXw/pool/raid/cd0-overlay0: Backing file specified without backing format
 #   Detected format of raw.' at /builddir/build/BUILD/os-autoinst-ad28b4b59369ada5731ebd7f0916bc2e52324988/t/../osutils.pm line 121.

Suggestion

  • Prevent failure of qemu-img create with qemu 6.1.0

Further details

I was trying to just send a PR for this, but the relevant code is heavily abstracted and I haven't been able to figure it out completely. So far I have this, which ought to be correct, but actually it seems we are not currently specifying the correct "driver" for the objects that represent the backing files. If you apply this patch and run the tests, the ones that expect '-F raw' will fail because they instead get '-F qcow2'. We should be specifying 'raw' as the "driver" for firmware and ISO backing files, but we apparently are not doing so in this context, and I don't know where to fix that.

    From 282806def4c5b1021f431e58e8258d1dea4d6882 Mon Sep 17 00:00:00 2001
    From: Adam Williamson <awilliam@redhat.com>
    Date: Fri, 3 Sep 2021 11:02:42 -0700
    Subject: [PATCH] Specify backing file format for qemu-img commands (qemu
     6.1.0)

    qemu 6.1.0 requires the format to be specified for backing files
    in `qemu-img create`. In 6.0.0 and before, not specifying it was
    deprecated, and you can see the warnings in autoinst-log.txt,
    e.g.:

    [2021-09-02T12:42:37.401 UTC] [debug] qemu-img: warning: Deprecated use of backing file without explicit backing format (detected format of qcow2)

    Signed-off-by: Adam Williamson <awilliam@redhat.com>
    ---
     OpenQA/Qemu/BlockDev.pm |  6 ++++--
     t/18-qemu.t             | 10 +++++-----
     2 files changed, 9 insertions(+), 7 deletions(-)

    diff --git a/OpenQA/Qemu/BlockDev.pm b/OpenQA/Qemu/BlockDev.pm
    index 19f70a98..c8d7cbd8 100644
    --- a/OpenQA/Qemu/BlockDev.pm
    +++ b/OpenQA/Qemu/BlockDev.pm
    @@ -163,8 +163,10 @@ sub gen_qemu_img_cmdlines {
         return @cmdlns unless $self->needs_creating;

         my @params = ('create', '-f', $self->driver);
    -    push(@params, ('-b', $self->backing_file->file))
    -      if defined $self->backing_file;
    +    if (defined $self->backing_file) {
    +        push(@params, ('-b', $self->backing_file->file));
    +        push(@params, ('-F', $self->backing_file->driver));
    +    }
         push(@params, $self->file);
         push(@params, $self->size);

    diff --git a/t/18-qemu.t b/t/18-qemu.t
    index 147ed8a2..c8b887fd 100755
    --- a/t/18-qemu.t
    +++ b/t/18-qemu.t
    @@ -84,7 +84,7 @@ $bdc->add_existing_drive('hd1', '/abs/path/sle15-minimal.qcow2', 'virtio-blk', 2
     @gcmdl = $bdc->gen_cmdline();
     is_deeply(\@gcmdl, \@cmdl, 'Generate qemu command line for single existing drive');

    -@cmdl  = ([qw(create -f qcow2 -b /abs/path/sle15-minimal.qcow2 raid/hd1-overlay0 22548578304)]);
    +@cmdl  = ([qw(create -f qcow2 -b /abs/path/sle15-minimal.qcow2 -F qcow2 raid/hd1-overlay0 22548578304)]);
     @gcmdl = $bdc->gen_qemu_img_cmdlines();
     is_deeply(\@gcmdl, \@cmdl, 'Generate qemu-img command line for single existing drive');

    @@ -114,7 +114,7 @@ $proc  = qemu_proc('-foo', \%vars);
     @gcmdl = $proc->gen_cmdline();
     is_deeply(\@gcmdl, \@cmdl, 'Generate qemu command line for single existing UEFI disk using vars');

    -@cmdl  = ([qw(create -f qcow2 -b), "$Bin/data/Core-7.2.iso", qw(raid/hd0-overlay0 11116544)]);
    +@cmdl  = ([qw(create -f qcow2 -b), "$Bin/data/Core-7.2.iso", qw(-F raw raid/hd0-overlay0 11116544)]);
     @gcmdl = $proc->blockdev_conf->gen_qemu_img_cmdlines();
     is_deeply(\@gcmdl, \@cmdl, 'Generate qemu-img command line for single existing UEFI disk');

    @@ -229,8 +229,8 @@ $proc->deserialise_state(path($path)->slurp());
     is_deeply(\@gcmdl, \@cmdl, 'Command line after snapshot and serialisation')
       || diag(explain(\@gcmdl));

    -@cmdl = ([qw(create -f qcow2 -b raid/hd0 raid/hd0-overlay1 10G)],
    -    [qw(create -f qcow2 -b raid/cd0-overlay0 raid/cd0-overlay1 11116544)]);
    +@cmdl = ([qw(create -f qcow2 -b raid/hd0 -F qcow2 raid/hd0-overlay1 10G)],
    +    [qw(create -f qcow2 -b raid/cd0-overlay0 -F qcow2 raid/cd0-overlay1 11116544)]);
     @gcmdl = $bdc->gen_qemu_img_cmdlines();
     is_deeply(\@gcmdl, \@cmdl, 'Generate reverted snapshot images');

    @@ -384,7 +384,7 @@ subtest 'relative assets' => sub {
         symlink("$Bin/data/Core-7.2.iso", "./Core-7.2.iso");
         $proc = qemu_proc('-foo', \%vars);
         my @gcmdl = $proc->blockdev_conf->gen_qemu_img_cmdlines();
    -    @cmdl = map { [qw(create -f qcow2 -b), "$dir/Core-7.2.iso", "raid/$_-overlay0", 11116544] } qw(hd0 cd0 cd1);
    +    @cmdl = map { [qw(create -f qcow2 -b), "$dir/Core-7.2.iso", "-F", "raw", "raid/$_-overlay0", 11116544] } qw(hd0 cd0 cd1);
         push @cmdl, ["create", "-f", "qcow2", "-b", "$Bin/data/uefi-code.bin", "raid/pflash-code-overlay0", 1966080];
         push @cmdl, ["create", "-f", "qcow2", "-b", "$dir/Core-7.2.iso",       "raid/pflash-vars-overlay0", 11116544];
         is_deeply(\@gcmdl, \@cmdl, 'find the asset real path');
    -- 
    2.32.0
Actions #1

Updated by AdamWill over 3 years ago

For the record, this is what you get if you just run the tests from current HEAD with qemu 6.1.0:

 # [2021-08-31T14:48:35.199 UTC] [debug] Initializing block device images
 # [2021-08-31T14:48:35.199 UTC] [debug] running /usr/bin/qemu-img create -f qcow2 /tmp/18-qemu-options.t-8oXw/pool/raid/hd0 10G
 # [2021-08-31T14:48:35.217 UTC] [debug] Formatting '/tmp/18-qemu-options.t-8oXw/pool/raid/hd0', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=10737418240 lazy_refcounts=off refcount_bits=16
 # [2021-08-31T14:48:35.217 UTC] [debug] running /usr/bin/qemu-img create -f qcow2 -b /builddir/build/BUILD/os-autoinst-ad28b4b59369ada5731ebd7f0916bc2e52324988/t/data/Core-7.2.iso /tmp/18-qemu-options.t-8oXw/pool/raid/cd0-overlay0 11116544
 # [2021-08-31T14:48:35.231 UTC] [debug] qemu-img: /tmp/18-qemu-options.t-8oXw/pool/raid/cd0-overlay0: Backing file specified without backing format
 #   Detected format of raw.
 # [2021-08-31T14:48:35.231 UTC] [info] ::: backend::baseclass::die_handler: Backend process died, backend errors are reported below in the following lines:
 #   runcmd '/usr/bin/qemu-img create -f qcow2 -b /builddir/build/BUILD/os-autoinst-ad28b4b59369ada5731ebd7f0916bc2e52324988/t/data/Core-7.2.iso /tmp/18-qemu-options.t-8oXw/pool/raid/cd0-overlay0 11116544' failed with exit code 1: 'qemu-img: /tmp/18-qemu-options.t-8oXw/pool/raid/cd0-overlay0: Backing file specified without backing format
 #   Detected format of raw.' at /builddir/build/BUILD/os-autoinst-ad28b4b59369ada5731ebd7f0916bc2e52324988/t/../osutils.pm line 121.
Actions #2

Updated by livdywan over 3 years ago

$ zypper if qemu | grep ersion
Version        : 6.0.0-29.1

So Tumbleweed has version 6. Is 6.1 an in-development version? Do you have a link on upstream docs?

Actions #3

Updated by osukup over 3 years ago

https://build.opensuse.org/package/show/openSUSE:Factory/qemu -- 6.1 was accepted to Factory yesterday , so next snapshot will contain this version

Actions #4

Updated by VANASTASIADIS over 3 years ago

  • Target version set to Ready
Actions #5

Updated by VANASTASIADIS over 3 years ago

  • Description updated (diff)
Actions #6

Updated by VANASTASIADIS over 3 years ago

  • Status changed from New to Workable
Actions #7

Updated by VANASTASIADIS over 3 years ago

  • Description updated (diff)
Actions #8

Updated by livdywan over 3 years ago

  • Description updated (diff)
Actions #9

Updated by Xiaojing_liu over 3 years ago

  • Assignee set to Xiaojing_liu

I would like to try

Actions #10

Updated by mkittler over 3 years ago

  • Status changed from Workable to In Progress
  • Assignee changed from Xiaojing_liu to mkittler

I stumbled across this issue myself, this small change should fix it: https://github.com/os-autoinst/os-autoinst/pull/1764

@Xiaojing_liu Sorry for taking over but this affects TW now so I'd like to fix it as soon as possible and I needed to create a workaround for my local setup anyways.

Actions #11

Updated by mkittler over 3 years ago

I've only read the huge ticket description now. Looks like @AdamWill has already proposed something very similar to my change.

… but the relevant code is heavily abstracted and I haven't been able to figure it out completely.

I've noticed the same but came up with the same code change as you so I'd say that's the right place.

We should be specifying 'raw' as the "driver" for firmware and ISO backing files, but we apparently are not doing so in this context, and I don't know where to fix that.

It looks like we're actually specifying the driver correctly. Just one of the test lacks the correct format.

Actions #12

Updated by AdamWill over 3 years ago

It looks like we're actually specifying the driver correctly. Just one of the test lacks the correct format.

I disagree. If you look at the logs from a run with 6.0.0 that I pasted, you will see that qemu used 'raw' (not 'qcow2') as the backing format for ISO and firmware files. All three files in that log extract are ISOs or firmware files, and in all three cases, qemu logs "detected format of raw". It only logs "detected format of qcow2" for backing files that are qcow2 disk images - that wasn't shown in the log extract I pasted, but here's an example from a test where we attach a hard disk image as a hard disk and an ISO as an optical disk:

[2021-09-08T13:40:46.177 UTC] [debug] running /usr/bin/qemu-img info --output=json /var/lib/openqa/pool/17/00972318-disk_KDE-live-iso_64bit.qcow2
[2021-09-08T13:40:46.198 UTC] [debug] running /usr/bin/qemu-img info --output=json /var/lib/openqa/pool/17/Fedora-KDE-Live-x86_64-35-20210908.n.0.iso
[2021-09-08T13:40:46.218 UTC] [debug] Initializing block device images
[2021-09-08T13:40:46.218 UTC] [debug] running /usr/bin/qemu-img create -f qcow2 -b /var/lib/openqa/pool/17/00972318-disk_KDE-live-iso_64bit.qcow2 /var/lib/openqa/pool/17/raid/hd0-overlay0 10737418240
[2021-09-08T13:40:46.539 UTC] [debug] qemu-img: warning: Deprecated use of backing file without explicit backing format (detected format of qcow2)
  Formatting '/var/lib/openqa/pool/17/raid/hd0-overlay0', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=10737418240 backing_file=/var/lib/openqa/pool/17/00972318-disk_KDE-live-iso_64bit.qcow2 backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16
[2021-09-08T13:40:46.539 UTC] [debug] running /usr/bin/qemu-img create -f qcow2 -b /var/lib/openqa/pool/17/Fedora-KDE-Live-x86_64-35-20210908.n.0.iso /var/lib/openqa/pool/17/raid/cd0-overlay0 2151579648
[2021-09-08T13:40:46.585 UTC] [debug] qemu-img: warning: Deprecated use of backing file without explicit backing format (detected format of raw)

note qemu detects format 'qcow2' for the disk image but 'raw' for the ISO image.

I don't know if using a backing format of qcow2 actually causes any problems, but I think we ought to figure that out. Also, I note that we do actually already have code that implements this distinction in os-autoinst. It's in add_pflash_drive:

my $base_drive = $self->add_existing_base($id, $file_name, $size)
  ->implicit(1)
  ->driver($file_name =~ qr/\.qcow2$/ ? 'qcow2' : 'raw');

See https://github.com/os-autoinst/os-autoinst/blob/master/OpenQA/Qemu/BlockDevConf.pm#L169 . Looking at the name of it, I guess it's used for firmware images but not for ISO files...so maybe if we had a test of a firmware image here, it would get the expected result 'raw', and it's only ISO files that are wrong...

Actions #13

Updated by AdamWill over 3 years ago

edit: hmm, no. add_iso_drive is right above add_pflash_drive, and it always sets driver to 'raw'. So we do have some code here that 'does the right thing', but somehow the drive object that gets used for an ISO disk image in this qemu-img command-line construction code wasn't produced by add_iso_drive, or something. This was about the point where I gave up trying to figure things out and filed the issue, I think. :D

Actions #14

Updated by mkittler over 3 years ago

2nd PR to deduce the format from the extension: https://github.com/os-autoinst/os-autoinst/pull/1765

Actions #15

Updated by VANASTASIADIS over 3 years ago

  • Due date set to 2021-09-22

Setting due date based on mean cycle time of SUSE QE Tools

Actions #16

Updated by mkittler over 3 years ago

Both PR have been merged. I hope distinguishing between qcow2 and raw (= everything else) is good enough.

Actions #17

Updated by mkittler over 3 years ago

  • Status changed from In Progress to Feedback
Actions #18

Updated by mkittler over 3 years ago

The PR has been deployed today (10.09.21 07:40) on OSD workers and so far the number of incompletes looks still ok and I didn't see any other complaints.

Actions #19

Updated by mkittler over 3 years ago

  • Status changed from Feedback to Resolved

There's still room for improvement, e.g. we could use file (or better File::LibMagic) to determine the file type. This would of course be more reliable than only relying on the extension (see https://github.com/os-autoinst/os-autoinst/pull/1765#issuecomment-917005970). However, so far it seems that this is not necessary for our purposes. There were no complaints or an unusual high number of incompletes.

Actions

Also available in: Atom PDF