[PATCH lxc_ethernet] lxc:support network type with ethernet

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

 



From: z00209963 <z00209963@xxxxxxxxxxxxxxxxxxxxxx>

---
 src/lxc/lxc_process.c | 35 +++++++++++++++++++++++++++++++++++
 src/lxc/lxc_process.h |  3 +++
 2 files changed, 38 insertions(+)

diff --git a/src/lxc/lxc_process.c b/src/lxc/lxc_process.c
index 57e3880..1ffd9ac 100644
--- a/src/lxc/lxc_process.c
+++ b/src/lxc/lxc_process.c
@@ -359,6 +359,38 @@ char *virLXCProcessSetupInterfaceDirect(virConnectPtr conn,
     return ret;
 }
 
+char *virLXCProcessSetupInterfaceEthernet(virDomainDefPtr vm,
+                                         virDomainNetDefPtr net)
+{
+    char *ret = NULL;
+    char *parentVeth;
+    char *containerVeth = NULL;
+
+    VIR_DEBUG("calling vethCreate()");
+    parentVeth = net->ifname;
+    if (virNetDevVethCreate(&parentVeth, &containerVeth) < 0)
+        goto cleanup;
+    VIR_DEBUG("parentVeth: %s, containerVeth: %s", parentVeth, containerVeth);
+
+    if (net->ifname == NULL)
+        net->ifname = parentVeth;
+
+    if (virNetDevSetMAC(containerVeth, &net->mac) < 0)
+        goto cleanup;
+
+    if (virNetDevSetOnline(parentVeth, true) < 0)
+        goto cleanup;
+
+    if (net->filter &&
+        virDomainConfNWFilterInstantiate(vm->uuid, net) < 0)
+        goto cleanup;
+
+    ret = containerVeth;
+
+ cleanup:
+    return ret;
+}
+
 static const char *nsInfoLocal[VIR_LXC_DOMAIN_NAMESPACE_LAST] = {
     [VIR_LXC_DOMAIN_NAMESPACE_SHARENET] = "net",
     [VIR_LXC_DOMAIN_NAMESPACE_SHAREIPC] = "ipc",
@@ -559,6 +591,9 @@ static int virLXCProcessSetupInterfaces(virConnectPtr conn,
             break;
 
         case VIR_DOMAIN_NET_TYPE_ETHERNET:
+            if (!(veth = virLXCProcessSetupInterfaceEthernet(def,
+                                                           net)))
+                goto cleanup;
             break;
 
         case VIR_DOMAIN_NET_TYPE_USER:
diff --git a/src/lxc/lxc_process.h b/src/lxc/lxc_process.h
index b6c8083..cc8e707 100644
--- a/src/lxc/lxc_process.h
+++ b/src/lxc/lxc_process.h
@@ -53,5 +53,8 @@ char *virLXCProcessSetupInterfaceBridged(virDomainDefPtr vm,
 char *virLXCProcessSetupInterfaceDirect(virConnectPtr conn,
                                         virDomainDefPtr def,
                                         virDomainNetDefPtr net);
+char *virLXCProcessSetupInterfaceEthernet(virDomainDefPtr vm,
+                                         virDomainNetDefPtr net);
+
 
 #endif /* __LXC_PROCESS_H__ */
-- 
2.5.1.windows.1


--
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]