VIR_LOG_INIT("ch.ch_interface");
+
+static int
+virCHInterfaceUpdateNicindexes(virDomainNetDef *net,
+ int **nicindexes,
+ size_t *nnicindexes)
+{
+ int nicindex = 0;
+
+ if (!nicindexes || !nnicindexes || !net->ifname)
+ return 0;
+
+ if (virNetDevGetIndex(net->ifname, &nicindex) < 0)
+ return -1;
+
+ VIR_APPEND_ELEMENT(*nicindexes, *nnicindexes, nicindex);
+
+ return 0;
+}
+
+
/**
* virCHConnetNetworkInterfaces:
* @driver: pointer to ch driver object
net->driver.virtio.queues) < 0)
return -1;
+ if (virCHInterfaceUpdateNicindexes(net, nicindexes, nnicindexes) < 0)
+ return -1;
break;
case VIR_DOMAIN_NET_TYPE_NETWORK:
if (virDomainInterfaceBridgeConnect(vm, net,
false,
NULL) < 0)
return -1;
+
+ if (virCHInterfaceUpdateNicindexes(net, nicindexes, nnicindexes) < 0)
+ return -1;
break;
case VIR_DOMAIN_NET_TYPE_BRIDGE:
case VIR_DOMAIN_NET_TYPE_DIRECT:
+ if (virCHInterfaceUpdateNicindexes(net, nicindexes, nnicindexes) < 0)
+ return -1;
+ break;
case VIR_DOMAIN_NET_TYPE_USER:
case VIR_DOMAIN_NET_TYPE_SERVER:
case VIR_DOMAIN_NET_TYPE_CLIENT:
return -1;
}
- if (actualType == VIR_DOMAIN_NET_TYPE_ETHERNET ||
- actualType == VIR_DOMAIN_NET_TYPE_NETWORK ||
- actualType == VIR_DOMAIN_NET_TYPE_BRIDGE ||
- actualType == VIR_DOMAIN_NET_TYPE_DIRECT) {
- if (nicindexes && nnicindexes && net->ifname) {
- int nicindex = 0;
-
- if (virNetDevGetIndex(net->ifname, &nicindex) < 0)
- return -1;
-
- VIR_APPEND_ELEMENT(*nicindexes, *nnicindexes, nicindex);
- }
- }
-
return 0;
}