Hi All, I have added the support for hostonly and internal network as suggested on irc and list and am attaching the patch for same. PATCH 1/2: contains changes in the xml parsing/formatting on libvirt side namely adding a mode attribute to <source> tag in domain/interface xml PATCH 2/2: contains changes in the vbox driver itself. Regards, Pritesh
commit 43eb6ab5ce2ab1918c804614ca2b345858f2294c Author: Pritesh Kothari <Pritesh.Kothari@xxxxxxx> Date: Wed Apr 29 11:22:38 2009 +0200 hostonly and internal networking added with changes as specified on the list diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c index 7297172..9cc883f 100644 --- a/src/vbox/vbox_tmpl.c +++ b/src/vbox/vbox_tmpl.c @@ -1713,17 +1713,17 @@ static char *vboxDomainDumpXML(virDomainPtr dom, int flags) { data->pFuncs->pfnUtf8Free(hostInt); data->pFuncs->pfnUtf16Free(hostIntUtf16); -#if 0 } else if (attachmentType == NetworkAttachmentType_Internal) { PRUnichar *intNetUtf16 = NULL; char *intNet = NULL; - def->nets[netAdpIncCnt]->type = VIR_DOMAIN_NET_TYPE_INTERNAL; + def->nets[netAdpIncCnt]->type = VIR_DOMAIN_NET_TYPE_NETWORK; adapter->vtbl->GetInternalNetwork(adapter, &intNetUtf16); data->pFuncs->pfnUtf16ToUtf8(intNetUtf16, &intNet); - def->nets[netAdpIncCnt]->data.internal.name = strdup(intNet); + def->nets[netAdpIncCnt]->data.network.name = strdup(intNet); + def->nets[netAdpIncCnt]->data.network.mode = strdup("internal"); data->pFuncs->pfnUtf8Free(intNet); data->pFuncs->pfnUtf16Free(intNetUtf16); @@ -1732,17 +1732,17 @@ static char *vboxDomainDumpXML(virDomainPtr dom, int flags) { PRUnichar *hostIntUtf16 = NULL; char *hostInt = NULL; - def->nets[netAdpIncCnt]->type = VIR_DOMAIN_NET_TYPE_HOSTONLY; + def->nets[netAdpIncCnt]->type = VIR_DOMAIN_NET_TYPE_NETWORK; adapter->vtbl->GetHostInterface(adapter, &hostIntUtf16); data->pFuncs->pfnUtf16ToUtf8(hostIntUtf16, &hostInt); - def->nets[netAdpIncCnt]->data.hostonly.name = strdup(hostInt); + def->nets[netAdpIncCnt]->data.network.name = strdup(hostInt); + def->nets[netAdpIncCnt]->data.network.mode = strdup("hostonly"); data->pFuncs->pfnUtf8Free(hostInt); data->pFuncs->pfnUtf16Free(hostIntUtf16); -#endif } else { /* default to user type i.e. NAT in VirtualBox if this * dump is ever used to create a machine. @@ -2813,14 +2813,10 @@ static virDomainPtr vboxDomainDefineXML(virConnectPtr conn, const char *xml) { DEBUG("NIC(%d): Model: %s", i, def->nets[i]->model); DEBUG("NIC(%d): Mac: %s", i, macaddr); DEBUG("NIC(%d): ifname: %s", i, def->nets[i]->ifname); -#if 0 - if (def->nets[i]->type == VIR_DOMAIN_NET_TYPE_HOSTONLY) { - DEBUG("NIC(%d): name: %s", i, def->nets[i]->data.hostonly.name); - } else if (def->nets[i]->type == VIR_DOMAIN_NET_TYPE_INTERNAL) { - DEBUG("NIC(%d): name: %s", i, def->nets[i]->data.internal.name); - } else -#endif - if (def->nets[i]->type == VIR_DOMAIN_NET_TYPE_USER) { + if (def->nets[i]->type == VIR_DOMAIN_NET_TYPE_NETWORK) { + DEBUG("NIC(%d): name: %s", i, def->nets[i]->data.network.name); + DEBUG("NIC(%d): mode: %s", i, def->nets[i]->data.network.mode); + } else if (def->nets[i]->type == VIR_DOMAIN_NET_TYPE_USER) { DEBUG("NIC(%d): NAT.", i); } else if (def->nets[i]->type == VIR_DOMAIN_NET_TYPE_BRIDGE) { DEBUG("NIC(%d): brname: %s", i, def->nets[i]->data.bridge.brname); @@ -2859,8 +2855,8 @@ static virDomainPtr vboxDomainDefineXML(virConnectPtr conn, const char *xml) { adapter->vtbl->SetHostInterface(adapter, hostInterface); data->pFuncs->pfnUtf16Free(hostInterface); } -#if 0 - } else if (def->nets[i]->type == VIR_DOMAIN_NET_TYPE_INTERNAL) { + } else if ((def->nets[i]->type == VIR_DOMAIN_NET_TYPE_NETWORK) && + (STREQ(def->nets[i]->data.network.mode, "internal"))) { PRUnichar *internalNetwork = NULL; /* Internal Network */ @@ -2871,7 +2867,8 @@ static virDomainPtr vboxDomainDefineXML(virConnectPtr conn, const char *xml) { adapter->vtbl->SetInternalNetwork(adapter, internalNetwork); data->pFuncs->pfnUtf16Free(internalNetwork); } - } else if (def->nets[i]->type == VIR_DOMAIN_NET_TYPE_HOSTONLY) { + } else if ((def->nets[i]->type == VIR_DOMAIN_NET_TYPE_NETWORK) && + (STREQ(def->nets[i]->data.network.mode, "hostonly"))) { PRUnichar *hostInterface = NULL; /* Host Only Networking (currently only vboxnet0 available * on *nix and mac, on windows you can create and configure @@ -2879,12 +2876,11 @@ static virDomainPtr vboxDomainDefineXML(virConnectPtr conn, const char *xml) { */ adapter->vtbl->AttachToHostOnlyInterface(adapter); - if (def->nets[i]->data.ethernet.dev) { - g_pVBoxFuncs->pfnUtf8ToUtf16(def->nets[i]->data.hostonly.name, &hostInterface); + if (def->nets[i]->data.network.name) { + data->pFuncs->pfnUtf8ToUtf16(def->nets[i]->data.network.name, &hostInterface); adapter->vtbl->SetHostInterface(adapter, hostInterface); data->pFuncs->pfnUtf16Free(hostInterface); } -#endif } else if (def->nets[i]->type == VIR_DOMAIN_NET_TYPE_USER) { /* NAT */ adapter->vtbl->AttachToNAT(adapter);
-- Libvir-list mailing list Libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list