[libvirt] [PATCH 1/3] util: new function virNetDevOpenvswitchInterfaceGetMaster()

Laine Stump laine at laine.org
Mon Jul 2 22:08:25 UTC 2018


On 07/02/2018 02:11 AM, Michal Prívozník wrote:
> On 07/02/2018 01:46 AM, Laine Stump wrote:
>> +    virNetDevOpenvswitchAddTimeout(cmd);
>> +    virCommandAddArgList(cmd, "iface-to-br", ifname, NULL);
>> +    virCommandSetOutputBuffer(cmd, master);
>> +
>> +    if (virCommandRun(cmd, &exitstatus) < 0) {
>> +        virReportError(VIR_ERR_INTERNAL_ERROR,
>> +                       _("Unable to run command to get OVS master for "
>> +                         "interface %s"), ifname);
>> +        goto cleanup;
>> +    }
>> +
>> +    /* non-0 exit code just means that the interface has no master in OVS */
>> +    if (exitstatus != 0)
>> +        VIR_FREE(*master);
> A-ha! We indeed need to do this. I was under impression that just like
> other functions of ours if they fail no allocation is done. But this is
> different so we need to call VIR_FREE().

Right. If ovs-vsctl is run and returns non-0, there still might have
been some sort of output to stdout (or there might not have been, but I
don't want to rely on it).




More information about the libvir-list mailing list