On Mon, Jan 23, 2012 at 04:21:17PM +0100, Martin Kletzander wrote: > One more parameter added into the function parsing /proc/<pid>/stat > and the call of the function is fixed as well. > --- > src/qemu/qemu_driver.c | 25 ++++++++++++++++++------- > 1 files changed, 18 insertions(+), 7 deletions(-) > > diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c > index 608e82a..e82c0d5 100644 > --- a/src/qemu/qemu_driver.c > +++ b/src/qemu/qemu_driver.c > @@ -1049,12 +1049,13 @@ cleanup: > > > static int > -qemudGetProcessInfo(unsigned long long *cpuTime, int *lastCpu, int pid, > - int tid) > +qemudGetProcessInfo(unsigned long long *cpuTime, int *lastCpu, long *vm_rss, > + int pid, int tid) > { > char *proc; > FILE *pidinfo; > unsigned long long usertime, systime; > + long rss; > int cpu; > int ret; > > @@ -1071,6 +1072,8 @@ qemudGetProcessInfo(unsigned long long *cpuTime, int *lastCpu, int pid, > *cpuTime = 0; > if (lastCpu) > *lastCpu = 0; > + if (vm_rss) > + *vm_rss = 0; > VIR_FREE(proc); > return 0; > } > @@ -1082,10 +1085,10 @@ qemudGetProcessInfo(unsigned long long *cpuTime, int *lastCpu, int pid, > /* pid -> stime */ > "%*d %*s %*c %*d %*d %*d %*d %*d %*u %*u %*u %*u %*u %llu %llu" > /* cutime -> endcode */ > - "%*d %*d %*d %*d %*d %*u %*u %*d %*u %*u %*u %*u" > + "%*d %*d %*d %*d %*d %*u %*u %ld %*u %*u %*u %*u" > /* startstack -> processor */ > "%*u %*u %*u %*u %*u %*u %*u %*u %*u %*u %*d %d", > - &usertime, &systime, &cpu) != 3) { > + &usertime, &systime, &rss, &cpu) != 4) { > VIR_FORCE_FCLOSE(pidinfo); > VIR_WARN("cannot parse process status data"); > errno = -EINVAL; > @@ -1102,9 +1105,16 @@ qemudGetProcessInfo(unsigned long long *cpuTime, int *lastCpu, int pid, > if (lastCpu) > *lastCpu = cpu; > > + /* We got pages > + * We want kiloBytes > + * _SC_PAGESIZE is page size in Bytes > + * So calculate, but first lower the pagesize so we don't get overflow */ > + if (vm_rss) > + *vm_rss = rss * (sysconf(_SC_PAGESIZE) >> 10); > > - VIR_DEBUG("Got status for %d/%d user=%llu sys=%llu cpu=%d", > - pid, tid, usertime, systime, cpu); > + > + VIR_DEBUG("Got status for %d/%d user=%llu sys=%llu cpu=%d rss=%ld", > + pid, tid, usertime, systime, cpu, rss); > > VIR_FORCE_FCLOSE(pidinfo); > > @@ -2066,7 +2076,7 @@ static int qemudDomainGetInfo(virDomainPtr dom, > if (!virDomainObjIsActive(vm)) { > info->cpuTime = 0; > } else { > - if (qemudGetProcessInfo(&(info->cpuTime), NULL, vm->pid, 0) < 0) { > + if (qemudGetProcessInfo(&(info->cpuTime), NULL, NULL, vm->pid, 0) < 0) { > qemuReportError(VIR_ERR_OPERATION_FAILED, "%s", > _("cannot read cputime for domain")); > goto cleanup; > @@ -3648,6 +3658,7 @@ qemudDomainGetVcpus(virDomainPtr dom, > if (priv->vcpupids != NULL && > qemudGetProcessInfo(&(info[i].cpuTime), > &(info[i].cpu), > + NULL, > vm->pid, > priv->vcpupids[i]) < 0) { > virReportSystemError(errno, "%s", Looks just fine, ACK Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ daniel@xxxxxxxxxxxx | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/ -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list