提交 29bf8259 编写于 作者: D Daniel P. Berrange

Replace use of openvzError with virReportError

Update the OpenVZ driver to use virReportError instead of
the openvzError custom macro
Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
上级 a8483d42
......@@ -516,7 +516,6 @@ msg_gen_function += XENXS_ERROR
msg_gen_function += lxcError
msg_gen_function += libxlError
msg_gen_function += nodeReportError
msg_gen_function += openvzError
msg_gen_function += regerror
msg_gen_function += remoteError
msg_gen_function += statsError
......
......@@ -120,7 +120,7 @@ int openvzExtractVersion(struct openvz_driver *driver)
return 0;
if (openvzExtractVersionInfo(VZCTL, &driver->version) < 0) {
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Could not extract vzctl version"));
return -1;
}
......@@ -234,7 +234,7 @@ openvzReadNetworkConf(virDomainDefPtr def,
*/
ret = openvzReadVPSConfigParam(veid, "IP_ADDRESS", &temp);
if (ret < 0) {
openvzError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Could not read 'IP_ADDRESS' from config for container %d"),
veid);
goto error;
......@@ -266,7 +266,7 @@ openvzReadNetworkConf(virDomainDefPtr def,
*/
ret = openvzReadVPSConfigParam(veid, "NETIF", &temp);
if (ret < 0) {
openvzError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Could not read 'NETIF' from config for container %d"),
veid);
goto error;
......@@ -292,7 +292,7 @@ openvzReadNetworkConf(virDomainDefPtr def,
p += 12;
len = next - p;
if (len > 16) {
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Too long network device name"));
goto error;
}
......@@ -301,7 +301,7 @@ openvzReadNetworkConf(virDomainDefPtr def,
goto no_memory;
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);
goto error;
}
......@@ -309,7 +309,7 @@ openvzReadNetworkConf(virDomainDefPtr def,
p += 7;
len = next - p;
if (len > 16) {
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Too long bridge device name"));
goto error;
}
......@@ -318,7 +318,7 @@ openvzReadNetworkConf(virDomainDefPtr def,
goto no_memory;
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);
goto error;
}
......@@ -326,17 +326,17 @@ openvzReadNetworkConf(virDomainDefPtr def,
p += 4;
len = next - p;
if (len != 17) { /* should be 17 */
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Wrong length MAC address"));
goto error;
}
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);
goto error;
}
if (virMacAddrParse(cpy_temp, &net->mac) < 0) {
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Wrong MAC address"));
goto error;
}
......@@ -411,7 +411,7 @@ openvzReadFSConf(virDomainDefPtr def,
ret = openvzReadVPSConfigParam(veid, "OSTEMPLATE", &temp);
if (ret < 0) {
openvzError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Could not read 'OSTEMPLATE' from config for container %d"),
veid);
goto error;
......@@ -425,7 +425,7 @@ openvzReadFSConf(virDomainDefPtr def,
/* OSTEMPLATE was not found, VE was booted from a private dir directly */
ret = openvzReadVPSConfigParam(veid, "VE_PRIVATE", &temp);
if (ret <= 0) {
openvzError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Could not read 'VE_PRIVATE' from config for container %d"),
veid);
goto error;
......@@ -449,7 +449,7 @@ openvzReadFSConf(virDomainDefPtr def,
ret = openvzReadVPSConfigParam(veid, param, &temp);
if (ret > 0) {
if (openvzParseBarrierLimit(temp, &barrier, &limit)) {
openvzError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Could not read '%s' from config for container %d"),
param, veid);
goto error;
......@@ -503,14 +503,14 @@ openvzReadMemConf(virDomainDefPtr def, int veid)
param = "VMGUARPAGES";
ret = openvzReadVPSConfigParam(veid, param, &temp);
if (ret < 0) {
openvzError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Could not read '%s' from config for container %d"),
param, veid);
goto error;
} else if (ret > 0) {
ret = openvzParseBarrierLimit(temp, &barrier, NULL);
if (ret < 0) {
openvzError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Could not parse barrier of '%s' "
"from config for container %d"), param, veid);
goto error;
......@@ -525,14 +525,14 @@ openvzReadMemConf(virDomainDefPtr def, int veid)
param = "PRIVVMPAGES";
ret = openvzReadVPSConfigParam(veid, param, &temp);
if (ret < 0) {
openvzError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Could not read '%s' from config for container %d"),
param, veid);
goto error;
} else if (ret > 0) {
ret = openvzParseBarrierLimit(temp, &barrier, &limit);
if (ret < 0) {
openvzError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Could not parse barrier and limit of '%s' "
"from config for container %d"), param, veid);
goto error;
......@@ -592,7 +592,7 @@ int openvzLoadDomains(struct openvz_driver *driver) {
if (virStrToLong_i(line, &status, 10, &veid) < 0 ||
*status++ != ' ' ||
(line = strchr(status, '\n')) == NULL) {
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Failed to parse vzlist output"));
goto cleanup;
}
......@@ -602,7 +602,7 @@ int openvzLoadDomains(struct openvz_driver *driver) {
goto no_memory;
if (virMutexInit(&dom->lock) < 0) {
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("cannot initialize mutex"));
VIR_FREE(dom);
goto cleanup;
......@@ -639,7 +639,7 @@ int openvzLoadDomains(struct openvz_driver *driver) {
ret = virUUIDParse(uuidstr, dom->def->uuid);
if (ret == -1) {
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("UUID in config file malformed"));
goto cleanup;
}
......@@ -651,7 +651,7 @@ int openvzLoadDomains(struct openvz_driver *driver) {
ret = openvzReadVPSConfigParam(veid, "CPUS", &temp);
if (ret < 0) {
openvzError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Could not read config for container %d"),
veid);
goto cleanup;
......@@ -671,14 +671,14 @@ int openvzLoadDomains(struct openvz_driver *driver) {
virUUIDFormat(dom->def->uuid, uuidstr);
if (virHashLookup(driver->domains.objs, uuidstr)) {
openvzError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Duplicate container UUID %s detected for %d"),
uuidstr,
veid);
goto cleanup;
}
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);
goto cleanup;
}
......@@ -1048,7 +1048,7 @@ openvzGetVPSUUID(int vpsid, char *uuidstr, size_t len)
if (iden != NULL && uuidbuf != NULL && STREQ(iden, "#UUID:")) {
if (virStrcpy(uuidstr, uuidbuf, len) == NULL) {
openvzError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("invalid uuid %s"), uuidbuf);
goto cleanup;
}
......@@ -1110,7 +1110,7 @@ openvzSetUUID(int vpsid){
unsigned char uuid[VIR_UUID_BUFLEN];
if (virUUIDGenerate(uuid)) {
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Failed to generate UUID"));
return -1;
}
......@@ -1155,7 +1155,7 @@ static int openvzAssignUUIDs(void)
errno = 0;
}
if (errno) {
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Failed to scan configuration directory"));
ret = -1;
}
......@@ -1193,7 +1193,7 @@ int openvzGetVEID(const char *name) {
if (ok && veid >= 0)
return veid;
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Failed to parse vzlist output"));
return -1;
}
......@@ -33,10 +33,6 @@
# include "domain_conf.h"
# include "threads.h"
# define openvzError(code, ...) \
virReportErrorHelper(VIR_FROM_OPENVZ, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
/* OpenVZ commands - Replace with wrapper scripts later? */
# define VZLIST "/usr/sbin/vzlist"
......
......@@ -113,7 +113,7 @@ openvzDomainDefineCmd(virDomainDefPtr vmdef)
NULL);
if (vmdef == NULL) {
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Container is not defined"));
virCommandFree(cmd);
return NULL;
......@@ -138,7 +138,7 @@ static int openvzSetInitialConfig(virDomainDefPtr vmdef)
virCommandPtr cmd = NULL;
if (vmdef->nfss > 1) {
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("only one filesystem supported"));
goto cleanup;
}
......@@ -147,7 +147,7 @@ static int openvzSetInitialConfig(virDomainDefPtr vmdef)
vmdef->fss[0]->type != VIR_DOMAIN_FS_TYPE_TEMPLATE &&
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'"));
goto cleanup;
}
......@@ -158,19 +158,19 @@ static int openvzSetInitialConfig(virDomainDefPtr vmdef)
{
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"));
goto cleanup;
}
if (openvzCopyDefaultConfig(vpsid) < 0) {
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Could not copy default config"));
goto cleanup;
}
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"));
goto cleanup;
}
......@@ -217,7 +217,7 @@ openvzSetDiskQuota(virDomainDefPtr vmdef,
virCommandAddArgFormat(cmd, "%lld", hl);
}
} 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"));
goto cleanup;
}
......@@ -245,7 +245,7 @@ static virDomainPtr openvzDomainLookupByID(virConnectPtr conn,
openvzDriverUnlock(driver);
if (!vm) {
openvzError(VIR_ERR_NO_DOMAIN, NULL);
virReportError(VIR_ERR_NO_DOMAIN, NULL);
goto cleanup;
}
......@@ -278,7 +278,7 @@ static char *openvzGetOSType(virDomainPtr dom)
openvzDriverUnlock(driver);
if (!vm) {
openvzError(VIR_ERR_NO_DOMAIN, NULL);
virReportError(VIR_ERR_NO_DOMAIN, NULL);
goto cleanup;
}
......@@ -303,7 +303,7 @@ static virDomainPtr openvzDomainLookupByUUID(virConnectPtr conn,
openvzDriverUnlock(driver);
if (!vm) {
openvzError(VIR_ERR_NO_DOMAIN, NULL);
virReportError(VIR_ERR_NO_DOMAIN, NULL);
goto cleanup;
}
......@@ -328,7 +328,7 @@ static virDomainPtr openvzDomainLookupByName(virConnectPtr conn,
openvzDriverUnlock(driver);
if (!vm) {
openvzError(VIR_ERR_NO_DOMAIN, NULL);
virReportError(VIR_ERR_NO_DOMAIN, NULL);
goto cleanup;
}
......@@ -354,7 +354,7 @@ static int openvzDomainGetInfo(virDomainPtr dom,
openvzDriverUnlock(driver);
if (!vm) {
openvzError(VIR_ERR_NO_DOMAIN, "%s",
virReportError(VIR_ERR_NO_DOMAIN, "%s",
_("no domain with matching uuid"));
goto cleanup;
}
......@@ -367,7 +367,7 @@ static int openvzDomainGetInfo(virDomainPtr dom,
info->cpuTime = 0;
} else {
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);
goto cleanup;
}
......@@ -402,7 +402,7 @@ openvzDomainGetState(virDomainPtr dom,
openvzDriverUnlock(driver);
if (!vm) {
openvzError(VIR_ERR_NO_DOMAIN, "%s",
virReportError(VIR_ERR_NO_DOMAIN, "%s",
_("no domain with matching uuid"));
goto cleanup;
}
......@@ -426,7 +426,7 @@ static int openvzDomainIsActive(virDomainPtr dom)
obj = virDomainFindByUUID(&driver->domains, dom->uuid);
openvzDriverUnlock(driver);
if (!obj) {
openvzError(VIR_ERR_NO_DOMAIN, NULL);
virReportError(VIR_ERR_NO_DOMAIN, NULL);
goto cleanup;
}
ret = virDomainObjIsActive(obj);
......@@ -448,7 +448,7 @@ static int openvzDomainIsPersistent(virDomainPtr dom)
obj = virDomainFindByUUID(&driver->domains, dom->uuid);
openvzDriverUnlock(driver);
if (!obj) {
openvzError(VIR_ERR_NO_DOMAIN, NULL);
virReportError(VIR_ERR_NO_DOMAIN, NULL);
goto cleanup;
}
ret = obj->persistent;
......@@ -476,7 +476,7 @@ static char *openvzDomainGetXMLDesc(virDomainPtr dom, unsigned int flags) {
openvzDriverUnlock(driver);
if (!vm) {
openvzError(VIR_ERR_NO_DOMAIN, "%s",
virReportError(VIR_ERR_NO_DOMAIN, "%s",
_("no domain with matching uuid"));
goto cleanup;
}
......@@ -520,13 +520,13 @@ static int openvzDomainSuspend(virDomainPtr dom) {
openvzDriverUnlock(driver);
if (!vm) {
openvzError(VIR_ERR_NO_DOMAIN, "%s",
virReportError(VIR_ERR_NO_DOMAIN, "%s",
_("no domain with matching uuid"));
goto cleanup;
}
if (!virDomainObjIsActive(vm)) {
openvzError(VIR_ERR_OPERATION_INVALID, "%s",
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
_("Domain is not running"));
goto cleanup;
}
......@@ -558,13 +558,13 @@ static int openvzDomainResume(virDomainPtr dom) {
openvzDriverUnlock(driver);
if (!vm) {
openvzError(VIR_ERR_NO_DOMAIN, "%s",
virReportError(VIR_ERR_NO_DOMAIN, "%s",
_("no domain with matching uuid"));
goto cleanup;
}
if (!virDomainObjIsActive(vm)) {
openvzError(VIR_ERR_OPERATION_INVALID, "%s",
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
_("Domain is not running"));
goto cleanup;
}
......@@ -601,7 +601,7 @@ openvzDomainShutdownFlags(virDomainPtr dom,
openvzDriverUnlock(driver);
if (!vm) {
openvzError(VIR_ERR_NO_DOMAIN, "%s",
virReportError(VIR_ERR_NO_DOMAIN, "%s",
_("no domain with matching uuid"));
goto cleanup;
}
......@@ -611,7 +611,7 @@ openvzDomainShutdownFlags(virDomainPtr dom,
openvzSetProgramSentinal(prog, vm->def->name);
if (status != VIR_DOMAIN_RUNNING) {
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("domain is not in running state"));
goto cleanup;
}
......@@ -652,7 +652,7 @@ static int openvzDomainReboot(virDomainPtr dom,
openvzDriverUnlock(driver);
if (!vm) {
openvzError(VIR_ERR_NO_DOMAIN, "%s",
virReportError(VIR_ERR_NO_DOMAIN, "%s",
_("no domain with matching uuid"));
goto cleanup;
}
......@@ -662,7 +662,7 @@ static int openvzDomainReboot(virDomainPtr dom,
openvzSetProgramSentinal(prog, vm->def->name);
if (status != VIR_DOMAIN_RUNNING) {
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("domain is not in running state"));
goto cleanup;
}
......@@ -752,7 +752,7 @@ openvzDomainSetNetwork(virConnectPtr conn, const char *vpsid,
if (net == NULL)
return 0;
if (vpsid == NULL) {
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Container ID is not specified"));
return -1;
}
......@@ -788,7 +788,7 @@ openvzDomainSetNetwork(virConnectPtr conn, const char *vpsid,
if (net->data.ethernet.dev == NULL) {
net->data.ethernet.dev = openvzGenerateContainerVethName(veid);
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"));
rc = -1;
goto exit;
......@@ -800,7 +800,7 @@ openvzDomainSetNetwork(virConnectPtr conn, const char *vpsid,
if (net->ifname == NULL) {
net->ifname = openvzGenerateVethName(veid, net->data.ethernet.dev);
if (net->ifname == NULL) {
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Could not generate veth name"));
rc = -1;
goto exit;
......@@ -852,7 +852,7 @@ openvzDomainSetNetwork(virConnectPtr conn, const char *vpsid,
no_memory:
VIR_FREE(opt);
openvzError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Could not put argument to %s"), VZCTL);
cmdExecFree(prog);
return -1;
......@@ -881,7 +881,7 @@ openvzDomainSetNetworkConfig(virConnectPtr conn,
}
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"));
goto exit;
}
......@@ -892,7 +892,7 @@ openvzDomainSetNetworkConfig(virConnectPtr conn,
if (param) {
if (openvzWriteVPSConfigParam(strtoI(def->name), "NETIF", param) < 0) {
VIR_FREE(param);
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("cannot replace NETIF config"));
return -1;
}
......@@ -924,7 +924,7 @@ openvzDomainDefineXML(virConnectPtr conn, const char *xml)
vm = virDomainFindByName(&driver->domains, vmdef->name);
if (vm) {
openvzError(VIR_ERR_OPERATION_FAILED,
virReportError(VIR_ERR_OPERATION_FAILED,
_("Already an OPENVZ VM active with the id '%s'"),
vmdef->name);
goto cleanup;
......@@ -942,14 +942,14 @@ openvzDomainDefineXML(virConnectPtr conn, const char *xml)
if (vm->def->nfss == 1) {
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"));
goto cleanup;
}
}
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"));
goto cleanup;
}
......@@ -958,13 +958,13 @@ openvzDomainDefineXML(virConnectPtr conn, const char *xml)
goto cleanup;
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"));
goto cleanup;
}
if (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"));
goto cleanup;
}
......@@ -972,7 +972,7 @@ openvzDomainDefineXML(virConnectPtr conn, const char *xml)
if (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"));
goto cleanup;
}
......@@ -1010,7 +1010,7 @@ openvzDomainCreateXML(virConnectPtr conn, const char *xml,
vm = virDomainFindByName(&driver->domains, vmdef->name);
if (vm) {
openvzError(VIR_ERR_OPERATION_FAILED,
virReportError(VIR_ERR_OPERATION_FAILED,
_("Already an OPENVZ VM defined with the id '%s'"),
vmdef->name);
goto cleanup;
......@@ -1030,14 +1030,14 @@ openvzDomainCreateXML(virConnectPtr conn, const char *xml,
if (vm->def->nfss == 1) {
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"));
goto cleanup;
}
}
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"));
goto cleanup;
}
......@@ -1057,7 +1057,7 @@ openvzDomainCreateXML(virConnectPtr conn, const char *xml,
if (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"));
goto cleanup;
}
......@@ -1091,7 +1091,7 @@ openvzDomainCreateWithFlags(virDomainPtr dom, unsigned int flags)
openvzDriverUnlock(driver);
if (!vm) {
openvzError(VIR_ERR_NO_DOMAIN, "%s",
virReportError(VIR_ERR_NO_DOMAIN, "%s",
_("no domain with matching id"));
goto cleanup;
}
......@@ -1100,7 +1100,7 @@ openvzDomainCreateWithFlags(virDomainPtr dom, unsigned int flags)
goto cleanup;
if (status != VIR_DOMAIN_SHUTOFF) {
openvzError(VIR_ERR_OPERATION_DENIED, "%s",
virReportError(VIR_ERR_OPERATION_DENIED, "%s",
_("domain is not in shutoff state"));
goto cleanup;
}
......@@ -1143,7 +1143,7 @@ openvzDomainUndefineFlags(virDomainPtr dom,
openvzDriverLock(driver);
vm = virDomainFindByUUID(&driver->domains, dom->uuid);
if (!vm) {
openvzError(VIR_ERR_NO_DOMAIN, "%s",
virReportError(VIR_ERR_NO_DOMAIN, "%s",
_("no domain with matching uuid"));
goto cleanup;
}
......@@ -1192,7 +1192,7 @@ openvzDomainSetAutostart(virDomainPtr dom, int autostart)
openvzDriverUnlock(driver);
if (!vm) {
openvzError(VIR_ERR_NO_DOMAIN, "%s",
virReportError(VIR_ERR_NO_DOMAIN, "%s",
_("no domain with matching uuid"));
goto cleanup;
}
......@@ -1222,13 +1222,13 @@ openvzDomainGetAutostart(virDomainPtr dom, int *autostart)
openvzDriverUnlock(driver);
if (!vm) {
openvzError(VIR_ERR_NO_DOMAIN, "%s",
virReportError(VIR_ERR_NO_DOMAIN, "%s",
_("no domain with matching uuid"));
goto cleanup;
}
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"));
goto cleanup;
}
......@@ -1252,7 +1252,7 @@ static int openvzGetMaxVCPUs(virConnectPtr conn ATTRIBUTE_UNUSED,
if (type == NULL || STRCASEEQ(type, "openvz"))
return 1028; /* OpenVZ has no limitation */
openvzError(VIR_ERR_INVALID_ARG,
virReportError(VIR_ERR_INVALID_ARG,
_("unknown type '%s'"), type);
return -1;
}
......@@ -1262,7 +1262,8 @@ openvzDomainGetVcpusFlags(virDomainPtr dom ATTRIBUTE_UNUSED,
unsigned int flags)
{
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;
}
......@@ -1306,7 +1307,8 @@ static int openvzDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,
int ret = -1;
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;
}
......@@ -1315,13 +1317,13 @@ static int openvzDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,
openvzDriverUnlock(driver);
if (!vm) {
openvzError(VIR_ERR_NO_DOMAIN, "%s",
virReportError(VIR_ERR_NO_DOMAIN, "%s",
_("no domain with matching uuid"));
goto cleanup;
}
if (nvcpus <= 0) {
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("VCPUs should be >= 1"));
goto cleanup;
}
......@@ -1371,20 +1373,20 @@ static virDrvOpenStatus openvzOpen(virConnectPtr conn,
/* If path isn't /system, then they typoed, so tell them correct path */
if (conn->uri->path == NULL ||
STRNEQ (conn->uri->path, "/system")) {
openvzError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("unexpected OpenVZ URI path '%s', try openvz:///system"),
conn->uri->path);
return VIR_DRV_OPEN_ERROR;
}
if (!virFileExists("/proc/vz")) {
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("OpenVZ control file /proc/vz does not exist"));
return VIR_DRV_OPEN_ERROR;
}
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"));
return VIR_DRV_OPEN_ERROR;
}
......@@ -1479,7 +1481,7 @@ static int openvzListDomains(virConnectPtr conn ATTRIBUTE_UNUSED,
if (!ret)
break;
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);
continue;
}
......@@ -1534,7 +1536,7 @@ static int openvzListDefinedDomains(virConnectPtr conn ATTRIBUTE_UNUSED,
if (!ret)
break;
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);
continue;
}
......@@ -1666,7 +1668,7 @@ openvzDomainGetBarrierLimit(virDomainPtr domain,
virCommandAddArgFormat(cmd, "-o%s.b,%s.l", param, param);
virCommandAddArg(cmd, domain->name);
if (virCommandRun(cmd, &status)) {
openvzError(VIR_ERR_OPERATION_FAILED,
virReportError(VIR_ERR_OPERATION_FAILED,
_("Failed to get %s for %s: %d"), param, domain->name,
status);
goto cleanup;
......@@ -1675,14 +1677,14 @@ openvzDomainGetBarrierLimit(virDomainPtr domain,
tmp = output;
virSkipSpaces(&tmp);
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);
goto cleanup;
}
tmp = endp;
virSkipSpaces(&tmp);
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);
goto cleanup;
}
......@@ -1706,7 +1708,7 @@ openvzDomainSetBarrierLimit(virDomainPtr domain,
/* LONG_MAX indicates unlimited so reject larger values */
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,
domain->name);
goto cleanup;
......@@ -1717,7 +1719,7 @@ openvzDomainSetBarrierLimit(virDomainPtr domain,
virCommandAddArgFormat(cmd, "%llu:%llu", barrier, limit);
virCommandAddArg(cmd, "--save");
if (virCommandRun(cmd, &status)) {
openvzError(VIR_ERR_OPERATION_FAILED,
virReportError(VIR_ERR_OPERATION_FAILED,
_("Failed to set %s for %s: %d"), param, domain->name,
status);
goto cleanup;
......@@ -1872,7 +1874,7 @@ openvzGetVEStatus(virDomainObjPtr vm, int *status, int *reason)
goto cleanup;
if ((line = strchr(outbuf, '\n')) == NULL) {
openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Failed to parse vzlist output"));
goto cleanup;
}
......@@ -1916,13 +1918,13 @@ openvzDomainInterfaceStats (virDomainPtr dom,
if (!vm) {
char uuidstr[VIR_UUID_STRING_BUFLEN];
virUUIDFormat(dom->uuid, uuidstr);
openvzError(VIR_ERR_NO_DOMAIN,
virReportError(VIR_ERR_NO_DOMAIN,
_("no domain with matching uuid '%s'"), uuidstr);
goto cleanup;
}
if (!virDomainObjIsActive(vm)) {
openvzError(VIR_ERR_OPERATION_INVALID,
virReportError(VIR_ERR_OPERATION_INVALID,
"%s", _("domain is not running"));
goto cleanup;
}
......@@ -1939,7 +1941,7 @@ openvzDomainInterfaceStats (virDomainPtr dom,
if (ret == 0)
ret = linuxDomainInterfaceStats(path, stats);
else
openvzError(VIR_ERR_INVALID_ARG,
virReportError(VIR_ERR_INVALID_ARG,
_("invalid path, '%s' is not a known interface"), path);
cleanup:
......@@ -1962,7 +1964,7 @@ openvzUpdateDevice(virDomainDefPtr vmdef,
pos = virDomainFSIndexByName(vmdef, fs->dst);
if (pos < 0) {
openvzError(VIR_ERR_INVALID_ARG,
virReportError(VIR_ERR_INVALID_ARG,
_("target %s doesn't exist."), fs->dst);
return -1;
}
......@@ -1974,7 +1976,7 @@ openvzUpdateDevice(virDomainDefPtr vmdef,
|| cur->accessmode != fs->accessmode
|| cur->wrpolicy != fs->wrpolicy
|| cur->readonly != fs->readonly) {
openvzError(VIR_ERR_CONFIG_UNSUPPORTED,
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("Can only modify disk quota"));
return -1;
}
......@@ -1985,7 +1987,7 @@ openvzUpdateDevice(virDomainDefPtr vmdef,
cur->space_hard_limit = fs->space_hard_limit;
cur->space_soft_limit = fs->space_soft_limit;
} else {
openvzError(VIR_ERR_CONFIG_UNSUPPORTED,
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("Can't modify device type '%s'"),
virDomainDeviceTypeToString(dev->type));
return -1;
......@@ -2015,13 +2017,13 @@ openvzDomainUpdateDeviceFlags(virDomainPtr dom, const char *xml,
vmdef = vm->def;
if (!vm) {
openvzError(VIR_ERR_NO_DOMAIN, "%s",
virReportError(VIR_ERR_NO_DOMAIN, "%s",
_("no domain with matching uuid"));
goto cleanup;
}
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"));
goto cleanup;
}
......
......@@ -30,6 +30,7 @@
#include "openvz_conf.h"
#include "openvz_util.h"
#define VIR_FROM_THIS VIR_FROM_OPENVZ
long
openvzKBPerPages(void)
......@@ -41,7 +42,7 @@ openvzKBPerPages(void)
if (kb_per_pages > 0) {
kb_per_pages /= 1024;
} else {
openvzError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Can't determine page size"));
kb_per_pages = 0;
return -1;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册