mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-02 01:45:17 +00:00
OpenVZ: take veid from vmdef->name when defining new domains
We currently use the next free veid although there's one given in the domain xml. This currently breaks defining new domains since vmdef->name and veid don't match leading to the following error later on: error: Failed to define domain from 110.xml error: internal error Could not set UUID Since silently ignoring vmdef->name is not nice respect it instead. We avoid veid collisions in the upper levels already.
This commit is contained in:
parent
abff683f78
commit
50a7c59bb3
@ -58,7 +58,6 @@
|
|||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
#include "bridge.h"
|
#include "bridge.h"
|
||||||
#include "files.h"
|
#include "files.h"
|
||||||
#include "intprops.h"
|
|
||||||
|
|
||||||
#define VIR_FROM_THIS VIR_FROM_OPENVZ
|
#define VIR_FROM_THIS VIR_FROM_OPENVZ
|
||||||
|
|
||||||
@ -103,10 +102,6 @@ openvzDomainDefineCmd(const char *args[],
|
|||||||
int maxarg, virDomainDefPtr vmdef)
|
int maxarg, virDomainDefPtr vmdef)
|
||||||
{
|
{
|
||||||
int narg;
|
int narg;
|
||||||
int veid;
|
|
||||||
int max_veid;
|
|
||||||
char str_id[INT_BUFSIZE_BOUND(max_veid)];
|
|
||||||
FILE *fp;
|
|
||||||
|
|
||||||
for (narg = 0; narg < maxarg; narg++)
|
for (narg = 0; narg < maxarg; narg++)
|
||||||
args[narg] = NULL;
|
args[narg] = NULL;
|
||||||
@ -116,6 +111,7 @@ openvzDomainDefineCmd(const char *args[],
|
|||||||
_("Container is not defined"));
|
_("Container is not defined"));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define ADD_ARG(thisarg) \
|
#define ADD_ARG(thisarg) \
|
||||||
do { \
|
do { \
|
||||||
if (narg >= maxarg) \
|
if (narg >= maxarg) \
|
||||||
@ -136,36 +132,7 @@ openvzDomainDefineCmd(const char *args[],
|
|||||||
ADD_ARG_LIT("--quiet");
|
ADD_ARG_LIT("--quiet");
|
||||||
ADD_ARG_LIT("create");
|
ADD_ARG_LIT("create");
|
||||||
|
|
||||||
if ((fp = popen(VZLIST " -a -ovpsid -H 2>/dev/null", "r")) == NULL) {
|
ADD_ARG_LIT(vmdef->name);
|
||||||
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
||||||
_("popen failed"));
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
max_veid = 0;
|
|
||||||
while (!feof(fp)) {
|
|
||||||
if (fscanf(fp, "%d\n", &veid) != 1) {
|
|
||||||
if (feof(fp))
|
|
||||||
break;
|
|
||||||
|
|
||||||
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
||||||
_("Failed to parse vzlist output"));
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
if (veid > max_veid) {
|
|
||||||
max_veid = veid;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
VIR_FORCE_FCLOSE(fp);
|
|
||||||
|
|
||||||
if (max_veid == 0) {
|
|
||||||
max_veid = 100;
|
|
||||||
} else {
|
|
||||||
max_veid++;
|
|
||||||
}
|
|
||||||
|
|
||||||
snprintf(str_id, sizeof(str_id), "%d", max_veid);
|
|
||||||
ADD_ARG_LIT(str_id);
|
|
||||||
|
|
||||||
ADD_ARG_LIT("--name");
|
ADD_ARG_LIT("--name");
|
||||||
ADD_ARG_LIT(vmdef->name);
|
ADD_ARG_LIT(vmdef->name);
|
||||||
|
|
||||||
@ -189,10 +156,6 @@ no_memory:
|
|||||||
_("Could not put argument to %s"), VZCTL);
|
_("Could not put argument to %s"), VZCTL);
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
cleanup:
|
|
||||||
VIR_FORCE_FCLOSE(fp);
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
#undef ADD_ARG
|
#undef ADD_ARG
|
||||||
#undef ADD_ARG_LIT
|
#undef ADD_ARG_LIT
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user