Re: [PATCH v6 04/23] conf: add APIs to convert virDomainNetDef to virNetworkPortDef

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

 



[...]

> +virNetworkPortDefPtr
> +virDomainNetDefToNetworkPort(virDomainDefPtr dom,
> +                             virDomainNetDefPtr iface)
> +{
> +    virNetworkPortDefPtr port;
> +
> +    if (iface->type != VIR_DOMAIN_NET_TYPE_NETWORK) {
> +        virReportError(VIR_ERR_INTERNAL_ERROR,
> +                       _("Expected an interface of type 'network' not '%s'"),
> +                       virDomainNetTypeToString(iface->type));
> +        return NULL;
> +    }
> +
> +    if (VIR_ALLOC(port) < 0)
> +        return NULL;
> +
> +    virUUIDGenerate(port->uuid);

Coverity notes that here and ...

[...]

> +
> +virNetworkPortDefPtr
> +virDomainNetDefActualToNetworkPort(virDomainDefPtr dom,
> +                                   virDomainNetDefPtr iface)
> +{
> +    virDomainActualNetDefPtr actual;
> +    virNetworkPortDefPtr port;
> +
> +    if (!iface->data.network.actual) {
> +        virReportError(VIR_ERR_INTERNAL_ERROR,
> +                       _("Missing actual data for interface '%s'"),
> +                       iface->ifname);
> +        return NULL;
> +    }
> +
> +    actual = iface->data.network.actual;
> +
> +    if (iface->type != VIR_DOMAIN_NET_TYPE_NETWORK) {
> +        virReportError(VIR_ERR_INTERNAL_ERROR,
> +                       _("Expected an interface of type 'network' not '%s'"),
> +                       virDomainNetTypeToString(iface->type));
> +        return NULL;
> +    }
> +
> +    if (VIR_ALLOC(port) < 0)
> +        return NULL;
> +
> +    /* Bad - we need to preserve original port uuid */
> +    virUUIDGenerate(port->uuid);

... here calls are made to virUUIDGenerate that could fail, but we don't
return on that failure

John

> +
> +    memcpy(port->owneruuid, dom->uuid, VIR_UUID_BUFLEN);
> +    if (VIR_STRDUP(port->ownername, dom->name) < 0)
> +        goto error;
> +
> +    if (VIR_STRDUP(port->group, iface->data.network.portgroup) < 0)
> +        goto error;
> +
> +    memcpy(&port->mac, &iface->mac, VIR_MAC_BUFLEN);
> +

[...]

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

  Powered by Linux