提交 4343fee0 编写于 作者: D Daniel P. Berrange

Replace use of lxcError with virReportError

Update all LXC code to use virReportError instead of the custom
lxcError macro
Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
上级 19354715
......@@ -77,8 +77,8 @@ virCapsPtr lxcCapsInit(virLXCDriverPtr driver)
VIR_WARN("Failed to get host power management capabilities");
if (virGetHostUUID(caps->host.host_uuid)) {
lxcError(VIR_ERR_INTERNAL_ERROR,
"%s", _("cannot get the host uuid"));
virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("cannot get the host uuid"));
goto error;
}
......@@ -187,9 +187,9 @@ int lxcLoadDriverConfig(virLXCDriverPtr driver)
goto done;
#define CHECK_TYPE(name,typ) if (p && p->type != (typ)) { \
lxcError(VIR_ERR_INTERNAL_ERROR, \
"%s: %s: expected type " #typ, \
filename, (name)); \
virReportError(VIR_ERR_INTERNAL_ERROR, \
"%s: %s: expected type " #typ, \
filename, (name)); \
virConfFree(conf); \
return -1; \
}
......
......@@ -76,10 +76,6 @@ struct _virLXCDriver {
int lxcLoadDriverConfig(virLXCDriverPtr driver);
virCapsPtr lxcCapsInit(virLXCDriverPtr driver);
# define lxcError(code, ...) \
virReportErrorHelper(VIR_FROM_LXC, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
static inline void lxcDriverLock(virLXCDriverPtr driver)
{
virMutexLock(&driver->lock);
......@@ -89,5 +85,4 @@ static inline void lxcDriverUnlock(virLXCDriverPtr driver)
virMutexUnlock(&driver->lock);
}
#endif /* LXC_CONF_H */
......@@ -872,9 +872,9 @@ retry:
* /etc/filesystems is only allowed to contain '*' on the last line
*/
if (gotStar && !tryProc) {
lxcError(VIR_ERR_INTERNAL_ERROR,
_("%s has unexpected '*' before last line"),
fslist);
virReportError(VIR_ERR_INTERNAL_ERROR,
_("%s has unexpected '*' before last line"),
fslist);
goto cleanup;
}
......@@ -1066,14 +1066,14 @@ static int lxcContainerMountFS(virDomainFSDefPtr fs,
/* We do actually support this, but the lxc controller
* should have associated the file with a loopback
* device and changed this to TYPE_BLOCK for us */
lxcError(VIR_ERR_INTERNAL_ERROR,
_("Unexpected filesystem type %s"),
virDomainFSTypeToString(fs->type));
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Unexpected filesystem type %s"),
virDomainFSTypeToString(fs->type));
break;
default:
lxcError(VIR_ERR_CONFIG_UNSUPPORTED,
_("Cannot mount filesystem type %s"),
virDomainFSTypeToString(fs->type));
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("Cannot mount filesystem type %s"),
virDomainFSTypeToString(fs->type));
break;
}
return 0;
......@@ -1599,14 +1599,14 @@ static int lxcContainerDropCapabilities(void)
CAP_AUDIT_CONTROL, /* No messing with auditing status */
CAP_MAC_ADMIN, /* No messing with LSM config */
-1 /* sentinal */)) < 0) {
lxcError(VIR_ERR_INTERNAL_ERROR,
_("Failed to remove capabilities: %d"), ret);
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to remove capabilities: %d"), ret);
return -1;
}
if ((ret = capng_apply(CAPNG_SELECT_BOTH)) < 0) {
lxcError(VIR_ERR_INTERNAL_ERROR,
_("Failed to apply capabilities: %d"), ret);
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to apply capabilities: %d"), ret);
return -1;
}
......@@ -1646,8 +1646,8 @@ static int lxcContainerChild( void *data )
virCommandPtr cmd = NULL;
if (NULL == vmDef) {
lxcError(VIR_ERR_INTERNAL_ERROR,
"%s", _("lxcChild() passed invalid vm definition"));
virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("lxcChild() passed invalid vm definition"));
goto cleanup;
}
......
......@@ -291,9 +291,9 @@ static int virLXCControllerDaemonHandshake(virLXCControllerPtr ctrl)
static int virLXCControllerValidateNICs(virLXCControllerPtr ctrl)
{
if (ctrl->def->nnets != ctrl->nveths) {
lxcError(VIR_ERR_INTERNAL_ERROR,
_("expecting %d veths, but got %zu"),
ctrl->def->nnets, ctrl->nveths);
virReportError(VIR_ERR_INTERNAL_ERROR,
_("expecting %d veths, but got %zu"),
ctrl->def->nnets, ctrl->nveths);
return -1;
}
......@@ -304,9 +304,9 @@ static int virLXCControllerValidateNICs(virLXCControllerPtr ctrl)
static int virLXCControllerValidateConsoles(virLXCControllerPtr ctrl)
{
if (ctrl->def->nconsoles != ctrl->nconsoles) {
lxcError(VIR_ERR_INTERNAL_ERROR,
_("expecting %d consoles, but got %zu tty file handlers"),
ctrl->def->nconsoles, ctrl->nconsoles);
virReportError(VIR_ERR_INTERNAL_ERROR,
_("expecting %d consoles, but got %zu tty file handlers"),
ctrl->def->nconsoles, ctrl->nconsoles);
return -1;
}
......@@ -383,8 +383,8 @@ static int virLXCControllerSetupNUMAPolicy(virLXCControllerPtr ctrl)
VIR_DEBUG("Setting NUMA memory policy");
if (numa_available() < 0) {
lxcError(VIR_ERR_CONFIG_UNSUPPORTED,
"%s", _("Host kernel is not aware of NUMA."));
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
"%s", _("Host kernel is not aware of NUMA."));
return -1;
}
......@@ -395,8 +395,8 @@ static int virLXCControllerSetupNUMAPolicy(virLXCControllerPtr ctrl)
for (i = 0; i < VIR_DOMAIN_CPUMASK_LEN; i++) {
if (ctrl->def->numatune.memory.nodemask[i]) {
if (i > NUMA_NUM_NODES) {
lxcError(VIR_ERR_CONFIG_UNSUPPORTED,
_("Host cannot support NUMA node %d"), i);
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("Host cannot support NUMA node %d"), i);
return -1;
}
if (i > maxnode && !warned) {
......@@ -424,9 +424,9 @@ static int virLXCControllerSetupNUMAPolicy(virLXCControllerPtr ctrl)
}
if (nnodes != 1) {
lxcError(VIR_ERR_CONFIG_UNSUPPORTED,
"%s", _("NUMA memory tuning in 'preferred' mode "
"only supports single node"));
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
"%s", _("NUMA memory tuning in 'preferred' mode "
"only supports single node"));
goto cleanup;
}
......@@ -435,9 +435,9 @@ static int virLXCControllerSetupNUMAPolicy(virLXCControllerPtr ctrl)
} else if (mode == VIR_DOMAIN_NUMATUNE_MEM_INTERLEAVE) {
numa_set_interleave_mask(&mask);
} else {
lxcError(VIR_ERR_CONFIG_UNSUPPORTED,
_("Unable to set NUMA policy %s"),
virDomainNumatuneMemModeTypeToString(mode));
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("Unable to set NUMA policy %s"),
virDomainNumatuneMemModeTypeToString(mode));
goto cleanup;
}
......@@ -450,8 +450,8 @@ cleanup:
static int virLXCControllerSetupNUMAPolicy(virLXCControllerPtr ctrl)
{
if (ctrl->def->numatune.memory.nodemask) {
lxcError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("NUMA policy is not available on this platform"));
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("NUMA policy is not available on this platform"));
return -1;
}
......@@ -602,8 +602,8 @@ static int lxcControllerClearCapabilities(void)
capng_clear(CAPNG_SELECT_BOTH);
if ((ret = capng_apply(CAPNG_SELECT_BOTH)) < 0) {
lxcError(VIR_ERR_INTERNAL_ERROR,
_("failed to apply capabilities: %d"), ret);
virReportError(VIR_ERR_INTERNAL_ERROR,
_("failed to apply capabilities: %d"), ret);
return -1;
}
#else
......@@ -913,8 +913,8 @@ static int virLXCControllerMain(virLXCControllerPtr ctrl)
virLXCControllerConsoleEPoll,
&(ctrl->consoles[i]),
NULL)) < 0) {
lxcError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Unable to watch epoll FD"));
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Unable to watch epoll FD"));
goto cleanup;
}
......@@ -923,8 +923,8 @@ static int virLXCControllerMain(virLXCControllerPtr ctrl)
virLXCControllerConsoleIO,
&(ctrl->consoles[i]),
NULL)) < 0) {
lxcError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Unable to watch host console PTY"));
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Unable to watch host console PTY"));
goto cleanup;
}
......@@ -933,8 +933,8 @@ static int virLXCControllerMain(virLXCControllerPtr ctrl)
virLXCControllerConsoleIO,
&(ctrl->consoles[i]),
NULL)) < 0) {
lxcError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Unable to watch host console PTY"));
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Unable to watch host console PTY"));
goto cleanup;
}
}
......@@ -1092,9 +1092,9 @@ virLXCControllerSetupDevPTS(virLXCControllerPtr ctrl)
if (!root) {
if (ctrl->nconsoles != 1) {
lxcError(VIR_ERR_CONFIG_UNSUPPORTED,
_("Expected exactly one console, but got %zu"),
ctrl->nconsoles);
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("Expected exactly one console, but got %zu"),
ctrl->nconsoles);
return -1;
}
return 0;
......
此差异已折叠。
......@@ -275,9 +275,9 @@ static int virLXCProcessSetupInterfaceBridged(virConnectPtr conn,
if (virNetDevBandwidthSet(net->ifname,
virDomainNetGetActualBandwidth(net)) < 0) {
lxcError(VIR_ERR_INTERNAL_ERROR,
_("cannot set bandwidth limits on %s"),
net->ifname);
virReportError(VIR_ERR_INTERNAL_ERROR,
_("cannot set bandwidth limits on %s"),
net->ifname);
goto cleanup;
}
......@@ -311,8 +311,8 @@ static int virLXCProcessSetupInterfaceDirect(virConnectPtr conn,
*/
bw = virDomainNetGetActualBandwidth(net);
if (bw) {
lxcError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("Unable to set network bandwidth on direct interfaces"));
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("Unable to set network bandwidth on direct interfaces"));
return -1;
}
......@@ -325,8 +325,8 @@ static int virLXCProcessSetupInterfaceDirect(virConnectPtr conn,
*/
prof = virDomainNetGetActualVirtPortProfile(net);
if (prof) {
lxcError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("Unable to set port profile on direct interfaces"));
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("Unable to set port profile on direct interfaces"));
return -1;
}
......@@ -416,8 +416,8 @@ static int virLXCProcessSetupInterfaces(virConnectPtr conn,
case VIR_DOMAIN_NET_TYPE_BRIDGE: {
const char *brname = virDomainNetGetActualBridgeName(def->nets[i]);
if (!brname) {
lxcError(VIR_ERR_INTERNAL_ERROR, "%s",
_("No bridge name specified"));
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("No bridge name specified"));
goto cleanup;
}
if (virLXCProcessSetupInterfaceBridged(conn,
......@@ -445,11 +445,11 @@ static int virLXCProcessSetupInterfaces(virConnectPtr conn,
case VIR_DOMAIN_NET_TYPE_MCAST:
case VIR_DOMAIN_NET_TYPE_INTERNAL:
case VIR_DOMAIN_NET_TYPE_LAST:
lxcError(VIR_ERR_INTERNAL_ERROR,
_("Unsupported network type %s"),
virDomainNetTypeToString(
virDomainNetGetActualType(def->nets[i])
));
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Unsupported network type %s"),
virDomainNetTypeToString(
virDomainNetGetActualType(def->nets[i])
));
goto cleanup;
}
}
......@@ -508,8 +508,8 @@ static int virLXCProcessMonitorClient(virLXCDriverPtr driver,
memset(&addr, 0, sizeof(addr));
addr.sun_family = AF_UNIX;
if (virStrcpyStatic(addr.sun_path, sockpath) == NULL) {
lxcError(VIR_ERR_INTERNAL_ERROR,
_("Socket path %s too big for destination"), sockpath);
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Socket path %s too big for destination"), sockpath);
goto error;
}
......@@ -537,8 +537,8 @@ int virLXCProcessStop(virLXCDriverPtr driver,
int rc;
if (vm->pid <= 0) {
lxcError(VIR_ERR_INTERNAL_ERROR,
_("Invalid PID %d for container"), vm->pid);
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Invalid PID %d for container"), vm->pid);
return -1;
}
......@@ -561,8 +561,8 @@ int virLXCProcessStop(virLXCDriverPtr driver,
goto cleanup;
}
if (rc == 1) {
lxcError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Some container PIDs refused to die"));
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Some container PIDs refused to die"));
rc = -1;
goto cleanup;
}
......@@ -811,27 +811,27 @@ int virLXCProcessStart(virConnectPtr conn,
virErrorPtr err = NULL;
if (!lxc_driver->cgroup) {
lxcError(VIR_ERR_INTERNAL_ERROR, "%s",
_("The 'cpuacct', 'devices' & 'memory' cgroups controllers must be mounted"));
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("The 'cpuacct', 'devices' & 'memory' cgroups controllers must be mounted"));
return -1;
}
if (!virCgroupMounted(lxc_driver->cgroup,
VIR_CGROUP_CONTROLLER_CPUACCT)) {
lxcError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Unable to find 'cpuacct' cgroups controller mount"));
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Unable to find 'cpuacct' cgroups controller mount"));
return -1;
}
if (!virCgroupMounted(lxc_driver->cgroup,
VIR_CGROUP_CONTROLLER_DEVICES)) {
lxcError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Unable to find 'devices' cgroups controller mount"));
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Unable to find 'devices' cgroups controller mount"));
return -1;
}
if (!virCgroupMounted(lxc_driver->cgroup,
VIR_CGROUP_CONTROLLER_MEMORY)) {
lxcError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Unable to find 'memory' cgroups controller mount"));
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Unable to find 'memory' cgroups controller mount"));
return -1;
}
......@@ -906,8 +906,8 @@ int virLXCProcessStart(virConnectPtr conn,
for (i = 0 ; i < vm->def->nconsoles ; i++) {
char *ttyPath;
if (vm->def->consoles[i]->source.type != VIR_DOMAIN_CHR_TYPE_PTY) {
lxcError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("Only PTY console types are supported"));
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("Only PTY console types are supported"));
goto cleanup;
}
......@@ -1021,8 +1021,8 @@ int virLXCProcessStart(virConnectPtr conn,
char out[1024];
if (!(virLXCProcessReadLogOutput(vm, logfile, pos, out, 1024) < 0)) {
lxcError(VIR_ERR_INTERNAL_ERROR,
_("guest failed to start: %s"), out);
virReportError(VIR_ERR_INTERNAL_ERROR,
_("guest failed to start: %s"), out);
}
goto error;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册