[pve-devel] [PATCH qemu-server 1/2] Add disk operations to vmstatus

Tobias Böhm tb at robhost.de
Mon Jun 19 12:09:59 CEST 2017


Currently, only read/write bytes are extracted from qemu blockstats.
In order to provide IO operation stats these counters need to be read as well.

Signed-off-by: Tobias Böhm <tb at robhost.de>
---
 PVE/QemuServer.pm | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 1a4860e..5ee2348 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -2616,6 +2616,9 @@ sub vmstatus {
 	$d->{diskread} = 0;
 	$d->{diskwrite} = 0;
 
+	$d->{ioread} = 0;
+	$d->{iowrite} = 0;
+
         $d->{template} = PVE::QemuConfig->is_template($conf);
 
 	$res->{$vmid} = $d;
@@ -2712,16 +2715,22 @@ sub vmstatus {
 	my $data = $resp->{'return'} || [];
 	my $totalrdbytes = 0;
 	my $totalwrbytes = 0;
+	my $totalrdio = 0;
+	my $totalwrio = 0;
 
 	for my $blockstat (@$data) {
 	    $totalrdbytes = $totalrdbytes + $blockstat->{stats}->{rd_bytes};
 	    $totalwrbytes = $totalwrbytes + $blockstat->{stats}->{wr_bytes};
+	    $totalrdio = $totalrdio + $blockstat->{stats}->{rd_operations};
+	    $totalwrio = $totalwrio + $blockstat->{stats}->{wr_operations};
 
 	    $blockstat->{device} =~ s/drive-//;
 	    $res->{$vmid}->{blockstat}->{$blockstat->{device}} = $blockstat->{stats};
 	}
 	$res->{$vmid}->{diskread} = $totalrdbytes;
 	$res->{$vmid}->{diskwrite} = $totalwrbytes;
+	$res->{$vmid}->{ioread} = $totalrdio;
+	$res->{$vmid}->{iowrite} = $totalwrio;
     };
 
     my $statuscb = sub {
-- 
2.11.0




More information about the pve-devel mailing list