Submit patch on Tools.pm and pvemanagerlib.js

hashment

New Member
Jan 26, 2010
3
0
1
Hi all,
I encountered a problem few days ago trying to get console on a Proxmox cluster that have an very big uptime.
I didn't manage to get console with the following message :
unable to parse worker upid '......'
I note that the regexp in the Tools.pm perl module was wrong.
When I modify it, I got another message because hex command in upid_decode function cannot transform too big hex value (more that 8 digits).

So I modify Tools.pm like this :

--- /usr/share/perl5/PVE/Tools_20140618.pm 2014-06-18 14:20:40.000000000 +0200
+++ /usr/share/perl5/PVE/Tools.pm 2014-06-24 12:37:49.000000000 +0200
@@ -16,6 +16,7 @@
use Digest::SHA;
use Text::ParseWords;
use String::ShellQuote;
+use Math::BigInt; # Fortunately this module seems to be installed - let's use it !

our @EXPORT_OK = qw(
lock_file
@@ -758,11 +759,11 @@
my $filename;

# "UPID:$node:$pid:$pstart:$startime:$dtype:$id:$user"
- if ($upid =~ m/^UPID:([a-zA-Z0-9]([a-zA-Z0-9\-]*[a-zA-Z0-9])?):([0-9A-Fa-f]{8}):([0-9A-Fa-f]{8}):([0-9A-Fa-f]{8}):([^:\s]+):([^:\s]*):([^:\s]+):$/) {
+ if ($upid =~ m/^UPID:([a-zA-Z0-9]([a-zA-Z0-9\-]*[a-zA-Z0-9])?):([0-9A-Fa-f]{8,16}):([0-9A-Fa-f]{8,16}):([0-9A-Fa-f]{8,16}):([^:\s]+):([^:\s]*):([^:\s]+):$/) {
$res->{node} = $1;
- $res->{pid} = hex($3);
- $res->{pstart} = hex($4);
- $res->{starttime} = hex($5);
+ $res->{pid} = Math::BigInt->from_hex($3);
+ $res->{pstart} = Math::BigInt->from_hex($4);
+ $res->{starttime} = Math::BigInt->from_hex($5);
$res->{type} = $6;
$res->{id} = $7;
$res->{user} = $8;

Then I note that another script used that regexp :
--- /usr/share/pve-manager/ext4/pvemanagerlib_20140618.js 2014-06-18 14:24:26.000000000 +0200
+++ /usr/share/pve-manager/ext4/pvemanagerlib.js 2014-06-24 12:36:52.000000000 +0200
@@ -529,7 +529,7 @@
parse_task_upid: function(upid) {
var task = {};

- var res = upid.match(/^UPID:(\S+):([0-9A-Fa-f]{8}):([0-9A-Fa-f]{8}):([0-9A-Fa-f]{8}):([^:\s]+):([^:\s]*):([^:\s]+):$/);
+ var res = upid.match(/^UPID:(\S+):([0-9A-Fa-f]{8,16}):([0-9A-Fa-f]{8,16}):([0-9A-Fa-f]{8,16}):([^:\s]+):([^:\s]*):([^:\s]+):$/);
if (!res) {
throw "unable to parse upid '" + upid + "'";
}

It seems to work now.
Hope this can helps someone or inspire another.
Cheers.
 
Hi,
if pstart reaches 9 digits, you'll have a perl warning like this if you do not use Math::BigInt

Hexadecimal number > 0xffffffff non-portable at essai.pl line ....

I't just a warning, but it works. Maybe it doesn't matter .....
But it can be intercepted by an exception --> risk of bad interpretation.
Cheers.
 
Hi,
if pstart reaches 9 digits, you'll have a perl warning like this if you do not use Math::BigInt

Hexadecimal number > 0xffffffff non-portable at essai.pl line ....

I't just a warning, but it works. Maybe it doesn't matter .....
But it can be intercepted by an exception --> risk of bad interpretation.
Cheers.

OK, good catch.

can you submit patch to the proxmox dev mailing list ?