parent
fa529caf4b
commit
b1707f67c8
@ -1,85 +0,0 @@
|
||||
From 9e0a29dacf60cb63edf20b6558207691abcf40e8 Mon Sep 17 00:00:00 2001
|
||||
From: Marius Kittler <mkittler@suse.de>
|
||||
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 {
|
@ -1,102 +0,0 @@
|
||||
From 489916d5a18113365a97eb3181cbb6c5e351c467 Mon Sep 17 00:00:00 2001
|
||||
From: Marius Kittler <mkittler@suse.de>
|
||||
Date: Wed, 8 Sep 2021 18:20:52 +0200
|
||||
Subject: [PATCH] Deduce format of backing file from extension
|
||||
|
||||
* So even if we assign an ISO as HDD_x we would use the correct parameter
|
||||
`-F raw` (and not `-F qcow2`)
|
||||
* See https://github.com/os-autoinst/os-autoinst/pull/1764/files#r704549754
|
||||
and https://progress.opensuse.org/issues/98117
|
||||
---
|
||||
OpenQA/Qemu/BlockDev.pm | 4 +++-
|
||||
OpenQA/Qemu/BlockDevConf.pm | 10 ++++------
|
||||
t/18-qemu.t | 16 +++++++++++-----
|
||||
3 files changed, 18 insertions(+), 12 deletions(-)
|
||||
|
||||
diff --git a/OpenQA/Qemu/BlockDev.pm b/OpenQA/Qemu/BlockDev.pm
|
||||
index 99a970ddb6..58f226fc65 100644
|
||||
--- a/OpenQA/Qemu/BlockDev.pm
|
||||
+++ b/OpenQA/Qemu/BlockDev.pm
|
||||
@@ -33,7 +33,7 @@ weakened.
|
||||
=cut
|
||||
|
||||
package OpenQA::Qemu::BlockDev;
|
||||
-use Mojo::Base 'OpenQA::Qemu::MutParams';
|
||||
+use Mojo::Base 'OpenQA::Qemu::MutParams', -signatures;
|
||||
|
||||
use Scalar::Util 'weaken';
|
||||
use OpenQA::Qemu::SnapshotConf;
|
||||
@@ -216,6 +216,8 @@ sub _from_map {
|
||||
->snapshot($snap_conf->get_snapshot(sequence => $this->{snapshot}));
|
||||
}
|
||||
|
||||
+sub deduce_driver ($self) { $self->driver($self->file =~ qr/\.qcow2$/ ? 'qcow2' : 'raw') }
|
||||
+
|
||||
sub CARP_TRACE { 'OpenQA::Qemu::BlockDev(' . (shift->node_name || '') . ')' }
|
||||
|
||||
1;
|
||||
diff --git a/OpenQA/Qemu/BlockDevConf.pm b/OpenQA/Qemu/BlockDevConf.pm
|
||||
index 2b8dacbf32..bac282dfbc 100644
|
||||
--- a/OpenQA/Qemu/BlockDevConf.pm
|
||||
+++ b/OpenQA/Qemu/BlockDevConf.pm
|
||||
@@ -131,7 +131,7 @@ new overlay is created so that the existing qcow2 image is not modified.
|
||||
sub add_existing_drive {
|
||||
my ($self, $id, $file_name, $model, $size, $num_queues) = @_;
|
||||
|
||||
- my $base_drive = $self->add_existing_base($id, $file_name, $size)->implicit(1);
|
||||
+ my $base_drive = $self->add_existing_base($id, $file_name, $size)->implicit(1)->deduce_driver;
|
||||
my $overlay = $self->add_new_overlay($id . OVERLAY_POSTFIX . '0', $base_drive);
|
||||
|
||||
return $self->_push_new_drive_dev($id, $overlay, $model, $num_queues);
|
||||
@@ -164,11 +164,9 @@ variables. See the OpenQA::Qemu::PFlashDevice class.
|
||||
=cut
|
||||
sub add_pflash_drive {
|
||||
my ($self, $id, $file_name, $size) = @_;
|
||||
- my $base_drive = $self->add_existing_base($id, $file_name, $size)
|
||||
- ->implicit(1)
|
||||
- ->driver($file_name =~ qr/\.qcow2$/ ? 'qcow2' : 'raw');
|
||||
- my $overlay = $self->add_new_overlay($id . OVERLAY_POSTFIX . '0', $base_drive);
|
||||
- my $pflash = OpenQA::Qemu::PFlashDevice->new()
|
||||
+ my $base_drive = $self->add_existing_base($id, $file_name, $size)->implicit(1)->deduce_driver;
|
||||
+ my $overlay = $self->add_new_overlay($id . OVERLAY_POSTFIX . '0', $base_drive);
|
||||
+ my $pflash = OpenQA::Qemu::PFlashDevice->new()
|
||||
->id($id)
|
||||
->drive($overlay);
|
||||
|
||||
diff --git a/t/18-qemu.t b/t/18-qemu.t
|
||||
index 2d15dc1850..9483b296d4 100755
|
||||
--- a/t/18-qemu.t
|
||||
+++ b/t/18-qemu.t
|
||||
@@ -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 -F qcow2 -b), "$Bin/data/Core-7.2.iso", qw(raid/hd0-overlay0 11116544)]);
|
||||
+@cmdl = ([qw(create -f qcow2 -F raw -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');
|
||||
|
||||
@@ -380,13 +380,19 @@ subtest DriveDevice => sub {
|
||||
};
|
||||
|
||||
subtest 'relative assets' => sub {
|
||||
- $vars{$_} = "Core-7.2.iso" for qw(ISO ISO_1 HDD_1 UEFI_PFLASH_VARS);
|
||||
+ $vars{$_} = "Core-7.2.iso" for qw(ISO ISO_1 UEFI_PFLASH_VARS);
|
||||
+ $vars{$_} = "some.qcow2" for qw(HDD_1 UEFI_PFLASH_VARS);
|
||||
symlink("$Bin/data/Core-7.2.iso", "./Core-7.2.iso");
|
||||
+ path('./some.qcow2')->spurt('123');
|
||||
$proc = qemu_proc('-foo', \%vars);
|
||||
my @gcmdl = $proc->blockdev_conf->gen_qemu_img_cmdlines();
|
||||
- @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];
|
||||
+ @cmdl = (
|
||||
+ [qw(create -f qcow2 -F qcow2 -b), "$dir/some.qcow2", "raid/hd0-overlay0", 512],
|
||||
+ [qw(create -f qcow2 -F raw -b), "$dir/Core-7.2.iso", "raid/cd0-overlay0", 11116544],
|
||||
+ [qw(create -f qcow2 -F raw -b), "$dir/Core-7.2.iso", "raid/cd1-overlay0", 11116544],
|
||||
+ [qw(create -f qcow2 -F raw -b), "$Bin/data/uefi-code.bin", "raid/pflash-code-overlay0", 1966080],
|
||||
+ [qw(create -f qcow2 -F qcow2 -b), "$dir/some.qcow2", "raid/pflash-vars-overlay0", 512],
|
||||
+ );
|
||||
is_deeply(\@gcmdl, \@cmdl, 'find the asset real path') or diag explain \@gcmdl;
|
||||
};
|
||||
|
@ -1 +1 @@
|
||||
SHA512 (os-autoinst-ad28b4b59369ada5731ebd7f0916bc2e52324988.tar.gz) = 18dca7ea8d587953aa0823e376c7bd8197c3fbd2a1c57d148a5946a2edf4bfe02c8ad81067c950166719c906c7170a79935f8fd4baea6df1dd0f3844097c983c
|
||||
SHA512 (os-autoinst-627473ea5222dd4ad4cb0bfe82f0d5b5bcbe23c8.tar.gz) = ce2092237fe81e67fa5292d0ffd1d08f9deda9828831a7794599669067799d77bdff2282fcc760884815d7edfcf5972f4466c6e70caea1dd07ea835d5b0867d4
|
||||
|
Loading…
Reference in new issue