提交 ead3410f 编写于 作者: Y Yuji NISHIDA 提交者: Daniel Veillard

fix multiple veth problem for OpenVZ

Fix multiple veth problem.
NETIF setting was overwritten after first CT because any CT could not be
found by name.
* src/openvz/openvz_conf.c src/openvz/openvz_conf.h: add the
  openvzGetVEID lookup function
* src/openvz/openvz_driver.c: use it in openvzDomainSetNetwork()
上级 b97c24b2
......@@ -953,3 +953,44 @@ static int openvzAssignUUIDs(void)
VIR_FREE(conf_dir);
return 0;
}
/*
* Return CTID from name
*
*/
int openvzGetVEID(const char *name) {
char *cmd;
int veid;
FILE *fp;
if (virAsprintf(&cmd, "%s %s -ovpsid -H", VZLIST, name) < 0) {
openvzError(NULL, VIR_ERR_INTERNAL_ERROR, "%s",
_("virAsprintf failed"));
return -1;
}
fp = popen(cmd, "r");
VIR_FREE(cmd);
if (fp == NULL) {
openvzError(NULL, VIR_ERR_INTERNAL_ERROR, "%s", _("popen failed"));
return -1;
}
if (fscanf(fp, "%d\n", &veid ) != 1) {
if (feof(fp))
return -1;
openvzError(NULL, VIR_ERR_INTERNAL_ERROR,
"%s", _("Failed to parse vzlist output"));
goto cleanup;
}
return veid;
cleanup:
fclose(fp);
return -1;
}
......@@ -66,5 +66,6 @@ void openvzFreeDriver(struct openvz_driver *driver);
int strtoI(const char *str);
int openvzSetDefinedUUID(int vpsid, unsigned char *uuid);
unsigned int openvzGetNodeCPUs(void);
int openvzGetVEID(const char *name);
#endif /* OPENVZ_CONF_H */
......@@ -667,7 +667,7 @@ openvzDomainSetNetwork(virConnectPtr conn, const char *vpsid,
if (net->type == VIR_DOMAIN_NET_TYPE_BRIDGE) {
virBuffer buf = VIR_BUFFER_INITIALIZER;
char *dev_name_ve;
int veid = strtoI(vpsid);
int veid = openvzGetVEID(vpsid);
//--netif_add ifname[,mac,host_ifname,host_mac]
ADD_ARG_LIT("--netif_add") ;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册