[pve-devel] [PATCH] rbd: get volume size for volumes list

para zheng para.pve at gmail.com
Wed Oct 17 08:15:59 CEST 2012


With this patch, you can check the storage volume of ceph cluster when
you create a VM.

2012/10/17 Dietmar Maurer <dietmar at proxmox.com>:
> I do not understand this patch? What is the purpose?
>
>> -----Original Message-----
>> From: pve-devel-bounces at pve.proxmox.com [mailto:pve-devel-
>> bounces at pve.proxmox.com] On Behalf Of Alexandre Derumier
>> Sent: Dienstag, 16. Oktober 2012 16:38
>> To: pve-devel at pve.proxmox.com
>> Subject: [pve-devel] [PATCH] rbd: get volume size for volumes list
>>
>>
>> Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
>> ---
>>  PVE/Storage/RBDPlugin.pm |   38 ++++++++++++++++++++++----------------
>>  1 file changed, 22 insertions(+), 16 deletions(-)
>>
>> diff --git a/PVE/Storage/RBDPlugin.pm b/PVE/Storage/RBDPlugin.pm index
>> b05d299..33ae853 100644
>> --- a/PVE/Storage/RBDPlugin.pm
>> +++ b/PVE/Storage/RBDPlugin.pm
>> @@ -56,7 +56,7 @@ sub rbd_ls {
>>
>>           $list->{$scfg->{pool}}->{$image} = {
>>               name => $image,
>> -             size => 0,
>> +             size => rbd_volume_size($scfg, $storeid, $image),
>>               vmid => $owner
>>           };
>>       }
>> @@ -72,6 +72,26 @@ sub rbd_ls {
>>      return $list;
>>  }
>>
>> +sub rbd_volume_size {
>> +    my ($scfg, $storeid, $volname) = @_;
>> +
>> +    my $cmd = &$rbd_cmd($scfg, $storeid, 'info', $volname);
>> +    my $size = undef;
>> +    my $parser = sub {
>> +     my $line = shift;
>> +
>> +     if ($line =~ m/size (\d+) MB in (\d+) objects/) {
>> +         $size = $1;
>> +     }
>> +    };
>> +
>> +    run_command($cmd, errmsg => "rbd error", errfunc => sub {}, outfunc
>> + => $parser);
>> +
>> +    $size = $size*1024*1024 if $size;
>> +
>> +    return $size;
>> +}
>> +
>>  sub addslashes {
>>      my $text = shift;
>>      $text =~ s/;/\\;/g;
>> @@ -282,21 +302,7 @@ sub deactivate_volume {  sub volume_size_info {
>>      my ($class, $scfg, $storeid, $volname, $timeout) = @_;
>>
>> -    my $cmd = &$rbd_cmd($scfg, $storeid, 'info', $volname);
>> -    my $size = undef;
>> -    my $parser = sub {
>> -        my $line = shift;
>> -
>> -        if ($line =~ m/size (\d+) MB in (\d+) objects/) {
>> -            $size = $1;
>> -        }
>> -    };
>> -
>> -    run_command($cmd, errmsg => "rbd error", errfunc => sub {}, outfunc =>
>> $parser);
>> -
>> -    $size = $size*1024*1024 if $size;
>> -
>> -    return $size;
>> +    return rbd_volume_size($scfg, $storeid, $volname);
>>  }
>>
>>  sub volume_resize {
>> --
>> 1.7.10.4
>>
>> _______________________________________________
>> pve-devel mailing list
>> pve-devel at pve.proxmox.com
>> http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
>
>
> _______________________________________________
> 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