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()
This commit is contained in:
parent
b97c24b2e1
commit
ead3410f30
@ -953,3 +953,44 @@ static int openvzAssignUUIDs(void)
|
|||||||
VIR_FREE(conf_dir);
|
VIR_FREE(conf_dir);
|
||||||
return 0;
|
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 strtoI(const char *str);
|
||||||
int openvzSetDefinedUUID(int vpsid, unsigned char *uuid);
|
int openvzSetDefinedUUID(int vpsid, unsigned char *uuid);
|
||||||
unsigned int openvzGetNodeCPUs(void);
|
unsigned int openvzGetNodeCPUs(void);
|
||||||
|
int openvzGetVEID(const char *name);
|
||||||
|
|
||||||
#endif /* OPENVZ_CONF_H */
|
#endif /* OPENVZ_CONF_H */
|
||||||
|
@ -667,7 +667,7 @@ openvzDomainSetNetwork(virConnectPtr conn, const char *vpsid,
|
|||||||
if (net->type == VIR_DOMAIN_NET_TYPE_BRIDGE) {
|
if (net->type == VIR_DOMAIN_NET_TYPE_BRIDGE) {
|
||||||
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
||||||
char *dev_name_ve;
|
char *dev_name_ve;
|
||||||
int veid = strtoI(vpsid);
|
int veid = openvzGetVEID(vpsid);
|
||||||
|
|
||||||
//--netif_add ifname[,mac,host_ifname,host_mac]
|
//--netif_add ifname[,mac,host_ifname,host_mac]
|
||||||
ADD_ARG_LIT("--netif_add") ;
|
ADD_ARG_LIT("--netif_add") ;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user