Convert (nearly) all files in src/util/ to use virReportError()

This removes nearly all the per-file error reporting macros
from the code in src/util/. A few custom macros remain for the
case, where the file needs to report errors with a variety of
different codes or parameters

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
This commit is contained in:
Daniel P. Berrange 2012-07-18 11:26:24 +01:00
parent 8a89c08069
commit f6d4405e3c
27 changed files with 322 additions and 443 deletions

18
cfg.mk
View File

@ -514,38 +514,26 @@ msg_gen_function += VIR_ERROR
msg_gen_function += VMX_ERROR
msg_gen_function += XENXS_ERROR
msg_gen_function += eventReportError
msg_gen_function += ifaceError
msg_gen_function += interfaceReportError
msg_gen_function += iptablesError
msg_gen_function += lxcError
msg_gen_function += libxlError
msg_gen_function += macvtapError
msg_gen_function += networkReportError
msg_gen_function += nodeReportError
msg_gen_function += openvzError
msg_gen_function += pciReportError
msg_gen_function += qemuReportError
msg_gen_function += qemudDispatchClientFailure
msg_gen_function += regerror
msg_gen_function += remoteError
msg_gen_function += remoteDispatchFormatError
msg_gen_function += statsError
msg_gen_function += streamsReportError
msg_gen_function += usbReportError
msg_gen_function += umlReportError
msg_gen_function += vah_error
msg_gen_function += vah_warning
msg_gen_function += vboxError
msg_gen_function += virCommandError
msg_gen_function += virConfError
msg_gen_function += virCPUReportError
msg_gen_function += virEventError
msg_gen_function += virDomainReportError
msg_gen_function += virGenericReportError
msg_gen_function += virHashError
msg_gen_function += virHookReportError
msg_gen_function += virInterfaceReportError
msg_gen_function += virJSONError
msg_gen_function += virLibConnError
msg_gen_function += virLibDomainError
msg_gen_function += virLibDomainSnapshotError
@ -565,13 +553,7 @@ msg_gen_function += virReportErrorHelper
msg_gen_function += virReportSystemError
msg_gen_function += virSecretReportError
msg_gen_function += virSecurityReportError
msg_gen_function += virSexprError
msg_gen_function += virSmbiosReportError
msg_gen_function += virSocketError
msg_gen_function += virStatsError
msg_gen_function += virStorageReportError
msg_gen_function += virUtilError
msg_gen_function += virXMLError
msg_gen_function += virXenInotifyError
msg_gen_function += virXenStoreError
msg_gen_function += virXendError

View File

@ -44,10 +44,6 @@
#define VIR_FROM_THIS VIR_FROM_NONE
#define virCommandError(code, ...) \
virReportErrorHelper(VIR_FROM_NONE, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
/* Flags for virExecWithHook */
enum {
VIR_EXEC_NONE = 0,
@ -173,8 +169,8 @@ static int virClearCapabilities(void)
capng_clear(CAPNG_SELECT_BOTH);
if ((ret = capng_apply(CAPNG_SELECT_BOTH)) < 0) {
virCommandError(VIR_ERR_INTERNAL_ERROR,
_("cannot clear process capabilities %d"), ret);
virReportError(VIR_ERR_INTERNAL_ERROR,
_("cannot clear process capabilities %d"), ret);
return -1;
}
@ -200,8 +196,8 @@ static int virSetCapabilities(unsigned long long capabilities)
}
if ((ret = capng_apply(CAPNG_SELECT_BOTH)) < 0) {
virCommandError(VIR_ERR_INTERNAL_ERROR,
_("cannot apply process capabilities %d"), ret);
virReportError(VIR_ERR_INTERNAL_ERROR,
_("cannot apply process capabilities %d"), ret);
return -1;
}
@ -661,8 +657,8 @@ virExecWithHook(const char *const*argv,
if (binary != argv[0])
VIR_FREE(binary);
/* NB we don't virCommandError() on any failures here
because the code which jumped hre already raised
/* NB we don't virReportError() on any failures here
because the code which jumped here already raised
an error condition which we must not overwrite */
VIR_FORCE_CLOSE(pipeerr[0]);
VIR_FORCE_CLOSE(pipeerr[1]);
@ -707,8 +703,8 @@ virRun(const char *const *argv ATTRIBUTE_UNUSED,
if (status)
*status = ENOTSUP;
else
virCommandError(VIR_ERR_INTERNAL_ERROR,
"%s", _("virRun is not implemented for WIN32"));
virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("virRun is not implemented for WIN32"));
return -1;
}
@ -731,8 +727,8 @@ virExecWithHook(const char *const*argv ATTRIBUTE_UNUSED,
* top of _spawn() or CreateProcess(), but we can't implement
* everything, since mingw completely lacks fork(), so we cannot
* run hook code in the child. */
virCommandError(VIR_ERR_INTERNAL_ERROR,
"%s", _("virExec is not implemented for WIN32"));
virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("virExec is not implemented for WIN32"));
return -1;
}
@ -1619,8 +1615,8 @@ virCommandToString(virCommandPtr cmd)
return NULL;
}
if (cmd->has_error) {
virCommandError(VIR_ERR_INTERNAL_ERROR, "%s",
_("invalid use of command API"));
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("invalid use of command API"));
return NULL;
}
@ -1847,8 +1843,8 @@ int virCommandExec(virCommandPtr cmd)
return -1;
}
if (cmd->has_error) {
virCommandError(VIR_ERR_INTERNAL_ERROR, "%s",
_("invalid use of command API"));
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("invalid use of command API"));
return -1;
}
@ -1896,8 +1892,8 @@ virCommandRun(virCommandPtr cmd, int *exitstatus)
return -1;
}
if (cmd->has_error) {
virCommandError(VIR_ERR_INTERNAL_ERROR, "%s",
_("invalid use of command API"));
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("invalid use of command API"));
return -1;
}
@ -1918,14 +1914,14 @@ virCommandRun(virCommandPtr cmd, int *exitstatus)
async_io = true;
if (async_io) {
if (!(cmd->flags & VIR_EXEC_DAEMON) || string_io) {
virCommandError(VIR_ERR_INTERNAL_ERROR, "%s",
_("cannot mix caller fds with blocking execution"));
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("cannot mix caller fds with blocking execution"));
return -1;
}
} else {
if ((cmd->flags & VIR_EXEC_DAEMON) && string_io) {
virCommandError(VIR_ERR_INTERNAL_ERROR, "%s",
_("cannot mix string I/O with daemon"));
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("cannot mix string I/O with daemon"));
return -1;
}
}
@ -2137,8 +2133,8 @@ virCommandRunAsync(virCommandPtr cmd, pid_t *pid)
return -1;
}
if (cmd->has_error) {
virCommandError(VIR_ERR_INTERNAL_ERROR, "%s",
_("invalid use of command API"));
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("invalid use of command API"));
return -1;
}
@ -2149,32 +2145,32 @@ virCommandRunAsync(virCommandPtr cmd, pid_t *pid)
if ((cmd->inbuf && cmd->infd == -1) ||
(cmd->outbuf && cmd->outfdptr != &cmd->outfd) ||
(cmd->errbuf && cmd->errfdptr != &cmd->errfd)) {
virCommandError(VIR_ERR_INTERNAL_ERROR, "%s",
_("cannot mix string I/O with asynchronous command"));
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("cannot mix string I/O with asynchronous command"));
return -1;
}
if (cmd->pid != -1) {
virCommandError(VIR_ERR_INTERNAL_ERROR,
_("command is already running as pid %lld"),
(long long) cmd->pid);
virReportError(VIR_ERR_INTERNAL_ERROR,
_("command is already running as pid %lld"),
(long long) cmd->pid);
return -1;
}
if (!synchronous && (cmd->flags & VIR_EXEC_DAEMON)) {
virCommandError(VIR_ERR_INTERNAL_ERROR, "%s",
_("daemonized command cannot use virCommandRunAsync"));
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("daemonized command cannot use virCommandRunAsync"));
return -1;
}
if (cmd->pwd && (cmd->flags & VIR_EXEC_DAEMON)) {
virCommandError(VIR_ERR_INTERNAL_ERROR,
_("daemonized command cannot set working directory %s"),
cmd->pwd);
virReportError(VIR_ERR_INTERNAL_ERROR,
_("daemonized command cannot set working directory %s"),
cmd->pwd);
return -1;
}
if (cmd->pidfile && !(cmd->flags & VIR_EXEC_DAEMON)) {
virCommandError(VIR_ERR_INTERNAL_ERROR, "%s",
_("creation of pid file requires daemonized command"));
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("creation of pid file requires daemonized command"));
return -1;
}
@ -2250,9 +2246,9 @@ virPidWait(pid_t pid, int *exitstatus)
if (exitstatus == NULL) {
if (status != 0) {
char *st = virCommandTranslateStatus(status);
virCommandError(VIR_ERR_INTERNAL_ERROR,
_("Child process (%lld) status unexpected: %s"),
(long long) pid, NULLSTR(st));
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Child process (%lld) status unexpected: %s"),
(long long) pid, NULLSTR(st));
VIR_FREE(st);
return -1;
}
@ -2285,14 +2281,14 @@ virCommandWait(virCommandPtr cmd, int *exitstatus)
return -1;
}
if (cmd->has_error) {
virCommandError(VIR_ERR_INTERNAL_ERROR, "%s",
_("invalid use of command API"));
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("invalid use of command API"));
return -1;
}
if (cmd->pid == -1) {
virCommandError(VIR_ERR_INTERNAL_ERROR, "%s",
_("command is not yet running"));
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("command is not yet running"));
return -1;
}
@ -2309,9 +2305,9 @@ virCommandWait(virCommandPtr cmd, int *exitstatus)
if (status) {
char *str = virCommandToString(cmd);
char *st = virCommandTranslateStatus(status);
virCommandError(VIR_ERR_INTERNAL_ERROR,
_("Child process (%s) status unexpected: %s"),
str ? str : cmd->args[0], NULLSTR(st));
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Child process (%s) status unexpected: %s"),
str ? str : cmd->args[0], NULLSTR(st));
VIR_FREE(str);
VIR_FREE(st);
return -1;
@ -2476,14 +2472,14 @@ int virCommandHandshakeWait(virCommandPtr cmd)
return -1;
}
if (cmd->has_error || !cmd->handshake) {
virCommandError(VIR_ERR_INTERNAL_ERROR, "%s",
_("invalid use of command API"));
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("invalid use of command API"));
return -1;
}
if (cmd->handshakeWait[0] == -1) {
virCommandError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Handshake is already complete"));
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Handshake is already complete"));
return -1;
}
@ -2520,7 +2516,7 @@ int virCommandHandshakeWait(virCommandPtr cmd)
}
VIR_FORCE_CLOSE(cmd->handshakeWait[0]);
msg[len-1] = '\0';
virCommandError(VIR_ERR_INTERNAL_ERROR, "%s", msg);
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", msg);
VIR_FREE(msg);
return -1;
}
@ -2543,14 +2539,14 @@ int virCommandHandshakeNotify(virCommandPtr cmd)
return -1;
}
if (cmd->has_error || !cmd->handshake) {
virCommandError(VIR_ERR_INTERNAL_ERROR, "%s",
_("invalid use of command API"));
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("invalid use of command API"));
return -1;
}
if (cmd->handshakeNotify[1] == -1) {
virCommandError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Handshake is already complete"));
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Handshake is already complete"));
return -1;
}

View File

@ -44,10 +44,6 @@
#define VIR_FROM_THIS VIR_FROM_EVENT
#define virEventError(code, ...) \
virReportErrorHelper(VIR_FROM_EVENT, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
static int virEventPollInterruptLocked(void);
/* State for a single file handle being monitored */
@ -680,9 +676,9 @@ int virEventPollInit(void)
if (virEventPollAddHandle(eventLoop.wakeupfd[0],
VIR_EVENT_HANDLE_READABLE,
virEventPollHandleWakeup, NULL, NULL) < 0) {
virEventError(VIR_ERR_INTERNAL_ERROR,
_("Unable to add handle %d to event loop"),
eventLoop.wakeupfd[0]);
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Unable to add handle %d to event loop"),
eventLoop.wakeupfd[0]);
VIR_FORCE_CLOSE(eventLoop.wakeupfd[0]);
VIR_FORCE_CLOSE(eventLoop.wakeupfd[1]);
return -1;

View File

@ -41,10 +41,6 @@
#define VIR_FROM_THIS VIR_FROM_HOOK
#define virHookReportError(code, ...) \
virReportErrorHelper(VIR_FROM_HOOK, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
#define LIBVIRT_HOOK_DIR SYSCONFDIR "/libvirt/hooks"
VIR_ENUM_DECL(virHookDriver)
@ -105,16 +101,16 @@ virHookCheck(int no, const char *driver) {
int ret;
if (driver == NULL) {
virHookReportError(VIR_ERR_INTERNAL_ERROR,
_("Invalid hook name for #%d"), no);
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Invalid hook name for #%d"), no);
return -1;
}
ret = virBuildPath(&path, LIBVIRT_HOOK_DIR, driver);
if ((ret < 0) || (path == NULL)) {
virHookReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to build path for %s hook"),
driver);
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to build path for %s hook"),
driver);
return -1;
}
@ -252,9 +248,9 @@ virHookCall(int driver,
break;
}
if (opstr == NULL) {
virHookReportError(VIR_ERR_INTERNAL_ERROR,
_("Hook for %s, failed to find operation #%d"),
drvstr, op);
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Hook for %s, failed to find operation #%d"),
drvstr, op);
return 1;
}
subopstr = virHookSubopTypeToString(sub_op);
@ -265,9 +261,9 @@ virHookCall(int driver,
ret = virBuildPath(&path, LIBVIRT_HOOK_DIR, drvstr);
if ((ret < 0) || (path == NULL)) {
virHookReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to build path for %s hook"),
drvstr);
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to build path for %s hook"),
drvstr);
return -1;
}
@ -285,9 +281,9 @@ virHookCall(int driver,
ret = virCommandRun(cmd, &exitstatus);
if (ret == 0 && exitstatus != 0) {
virHookReportError(VIR_ERR_HOOK_SCRIPT_FAILED,
_("Hook script %s %s failed with error code %d"),
path, drvstr, exitstatus);
virReportError(VIR_ERR_HOOK_SCRIPT_FAILED,
_("Hook script %s %s failed with error code %d"),
path, drvstr, exitstatus);
ret = -1;
}

View File

@ -45,10 +45,6 @@
/* For virReportOOMError() and virReportSystemError() */
#define VIR_FROM_THIS VIR_FROM_NONE
#define usbReportError(code, ...) \
virReportErrorHelper(VIR_FROM_NONE, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
struct _usbDevice {
unsigned int bus;
unsigned int dev;
@ -88,7 +84,7 @@ static int usbSysReadFile(const char *f_name, const char *d_name,
goto cleanup;
if (virStrToLong_ui(buf, &ignore, base, value) < 0) {
usbReportError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Could not parse usb file %s"), filename);
goto cleanup;
}
@ -144,7 +140,7 @@ usbDeviceSearch(unsigned int vendor,
tmpstr += 3;
if (virStrToLong_ui(tmpstr, &ignore, 10, &found_bus) < 0) {
usbReportError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to parse dir name '%s'"),
de->d_name);
goto cleanup;
@ -200,7 +196,7 @@ usbFindDeviceByVendor(unsigned int vendor, unsigned product)
return NULL;
if (list->count == 0) {
usbReportError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Did not find USB device %x:%x"), vendor, product);
usbDeviceListFree(list);
return NULL;
@ -220,7 +216,7 @@ usbFindDeviceByBus(unsigned int bus, unsigned devno)
return NULL;
if (list->count == 0) {
usbReportError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Did not find USB device bus:%u device:%u"),
bus, devno);
usbDeviceListFree(list);
@ -248,7 +244,7 @@ usbFindDevice(unsigned int vendor,
return NULL;
if (list->count == 0) {
usbReportError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Did not find USB device %x:%x bus:%u device:%u"),
vendor, product, bus, devno);
usbDeviceListFree(list);
@ -278,7 +274,7 @@ usbGetDevice(unsigned int bus,
if (snprintf(dev->name, sizeof(dev->name), "%.3o:%.3o",
dev->bus, dev->dev) >= sizeof(dev->name)) {
usbReportError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("dev->name buffer overflow: %.3o:%.3o"),
dev->bus, dev->dev);
usbFreeDevice(dev);
@ -294,7 +290,7 @@ usbGetDevice(unsigned int bus,
/* XXX fixme. this should be product/vendor */
if (snprintf(dev->id, sizeof(dev->id), "%d %d", dev->bus,
dev->dev) >= sizeof(dev->id)) {
usbReportError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("dev->id buffer overflow: %d %d"),
dev->bus, dev->dev);
usbFreeDevice(dev);
@ -383,7 +379,7 @@ usbDeviceListAdd(usbDeviceList *list,
usbDevice *dev)
{
if (usbDeviceListFind(list, dev)) {
usbReportError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Device %s is already in use"),
dev->name);
return -1;

View File

@ -45,9 +45,6 @@
#include "logging.h"
#define VIR_FROM_THIS VIR_FROM_NONE
#define iptablesError(code, ...) \
virReportErrorHelper(VIR_FROM_THIS, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
enum {
ADD = 0,
@ -293,14 +290,14 @@ static char *iptablesFormatNetwork(virSocketAddr *netaddr,
if (!(VIR_SOCKET_ADDR_IS_FAMILY(netaddr, AF_INET) ||
VIR_SOCKET_ADDR_IS_FAMILY(netaddr, AF_INET6))) {
iptablesError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("Only IPv4 or IPv6 addresses can be used with iptables"));
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("Only IPv4 or IPv6 addresses can be used with iptables"));
return NULL;
}
if (virSocketAddrMaskByPrefix(netaddr, prefix, &network) < 0) {
iptablesError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Failure to mask address"));
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Failure to mask address"));
return NULL;
}
@ -763,9 +760,9 @@ iptablesForwardMasquerade(iptablesContext *ctx,
if (!VIR_SOCKET_ADDR_IS_FAMILY(netaddr, AF_INET)) {
/* Higher level code *should* guaranteee it's impossible to get here. */
iptablesError(VIR_ERR_INTERNAL_ERROR,
_("Attempted to NAT '%s'. NAT is only supported for IPv4."),
networkstr);
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Attempted to NAT '%s'. NAT is only supported for IPv4."),
networkstr);
VIR_FREE(networkstr);
return -1;
}

View File

@ -43,9 +43,6 @@
/* XXX fixme */
#define VIR_FROM_THIS VIR_FROM_NONE
#define virJSONError(code, ...) \
virReportErrorHelper(VIR_FROM_NONE, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
typedef struct _virJSONParserState virJSONParserState;
@ -956,8 +953,8 @@ virJSONValuePtr virJSONValueFromString(const char *jsonstring)
hand = yajl_alloc(&parserCallbacks, &cfg, NULL, &parser);
# endif
if (!hand) {
virJSONError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Unable to create JSON parser"));
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Unable to create JSON parser"));
goto cleanup;
}
@ -968,9 +965,9 @@ virJSONValuePtr virJSONValueFromString(const char *jsonstring)
(const unsigned char*)jsonstring,
strlen(jsonstring));
virJSONError(VIR_ERR_INTERNAL_ERROR,
_("cannot parse json %s: %s"),
jsonstring, (const char*) errstr);
virReportError(VIR_ERR_INTERNAL_ERROR,
_("cannot parse json %s: %s"),
jsonstring, (const char*) errstr);
VIR_FREE(errstr);
virJSONValueFree(parser.head);
goto cleanup;
@ -1080,8 +1077,8 @@ char *virJSONValueToString(virJSONValuePtr object)
g = yajl_gen_alloc(&conf, NULL);
# endif
if (!g) {
virJSONError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Unable to create JSON formatter"));
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Unable to create JSON formatter"));
goto cleanup;
}
@ -1110,14 +1107,14 @@ cleanup:
#else
virJSONValuePtr virJSONValueFromString(const char *jsonstring ATTRIBUTE_UNUSED)
{
virJSONError(VIR_ERR_INTERNAL_ERROR, "%s",
_("No JSON parser implementation is available"));
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("No JSON parser implementation is available"));
return NULL;
}
char *virJSONValueToString(virJSONValuePtr object ATTRIBUTE_UNUSED)
{
virJSONError(VIR_ERR_INTERNAL_ERROR, "%s",
_("No JSON parser implementation is available"));
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("No JSON parser implementation is available"));
return NULL;
}
#endif

View File

@ -82,10 +82,6 @@ struct _pciDeviceList {
/* For virReportOOMError() and virReportSystemError() */
#define VIR_FROM_THIS VIR_FROM_NONE
#define pciReportError(code, ...) \
virReportErrorHelper(VIR_FROM_NONE, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
/* Specifications referenced in comments:
* PCI30 - PCI Local Bus Specification 3.0
* PCIe20 - PCI Express Base Specification 2.0
@ -615,7 +611,7 @@ pciTrySecondaryBusReset(pciDevice *dev,
* are not in use by the host or other guests.
*/
if ((conflict = pciBusContainsActiveDevices(dev, inactiveDevs))) {
pciReportError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Active %s devices on bus with %s, not doing bus reset"),
conflict->name, dev->name);
return -1;
@ -625,7 +621,7 @@ pciTrySecondaryBusReset(pciDevice *dev,
if (pciGetParentDevice(dev, &parent) < 0)
return -1;
if (!parent) {
pciReportError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to find parent device for %s"),
dev->name);
return -1;
@ -638,7 +634,7 @@ pciTrySecondaryBusReset(pciDevice *dev,
* are multiple devices/functions
*/
if (pciRead(dev, 0, config_space, PCI_CONF_LEN) < 0) {
pciReportError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to read PCI config space for %s"),
dev->name);
goto out;
@ -658,7 +654,7 @@ pciTrySecondaryBusReset(pciDevice *dev,
usleep(200 * 1000); /* sleep 200ms */
if (pciWrite(dev, 0, config_space, PCI_CONF_LEN) < 0) {
pciReportError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to restore PCI config space for %s"),
dev->name);
goto out;
@ -684,7 +680,7 @@ pciTryPowerManagementReset(pciDevice *dev)
/* Save and restore the device's config space. */
if (pciRead(dev, 0, &config_space[0], PCI_CONF_LEN) < 0) {
pciReportError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to read PCI config space for %s"),
dev->name);
return -1;
@ -704,7 +700,7 @@ pciTryPowerManagementReset(pciDevice *dev)
usleep(10 * 1000); /* sleep 10ms */
if (pciWrite(dev, 0, &config_space[0], PCI_CONF_LEN) < 0) {
pciReportError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to restore PCI config space for %s"),
dev->name);
return -1;
@ -744,7 +740,7 @@ pciResetDevice(pciDevice *dev,
int ret = -1;
if (activeDevs && pciDeviceListFind(activeDevs, dev)) {
pciReportError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Not resetting active device %s"), dev->name);
return -1;
}
@ -771,7 +767,7 @@ pciResetDevice(pciDevice *dev,
if (ret < 0) {
virErrorPtr err = virGetLastError();
pciReportError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Unable to reset PCI device %s: %s"),
dev->name,
err ? err->message : _("no FLR, PM reset or bus reset available"));
@ -1118,13 +1114,13 @@ pciDettachDevice(pciDevice *dev,
{
const char *driver = pciFindStubDriver();
if (!driver) {
pciReportError(VIR_ERR_INTERNAL_ERROR, "%s",
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("cannot find any PCI stub module"));
return -1;
}
if (activeDevs && pciDeviceListFind(activeDevs, dev)) {
pciReportError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Not detaching active device %s"), dev->name);
return -1;
}
@ -1148,13 +1144,13 @@ pciReAttachDevice(pciDevice *dev,
{
const char *driver = pciFindStubDriver();
if (!driver) {
pciReportError(VIR_ERR_INTERNAL_ERROR, "%s",
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("cannot find any PCI stub module"));
return -1;
}
if (activeDevs && pciDeviceListFind(activeDevs, dev)) {
pciReportError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Not reattaching active device %s"), dev->name);
return -1;
}
@ -1356,7 +1352,7 @@ pciGetDevice(unsigned domain,
if (snprintf(dev->name, sizeof(dev->name), "%.4x:%.2x:%.2x.%.1x",
dev->domain, dev->bus, dev->slot,
dev->function) >= sizeof(dev->name)) {
pciReportError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("dev->name buffer overflow: %.4x:%.2x:%.2x.%.1x"),
dev->domain, dev->bus, dev->slot, dev->function);
goto error;
@ -1378,7 +1374,7 @@ pciGetDevice(unsigned domain,
product = pciReadDeviceID(dev, "device");
if (!vendor || !product) {
pciReportError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to read product/vendor ID for %s"),
dev->name);
goto error;
@ -1387,7 +1383,7 @@ pciGetDevice(unsigned domain,
/* strings contain '0x' prefix */
if (snprintf(dev->id, sizeof(dev->id), "%s %s", &vendor[2],
&product[2]) >= sizeof(dev->id)) {
pciReportError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("dev->id buffer overflow: %s %s"),
&vendor[2], &product[2]);
goto error;
@ -1525,7 +1521,7 @@ pciDeviceListAdd(pciDeviceList *list,
pciDevice *dev)
{
if (pciDeviceListFind(list, dev)) {
pciReportError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Device %s is already in use"), dev->name);
return -1;
}
@ -1713,7 +1709,7 @@ pciDeviceIsBehindSwitchLackingACS(pciDevice *dev)
if (dev->bus == 0)
return 0;
else {
pciReportError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to find parent device for %s"),
dev->name);
return -1;
@ -1768,7 +1764,7 @@ int pciDeviceIsAssignable(pciDevice *dev,
VIR_DEBUG("%s %s: strict ACS check disabled; device assignment allowed",
dev->id, dev->name);
} else {
pciReportError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Device %s is behind a switch lacking ACS and "
"cannot be assigned"),
dev->name);
@ -1865,7 +1861,7 @@ pciGetPciConfigAddressFromSysfsDeviceLink(const char *device_link,
device_path = canonicalize_file_name (device_link);
if (device_path == NULL) {
memset(errbuf, '\0', sizeof(errbuf));
pciReportError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to resolve device link '%s': '%s'"),
device_link, virStrerror(errno, errbuf,
sizeof(errbuf)));
@ -1879,7 +1875,7 @@ pciGetPciConfigAddressFromSysfsDeviceLink(const char *device_link,
}
if (pciParsePciConfigAddress(config_address, *bdf) != 0) {
pciReportError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to parse PCI config address '%s'"),
config_address);
VIR_FREE(*bdf);
@ -1946,7 +1942,7 @@ pciGetVirtualFunctions(const char *sysfs_path,
dir = opendir(sysfs_path);
if (dir == NULL) {
memset(errbuf, '\0', sizeof(errbuf));
pciReportError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to open dir '%s': '%s'"),
sysfs_path, virStrerror(errno, errbuf,
sizeof(errbuf)));
@ -1977,7 +1973,7 @@ pciGetVirtualFunctions(const char *sysfs_path,
SRIOV_FOUND) {
/* We should not get back SRIOV_NOT_FOUND in this
* case, so if we do, it's an error. */
pciReportError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to get SR IOV function from device "
"link '%s'"), device_link);
VIR_FREE(device_link);
@ -2039,7 +2035,7 @@ pciGetVirtualFunctionIndex(const char *pf_sysfs_device_link,
if (pciGetVirtualFunctions(pf_sysfs_device_link, &virt_fns,
&num_virt_fns) < 0) {
pciReportError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Error getting physical function's '%s' "
"virtual_functions"), pf_sysfs_device_link);
goto out;
@ -2176,7 +2172,7 @@ int
pciGetPhysicalFunction(const char *vf_sysfs_path ATTRIBUTE_UNUSED,
struct pci_config_address **physical_function ATTRIBUTE_UNUSED)
{
pciReportError(VIR_ERR_INTERNAL_ERROR, "%s", _(unsupported));
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _(unsupported));
return -1;
}
@ -2185,14 +2181,14 @@ pciGetVirtualFunctions(const char *sysfs_path ATTRIBUTE_UNUSED,
struct pci_config_address ***virtual_functions ATTRIBUTE_UNUSED,
unsigned int *num_virtual_functions ATTRIBUTE_UNUSED)
{
pciReportError(VIR_ERR_INTERNAL_ERROR, "%s", _(unsupported));
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _(unsupported));
return -1;
}
int
pciDeviceIsVirtualFunction(const char *vf_sysfs_device_link ATTRIBUTE_UNUSED)
{
pciReportError(VIR_ERR_INTERNAL_ERROR, "%s", _(unsupported));
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _(unsupported));
return -1;
}
@ -2201,7 +2197,7 @@ pciGetVirtualFunctionIndex(const char *pf_sysfs_device_link ATTRIBUTE_UNUSED,
const char *vf_sysfs_device_link ATTRIBUTE_UNUSED,
int *vf_index ATTRIBUTE_UNUSED)
{
pciReportError(VIR_ERR_INTERNAL_ERROR, "%s", _(unsupported));
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _(unsupported));
return -1;
}
@ -2210,7 +2206,7 @@ int
pciConfigAddressToSysfsFile(struct pci_config_address *dev ATTRIBUTE_UNUSED,
char **pci_sysfs_device_link ATTRIBUTE_UNUSED)
{
pciReportError(VIR_ERR_INTERNAL_ERROR, "%s", _(unsupported));
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _(unsupported));
return -1;
}
@ -2218,7 +2214,7 @@ int
pciDeviceNetName(char *device_link_sysfs_path ATTRIBUTE_UNUSED,
char **netname ATTRIBUTE_UNUSED)
{
pciReportError(VIR_ERR_INTERNAL_ERROR, "%s", _(unsupported));
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _(unsupported));
return -1;
}
@ -2227,7 +2223,7 @@ pciDeviceGetVirtualFunctionInfo(const char *vf_sysfs_device_path ATTRIBUTE_UNUSE
char **pfname ATTRIBUTE_UNUSED,
int *vf_index ATTRIBUTE_UNUSED)
{
pciReportError(VIR_ERR_INTERNAL_ERROR, "%s", _(unsupported));
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _(unsupported));
return -1;
}
#endif /* __linux__ */

View File

@ -24,9 +24,6 @@
#define VIR_FROM_THIS VIR_FROM_SEXPR
#define virSexprError(code, ...) \
virReportErrorHelper(VIR_FROM_SEXPR, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
/**
* sexpr_new:
@ -241,8 +238,8 @@ sexpr2string(const struct sexpr *sexpr, virBufferPtr buffer)
virBufferAddLit(buffer, "()");
break;
default:
virSexprError(VIR_ERR_SEXPR_SERIAL,
_("unknown s-expression kind %d"), sexpr->kind);
virReportError(VIR_ERR_SEXPR_SERIAL,
_("unknown s-expression kind %d"), sexpr->kind);
return -1;
}

View File

@ -29,10 +29,6 @@
# define VIR_FROM_THIS VIR_FROM_STATS_LINUX
# define virStatsError(code, ...) \
virReportErrorHelper(VIR_FROM_THIS, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
/*-------------------- interface stats --------------------*/
/* Just reads the named interface, so not Xen or QEMU-specific.
@ -106,8 +102,8 @@ linuxDomainInterfaceStats(const char *path,
}
VIR_FORCE_FCLOSE(fp);
virStatsError(VIR_ERR_INTERNAL_ERROR, "%s",
_("/proc/net/dev: Interface not found"));
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("/proc/net/dev: Interface not found"));
return -1;
}

View File

@ -39,10 +39,6 @@
#define VIR_FROM_THIS VIR_FROM_SYSINFO
#define virSmbiosReportError(code, ...) \
virReportErrorHelper(VIR_FROM_SYSINFO, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
#define SYSINFO_SMBIOS_DECODER "dmidecode"
#define SYSINFO "/proc/sysinfo"
#define CPUINFO "/proc/cpuinfo"
@ -222,8 +218,8 @@ virSysinfoRead(void) {
goto no_memory;
if(virFileReadAll(CPUINFO, 2048, &outbuf) < 0) {
virSmbiosReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to open %s"), CPUINFO);
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to open %s"), CPUINFO);
return NULL;
}
@ -366,8 +362,8 @@ virSysinfoRead(void) {
/* Gather info from /proc/cpuinfo */
if (virFileReadAll(CPUINFO, 2048, &outbuf) < 0) {
virSmbiosReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to open %s"), CPUINFO);
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to open %s"), CPUINFO);
return NULL;
}
@ -381,8 +377,8 @@ virSysinfoRead(void) {
/* Gather info from /proc/sysinfo */
if (virFileReadAll(SYSINFO, 4096, &outbuf) < 0) {
virSmbiosReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to open %s"), SYSINFO);
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to open %s"), SYSINFO);
return NULL;
}
@ -408,7 +404,7 @@ virSysinfoRead(void) {
* http://www.microsoft.com/whdc/system/platform/firmware/SMBIOS.mspx
*/
virReportSystemError(ENOSYS, "%s",
_("Host sysinfo extraction not supported on this platform"));
_("Host sysinfo extraction not supported on this platform"));
return NULL;
}
@ -762,9 +758,9 @@ virSysinfoRead(void) {
path = virFindFileInPath(SYSINFO_SMBIOS_DECODER);
if (path == NULL) {
virSmbiosReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to find path for %s binary"),
SYSINFO_SMBIOS_DECODER);
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to find path for %s binary"),
SYSINFO_SMBIOS_DECODER);
return NULL;
}
@ -772,9 +768,9 @@ virSysinfoRead(void) {
VIR_FREE(path);
virCommandSetOutputBuffer(cmd, &outbuf);
if (virCommandRun(cmd, NULL) < 0) {
virSmbiosReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to execute command %s"),
path);
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to execute command %s"),
path);
goto cleanup;
}
@ -976,9 +972,9 @@ virSysinfoFormat(virBufferPtr buf, virSysinfoDefPtr def)
const char *type = virSysinfoTypeToString(def->type);
if (!type) {
virSmbiosReportError(VIR_ERR_INTERNAL_ERROR,
_("unexpected sysinfo type model %d"),
def->type);
virReportError(VIR_ERR_INTERNAL_ERROR,
_("unexpected sysinfo type model %d"),
def->type);
virBufferFreeAndReset(buf);
return -1;
}
@ -1009,25 +1005,25 @@ bool virSysinfoIsEqual(virSysinfoDefPtr src,
return true;
if ((src && !dst) || (!src && dst)) {
virSmbiosReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("Target sysinfo does not match source"));
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("Target sysinfo does not match source"));
goto cleanup;
}
if (src->type != dst->type) {
virSmbiosReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("Target sysinfo %s does not match source %s"),
virSysinfoTypeToString(dst->type),
virSysinfoTypeToString(src->type));
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("Target sysinfo %s does not match source %s"),
virSysinfoTypeToString(dst->type),
virSysinfoTypeToString(src->type));
goto cleanup;
}
#define CHECK_FIELD(name, desc) \
do { \
if (STRNEQ_NULLABLE(src->name, dst->name)) { \
virSmbiosReportError(VIR_ERR_CONFIG_UNSUPPORTED, \
_("Target sysinfo %s %s does not match source %s"), \
desc, NULLSTR(src->name), NULLSTR(dst->name)); \
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, \
_("Target sysinfo %s %s does not match source %s"), \
desc, NULLSTR(src->name), NULLSTR(dst->name)); \
} \
} while (0)

View File

@ -96,10 +96,6 @@ verify(sizeof(gid_t) <= sizeof(unsigned int) &&
#define VIR_FROM_THIS VIR_FROM_NONE
#define virUtilError(code, ...) \
virReportErrorHelper(VIR_FROM_NONE, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
/* Like read(), but restarts after EINTR */
ssize_t
saferead(int fd, void *buf, size_t count)
@ -333,8 +329,8 @@ virPipeReadUntilEOF(int outfd, int errfd,
if (fds[i].revents & POLLHUP)
continue;
virUtilError(VIR_ERR_INTERNAL_ERROR,
"%s", _("Unknown poll response."));
virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("Unknown poll response."));
goto error;
}
@ -1235,8 +1231,8 @@ int virFileOpenAs(const char *path ATTRIBUTE_UNUSED,
gid_t gid ATTRIBUTE_UNUSED,
unsigned int flags_unused ATTRIBUTE_UNUSED)
{
virUtilError(VIR_ERR_INTERNAL_ERROR,
"%s", _("virFileOpenAs is not implemented for WIN32"));
virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("virFileOpenAs is not implemented for WIN32"));
return -ENOSYS;
}
@ -1247,8 +1243,8 @@ int virDirCreate(const char *path ATTRIBUTE_UNUSED,
gid_t gid ATTRIBUTE_UNUSED,
unsigned int flags_unused ATTRIBUTE_UNUSED)
{
virUtilError(VIR_ERR_INTERNAL_ERROR,
"%s", _("virDirCreate is not implemented for WIN32"));
virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("virDirCreate is not implemented for WIN32"));
return -ENOSYS;
}
@ -1749,8 +1745,8 @@ virScaleInteger(unsigned long long *value, const char *suffix,
{
if (!suffix || !*suffix) {
if (!scale) {
virUtilError(VIR_ERR_INTERNAL_ERROR,
_("invalid scale %llu"), scale);
virReportError(VIR_ERR_INTERNAL_ERROR,
_("invalid scale %llu"), scale);
return -1;
}
suffix = "";
@ -1765,7 +1761,7 @@ virScaleInteger(unsigned long long *value, const char *suffix,
} else if (c_tolower(suffix[1]) == 'b' && !suffix[2]) {
base = 1000;
} else {
virUtilError(VIR_ERR_INVALID_ARG,
virReportError(VIR_ERR_INVALID_ARG,
_("unknown suffix '%s'"), suffix);
return -1;
}
@ -1790,15 +1786,15 @@ virScaleInteger(unsigned long long *value, const char *suffix,
scale *= base;
break;
default:
virUtilError(VIR_ERR_INVALID_ARG,
_("unknown suffix '%s'"), suffix);
virReportError(VIR_ERR_INVALID_ARG,
_("unknown suffix '%s'"), suffix);
return -1;
}
}
if (*value && *value >= (limit / scale)) {
virUtilError(VIR_ERR_OVERFLOW, _("value too large: %llu%s"),
*value, suffix);
virReportError(VIR_ERR_OVERFLOW, _("value too large: %llu%s"),
*value, suffix);
return -1;
}
*value *= scale;
@ -2120,8 +2116,8 @@ char *virIndexToDiskName(int idx, const char *prefix)
int i, k, offset;
if (idx < 0) {
virUtilError(VIR_ERR_INTERNAL_ERROR,
_("Disk index %d is negative"), idx);
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Disk index %d is negative"), idx);
return NULL;
}
@ -2737,8 +2733,8 @@ virGetUserDirectory(void)
return NULL;
if (!ret) {
virUtilError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Unable to determine home directory"));
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Unable to determine home directory"));
return NULL;
}
@ -2753,8 +2749,8 @@ virGetUserConfigDirectory(void)
return NULL;
if (!ret) {
virUtilError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Unable to determine config directory"));
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Unable to determine config directory"));
return NULL;
}
return ret;
@ -2768,8 +2764,8 @@ virGetUserCacheDirectory(void)
return NULL;
if (!ret) {
virUtilError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Unable to determine config directory"));
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Unable to determine config directory"));
return NULL;
}
return ret;
@ -2784,8 +2780,8 @@ virGetUserRuntimeDirectory(void)
char *
virGetUserDirectory(void)
{
virUtilError(VIR_ERR_INTERNAL_ERROR,
"%s", _("virGetUserDirectory is not available"));
virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("virGetUserDirectory is not available"));
return NULL;
}
@ -2793,8 +2789,8 @@ virGetUserDirectory(void)
char *
virGetUserConfigDirectory(void)
{
virUtilError(VIR_ERR_INTERNAL_ERROR,
"%s", _("virGetUserConfigDirectory is not available"));
virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("virGetUserConfigDirectory is not available"));
return NULL;
}
@ -2802,8 +2798,8 @@ virGetUserConfigDirectory(void)
char *
virGetUserCacheDirectory(void)
{
virUtilError(VIR_ERR_INTERNAL_ERROR,
"%s", _("virGetUserCacheDirectory is not available"));
virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("virGetUserCacheDirectory is not available"));
return NULL;
}
@ -2811,8 +2807,8 @@ virGetUserCacheDirectory(void)
char *
virGetUserRuntimeDirectory(void)
{
virUtilError(VIR_ERR_INTERNAL_ERROR,
"%s", _("virGetUserRuntimeDirectory is not available"));
virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("virGetUserRuntimeDirectory is not available"));
return NULL;
}
@ -2821,8 +2817,8 @@ virGetUserRuntimeDirectory(void)
char *
virGetUserName(uid_t uid ATTRIBUTE_UNUSED)
{
virUtilError(VIR_ERR_INTERNAL_ERROR,
"%s", _("virGetUserName is not available"));
virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("virGetUserName is not available"));
return NULL;
}
@ -2830,8 +2826,8 @@ virGetUserName(uid_t uid ATTRIBUTE_UNUSED)
int virGetUserID(const char *name ATTRIBUTE_UNUSED,
uid_t *uid ATTRIBUTE_UNUSED)
{
virUtilError(VIR_ERR_INTERNAL_ERROR,
"%s", _("virGetUserID is not available"));
virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("virGetUserID is not available"));
return 0;
}
@ -2840,8 +2836,8 @@ int virGetUserID(const char *name ATTRIBUTE_UNUSED,
int virGetGroupID(const char *name ATTRIBUTE_UNUSED,
gid_t *gid ATTRIBUTE_UNUSED)
{
virUtilError(VIR_ERR_INTERNAL_ERROR,
"%s", _("virGetGroupID is not available"));
virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("virGetGroupID is not available"));
return 0;
}
@ -2850,16 +2846,16 @@ int
virSetUIDGID(uid_t uid ATTRIBUTE_UNUSED,
gid_t gid ATTRIBUTE_UNUSED)
{
virUtilError(VIR_ERR_INTERNAL_ERROR,
"%s", _("virSetUIDGID is not available"));
virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("virSetUIDGID is not available"));
return -1;
}
char *
virGetGroupName(gid_t gid ATTRIBUTE_UNUSED)
{
virUtilError(VIR_ERR_INTERNAL_ERROR,
"%s", _("virGetGroupName is not available"));
virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("virGetGroupName is not available"));
return NULL;
}

View File

@ -38,10 +38,6 @@ struct _virAuthConfig {
#define VIR_FROM_THIS VIR_FROM_NONE
#define virAuthReportError(code, ...) \
virReportErrorHelper(VIR_FROM_THIS, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
virAuthConfigPtr virAuthConfigNew(const char *path)
{
@ -141,9 +137,9 @@ int virAuthConfigLookup(virAuthConfigPtr auth,
}
if (!(authcred = virKeyFileGetValueString(auth->keyfile, authgroup, "credentials"))) {
virAuthReportError(VIR_ERR_CONF_SYNTAX,
_("Missing item 'credentials' in group '%s' in '%s'"),
authgroup, auth->path);
virReportError(VIR_ERR_CONF_SYNTAX,
_("Missing item 'credentials' in group '%s' in '%s'"),
authgroup, auth->path);
goto cleanup;
}
@ -153,9 +149,9 @@ int virAuthConfigLookup(virAuthConfigPtr auth,
}
if (!virKeyFileHasGroup(auth->keyfile, credgroup)) {
virAuthReportError(VIR_ERR_CONF_SYNTAX,
_("Missing group 'credentials-%s' referenced from group '%s' in '%s'"),
authcred, authgroup, auth->path);
virReportError(VIR_ERR_CONF_SYNTAX,
_("Missing group 'credentials-%s' referenced from group '%s' in '%s'"),
authcred, authgroup, auth->path);
goto cleanup;
}

View File

@ -29,10 +29,6 @@
#define VIR_FROM_THIS VIR_FROM_DBUS
#define virDBusReportError(code, ...) \
virReportErrorHelper(VIR_FROM_THIS, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
#ifdef HAVE_DBUS
static DBusConnection *systembus = NULL;
@ -70,15 +66,15 @@ static void virDBusSystemBusInit(void)
DBusConnection *virDBusGetSystemBus(void)
{
if (virOnce(&once, virDBusSystemBusInit) < 0) {
virDBusReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Unable to run one time DBus initializer"));
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Unable to run one time DBus initializer"));
return NULL;
}
if (!systembus) {
virDBusReportError(VIR_ERR_INTERNAL_ERROR,
_("Unable to get DBus system bus connection: %s"),
dbuserr.message ? dbuserr.message : "watch setup failed");
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Unable to get DBus system bus connection: %s"),
dbuserr.message ? dbuserr.message : "watch setup failed");
return NULL;
}
@ -193,8 +189,8 @@ static void virDBusToggleWatch(DBusWatch *watch,
#else /* ! HAVE_DBUS */
DBusConnection *virDBusGetSystemBus(void)
{
virDBusReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("DBus support not compiled into this binary"));
virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("DBus support not compiled into this binary"));
return NULL;
}

View File

@ -44,10 +44,6 @@
#include "logging.h"
#define VIR_FROM_THIS VIR_FROM_NONE
#define virFileError(code, ...) \
virReportErrorHelper(VIR_FROM_THIS, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
int virFileClose(int *fdptr, virFileCloseFlags flags)
{
@ -178,8 +174,8 @@ virFileWrapperFdNew(int *fd, const char *name, unsigned int flags)
int mode = -1;
if (!flags) {
virFileError(VIR_ERR_INTERNAL_ERROR, "%s",
_("invalid use with no flags"));
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("invalid use with no flags"));
return NULL;
}
@ -191,8 +187,8 @@ virFileWrapperFdNew(int *fd, const char *name, unsigned int flags)
*/
if ((flags & VIR_FILE_WRAPPER_BYPASS_CACHE) && !O_DIRECT) {
virFileError(VIR_ERR_INTERNAL_ERROR, "%s",
_("O_DIRECT unsupported on this platform"));
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("O_DIRECT unsupported on this platform"));
return NULL;
}
@ -204,20 +200,20 @@ virFileWrapperFdNew(int *fd, const char *name, unsigned int flags)
mode = fcntl(*fd, F_GETFL);
if (mode < 0) {
virFileError(VIR_ERR_INTERNAL_ERROR, _("invalid fd %d for %s"),
*fd, name);
virReportError(VIR_ERR_INTERNAL_ERROR, _("invalid fd %d for %s"),
*fd, name);
goto error;
} else if ((mode & O_ACCMODE) == O_WRONLY) {
output = true;
} else if ((mode & O_ACCMODE) != O_RDONLY) {
virFileError(VIR_ERR_INTERNAL_ERROR, _("unexpected mode %x for %s"),
mode & O_ACCMODE, name);
virReportError(VIR_ERR_INTERNAL_ERROR, _("unexpected mode %x for %s"),
mode & O_ACCMODE, name);
goto error;
}
if (pipe2(pipefd, O_CLOEXEC) < 0) {
virFileError(VIR_ERR_INTERNAL_ERROR,
_("unable to create pipe for %s"), name);
virReportError(VIR_ERR_INTERNAL_ERROR,
_("unable to create pipe for %s"), name);
goto error;
}
@ -237,7 +233,7 @@ virFileWrapperFdNew(int *fd, const char *name, unsigned int flags)
goto error;
if (VIR_CLOSE(pipefd[!output]) < 0) {
virFileError(VIR_ERR_INTERNAL_ERROR, "%s", _("unable to close pipe"));
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("unable to close pipe"));
goto error;
}
@ -257,7 +253,7 @@ virFileWrapperFdNew(int *fd ATTRIBUTE_UNUSED,
const char *name ATTRIBUTE_UNUSED,
unsigned int fdflags ATTRIBUTE_UNUSED)
{
virFileError(VIR_ERR_INTERNAL_ERROR, "%s",
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("virFileWrapperFd unsupported on this platform"));
return NULL;
}
@ -474,7 +470,7 @@ int virFileUpdatePerm(const char *path,
mode_t mode;
if (mode_remove & ~MODE_BITS || mode_add & ~MODE_BITS) {
virFileError(VIR_ERR_INVALID_ARG, "%s", _("invalid mode"));
virReportError(VIR_ERR_INVALID_ARG, "%s", _("invalid mode"));
return -1;
}
@ -551,8 +547,8 @@ static int virFileLoopDeviceOpen(char **dev_name)
VIR_FREE(looppath);
}
virFileError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Unable to find a free loop device in /dev"));
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Unable to find a free loop device in /dev"));
cleanup:
if (fd != -1) {

View File

@ -44,9 +44,6 @@
#endif
#define VIR_FROM_THIS VIR_FROM_NONE
#define virNetDevError(code, ...) \
virReportErrorHelper(VIR_FROM_THIS, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
#if defined(HAVE_STRUCT_IFREQ)
static int virNetDevSetupControlFull(const char *ifname,
@ -307,7 +304,7 @@ virNetDevRestoreMacAddress(const char *linkdev,
return -1;
if (virMacAddrParse(macstr, &oldmac) != 0) {
virNetDevError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Cannot parse MAC address from '%s'"),
oldmacname);
VIR_FREE(macstr);
@ -1322,12 +1319,12 @@ cleanup:
return rc;
malformed_resp:
virNetDevError(VIR_ERR_INTERNAL_ERROR, "%s",
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("malformed netlink response message"));
goto cleanup;
buffer_too_small:
virNetDevError(VIR_ERR_INTERNAL_ERROR, "%s",
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("allocated netlink buffer is too small"));
goto cleanup;
}
@ -1446,12 +1443,12 @@ cleanup:
return rc;
malformed_resp:
virNetDevError(VIR_ERR_INTERNAL_ERROR, "%s",
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("malformed netlink response message"));
goto cleanup;
buffer_too_small:
virNetDevError(VIR_ERR_INTERNAL_ERROR, "%s",
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("allocated netlink buffer is too small"));
goto cleanup;
}
@ -1505,7 +1502,7 @@ virNetDevParseVfConfig(struct nlattr **tb, int32_t vf, virMacAddrPtr mac,
cleanup:
if (msg)
virNetDevError(VIR_ERR_INTERNAL_ERROR, "%s", msg);
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", msg);
return rc;
}
@ -1587,7 +1584,7 @@ virNetDevRestoreVfConfig(const char *pflinkdev, int vf,
}
if (virMacAddrParse(macstr, &oldmac) != 0) {
virNetDevError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Cannot parse MAC address from '%s'"),
macstr);
goto cleanup;

View File

@ -34,11 +34,6 @@
#define VIR_FROM_THIS VIR_FROM_NET
#define virNetDevError(code, ...) \
virReportErrorHelper(VIR_FROM_NET, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
VIR_ENUM_IMPL(virNetDevMacVLanMode, VIR_NETDEV_MACVLAN_MODE_LAST,
"vepa",
"private",
@ -200,12 +195,12 @@ cleanup:
return rc;
malformed_resp:
virNetDevError(VIR_ERR_INTERNAL_ERROR, "%s",
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("malformed netlink response message"));
goto cleanup;
buffer_too_small:
virNetDevError(VIR_ERR_INTERNAL_ERROR, "%s",
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("allocated netlink buffer is too small"));
goto cleanup;
}
@ -279,12 +274,12 @@ cleanup:
return rc;
malformed_resp:
virNetDevError(VIR_ERR_INTERNAL_ERROR, "%s",
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("malformed netlink response message"));
goto cleanup;
buffer_too_small:
virNetDevError(VIR_ERR_INTERNAL_ERROR, "%s",
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("allocated netlink buffer is too small"));
goto cleanup;
}
@ -929,7 +924,7 @@ create_name:
}
if (virNetDevBandwidthSet(cr_ifname, bandwidth) < 0) {
virNetDevError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("cannot set bandwidth limits on %s"),
cr_ifname);
if (withTap)

View File

@ -45,10 +45,6 @@
#define VIR_FROM_THIS VIR_FROM_NONE
#define virNetDevTapError(code, ...) \
virReportErrorHelper(VIR_FROM_NONE, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
/**
* virNetDevProbeVnetHdr:
* @tapfd: a tun/tap file descriptor
@ -305,12 +301,12 @@ int virNetDevTapCreateInBridgePort(const char *brname,
* in "received packet on vnetX with own address as source
* address" error logs from the kernel.
*/
virNetDevTapError(VIR_ERR_CONFIG_UNSUPPORTED,
_("Unable to use MAC address starting with "
"reserved value 0xFE - '%02X:%02X:%02X:%02X:%02X:%02X' - "),
macaddr->addr[0], macaddr->addr[1],
macaddr->addr[2], macaddr->addr[3],
macaddr->addr[4], macaddr->addr[5]);
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("Unable to use MAC address starting with "
"reserved value 0xFE - '%02X:%02X:%02X:%02X:%02X:%02X' - "),
macaddr->addr[0], macaddr->addr[1],
macaddr->addr[2], macaddr->addr[3],
macaddr->addr[4], macaddr->addr[5]);
goto error;
}
tapmac.addr[0] = 0xFE; /* Discourage bridge from using TAP dev MAC */

View File

@ -33,10 +33,6 @@
#define VIR_FROM_THIS VIR_FROM_NONE
#define virNetDevvError(code, ...) \
virReportErrorHelper(VIR_FROM_NONE, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
/* Functions */
/**
* virNetDevVethGetFreeName:

View File

@ -27,11 +27,6 @@
#define VIR_FROM_THIS VIR_FROM_NET
#define virNetDevError(code, ...) \
virReportErrorHelper(VIR_FROM_NET, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
VIR_ENUM_IMPL(virNetDevVPortProfileOp, VIR_NETDEV_VPORT_PROFILE_OP_LAST,
"create",
"save",
@ -145,7 +140,7 @@ virNetDevVPortProfileGetLldpadPid(void) {
&& res != 0) {
pid = res;
} else {
virNetDevError(VIR_ERR_INTERNAL_ERROR, "%s",
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("error parsing pid of lldpad"));
}
}
@ -185,12 +180,12 @@ virNetDevVPortProfileGetStatus(struct nlattr **tb, int32_t vf,
if (tb[IFLA_PORT_SELF]) {
if (nla_parse_nested(tb_port, IFLA_PORT_MAX, tb[IFLA_PORT_SELF],
ifla_port_policy)) {
virNetDevError(VIR_ERR_INTERNAL_ERROR, "%s",
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("error parsing IFLA_PORT_SELF part"));
goto cleanup;
}
} else {
virNetDevError(VIR_ERR_INTERNAL_ERROR, "%s",
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("IFLA_PORT_SELF is missing"));
goto cleanup;
}
@ -203,7 +198,7 @@ virNetDevVPortProfileGetStatus(struct nlattr **tb, int32_t vf,
nla_for_each_nested(tb_vf_ports, tb[IFLA_VF_PORTS], rem) {
if (nla_type(tb_vf_ports) != IFLA_VF_PORT) {
virNetDevError(VIR_ERR_INTERNAL_ERROR, "%s",
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("error while iterating over "
"IFLA_VF_PORTS part"));
goto cleanup;
@ -211,7 +206,7 @@ virNetDevVPortProfileGetStatus(struct nlattr **tb, int32_t vf,
if (nla_parse_nested(tb_port, IFLA_PORT_MAX, tb_vf_ports,
ifla_port_policy)) {
virNetDevError(VIR_ERR_INTERNAL_ERROR, "%s",
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("error parsing IFLA_VF_PORT part"));
goto cleanup;
}
@ -230,13 +225,13 @@ virNetDevVPortProfileGetStatus(struct nlattr **tb, int32_t vf,
}
if (!found) {
virNetDevError(VIR_ERR_INTERNAL_ERROR, "%s",
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Could not find netlink response with "
"expected parameters"));
goto cleanup;
}
} else {
virNetDevError(VIR_ERR_INTERNAL_ERROR, "%s",
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("IFLA_VF_PORTS is missing"));
goto cleanup;
}
@ -251,7 +246,7 @@ virNetDevVPortProfileGetStatus(struct nlattr **tb, int32_t vf,
*status = PORT_PROFILE_RESPONSE_INPROGRESS;
rc = 0;
} else {
virNetDevError(VIR_ERR_INTERNAL_ERROR, "%s",
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("no IFLA_PORT_RESPONSE found in netlink message"));
goto cleanup;
}
@ -433,12 +428,12 @@ cleanup:
return rc;
malformed_resp:
virNetDevError(VIR_ERR_INTERNAL_ERROR, "%s",
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("malformed netlink response message"));
goto cleanup;
buffer_too_small:
virNetDevError(VIR_ERR_INTERNAL_ERROR, "%s",
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("allocated netlink buffer is too small"));
goto cleanup;
}
@ -486,7 +481,7 @@ virNetDevVPortProfileGetNthParent(const char *ifname, int ifindex, unsigned int
if (tb[IFLA_IFNAME]) {
if (!virStrcpy(parent_ifname, (char*)RTA_DATA(tb[IFLA_IFNAME]),
IFNAMSIZ)) {
virNetDevError(VIR_ERR_INTERNAL_ERROR, "%s",
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("buffer for root interface name is too small"));
VIR_FREE(recvbuf);
return -1;
@ -545,7 +540,7 @@ virNetDevVPortProfileOpCommon(const char *ifname, int ifindex,
vf,
op);
if (rc < 0) {
virNetDevError(VIR_ERR_INTERNAL_ERROR, "%s",
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("sending of PortProfileRequest failed."));
return rc;
}
@ -589,7 +584,7 @@ virNetDevVPortProfileOpCommon(const char *ifname, int ifindex,
}
if (status == PORT_PROFILE_RESPONSE_INPROGRESS) {
virNetDevError(VIR_ERR_INTERNAL_ERROR, "%s",
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("port-profile setlink timed out"));
rc = -2;
}
@ -678,7 +673,7 @@ virNetDevVPortProfileOp8021Qbg(const char *ifname,
op = PORT_REQUEST_DISASSOCIATE;
break;
default:
virNetDevError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("operation type %d not supported"), virtPortOp);
goto cleanup;
}
@ -794,7 +789,7 @@ virNetDevVPortProfileOp8021Qbh(const char *ifname,
break;
default:
virNetDevError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("operation type %d not supported"), virtPortOp);
rc = -1;
}

View File

@ -43,10 +43,6 @@
#define VIR_FROM_THIS VIR_FROM_NET
#define netlinkError(code, ...) \
virReportErrorHelper(VIR_FROM_NET, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
#define NETLINK_ACK_TIMEOUT_S 2
#if defined(__linux__) && defined(HAVE_LIBNL)
@ -389,8 +385,8 @@ virNetlinkEventServiceIsRunning(void)
int virNetlinkEventServiceLocalPid(void)
{
if (!(server && server->netlinknh)) {
netlinkError(VIR_ERR_INTERNAL_ERROR, "%s",
_("netlink event service not running"));
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("netlink event service not running"));
return -1;
}
return (int)nl_socket_get_local_port(server->netlinknh);
@ -462,8 +458,8 @@ virNetlinkEventServiceStart(void)
VIR_EVENT_HANDLE_READABLE,
virNetlinkEventCallback,
srv, NULL)) < 0) {
netlinkError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Failed to add netlink event handle watch"));
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Failed to add netlink event handle watch"));
goto error_server;
}
@ -512,8 +508,8 @@ virNetlinkEventAddClient(virNetlinkEventHandleCallback handleCB,
virNetlinkEventSrvPrivatePtr srv = server;
if (handleCB == NULL) {
netlinkError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Invalid NULL callback provided"));
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Invalid NULL callback provided"));
return -1;
}
@ -637,7 +633,7 @@ int virNetlinkCommand(struct nl_msg *nl_msg ATTRIBUTE_UNUSED,
uint32_t src_pid ATTRIBUTE_UNUSED,
uint32_t dst_pid ATTRIBUTE_UNUSED)
{
netlinkError(VIR_ERR_INTERNAL_ERROR, "%s", _(unsupported));
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _(unsupported));
return -1;
}
@ -667,13 +663,13 @@ int virNetlinkEventServiceStart(void)
*/
bool virNetlinkEventServiceIsRunning(void)
{
netlinkError(VIR_ERR_INTERNAL_ERROR, "%s", _(unsupported));
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _(unsupported));
return 0;
}
int virNetlinkEventServiceLocalPid(void)
{
netlinkError(VIR_ERR_INTERNAL_ERROR, "%s", _(unsupported));
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _(unsupported));
return -1;
}
@ -686,7 +682,7 @@ int virNetlinkEventAddClient(virNetlinkEventHandleCallback handleCB ATTRIBUTE_UN
void *opaque ATTRIBUTE_UNUSED,
const unsigned char *macaddr ATTRIBUTE_UNUSED)
{
netlinkError(VIR_ERR_INTERNAL_ERROR, "%s", _(unsupported));
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _(unsupported));
return -1;
}
@ -696,7 +692,7 @@ int virNetlinkEventAddClient(virNetlinkEventHandleCallback handleCB ATTRIBUTE_UN
int virNetlinkEventRemoveClient(int watch ATTRIBUTE_UNUSED,
const unsigned char *macaddr ATTRIBUTE_UNUSED)
{
netlinkError(VIR_ERR_INTERNAL_ERROR, "%s", _(unsupported));
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _(unsupported));
return -1;
}

View File

@ -32,11 +32,6 @@
#define VIR_FROM_THIS VIR_FROM_NONE
#define virNodeSuspendError(code, ...) \
virReportErrorHelper(VIR_FROM_NONE, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
#define SUSPEND_DELAY 10 /* in seconds */
/* Give sufficient time for performing the suspend operation on the host */
@ -96,7 +91,7 @@ static int virNodeSuspendSetNodeWakeup(unsigned long long alarmTime)
int ret = -1;
if (alarmTime <= MIN_TIME_REQ_FOR_SUSPEND) {
virNodeSuspendError(VIR_ERR_INVALID_ARG, "%s", _("Suspend duration is too short"));
virReportError(VIR_ERR_INVALID_ARG, "%s", _("Suspend duration is too short"));
return -1;
}
@ -198,8 +193,8 @@ int nodeSuspendForDuration(virConnectPtr conn ATTRIBUTE_UNUSED,
if (aboutToSuspend) {
/* A suspend operation is already in progress */
virNodeSuspendError(VIR_ERR_OPERATION_INVALID, "%s",
_("Suspend operation already in progress"));
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
_("Suspend operation already in progress"));
goto cleanup;
}
@ -207,7 +202,7 @@ int nodeSuspendForDuration(virConnectPtr conn ATTRIBUTE_UNUSED,
switch (target) {
case VIR_NODE_SUSPEND_TARGET_MEM:
if (!(supported & (1 << VIR_NODE_SUSPEND_TARGET_MEM))) {
virNodeSuspendError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", _("Suspend-to-RAM"));
virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", _("Suspend-to-RAM"));
goto cleanup;
}
cmdString = "pm-suspend";
@ -215,7 +210,7 @@ int nodeSuspendForDuration(virConnectPtr conn ATTRIBUTE_UNUSED,
case VIR_NODE_SUSPEND_TARGET_DISK:
if (!(supported & (1 << VIR_NODE_SUSPEND_TARGET_DISK))) {
virNodeSuspendError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", _("Suspend-to-Disk"));
virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", _("Suspend-to-Disk"));
goto cleanup;
}
cmdString = "pm-hibernate";
@ -223,14 +218,14 @@ int nodeSuspendForDuration(virConnectPtr conn ATTRIBUTE_UNUSED,
case VIR_NODE_SUSPEND_TARGET_HYBRID:
if (!(supported & (1 << VIR_NODE_SUSPEND_TARGET_HYBRID))) {
virNodeSuspendError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", _("Hybrid-Suspend"));
virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", _("Hybrid-Suspend"));
goto cleanup;
}
cmdString = "pm-suspend-hybrid";
break;
default:
virNodeSuspendError(VIR_ERR_INVALID_ARG, "%s", _("Invalid suspend target"));
virReportError(VIR_ERR_INVALID_ARG, "%s", _("Invalid suspend target"));
goto cleanup;
}
@ -239,8 +234,8 @@ int nodeSuspendForDuration(virConnectPtr conn ATTRIBUTE_UNUSED,
goto cleanup;
if (virThreadCreate(&thread, false, virNodeSuspend, (void *)cmdString) < 0) {
virNodeSuspendError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Failed to create thread to suspend the host"));
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Failed to create thread to suspend the host"));
goto cleanup;
}

View File

@ -32,10 +32,6 @@
#define VIR_FROM_THIS VIR_FROM_NONE
#define virRandomError(code, ...) \
virReportErrorHelper(VIR_FROM_NONE, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
static char randomState[128];
static struct random_data randomData;
static virMutex randomLock;
@ -100,7 +96,7 @@ virRandomGenerateWWN(char **wwn,
const char *oui = NULL;
if (!virt_type) {
virRandomError(VIR_ERR_INVALID_ARG, "%s",
virReportError(VIR_ERR_INVALID_ARG, "%s",
_("argument virt_type must not be NULL"));
return -1;
}
@ -117,7 +113,7 @@ virRandomGenerateWWN(char **wwn,
} else if (STREQ(virt_type, "HYPER-V")) {
oui = MICROSOFT_OUI;
} else {
virRandomError(VIR_ERR_INTERNAL_ERROR, "%s",
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Unsupported virt type"));
return -1;
}

View File

@ -30,9 +30,6 @@
#include <netdb.h>
#define VIR_FROM_THIS VIR_FROM_NONE
#define virSocketError(code, ...) \
virReportErrorHelper(VIR_FROM_THIS, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
/*
* Helpers to extract the IP arrays from the virSocketAddrPtr
@ -92,7 +89,7 @@ int virSocketAddrParse(virSocketAddrPtr addr, const char *val, int family) {
int err;
if (val == NULL) {
virSocketError(VIR_ERR_INVALID_ARG, "%s", _("Missing address"));
virReportError(VIR_ERR_INVALID_ARG, "%s", _("Missing address"));
return -1;
}
@ -100,14 +97,14 @@ int virSocketAddrParse(virSocketAddrPtr addr, const char *val, int family) {
hints.ai_family = family;
hints.ai_flags = AI_NUMERICHOST;
if ((err = getaddrinfo(val, NULL, &hints, &res)) != 0) {
virSocketError(VIR_ERR_SYSTEM_ERROR,
virReportError(VIR_ERR_SYSTEM_ERROR,
_("Cannot parse socket address '%s': %s"),
val, gai_strerror(err));
return -1;
}
if (res == NULL) {
virSocketError(VIR_ERR_SYSTEM_ERROR,
virReportError(VIR_ERR_SYSTEM_ERROR,
_("No socket addresses found for '%s'"),
val);
return -1;
@ -230,7 +227,7 @@ virSocketAddrFormatFull(virSocketAddrPtr addr,
int err;
if (addr == NULL) {
virSocketError(VIR_ERR_INVALID_ARG, "%s", _("Missing address"));
virReportError(VIR_ERR_INVALID_ARG, "%s", _("Missing address"));
return NULL;
}
@ -253,7 +250,7 @@ virSocketAddrFormatFull(virSocketAddrPtr addr,
host, sizeof(host),
port, sizeof(port),
NI_NUMERICHOST | NI_NUMERICSERV)) != 0) {
virSocketError(VIR_ERR_SYSTEM_ERROR,
virReportError(VIR_ERR_SYSTEM_ERROR,
_("Cannot convert socket address to string: %s"),
gai_strerror(err));
return NULL;

View File

@ -30,10 +30,6 @@
#define VIR_FROM_THIS VIR_FROM_NONE
#define virUtilError(code, ...) \
virReportErrorHelper(VIR_FROM_NONE, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
VIR_ENUM_DECL(virTypedParameter)
VIR_ENUM_IMPL(virTypedParameter, VIR_TYPED_PARAM_LAST,
"unknown",
@ -93,27 +89,27 @@ virTypedParameterArrayValidate(virTypedParameterPtr params, int nparams, ...)
badtype = virTypedParameterTypeToString(params[i].type);
if (!badtype)
badtype = virTypedParameterTypeToString(0);
virUtilError(VIR_ERR_INVALID_ARG,
_("invalid type '%s' for parameter '%s', "
"expected '%s'"),
badtype, params[i].field,
virTypedParameterTypeToString(type));
virReportError(VIR_ERR_INVALID_ARG,
_("invalid type '%s' for parameter '%s', "
"expected '%s'"),
badtype, params[i].field,
virTypedParameterTypeToString(type));
}
break;
}
name = va_arg(ap, const char *);
}
if (!name) {
virUtilError(VIR_ERR_INVALID_ARG,
_("parameter '%s' not supported"),
params[i].field);
virReportError(VIR_ERR_INVALID_ARG,
_("parameter '%s' not supported"),
params[i].field);
goto cleanup;
}
for (j = 0; j < i; j++) {
if (STREQ(params[i].field, params[j].field)) {
virUtilError(VIR_ERR_INVALID_ARG,
_("parameter '%s' occurs multiple times"),
params[i].field);
virReportError(VIR_ERR_INVALID_ARG,
_("parameter '%s' occurs multiple times"),
params[i].field);
goto cleanup;
}
}
@ -140,8 +136,8 @@ virTypedParameterAssign(virTypedParameterPtr param, const char *name,
va_start(ap, type);
if (virStrcpyStatic(param->field, name) == NULL) {
virUtilError(VIR_ERR_INTERNAL_ERROR, _("Field name '%s' too long"),
name);
virReportError(VIR_ERR_INTERNAL_ERROR, _("Field name '%s' too long"),
name);
goto cleanup;
}
param->type = type;
@ -175,8 +171,8 @@ virTypedParameterAssign(virTypedParameterPtr param, const char *name,
}
break;
default:
virUtilError(VIR_ERR_INTERNAL_ERROR,
_("unexpected type %d for field %s"), type, name);
virReportError(VIR_ERR_INTERNAL_ERROR,
_("unexpected type %d for field %s"), type, name);
goto cleanup;
}

View File

@ -17,11 +17,6 @@
#define VIR_FROM_THIS VIR_FROM_URI
#define virURIReportError(code, ...) \
virReportErrorHelper(VIR_FROM_THIS, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
static int
virURIParamAppend(virURIPtr uri,
const char *name,
@ -155,8 +150,8 @@ virURIParse(const char *uri)
if (!xmluri) {
/* libxml2 does not tell us what failed. Grr :-( */
virURIReportError(VIR_ERR_INTERNAL_ERROR,
_("Unable to parse URI %s"), uri);
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Unable to parse URI %s"), uri);
return NULL;
}

View File

@ -31,10 +31,6 @@
virReportErrorHelper(from, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
#define virXMLError(code, ...) \
virGenericReportError(VIR_FROM_XML, code, __VA_ARGS__)
/* Internal data to be passed to SAX parser and used by error handler. */
struct virParserData {
int domcode;
@ -66,8 +62,8 @@ virXPathString(const char *xpath,
char *ret;
if ((ctxt == NULL) || (xpath == NULL)) {
virXMLError(VIR_ERR_INTERNAL_ERROR,
"%s", _("Invalid parameter to virXPathString()"));
virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("Invalid parameter to virXPathString()"));
return NULL;
}
relnode = ctxt->node;
@ -106,9 +102,9 @@ virXPathStringLimit(const char *xpath,
char *tmp = virXPathString(xpath, ctxt);
if (tmp != NULL && strlen(tmp) >= maxlen) {
virXMLError(VIR_ERR_INTERNAL_ERROR,
_("\'%s\' value longer than %zu bytes"),
xpath, maxlen);
virReportError(VIR_ERR_INTERNAL_ERROR,
_("\'%s\' value longer than %zu bytes"),
xpath, maxlen);
VIR_FREE(tmp);
return NULL;
}
@ -136,8 +132,8 @@ virXPathNumber(const char *xpath,
xmlNodePtr relnode;
if ((ctxt == NULL) || (xpath == NULL) || (value == NULL)) {
virXMLError(VIR_ERR_INTERNAL_ERROR,
"%s", _("Invalid parameter to virXPathNumber()"));
virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("Invalid parameter to virXPathNumber()"));
return -1;
}
relnode = ctxt->node;
@ -165,8 +161,8 @@ virXPathLongBase(const char *xpath,
int ret = 0;
if ((ctxt == NULL) || (xpath == NULL) || (value == NULL)) {
virXMLError(VIR_ERR_INTERNAL_ERROR,
"%s", _("Invalid parameter to virXPathLong()"));
virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("Invalid parameter to virXPathLong()"));
return -1;
}
relnode = ctxt->node;
@ -271,8 +267,8 @@ virXPathULongBase(const char *xpath,
int ret = 0;
if ((ctxt == NULL) || (xpath == NULL) || (value == NULL)) {
virXMLError(VIR_ERR_INTERNAL_ERROR,
"%s", _("Invalid parameter to virXPathULong()"));
virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("Invalid parameter to virXPathULong()"));
return -1;
}
relnode = ctxt->node;
@ -388,8 +384,8 @@ virXPathULongLong(const char *xpath,
int ret = 0;
if ((ctxt == NULL) || (xpath == NULL) || (value == NULL)) {
virXMLError(VIR_ERR_INTERNAL_ERROR,
"%s", _("Invalid parameter to virXPathULong()"));
virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("Invalid parameter to virXPathULong()"));
return -1;
}
relnode = ctxt->node;
@ -435,8 +431,8 @@ virXPathLongLong(const char *xpath,
int ret = 0;
if ((ctxt == NULL) || (xpath == NULL) || (value == NULL)) {
virXMLError(VIR_ERR_INTERNAL_ERROR,
"%s", _("Invalid parameter to virXPathLongLong()"));
virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("Invalid parameter to virXPathLongLong()"));
return -1;
}
relnode = ctxt->node;
@ -485,8 +481,8 @@ virXPathBoolean(const char *xpath,
int ret;
if ((ctxt == NULL) || (xpath == NULL)) {
virXMLError(VIR_ERR_INTERNAL_ERROR,
"%s", _("Invalid parameter to virXPathBoolean()"));
virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("Invalid parameter to virXPathBoolean()"));
return -1;
}
relnode = ctxt->node;
@ -522,8 +518,8 @@ virXPathNode(const char *xpath,
xmlNodePtr ret;
if ((ctxt == NULL) || (xpath == NULL)) {
virXMLError(VIR_ERR_INTERNAL_ERROR,
"%s", _("Invalid parameter to virXPathNode()"));
virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("Invalid parameter to virXPathNode()"));
return NULL;
}
relnode = ctxt->node;
@ -562,8 +558,8 @@ virXPathNodeSet(const char *xpath,
int ret;
if ((ctxt == NULL) || (xpath == NULL)) {
virXMLError(VIR_ERR_INTERNAL_ERROR,
"%s", _("Invalid parameter to virXPathNodeSet()"));
virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("Invalid parameter to virXPathNodeSet()"));
return -1;
}
@ -577,8 +573,8 @@ virXPathNodeSet(const char *xpath,
return 0;
if (obj->type != XPATH_NODESET) {
virXMLError(VIR_ERR_INTERNAL_ERROR,
_("Incorrect xpath '%s'"), xpath);
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Incorrect xpath '%s'"), xpath);
xmlXPathFreeObject(obj);
return -1;
}