Note: "permalinks" may not be as permanent as we would like,
direct links of old sources may well be a few messages off.
Hi Roland,
I am not a perl-friend too. Maybe my solution is ugly and not performant but it works for me.
root at virt5:/usr/share/perl5/PVE/Storage/Custom# diff -u DRBDPlugin.pm.orig-2.2-1 DRBDPlugin.pm.Frank-2.1-1
--- DRBDPlugin.pm.orig-2.2-1 2017-09-27 09:45:09.770649386 +0200
+++ DRBDPlugin.pm.Frank-2.1-1 2017-09-28 11:05:21.645594981 +0200
@@ -84,10 +84,14 @@
}
sub drbdmanage_cmd {
+#use Data::Dumper;
# be extra pedantic.
run_command(['/usr/bin/drbdmanage', 'wait-for-startup'], errmsg => 'drbdmanage not ready');
my ($cmd, $errormsg) = @_;
+#print "Exec cmd( ";
+#print Dumper($cmd);
+#print " )\n";
run_command($cmd, errmsg => $errormsg);
}
@@ -153,7 +157,19 @@
die "unable to allocate an image name for VM $vmid in storage '$storeid'\n"
if !defined($name);
- $size = ($size/1024/1024);
+ #$size = ($size/1024/1024); # works only if size is multiple of 1024*1024, otherwise division will have decimals that break "new-volume"-command
+ 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");
drbdmanage_cmd(['/usr/bin/drbdmanage', 'net-options', '--resource', $name, '--allow-two-primaries=yes'], "Could not set 'allow-two-primaries'");
BTW: I am sure that I never added a VM Image that was not multiple of 1GB in size, but other storage implementations seem to have rounding errors causing strange sizes after moving images around...
Best regards,
Frank Rust
------------------------------------------------------------------------
Frank Rust Technische Universität Braunschweig
Fon: 0531 39155122 Institut für Systemsicherheit
Fax: 0531 39155130 Rebenring 56
Mail: f.rust at tu-braunschweig.de D-38106 Braunschweig
> Am 27.09.2017 um 10:31 schrieb Roland Kammerer <roland.kammerer at linbit.com>:
>
> On Wed, Sep 27, 2017 at 08:24:39AM +0200, Frank Rust wrote:
>> Hi Roland,
>> I just installed the latest version of drbdmanage-proxmox (2.1-1) and tried a "Move Disk" to drbdstorage.
>> Result is:
>> (…)
>>> "." is not a valid unit!
>> usage: drbdmanage add-volume [-h] [-m MINOR] [-d DEPLOY] [-s SITE] name size
>> (…)
>>
>> I debugged a bit and it shows the following command to be executed:
>>
>> Exec cmd( $VAR1 = [
>> '/usr/bin/drbdmanage',
>> 'new-volume',
>> 'vm-1018-disk-1',
>> '10.015625'
>> ];
>> )
>>
>> I think you should re-think the size calculation to be more precise than the current
>>
>>> $size = ($size/1024/1024);
>>
>> and hoping it will result in an integer…
>
> Yes, I totally agree. I did not invent that, code like that was already
> in place, but it smelled when I was looking at it, but for this release
> fixing the more fundamental bugs for customers was the first priority.
>
> Still, no excuse, that has to change eventually, I remember that I
> wanted to convert it down to M and call DM with $sizeM, but got lost in
> perl string conversion and kept the "old way".
>
> So this will change eventually, if you can contribute a fix[1], that
> would be great. In general I like perl as much as visual basic, so any
> contribution is highly appreciated ;-).
>
> Regards, rck
>
> [1] https://github.com/LINBIT/drbdmanage-proxmox/
> _______________________________________________
> drbd-user mailing list
> drbd-user at lists.linbit.com
> http://lists.linbit.com/mailman/listinfo/drbd-user