[pve-devel] [PATCH] check if volume exist on volume update.
Dietmar Maurer
dietmar at proxmox.com
Mon Jun 25 07:10:18 CEST 2012
comitted, thanks.
But wait, we already do those checks inside PVE::Storage::Plugin::activate_volumes()!
I suggest we modify PVE::Storage::RBDPlugin::activate_volume() to check if the volume exists?
- Dietmar
> -----Original Message-----
> From: pve-devel-bounces at pve.proxmox.com [mailto:pve-devel-
> bounces at pve.proxmox.com] On Behalf Of Alexandre Derumier
> Sent: Samstag, 23. Juni 2012 09:08
> To: pve-devel at pve.proxmox.com
> Subject: [pve-devel] [PATCH] check if volume exist on volume update.
>
> for the moment we check only if the real path exist on the host.
> This doesn't work for "virtual" device that host doesn't see.(like rbd, virtio-
> scsi,...).
>
> This add a check if the volid exist in the storage.
>
> Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
> ---
> PVE/API2/Qemu.pm | 15 ++++++++++++++-
> 1 files changed, 14 insertions(+), 1 deletions(-)
>
> diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm index
> c172fde..497c334 100644
> --- a/PVE/API2/Qemu.pm
> +++ b/PVE/API2/Qemu.pm
> @@ -88,7 +88,20 @@ my $create_disks = sub {
> my $path = $rpcenv->check_volume_access($authuser, $storecfg,
> $vmid, $volid);
> PVE::Storage::activate_volumes($storecfg, [ $volid ])
> if PVE::Storage::parse_volume_id ($volid, 1);
> - die "image '$path' does not exists\n" if (!(-f $path || -b $path));
> +
> + my ($storeid, $volname) = PVE::Storage::parse_volume_id($volid);
> + my $dl = PVE::Storage::vdisk_list($storecfg, $storeid, undef);
> + my $foundvolid = undef;
> +
> + PVE::Storage::foreach_volid($dl, sub {
> + my ($volumeid) = @_;
> + if($volumeid eq $volid) {
> + $foundvolid = 1;
> + return;
> + }
> + });
> +
> + die "image '$path' does not exists\n" if (!(-f $path || -b $path
> +|| $foundvolid));
> $res->{$ds} = $settings->{$ds};
> }
> });
> --
> 1.7.2.5
>
> _______________________________________________
> pve-devel mailing list
> pve-devel at pve.proxmox.com
> http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
More information about the pve-devel
mailing list