[pve-devel] [PATCH 2/2] monitor diskio with qmp command
Dietmar Maurer
dietmar at proxmox.com
Tue Jul 10 10:21:33 CEST 2012
The problem with that is that vmstatus needs to be fast, and should never block.
What if a KVM process hangs?
- Dietmar
> -----Original Message-----
> From: pve-devel-bounces at pve.proxmox.com [mailto:pve-devel-
> bounces at pve.proxmox.com] On Behalf Of Alexandre Derumier
> Sent: Freitag, 29. Juni 2012 12:35
> To: pve-devel at pve.proxmox.com
> Subject: [pve-devel] [PATCH 2/2] monitor diskio with qmp command
>
>
> Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
> ---
> PVE/QemuServer.pm | 19 +++++++++----------
> 1 files changed, 9 insertions(+), 10 deletions(-)
>
> diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm index
> 89b8454..a0d3a80 100644
> --- a/PVE/QemuServer.pm
> +++ b/PVE/QemuServer.pm
> @@ -1970,17 +1970,16 @@ sub vmstatus {
> my $pid = $d->{pid};
> next if !$pid;
>
> - if (my $fh = IO::File->new("/proc/$pid/io", "r")) {
> - my $data = {};
> - while (defined(my $line = <$fh>)) {
> - if ($line =~ m/^([rw]char):\s+(\d+)$/) {
> - $data->{$1} = $2;
> - }
> - }
> - close($fh);
> - $d->{diskread} = $data->{rchar} || 0;
> - $d->{diskwrite} = $data->{wchar} || 0;
> + my $blockstats = vm_mon_cmd($vmid, "query-blockstats");
> +
> + my $totalrdbytes = 0;
> + my $totalwrbytes = 0;
> + for my $blockstat ( @$blockstats ) {
> + $totalrdbytes = $totalrdbytes + $blockstat->{stats}->{rd_bytes};
> + $totalwrbytes = $totalwrbytes + $blockstat->{stats}->{wr_bytes};
> }
> + $d->{diskread} = $totalrdbytes;
> + $d->{diskwrite} = $totalwrbytes;
>
> my $pstat = PVE::ProcFSTools::read_proc_pid_stat($pid);
> next if !$pstat; # not running
> --
> 1.7.2.5
>
> _______________________________________________
> pve-devel mailing list
> pve-devel at pve.proxmox.com
> http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
More information about the pve-devel
mailing list