return ret;
}
-static void
-vboxDumpNetwork(virDomainNetDefPtr net, vboxDriverPtr data, INetworkAdapter *adapter)
+static virDomainNetDefPtr
+vboxDumpNetwork(vboxDriverPtr data, INetworkAdapter *adapter)
{
PRUint32 attachmentType = NetworkAttachmentType_Null;
PRUint32 adapterType = NetworkAdapterType_Null;
PRUnichar *MACAddressUtf16 = NULL;
char *MACAddress = NULL;
char macaddr[VIR_MAC_STRING_BUFLEN] = {0};
+ virDomainNetDefPtr net = NULL;
+
+ if (VIR_ALLOC(net) < 0)
+ return NULL;
gVBoxAPI.UINetworkAdapter.GetAttachmentType(adapter, &attachmentType);
if (attachmentType == NetworkAttachmentType_NAT) {
VBOX_UTF16_FREE(MACAddressUtf16);
VBOX_UTF8_FREE(MACAddress);
+ return net;
}
static void
}
/* Allocate memory for the networkcards which are enabled */
- if ((def->nnets > 0) && (VIR_ALLOC_N(def->nets, def->nnets) >= 0)) {
- for (i = 0; i < def->nnets; i++)
- ignore_value(VIR_ALLOC(def->nets[i]));
- }
+ if (def->nnets > 0)
+ ignore_value(VIR_ALLOC_N(def->nets, def->nnets));
/* Now get the details about the network cards here */
for (i = 0; netAdpIncCnt < def->nnets && i < networkAdapterCount; i++) {
INetworkAdapter *adapter = NULL;
- virDomainNetDefPtr net = def->nets[netAdpIncCnt];
+ virDomainNetDefPtr net = NULL;
PRBool enabled = PR_FALSE;
gVBoxAPI.UIMachine.GetNetworkAdapter(machine, i, &adapter);
gVBoxAPI.UINetworkAdapter.GetEnabled(adapter, &enabled);
if (enabled) {
- vboxDumpNetwork(net, data, adapter);
-
- netAdpIncCnt++;
+ net = vboxDumpNetwork(data, adapter);
+ def->nets[netAdpIncCnt++] = net;
}
VBOX_RELEASE(adapter);