> >      free(virtTestLogContentAndReset());
> >      cmd = virCommandNew(abs_builddir "/commandhelper-doesnotexist");
> > -    if (virCommandRun(cmd, NULL) == 0)
> > +    if (!cmd || virCommandRun(cmd, NULL) == 0)
> 
> The API explicitly does *not* require you to check
> !cmd after virCommandNew. virCommandRun() and other
> APis will check that for you and return ENOMEM.

That was my suspicion too but then I looked at virCommandRun implementation
and saw this:

    if (!cmd || cmd->has_error == -1) {
        virCommandError(VIR_ERR_INTERNAL_ERROR, "%s",
                        _("invalid use of command API"));
        return -1;
    }
    if (cmd->has_error == ENOMEM) {
        virReportOOMError();
        return -1;
    }

That is, if virCommandNew() returns NULL for either reason, by running
virCommandRun() on it, the original error (probably OOM) gets overwritten by
an internal error.

Jirka

--
libvir-list mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/libvir-list

Reply via email to