[libvirt] [PATCH] in vbox driver, interface type bridge should really be type ethernet

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



If I understand correctly, the "bridge" type for an interface means
libvirt is in charge of creating a tun device and adding it to the
specified bridge in the <source bridge=".."> attribute. This is not what
the (badly named IHMO) "Bridged Networking" mode in vbox does: all it
does is read and write its packets on the specified interface. Which is
what a type "ethernet" interface does in my opinion. I joined a quick
patch for that, Pritesh could you check it ?

Also, I was about to patch to add support for the proper "bridge" mode
in the vbox driver (because it's what I need in the end), but I see no
way of storing the fact that it's not just an "ethernet" interface using
the vbox API, so that the config would persist over libvirtd restarts.

There is always the possibility of naming the interface a special way
like "br1_myTap", and assume any type "ethernet" interface with a device
containing a "br1_" prefix would actually be a type "bridge" interface
with an associated "vbox_br1" bridge. Would that be acceptable, or is it
too hackish ?

BTW, just to make sure, I can use pretty much anything as a <target> ie.
ethN, panN etc in a type "ethernet" interface, right ? If <target> is
specified, it's not going to create a tun and use that ?

Thanks,
Florian
diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c
index 72220e1..60f2c21 100644
--- a/src/vbox/vbox_tmpl.c
+++ b/src/vbox/vbox_tmpl.c
@@ -2155,12 +2155,12 @@ static char *vboxDomainDumpXML(virDomainPtr dom, int flags) {
                                 PRUnichar *hostIntUtf16 = NULL;
                                 char *hostInt           = NULL;
 
-                                def->nets[netAdpIncCnt]->type = VIR_DOMAIN_NET_TYPE_BRIDGE;
+                                def->nets[netAdpIncCnt]->type = VIR_DOMAIN_NET_TYPE_ETHERNET;
 
                                 adapter->vtbl->GetHostInterface(adapter, &hostIntUtf16);
 
                                 data->pFuncs->pfnUtf16ToUtf8(hostIntUtf16, &hostInt);
-                                def->nets[netAdpIncCnt]->data.bridge.brname = strdup(hostInt);
+                                def->nets[netAdpIncCnt]->data.ethernet.dev = strdup(hostInt);
 
                                 data->pFuncs->pfnUtf8Free(hostInt);
                                 data->pFuncs->pfnUtf16Free(hostIntUtf16);
@@ -3409,10 +3409,10 @@ static virDomainPtr vboxDomainDefineXML(virConnectPtr conn, const char *xml) {
                     DEBUG("NIC(%d): name:   %s", i, def->nets[i]->data.internal.name);
                 } 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);
-                    DEBUG("NIC(%d): script: %s", i, def->nets[i]->data.bridge.script);
-                    DEBUG("NIC(%d): ipaddr: %s", i, def->nets[i]->data.bridge.ipaddr);
+                } else if (def->nets[i]->type == VIR_DOMAIN_NET_TYPE_ETHERNET) {
+                    DEBUG("NIC(%d):    dev: %s", i, def->nets[i]->data.ethernet.dev);
+                    DEBUG("NIC(%d): script: %s", i, def->nets[i]->data.ethernet.script);
+                    DEBUG("NIC(%d): ipaddr: %s", i, def->nets[i]->data.ethernet.ipaddr);
                 }
 
                 machine->vtbl->GetNetworkAdapter(machine, i, &adapter);
@@ -3435,14 +3435,14 @@ static virDomainPtr vboxDomainDefineXML(virConnectPtr conn, const char *xml) {
 
                     adapter->vtbl->SetAdapterType(adapter, adapterType);
 
-                    if (def->nets[i]->type == VIR_DOMAIN_NET_TYPE_BRIDGE) {
+                    if (def->nets[i]->type == VIR_DOMAIN_NET_TYPE_ETHERNET) {
                         PRUnichar *hostInterface = NULL;
                         /* Bridged Network */
 
                         adapter->vtbl->AttachToBridgedInterface(adapter);
 
-                        if (def->nets[i]->data.bridge.brname) {
-                            data->pFuncs->pfnUtf8ToUtf16(def->nets[i]->data.bridge.brname, &hostInterface);
+                        if (def->nets[i]->data.ethernet.dev) {
+                            data->pFuncs->pfnUtf8ToUtf16(def->nets[i]->data.ethernet.dev, &hostInterface);
                             adapter->vtbl->SetHostInterface(adapter, hostInterface);
                             data->pFuncs->pfnUtf16Free(hostInterface);
                         }
--
Libvir-list mailing list
Libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]