From 9e0a29dacf60cb63edf20b6558207691abcf40e8 Mon Sep 17 00:00:00 2001 From: Marius Kittler Date: Wed, 8 Sep 2021 17:21:57 +0200 Subject: [PATCH] Fix `qemu-img` failure with QEMU 6.1.0 due to missing file format * Specify format of backing file on image creation with `qemu-img` * See https://progress.opensuse.org/issues/98117 --- OpenQA/Qemu/BlockDev.pm | 10 ++++++---- t/18-qemu.t | 16 ++++++++-------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/OpenQA/Qemu/BlockDev.pm b/OpenQA/Qemu/BlockDev.pm index 19f70a98bf..99a970ddb6 100644 --- a/OpenQA/Qemu/BlockDev.pm +++ b/OpenQA/Qemu/BlockDev.pm @@ -158,13 +158,15 @@ creating. =cut sub gen_qemu_img_cmdlines { - my $self = shift; - my @cmdlns = defined $self->backing_file ? $self->backing_file->gen_qemu_img_cmdlines : (); + my $self = shift; + + my $backing_file = $self->backing_file; + my @cmdlns = defined $backing_file ? $backing_file->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; + push(@params, '-F', $backing_file->driver, '-b', $backing_file->file) + if defined $backing_file; push(@params, $self->file); push(@params, $self->size); diff --git a/t/18-qemu.t b/t/18-qemu.t index 147ed8a2e4..2d15dc1850 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 -F qcow2 -b /abs/path/sle15-minimal.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 -F qcow2 -b), "$Bin/data/Core-7.2.iso", qw(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 -F qcow2 -b raid/hd0 raid/hd0-overlay1 10G)], + [qw(create -f qcow2 -F qcow2 -b raid/cd0-overlay0 raid/cd0-overlay1 11116544)]); @gcmdl = $bdc->gen_qemu_img_cmdlines(); is_deeply(\@gcmdl, \@cmdl, 'Generate reverted snapshot images'); @@ -384,10 +384,10 @@ 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); - 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'); + @cmdl = map { [qw(create -f qcow2 -F), $_ eq 'hd0' ? 'qcow2' : 'raw', '-b', "$dir/Core-7.2.iso", "raid/$_-overlay0", 11116544] } qw(hd0 cd0 cd1); + push @cmdl, [qw(create -f qcow2 -F raw -b), "$Bin/data/uefi-code.bin", "raid/pflash-code-overlay0", 1966080]; + push @cmdl, [qw(create -f qcow2 -F raw -b), "$dir/Core-7.2.iso", "raid/pflash-vars-overlay0", 11116544]; + is_deeply(\@gcmdl, \@cmdl, 'find the asset real path') or diag explain \@gcmdl; }; subtest 'qemu was killed due to the system being out of memory' => sub {