mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-03 03:25:20 +00:00
Fix usage of virReportSystemError
virReportSystemError is reserved for reporting system errors, calling it with VIR_ERR_* error codes produces error messages that do not make any sense, such as internal error: guest failed to start: Kernel doesn't support user namespace: Link has been severed We should prohibit wrong usage with a syntax-check rule. Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
This commit is contained in:
parent
b09b92665d
commit
9340528a7f
5
cfg.mk
5
cfg.mk
@ -983,6 +983,11 @@ sc_prohibit_devname:
|
||||
halt='avoid using 'devname' as FreeBSD exports the symbol' \
|
||||
$(_sc_search_regexp)
|
||||
|
||||
sc_prohibit_system_error_with_vir_err:
|
||||
@prohibit='\bvirReportSystemError *\(VIR_ERR_' \
|
||||
halt='do not use virReportSystemError with VIR_ERR_* error codes' \
|
||||
$(_sc_search_regexp)
|
||||
|
||||
# We don't use this feature of maint.mk.
|
||||
prev_version_file = /dev/null
|
||||
|
||||
|
@ -2309,7 +2309,7 @@ int lxcContainerStart(virDomainDefPtr def,
|
||||
VIR_DEBUG("Enable user namespace");
|
||||
cflags |= CLONE_NEWUSER;
|
||||
} else {
|
||||
virReportSystemError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
_("Kernel doesn't support user namespace"));
|
||||
VIR_FREE(stack);
|
||||
return -1;
|
||||
|
@ -405,7 +405,7 @@ openvzReadFSConf(virDomainDefPtr def,
|
||||
/* Ensure that we can multiply by 1024 without overflowing. */
|
||||
if (barrier > ULLONG_MAX / 1024 ||
|
||||
limit > ULLONG_MAX / 1024) {
|
||||
virReportSystemError(VIR_ERR_OVERFLOW, "%s",
|
||||
virReportError(VIR_ERR_OVERFLOW, "%s",
|
||||
_("Unable to parse quota"));
|
||||
goto error;
|
||||
}
|
||||
|
@ -369,7 +369,7 @@ qemuMigrationCookieNetworkAlloc(virQEMUDriverPtr driver ATTRIBUTE_UNUSED,
|
||||
case VIR_NETDEV_VPORT_PROFILE_OPENVSWITCH:
|
||||
if (virNetDevOpenvswitchGetMigrateData(&mig->net[i].portdata,
|
||||
netptr->ifname) != 0) {
|
||||
virReportSystemError(VIR_ERR_INTERNAL_ERROR,
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("Unable to run command to get OVS port data for "
|
||||
"interface %s"), netptr->ifname);
|
||||
goto error;
|
||||
@ -2223,7 +2223,7 @@ qemuDomainMigrateOPDRelocate(virQEMUDriverPtr driver ATTRIBUTE_UNUSED,
|
||||
case VIR_NETDEV_VPORT_PROFILE_OPENVSWITCH:
|
||||
if (virNetDevOpenvswitchSetMigrateData(cookie->network->net[i].portdata,
|
||||
netptr->ifname) != 0) {
|
||||
virReportSystemError(VIR_ERR_INTERNAL_ERROR,
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("Unable to run command to set OVS port data for "
|
||||
"interface %s"), netptr->ifname);
|
||||
goto cleanup;
|
||||
|
@ -147,7 +147,7 @@ int virNetDevOpenvswitchAddPort(const char *brname, const char *ifname,
|
||||
}
|
||||
|
||||
if (virCommandRun(cmd, NULL) < 0) {
|
||||
virReportSystemError(VIR_ERR_INTERNAL_ERROR,
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("Unable to add port %s to OVS bridge %s"),
|
||||
ifname, brname);
|
||||
goto cleanup;
|
||||
@ -181,7 +181,7 @@ int virNetDevOpenvswitchRemovePort(const char *brname ATTRIBUTE_UNUSED, const ch
|
||||
virCommandAddArgList(cmd, "--timeout=5", "--", "--if-exists", "del-port", ifname, NULL);
|
||||
|
||||
if (virCommandRun(cmd, NULL) < 0) {
|
||||
virReportSystemError(VIR_ERR_INTERNAL_ERROR,
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("Unable to delete port %s from OVS"), ifname);
|
||||
goto cleanup;
|
||||
}
|
||||
@ -213,7 +213,7 @@ int virNetDevOpenvswitchGetMigrateData(char **migrate, const char *ifname)
|
||||
|
||||
/* Run the command */
|
||||
if (virCommandRun(cmd, NULL) < 0) {
|
||||
virReportSystemError(VIR_ERR_INTERNAL_ERROR,
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("Unable to run command to get OVS port data for "
|
||||
"interface %s"), ifname);
|
||||
goto cleanup;
|
||||
@ -247,7 +247,7 @@ int virNetDevOpenvswitchSetMigrateData(char *migrate, const char *ifname)
|
||||
|
||||
/* Run the command */
|
||||
if (virCommandRun(cmd, NULL) < 0) {
|
||||
virReportSystemError(VIR_ERR_INTERNAL_ERROR,
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("Unable to run command to set OVS port data for "
|
||||
"interface %s"), ifname);
|
||||
goto cleanup;
|
||||
|
@ -220,7 +220,7 @@ void *virObjectLockableNew(virClassPtr klass)
|
||||
return NULL;
|
||||
|
||||
if (virMutexInit(&obj->lock) < 0) {
|
||||
virReportSystemError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("Unable to initialize mutex"));
|
||||
virObjectUnref(obj);
|
||||
return NULL;
|
||||
|
Loading…
Reference in New Issue
Block a user