all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Fiona Ebner <f.ebner@proxmox.com>
To: "Proxmox VE development discussion" <pve-devel@lists.proxmox.com>,
	"Fabian Grünbichler" <f.gruenbichler@proxmox.com>
Subject: Re: [pve-devel] [PATCH qemu-server 5/5] blockdev-stream/-commit: make backing file relative
Date: Tue, 29 Jul 2025 11:17:56 +0200	[thread overview]
Message-ID: <b7243d18-3fe3-419c-82df-420020ce73e0@proxmox.com> (raw)
In-Reply-To: <20250729073844.185466-6-f.gruenbichler@proxmox.com>

Am 29.07.25 um 9:39 AM schrieb Fabian Grünbichler:
> to avoid the resulting qcow2 file referencing its backing file via an absolute
> path, which makes renaming the base of the storage impossible.
> 
> Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>

Reviewed-by: Fiona Ebner <f.ebner@proxmox.com>
Tested-by: Fiona Ebner <f.ebner@proxmox.com>

with some minor suggestions below. Thank you for tackling this!

> ---
>  src/PVE/QemuServer/Blockdev.pm | 19 +++++++++++++++++--
>  1 file changed, 17 insertions(+), 2 deletions(-)
> 
> diff --git a/src/PVE/QemuServer/Blockdev.pm b/src/PVE/QemuServer/Blockdev.pm
> index 6e105571..71d5ef69 100644
> --- a/src/PVE/QemuServer/Blockdev.pm
> +++ b/src/PVE/QemuServer/Blockdev.pm
> @@ -5,6 +5,7 @@ use warnings;
>  
>  use Digest::SHA;
>  use Fcntl qw(S_ISBLK S_ISCHR);
> +use File::Basename;

Nit: could use qw(basename dirname) to make the imports explicit

>  use File::stat;
>  use JSON;
>  
> @@ -954,12 +955,19 @@ sub blockdev_replace {
>          $parent_fmt_blockdev->{backing} = $target_fmt_blockdev->{'node-name'};
>          mon_cmd($vmid, 'blockdev-reopen', options => [$parent_fmt_blockdev]);
>  
> +        my $backing_file = $target_file_blockdev->{filename};
> +        my $backing_dir = dirname($backing_file);
> +        if ($backing_dir eq dirname($parent_file_blockdev->{filename})) {
> +            # make backing file relative if in same directory
> +            $backing_file = basename($backing_file);
> +        }

Nit: while only used twice, could still become a helper to avoid making
the functions here longer.

> +
>          #change backing-file in qcow2 metadatas
>          mon_cmd(
>              $vmid, 'change-backing-file',
>              device => $deviceid,
>              'image-node-name' => $parent_fmt_blockdev->{'node-name'},
> -            'backing-file' => $target_file_blockdev->{filename},
> +            'backing-file' => $backing_file,
>          );
>      }
>  
> @@ -1069,11 +1077,18 @@ sub blockdev_stream {
>          { 'snapshot-name' => $snap },
>      );
>  
> +    my $backing_file = $parent_file_blockdev->{filename};
> +    my $backing_dir = dirname($backing_file);
> +    if ($backing_dir eq dirname($target_file_blockdev->{filename})) {
> +        # make backing file relative if in same directory
> +        $backing_file = basename($backing_file);
> +    }
> +
>      my $job_id = "stream-$deviceid";
>      my $jobs = {};
>      my $options = { 'job-id' => $job_id, device => $target_fmt_blockdev->{'node-name'} };
>      $options->{'base-node'} = $parent_fmt_blockdev->{'node-name'};
> -    $options->{'backing-file'} = $parent_file_blockdev->{filename};
> +    $options->{'backing-file'} = $backing_file;
>  
>      mon_cmd($vmid, 'block-stream', %$options);
>      $jobs->{$job_id} = {};



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

  reply	other threads:[~2025-07-29  9:17 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-29  7:38 [pve-devel] [PATCH storage/qemu-server 0/5] avoid absolute qcow2 references Fabian Grünbichler
2025-07-29  7:38 ` [pve-devel] [PATCH storage 1/5] plugin: fix typo in rebase log message Fabian Grünbichler
2025-07-29  8:09   ` Fiona Ebner
2025-07-29  7:38 ` [pve-devel] [PATCH storage 2/5] lvm " Fabian Grünbichler
2025-07-29  8:09   ` Fiona Ebner
2025-07-29  7:38 ` [pve-devel] [PATCH storage 3/5] plugin: use relative path for qcow2 rebase command Fabian Grünbichler
2025-07-29  9:01   ` Fiona Ebner
2025-07-29  7:38 ` [pve-devel] [PATCH storage 4/5] lvm " Fabian Grünbichler
2025-07-29  9:04   ` Fiona Ebner
2025-07-29  7:38 ` [pve-devel] [PATCH qemu-server 5/5] blockdev-stream/-commit: make backing file relative Fabian Grünbichler
2025-07-29  9:17   ` Fiona Ebner [this message]
2025-07-29 12:02 ` [pve-devel] superseded: [PATCH storage/qemu-server 0/5] avoid absolute qcow2 references Fabian Grünbichler

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=b7243d18-3fe3-419c-82df-420020ce73e0@proxmox.com \
    --to=f.ebner@proxmox.com \
    --cc=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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal