mirror of
https://git.proxmox.com/git/qemu-server
synced 2025-05-05 12:43:09 +00:00
drives: expose 'readonly' flag of qemu for scsi/virtio
this allows a user to set a drive to 'read-only'. This can be useful if a disk should not be written to, or if the backing file/source is not writable (like a mapped pbs backup to /dev/loopX). the option is named 'ro', to achieve consistency with containers while this could also be achieved by setting 'snapshot=1', this would create a temporary file in /var/tmp which can get quite big. Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
parent
6a5589010e
commit
12e1d472e3
@ -1597,6 +1597,12 @@ sub print_drive_commandline_full {
|
|||||||
$opts .= ",snapshot=$v";
|
$opts .= ",snapshot=$v";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# ro is 'readonly', and only accepts on|off
|
||||||
|
if (defined($drive->{ro})) {
|
||||||
|
my $v = $drive->{ro} ? 'on' : 'off';
|
||||||
|
$opts .= ",readonly=$v";
|
||||||
|
}
|
||||||
|
|
||||||
foreach my $type (['', '-total'], [_rd => '-read'], [_wr => '-write']) {
|
foreach my $type (['', '-total'], [_rd => '-read'], [_wr => '-write']) {
|
||||||
my ($dir, $qmpname) = @$type;
|
my ($dir, $qmpname) = @$type;
|
||||||
if (my $v = $drive->{"mbps$dir"}) {
|
if (my $v = $drive->{"mbps$dir"}) {
|
||||||
|
@ -175,6 +175,14 @@ my %queues_fmt = (
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
my %readonly_fmt = (
|
||||||
|
ro => {
|
||||||
|
type => 'boolean',
|
||||||
|
description => "Whether the drive is read-only.",
|
||||||
|
optional => 1,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
my %scsiblock_fmt = (
|
my %scsiblock_fmt = (
|
||||||
scsiblock => {
|
scsiblock => {
|
||||||
type => 'boolean',
|
type => 'boolean',
|
||||||
@ -269,6 +277,7 @@ my $scsi_fmt = {
|
|||||||
%drivedesc_base,
|
%drivedesc_base,
|
||||||
%iothread_fmt,
|
%iothread_fmt,
|
||||||
%queues_fmt,
|
%queues_fmt,
|
||||||
|
%readonly_fmt,
|
||||||
%scsiblock_fmt,
|
%scsiblock_fmt,
|
||||||
%ssd_fmt,
|
%ssd_fmt,
|
||||||
%wwn_fmt,
|
%wwn_fmt,
|
||||||
@ -297,6 +306,7 @@ PVE::JSONSchema::register_standard_option("pve-qm-sata", $satadesc);
|
|||||||
my $virtio_fmt = {
|
my $virtio_fmt = {
|
||||||
%drivedesc_base,
|
%drivedesc_base,
|
||||||
%iothread_fmt,
|
%iothread_fmt,
|
||||||
|
%readonly_fmt,
|
||||||
};
|
};
|
||||||
my $virtiodesc = {
|
my $virtiodesc = {
|
||||||
optional => 1,
|
optional => 1,
|
||||||
@ -399,6 +409,7 @@ my $alldrive_fmt = {
|
|||||||
%iothread_fmt,
|
%iothread_fmt,
|
||||||
%model_fmt,
|
%model_fmt,
|
||||||
%queues_fmt,
|
%queues_fmt,
|
||||||
|
%readonly_fmt,
|
||||||
%scsiblock_fmt,
|
%scsiblock_fmt,
|
||||||
%ssd_fmt,
|
%ssd_fmt,
|
||||||
%wwn_fmt,
|
%wwn_fmt,
|
||||||
|
Loading…
Reference in New Issue
Block a user