public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: "Fabian Grünbichler" <f.gruenbichler@proxmox.com>
To: Proxmox VE development discussion <pve-devel@lists.proxmox.com>
Subject: Re: [pve-devel] [PATCH qemu-server v2] drives: expose 'readonly' flag of qemu for scsi/virtio
Date: Tue, 28 Sep 2021 11:15:27 +0200	[thread overview]
Message-ID: <1632820448.4l68m4o6ly.astroid@nora.none> (raw)
In-Reply-To: <20210928090211.2082146-1-d.csapak@proxmox.com>

On September 28, 2021 11:02 am, Dominik Csapak wrote:
> 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).
> 
> 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>
> ---
> changes from v1:
> * limit that setting to scsi/virtio as it is not possible to use it on
>   ide/sata
> 
>  PVE/QemuServer.pm       | 10 ++++++----
>  PVE/QemuServer/Drive.pm | 11 +++++++++++
>  2 files changed, 17 insertions(+), 4 deletions(-)
> 
> diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
> index 0fb8628..5209f51 100644
> --- a/PVE/QemuServer.pm
> +++ b/PVE/QemuServer.pm
> @@ -1569,10 +1569,12 @@ sub print_drive_commandline_full {
>  	$opts .= ",$o=$drive->{$o}" if defined($drive->{$o});
>      }
>  
> -    # snapshot only accepts on|off
> -    if (defined($drive->{snapshot})) {
> -	my $v = $drive->{snapshot} ? 'on' : 'off';
> -	$opts .= ",snapshot=$v";
> +    # some options only accepts on|off
> +    foreach my $o (qw(snapshot readonly)) {
> +	if (defined($drive->{$o})) {
> +	    my $v = $drive->{$o} ? 'on' : 'off';
> +	    $opts .= ",$o=$v";
> +	}
>      }
>  
>      foreach my $type (['', '-total'], [_rd => '-read'], [_wr => '-write']) {
> diff --git a/PVE/QemuServer/Drive.pm b/PVE/QemuServer/Drive.pm
> index 5110190..af7aafe 100644
> --- a/PVE/QemuServer/Drive.pm
> +++ b/PVE/QemuServer/Drive.pm
> @@ -175,6 +175,14 @@ my %queues_fmt = (
>      }
>  );
>  
> +my %readonly_fmt = (
> +    readonly => {

we have a very similar CT mountpoint property called 'ro', might make sense 
to have it consistent?

> +	type => 'boolean',
> +	description => "Whether the drive is read-only.",
> +	optional => 1,
> +    },
> +);
> +
>  my %scsiblock_fmt = (
>      scsiblock => {
>  	type => 'boolean',
> @@ -269,6 +277,7 @@ my $scsi_fmt = {
>      %drivedesc_base,
>      %iothread_fmt,
>      %queues_fmt,
> +    %readonly_fmt,
>      %scsiblock_fmt,
>      %ssd_fmt,
>      %wwn_fmt,
> @@ -297,6 +306,7 @@ PVE::JSONSchema::register_standard_option("pve-qm-sata", $satadesc);
>  my $virtio_fmt = {
>      %drivedesc_base,
>      %iothread_fmt,
> +    %readonly_fmt,
>  };
>  my $virtiodesc = {
>      optional => 1,
> @@ -311,6 +321,7 @@ my $alldrive_fmt = {
>      %iothread_fmt,
>      %model_fmt,
>      %queues_fmt,
> +    %readonly_fmt,
>      %scsiblock_fmt,
>      %ssd_fmt,
>      %wwn_fmt,
> -- 
> 2.30.2
> 
> 
> 
> _______________________________________________
> pve-devel mailing list
> pve-devel@lists.proxmox.com
> https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
> 
> 
> 




      reply	other threads:[~2021-09-28  9:16 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-28  9:02 Dominik Csapak
2021-09-28  9:15 ` Fabian Grünbichler [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1632820448.4l68m4o6ly.astroid@nora.none \
    --to=f.gruenbichler@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal