goto error;
if (n_leases) {
+ const char *ifname = def->nets[i]->ifname;
+
+ if (!ifname) {
+ ifname = def->nets[i]->info.alias;
+ }
+
ifaces_ret = g_renew(virDomainInterfacePtr, ifaces_ret, ifaces_count + 1);
ifaces_ret[ifaces_count] = g_new0(virDomainInterface, 1);
iface = ifaces_ret[ifaces_count];
/* Assuming each lease corresponds to a separate IP */
iface->naddrs = n_leases;
iface->addrs = g_new0(virDomainIPAddress, iface->naddrs);
- iface->name = g_strdup(def->nets[i]->ifname);
+ iface->name = g_strdup(ifname);
iface->hwaddr = g_strdup(macaddr);
}
virArpTableEntry entry = table->t[j];
if (STREQ(entry.mac, macaddr)) {
+ const char *ifname = def->nets[i]->ifname;
+
+ if (!ifname) {
+ ifname = def->nets[i]->info.alias;
+ }
+
iface = g_new0(virDomainInterface, 1);
- iface->name = g_strdup(def->nets[i]->ifname);
+ iface->name = g_strdup(ifname);
iface->hwaddr = g_strdup(macaddr);
* Note that for some @source values some pieces of returned @ifaces
* might be unset (e.g. VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_ARP does not
* set IP address prefix as ARP table does not have any notion of that).
+ * Moreover, it may happen that the interface doesn't have a name. In
+ * that case, @ifaces->name is set to the interface's device alias.
*
* @ifaces->name is never NULL, and @ifaces->hwaddr may be NULL.
*