diff --git a/OpenQA/Qemu/BlockDevConf.pm b/OpenQA/Qemu/BlockDevConf.pm index 2b8dacbf..454815d3 100644 --- a/OpenQA/Qemu/BlockDevConf.pm +++ b/OpenQA/Qemu/BlockDevConf.pm @@ -80,6 +80,18 @@ sub add_existing_overlay { return $ol; } +sub add_existing_overlayfix { + my ($self, $id, $backing_file) = @_; + + my $ol = OpenQA::Qemu::BlockDev->new() + ->node_name($id) + ->file($self->basedir . '/' . $id) + ->size($backing_file->size); + $backing_file->overlay($ol); + + return $ol; +} + =head3 add_new_overlay Add an overlay on top of $backing_file, this is equivalent to creating a new @@ -73,6 +73,10 @@ model. =cut sub add_new_overlay ($self, @args) { $self->add_existing_overlay(@args)->needs_creating(1) } +sub add_new_overlayfix { + return add_existing_overlayfix(@_)->needs_creating(1); +} + sub _push_new_drive_dev ($self, $id, $drive, $model, $num_queues = undef) { die 'PFlash drives are not supported by DriveDevice, use PFlashDevice' if $model eq 'pflash'; @@ -176,6 +192,20 @@ sub add_pflash_drive { return $pflash; } +sub add_pflash_drivefix { + 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_overlayfix($id . OVERLAY_POSTFIX . '0', $base_drive); + my $pflash = OpenQA::Qemu::PFlashDevice->new() + ->id($id) + ->drive($overlay); + + push(@{$self->_drives}, $pflash); + return $pflash; +} + =head3 add_path_to_drive Add a connection between a drive device and a controller device. You can add diff --git a/OpenQA/Qemu/Proc.pm b/OpenQA/Qemu/Proc.pm index 0a1b99fe..b00153b6 100644 --- a/OpenQA/Qemu/Proc.pm +++ b/OpenQA/Qemu/Proc.pm @@ -270,7 +270,7 @@ sub configure_pflash { $fw = $vars->{UEFI_PFLASH_VARS}; die 'Need UEFI_PFLASH_VARS with UEFI_PFLASH_CODE' unless $fw; - $bdc->add_pflash_drive('pflash-vars', $fw, $self->get_img_size($fw)) + $bdc->add_pflash_drivefix('pflash-vars', $fw, $self->get_img_size($fw)) ->unit(1); } elsif ($vars->{UEFI_PFLASH_VARS}) {