Re: [libvirt] [PATCH] Log virRun command output, return with error

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

 



On Tue, Sep 23, 2008 at 04:56:45PM -0400, Cole Robinson wrote:
>      if ((ret = virExec(conn, argv, NULL, NULL,
> -                       &childpid, -1, NULL, NULL, VIR_EXEC_NONE)) < 0)
> +                       &childpid, -1, &outfd, &errfd, VIR_EXEC_NONE)) < 0)
>          return ret;
>  
>      while ((ret = waitpid(childpid, &exitstatus, 0) == -1) && errno == EINTR);
> @@ -418,16 +430,31 @@ virRun(virConnectPtr conn,
>          return -1;
>      }
>  
> +    /* Log command output */
> +    if (outfd) {
> +        ret = saferead(outfd, out, sizeof(out)-1);
> +        err[ret < 0 ? 0 : ret] = '\0';
> +        if (*out)
> +            DEBUG("Command stdout: %s", out);
> +    }
> +    if (errfd) {
> +        ret = saferead(errfd, err, sizeof(err)-1);
> +        err[ret < 0 ? 0 : ret] = '\0';
> +        if (*err)
> +            DEBUG("Command stderr: %s", err);
> +    }
> +

I'm sure this works in tests, but I don't think it'll work reliably
all the time.

What happens if the command pauses for some time before sending output
to stdout/stderr?  You need to integrate these in the event loop,
which is going to make everything a lot more complicated.

Rich.

-- 
Richard Jones, Emerging Technologies, Red Hat  http://et.redhat.com/~rjones
virt-top is 'top' for virtual machines.  Tiny program with many
powerful monitoring features, net stats, disk stats, logging, etc.
http://et.redhat.com/~rjones/virt-top

--
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]