From: Aaron Lauterer <a.lauterer@proxmox.com>
To: Proxmox VE development discussion <pve-devel@lists.proxmox.com>,
Maximiliano Sandoval <m.sandoval@proxmox.com>
Subject: Re: [pve-devel] [PATCH storage v2] fix-4272: btrfs: add rename feature
Date: Thu, 4 Jul 2024 11:52:42 +0200 [thread overview]
Message-ID: <b1f694ae-01bf-4097-add8-ae3d911e43c0@proxmox.com> (raw)
In-Reply-To: <20240703124147.441210-1-m.sandoval@proxmox.com>
did you test if it works if a manually placed qcow2 or vmdk disk image
is used as discussed in my previous responses and in person?
There currently are no checks in place, as there are for all the other
functions in the BTRFS plugin that deal with creating/changing disk images.
One more thing inline.
On 2024-07-03 14:41, Maximiliano Sandoval wrote:
> Adds the ability to change the owner of a guest image.
>
> Btrfs does not need special commands to rename a subvolume and this can
> be achieved the same as in Storage/plugin.pm's rename_volume taking
> special care of how the directory structure used by Btrfs.
>
> Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
> ---
> src/PVE/Storage/BTRFSPlugin.pm | 40 ++++++++++++++++++++++++++++++++++
> 1 file changed, 40 insertions(+)
>
> diff --git a/src/PVE/Storage/BTRFSPlugin.pm b/src/PVE/Storage/BTRFSPlugin.pm
> index 42815cb..9f71d78 100644
> --- a/src/PVE/Storage/BTRFSPlugin.pm
> +++ b/src/PVE/Storage/BTRFSPlugin.pm
> @@ -7,6 +7,7 @@ use base qw(PVE::Storage::Plugin);
>
> use Fcntl qw(S_ISDIR O_WRONLY O_CREAT O_EXCL);
> use File::Basename qw(basename dirname);
> +use File::Copy 'move';
> use File::Path qw(mkpath);
> use IO::Dir;
> use POSIX qw(EEXIST);
> @@ -618,6 +619,9 @@ sub volume_has_feature {
> base => { qcow2 => 1, raw => 1, vmdk => 1 },
> current => { qcow2 => 1, raw => 1, vmdk => 1 },
> },
> + rename => {
> + current => { raw => 1 },
> + },
> };
>
> my ($vtype, $name, $vmid, $basename, $basevmid, $isBase, $format) = $class->parse_volname($volname);
> @@ -930,4 +934,40 @@ sub volume_import {
> return "$storeid:$volname";
> }
>
> +sub rename_volume {
> + my ($class, $scfg, $storeid, $source_volname, $target_vmid, $target_volname) = @_;
> + die "no path found\n" if !$scfg->{path};
> +
> + my (
> + undef,
> + undef,
> + undef,
> + undef,
> + undef
> + undef,
> + $format
> + ) = $class->parse_volname($source_volname);
> +
> + my $ppath = $class->filesystem_path($scfg, $source_volname);
> +
> + $target_volname = $class->find_free_diskname($storeid, $scfg, $target_vmid, $format, 1)
> + if !$target_volname;
> + $target_volname = "$target_vmid/$target_volname";
> +
> + my $basedir = $class->get_subdir($scfg, 'images');
> +
> + mkpath "${basedir}/${target_vmid}";
> + my $source_dir = raw_name_to_dir($source_volname);
> + my $target_dir = raw_name_to_dir($target_volname);
> +
> + my $old_path = "${basedir}/${source_dir}";
> + my $new_path = "${basedir}/${target_dir}";
> +
> + die "target volume '${target_volname}' already exists\n" if -e $new_path;
> + move $old_path, $new_path ||
did you try if it would just work with 'rename' like in the main
implementation used in `Plugin.pm`?
Then we could drop the whole import of File::Copy::move
> + die "rename '$old_path' to '$new_path' failed - $!\n";
> +
> + return "${storeid}:$target_volname";
> +}
> +
> 1
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
prev parent reply other threads:[~2024-07-04 9:53 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-03 12:41 Maximiliano Sandoval
2024-07-04 9:32 ` Thomas Lamprecht
[not found] ` <s8osewp5w88.fsf@proxmox.com>
2024-07-04 10:01 ` Thomas Lamprecht
2024-07-04 9:49 ` Fiona Ebner
2024-07-04 9:52 ` Aaron Lauterer [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=b1f694ae-01bf-4097-add8-ae3d911e43c0@proxmox.com \
--to=a.lauterer@proxmox.com \
--cc=m.sandoval@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