[DRBD-user] drbdmanage-proxmox v2.0

Roland Kammerer roland.kammerer at linbit.com
Thu Sep 28 12:11:10 CEST 2017

Note: "permalinks" may not be as permanent as we would like,
direct links of old sources may well be a few messages off.


On Thu, Sep 28, 2017 at 11:51:28AM +0200, Robert Altnoeder wrote:
> On 09/28/2017 11:10 AM, Frank Rust wrote:
> > Hi Roland,
> > I am not a perl-friend too.
> +1
> > +    my $x=$size;
> > +    my $unit="gib"; # GiB is default
> > +    my $factor=1024*1024;
> > +    if ($x/$factor != int($x/$factor)) {
> > +      $factor=$factor/1024; $unit="mib";
> > +      if ($x/$factor != int($x/$factor)) {
> > +        $factor=$factor/1024; $unit="kib";
> > +      }
> > +    };
> > +    $size=sprintf("%u%s",($x/$factor),$unit);
> > +    print "Size=$size\n";
> > +
> >      drbdmanage_cmd(['/usr/bin/drbdmanage', 'new-resource', $name], "Could not create resource $name");
> >      drbdmanage_cmd(['/usr/bin/drbdmanage', 'new-volume', $name, $size], "Could not create-volume in $name resource");
> Apparently, the original size ($size) is in kiB, so the question would
> rather be whether it makes much sense to recalculate the size in a
> different unit if it is only going to be used for a machine-to-machine
> interface.

It does not make any sense. I will commit something along these lines
soon:

diff --git a/DRBDPlugin.pm b/DRBDPlugin.pm
index c4c95e5..dea96f6 100644
--- a/DRBDPlugin.pm
+++ b/DRBDPlugin.pm
@@ -153,7 +153,7 @@ sub alloc_image {
     die "unable to allocate an image name for VM $vmid in storage '$storeid'\n"
     if !defined($name);

-    $size = ($size/1024/1024);
+    $size = $size . 'KiB';
     drbdmanage_cmd(['/usr/bin/drbdmanage', 'new-resource', $name], "Could not create resource $name");
     drbdmanage_cmd(['/usr/bin/drbdmanage', 'new-volume', $name, $size], "Could not create-volume in $name resource");
     drbdmanage_cmd(['/usr/bin/drbdmanage', 'net-options', '--resource', $name, '--allow-two-primaries=yes'], "Could not set 'allow-two-primaries'");
@@ -308,7 +308,7 @@ sub deactivate_volume {
 sub volume_resize {
     my ($class, $scfg, $storeid, $volname, $size, $running) = @_;

-    $size = ($size/1024/1024/1024);
+    $size = ($size/1024) . 'kiB';
     drbdmanage_cmd(['/usr/bin/drbdmanage', 'resize', $volname, 0, $size], "Could not resize $volname");

     return 1;


"Funny" fact: sometimes you get the size from proxmox in KiB, sometimes
in bytes...

Regards, rck



More information about the drbd-user mailing list