---
src/vbox/vbox_network.c | 72 +++++++++++++++++++++++++++++++++++++++++
src/vbox/vbox_tmpl.c | 68 --------------------------------------
src/vbox/vbox_uniformed_api.h | 1 +
3 files changed, 73 insertions(+), 68 deletions(-)
diff --git a/src/vbox/vbox_network.c b/src/vbox/vbox_network.c
index 60fbe5e..2fc8230 100644
--- a/src/vbox/vbox_network.c
+++ b/src/vbox/vbox_network.c
@@ -734,3 +734,75 @@ int vboxNetworkDestroy(virNetworkPtr network)
{
return vboxNetworkUndefineDestroy(network, false);
}
+
+int vboxNetworkCreate(virNetworkPtr network)
+{
+ vboxGlobalData *data = network->conn->privateData;
+ char *networkNameUtf8 = NULL;
+ PRUnichar *networkInterfaceNameUtf16 = NULL;
+ IHostNetworkInterface *networkInterface = NULL;
+ PRUnichar *networkNameUtf16 = NULL;
+ IDHCPServer *dhcpServer = NULL;
+ PRUnichar *trunkTypeUtf16 = NULL;
+ PRUint32 interfaceType = 0;
+ IHost *host = NULL;
+ int ret = -1;
+
+ if (!data->vboxObj)
+ return ret;
+
+ gVBoxAPI.UIVirtualBox.GetHost(data->vboxObj, &host);
+ if (!host)
+ return ret;
+
+ /* Current limitation of the function for VirtualBox 2.2.* is
+ * that the default hostonly network "vboxnet0" is always active
+ * and thus all this functions does is start the dhcp server,
+ * but the network can still be used without starting the dhcp
+ * server by giving the machine static IP
+ */
+
+ if (virAsprintf(&networkNameUtf8, "HostInterfaceNetworking-%s",
network->name) < 0)
+ goto cleanup;
+
+ VBOX_UTF8_TO_UTF16(network->name, &networkInterfaceNameUtf16);
+
+ gVBoxAPI.UIHost.FindHostNetworkInterfaceByName(host, networkInterfaceNameUtf16,
&networkInterface);
+
+ if (!networkInterface)
+ goto cleanup;
+
+ gVBoxAPI.UIHNInterface.GetInterfaceType(networkInterface, &interfaceType);
+
+ if (interfaceType != HostNetworkInterfaceType_HostOnly)
+ goto cleanup;
+
+ VBOX_UTF8_TO_UTF16(networkNameUtf8, &networkNameUtf16);
+
+ gVBoxAPI.UIVirtualBox.FindDHCPServerByNetworkName(data->vboxObj,
+ networkNameUtf16,
+ &dhcpServer);
+ if (!dhcpServer)
+ goto cleanup;
+
+ gVBoxAPI.UIDHCPServer.SetEnabled(dhcpServer, PR_TRUE);
+
+ VBOX_UTF8_TO_UTF16("netflt", &trunkTypeUtf16);
+
+ gVBoxAPI.UIDHCPServer.Start(dhcpServer,
+ networkNameUtf16,
+ networkInterfaceNameUtf16,
+ trunkTypeUtf16);
+
+ VBOX_UTF16_FREE(trunkTypeUtf16);
+ ret = 0;
+
+ cleanup:
+ VBOX_RELEASE(dhcpServer);
+ VBOX_UTF16_FREE(networkNameUtf16);
+ VBOX_RELEASE(networkInterface);
+ VBOX_UTF16_FREE(networkInterfaceNameUtf16);
+ VBOX_RELEASE(host);
+ VIR_FREE(networkNameUtf8);
+ return ret;
+}
diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c
index c072246..8712a3b 100644
--- a/src/vbox/vbox_tmpl.c
+++ b/src/vbox/vbox_tmpl.c
@@ -2042,74 +2042,6 @@ _registerDomainEvent(virDriverPtr driver)
* The Network Functions here on
*/
-static int vboxNetworkCreate(virNetworkPtr network)
-{
- VBOX_OBJECT_HOST_CHECK(network->conn, int, -1);
- char *networkNameUtf8 = NULL;
- PRUnichar *networkInterfaceNameUtf16 = NULL;
- IHostNetworkInterface *networkInterface = NULL;
-
- /* Current limitation of the function for VirtualBox 2.2.* is
- * that the default hostonly network "vboxnet0" is always active
- * and thus all this functions does is start the dhcp server,
- * but the network can still be used without starting the dhcp
- * server by giving the machine static IP
- */
-
- if (virAsprintf(&networkNameUtf8, "HostInterfaceNetworking-%s",
network->name) < 0)
- goto cleanup;
-
- VBOX_UTF8_TO_UTF16(network->name, &networkInterfaceNameUtf16);
-
- host->vtbl->FindHostNetworkInterfaceByName(host, networkInterfaceNameUtf16,
&networkInterface);
-
- if (networkInterface) {
- PRUint32 interfaceType = 0;
-
- networkInterface->vtbl->GetInterfaceType(networkInterface,
&interfaceType);
-
- if (interfaceType == HostNetworkInterfaceType_HostOnly) {
- PRUnichar *networkNameUtf16 = NULL;
- IDHCPServer *dhcpServer = NULL;
-
-
- VBOX_UTF8_TO_UTF16(networkNameUtf8, &networkNameUtf16);
-
- data->vboxObj->vtbl->FindDHCPServerByNetworkName(data->vboxObj,
- networkNameUtf16,
- &dhcpServer);
- if (dhcpServer) {
- PRUnichar *trunkTypeUtf16 = NULL;
-
- dhcpServer->vtbl->SetEnabled(dhcpServer, PR_TRUE);
-
- VBOX_UTF8_TO_UTF16("netflt", &trunkTypeUtf16);
-
- dhcpServer->vtbl->Start(dhcpServer,
- networkNameUtf16,
- networkInterfaceNameUtf16,
- trunkTypeUtf16);
-
- VBOX_UTF16_FREE(trunkTypeUtf16);
- VBOX_RELEASE(dhcpServer);
- }
-
- VBOX_UTF16_FREE(networkNameUtf16);
- }
-
- VBOX_RELEASE(networkInterface);
- }
-
- VBOX_UTF16_FREE(networkInterfaceNameUtf16);
- VBOX_RELEASE(host);
-
- ret = 0;
-
- cleanup:
- VIR_FREE(networkNameUtf8);
- return ret;
-}
-
static char *vboxNetworkGetXMLDesc(virNetworkPtr network,
unsigned int flags)
{
diff --git a/src/vbox/vbox_uniformed_api.h b/src/vbox/vbox_uniformed_api.h
index 8f713af..f0b98c0 100644
--- a/src/vbox/vbox_uniformed_api.h
+++ b/src/vbox/vbox_uniformed_api.h
@@ -593,6 +593,7 @@ virNetworkPtr vboxNetworkCreateXML(virConnectPtr conn, const char
*xml);
virNetworkPtr vboxNetworkDefineXML(virConnectPtr conn, const char *xml);
int vboxNetworkUndefine(virNetworkPtr network);
int vboxNetworkDestroy(virNetworkPtr network);
+int vboxNetworkCreate(virNetworkPtr network);
/* Version specified functions for installing uniformed API */
void vbox22InstallUniformedAPI(vboxUniformedAPI *pVBoxAPI);
--
1.7.9.5