On Mon, Nov 30, 2015 at 12:47:44PM +0000, zhongguocheng1(a)163.com wrote:
From: z00209963 <z00209963(a)szxbz472.huaweiobz.com>
Going through some older patches I noticed this one. There are few
questions / hints for next time.
You could use your whole name so that they are properly attributed to
you.
Also some more info in the commit message wouldn't hurt. What are your
trying to achieve with this? I mean, I kind of understand what you
probably want to do, but be sure to check the documentation for the
interface type='ethernet', it's not that straight-forward. Here's the
excerpt from the docs:
Generic ethernet connection
Provides a means for the administrator to execute an arbitrary script
to connect the guest's network to the LAN. The guest will have a tun
device created with a name of vnetN, which can also be overridden with
the <target> element. After creating the tun device a shell script
will be run which is expected to do whatever host network integration
is required. By default this script is called /etc/qemu-ifup but can
be overridden.
Anyway, this patch is right in one thing and that is that interface
type='ethernet' doesn't work and we pass --veth parameter with no value
to livbirt_lxc and that fails.
Plus few hints in the code in case we really want interface
type='ethernet' to behave similarly to this (it could make sense with
few changes, it's just that it would not bahave according to the docs).
---
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)
Indentation is off.
+{
+ 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;
+
This is basically a copy-paste from the bridged interface creation, but
it is not connected anywhere. And the script that should be ran is not
ran at all, so even if I were to route the local part of the veth pair
somewhere, there is no option to do so.
That leads me to a question that I had in the start of the e-mail. What
are you trying to achieve with this?
+ 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)))
Indentation is off.
+ 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);
Indentation is off.
+
#endif /* __LXC_PROCESS_H__ */
--
2.5.1.windows.1
--
libvir-list mailing list
libvir-list(a)redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list