mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
Replace use of openvzError with virReportError
Update the OpenVZ driver to use virReportError instead of the openvzError custom macro Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
This commit is contained in:
parent
a8483d425e
commit
29bf82593c
1
cfg.mk
1
cfg.mk
@ -516,7 +516,6 @@ msg_gen_function += XENXS_ERROR
|
|||||||
msg_gen_function += lxcError
|
msg_gen_function += lxcError
|
||||||
msg_gen_function += libxlError
|
msg_gen_function += libxlError
|
||||||
msg_gen_function += nodeReportError
|
msg_gen_function += nodeReportError
|
||||||
msg_gen_function += openvzError
|
|
||||||
msg_gen_function += regerror
|
msg_gen_function += regerror
|
||||||
msg_gen_function += remoteError
|
msg_gen_function += remoteError
|
||||||
msg_gen_function += statsError
|
msg_gen_function += statsError
|
||||||
|
@ -120,8 +120,8 @@ int openvzExtractVersion(struct openvz_driver *driver)
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (openvzExtractVersionInfo(VZCTL, &driver->version) < 0) {
|
if (openvzExtractVersionInfo(VZCTL, &driver->version) < 0) {
|
||||||
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("Could not extract vzctl version"));
|
_("Could not extract vzctl version"));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -234,9 +234,9 @@ openvzReadNetworkConf(virDomainDefPtr def,
|
|||||||
*/
|
*/
|
||||||
ret = openvzReadVPSConfigParam(veid, "IP_ADDRESS", &temp);
|
ret = openvzReadVPSConfigParam(veid, "IP_ADDRESS", &temp);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
openvzError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Could not read 'IP_ADDRESS' from config for container %d"),
|
_("Could not read 'IP_ADDRESS' from config for container %d"),
|
||||||
veid);
|
veid);
|
||||||
goto error;
|
goto error;
|
||||||
} else if (ret > 0) {
|
} else if (ret > 0) {
|
||||||
token = strtok_r(temp, " ", &saveptr);
|
token = strtok_r(temp, " ", &saveptr);
|
||||||
@ -266,9 +266,9 @@ openvzReadNetworkConf(virDomainDefPtr def,
|
|||||||
*/
|
*/
|
||||||
ret = openvzReadVPSConfigParam(veid, "NETIF", &temp);
|
ret = openvzReadVPSConfigParam(veid, "NETIF", &temp);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
openvzError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Could not read 'NETIF' from config for container %d"),
|
_("Could not read 'NETIF' from config for container %d"),
|
||||||
veid);
|
veid);
|
||||||
goto error;
|
goto error;
|
||||||
} else if (ret > 0) {
|
} else if (ret > 0) {
|
||||||
token = strtok_r(temp, ";", &saveptr);
|
token = strtok_r(temp, ";", &saveptr);
|
||||||
@ -292,8 +292,8 @@ openvzReadNetworkConf(virDomainDefPtr def,
|
|||||||
p += 12;
|
p += 12;
|
||||||
len = next - p;
|
len = next - p;
|
||||||
if (len > 16) {
|
if (len > 16) {
|
||||||
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("Too long network device name"));
|
_("Too long network device name"));
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -301,16 +301,16 @@ openvzReadNetworkConf(virDomainDefPtr def,
|
|||||||
goto no_memory;
|
goto no_memory;
|
||||||
|
|
||||||
if (virStrncpy(net->ifname, p, len, len+1) == NULL) {
|
if (virStrncpy(net->ifname, p, len, len+1) == NULL) {
|
||||||
openvzError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Network ifname %s too long for destination"), p);
|
_("Network ifname %s too long for destination"), p);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
} else if (STRPREFIX(p, "bridge=")) {
|
} else if (STRPREFIX(p, "bridge=")) {
|
||||||
p += 7;
|
p += 7;
|
||||||
len = next - p;
|
len = next - p;
|
||||||
if (len > 16) {
|
if (len > 16) {
|
||||||
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("Too long bridge device name"));
|
_("Too long bridge device name"));
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -318,26 +318,26 @@ openvzReadNetworkConf(virDomainDefPtr def,
|
|||||||
goto no_memory;
|
goto no_memory;
|
||||||
|
|
||||||
if (virStrncpy(net->data.bridge.brname, p, len, len+1) == NULL) {
|
if (virStrncpy(net->data.bridge.brname, p, len, len+1) == NULL) {
|
||||||
openvzError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Bridge name %s too long for destination"), p);
|
_("Bridge name %s too long for destination"), p);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
} else if (STRPREFIX(p, "mac=")) {
|
} else if (STRPREFIX(p, "mac=")) {
|
||||||
p += 4;
|
p += 4;
|
||||||
len = next - p;
|
len = next - p;
|
||||||
if (len != 17) { /* should be 17 */
|
if (len != 17) { /* should be 17 */
|
||||||
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("Wrong length MAC address"));
|
_("Wrong length MAC address"));
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
if (virStrncpy(cpy_temp, p, len, sizeof(cpy_temp)) == NULL) {
|
if (virStrncpy(cpy_temp, p, len, sizeof(cpy_temp)) == NULL) {
|
||||||
openvzError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("MAC address %s too long for destination"), p);
|
_("MAC address %s too long for destination"), p);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
if (virMacAddrParse(cpy_temp, &net->mac) < 0) {
|
if (virMacAddrParse(cpy_temp, &net->mac) < 0) {
|
||||||
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("Wrong MAC address"));
|
_("Wrong MAC address"));
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -411,9 +411,9 @@ openvzReadFSConf(virDomainDefPtr def,
|
|||||||
|
|
||||||
ret = openvzReadVPSConfigParam(veid, "OSTEMPLATE", &temp);
|
ret = openvzReadVPSConfigParam(veid, "OSTEMPLATE", &temp);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
openvzError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Could not read 'OSTEMPLATE' from config for container %d"),
|
_("Could not read 'OSTEMPLATE' from config for container %d"),
|
||||||
veid);
|
veid);
|
||||||
goto error;
|
goto error;
|
||||||
} else if (ret > 0) {
|
} else if (ret > 0) {
|
||||||
if (VIR_ALLOC(fs) < 0)
|
if (VIR_ALLOC(fs) < 0)
|
||||||
@ -425,9 +425,9 @@ openvzReadFSConf(virDomainDefPtr def,
|
|||||||
/* OSTEMPLATE was not found, VE was booted from a private dir directly */
|
/* OSTEMPLATE was not found, VE was booted from a private dir directly */
|
||||||
ret = openvzReadVPSConfigParam(veid, "VE_PRIVATE", &temp);
|
ret = openvzReadVPSConfigParam(veid, "VE_PRIVATE", &temp);
|
||||||
if (ret <= 0) {
|
if (ret <= 0) {
|
||||||
openvzError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Could not read 'VE_PRIVATE' from config for container %d"),
|
_("Could not read 'VE_PRIVATE' from config for container %d"),
|
||||||
veid);
|
veid);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -449,9 +449,9 @@ openvzReadFSConf(virDomainDefPtr def,
|
|||||||
ret = openvzReadVPSConfigParam(veid, param, &temp);
|
ret = openvzReadVPSConfigParam(veid, param, &temp);
|
||||||
if (ret > 0) {
|
if (ret > 0) {
|
||||||
if (openvzParseBarrierLimit(temp, &barrier, &limit)) {
|
if (openvzParseBarrierLimit(temp, &barrier, &limit)) {
|
||||||
openvzError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Could not read '%s' from config for container %d"),
|
_("Could not read '%s' from config for container %d"),
|
||||||
param, veid);
|
param, veid);
|
||||||
goto error;
|
goto error;
|
||||||
} else {
|
} else {
|
||||||
/* Ensure that we can multiply by 1024 without overflowing. */
|
/* Ensure that we can multiply by 1024 without overflowing. */
|
||||||
@ -503,16 +503,16 @@ openvzReadMemConf(virDomainDefPtr def, int veid)
|
|||||||
param = "VMGUARPAGES";
|
param = "VMGUARPAGES";
|
||||||
ret = openvzReadVPSConfigParam(veid, param, &temp);
|
ret = openvzReadVPSConfigParam(veid, param, &temp);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
openvzError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Could not read '%s' from config for container %d"),
|
_("Could not read '%s' from config for container %d"),
|
||||||
param, veid);
|
param, veid);
|
||||||
goto error;
|
goto error;
|
||||||
} else if (ret > 0) {
|
} else if (ret > 0) {
|
||||||
ret = openvzParseBarrierLimit(temp, &barrier, NULL);
|
ret = openvzParseBarrierLimit(temp, &barrier, NULL);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
openvzError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Could not parse barrier of '%s' "
|
_("Could not parse barrier of '%s' "
|
||||||
"from config for container %d"), param, veid);
|
"from config for container %d"), param, veid);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
if (barrier == LONG_MAX)
|
if (barrier == LONG_MAX)
|
||||||
@ -525,16 +525,16 @@ openvzReadMemConf(virDomainDefPtr def, int veid)
|
|||||||
param = "PRIVVMPAGES";
|
param = "PRIVVMPAGES";
|
||||||
ret = openvzReadVPSConfigParam(veid, param, &temp);
|
ret = openvzReadVPSConfigParam(veid, param, &temp);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
openvzError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Could not read '%s' from config for container %d"),
|
_("Could not read '%s' from config for container %d"),
|
||||||
param, veid);
|
param, veid);
|
||||||
goto error;
|
goto error;
|
||||||
} else if (ret > 0) {
|
} else if (ret > 0) {
|
||||||
ret = openvzParseBarrierLimit(temp, &barrier, &limit);
|
ret = openvzParseBarrierLimit(temp, &barrier, &limit);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
openvzError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Could not parse barrier and limit of '%s' "
|
_("Could not parse barrier and limit of '%s' "
|
||||||
"from config for container %d"), param, veid);
|
"from config for container %d"), param, veid);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
if (barrier == LONG_MAX)
|
if (barrier == LONG_MAX)
|
||||||
@ -592,8 +592,8 @@ int openvzLoadDomains(struct openvz_driver *driver) {
|
|||||||
if (virStrToLong_i(line, &status, 10, &veid) < 0 ||
|
if (virStrToLong_i(line, &status, 10, &veid) < 0 ||
|
||||||
*status++ != ' ' ||
|
*status++ != ' ' ||
|
||||||
(line = strchr(status, '\n')) == NULL) {
|
(line = strchr(status, '\n')) == NULL) {
|
||||||
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("Failed to parse vzlist output"));
|
_("Failed to parse vzlist output"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
*line++ = '\0';
|
*line++ = '\0';
|
||||||
@ -602,8 +602,8 @@ int openvzLoadDomains(struct openvz_driver *driver) {
|
|||||||
goto no_memory;
|
goto no_memory;
|
||||||
|
|
||||||
if (virMutexInit(&dom->lock) < 0) {
|
if (virMutexInit(&dom->lock) < 0) {
|
||||||
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("cannot initialize mutex"));
|
_("cannot initialize mutex"));
|
||||||
VIR_FREE(dom);
|
VIR_FREE(dom);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
@ -639,8 +639,8 @@ int openvzLoadDomains(struct openvz_driver *driver) {
|
|||||||
ret = virUUIDParse(uuidstr, dom->def->uuid);
|
ret = virUUIDParse(uuidstr, dom->def->uuid);
|
||||||
|
|
||||||
if (ret == -1) {
|
if (ret == -1) {
|
||||||
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("UUID in config file malformed"));
|
_("UUID in config file malformed"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -651,9 +651,9 @@ int openvzLoadDomains(struct openvz_driver *driver) {
|
|||||||
|
|
||||||
ret = openvzReadVPSConfigParam(veid, "CPUS", &temp);
|
ret = openvzReadVPSConfigParam(veid, "CPUS", &temp);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
openvzError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Could not read config for container %d"),
|
_("Could not read config for container %d"),
|
||||||
veid);
|
veid);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
} else if (ret > 0) {
|
} else if (ret > 0) {
|
||||||
dom->def->maxvcpus = strtoI(temp);
|
dom->def->maxvcpus = strtoI(temp);
|
||||||
@ -671,15 +671,15 @@ int openvzLoadDomains(struct openvz_driver *driver) {
|
|||||||
|
|
||||||
virUUIDFormat(dom->def->uuid, uuidstr);
|
virUUIDFormat(dom->def->uuid, uuidstr);
|
||||||
if (virHashLookup(driver->domains.objs, uuidstr)) {
|
if (virHashLookup(driver->domains.objs, uuidstr)) {
|
||||||
openvzError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Duplicate container UUID %s detected for %d"),
|
_("Duplicate container UUID %s detected for %d"),
|
||||||
uuidstr,
|
uuidstr,
|
||||||
veid);
|
veid);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
if (virHashAddEntry(driver->domains.objs, uuidstr, dom) < 0) {
|
if (virHashAddEntry(driver->domains.objs, uuidstr, dom) < 0) {
|
||||||
openvzError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Could not add UUID for container %d"), veid);
|
_("Could not add UUID for container %d"), veid);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1048,8 +1048,8 @@ openvzGetVPSUUID(int vpsid, char *uuidstr, size_t len)
|
|||||||
|
|
||||||
if (iden != NULL && uuidbuf != NULL && STREQ(iden, "#UUID:")) {
|
if (iden != NULL && uuidbuf != NULL && STREQ(iden, "#UUID:")) {
|
||||||
if (virStrcpy(uuidstr, uuidbuf, len) == NULL) {
|
if (virStrcpy(uuidstr, uuidbuf, len) == NULL) {
|
||||||
openvzError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("invalid uuid %s"), uuidbuf);
|
_("invalid uuid %s"), uuidbuf);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -1110,8 +1110,8 @@ openvzSetUUID(int vpsid){
|
|||||||
unsigned char uuid[VIR_UUID_BUFLEN];
|
unsigned char uuid[VIR_UUID_BUFLEN];
|
||||||
|
|
||||||
if (virUUIDGenerate(uuid)) {
|
if (virUUIDGenerate(uuid)) {
|
||||||
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("Failed to generate UUID"));
|
_("Failed to generate UUID"));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1155,8 +1155,8 @@ static int openvzAssignUUIDs(void)
|
|||||||
errno = 0;
|
errno = 0;
|
||||||
}
|
}
|
||||||
if (errno) {
|
if (errno) {
|
||||||
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("Failed to scan configuration directory"));
|
_("Failed to scan configuration directory"));
|
||||||
ret = -1;
|
ret = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1193,7 +1193,7 @@ int openvzGetVEID(const char *name) {
|
|||||||
if (ok && veid >= 0)
|
if (ok && veid >= 0)
|
||||||
return veid;
|
return veid;
|
||||||
|
|
||||||
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("Failed to parse vzlist output"));
|
_("Failed to parse vzlist output"));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -33,10 +33,6 @@
|
|||||||
# include "domain_conf.h"
|
# include "domain_conf.h"
|
||||||
# include "threads.h"
|
# include "threads.h"
|
||||||
|
|
||||||
# define openvzError(code, ...) \
|
|
||||||
virReportErrorHelper(VIR_FROM_OPENVZ, code, __FILE__, \
|
|
||||||
__FUNCTION__, __LINE__, __VA_ARGS__)
|
|
||||||
|
|
||||||
|
|
||||||
/* OpenVZ commands - Replace with wrapper scripts later? */
|
/* OpenVZ commands - Replace with wrapper scripts later? */
|
||||||
# define VZLIST "/usr/sbin/vzlist"
|
# define VZLIST "/usr/sbin/vzlist"
|
||||||
|
@ -113,8 +113,8 @@ openvzDomainDefineCmd(virDomainDefPtr vmdef)
|
|||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
if (vmdef == NULL) {
|
if (vmdef == NULL) {
|
||||||
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("Container is not defined"));
|
_("Container is not defined"));
|
||||||
virCommandFree(cmd);
|
virCommandFree(cmd);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -138,8 +138,8 @@ static int openvzSetInitialConfig(virDomainDefPtr vmdef)
|
|||||||
virCommandPtr cmd = NULL;
|
virCommandPtr cmd = NULL;
|
||||||
|
|
||||||
if (vmdef->nfss > 1) {
|
if (vmdef->nfss > 1) {
|
||||||
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("only one filesystem supported"));
|
_("only one filesystem supported"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -147,8 +147,8 @@ static int openvzSetInitialConfig(virDomainDefPtr vmdef)
|
|||||||
vmdef->fss[0]->type != VIR_DOMAIN_FS_TYPE_TEMPLATE &&
|
vmdef->fss[0]->type != VIR_DOMAIN_FS_TYPE_TEMPLATE &&
|
||||||
vmdef->fss[0]->type != VIR_DOMAIN_FS_TYPE_MOUNT)
|
vmdef->fss[0]->type != VIR_DOMAIN_FS_TYPE_MOUNT)
|
||||||
{
|
{
|
||||||
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("filesystem is not of type 'template' or 'mount'"));
|
_("filesystem is not of type 'template' or 'mount'"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -158,20 +158,20 @@ static int openvzSetInitialConfig(virDomainDefPtr vmdef)
|
|||||||
{
|
{
|
||||||
|
|
||||||
if (virStrToLong_i(vmdef->name, NULL, 10, &vpsid) < 0) {
|
if (virStrToLong_i(vmdef->name, NULL, 10, &vpsid) < 0) {
|
||||||
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("Could not convert domain name to VEID"));
|
_("Could not convert domain name to VEID"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (openvzCopyDefaultConfig(vpsid) < 0) {
|
if (openvzCopyDefaultConfig(vpsid) < 0) {
|
||||||
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("Could not copy default config"));
|
_("Could not copy default config"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (openvzWriteVPSConfigParam(vpsid, "VE_PRIVATE", vmdef->fss[0]->src) < 0) {
|
if (openvzWriteVPSConfigParam(vpsid, "VE_PRIVATE", vmdef->fss[0]->src) < 0) {
|
||||||
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("Could not set the source dir for the filesystem"));
|
_("Could not set the source dir for the filesystem"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -217,8 +217,8 @@ openvzSetDiskQuota(virDomainDefPtr vmdef,
|
|||||||
virCommandAddArgFormat(cmd, "%lld", hl);
|
virCommandAddArgFormat(cmd, "%lld", hl);
|
||||||
}
|
}
|
||||||
} else if (fss->space_soft_limit) {
|
} else if (fss->space_soft_limit) {
|
||||||
openvzError(VIR_ERR_INVALID_ARG, "%s",
|
virReportError(VIR_ERR_INVALID_ARG, "%s",
|
||||||
_("Can't set soft limit without hard limit"));
|
_("Can't set soft limit without hard limit"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -245,7 +245,7 @@ static virDomainPtr openvzDomainLookupByID(virConnectPtr conn,
|
|||||||
openvzDriverUnlock(driver);
|
openvzDriverUnlock(driver);
|
||||||
|
|
||||||
if (!vm) {
|
if (!vm) {
|
||||||
openvzError(VIR_ERR_NO_DOMAIN, NULL);
|
virReportError(VIR_ERR_NO_DOMAIN, NULL);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -278,7 +278,7 @@ static char *openvzGetOSType(virDomainPtr dom)
|
|||||||
openvzDriverUnlock(driver);
|
openvzDriverUnlock(driver);
|
||||||
|
|
||||||
if (!vm) {
|
if (!vm) {
|
||||||
openvzError(VIR_ERR_NO_DOMAIN, NULL);
|
virReportError(VIR_ERR_NO_DOMAIN, NULL);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -303,7 +303,7 @@ static virDomainPtr openvzDomainLookupByUUID(virConnectPtr conn,
|
|||||||
openvzDriverUnlock(driver);
|
openvzDriverUnlock(driver);
|
||||||
|
|
||||||
if (!vm) {
|
if (!vm) {
|
||||||
openvzError(VIR_ERR_NO_DOMAIN, NULL);
|
virReportError(VIR_ERR_NO_DOMAIN, NULL);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -328,7 +328,7 @@ static virDomainPtr openvzDomainLookupByName(virConnectPtr conn,
|
|||||||
openvzDriverUnlock(driver);
|
openvzDriverUnlock(driver);
|
||||||
|
|
||||||
if (!vm) {
|
if (!vm) {
|
||||||
openvzError(VIR_ERR_NO_DOMAIN, NULL);
|
virReportError(VIR_ERR_NO_DOMAIN, NULL);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -354,8 +354,8 @@ static int openvzDomainGetInfo(virDomainPtr dom,
|
|||||||
openvzDriverUnlock(driver);
|
openvzDriverUnlock(driver);
|
||||||
|
|
||||||
if (!vm) {
|
if (!vm) {
|
||||||
openvzError(VIR_ERR_NO_DOMAIN, "%s",
|
virReportError(VIR_ERR_NO_DOMAIN, "%s",
|
||||||
_("no domain with matching uuid"));
|
_("no domain with matching uuid"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -367,8 +367,8 @@ static int openvzDomainGetInfo(virDomainPtr dom,
|
|||||||
info->cpuTime = 0;
|
info->cpuTime = 0;
|
||||||
} else {
|
} else {
|
||||||
if (openvzGetProcessInfo(&(info->cpuTime), dom->id) < 0) {
|
if (openvzGetProcessInfo(&(info->cpuTime), dom->id) < 0) {
|
||||||
openvzError(VIR_ERR_OPERATION_FAILED,
|
virReportError(VIR_ERR_OPERATION_FAILED,
|
||||||
_("cannot read cputime for domain %d"), dom->id);
|
_("cannot read cputime for domain %d"), dom->id);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -402,8 +402,8 @@ openvzDomainGetState(virDomainPtr dom,
|
|||||||
openvzDriverUnlock(driver);
|
openvzDriverUnlock(driver);
|
||||||
|
|
||||||
if (!vm) {
|
if (!vm) {
|
||||||
openvzError(VIR_ERR_NO_DOMAIN, "%s",
|
virReportError(VIR_ERR_NO_DOMAIN, "%s",
|
||||||
_("no domain with matching uuid"));
|
_("no domain with matching uuid"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -426,7 +426,7 @@ static int openvzDomainIsActive(virDomainPtr dom)
|
|||||||
obj = virDomainFindByUUID(&driver->domains, dom->uuid);
|
obj = virDomainFindByUUID(&driver->domains, dom->uuid);
|
||||||
openvzDriverUnlock(driver);
|
openvzDriverUnlock(driver);
|
||||||
if (!obj) {
|
if (!obj) {
|
||||||
openvzError(VIR_ERR_NO_DOMAIN, NULL);
|
virReportError(VIR_ERR_NO_DOMAIN, NULL);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
ret = virDomainObjIsActive(obj);
|
ret = virDomainObjIsActive(obj);
|
||||||
@ -448,7 +448,7 @@ static int openvzDomainIsPersistent(virDomainPtr dom)
|
|||||||
obj = virDomainFindByUUID(&driver->domains, dom->uuid);
|
obj = virDomainFindByUUID(&driver->domains, dom->uuid);
|
||||||
openvzDriverUnlock(driver);
|
openvzDriverUnlock(driver);
|
||||||
if (!obj) {
|
if (!obj) {
|
||||||
openvzError(VIR_ERR_NO_DOMAIN, NULL);
|
virReportError(VIR_ERR_NO_DOMAIN, NULL);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
ret = obj->persistent;
|
ret = obj->persistent;
|
||||||
@ -476,8 +476,8 @@ static char *openvzDomainGetXMLDesc(virDomainPtr dom, unsigned int flags) {
|
|||||||
openvzDriverUnlock(driver);
|
openvzDriverUnlock(driver);
|
||||||
|
|
||||||
if (!vm) {
|
if (!vm) {
|
||||||
openvzError(VIR_ERR_NO_DOMAIN, "%s",
|
virReportError(VIR_ERR_NO_DOMAIN, "%s",
|
||||||
_("no domain with matching uuid"));
|
_("no domain with matching uuid"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -520,14 +520,14 @@ static int openvzDomainSuspend(virDomainPtr dom) {
|
|||||||
openvzDriverUnlock(driver);
|
openvzDriverUnlock(driver);
|
||||||
|
|
||||||
if (!vm) {
|
if (!vm) {
|
||||||
openvzError(VIR_ERR_NO_DOMAIN, "%s",
|
virReportError(VIR_ERR_NO_DOMAIN, "%s",
|
||||||
_("no domain with matching uuid"));
|
_("no domain with matching uuid"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!virDomainObjIsActive(vm)) {
|
if (!virDomainObjIsActive(vm)) {
|
||||||
openvzError(VIR_ERR_OPERATION_INVALID, "%s",
|
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
||||||
_("Domain is not running"));
|
_("Domain is not running"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -558,14 +558,14 @@ static int openvzDomainResume(virDomainPtr dom) {
|
|||||||
openvzDriverUnlock(driver);
|
openvzDriverUnlock(driver);
|
||||||
|
|
||||||
if (!vm) {
|
if (!vm) {
|
||||||
openvzError(VIR_ERR_NO_DOMAIN, "%s",
|
virReportError(VIR_ERR_NO_DOMAIN, "%s",
|
||||||
_("no domain with matching uuid"));
|
_("no domain with matching uuid"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!virDomainObjIsActive(vm)) {
|
if (!virDomainObjIsActive(vm)) {
|
||||||
openvzError(VIR_ERR_OPERATION_INVALID, "%s",
|
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
||||||
_("Domain is not running"));
|
_("Domain is not running"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -601,8 +601,8 @@ openvzDomainShutdownFlags(virDomainPtr dom,
|
|||||||
openvzDriverUnlock(driver);
|
openvzDriverUnlock(driver);
|
||||||
|
|
||||||
if (!vm) {
|
if (!vm) {
|
||||||
openvzError(VIR_ERR_NO_DOMAIN, "%s",
|
virReportError(VIR_ERR_NO_DOMAIN, "%s",
|
||||||
_("no domain with matching uuid"));
|
_("no domain with matching uuid"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -611,8 +611,8 @@ openvzDomainShutdownFlags(virDomainPtr dom,
|
|||||||
|
|
||||||
openvzSetProgramSentinal(prog, vm->def->name);
|
openvzSetProgramSentinal(prog, vm->def->name);
|
||||||
if (status != VIR_DOMAIN_RUNNING) {
|
if (status != VIR_DOMAIN_RUNNING) {
|
||||||
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("domain is not in running state"));
|
_("domain is not in running state"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -652,8 +652,8 @@ static int openvzDomainReboot(virDomainPtr dom,
|
|||||||
openvzDriverUnlock(driver);
|
openvzDriverUnlock(driver);
|
||||||
|
|
||||||
if (!vm) {
|
if (!vm) {
|
||||||
openvzError(VIR_ERR_NO_DOMAIN, "%s",
|
virReportError(VIR_ERR_NO_DOMAIN, "%s",
|
||||||
_("no domain with matching uuid"));
|
_("no domain with matching uuid"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -662,8 +662,8 @@ static int openvzDomainReboot(virDomainPtr dom,
|
|||||||
|
|
||||||
openvzSetProgramSentinal(prog, vm->def->name);
|
openvzSetProgramSentinal(prog, vm->def->name);
|
||||||
if (status != VIR_DOMAIN_RUNNING) {
|
if (status != VIR_DOMAIN_RUNNING) {
|
||||||
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("domain is not in running state"));
|
_("domain is not in running state"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -752,8 +752,8 @@ openvzDomainSetNetwork(virConnectPtr conn, const char *vpsid,
|
|||||||
if (net == NULL)
|
if (net == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
if (vpsid == NULL) {
|
if (vpsid == NULL) {
|
||||||
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("Container ID is not specified"));
|
_("Container ID is not specified"));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -788,8 +788,8 @@ openvzDomainSetNetwork(virConnectPtr conn, const char *vpsid,
|
|||||||
if (net->data.ethernet.dev == NULL) {
|
if (net->data.ethernet.dev == NULL) {
|
||||||
net->data.ethernet.dev = openvzGenerateContainerVethName(veid);
|
net->data.ethernet.dev = openvzGenerateContainerVethName(veid);
|
||||||
if (net->data.ethernet.dev == NULL) {
|
if (net->data.ethernet.dev == NULL) {
|
||||||
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("Could not generate eth name for container"));
|
_("Could not generate eth name for container"));
|
||||||
rc = -1;
|
rc = -1;
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
@ -800,8 +800,8 @@ openvzDomainSetNetwork(virConnectPtr conn, const char *vpsid,
|
|||||||
if (net->ifname == NULL) {
|
if (net->ifname == NULL) {
|
||||||
net->ifname = openvzGenerateVethName(veid, net->data.ethernet.dev);
|
net->ifname = openvzGenerateVethName(veid, net->data.ethernet.dev);
|
||||||
if (net->ifname == NULL) {
|
if (net->ifname == NULL) {
|
||||||
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("Could not generate veth name"));
|
_("Could not generate veth name"));
|
||||||
rc = -1;
|
rc = -1;
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
@ -852,8 +852,8 @@ openvzDomainSetNetwork(virConnectPtr conn, const char *vpsid,
|
|||||||
|
|
||||||
no_memory:
|
no_memory:
|
||||||
VIR_FREE(opt);
|
VIR_FREE(opt);
|
||||||
openvzError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Could not put argument to %s"), VZCTL);
|
_("Could not put argument to %s"), VZCTL);
|
||||||
cmdExecFree(prog);
|
cmdExecFree(prog);
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
@ -881,8 +881,8 @@ openvzDomainSetNetworkConfig(virConnectPtr conn,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (openvzDomainSetNetwork(conn, def->name, def->nets[i], &buf) < 0) {
|
if (openvzDomainSetNetwork(conn, def->name, def->nets[i], &buf) < 0) {
|
||||||
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("Could not configure network"));
|
_("Could not configure network"));
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -892,8 +892,8 @@ openvzDomainSetNetworkConfig(virConnectPtr conn,
|
|||||||
if (param) {
|
if (param) {
|
||||||
if (openvzWriteVPSConfigParam(strtoI(def->name), "NETIF", param) < 0) {
|
if (openvzWriteVPSConfigParam(strtoI(def->name), "NETIF", param) < 0) {
|
||||||
VIR_FREE(param);
|
VIR_FREE(param);
|
||||||
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("cannot replace NETIF config"));
|
_("cannot replace NETIF config"));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
VIR_FREE(param);
|
VIR_FREE(param);
|
||||||
@ -924,9 +924,9 @@ openvzDomainDefineXML(virConnectPtr conn, const char *xml)
|
|||||||
|
|
||||||
vm = virDomainFindByName(&driver->domains, vmdef->name);
|
vm = virDomainFindByName(&driver->domains, vmdef->name);
|
||||||
if (vm) {
|
if (vm) {
|
||||||
openvzError(VIR_ERR_OPERATION_FAILED,
|
virReportError(VIR_ERR_OPERATION_FAILED,
|
||||||
_("Already an OPENVZ VM active with the id '%s'"),
|
_("Already an OPENVZ VM active with the id '%s'"),
|
||||||
vmdef->name);
|
vmdef->name);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
if (!(vm = virDomainAssignDef(driver->caps,
|
if (!(vm = virDomainAssignDef(driver->caps,
|
||||||
@ -942,15 +942,15 @@ openvzDomainDefineXML(virConnectPtr conn, const char *xml)
|
|||||||
|
|
||||||
if (vm->def->nfss == 1) {
|
if (vm->def->nfss == 1) {
|
||||||
if (openvzSetDiskQuota(vm->def, vm->def->fss[0], true) < 0) {
|
if (openvzSetDiskQuota(vm->def, vm->def->fss[0], true) < 0) {
|
||||||
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("Could not set disk quota"));
|
_("Could not set disk quota"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (openvzSetDefinedUUID(strtoI(vm->def->name), vm->def->uuid) < 0) {
|
if (openvzSetDefinedUUID(strtoI(vm->def->name), vm->def->uuid) < 0) {
|
||||||
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("Could not set UUID"));
|
_("Could not set UUID"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -958,22 +958,22 @@ openvzDomainDefineXML(virConnectPtr conn, const char *xml)
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (vm->def->vcpus != vm->def->maxvcpus) {
|
if (vm->def->vcpus != vm->def->maxvcpus) {
|
||||||
openvzError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||||
_("current vcpu count must equal maximum"));
|
_("current vcpu count must equal maximum"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
if (vm->def->maxvcpus > 0) {
|
if (vm->def->maxvcpus > 0) {
|
||||||
if (openvzDomainSetVcpusInternal(vm, vm->def->maxvcpus) < 0) {
|
if (openvzDomainSetVcpusInternal(vm, vm->def->maxvcpus) < 0) {
|
||||||
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("Could not set number of virtual cpu"));
|
_("Could not set number of virtual cpu"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vm->def->mem.cur_balloon > 0) {
|
if (vm->def->mem.cur_balloon > 0) {
|
||||||
if (openvzDomainSetMemoryInternal(vm, vm->def->mem.cur_balloon) < 0) {
|
if (openvzDomainSetMemoryInternal(vm, vm->def->mem.cur_balloon) < 0) {
|
||||||
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("Could not set memory size"));
|
_("Could not set memory size"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1010,9 +1010,9 @@ openvzDomainCreateXML(virConnectPtr conn, const char *xml,
|
|||||||
|
|
||||||
vm = virDomainFindByName(&driver->domains, vmdef->name);
|
vm = virDomainFindByName(&driver->domains, vmdef->name);
|
||||||
if (vm) {
|
if (vm) {
|
||||||
openvzError(VIR_ERR_OPERATION_FAILED,
|
virReportError(VIR_ERR_OPERATION_FAILED,
|
||||||
_("Already an OPENVZ VM defined with the id '%s'"),
|
_("Already an OPENVZ VM defined with the id '%s'"),
|
||||||
vmdef->name);
|
vmdef->name);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
if (!(vm = virDomainAssignDef(driver->caps,
|
if (!(vm = virDomainAssignDef(driver->caps,
|
||||||
@ -1030,15 +1030,15 @@ openvzDomainCreateXML(virConnectPtr conn, const char *xml,
|
|||||||
|
|
||||||
if (vm->def->nfss == 1) {
|
if (vm->def->nfss == 1) {
|
||||||
if (openvzSetDiskQuota(vm->def, vm->def->fss[0], true) < 0) {
|
if (openvzSetDiskQuota(vm->def, vm->def->fss[0], true) < 0) {
|
||||||
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("Could not set disk quota"));
|
_("Could not set disk quota"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (openvzSetDefinedUUID(strtoI(vm->def->name), vm->def->uuid) < 0) {
|
if (openvzSetDefinedUUID(strtoI(vm->def->name), vm->def->uuid) < 0) {
|
||||||
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("Could not set UUID"));
|
_("Could not set UUID"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1057,8 +1057,8 @@ openvzDomainCreateXML(virConnectPtr conn, const char *xml,
|
|||||||
|
|
||||||
if (vm->def->maxvcpus > 0) {
|
if (vm->def->maxvcpus > 0) {
|
||||||
if (openvzDomainSetVcpusInternal(vm, vm->def->maxvcpus) < 0) {
|
if (openvzDomainSetVcpusInternal(vm, vm->def->maxvcpus) < 0) {
|
||||||
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("Could not set number of virtual cpu"));
|
_("Could not set number of virtual cpu"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1091,8 +1091,8 @@ openvzDomainCreateWithFlags(virDomainPtr dom, unsigned int flags)
|
|||||||
openvzDriverUnlock(driver);
|
openvzDriverUnlock(driver);
|
||||||
|
|
||||||
if (!vm) {
|
if (!vm) {
|
||||||
openvzError(VIR_ERR_NO_DOMAIN, "%s",
|
virReportError(VIR_ERR_NO_DOMAIN, "%s",
|
||||||
_("no domain with matching id"));
|
_("no domain with matching id"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1100,8 +1100,8 @@ openvzDomainCreateWithFlags(virDomainPtr dom, unsigned int flags)
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (status != VIR_DOMAIN_SHUTOFF) {
|
if (status != VIR_DOMAIN_SHUTOFF) {
|
||||||
openvzError(VIR_ERR_OPERATION_DENIED, "%s",
|
virReportError(VIR_ERR_OPERATION_DENIED, "%s",
|
||||||
_("domain is not in shutoff state"));
|
_("domain is not in shutoff state"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1143,8 +1143,8 @@ openvzDomainUndefineFlags(virDomainPtr dom,
|
|||||||
openvzDriverLock(driver);
|
openvzDriverLock(driver);
|
||||||
vm = virDomainFindByUUID(&driver->domains, dom->uuid);
|
vm = virDomainFindByUUID(&driver->domains, dom->uuid);
|
||||||
if (!vm) {
|
if (!vm) {
|
||||||
openvzError(VIR_ERR_NO_DOMAIN, "%s",
|
virReportError(VIR_ERR_NO_DOMAIN, "%s",
|
||||||
_("no domain with matching uuid"));
|
_("no domain with matching uuid"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1192,8 +1192,8 @@ openvzDomainSetAutostart(virDomainPtr dom, int autostart)
|
|||||||
openvzDriverUnlock(driver);
|
openvzDriverUnlock(driver);
|
||||||
|
|
||||||
if (!vm) {
|
if (!vm) {
|
||||||
openvzError(VIR_ERR_NO_DOMAIN, "%s",
|
virReportError(VIR_ERR_NO_DOMAIN, "%s",
|
||||||
_("no domain with matching uuid"));
|
_("no domain with matching uuid"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1222,14 +1222,14 @@ openvzDomainGetAutostart(virDomainPtr dom, int *autostart)
|
|||||||
openvzDriverUnlock(driver);
|
openvzDriverUnlock(driver);
|
||||||
|
|
||||||
if (!vm) {
|
if (!vm) {
|
||||||
openvzError(VIR_ERR_NO_DOMAIN, "%s",
|
virReportError(VIR_ERR_NO_DOMAIN, "%s",
|
||||||
_("no domain with matching uuid"));
|
_("no domain with matching uuid"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (openvzReadVPSConfigParam(strtoI(vm->def->name), "ONBOOT", &value) < 0) {
|
if (openvzReadVPSConfigParam(strtoI(vm->def->name), "ONBOOT", &value) < 0) {
|
||||||
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("Could not read container config"));
|
_("Could not read container config"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1252,8 +1252,8 @@ static int openvzGetMaxVCPUs(virConnectPtr conn ATTRIBUTE_UNUSED,
|
|||||||
if (type == NULL || STRCASEEQ(type, "openvz"))
|
if (type == NULL || STRCASEEQ(type, "openvz"))
|
||||||
return 1028; /* OpenVZ has no limitation */
|
return 1028; /* OpenVZ has no limitation */
|
||||||
|
|
||||||
openvzError(VIR_ERR_INVALID_ARG,
|
virReportError(VIR_ERR_INVALID_ARG,
|
||||||
_("unknown type '%s'"), type);
|
_("unknown type '%s'"), type);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1262,7 +1262,8 @@ openvzDomainGetVcpusFlags(virDomainPtr dom ATTRIBUTE_UNUSED,
|
|||||||
unsigned int flags)
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
if (flags != (VIR_DOMAIN_AFFECT_LIVE | VIR_DOMAIN_VCPU_MAXIMUM)) {
|
if (flags != (VIR_DOMAIN_AFFECT_LIVE | VIR_DOMAIN_VCPU_MAXIMUM)) {
|
||||||
openvzError(VIR_ERR_INVALID_ARG, _("unsupported flags (0x%x)"), flags);
|
virReportError(VIR_ERR_INVALID_ARG,
|
||||||
|
_("unsupported flags (0x%x)"), flags);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1306,7 +1307,8 @@ static int openvzDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,
|
|||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
if (flags != VIR_DOMAIN_AFFECT_LIVE) {
|
if (flags != VIR_DOMAIN_AFFECT_LIVE) {
|
||||||
openvzError(VIR_ERR_INVALID_ARG, _("unsupported flags (0x%x)"), flags);
|
virReportError(VIR_ERR_INVALID_ARG,
|
||||||
|
_("unsupported flags (0x%x)"), flags);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1315,14 +1317,14 @@ static int openvzDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,
|
|||||||
openvzDriverUnlock(driver);
|
openvzDriverUnlock(driver);
|
||||||
|
|
||||||
if (!vm) {
|
if (!vm) {
|
||||||
openvzError(VIR_ERR_NO_DOMAIN, "%s",
|
virReportError(VIR_ERR_NO_DOMAIN, "%s",
|
||||||
_("no domain with matching uuid"));
|
_("no domain with matching uuid"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nvcpus <= 0) {
|
if (nvcpus <= 0) {
|
||||||
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("VCPUs should be >= 1"));
|
_("VCPUs should be >= 1"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1371,21 +1373,21 @@ static virDrvOpenStatus openvzOpen(virConnectPtr conn,
|
|||||||
/* If path isn't /system, then they typoed, so tell them correct path */
|
/* If path isn't /system, then they typoed, so tell them correct path */
|
||||||
if (conn->uri->path == NULL ||
|
if (conn->uri->path == NULL ||
|
||||||
STRNEQ (conn->uri->path, "/system")) {
|
STRNEQ (conn->uri->path, "/system")) {
|
||||||
openvzError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("unexpected OpenVZ URI path '%s', try openvz:///system"),
|
_("unexpected OpenVZ URI path '%s', try openvz:///system"),
|
||||||
conn->uri->path);
|
conn->uri->path);
|
||||||
return VIR_DRV_OPEN_ERROR;
|
return VIR_DRV_OPEN_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!virFileExists("/proc/vz")) {
|
if (!virFileExists("/proc/vz")) {
|
||||||
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("OpenVZ control file /proc/vz does not exist"));
|
_("OpenVZ control file /proc/vz does not exist"));
|
||||||
return VIR_DRV_OPEN_ERROR;
|
return VIR_DRV_OPEN_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (access("/proc/vz", W_OK) < 0) {
|
if (access("/proc/vz", W_OK) < 0) {
|
||||||
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("OpenVZ control file /proc/vz is not accessible"));
|
_("OpenVZ control file /proc/vz is not accessible"));
|
||||||
return VIR_DRV_OPEN_ERROR;
|
return VIR_DRV_OPEN_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1479,8 +1481,8 @@ static int openvzListDomains(virConnectPtr conn ATTRIBUTE_UNUSED,
|
|||||||
if (!ret)
|
if (!ret)
|
||||||
break;
|
break;
|
||||||
if (virStrToLong_i(buf, &endptr, 10, &veid) < 0) {
|
if (virStrToLong_i(buf, &endptr, 10, &veid) < 0) {
|
||||||
openvzError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Could not parse VPS ID %s"), buf);
|
_("Could not parse VPS ID %s"), buf);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
ids[got] = veid;
|
ids[got] = veid;
|
||||||
@ -1534,8 +1536,8 @@ static int openvzListDefinedDomains(virConnectPtr conn ATTRIBUTE_UNUSED,
|
|||||||
if (!ret)
|
if (!ret)
|
||||||
break;
|
break;
|
||||||
if (virStrToLong_i(buf, &endptr, 10, &veid) < 0) {
|
if (virStrToLong_i(buf, &endptr, 10, &veid) < 0) {
|
||||||
openvzError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Could not parse VPS ID %s"), buf);
|
_("Could not parse VPS ID %s"), buf);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
snprintf(vpsname, sizeof(vpsname), "%d", veid);
|
snprintf(vpsname, sizeof(vpsname), "%d", veid);
|
||||||
@ -1666,24 +1668,24 @@ openvzDomainGetBarrierLimit(virDomainPtr domain,
|
|||||||
virCommandAddArgFormat(cmd, "-o%s.b,%s.l", param, param);
|
virCommandAddArgFormat(cmd, "-o%s.b,%s.l", param, param);
|
||||||
virCommandAddArg(cmd, domain->name);
|
virCommandAddArg(cmd, domain->name);
|
||||||
if (virCommandRun(cmd, &status)) {
|
if (virCommandRun(cmd, &status)) {
|
||||||
openvzError(VIR_ERR_OPERATION_FAILED,
|
virReportError(VIR_ERR_OPERATION_FAILED,
|
||||||
_("Failed to get %s for %s: %d"), param, domain->name,
|
_("Failed to get %s for %s: %d"), param, domain->name,
|
||||||
status);
|
status);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
tmp = output;
|
tmp = output;
|
||||||
virSkipSpaces(&tmp);
|
virSkipSpaces(&tmp);
|
||||||
if (virStrToLong_ull(tmp, &endp, 10, barrier) < 0) {
|
if (virStrToLong_ull(tmp, &endp, 10, barrier) < 0) {
|
||||||
openvzError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Can't parse limit from "VZLIST" output '%s'"), output);
|
_("Can't parse limit from "VZLIST" output '%s'"), output);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
tmp = endp;
|
tmp = endp;
|
||||||
virSkipSpaces(&tmp);
|
virSkipSpaces(&tmp);
|
||||||
if (virStrToLong_ull(tmp, &endp, 10, limit) < 0) {
|
if (virStrToLong_ull(tmp, &endp, 10, limit) < 0) {
|
||||||
openvzError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Can't parse barrier from "VZLIST" output '%s'"), output);
|
_("Can't parse barrier from "VZLIST" output '%s'"), output);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1706,9 +1708,9 @@ openvzDomainSetBarrierLimit(virDomainPtr domain,
|
|||||||
|
|
||||||
/* LONG_MAX indicates unlimited so reject larger values */
|
/* LONG_MAX indicates unlimited so reject larger values */
|
||||||
if (barrier > LONG_MAX || limit > LONG_MAX) {
|
if (barrier > LONG_MAX || limit > LONG_MAX) {
|
||||||
openvzError(VIR_ERR_OPERATION_FAILED,
|
virReportError(VIR_ERR_OPERATION_FAILED,
|
||||||
_("Failed to set %s for %s: value too large"), param,
|
_("Failed to set %s for %s: value too large"), param,
|
||||||
domain->name);
|
domain->name);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1717,9 +1719,9 @@ openvzDomainSetBarrierLimit(virDomainPtr domain,
|
|||||||
virCommandAddArgFormat(cmd, "%llu:%llu", barrier, limit);
|
virCommandAddArgFormat(cmd, "%llu:%llu", barrier, limit);
|
||||||
virCommandAddArg(cmd, "--save");
|
virCommandAddArg(cmd, "--save");
|
||||||
if (virCommandRun(cmd, &status)) {
|
if (virCommandRun(cmd, &status)) {
|
||||||
openvzError(VIR_ERR_OPERATION_FAILED,
|
virReportError(VIR_ERR_OPERATION_FAILED,
|
||||||
_("Failed to set %s for %s: %d"), param, domain->name,
|
_("Failed to set %s for %s: %d"), param, domain->name,
|
||||||
status);
|
status);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1872,8 +1874,8 @@ openvzGetVEStatus(virDomainObjPtr vm, int *status, int *reason)
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if ((line = strchr(outbuf, '\n')) == NULL) {
|
if ((line = strchr(outbuf, '\n')) == NULL) {
|
||||||
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("Failed to parse vzlist output"));
|
_("Failed to parse vzlist output"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
*line++ = '\0';
|
*line++ = '\0';
|
||||||
@ -1916,14 +1918,14 @@ openvzDomainInterfaceStats (virDomainPtr dom,
|
|||||||
if (!vm) {
|
if (!vm) {
|
||||||
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
||||||
virUUIDFormat(dom->uuid, uuidstr);
|
virUUIDFormat(dom->uuid, uuidstr);
|
||||||
openvzError(VIR_ERR_NO_DOMAIN,
|
virReportError(VIR_ERR_NO_DOMAIN,
|
||||||
_("no domain with matching uuid '%s'"), uuidstr);
|
_("no domain with matching uuid '%s'"), uuidstr);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!virDomainObjIsActive(vm)) {
|
if (!virDomainObjIsActive(vm)) {
|
||||||
openvzError(VIR_ERR_OPERATION_INVALID,
|
virReportError(VIR_ERR_OPERATION_INVALID,
|
||||||
"%s", _("domain is not running"));
|
"%s", _("domain is not running"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1939,8 +1941,8 @@ openvzDomainInterfaceStats (virDomainPtr dom,
|
|||||||
if (ret == 0)
|
if (ret == 0)
|
||||||
ret = linuxDomainInterfaceStats(path, stats);
|
ret = linuxDomainInterfaceStats(path, stats);
|
||||||
else
|
else
|
||||||
openvzError(VIR_ERR_INVALID_ARG,
|
virReportError(VIR_ERR_INVALID_ARG,
|
||||||
_("invalid path, '%s' is not a known interface"), path);
|
_("invalid path, '%s' is not a known interface"), path);
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
if (vm)
|
if (vm)
|
||||||
@ -1962,8 +1964,8 @@ openvzUpdateDevice(virDomainDefPtr vmdef,
|
|||||||
pos = virDomainFSIndexByName(vmdef, fs->dst);
|
pos = virDomainFSIndexByName(vmdef, fs->dst);
|
||||||
|
|
||||||
if (pos < 0) {
|
if (pos < 0) {
|
||||||
openvzError(VIR_ERR_INVALID_ARG,
|
virReportError(VIR_ERR_INVALID_ARG,
|
||||||
_("target %s doesn't exist."), fs->dst);
|
_("target %s doesn't exist."), fs->dst);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
cur = vmdef->fss[pos];
|
cur = vmdef->fss[pos];
|
||||||
@ -1974,8 +1976,8 @@ openvzUpdateDevice(virDomainDefPtr vmdef,
|
|||||||
|| cur->accessmode != fs->accessmode
|
|| cur->accessmode != fs->accessmode
|
||||||
|| cur->wrpolicy != fs->wrpolicy
|
|| cur->wrpolicy != fs->wrpolicy
|
||||||
|| cur->readonly != fs->readonly) {
|
|| cur->readonly != fs->readonly) {
|
||||||
openvzError(VIR_ERR_CONFIG_UNSUPPORTED,
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||||
_("Can only modify disk quota"));
|
_("Can only modify disk quota"));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1985,9 +1987,9 @@ openvzUpdateDevice(virDomainDefPtr vmdef,
|
|||||||
cur->space_hard_limit = fs->space_hard_limit;
|
cur->space_hard_limit = fs->space_hard_limit;
|
||||||
cur->space_soft_limit = fs->space_soft_limit;
|
cur->space_soft_limit = fs->space_soft_limit;
|
||||||
} else {
|
} else {
|
||||||
openvzError(VIR_ERR_CONFIG_UNSUPPORTED,
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||||
_("Can't modify device type '%s'"),
|
_("Can't modify device type '%s'"),
|
||||||
virDomainDeviceTypeToString(dev->type));
|
virDomainDeviceTypeToString(dev->type));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2015,14 +2017,14 @@ openvzDomainUpdateDeviceFlags(virDomainPtr dom, const char *xml,
|
|||||||
vmdef = vm->def;
|
vmdef = vm->def;
|
||||||
|
|
||||||
if (!vm) {
|
if (!vm) {
|
||||||
openvzError(VIR_ERR_NO_DOMAIN, "%s",
|
virReportError(VIR_ERR_NO_DOMAIN, "%s",
|
||||||
_("no domain with matching uuid"));
|
_("no domain with matching uuid"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virStrToLong_i(vmdef->name, NULL, 10, &veid) < 0) {
|
if (virStrToLong_i(vmdef->name, NULL, 10, &veid) < 0) {
|
||||||
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("Could not convert domain name to VEID"));
|
_("Could not convert domain name to VEID"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
#include "openvz_conf.h"
|
#include "openvz_conf.h"
|
||||||
#include "openvz_util.h"
|
#include "openvz_util.h"
|
||||||
|
|
||||||
|
#define VIR_FROM_THIS VIR_FROM_OPENVZ
|
||||||
|
|
||||||
long
|
long
|
||||||
openvzKBPerPages(void)
|
openvzKBPerPages(void)
|
||||||
@ -41,8 +42,8 @@ openvzKBPerPages(void)
|
|||||||
if (kb_per_pages > 0) {
|
if (kb_per_pages > 0) {
|
||||||
kb_per_pages /= 1024;
|
kb_per_pages /= 1024;
|
||||||
} else {
|
} else {
|
||||||
openvzError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Can't determine page size"));
|
_("Can't determine page size"));
|
||||||
kb_per_pages = 0;
|
kb_per_pages = 0;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user