[libvirt] Segfault in virCommandRun when trying to start a QEMU guest

Matthias Bolte matthias.bolte at googlemail.com
Sat Dec 4 23:54:24 UTC 2010


In qemudStartVMDaemon in/out/err for the virCommand are set based on
FDs this results in a segfault in virCommandRun here

    VIR_DEBUG("Result stdout: '%s' stderr: '%s'",
              NULLSTR(*cmd->outbuf),
              NULLSTR(*cmd->errbuf));

as cmd->outbuf and cmd->errbuf are NULL.

The two if blocks before that setup cmd->outbuf and cmd->errbuf in
case the caller didn't request output capturing aren't executed
because the caller requested to capture the output to FDs.

    /* If caller hasn't requested capture of stdout/err, then capture
     * it ourselves so we can log it.
     */
    if (!cmd->outfdptr) {
        cmd->outfdptr = &cmd->outfd;
        cmd->outbuf = &outbuf;
    }
    if (!cmd->errfdptr) {
        cmd->errfdptr = &cmd->errfd;
        cmd->errbuf = &errbuf;
    }

In the case the caller requested to capture the output to FDs there is
no capturing to cmd->outbuf and cmd->errbuf and they stay NULL.

When I remove that offending VIR_DEBUG line everything works fine.

Also this case of FD only usage is not yet covered in the command API
test cases.

Matthias




More information about the libvir-list mailing list