File Coverage

OpenQA/Qemu/PFlashDevice.pm
Criterion Covered Total %
statement 11 11 100.0
total 11 11 100.0


line stmt code
1   # Copyright 2018 SUSE LLC
2   # SPDX-License-Identifier: GPL-2.0-or-later
3    
4   =head3 OpenQA::Qemu::PFlashDevice
5    
6   Some storage devices can only be created using the '-drive' parameter in
7   QEMU. Pflash is one such device (at the time of writing), so we can not use a
8   standard drive device to represent it. This limits our control over how the
9   drive device and block device chain are created; we can not set the node id of
10   the top block device for example nor can we override the backing file AFAIK.
11    
12   This class is the same as DriveDevice except for a few extra fields and
13   gen_cmdline has been overridden to use '-drive' instead.
14    
15   =cut
16    
17   use Mojo::Base 'OpenQA::Qemu::DriveDevice', -signatures;
18 16  
  16  
  16  
19   has model => 'pflash';
20   has 'unit';
21   has 'readonly';
22    
23   my $drive = $self->drive;
24 8 my @params = ('id=' . $drive->node_name,
  8  
  8  
25 8 "if=pflash",
26 8 'file=' . $drive->file);
27    
28   $self->_push_ifdef(\@params, 'unit=', $self->unit);
29   $self->_push_ifdef(\@params, 'readonly=', $self->readonly);
30 8  
31 8 return ('-drive', join(',', @params));
32   }
33 8  
34   1;