1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-01-26 14:03:49 +03:00

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:
Yuji NISHIDA 2010-02-19 16:49:56 +01:00 committed by Daniel Veillard
parent b97c24b2e1
commit ead3410f30
3 changed files with 43 additions and 1 deletions

View File

@ -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;
}

View File

@ -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 */

View File

@ -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") ;