[pve-devel] [PATCH] create_disks : avoid storage scan v2

Alexandre DERUMIER aderumier at odiso.com
Mon Jun 10 07:49:59 CEST 2013


Ok, I'll look a this today, thank for the report.

----- Mail original ----- 

De: "Dietmar Maurer" <dietmar at proxmox.com> 
À: "Alexandre Derumier" <aderumier at odiso.com>, pve-devel at pve.proxmox.com 
Envoyé: Lundi 10 Juin 2013 07:00:33 
Objet: RE: [pve-devel] [PATCH] create_disks : avoid storage scan v2 

This does not work for me: 

old code: 

# qm set 100 -ide0 /dev/pve/test1 

==> ide0: /dev/pve/test1,size=1G 

your code: 

==> ide0: /dev/pve/test1 

> -----Original Message----- 
> From: pve-devel-bounces at pve.proxmox.com [mailto:pve-devel- 
> bounces at pve.proxmox.com] On Behalf Of Alexandre Derumier 
> Sent: Mittwoch, 05. Juni 2013 08:53 
> To: pve-devel at pve.proxmox.com 
> Subject: [pve-devel] [PATCH] create_disks : avoid storage scan v2 
> 
> 
> Signed-off-by: Alexandre Derumier <aderumier at odiso.com> 
> --- 
> PVE/API2/Qemu.pm | 35 ++++++++++++++++++++--------------- 
> 1 file changed, 20 insertions(+), 15 deletions(-) 
> 
> diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm index 
> 24b57ad..0e00529 100644 
> --- a/PVE/API2/Qemu.pm 
> +++ b/PVE/API2/Qemu.pm 
> @@ -130,25 +130,30 @@ my $create_disks = sub { 
> 
> my ($storeid, $volname) = PVE::Storage::parse_volume_id($volid, 
> 1); 
> 
> - my $foundvolid = undef; 
> + my $foundvolid = 1; 
> + my $volid_is_new = 1; 
> 
> - if ($storeid) { 
> - PVE::Storage::activate_volumes($storecfg, [ $volid ]); 
> - my $dl = PVE::Storage::vdisk_list($storecfg, $storeid, undef); 
> - 
> - PVE::Storage::foreach_volid($dl, sub { 
> - my ($volumeid) = @_; 
> - if($volumeid eq $volid) { 
> - $foundvolid = 1; 
> - return; 
> - } 
> - }); 
> + if ($conf->{$ds}) { 
> + my $olddrive = PVE::QemuServer::parse_drive($ds, $conf- 
> >{$ds}); 
> + $volid_is_new = undef if $olddrive->{file} && $olddrive- 
> >{file} eq 
> +$volid; 
> } 
> 
> - die "image '$path' does not exists\n" if (!(-f $path || -b $path || 
> $foundvolid)); 
> + if($volid_is_new){ 
> + 
> + if ($storeid) { 
> + 
> + PVE::Storage::activate_volumes($storecfg, [ $volid ]); 
> + my $size = undef; 
> + eval { 
> + $size = PVE::Storage::volume_size_info($storecfg, 
> $volid); 
> + $disk->{size} = $size; 
> + }; 
> + $foundvolid = undef if $@; 
> + 
> + die "volume $volid does not exists\n" if (!(-f $path || -b 
> $path || $foundvolid)); 
> + } 
> + } 
> 
> - my ($size) = PVE::Storage::volume_size_info($storecfg, $volid, 1); 
> - $disk->{size} = $size; 
> $res->{$ds} = PVE::QemuServer::print_drive($vmid, $disk); 
> } 
> }); 
> -- 
> 1.7.10.4 
> 
> _______________________________________________ 
> 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