Re: [PATCH] qemu: add reporting of vCPU wait time

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Dec 10, 2015 at 02:41:56PM +0000, Daniel P. Berrange wrote:
> diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
> index 783a7cd..5293294 100644
> --- a/src/qemu/qemu_driver.c
> +++ b/src/qemu/qemu_driver.c
> @@ -1361,6 +1361,80 @@ static char *qemuConnectGetCapabilities(virConnectPtr conn) {
>  
>  
>  static int
> +qemuGetSchedInfo(unsigned long long *cpuWait,
> +                 pid_t pid, pid_t tid)
> +{
> +    char *proc = NULL;
> +    char *data = NULL;
> +    char **lines = NULL;
> +    size_t i;
> +    int ret = -1;
> +    double val;
> +
> +    *cpuWait = 0;
> +

> +    /* In general, we cannot assume pid_t fits in int; but /proc parsing
> +     * is specific to Linux where int works fine.  */
> +    if (tid)
> +        ret = virAsprintf(&proc, "/proc/%d/task/%d/sched", (int)pid, (int)tid);
> +    else
> +        ret = virAsprintf(&proc, "/proc/%d/sched", (int)pid);
> +    if (ret < 0)
> +        goto cleanup;
> +

After this hunk, ret contains the positive integer returned by
virAsprintf instead of the expected value of -1.

> +    /* The file is not guaranteed to exist (needs CONFIG_SCHED_DEBUG) */
> +    if (access(proc, R_OK) < 0)
> +        return 0;
> +
> +    if (virFileReadAll(proc, (1<<16), &data) < 0)
> +        goto cleanup;
> +
> +    lines = virStringSplit(data, "\n", 0);
> +    if (!lines)
> +        goto cleanup;
> +
> +    for (i = 0; lines[i] != NULL; i++) {
> +        const char *line = lines[i];
> +
> +        /* Needs CONFIG_SCHEDSTATS. The second check
> +         * is the old name the kernel used in past */
> +        if (STRPREFIX(line, "se.statistics.wait_sum") ||
> +            STRPREFIX(line, "se.wait_sum")) {
> +            line = strchr(line, ':');
> +            if (!line) {
> +                virReportError(VIR_ERR_INTERNAL_ERROR,
> +                               _("Missing separate in sched info '%s'"),
> +                               lines[i]);
> +                goto cleanup;
> +            }
> +            line++;
> +            while (*line == ' ') {
> +                line++;
> +            }

This breaks syntax check:

Curly brackets around single-line body:
src/qemu/qemu_driver.c:1411-1413:
            while (*line == ' ') {
                line++;
            }

Jan

Attachment: signature.asc
Description: Digital signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]