[libvirt] [PATCH] openvz: Restore original EOF handling in openvzGetProcessInfo

This function is also affected by getline conversion. But this didn't result in a regression in general, because the difference whould only affect the behavior of the function when the line in /proc/vz/vestat for the given vpsid wasn't found. Under normal conditions this should not happen. --- src/openvz/openvz_driver.c | 7 +++++-- 1 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c index ae951a2..e24b5d8 100644 --- a/src/openvz/openvz_driver.c +++ b/src/openvz/openvz_driver.c @@ -1507,6 +1507,7 @@ static int openvzGetProcessInfo(unsigned long long *cpuTime, int vpsid) unsigned long long usertime, systime, nicetime; int readvps = vpsid + 1; /* ensure readvps is initially different */ ssize_t ret; + int err = 0; /* read statistic from /proc/vz/vestat. sample: @@ -1522,8 +1523,10 @@ Version: 2.2 /*search line with VEID=vpsid*/ while (1) { ret = getline(&line, &line_size, fp); - if (ret <= 0) + if (ret < 0) { + err = !feof(fp); break; + } if (sscanf (line, "%d %llu %llu %llu", &readvps, &usertime, &nicetime, &systime) == 4 @@ -1538,7 +1541,7 @@ Version: 2.2 VIR_FREE(line); VIR_FORCE_FCLOSE(fp); - if (ret < 0) + if (err) return -1; if (readvps != vpsid) /*not found*/ -- 1.7.0.4

On 05/27/2011 09:47 AM, Matthias Bolte wrote:
This function is also affected by getline conversion. But this didn't result in a regression in general, because the difference whould only affect the behavior of the function when the line in /proc/vz/vestat for the given vpsid wasn't found. Under normal conditions this should not happen. --- src/openvz/openvz_driver.c | 7 +++++-- 1 files changed, 5 insertions(+), 2 deletions(-)
ACK. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

2011/5/31 Eric Blake <eblake@redhat.com>:
On 05/27/2011 09:47 AM, Matthias Bolte wrote:
This function is also affected by getline conversion. But this didn't result in a regression in general, because the difference whould only affect the behavior of the function when the line in /proc/vz/vestat for the given vpsid wasn't found. Under normal conditions this should not happen. --- src/openvz/openvz_driver.c | 7 +++++-- 1 files changed, 5 insertions(+), 2 deletions(-)
ACK.
Thanks, pushed. Matthias
participants (2)
-
Eric Blake
-
Matthias Bolte