[PVE-User] Submitting patches

Flavio Stanchina flavio.stanchina at ies.it
Thu Feb 4 10:36:09 CET 2010


Dietmar Maurer wrote:
>> With this patch, the "Hardware device list for VM xxx" and the "Content
>> of Storage xxx" pages will show the used disk space for QCOW2 and raw
>> disk images, as reported by "qemu-img info $file". 
> 
> Many thank for the patch. Seems the qemu-server modifications are missing?

Ooops... sorry, I pasted the diffs for /usr/share/perl5/PVE/Storage.pm 
two times and forgot /usr/share/perl5/PVE/QemuServer.pm, here it is.

> Anyways, I don't think the 'Hardware device list' is the right place to
> display that info. Instead we should display that in the Storage browser?

Well, I like it in both places. The right place is definitely the 
storage browser, as that's where the admin would look to check where his 
disk space is being used up. But it's also useful in the VM device list, 
so one doesn't have to take note of the volume ID and switch to the 
storage browser to see how much disk space this machine is using.

-- 
Flavio Stanchina
Informatica e Servizi
Trento - Italy

-------------- next part --------------
--- /usr/share/perl5/PVE/QemuServer.pm.orig	2010-01-11 08:32:12.000000000 +0100
+++ /usr/share/perl5/PVE/QemuServer.pm	2010-01-22 17:30:40.000000000 +0100
@@ -860,7 +860,10 @@
 	next if drive_is_cdrom ($di);
 
 	if ($di->{file} =~ m|^/dev/.+|) {
-	    $info->{$di->{file}}->{size} = PVE::Storage::file_size_info ($di->{file});
+	    #$info->{$di->{file}}->{size} = PVE::Storage::file_size_info ($di->{file});
+	    my ($size, $format, $used) = file_size_info ($di->{file});
+	    $info->{$di->{file}}->{size} = $size;
+	    $info->{$di->{file}}->{used} = $used;
 	} else {
 	    push @$vollist, $di->{file};
 	}
@@ -881,6 +884,8 @@
 
 	$res->{$ds}->{disksize} = $info->{$di->{file}} ? 
 	    $info->{$di->{file}}->{size} / (1024*1024) : 0;
+	$res->{$ds}->{diskused} = $info->{$di->{file}} ? 
+	    $info->{$di->{file}}->{used} : '?';
     }
 
     return $res;
@@ -954,6 +959,7 @@
 
     my $disksize = 0;
     my $disktype = 'none';
+    my $diskused = '?';
  
     my $di = load_diskinfo ($storecfg, $vmid, $res);
 
@@ -962,11 +968,13 @@
 	if ($res->{bootdisk} && ($ds eq $res->{bootdisk}) && $size) {
 	    $disksize = $size;
 	    $disktype = $di->{$ds}->{interface};
+	    $diskused = $di->{$ds}->{diskused};
 	}
     }
 
     $res->{disksize} = $disksize;
     $res->{disktype} = $disktype;
+    $res->{diskused} = $diskused;
     $res->{diskinfo} = $di;
 
     return $res;


More information about the pve-user mailing list