[libvirt] [PATCH 00/13] Remove many custom error reporting macros

This series is all about replacing custom error reporting macros with a common virReportError macro cfg.mk | 29 po/POTFILES.in | 1 src/conf/cpu_conf.c | 224 +- src/conf/domain_conf.c | 2347 +++++++++++++++--------------- src/conf/domain_event.c | 32 src/conf/interface_conf.c | 144 - src/conf/netdev_bandwidth_conf.c | 20 src/conf/netdev_vport_profile_conf.c | 39 src/conf/network_conf.c | 272 +-- src/conf/node_device_conf.c | 142 - src/conf/node_device_conf.h | 3 src/conf/nwfilter_conf.c | 138 - src/conf/nwfilter_conf.h | 4 src/conf/nwfilter_params.c | 78 src/conf/secret_conf.c | 58 src/conf/secret_conf.h | 4 src/conf/storage_conf.c | 202 +- src/conf/storage_conf.h | 4 src/conf/storage_encryption_conf.c | 52 src/conf/virconsole.c | 11 src/interface/netcf_driver.c | 150 - src/network/bridge_driver.c | 344 ++-- src/node_device/node_device_driver.c | 42 src/node_device/node_device_udev.c | 6 src/nwfilter/nwfilter_dhcpsnoop.c | 149 - src/nwfilter/nwfilter_driver.c | 3 src/nwfilter/nwfilter_ebiptables_driver.c | 129 - src/nwfilter/nwfilter_gentech_driver.c | 3 src/nwfilter/nwfilter_learnipaddr.c | 40 src/rpc/virkeepalive.c | 7 src/rpc/virnetclient.c | 51 src/rpc/virnetclientprogram.c | 23 src/rpc/virnetclientstream.c | 19 src/rpc/virnetmessage.c | 49 src/rpc/virnetsaslcontext.c | 130 - src/rpc/virnetserver.c | 15 src/rpc/virnetserverclient.c | 11 src/rpc/virnetservermdns.c | 17 src/rpc/virnetserverprogram.c | 41 src/rpc/virnetsocket.c | 28 src/rpc/virnettlscontext.c | 265 +-- src/secret/secret_driver.c | 66 src/storage/storage_backend.c | 133 - src/storage/storage_backend_disk.c | 66 src/storage/storage_backend_fs.c | 162 +- src/storage/storage_backend_iscsi.c | 94 - src/storage/storage_backend_logical.c | 40 src/storage/storage_backend_mpath.c | 6 src/storage/storage_backend_rbd.c | 132 - src/storage/storage_backend_scsi.c | 24 src/storage/storage_driver.c | 386 ++-- src/test/test_driver.c | 32 src/util/command.c | 108 - src/util/event_poll.c | 10 src/util/hooks.c | 32 src/util/hostusb.c | 20 src/util/iptables.c | 17 src/util/json.c | 25 src/util/pci.c | 64 src/util/sexpr.c | 7 src/util/stats_linux.c | 8 src/util/sysinfo.c | 54 src/util/util.c | 82 - src/util/virauthconfig.c | 16 src/util/virdbus.c | 18 src/util/virfile.c | 34 src/util/virnetdev.c | 17 src/util/virnetdevmacvlan.c | 15 src/util/virnetdevtap.c | 16 src/util/virnetdevveth.c | 4 src/util/virnetdevvportprofile.c | 35 src/util/virnetlink.c | 26 src/util/virnodesuspend.c | 23 src/util/virrandom.c | 8 src/util/virsocketaddr.c | 13 src/util/virterror_internal.h | 3 src/util/virtypedparam.c | 34 src/util/viruri.c | 9 src/util/xml.c | 50 79 files changed, 3510 insertions(+), 3705 deletions(-)

From: "Daniel P. Berrange" <berrange@redhat.com> Nearly every source file does something like #define VIR_FROM_THIS VIR_FROM_FOO #define virFooReportErorr(code, ...) \ virReportErrorHelper(VIR_FROM_THIS, code, __FILE__, \ __FUNCTION__, __LINE__, \ __VA_ARGS__) This creates needless duplication and inconsistent error reporting function names in each file. It is trivial to just have virterror_internal.h provide a virReportError macro that is equivalent * src/util/virterror_internal.h: Define virReportError(code, ...) Signed-off-by: Daniel P. Berrange <berrange@redhat.com> --- cfg.mk | 1 + src/util/virterror_internal.h | 3 +++ 2 files changed, 4 insertions(+) diff --git a/cfg.mk b/cfg.mk index 6dfe799..69b2a28 100644 --- a/cfg.mk +++ b/cfg.mk @@ -560,6 +560,7 @@ msg_gen_function += virNetworkReportError msg_gen_function += virNodeDeviceReportError msg_gen_function += virNWFilterReportError msg_gen_function += virRaiseError +msg_gen_function += virReportError msg_gen_function += virReportErrorHelper msg_gen_function += virReportSystemError msg_gen_function += virSecretReportError diff --git a/src/util/virterror_internal.h b/src/util/virterror_internal.h index cb7df03..06417b5 100644 --- a/src/util/virterror_internal.h +++ b/src/util/virterror_internal.h @@ -153,6 +153,9 @@ void virReportOOMErrorFull(int domcode, # define virReportOOMError() \ virReportOOMErrorFull(VIR_FROM_THIS, __FILE__, __FUNCTION__, __LINE__) +# define virReportError(code, ...) \ + virReportErrorHelper(VIR_FROM_THIS, code, __FILE__, \ + __FUNCTION__, __LINE__, __VA_ARGS__) int virSetError(virErrorPtr newerr); void virDispatchError(virConnectPtr conn); -- 1.7.10.4

On 07/18/2012 05:52 AM, Daniel P. Berrange wrote:
From: "Daniel P. Berrange" <berrange@redhat.com>
Nearly every source file does something like
#define VIR_FROM_THIS VIR_FROM_FOO #define virFooReportErorr(code, ...) \ virReportErrorHelper(VIR_FROM_THIS, code, __FILE__, \ __FUNCTION__, __LINE__, \ __VA_ARGS__)
This creates needless duplication and inconsistent error reporting function names in each file. It is trivial to just have virterror_internal.h provide a virReportError macro that is equivalent
* src/util/virterror_internal.h: Define virReportError(code, ...)
Signed-off-by: Daniel P. Berrange <berrange@redhat.com> --- cfg.mk | 1 + src/util/virterror_internal.h | 3 +++ 2 files changed, 4 insertions(+)
ACK. The real trick will be using it in all the followup patches :) -- Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

From: "Daniel P. Berrange" <berrange@redhat.com> The virnetdevtap.c and viruri.c files had two error report messages which were not annotated with _(...) Signed-off-by: Daniel P. Berrange <berrange@redhat.com> --- src/util/virnetdevtap.c | 4 ++-- src/util/viruri.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/util/virnetdevtap.c b/src/util/virnetdevtap.c index e46dd36..7562840 100644 --- a/src/util/virnetdevtap.c +++ b/src/util/virnetdevtap.c @@ -306,8 +306,8 @@ int virNetDevTapCreateInBridgePort(const char *brname, * 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' - ", + _("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]); diff --git a/src/util/viruri.c b/src/util/viruri.c index a41f345..8a25f3a 100644 --- a/src/util/viruri.c +++ b/src/util/viruri.c @@ -156,7 +156,7 @@ 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); + _("Unable to parse URI %s"), uri); return NULL; } -- 1.7.10.4

On 07/18/2012 05:52 AM, Daniel P. Berrange wrote:
From: "Daniel P. Berrange" <berrange@redhat.com>
The virnetdevtap.c and viruri.c files had two error report messages which were not annotated with _(...)
Signed-off-by: Daniel P. Berrange <berrange@redhat.com> --- src/util/virnetdevtap.c | 4 ++-- src/util/viruri.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
ACK. Practically falls under the trivial rule. -- Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

From: "Daniel P. Berrange" <berrange@redhat.com> Signed-off-by: Daniel P. Berrange <berrange@redhat.com> --- po/POTFILES.in | 1 + 1 file changed, 1 insertion(+) diff --git a/po/POTFILES.in b/po/POTFILES.in index 31246f7..6ca40d9 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -151,6 +151,7 @@ src/util/virterror.c src/util/virterror_internal.h src/util/virtime.c src/util/virtypedparam.c +src/util/viruri.c src/util/xml.c src/vbox/vbox_MSCOMGlue.c src/vbox/vbox_XPCOMCGlue.c -- 1.7.10.4

On 07/18/2012 05:52 AM, Daniel P. Berrange wrote:
From: "Daniel P. Berrange" <berrange@redhat.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com> --- po/POTFILES.in | 1 + 1 file changed, 1 insertion(+)
diff --git a/po/POTFILES.in b/po/POTFILES.in index 31246f7..6ca40d9 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -151,6 +151,7 @@ src/util/virterror.c src/util/virterror_internal.h src/util/virtime.c src/util/virtypedparam.c +src/util/viruri.c
This needs to be squashed into 2/13. ACK. -- Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

From: "Daniel P. Berrange" <berrange@redhat.com> Signed-off-by: Daniel P. Berrange <berrange@redhat.com> --- src/util/virnodesuspend.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/virnodesuspend.c b/src/util/virnodesuspend.c index 7e37118..c6becce 100644 --- a/src/util/virnodesuspend.c +++ b/src/util/virnodesuspend.c @@ -240,7 +240,7 @@ int nodeSuspendForDuration(virConnectPtr conn ATTRIBUTE_UNUSED, if (virThreadCreate(&thread, false, virNodeSuspend, (void *)cmdString) < 0) { virNodeSuspendError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Failed to create thread to suspend the host\n")); + _("Failed to create thread to suspend the host")); goto cleanup; } -- 1.7.10.4

On 07/18/2012 05:52 AM, Daniel P. Berrange wrote:
From: "Daniel P. Berrange" <berrange@redhat.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com> --- src/util/virnodesuspend.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/util/virnodesuspend.c b/src/util/virnodesuspend.c index 7e37118..c6becce 100644 --- a/src/util/virnodesuspend.c +++ b/src/util/virnodesuspend.c @@ -240,7 +240,7 @@ int nodeSuspendForDuration(virConnectPtr conn ATTRIBUTE_UNUSED,
if (virThreadCreate(&thread, false, virNodeSuspend, (void *)cmdString) < 0) { virNodeSuspendError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Failed to create thread to suspend the host\n")); + _("Failed to create thread to suspend the host"));
ACK; another trivial rule patch. -- Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

From: "Daniel P. Berrange" <berrange@redhat.com> 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 parametes Signed-off-by: Daniel P. Berrange <berrange@redhat.com> --- cfg.mk | 18 ------- src/util/command.c | 108 ++++++++++++++++++-------------------- src/util/event_poll.c | 10 ++-- src/util/hooks.c | 32 +++++------ src/util/hostusb.c | 20 +++---- src/util/iptables.c | 17 +++--- src/util/json.c | 25 ++++----- src/util/pci.c | 64 +++++++++++----------- src/util/sexpr.c | 7 +-- src/util/stats_linux.c | 8 +-- src/util/sysinfo.c | 54 +++++++++---------- src/util/util.c | 82 ++++++++++++++--------------- src/util/virauthconfig.c | 16 +++--- src/util/virdbus.c | 18 +++---- src/util/virfile.c | 34 ++++++------ src/util/virnetdev.c | 17 +++--- src/util/virnetdevmacvlan.c | 15 ++---- src/util/virnetdevtap.c | 16 +++--- src/util/virnetdevveth.c | 4 -- src/util/virnetdevvportprofile.c | 35 ++++++------ src/util/virnetlink.c | 26 ++++----- src/util/virnodesuspend.c | 23 ++++---- src/util/virrandom.c | 8 +-- src/util/virsocketaddr.c | 13 ++--- src/util/virtypedparam.c | 34 ++++++------ src/util/viruri.c | 9 +--- src/util/xml.c | 50 ++++++++---------- 27 files changed, 321 insertions(+), 442 deletions(-) diff --git a/cfg.mk b/cfg.mk index 69b2a28..3ae4c5a 100644 --- a/cfg.mk +++ b/cfg.mk @@ -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 diff --git a/src/util/command.c b/src/util/command.c index 5838d45..68ee98d 100644 --- a/src/util/command.c +++ b/src/util/command.c @@ -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,7 +657,7 @@ virExecWithHook(const char *const*argv, if (binary != argv[0]) VIR_FREE(binary); - /* NB we don't virCommandError() on any failures here + /* NB we don't virReportError() on any failures here because the code which jumped hre already raised an error condition which we must not overwrite */ VIR_FORCE_CLOSE(pipeerr[0]); @@ -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; } diff --git a/src/util/event_poll.c b/src/util/event_poll.c index 3841673..273200d 100644 --- a/src/util/event_poll.c +++ b/src/util/event_poll.c @@ -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; diff --git a/src/util/hooks.c b/src/util/hooks.c index e0d6bf0..1e462a9 100644 --- a/src/util/hooks.c +++ b/src/util/hooks.c @@ -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; } diff --git a/src/util/hostusb.c b/src/util/hostusb.c index 63b10ef..755135d 100644 --- a/src/util/hostusb.c +++ b/src/util/hostusb.c @@ -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; diff --git a/src/util/iptables.c b/src/util/iptables.c index 3023900..f63ae25 100644 --- a/src/util/iptables.c +++ b/src/util/iptables.c @@ -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; } diff --git a/src/util/json.c b/src/util/json.c index e7dc272..ae3686f 100644 --- a/src/util/json.c +++ b/src/util/json.c @@ -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 diff --git a/src/util/pci.c b/src/util/pci.c index b3be405..062005d 100644 --- a/src/util/pci.c +++ b/src/util/pci.c @@ -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__ */ diff --git a/src/util/sexpr.c b/src/util/sexpr.c index 9e7df1d..f72b7d7 100644 --- a/src/util/sexpr.c +++ b/src/util/sexpr.c @@ -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; } diff --git a/src/util/stats_linux.c b/src/util/stats_linux.c index 725a2d0..8601fa0 100644 --- a/src/util/stats_linux.c +++ b/src/util/stats_linux.c @@ -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, - _("/proc/net/dev: Interface not found")); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("/proc/net/dev: Interface not found")); return -1; } diff --git a/src/util/sysinfo.c b/src/util/sysinfo.c index 20482db..ca4e56e 100644 --- a/src/util/sysinfo.c +++ b/src/util/sysinfo.c @@ -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) diff --git a/src/util/util.c b/src/util/util.c index 07dc704..d1ba0d0 100644 --- a/src/util/util.c +++ b/src/util/util.c @@ -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; } diff --git a/src/util/virauthconfig.c b/src/util/virauthconfig.c index ad98959..20a5571 100644 --- a/src/util/virauthconfig.c +++ b/src/util/virauthconfig.c @@ -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; } diff --git a/src/util/virdbus.c b/src/util/virdbus.c index badfe8c..0402027 100644 --- a/src/util/virdbus.c +++ b/src/util/virdbus.c @@ -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; } diff --git a/src/util/virfile.c b/src/util/virfile.c index 0f88cef..4294da7 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -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) { diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c index 3ae9bfb..cd44bf4 100644 --- a/src/util/virnetdev.c +++ b/src/util/virnetdev.c @@ -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; diff --git a/src/util/virnetdevmacvlan.c b/src/util/virnetdevmacvlan.c index b047750..559fac5 100644 --- a/src/util/virnetdevmacvlan.c +++ b/src/util/virnetdevmacvlan.c @@ -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) diff --git a/src/util/virnetdevtap.c b/src/util/virnetdevtap.c index 7562840..e6b1ae5 100644 --- a/src/util/virnetdevtap.c +++ b/src/util/virnetdevtap.c @@ -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 */ diff --git a/src/util/virnetdevveth.c b/src/util/virnetdevveth.c index c77e558..b996cfe 100644 --- a/src/util/virnetdevveth.c +++ b/src/util/virnetdevveth.c @@ -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: diff --git a/src/util/virnetdevvportprofile.c b/src/util/virnetdevvportprofile.c index 34ec0b6..089ec8a 100644 --- a/src/util/virnetdevvportprofile.c +++ b/src/util/virnetdevvportprofile.c @@ -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; } diff --git a/src/util/virnetlink.c b/src/util/virnetlink.c index 19c9ad0..222e2fa 100644 --- a/src/util/virnetlink.c +++ b/src/util/virnetlink.c @@ -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; } diff --git a/src/util/virnodesuspend.c b/src/util/virnodesuspend.c index c6becce..2978b1c 100644 --- a/src/util/virnodesuspend.c +++ b/src/util/virnodesuspend.c @@ -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; } diff --git a/src/util/virrandom.c b/src/util/virrandom.c index 9092fd2..88413ab 100644 --- a/src/util/virrandom.c +++ b/src/util/virrandom.c @@ -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; } diff --git a/src/util/virsocketaddr.c b/src/util/virsocketaddr.c index 3466406..603d2ec 100644 --- a/src/util/virsocketaddr.c +++ b/src/util/virsocketaddr.c @@ -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; diff --git a/src/util/virtypedparam.c b/src/util/virtypedparam.c index 48ee5d5..d1a1eea 100644 --- a/src/util/virtypedparam.c +++ b/src/util/virtypedparam.c @@ -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; } diff --git a/src/util/viruri.c b/src/util/viruri.c index 8a25f3a..791a412 100644 --- a/src/util/viruri.c +++ b/src/util/viruri.c @@ -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; } diff --git a/src/util/xml.c b/src/util/xml.c index 7411968..4c88a06 100644 --- a/src/util/xml.c +++ b/src/util/xml.c @@ -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; } -- 1.7.10.4

On 07/18/2012 05:52 AM, Daniel P. Berrange wrote:
From: "Daniel P. Berrange" <berrange@redhat.com>
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 parametes
s/parametes/parameters/ I'm only doing a "positive review" (did the changes you make look right?), and skipping the "completeness review" (did you miss an opportunity for even more changes that should be made at the same time?). That means I'm probably not spotting the custom macros that you didn't convert, but that shouldn't stop you from applying this.
@@ -661,7 +657,7 @@ virExecWithHook(const char *const*argv, if (binary != argv[0]) VIR_FREE(binary);
- /* NB we don't virCommandError() on any failures here + /* NB we don't virReportError() on any failures here because the code which jumped hre already raised
As long as you are touching this, s/hre/here/
+++ b/src/util/hooks.c
@@ -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"),
Generic question - now that we are touching 90% of the existing error messages, should we establish a convention on whether all messages should start with a lower case letter? (That would at least make us consistent with GNU Coding Standards, and while we are not a GNU project, cross-project consistency does have an advantage. Personally, I've noticed our inconsistent use of capitals for more than 2 years now, but it hasn't been high enough on my "itch radar" to scratch it.) Obviously, a syntax check would be needed IF we make a decision to standardize.
+++ b/src/util/json.c @@ -43,9 +43,6 @@
/* XXX fixme */ #define VIR_FROM_THIS VIR_FROM_NONE -#define virJSONError(code, ...) \
I think the 'fixme' comment is no longer relevant, and should be nuked.
+++ b/src/util/pci.c @@ -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);
Code like this means we will probably see a second round of patches in the future for scrubbing stupid uses of VIR_ERR_INTERNAL_ERROR into better messages for user-visible errors :)
+++ b/src/util/stats_linux.c @@ -106,8 +102,8 @@ linuxDomainInterfaceStats(const char *path, } VIR_FORCE_FCLOSE(fp);
- virStatsError(VIR_ERR_INTERNAL_ERROR, - _("/proc/net/dev: Interface not found")); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("/proc/net/dev: Interface not found"));
Needs a "%s" argument to silence compiler warnings when i18n is disabled.
+++ b/src/util/util.c @@ -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."));
Is it worth scrubbing for error messages that end with '.'? That's another thing that GNU Coding Standards discourage. ACK. Either squash in the nits I pointed out, or we can do that as a separate patch to keep this one mechanical. As for consensus on whether to standardize error message conventions, does anyone else have an opinion? -- Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

On Wed, Jul 18, 2012 at 07:54:11AM -0600, Eric Blake wrote:
+++ b/src/util/hooks.c
@@ -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"),
Generic question - now that we are touching 90% of the existing error messages, should we establish a convention on whether all messages should start with a lower case letter? (That would at least make us consistent with GNU Coding Standards, and while we are not a GNU project, cross-project consistency does have an advantage. Personally, I've noticed our inconsistent use of capitals for more than 2 years now, but it hasn't been high enough on my "itch radar" to scratch it.) Obviously, a syntax check would be needed IF we make a decision to standardize.
Yeah sounds like a reasonble idea to fix this.
+++ b/src/util/pci.c @@ -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);
Code like this means we will probably see a second round of patches in the future for scrubbing stupid uses of VIR_ERR_INTERNAL_ERROR into better messages for user-visible errors :)
Arugably nearly every use of VIR_ERR_INTERNAL_ERROR ought to be replaced by something more meaningful. That's not a job I wish to tackle now :-)
+++ b/src/util/stats_linux.c @@ -106,8 +102,8 @@ linuxDomainInterfaceStats(const char *path, } VIR_FORCE_FCLOSE(fp);
- virStatsError(VIR_ERR_INTERNAL_ERROR, - _("/proc/net/dev: Interface not found")); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("/proc/net/dev: Interface not found"));
Needs a "%s" argument to silence compiler warnings when i18n is disabled.
I'm fixing this as a separate patch, since this was a pre-existing problem
+++ b/src/util/util.c @@ -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."));
Is it worth scrubbing for error messages that end with '.'? That's another thing that GNU Coding Standards discourage.
Something to fix at the same time as the capitalization Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|

From: "Daniel P. Berrange" <berrange@redhat.com> This rmoves all the per-file error reporting macros from the code in src/rpc/ Signed-off-by: Daniel P. Berrange <berrange@redhat.com> --- src/rpc/virkeepalive.c | 7 +- src/rpc/virnetclient.c | 51 ++++---- src/rpc/virnetclientprogram.c | 23 ++-- src/rpc/virnetclientstream.c | 19 ++- src/rpc/virnetmessage.c | 49 ++++---- src/rpc/virnetsaslcontext.c | 130 ++++++++++---------- src/rpc/virnetserver.c | 15 +-- src/rpc/virnetserverclient.c | 11 +- src/rpc/virnetservermdns.c | 17 ++- src/rpc/virnetserverprogram.c | 41 +++---- src/rpc/virnetsocket.c | 28 ++--- src/rpc/virnettlscontext.c | 265 ++++++++++++++++++++--------------------- 12 files changed, 309 insertions(+), 347 deletions(-) diff --git a/src/rpc/virkeepalive.c b/src/rpc/virkeepalive.c index 70cf31e..c05847a 100644 --- a/src/rpc/virkeepalive.c +++ b/src/rpc/virkeepalive.c @@ -33,9 +33,6 @@ #include "virkeepalive.h" #define VIR_FROM_THIS VIR_FROM_RPC -#define virNetError(code, ...) \ - virReportErrorHelper(VIR_FROM_THIS, code, __FILE__, \ - __FUNCTION__, __LINE__, __VA_ARGS__) struct _virKeepAlive { int refs; @@ -287,8 +284,8 @@ virKeepAliveStart(virKeepAlivePtr ka, if (interval > 0) { if (ka->interval > 0) { - virNetError(VIR_ERR_INTERNAL_ERROR, "%s", - _("keepalive interval already set")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("keepalive interval already set")); goto cleanup; } ka->interval = interval; diff --git a/src/rpc/virnetclient.c b/src/rpc/virnetclient.c index 49d238e..f877934 100644 --- a/src/rpc/virnetclient.c +++ b/src/rpc/virnetclient.c @@ -38,9 +38,6 @@ #include "virterror_internal.h" #define VIR_FROM_THIS VIR_FROM_RPC -#define virNetError(code, ...) \ - virReportErrorHelper(VIR_FROM_THIS, code, __FILE__, \ - __FUNCTION__, __LINE__, __VA_ARGS__) typedef struct _virNetClientCall virNetClientCall; typedef virNetClientCall *virNetClientCallPtr; @@ -651,9 +648,9 @@ int virNetClientSetTLSSession(virNetClientPtr client, goto error; } if (len != 1 || buf[0] != '\1') { - virNetError(VIR_ERR_RPC, "%s", - _("server verification (of our certificate or IP " - "address) failed")); + virReportError(VIR_ERR_RPC, "%s", + _("server verification (of our certificate or IP " + "address) failed")); goto error; } @@ -802,9 +799,9 @@ virNetClientCallDispatchReply(virNetClientPtr client) thecall = thecall->next; if (!thecall) { - virNetError(VIR_ERR_RPC, - _("no call waiting for reply with prog %d vers %d serial %d"), - client->msg.header.prog, client->msg.header.vers, client->msg.header.serial); + virReportError(VIR_ERR_RPC, + _("no call waiting for reply with prog %d vers %d serial %d"), + client->msg.header.prog, client->msg.header.vers, client->msg.header.serial); return -1; } @@ -968,10 +965,10 @@ virNetClientCallDispatch(virNetClientPtr client) return virNetClientCallDispatchStream(client); default: - virNetError(VIR_ERR_RPC, - _("got unexpected RPC call prog %d vers %d proc %d type %d"), - client->msg.header.prog, client->msg.header.vers, - client->msg.header.proc, client->msg.header.type); + virReportError(VIR_ERR_RPC, + _("got unexpected RPC call prog %d vers %d proc %d type %d"), + client->msg.header.prog, client->msg.header.vers, + client->msg.header.proc, client->msg.header.type); return -1; } } @@ -1413,8 +1410,8 @@ static int virNetClientIOEventLoop(virNetClientPtr client, } if (fds[0].revents & (POLLHUP | POLLERR)) { - virNetError(VIR_ERR_INTERNAL_ERROR, "%s", - _("received hangup / error event on socket")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("received hangup / error event on socket")); goto error; } } @@ -1554,8 +1551,8 @@ static int virNetClientIO(virNetClientPtr client, /* Go to sleep while other thread is working... */ if (virCondWait(&thiscall->cond, &client->lock) < 0) { virNetClientCallRemove(&client->waitDispatch, thiscall); - virNetError(VIR_ERR_INTERNAL_ERROR, "%s", - _("failed to wait on condition")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("failed to wait on condition")); return -1; } @@ -1673,16 +1670,16 @@ virNetClientCallNew(virNetMessagePtr msg, if (expectReply && (msg->bufferLength != 0) && (msg->header.status == VIR_NET_CONTINUE)) { - virNetError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Attempt to send an asynchronous message with" - " a synchronous reply")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Attempt to send an asynchronous message with" + " a synchronous reply")); goto error; } if (expectReply && nonBlock) { - virNetError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Attempt to send a non-blocking message with" - " a synchronous reply")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Attempt to send a non-blocking message with" + " a synchronous reply")); goto error; } @@ -1692,8 +1689,8 @@ virNetClientCallNew(virNetMessagePtr msg, } if (virCondInit(&call->cond) < 0) { - virNetError(VIR_ERR_INTERNAL_ERROR, "%s", - _("cannot initialize condition variable")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("cannot initialize condition variable")); goto error; } @@ -1757,8 +1754,8 @@ static int virNetClientSendInternal(virNetClientPtr client, msg->header.type, msg->header.status, msg->header.serial); if (!client->sock || client->wantClose) { - virNetError(VIR_ERR_INTERNAL_ERROR, "%s", - _("client socket is closed")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("client socket is closed")); return -1; } diff --git a/src/rpc/virnetclientprogram.c b/src/rpc/virnetclientprogram.c index e1e8846..47e6adc 100644 --- a/src/rpc/virnetclientprogram.c +++ b/src/rpc/virnetclientprogram.c @@ -35,9 +35,6 @@ #include "virfile.h" #define VIR_FROM_THIS VIR_FROM_RPC -#define virNetError(code, ...) \ - virReportErrorHelper(VIR_FROM_THIS, code, __FILE__, \ - __FUNCTION__, __LINE__, __VA_ARGS__) struct _virNetClientProgram { int refs; @@ -336,20 +333,20 @@ int virNetClientProgramCall(virNetClientProgramPtr prog, */ if (msg->header.type != VIR_NET_REPLY && msg->header.type != VIR_NET_REPLY_WITH_FDS) { - virNetError(VIR_ERR_INTERNAL_ERROR, - _("Unexpected message type %d"), msg->header.type); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Unexpected message type %d"), msg->header.type); goto error; } if (msg->header.proc != proc) { - virNetError(VIR_ERR_INTERNAL_ERROR, - _("Unexpected message proc %d != %d"), - msg->header.proc, proc); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Unexpected message proc %d != %d"), + msg->header.proc, proc); goto error; } if (msg->header.serial != serial) { - virNetError(VIR_ERR_INTERNAL_ERROR, - _("Unexpected message serial %d != %d"), - msg->header.serial, serial); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Unexpected message serial %d != %d"), + msg->header.serial, serial); goto error; } @@ -388,8 +385,8 @@ int virNetClientProgramCall(virNetClientProgramPtr prog, goto error; default: - virNetError(VIR_ERR_RPC, - _("Unexpected message status %d"), msg->header.status); + virReportError(VIR_ERR_RPC, + _("Unexpected message status %d"), msg->header.status); goto error; } diff --git a/src/rpc/virnetclientstream.c b/src/rpc/virnetclientstream.c index de61a62..f230d20 100644 --- a/src/rpc/virnetclientstream.c +++ b/src/rpc/virnetclientstream.c @@ -31,9 +31,6 @@ #include "threads.h" #define VIR_FROM_THIS VIR_FROM_RPC -#define virNetError(code, ...) \ - virReportErrorHelper(VIR_FROM_THIS, code, __FILE__, \ - __FUNCTION__, __LINE__, __VA_ARGS__) struct _virNetClientStream { virMutex lock; @@ -147,8 +144,8 @@ virNetClientStreamPtr virNetClientStreamNew(virNetClientProgramPtr prog, st->serial = serial; if (virMutexInit(&st->lock) < 0) { - virNetError(VIR_ERR_INTERNAL_ERROR, "%s", - _("cannot initialize mutex")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("cannot initialize mutex")); VIR_FREE(st); return NULL; } @@ -452,8 +449,8 @@ int virNetClientStreamEventAddCallback(virNetClientStreamPtr st, virMutexLock(&st->lock); if (st->cb) { - virNetError(VIR_ERR_INTERNAL_ERROR, - "%s", _("multiple stream callbacks not supported")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("multiple stream callbacks not supported")); goto cleanup; } @@ -488,8 +485,8 @@ int virNetClientStreamEventUpdateCallback(virNetClientStreamPtr st, virMutexLock(&st->lock); if (!st->cb) { - virNetError(VIR_ERR_INTERNAL_ERROR, - "%s", _("no stream callback registered")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("no stream callback registered")); goto cleanup; } @@ -510,8 +507,8 @@ int virNetClientStreamEventRemoveCallback(virNetClientStreamPtr st) virMutexLock(&st->lock); if (!st->cb) { - virNetError(VIR_ERR_INTERNAL_ERROR, - "%s", _("no stream callback registered")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("no stream callback registered")); goto cleanup; } diff --git a/src/rpc/virnetmessage.c b/src/rpc/virnetmessage.c index 82d5f8d..4b5adb8 100644 --- a/src/rpc/virnetmessage.c +++ b/src/rpc/virnetmessage.c @@ -31,9 +31,6 @@ #include "util.h" #define VIR_FROM_THIS VIR_FROM_RPC -#define virNetError(code, ...) \ - virReportErrorHelper(VIR_FROM_THIS, code, __FILE__, \ - __FUNCTION__, __LINE__, __VA_ARGS__) virNetMessagePtr virNetMessageNew(bool tracked) { @@ -121,15 +118,15 @@ int virNetMessageDecodeLength(virNetMessagePtr msg) xdrmem_create(&xdr, msg->buffer, msg->bufferLength, XDR_DECODE); if (!xdr_u_int(&xdr, &len)) { - virNetError(VIR_ERR_RPC, "%s", _("Unable to decode message length")); + virReportError(VIR_ERR_RPC, "%s", _("Unable to decode message length")); goto cleanup; } msg->bufferOffset = xdr_getpos(&xdr); if (len < VIR_NET_MESSAGE_LEN_MAX) { - virNetError(VIR_ERR_RPC, - _("packet %d bytes received from server too small, want %d"), - len, VIR_NET_MESSAGE_LEN_MAX); + virReportError(VIR_ERR_RPC, + _("packet %d bytes received from server too small, want %d"), + len, VIR_NET_MESSAGE_LEN_MAX); goto cleanup; } @@ -137,9 +134,9 @@ int virNetMessageDecodeLength(virNetMessagePtr msg) len -= VIR_NET_MESSAGE_LEN_MAX; if (len > VIR_NET_MESSAGE_MAX) { - virNetError(VIR_ERR_RPC, - _("packet %d bytes received from server too large, want %d"), - len, VIR_NET_MESSAGE_MAX); + virReportError(VIR_ERR_RPC, + _("packet %d bytes received from server too large, want %d"), + len, VIR_NET_MESSAGE_MAX); goto cleanup; } @@ -187,7 +184,7 @@ int virNetMessageDecodeHeader(virNetMessagePtr msg) XDR_DECODE); if (!xdr_virNetMessageHeader(&xdr, &msg->header)) { - virNetError(VIR_ERR_RPC, "%s", _("Unable to decode message header")); + virReportError(VIR_ERR_RPC, "%s", _("Unable to decode message header")); goto cleanup; } @@ -233,12 +230,12 @@ int virNetMessageEncodeHeader(virNetMessagePtr msg) /* The real value is filled in shortly */ if (!xdr_u_int(&xdr, &len)) { - virNetError(VIR_ERR_RPC, "%s", _("Unable to encode message length")); + virReportError(VIR_ERR_RPC, "%s", _("Unable to encode message length")); goto cleanup; } if (!xdr_virNetMessageHeader(&xdr, &msg->header)) { - virNetError(VIR_ERR_RPC, "%s", _("Unable to encode message header")); + virReportError(VIR_ERR_RPC, "%s", _("Unable to encode message header")); goto cleanup; } @@ -249,7 +246,7 @@ int virNetMessageEncodeHeader(virNetMessagePtr msg) * if a payload is added */ if (!xdr_u_int(&xdr, &len)) { - virNetError(VIR_ERR_RPC, "%s", _("Unable to re-encode message length")); + virReportError(VIR_ERR_RPC, "%s", _("Unable to re-encode message length")); goto cleanup; } @@ -273,14 +270,14 @@ int virNetMessageEncodeNumFDs(virNetMessagePtr msg) msg->bufferLength - msg->bufferOffset, XDR_ENCODE); if (numFDs > VIR_NET_MESSAGE_NUM_FDS_MAX) { - virNetError(VIR_ERR_RPC, + virReportError(VIR_ERR_RPC, _("Too many FDs to send %d, expected %d maximum"), numFDs, VIR_NET_MESSAGE_NUM_FDS_MAX); goto cleanup; } if (!xdr_u_int(&xdr, &numFDs)) { - virNetError(VIR_ERR_RPC, "%s", _("Unable to encode number of FDs")); + virReportError(VIR_ERR_RPC, "%s", _("Unable to encode number of FDs")); goto cleanup; } msg->bufferOffset += xdr_getpos(&xdr); @@ -305,13 +302,13 @@ int virNetMessageDecodeNumFDs(virNetMessagePtr msg) xdrmem_create(&xdr, msg->buffer + msg->bufferOffset, msg->bufferLength - msg->bufferOffset, XDR_DECODE); if (!xdr_u_int(&xdr, &numFDs)) { - virNetError(VIR_ERR_RPC, "%s", _("Unable to decode number of FDs")); + virReportError(VIR_ERR_RPC, "%s", _("Unable to decode number of FDs")); goto cleanup; } msg->bufferOffset += xdr_getpos(&xdr); if (numFDs > VIR_NET_MESSAGE_NUM_FDS_MAX) { - virNetError(VIR_ERR_RPC, + virReportError(VIR_ERR_RPC, _("Received too many FDs %d, expected %d maximum"), numFDs, VIR_NET_MESSAGE_NUM_FDS_MAX); goto cleanup; @@ -349,7 +346,7 @@ int virNetMessageEncodePayload(virNetMessagePtr msg, msg->bufferLength - msg->bufferOffset, XDR_ENCODE); if (!(*filter)(&xdr, data)) { - virNetError(VIR_ERR_RPC, "%s", _("Unable to encode message payload")); + virReportError(VIR_ERR_RPC, "%s", _("Unable to encode message payload")); goto error; } @@ -362,7 +359,7 @@ int virNetMessageEncodePayload(virNetMessagePtr msg, xdrmem_create(&xdr, msg->buffer, VIR_NET_MESSAGE_HEADER_XDR_LEN, XDR_ENCODE); msglen = msg->bufferOffset; if (!xdr_u_int(&xdr, &msglen)) { - virNetError(VIR_ERR_RPC, "%s", _("Unable to encode message length")); + virReportError(VIR_ERR_RPC, "%s", _("Unable to encode message length")); goto error; } xdr_destroy(&xdr); @@ -390,7 +387,7 @@ int virNetMessageDecodePayload(virNetMessagePtr msg, msg->bufferLength - msg->bufferOffset, XDR_DECODE); if (!(*filter)(&xdr, data)) { - virNetError(VIR_ERR_RPC, "%s", _("Unable to decode message payload")); + virReportError(VIR_ERR_RPC, "%s", _("Unable to decode message payload")); goto error; } @@ -413,7 +410,7 @@ int virNetMessageEncodePayloadRaw(virNetMessagePtr msg, unsigned int msglen; if ((msg->bufferLength - msg->bufferOffset) < len) { - virNetError(VIR_ERR_RPC, + virReportError(VIR_ERR_RPC, _("Stream data too long to send (%zu bytes needed, %zu bytes available)"), len, (msg->bufferLength - msg->bufferOffset)); return -1; @@ -427,7 +424,7 @@ int virNetMessageEncodePayloadRaw(virNetMessagePtr msg, xdrmem_create(&xdr, msg->buffer, VIR_NET_MESSAGE_HEADER_XDR_LEN, XDR_ENCODE); msglen = msg->bufferOffset; if (!xdr_u_int(&xdr, &msglen)) { - virNetError(VIR_ERR_RPC, "%s", _("Unable to encode message length")); + virReportError(VIR_ERR_RPC, "%s", _("Unable to encode message length")); goto error; } xdr_destroy(&xdr); @@ -452,7 +449,7 @@ int virNetMessageEncodePayloadEmpty(virNetMessagePtr msg) xdrmem_create(&xdr, msg->buffer, VIR_NET_MESSAGE_HEADER_XDR_LEN, XDR_ENCODE); msglen = msg->bufferOffset; if (!xdr_u_int(&xdr, &msglen)) { - virNetError(VIR_ERR_RPC, "%s", _("Unable to encode message length")); + virReportError(VIR_ERR_RPC, "%s", _("Unable to encode message length")); goto error; } xdr_destroy(&xdr); @@ -508,8 +505,8 @@ int virNetMessageDupFD(virNetMessagePtr msg, int fd; if (slot >= msg->nfds) { - virNetError(VIR_ERR_INTERNAL_ERROR, - _("No FD available at slot %zu"), slot); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("No FD available at slot %zu"), slot); return -1; } diff --git a/src/rpc/virnetsaslcontext.c b/src/rpc/virnetsaslcontext.c index 8db0e15..9943057 100644 --- a/src/rpc/virnetsaslcontext.c +++ b/src/rpc/virnetsaslcontext.c @@ -31,10 +31,6 @@ #include "logging.h" #define VIR_FROM_THIS VIR_FROM_RPC -#define virNetError(code, ...) \ - virReportErrorHelper(VIR_FROM_THIS, code, __FILE__, \ - __FUNCTION__, __LINE__, __VA_ARGS__) - struct _virNetSASLContext { virMutex lock; @@ -57,9 +53,9 @@ virNetSASLContextPtr virNetSASLContextNewClient(void) err = sasl_client_init(NULL); if (err != SASL_OK) { - virNetError(VIR_ERR_AUTH_FAILED, - _("failed to initialize SASL library: %d (%s)"), - err, sasl_errstring(err, NULL, NULL)); + virReportError(VIR_ERR_AUTH_FAILED, + _("failed to initialize SASL library: %d (%s)"), + err, sasl_errstring(err, NULL, NULL)); return NULL; } @@ -69,8 +65,8 @@ virNetSASLContextPtr virNetSASLContextNewClient(void) } if (virMutexInit(&ctxt->lock) < 0) { - virNetError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Failed to initialized mutex")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Failed to initialized mutex")); VIR_FREE(ctxt); return NULL; } @@ -87,9 +83,9 @@ virNetSASLContextPtr virNetSASLContextNewServer(const char *const*usernameWhitel err = sasl_server_init(NULL, "libvirt"); if (err != SASL_OK) { - virNetError(VIR_ERR_AUTH_FAILED, - _("failed to initialize SASL library: %d (%s)"), - err, sasl_errstring(err, NULL, NULL)); + virReportError(VIR_ERR_AUTH_FAILED, + _("failed to initialize SASL library: %d (%s)"), + err, sasl_errstring(err, NULL, NULL)); return NULL; } @@ -99,8 +95,8 @@ virNetSASLContextPtr virNetSASLContextNewServer(const char *const*usernameWhitel } if (virMutexInit(&ctxt->lock) < 0) { - virNetError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Failed to initialized mutex")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Failed to initialized mutex")); VIR_FREE(ctxt); return NULL; } @@ -133,9 +129,9 @@ int virNetSASLContextCheckIdentity(virNetSASLContextPtr ctxt, goto cleanup; /* Succesful match */ } if (rv != FNM_NOMATCH) { - virNetError(VIR_ERR_INTERNAL_ERROR, - _("Malformed TLS whitelist regular expression '%s'"), - *wildcards); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Malformed TLS whitelist regular expression '%s'"), + *wildcards); goto cleanup; } @@ -146,8 +142,8 @@ int virNetSASLContextCheckIdentity(virNetSASLContextPtr ctxt, VIR_ERROR(_("SASL client %s not allowed in whitelist"), identity); /* This is the most common error: make it informative. */ - virNetError(VIR_ERR_SYSTEM_ERROR, "%s", - _("Client's username is not on the list of allowed clients")); + virReportError(VIR_ERR_SYSTEM_ERROR, "%s", + _("Client's username is not on the list of allowed clients")); ret = 0; cleanup: @@ -196,8 +192,8 @@ virNetSASLSessionPtr virNetSASLSessionNewClient(virNetSASLContextPtr ctxt ATTRIB } if (virMutexInit(&sasl->lock) < 0) { - virNetError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Failed to initialized mutex")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Failed to initialized mutex")); VIR_FREE(sasl); return NULL; } @@ -214,9 +210,9 @@ virNetSASLSessionPtr virNetSASLSessionNewClient(virNetSASLContextPtr ctxt ATTRIB SASL_SUCCESS_DATA, &sasl->conn); if (err != SASL_OK) { - virNetError(VIR_ERR_AUTH_FAILED, - _("Failed to create SASL client context: %d (%s)"), - err, sasl_errstring(err, NULL, NULL)); + virReportError(VIR_ERR_AUTH_FAILED, + _("Failed to create SASL client context: %d (%s)"), + err, sasl_errstring(err, NULL, NULL)); goto cleanup; } @@ -241,8 +237,8 @@ virNetSASLSessionPtr virNetSASLSessionNewServer(virNetSASLContextPtr ctxt ATTRIB } if (virMutexInit(&sasl->lock) < 0) { - virNetError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Failed to initialized mutex")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Failed to initialized mutex")); VIR_FREE(sasl); return NULL; } @@ -260,9 +256,9 @@ virNetSASLSessionPtr virNetSASLSessionNewServer(virNetSASLContextPtr ctxt ATTRIB SASL_SUCCESS_DATA, &sasl->conn); if (err != SASL_OK) { - virNetError(VIR_ERR_AUTH_FAILED, - _("Failed to create SASL client context: %d (%s)"), - err, sasl_errstring(err, NULL, NULL)); + virReportError(VIR_ERR_AUTH_FAILED, + _("Failed to create SASL client context: %d (%s)"), + err, sasl_errstring(err, NULL, NULL)); goto cleanup; } @@ -289,9 +285,9 @@ int virNetSASLSessionExtKeySize(virNetSASLSessionPtr sasl, err = sasl_setprop(sasl->conn, SASL_SSF_EXTERNAL, &ssf); if (err != SASL_OK) { - virNetError(VIR_ERR_INTERNAL_ERROR, - _("cannot set external SSF %d (%s)"), - err, sasl_errstring(err, NULL, NULL)); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("cannot set external SSF %d (%s)"), + err, sasl_errstring(err, NULL, NULL)); goto cleanup; } @@ -310,15 +306,15 @@ const char *virNetSASLSessionGetIdentity(virNetSASLSessionPtr sasl) err = sasl_getprop(sasl->conn, SASL_USERNAME, &val); if (err != SASL_OK) { - virNetError(VIR_ERR_AUTH_FAILED, - _("cannot query SASL username on connection %d (%s)"), - err, sasl_errstring(err, NULL, NULL)); + virReportError(VIR_ERR_AUTH_FAILED, + _("cannot query SASL username on connection %d (%s)"), + err, sasl_errstring(err, NULL, NULL)); val = NULL; goto cleanup; } if (val == NULL) { - virNetError(VIR_ERR_AUTH_FAILED, - _("no client username was found")); + virReportError(VIR_ERR_AUTH_FAILED, + _("no client username was found")); goto cleanup; } VIR_DEBUG("SASL client username %s", (const char *)val); @@ -338,9 +334,9 @@ int virNetSASLSessionGetKeySize(virNetSASLSessionPtr sasl) virMutexLock(&sasl->lock); err = sasl_getprop(sasl->conn, SASL_SSF, &val); if (err != SASL_OK) { - virNetError(VIR_ERR_AUTH_FAILED, - _("cannot query SASL ssf on connection %d (%s)"), - err, sasl_errstring(err, NULL, NULL)); + virReportError(VIR_ERR_AUTH_FAILED, + _("cannot query SASL ssf on connection %d (%s)"), + err, sasl_errstring(err, NULL, NULL)); ssf = -1; goto cleanup; } @@ -374,9 +370,9 @@ int virNetSASLSessionSecProps(virNetSASLSessionPtr sasl, err = sasl_setprop(sasl->conn, SASL_SEC_PROPS, &secprops); if (err != SASL_OK) { - virNetError(VIR_ERR_INTERNAL_ERROR, - _("cannot set security props %d (%s)"), - err, sasl_errstring(err, NULL, NULL)); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("cannot set security props %d (%s)"), + err, sasl_errstring(err, NULL, NULL)); goto cleanup; } @@ -398,9 +394,9 @@ static int virNetSASLSessionUpdateBufSize(virNetSASLSessionPtr sasl) err = sasl_getprop(sasl->conn, SASL_MAXOUTBUF, &u.ptr); if (err != SASL_OK) { - virNetError(VIR_ERR_INTERNAL_ERROR, - _("cannot get security props %d (%s)"), - err, sasl_errstring(err, NULL, NULL)); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("cannot get security props %d (%s)"), + err, sasl_errstring(err, NULL, NULL)); return -1; } @@ -426,9 +422,9 @@ char *virNetSASLSessionListMechanisms(virNetSASLSessionPtr sasl) NULL, NULL); if (err != SASL_OK) { - virNetError(VIR_ERR_INTERNAL_ERROR, - _("cannot list SASL mechanisms %d (%s)"), - err, sasl_errdetail(sasl->conn)); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("cannot list SASL mechanisms %d (%s)"), + err, sasl_errdetail(sasl->conn)); goto cleanup; } if (!(ret = strdup(mechlist))) { @@ -479,9 +475,9 @@ int virNetSASLSessionClientStart(virNetSASLSessionPtr sasl, ret = VIR_NET_SASL_INTERACT; break; default: - virNetError(VIR_ERR_AUTH_FAILED, - _("Failed to start SASL negotiation: %d (%s)"), - err, sasl_errdetail(sasl->conn)); + virReportError(VIR_ERR_AUTH_FAILED, + _("Failed to start SASL negotiation: %d (%s)"), + err, sasl_errdetail(sasl->conn)); break; } @@ -528,9 +524,9 @@ int virNetSASLSessionClientStep(virNetSASLSessionPtr sasl, ret = VIR_NET_SASL_INTERACT; break; default: - virNetError(VIR_ERR_AUTH_FAILED, - _("Failed to step SASL negotiation: %d (%s)"), - err, sasl_errdetail(sasl->conn)); + virReportError(VIR_ERR_AUTH_FAILED, + _("Failed to step SASL negotiation: %d (%s)"), + err, sasl_errdetail(sasl->conn)); break; } @@ -574,9 +570,9 @@ int virNetSASLSessionServerStart(virNetSASLSessionPtr sasl, ret = VIR_NET_SASL_INTERACT; break; default: - virNetError(VIR_ERR_AUTH_FAILED, - _("Failed to start SASL negotiation: %d (%s)"), - err, sasl_errdetail(sasl->conn)); + virReportError(VIR_ERR_AUTH_FAILED, + _("Failed to start SASL negotiation: %d (%s)"), + err, sasl_errdetail(sasl->conn)); break; } @@ -619,9 +615,9 @@ int virNetSASLSessionServerStep(virNetSASLSessionPtr sasl, ret = VIR_NET_SASL_INTERACT; break; default: - virNetError(VIR_ERR_AUTH_FAILED, - _("Failed to start SASL negotiation: %d (%s)"), - err, sasl_errdetail(sasl->conn)); + virReportError(VIR_ERR_AUTH_FAILED, + _("Failed to start SASL negotiation: %d (%s)"), + err, sasl_errdetail(sasl->conn)); break; } @@ -666,9 +662,9 @@ ssize_t virNetSASLSessionEncode(virNetSASLSessionPtr sasl, *outputlen = outlen; if (err != SASL_OK) { - virNetError(VIR_ERR_INTERNAL_ERROR, - _("failed to encode SASL data: %d (%s)"), - err, sasl_errstring(err, NULL, NULL)); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("failed to encode SASL data: %d (%s)"), + err, sasl_errstring(err, NULL, NULL)); goto cleanup; } ret = 0; @@ -704,9 +700,9 @@ ssize_t virNetSASLSessionDecode(virNetSASLSessionPtr sasl, &outlen); *outputlen = outlen; if (err != SASL_OK) { - virNetError(VIR_ERR_INTERNAL_ERROR, - _("failed to decode SASL data: %d (%s)"), - err, sasl_errstring(err, NULL, NULL)); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("failed to decode SASL data: %d (%s)"), + err, sasl_errstring(err, NULL, NULL)); goto cleanup; } ret = 0; diff --git a/src/rpc/virnetserver.c b/src/rpc/virnetserver.c index 4a02aab..6c0ccf5 100644 --- a/src/rpc/virnetserver.c +++ b/src/rpc/virnetserver.c @@ -45,9 +45,6 @@ #endif #define VIR_FROM_THIS VIR_FROM_RPC -#define virNetError(code, ...) \ - virReportErrorHelper(VIR_FROM_THIS, code, __FILE__, \ - __FUNCTION__, __LINE__, __VA_ARGS__) typedef struct _virNetServerSignal virNetServerSignal; typedef virNetServerSignal *virNetServerSignalPtr; @@ -261,7 +258,7 @@ static int virNetServerDispatchNewClient(virNetServerServicePtr svc ATTRIBUTE_UN virNetServerLock(srv); if (srv->nclients >= srv->nclients_max) { - virNetError(VIR_ERR_RPC, + virReportError(VIR_ERR_RPC, _("Too many active clients (%zu), dropping connection from %s"), srv->nclients_max, virNetServerClientRemoteAddrString(client)); goto error; @@ -378,7 +375,7 @@ virNetServerPtr virNetServerNew(size_t min_workers, #endif if (virMutexInit(&srv->lock) < 0) { - virNetError(VIR_ERR_INTERNAL_ERROR, "%s", + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("cannot initialize mutex")); goto error; } @@ -507,7 +504,7 @@ virNetServerSignalEvent(int watch, } } - virNetError(VIR_ERR_INTERNAL_ERROR, + virReportError(VIR_ERR_INTERNAL_ERROR, _("Unexpected signal received: %d"), siginfo.si_signo); cleanup: @@ -531,7 +528,7 @@ static int virNetServerSignalSetup(virNetServerPtr srv) VIR_EVENT_HANDLE_READABLE, virNetServerSignalEvent, srv, NULL)) < 0) { - virNetError(VIR_ERR_INTERNAL_ERROR, "%s", + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Failed to add signal handle watch")); goto error; } @@ -707,8 +704,8 @@ void virNetServerRun(virNetServerPtr srv) (timerid = virEventAddTimeout(-1, virNetServerAutoShutdownTimer, srv, NULL)) < 0) { - virNetError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Failed to register shutdown timeout")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Failed to register shutdown timeout")); goto cleanup; } diff --git a/src/rpc/virnetserverclient.c b/src/rpc/virnetserverclient.c index a56031c..3e33c39 100644 --- a/src/rpc/virnetserverclient.c +++ b/src/rpc/virnetserverclient.c @@ -36,9 +36,6 @@ #include "virkeepalive.h" #define VIR_FROM_THIS VIR_FROM_RPC -#define virNetError(code, ...) \ - virReportErrorHelper(VIR_FROM_THIS, code, __FILE__, \ - __FUNCTION__, __LINE__, __VA_ARGS__) /* Allow for filtering of incoming messages to a custom * dispatch processing queue, instead of the workers. @@ -775,7 +772,7 @@ static ssize_t virNetServerClientRead(virNetServerClientPtr client) ssize_t ret; if (client->rx->bufferLength <= client->rx->bufferOffset) { - virNetError(VIR_ERR_RPC, + virReportError(VIR_ERR_RPC, _("unexpected zero/negative length request %lld"), (long long int)(client->rx->bufferLength - client->rx->bufferOffset)); client->wantClose = true; @@ -953,9 +950,9 @@ static ssize_t virNetServerClientWrite(virNetServerClientPtr client) ssize_t ret; if (client->tx->bufferLength < client->tx->bufferOffset) { - virNetError(VIR_ERR_RPC, - _("unexpected zero/negative length request %lld"), - (long long int)(client->tx->bufferLength - client->tx->bufferOffset)); + virReportError(VIR_ERR_RPC, + _("unexpected zero/negative length request %lld"), + (long long int)(client->tx->bufferLength - client->tx->bufferOffset)); client->wantClose = true; return -1; } diff --git a/src/rpc/virnetservermdns.c b/src/rpc/virnetservermdns.c index 335274a..92eb59c 100644 --- a/src/rpc/virnetservermdns.c +++ b/src/rpc/virnetservermdns.c @@ -46,9 +46,6 @@ #include "logging.h" #define VIR_FROM_THIS VIR_FROM_RPC -#define virNetError(code, ...) \ - virReportErrorHelper(VIR_FROM_THIS, code, __FILE__, \ - __FUNCTION__, __LINE__, __VA_ARGS__) struct _virNetServerMDNSEntry { char *type; @@ -285,8 +282,8 @@ static AvahiWatch *virNetServerMDNSWatchNew(const AvahiPoll *api ATTRIBUTE_UNUSE virNetServerMDNSWatchDispatch, w, virNetServerMDNSWatchDofree)) < 0) { - virNetError(VIR_ERR_INTERNAL_ERROR, - _("Failed to add watch for fd %d events %d"), fd, hEvents); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Failed to add watch for fd %d events %d"), fd, hEvents); VIR_FREE(w); return NULL; } @@ -367,8 +364,8 @@ static AvahiTimeout *virNetServerMDNSTimeoutNew(const AvahiPoll *api ATTRIBUTE_U t->userdata = userdata; if (t->timer < 0) { - virNetError(VIR_ERR_INTERNAL_ERROR, - _("Failed to add timer with timeout %d"), (int)timeout); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Failed to add timer with timeout %d"), (int)timeout); VIR_FREE(t); return NULL; } @@ -455,9 +452,9 @@ int virNetServerMDNSStart(virNetServerMDNS *mdns) mdns, &error); if (!mdns->client) { - virNetError(VIR_ERR_INTERNAL_ERROR, - _("Failed to create mDNS client: %s"), - avahi_strerror(error)); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Failed to create mDNS client: %s"), + avahi_strerror(error)); return -1; } diff --git a/src/rpc/virnetserverprogram.c b/src/rpc/virnetserverprogram.c index 7f589c8..001e18d 100644 --- a/src/rpc/virnetserverprogram.c +++ b/src/rpc/virnetserverprogram.c @@ -32,9 +32,6 @@ #include "virfile.h" #define VIR_FROM_THIS VIR_FROM_RPC -#define virNetError(code, ...) \ - virReportErrorHelper(VIR_FROM_THIS, code, __FILE__, \ - __FUNCTION__, __LINE__, __VA_ARGS__) struct _virNetServerProgram { int refs; @@ -218,8 +215,8 @@ int virNetServerProgramUnknownError(virNetServerClientPtr client, { virNetMessageError rerr; - virNetError(VIR_ERR_RPC, - _("Cannot find program %d version %d"), req->prog, req->vers); + virReportError(VIR_ERR_RPC, + _("Cannot find program %d version %d"), req->prog, req->vers); memset(&rerr, 0, sizeof(rerr)); return virNetServerProgramSendError(req->prog, @@ -270,16 +267,16 @@ int virNetServerProgramDispatch(virNetServerProgramPtr prog, /* Check version, etc. */ if (msg->header.prog != prog->program) { - virNetError(VIR_ERR_RPC, - _("program mismatch (actual %x, expected %x)"), - msg->header.prog, prog->program); + virReportError(VIR_ERR_RPC, + _("program mismatch (actual %x, expected %x)"), + msg->header.prog, prog->program); goto error; } if (msg->header.vers != prog->version) { - virNetError(VIR_ERR_RPC, - _("version mismatch (actual %x, expected %x)"), - msg->header.vers, prog->version); + virReportError(VIR_ERR_RPC, + _("version mismatch (actual %x, expected %x)"), + msg->header.vers, prog->version); goto error; } @@ -307,9 +304,9 @@ int virNetServerProgramDispatch(virNetServerProgramPtr prog, break; default: - virNetError(VIR_ERR_RPC, - _("Unexpected message type %u"), - msg->header.type); + virReportError(VIR_ERR_RPC, + _("Unexpected message type %u"), + msg->header.type); goto error; } @@ -363,18 +360,18 @@ virNetServerProgramDispatchCall(virNetServerProgramPtr prog, memset(&rerr, 0, sizeof(rerr)); if (msg->header.status != VIR_NET_OK) { - virNetError(VIR_ERR_RPC, - _("Unexpected message status %u"), - msg->header.status); + virReportError(VIR_ERR_RPC, + _("Unexpected message status %u"), + msg->header.status); goto error; } dispatcher = virNetServerProgramGetProc(prog, msg->header.proc); if (!dispatcher) { - virNetError(VIR_ERR_RPC, - _("unknown procedure: %d"), - msg->header.proc); + virReportError(VIR_ERR_RPC, + _("unknown procedure: %d"), + msg->header.proc); goto error; } @@ -386,8 +383,8 @@ virNetServerProgramDispatchCall(virNetServerProgramPtr prog, /* Explicitly *NOT* calling remoteDispatchAuthError() because we want back-compatibility with libvirt clients which don't support the VIR_ERR_AUTH_FAILED error code */ - virNetError(VIR_ERR_RPC, - "%s", _("authentication required")); + virReportError(VIR_ERR_RPC, + "%s", _("authentication required")); goto error; } diff --git a/src/rpc/virnetsocket.c b/src/rpc/virnetsocket.c index 08dfbb0..3ddf37d 100644 --- a/src/rpc/virnetsocket.c +++ b/src/rpc/virnetsocket.c @@ -48,10 +48,6 @@ #define VIR_FROM_THIS VIR_FROM_RPC -#define virNetError(code, ...) \ - virReportErrorHelper(VIR_FROM_THIS, code, __FILE__, \ - __FUNCTION__, __LINE__, __VA_ARGS__) - struct _virNetSocket { virMutex lock; @@ -212,9 +208,9 @@ int virNetSocketNewListenTCP(const char *nodename, int e = getaddrinfo(nodename, service, &hints, &ai); if (e != 0) { - virNetError(VIR_ERR_SYSTEM_ERROR, - _("Unable to resolve address '%s' service '%s': %s"), - nodename, service, gai_strerror(e)); + virReportError(VIR_ERR_SYSTEM_ERROR, + _("Unable to resolve address '%s' service '%s': %s"), + nodename, service, gai_strerror(e)); return -1; } @@ -409,9 +405,9 @@ int virNetSocketNewConnectTCP(const char *nodename, int e = getaddrinfo(nodename, service, &hints, &ai); if (e != 0) { - virNetError(VIR_ERR_SYSTEM_ERROR, - _("Unable to resolve address '%s' service '%s': %s"), - nodename, service, gai_strerror (e)); + virReportError(VIR_ERR_SYSTEM_ERROR, + _("Unable to resolve address '%s' service '%s': %s"), + nodename, service, gai_strerror (e)); return -1; } @@ -485,8 +481,8 @@ int virNetSocketNewConnectUNIX(const char *path, remoteAddr.len = sizeof(remoteAddr.data.un); if (spawnDaemon && !binary) { - virNetError(VIR_ERR_INTERNAL_ERROR, - _("Auto-spawn of daemon requested, but no binary specified")); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Auto-spawn of daemon requested, but no binary specified")); return -1; } @@ -1180,8 +1176,8 @@ int virNetSocketSendFD(virNetSocketPtr sock, int fd) { int ret = -1; if (!virNetSocketHasPassFD(sock)) { - virNetError(VIR_ERR_INTERNAL_ERROR, - _("Sending file descriptors is not supported on this socket")); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Sending file descriptors is not supported on this socket")); return -1; } virMutexLock(&sock->lock); @@ -1214,8 +1210,8 @@ int virNetSocketRecvFD(virNetSocketPtr sock, int *fd) *fd = -1; if (!virNetSocketHasPassFD(sock)) { - virNetError(VIR_ERR_INTERNAL_ERROR, - _("Receiving file descriptors is not supported on this socket")); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Receiving file descriptors is not supported on this socket")); return -1; } virMutexLock(&sock->lock); diff --git a/src/rpc/virnettlscontext.c b/src/rpc/virnettlscontext.c index bf92088..adbc0de 100644 --- a/src/rpc/virnettlscontext.c +++ b/src/rpc/virnettlscontext.c @@ -48,9 +48,6 @@ #define LIBVIRT_SERVERCERT LIBVIRT_PKI_DIR "/libvirt/servercert.pem" #define VIR_FROM_THIS VIR_FROM_RPC -#define virNetError(code, ...) \ - virReportErrorHelper(VIR_FROM_THIS, code, __FILE__, \ - __FUNCTION__, __LINE__, __VA_ARGS__) struct _virNetTLSContext { virMutex lock; @@ -116,24 +113,24 @@ static int virNetTLSContextCheckCertTimes(gnutls_x509_crt_t cert, } if (gnutls_x509_crt_get_expiration_time(cert) < now) { - virNetError(VIR_ERR_SYSTEM_ERROR, - (isCA ? - _("The CA certificate %s has expired") : - (isServer ? - _("The server certificate %s has expired") : - _("The client certificate %s has expired"))), - certFile); + virReportError(VIR_ERR_SYSTEM_ERROR, + (isCA ? + _("The CA certificate %s has expired") : + (isServer ? + _("The server certificate %s has expired") : + _("The client certificate %s has expired"))), + certFile); return -1; } if (gnutls_x509_crt_get_activation_time(cert) > now) { - virNetError(VIR_ERR_SYSTEM_ERROR, - (isCA ? - _("The CA certificate %s is not yet active") : - (isServer ? - _("The server certificate %s is not yet active") : - _("The client certificate %s is not yet active"))), - certFile); + virReportError(VIR_ERR_SYSTEM_ERROR, + (isCA ? + _("The CA certificate %s is not yet active") : + (isServer ? + _("The server certificate %s is not yet active") : + _("The client certificate %s is not yet active"))), + certFile); return -1; } @@ -161,30 +158,30 @@ static int virNetTLSContextCheckCertBasicConstraints(gnutls_x509_crt_t cert, if (status > 0) { /* It is a CA cert */ if (!isCA) { - virNetError(VIR_ERR_SYSTEM_ERROR, isServer ? - _("The certificate %s basic constraints show a CA, but we need one for a server") : - _("The certificate %s basic constraints show a CA, but we need one for a client"), - certFile); + virReportError(VIR_ERR_SYSTEM_ERROR, isServer ? + _("The certificate %s basic constraints show a CA, but we need one for a server") : + _("The certificate %s basic constraints show a CA, but we need one for a client"), + certFile); return -1; } } else if (status == 0) { /* It is not a CA cert */ if (isCA) { - virNetError(VIR_ERR_SYSTEM_ERROR, - _("The certificate %s basic constraints do not show a CA"), - certFile); + virReportError(VIR_ERR_SYSTEM_ERROR, + _("The certificate %s basic constraints do not show a CA"), + certFile); return -1; } } else if (status == GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE) { /* Missing basicConstraints */ if (isCA) { - virNetError(VIR_ERR_SYSTEM_ERROR, - _("The certificate %s is missing basic constraints for a CA"), - certFile); + virReportError(VIR_ERR_SYSTEM_ERROR, + _("The certificate %s is missing basic constraints for a CA"), + certFile); return -1; } } else { /* General error */ - virNetError(VIR_ERR_SYSTEM_ERROR, - _("Unable to query certificate %s basic constraints %s"), - certFile, gnutls_strerror(status)); + virReportError(VIR_ERR_SYSTEM_ERROR, + _("Unable to query certificate %s basic constraints %s"), + certFile, gnutls_strerror(status)); return -1; } @@ -209,9 +206,9 @@ static int virNetTLSContextCheckCertKeyUsage(gnutls_x509_crt_t cert, usage = isCA ? GNUTLS_KEY_KEY_CERT_SIGN : GNUTLS_KEY_DIGITAL_SIGNATURE|GNUTLS_KEY_KEY_ENCIPHERMENT; } else { - virNetError(VIR_ERR_SYSTEM_ERROR, - _("Unable to query certificate %s key usage %s"), - certFile, gnutls_strerror(status)); + virReportError(VIR_ERR_SYSTEM_ERROR, + _("Unable to query certificate %s key usage %s"), + certFile, gnutls_strerror(status)); return -1; } } @@ -219,9 +216,9 @@ static int virNetTLSContextCheckCertKeyUsage(gnutls_x509_crt_t cert, if (isCA) { if (!(usage & GNUTLS_KEY_KEY_CERT_SIGN)) { if (critical) { - virNetError(VIR_ERR_SYSTEM_ERROR, - _("Certificate %s usage does not permit certificate signing"), - certFile); + virReportError(VIR_ERR_SYSTEM_ERROR, + _("Certificate %s usage does not permit certificate signing"), + certFile); return -1; } else { VIR_WARN("Certificate %s usage does not permit certificate signing", @@ -231,9 +228,9 @@ static int virNetTLSContextCheckCertKeyUsage(gnutls_x509_crt_t cert, } else { if (!(usage & GNUTLS_KEY_DIGITAL_SIGNATURE)) { if (critical) { - virNetError(VIR_ERR_SYSTEM_ERROR, - _("Certificate %s usage does not permit digital signature"), - certFile); + virReportError(VIR_ERR_SYSTEM_ERROR, + _("Certificate %s usage does not permit digital signature"), + certFile); return -1; } else { VIR_WARN("Certificate %s usage does not permit digital signature", @@ -242,9 +239,9 @@ static int virNetTLSContextCheckCertKeyUsage(gnutls_x509_crt_t cert, } if (!(usage & GNUTLS_KEY_KEY_ENCIPHERMENT)) { if (critical) { - virNetError(VIR_ERR_SYSTEM_ERROR, - _("Certificate %s usage does not permit key encipherment"), - certFile); + virReportError(VIR_ERR_SYSTEM_ERROR, + _("Certificate %s usage does not permit key encipherment"), + certFile); return -1; } else { VIR_WARN("Certificate %s usage does not permit key encipherment", @@ -283,9 +280,9 @@ static int virNetTLSContextCheckCertKeyPurpose(gnutls_x509_crt_t cert, break; } if (status != GNUTLS_E_SHORT_MEMORY_BUFFER) { - virNetError(VIR_ERR_SYSTEM_ERROR, - _("Unable to query certificate %s key purpose %s"), - certFile, gnutls_strerror(status)); + virReportError(VIR_ERR_SYSTEM_ERROR, + _("Unable to query certificate %s key purpose %s"), + certFile, gnutls_strerror(status)); return -1; } @@ -297,9 +294,9 @@ static int virNetTLSContextCheckCertKeyPurpose(gnutls_x509_crt_t cert, status = gnutls_x509_crt_get_key_purpose_oid(cert, i, buffer, &size, &purposeCritical); if (status < 0) { VIR_FREE(buffer); - virNetError(VIR_ERR_SYSTEM_ERROR, - _("Unable to query certificate %s key purpose %s"), - certFile, gnutls_strerror(status)); + virReportError(VIR_ERR_SYSTEM_ERROR, + _("Unable to query certificate %s key purpose %s"), + certFile, gnutls_strerror(status)); return -1; } if (purposeCritical) @@ -320,9 +317,9 @@ static int virNetTLSContextCheckCertKeyPurpose(gnutls_x509_crt_t cert, if (isServer) { if (!allowServer) { if (critical) { - virNetError(VIR_ERR_SYSTEM_ERROR, - _("Certificate %s purpose does not allow use for with a TLS server"), - certFile); + virReportError(VIR_ERR_SYSTEM_ERROR, + _("Certificate %s purpose does not allow use for with a TLS server"), + certFile); return -1; } else { VIR_WARN("Certificate %s purpose does not allow use for with a TLS server", @@ -332,9 +329,9 @@ static int virNetTLSContextCheckCertKeyPurpose(gnutls_x509_crt_t cert, } else { if (!allowClient) { if (critical) { - virNetError(VIR_ERR_SYSTEM_ERROR, - _("Certificate %s purpose does not allow use for with a TLS client"), - certFile); + virReportError(VIR_ERR_SYSTEM_ERROR, + _("Certificate %s purpose does not allow use for with a TLS client"), + certFile); return -1; } else { VIR_WARN("Certificate %s purpose does not allow use for with a TLS client", @@ -356,9 +353,9 @@ virNetTLSContextCheckCertDNWhitelist(const char *dname, if (ret == 0) /* Succesful match */ return 1; if (ret != FNM_NOMATCH) { - virNetError(VIR_ERR_INTERNAL_ERROR, - _("Malformed TLS whitelist regular expression '%s'"), - *wildcards); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Malformed TLS whitelist regular expression '%s'"), + *wildcards); return -1; } @@ -369,12 +366,12 @@ virNetTLSContextCheckCertDNWhitelist(const char *dname, VIR_DEBUG("Failed whitelist check for client DN '%s'", dname); /* This is the most common error: make it informative. */ - virNetError(VIR_ERR_SYSTEM_ERROR, "%s", - _("Client's Distinguished Name is not on the list " - "of allowed clients (tls_allowed_dn_list). Use " - "'certtool -i --infile clientcert.pem' to view the" - "Distinguished Name field in the client certificate," - "or run this daemon with --verbose option.")); + virReportError(VIR_ERR_SYSTEM_ERROR, "%s", + _("Client's Distinguished Name is not on the list " + "of allowed clients (tls_allowed_dn_list). Use " + "'certtool -i --infile clientcert.pem' to view the" + "Distinguished Name field in the client certificate," + "or run this daemon with --verbose option.")); return 0; } @@ -392,9 +389,9 @@ virNetTLSContextCheckCertDN(gnutls_x509_crt_t cert, if (hostname && !gnutls_x509_crt_check_hostname(cert, hostname)) { - virNetError(VIR_ERR_RPC, - _("Certificate %s owner does not match the hostname %s"), - certFile, hostname); + virReportError(VIR_ERR_RPC, + _("Certificate %s owner does not match the hostname %s"), + certFile, hostname); return -1; } @@ -442,10 +439,10 @@ static int virNetTLSContextCheckCertPair(gnutls_x509_crt_t cert, &cacert, 1, NULL, 0, 0, &status) < 0) { - virNetError(VIR_ERR_SYSTEM_ERROR, isServer ? - _("Unable to verify server certificate %s against CA certificate %s") : - _("Unable to verify client certificate %s against CA certificate %s"), - certFile, cacertFile); + virReportError(VIR_ERR_SYSTEM_ERROR, isServer ? + _("Unable to verify server certificate %s against CA certificate %s") : + _("Unable to verify client certificate %s against CA certificate %s"), + certFile, cacertFile); return -1; } @@ -466,9 +463,9 @@ static int virNetTLSContextCheckCertPair(gnutls_x509_crt_t cert, reason = _("The certificate uses an insecure algorithm"); #endif - virNetError(VIR_ERR_SYSTEM_ERROR, - _("Our own certificate %s failed validation against %s: %s"), - certFile, cacertFile, reason); + virReportError(VIR_ERR_SYSTEM_ERROR, + _("Our own certificate %s failed validation against %s: %s"), + certFile, cacertFile, reason); return -1; } @@ -489,8 +486,8 @@ static gnutls_x509_crt_t virNetTLSContextLoadCertFromFile(const char *certFile, isServer, isCA, certFile); if (gnutls_x509_crt_init(&cert) < 0) { - virNetError(VIR_ERR_SYSTEM_ERROR, "%s", - _("Unable to initialize certificate")); + virReportError(VIR_ERR_SYSTEM_ERROR, "%s", + _("Unable to initialize certificate")); goto cleanup; } @@ -501,10 +498,10 @@ static gnutls_x509_crt_t virNetTLSContextLoadCertFromFile(const char *certFile, data.size = strlen(buf); if (gnutls_x509_crt_import(cert, &data, GNUTLS_X509_FMT_PEM) < 0) { - virNetError(VIR_ERR_SYSTEM_ERROR, isServer ? - _("Unable to import server certificate %s") : - _("Unable to import client certificate %s"), - certFile); + virReportError(VIR_ERR_SYSTEM_ERROR, isServer ? + _("Unable to import server certificate %s") : + _("Unable to import client certificate %s"), + certFile); goto cleanup; } @@ -577,9 +574,9 @@ static int virNetTLSContextLoadCredentials(virNetTLSContextPtr ctxt, cacert, GNUTLS_X509_FMT_PEM); if (err < 0) { - virNetError(VIR_ERR_SYSTEM_ERROR, - _("Unable to set x509 CA certificate: %s: %s"), - cacert, gnutls_strerror (err)); + virReportError(VIR_ERR_SYSTEM_ERROR, + _("Unable to set x509 CA certificate: %s: %s"), + cacert, gnutls_strerror (err)); goto cleanup; } } @@ -595,9 +592,9 @@ static int virNetTLSContextLoadCredentials(virNetTLSContextPtr ctxt, cacrl, GNUTLS_X509_FMT_PEM); if (err < 0) { - virNetError(VIR_ERR_SYSTEM_ERROR, - _("Unable to set x509 certificate revocation list: %s: %s"), - cacrl, gnutls_strerror(err)); + virReportError(VIR_ERR_SYSTEM_ERROR, + _("Unable to set x509 certificate revocation list: %s: %s"), + cacrl, gnutls_strerror(err)); goto cleanup; } } else { @@ -620,9 +617,9 @@ static int virNetTLSContextLoadCredentials(virNetTLSContextPtr ctxt, cert, key, GNUTLS_X509_FMT_PEM); if (err < 0) { - virNetError(VIR_ERR_SYSTEM_ERROR, - _("Unable to set x509 key and certificate: %s, %s: %s"), - key, cert, gnutls_strerror(err)); + virReportError(VIR_ERR_SYSTEM_ERROR, + _("Unable to set x509 key and certificate: %s, %s: %s"), + key, cert, gnutls_strerror(err)); goto cleanup; } } else { @@ -656,8 +653,8 @@ static virNetTLSContextPtr virNetTLSContextNew(const char *cacert, } if (virMutexInit(&ctxt->lock) < 0) { - virNetError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Failed to initialized mutex")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Failed to initialized mutex")); VIR_FREE(ctxt); return NULL; } @@ -676,9 +673,9 @@ static virNetTLSContextPtr virNetTLSContextNew(const char *cacert, err = gnutls_certificate_allocate_credentials(&ctxt->x509cred); if (err) { - virNetError(VIR_ERR_SYSTEM_ERROR, - _("Unable to allocate x509 credentials: %s"), - gnutls_strerror(err)); + virReportError(VIR_ERR_SYSTEM_ERROR, + _("Unable to allocate x509 credentials: %s"), + gnutls_strerror(err)); goto error; } @@ -697,16 +694,16 @@ static virNetTLSContextPtr virNetTLSContextNew(const char *cacert, if (isServer) { err = gnutls_dh_params_init(&ctxt->dhParams); if (err < 0) { - virNetError(VIR_ERR_SYSTEM_ERROR, - _("Unable to initialize diffie-hellman parameters: %s"), - gnutls_strerror(err)); + virReportError(VIR_ERR_SYSTEM_ERROR, + _("Unable to initialize diffie-hellman parameters: %s"), + gnutls_strerror(err)); goto error; } err = gnutls_dh_params_generate2(ctxt->dhParams, DH_BITS); if (err < 0) { - virNetError(VIR_ERR_SYSTEM_ERROR, - _("Unable to generate diffie-hellman parameters: %s"), - gnutls_strerror(err)); + virReportError(VIR_ERR_SYSTEM_ERROR, + _("Unable to generate diffie-hellman parameters: %s"), + gnutls_strerror(err)); goto error; } @@ -954,9 +951,9 @@ static int virNetTLSContextValidCertificate(virNetTLSContextPtr ctxt, memset(dname, 0, dnamesize); if ((ret = gnutls_certificate_verify_peers2(sess->session, &status)) < 0){ - virNetError(VIR_ERR_SYSTEM_ERROR, - _("Unable to verify TLS peer: %s"), - gnutls_strerror(ret)); + virReportError(VIR_ERR_SYSTEM_ERROR, + _("Unable to verify TLS peer: %s"), + gnutls_strerror(ret)); goto authdeny; } @@ -977,21 +974,21 @@ static int virNetTLSContextValidCertificate(virNetTLSContextPtr ctxt, reason = _("The certificate uses an insecure algorithm"); #endif - virNetError(VIR_ERR_SYSTEM_ERROR, - _("Certificate failed validation: %s"), - reason); + virReportError(VIR_ERR_SYSTEM_ERROR, + _("Certificate failed validation: %s"), + reason); goto authdeny; } if (gnutls_certificate_type_get(sess->session) != GNUTLS_CRT_X509) { - virNetError(VIR_ERR_SYSTEM_ERROR, "%s", - _("Only x509 certificates are supported")); + virReportError(VIR_ERR_SYSTEM_ERROR, "%s", + _("Only x509 certificates are supported")); goto authdeny; } if (!(certs = gnutls_certificate_get_peers(sess->session, &nCerts))) { - virNetError(VIR_ERR_SYSTEM_ERROR, "%s", - _("The certificate has no peers")); + virReportError(VIR_ERR_SYSTEM_ERROR, "%s", + _("The certificate has no peers")); goto authdeny; } @@ -999,14 +996,14 @@ static int virNetTLSContextValidCertificate(virNetTLSContextPtr ctxt, gnutls_x509_crt_t cert; if (gnutls_x509_crt_init(&cert) < 0) { - virNetError(VIR_ERR_SYSTEM_ERROR, "%s", - _("Unable to initialize certificate")); + virReportError(VIR_ERR_SYSTEM_ERROR, "%s", + _("Unable to initialize certificate")); goto authfail; } if (gnutls_x509_crt_import(cert, &certs[i], GNUTLS_X509_FMT_DER) < 0) { - virNetError(VIR_ERR_SYSTEM_ERROR, "%s", - _("Unable to load certificate")); + virReportError(VIR_ERR_SYSTEM_ERROR, "%s", + _("Unable to load certificate")); gnutls_x509_crt_deinit(cert); goto authfail; } @@ -1020,9 +1017,9 @@ static int virNetTLSContextValidCertificate(virNetTLSContextPtr ctxt, if (i == 0) { ret = gnutls_x509_crt_get_dn(cert, dname, &dnamesize); if (ret != 0) { - virNetError(VIR_ERR_SYSTEM_ERROR, - _("Failed to get certificate %s distinguished name: %s"), - "[session]", gnutls_strerror(ret)); + virReportError(VIR_ERR_SYSTEM_ERROR, + _("Failed to get certificate %s distinguished name: %s"), + "[session]", gnutls_strerror(ret)); goto authfail; } VIR_DEBUG("Peer DN is %s", dname); @@ -1092,8 +1089,8 @@ int virNetTLSContextCheckCertificate(virNetTLSContextPtr ctxt, virErrorPtr err = virGetLastError(); VIR_WARN("Certificate check failed %s", err && err->message ? err->message : "<unknown>"); if (ctxt->requireValidCert) { - virNetError(VIR_ERR_AUTH_FAILED, "%s", - _("Failed to verify peer's certificate")); + virReportError(VIR_ERR_AUTH_FAILED, "%s", + _("Failed to verify peer's certificate")); goto cleanup; } virResetLastError(); @@ -1176,8 +1173,8 @@ virNetTLSSessionPtr virNetTLSSessionNew(virNetTLSContextPtr ctxt, } if (virMutexInit(&sess->lock) < 0) { - virNetError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Failed to initialized mutex")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Failed to initialized mutex")); VIR_FREE(sess); return NULL; } @@ -1191,9 +1188,9 @@ virNetTLSSessionPtr virNetTLSSessionNew(virNetTLSContextPtr ctxt, if ((err = gnutls_init(&sess->session, ctxt->isServer ? GNUTLS_SERVER : GNUTLS_CLIENT)) != 0) { - virNetError(VIR_ERR_SYSTEM_ERROR, - _("Failed to initialize TLS session: %s"), - gnutls_strerror(err)); + virReportError(VIR_ERR_SYSTEM_ERROR, + _("Failed to initialize TLS session: %s"), + gnutls_strerror(err)); goto error; } @@ -1201,18 +1198,18 @@ virNetTLSSessionPtr virNetTLSSessionNew(virNetTLSContextPtr ctxt, * are adequate. */ if ((err = gnutls_set_default_priority(sess->session)) != 0) { - virNetError(VIR_ERR_SYSTEM_ERROR, - _("Failed to set TLS session priority %s"), - gnutls_strerror(err)); + virReportError(VIR_ERR_SYSTEM_ERROR, + _("Failed to set TLS session priority %s"), + gnutls_strerror(err)); goto error; } if ((err = gnutls_credentials_set(sess->session, GNUTLS_CRD_CERTIFICATE, ctxt->x509cred)) != 0) { - virNetError(VIR_ERR_SYSTEM_ERROR, - _("Failed set TLS x509 credentials: %s"), - gnutls_strerror(err)); + virReportError(VIR_ERR_SYSTEM_ERROR, + _("Failed set TLS x509 credentials: %s"), + gnutls_strerror(err)); goto error; } @@ -1352,9 +1349,9 @@ int virNetTLSSessionHandshake(virNetTLSSessionPtr sess) virNetServerClientGetFD(client)); #endif - virNetError(VIR_ERR_AUTH_FAILED, - _("TLS handshake failed %s"), - gnutls_strerror(ret)); + virReportError(VIR_ERR_AUTH_FAILED, + _("TLS handshake failed %s"), + gnutls_strerror(ret)); ret = -1; cleanup: @@ -1384,8 +1381,8 @@ int virNetTLSSessionGetKeySize(virNetTLSSessionPtr sess) virMutexLock(&sess->lock); cipher = gnutls_cipher_get(sess->session); if (!(ssf = gnutls_cipher_get_key_size(cipher))) { - virNetError(VIR_ERR_INTERNAL_ERROR, "%s", - _("invalid cipher size for TLS session")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("invalid cipher size for TLS session")); ssf = -1; goto cleanup; } -- 1.7.10.4

On 07/18/2012 05:52 AM, Daniel P. Berrange wrote:
From: "Daniel P. Berrange" <berrange@redhat.com>
This rmoves all the per-file error reporting macros
s/rmoves/removes/
from the code in src/rpc/
Signed-off-by: Daniel P. Berrange <berrange@redhat.com> ---
+++ b/src/rpc/virnetserver.c @@ -261,7 +258,7 @@ static int virNetServerDispatchNewClient(virNetServerServicePtr svc ATTRIBUTE_UN virNetServerLock(srv);
if (srv->nclients >= srv->nclients_max) { - virNetError(VIR_ERR_RPC, + virReportError(VIR_ERR_RPC, _("Too many active clients (%zu), dropping connection from %s"), srv->nclients_max, virNetServerClientRemoteAddrString(client));
Did you intentionally skip re-indenting this file? 4 of the 5 hunks you touched end up with odd indents.
+++ b/src/rpc/virnetserverclient.c @@ -775,7 +772,7 @@ static ssize_t virNetServerClientRead(virNetServerClientPtr client) ssize_t ret;
if (client->rx->bufferLength <= client->rx->bufferOffset) { - virNetError(VIR_ERR_RPC, + virReportError(VIR_ERR_RPC, _("unexpected zero/negative length request %lld"), (long long int)(client->rx->bufferLength - client->rx->bufferOffset));
And another missed reindent, 1 out of 2 hunks in this file.
+++ b/src/rpc/virnetservermdns.c @@ -367,8 +364,8 @@ static AvahiTimeout *virNetServerMDNSTimeoutNew(const AvahiPoll *api ATTRIBUTE_U t->userdata = userdata;
if (t->timer < 0) { - virNetError(VIR_ERR_INTERNAL_ERROR, - _("Failed to add timer with timeout %d"), (int)timeout); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Failed to add timer with timeout %d"), (int)timeout);
Why are we casting to int, instead of pairing this with %lld in the first place? ACK. Again, nits can be squashed here, or done as a separate patch. -- Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

On Wed, Jul 18, 2012 at 08:20:12AM -0600, Eric Blake wrote:
On 07/18/2012 05:52 AM, Daniel P. Berrange wrote:
From: "Daniel P. Berrange" <berrange@redhat.com>
This rmoves all the per-file error reporting macros
s/rmoves/removes/
from the code in src/rpc/
Signed-off-by: Daniel P. Berrange <berrange@redhat.com> ---
+++ b/src/rpc/virnetserver.c @@ -261,7 +258,7 @@ static int virNetServerDispatchNewClient(virNetServerServicePtr svc ATTRIBUTE_UN virNetServerLock(srv);
if (srv->nclients >= srv->nclients_max) { - virNetError(VIR_ERR_RPC, + virReportError(VIR_ERR_RPC, _("Too many active clients (%zu), dropping connection from %s"), srv->nclients_max, virNetServerClientRemoteAddrString(client));
Did you intentionally skip re-indenting this file? 4 of the 5 hunks you touched end up with odd indents.
+++ b/src/rpc/virnetserverclient.c @@ -775,7 +772,7 @@ static ssize_t virNetServerClientRead(virNetServerClientPtr client) ssize_t ret;
if (client->rx->bufferLength <= client->rx->bufferOffset) { - virNetError(VIR_ERR_RPC, + virReportError(VIR_ERR_RPC, _("unexpected zero/negative length request %lld"), (long long int)(client->rx->bufferLength - client->rx->bufferOffset));
And another missed reindent, 1 out of 2 hunks in this file.
+++ b/src/rpc/virnetservermdns.c @@ -367,8 +364,8 @@ static AvahiTimeout *virNetServerMDNSTimeoutNew(const AvahiPoll *api ATTRIBUTE_U t->userdata = userdata;
if (t->timer < 0) { - virNetError(VIR_ERR_INTERNAL_ERROR, - _("Failed to add timer with timeout %d"), (int)timeout); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Failed to add timer with timeout %d"), (int)timeout);
Why are we casting to int, instead of pairing this with %lld in the first place?
ACK. Again, nits can be squashed here, or done as a separate patch.
Fixed the indents, and did the %lld fix as a separate patch since it is pre-existing. Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|

From: "Daniel P. Berrange" <berrange@redhat.com> This rmoves all the per-file error reporting macros from the code in src/conf/ Signed-off-by: Daniel P. Berrange <berrange@redhat.com> --- cfg.mk | 4 - src/conf/cpu_conf.c | 224 ++- src/conf/domain_conf.c | 2347 +++++++++++++++-------------- src/conf/domain_event.c | 32 +- src/conf/interface_conf.c | 144 +- src/conf/netdev_bandwidth_conf.c | 20 +- src/conf/netdev_vport_profile_conf.c | 39 +- src/conf/network_conf.c | 272 ++-- src/conf/node_device_conf.c | 142 +- src/conf/node_device_conf.h | 3 - src/conf/nwfilter_conf.c | 138 +- src/conf/nwfilter_conf.h | 4 - src/conf/nwfilter_params.c | 78 +- src/conf/secret_conf.c | 58 +- src/conf/secret_conf.h | 4 - src/conf/storage_conf.c | 202 +-- src/conf/storage_conf.h | 4 - src/conf/storage_encryption_conf.c | 52 +- src/conf/virconsole.c | 11 +- src/node_device/node_device_driver.h | 4 + src/nwfilter/nwfilter_dhcpsnoop.c | 4 + src/nwfilter/nwfilter_driver.c | 3 + src/nwfilter/nwfilter_ebiptables_driver.c | 4 +- src/nwfilter/nwfilter_gentech_driver.c | 3 + src/nwfilter/nwfilter_learnipaddr.c | 3 + src/secret/secret_driver.c | 4 + src/storage/storage_backend.h | 4 + src/test/test_driver.c | 32 +- 28 files changed, 1912 insertions(+), 1927 deletions(-) diff --git a/cfg.mk b/cfg.mk index 3ae4c5a..0f62a89 100644 --- a/cfg.mk +++ b/cfg.mk @@ -513,7 +513,6 @@ msg_gen_function += PHYP_ERROR msg_gen_function += VIR_ERROR msg_gen_function += VMX_ERROR msg_gen_function += XENXS_ERROR -msg_gen_function += eventReportError msg_gen_function += interfaceReportError msg_gen_function += lxcError msg_gen_function += libxlError @@ -531,9 +530,7 @@ msg_gen_function += vah_warning msg_gen_function += vboxError msg_gen_function += virConfError msg_gen_function += virCPUReportError -msg_gen_function += virDomainReportError msg_gen_function += virGenericReportError -msg_gen_function += virInterfaceReportError msg_gen_function += virLibConnError msg_gen_function += virLibDomainError msg_gen_function += virLibDomainSnapshotError @@ -544,7 +541,6 @@ msg_gen_function += virLibNWFilterError msg_gen_function += virLibSecretError msg_gen_function += virLibStoragePoolError msg_gen_function += virLibStorageVolError -msg_gen_function += virNetworkReportError msg_gen_function += virNodeDeviceReportError msg_gen_function += virNWFilterReportError msg_gen_function += virRaiseError diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c index 7fe3c1e..175a7ed 100644 --- a/src/conf/cpu_conf.c +++ b/src/conf/cpu_conf.c @@ -32,10 +32,6 @@ #define VIR_FROM_THIS VIR_FROM_CPU -#define virCPUReportError(code, ...) \ - virReportErrorHelper(VIR_FROM_CPU, code, __FILE__, \ - __FUNCTION__, __LINE__, __VA_ARGS__) - VIR_ENUM_IMPL(virCPU, VIR_CPU_TYPE_LAST, "host", "guest", "auto") @@ -201,9 +197,9 @@ virCPUDefParseXML(const xmlNodePtr node, char *cpuMode; if (!xmlStrEqual(node->name, BAD_CAST "cpu")) { - virCPUReportError(VIR_ERR_INTERNAL_ERROR, - "%s", - _("XML does not contain expected 'cpu' element")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", + _("XML does not contain expected 'cpu' element")); return NULL; } @@ -215,9 +211,9 @@ virCPUDefParseXML(const xmlNodePtr node, if (mode == VIR_CPU_TYPE_AUTO) { if (virXPathBoolean("boolean(./arch)", ctxt)) { if (virXPathBoolean("boolean(./@match)", ctxt)) { - virCPUReportError(VIR_ERR_XML_ERROR, "%s", - _("'arch' element element cannot be used inside 'cpu'" - " element with 'match' attribute'")); + virReportError(VIR_ERR_XML_ERROR, "%s", + _("'arch' element element cannot be used inside 'cpu'" + " element with 'match' attribute'")); goto error; } def->type = VIR_CPU_TYPE_HOST; @@ -231,16 +227,16 @@ virCPUDefParseXML(const xmlNodePtr node, if ((cpuMode = virXMLPropString(node, "mode"))) { if (def->type == VIR_CPU_TYPE_HOST) { VIR_FREE(cpuMode); - virCPUReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("Attribute mode is only allowed for guest CPU")); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Attribute mode is only allowed for guest CPU")); goto error; } else { def->mode = virCPUModeTypeFromString(cpuMode); if (def->mode < 0) { - virCPUReportError(VIR_ERR_INTERNAL_ERROR, - _("Invalid mode attribute '%s'"), - cpuMode); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Invalid mode attribute '%s'"), + cpuMode); VIR_FREE(cpuMode); goto error; } @@ -266,8 +262,8 @@ virCPUDefParseXML(const xmlNodePtr node, VIR_FREE(match); if (def->match < 0) { - virCPUReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("Invalid match attribute for CPU specification")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("Invalid match attribute for CPU specification")); goto error; } } @@ -276,16 +272,16 @@ virCPUDefParseXML(const xmlNodePtr node, if (def->type == VIR_CPU_TYPE_HOST) { def->arch = virXPathString("string(./arch[1])", ctxt); if (!def->arch) { - virCPUReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("Missing CPU architecture")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("Missing CPU architecture")); goto error; } } if (!(def->model = virXPathString("string(./model[1])", ctxt)) && def->type == VIR_CPU_TYPE_HOST) { - virCPUReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("Missing CPU model name")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("Missing CPU model name")); goto error; } @@ -300,8 +296,8 @@ virCPUDefParseXML(const xmlNodePtr node, def->fallback = virCPUFallbackTypeFromString(fallback); VIR_FREE(fallback); if (def->fallback < 0) { - virCPUReportError(VIR_ERR_XML_ERROR, "%s", - _("Invalid fallback attribute")); + virReportError(VIR_ERR_XML_ERROR, "%s", + _("Invalid fallback attribute")); goto error; } } @@ -313,18 +309,18 @@ virCPUDefParseXML(const xmlNodePtr node, ctxt); if (!vendor_id || strlen(vendor_id) != VIR_CPU_VENDOR_ID_LENGTH) { - virCPUReportError(VIR_ERR_XML_ERROR, - _("vendor_id must be exactly" - " %d characters long"), - VIR_CPU_VENDOR_ID_LENGTH); + virReportError(VIR_ERR_XML_ERROR, + _("vendor_id must be exactly" + " %d characters long"), + VIR_CPU_VENDOR_ID_LENGTH); VIR_FREE(vendor_id); goto error; } /* ensure that the string can be passed to qemu*/ for (i = 0; i < strlen(vendor_id); i++) { if (vendor_id[i]==',') { - virCPUReportError(VIR_ERR_XML_ERROR, "%s", - _("vendor id is invalid")); + virReportError(VIR_ERR_XML_ERROR, "%s", + _("vendor id is invalid")); VIR_FREE(vendor_id); goto error; } @@ -336,8 +332,8 @@ virCPUDefParseXML(const xmlNodePtr node, def->vendor = virXPathString("string(./vendor[1])", ctxt); if (def->vendor && !def->model) { - virCPUReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("CPU vendor specified without CPU model")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("CPU vendor specified without CPU model")); goto error; } @@ -348,8 +344,8 @@ virCPUDefParseXML(const xmlNodePtr node, ret = virXPathULong("string(./topology[1]/@sockets)", ctxt, &ul); if (ret < 0) { - virCPUReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("Missing 'sockets' attribute in CPU topology")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("Missing 'sockets' attribute in CPU topology")); goto error; } def->sockets = (unsigned int) ul; @@ -357,8 +353,8 @@ virCPUDefParseXML(const xmlNodePtr node, ret = virXPathULong("string(./topology[1]/@cores)", ctxt, &ul); if (ret < 0) { - virCPUReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("Missing 'cores' attribute in CPU topology")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("Missing 'cores' attribute in CPU topology")); goto error; } def->cores = (unsigned int) ul; @@ -366,15 +362,15 @@ virCPUDefParseXML(const xmlNodePtr node, ret = virXPathULong("string(./topology[1]/@threads)", ctxt, &ul); if (ret < 0) { - virCPUReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("Missing 'threads' attribute in CPU topology")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("Missing 'threads' attribute in CPU topology")); goto error; } def->threads = (unsigned int) ul; if (!def->sockets || !def->cores || !def->threads) { - virCPUReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("Invalid CPU topology")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("Invalid CPU topology")); goto error; } } @@ -385,8 +381,8 @@ virCPUDefParseXML(const xmlNodePtr node, if (n > 0) { if (!def->model) { - virCPUReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("Non-empty feature list specified without CPU model")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("Non-empty feature list specified without CPU model")); goto error; } @@ -412,8 +408,8 @@ virCPUDefParseXML(const xmlNodePtr node, VIR_FREE(strpolicy); if (policy < 0) { - virCPUReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("Invalid CPU feature policy")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("Invalid CPU feature policy")); goto error; } } else { @@ -422,16 +418,16 @@ virCPUDefParseXML(const xmlNodePtr node, if (!(name = virXMLPropString(nodes[i], "name")) || *name == 0) { VIR_FREE(name); - virCPUReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("Invalid CPU feature name")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("Invalid CPU feature name")); goto error; } for (j = 0 ; j < i ; j++) { if (STREQ(name, def->features[j].name)) { - virCPUReportError(VIR_ERR_INTERNAL_ERROR, - _("CPU feature `%s' specified more than once"), - name); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("CPU feature `%s' specified more than once"), + name); VIR_FREE(name); goto error; } @@ -445,8 +441,8 @@ virCPUDefParseXML(const xmlNodePtr node, VIR_FREE(nodes); n = virXPathNodeSet("./numa[1]/cell", ctxt, &nodes); if (n <= 0) { - virCPUReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("NUMA topology defined without NUMA cells")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("NUMA topology defined without NUMA cells")); goto error; } @@ -464,8 +460,8 @@ virCPUDefParseXML(const xmlNodePtr node, def->cells[i].cellid = i; cpus = virXMLPropString(nodes[i], "cpus"); if (!cpus) { - virCPUReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("Missing 'cpus' attribute in NUMA cell")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("Missing 'cpus' attribute in NUMA cell")); goto error; } def->cells[i].cpustr = cpus; @@ -481,15 +477,15 @@ virCPUDefParseXML(const xmlNodePtr node, memory = virXMLPropString(nodes[i], "memory"); if (!memory) { - virCPUReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("Missing 'memory' attribute in NUMA cell")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("Missing 'memory' attribute in NUMA cell")); goto error; } ret = virStrToLong_ui(memory, NULL, 10, &def->cells[i].mem); if (ret == -1) { - virCPUReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("Invalid 'memory' attribute in NUMA cell")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("Invalid 'memory' attribute in NUMA cell")); VIR_FREE(memory); goto error; } @@ -547,8 +543,8 @@ virCPUDefFormatBufFull(virBufferPtr buf, if (def->mode != VIR_CPU_MODE_CUSTOM || def->model) { if (!(tmp = virCPUModeTypeToString(def->mode))) { - virCPUReportError(VIR_ERR_INTERNAL_ERROR, - _("Unexpected CPU mode %d"), def->mode); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Unexpected CPU mode %d"), def->mode); return -1; } virBufferAsprintf(buf, " mode='%s'", tmp); @@ -558,9 +554,9 @@ virCPUDefFormatBufFull(virBufferPtr buf, (def->mode == VIR_CPU_MODE_CUSTOM || (flags & VIR_DOMAIN_XML_UPDATE_CPU))) { if (!(tmp = virCPUMatchTypeToString(def->match))) { - virCPUReportError(VIR_ERR_INTERNAL_ERROR, - _("Unexpected CPU match policy %d"), - def->match); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Unexpected CPU match policy %d"), + def->match); return -1; } virBufferAsprintf(buf, " match='%s'", tmp); @@ -600,8 +596,8 @@ virCPUDefFormatBuf(virBufferPtr buf, (def->mode == VIR_CPU_MODE_CUSTOM && def->model))); if (!def->model && def->nfeatures) { - virCPUReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("Non-empty feature list specified without CPU model")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("Non-empty feature list specified without CPU model")); return -1; } @@ -612,9 +608,9 @@ virCPUDefFormatBuf(virBufferPtr buf, fallback = virCPUFallbackTypeToString(def->fallback); if (!fallback) { - virCPUReportError(VIR_ERR_INTERNAL_ERROR, - _("Unexpected CPU fallback value: %d"), - def->fallback); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Unexpected CPU fallback value: %d"), + def->fallback); return -1; } virBufferAsprintf(buf, " fallback='%s'", fallback); @@ -644,8 +640,8 @@ virCPUDefFormatBuf(virBufferPtr buf, virCPUFeatureDefPtr feature = def->features + i; if (!feature->name) { - virCPUReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("Missing CPU feature name")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("Missing CPU feature name")); return -1; } @@ -654,9 +650,9 @@ virCPUDefFormatBuf(virBufferPtr buf, policy = virCPUFeaturePolicyTypeToString(feature->policy); if (!policy) { - virCPUReportError(VIR_ERR_INTERNAL_ERROR, - _("Unexpected CPU feature policy %d"), - feature->policy); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Unexpected CPU feature policy %d"), + feature->policy); return -1; } virBufferAsprintf(buf, "<feature policy='%s' name='%s'/>\n", @@ -691,8 +687,8 @@ virCPUDefAddFeature(virCPUDefPtr def, for (i = 0 ; i < def->nfeatures ; i++) { if (STREQ(name, def->features[i].name)) { - virCPUReportError(VIR_ERR_INTERNAL_ERROR, - _("CPU feature `%s' specified more than once"), name); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("CPU feature `%s' specified more than once"), name); return -1; } } @@ -728,96 +724,96 @@ virCPUDefIsEqual(virCPUDefPtr src, return true; if ((src && !dst) || (!src && dst)) { - virCPUReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("Target CPU does not match source")); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Target CPU does not match source")); goto cleanup; } if (src->type != dst->type) { - virCPUReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Target CPU type %s does not match source %s"), - virCPUTypeToString(dst->type), - virCPUTypeToString(src->type)); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target CPU type %s does not match source %s"), + virCPUTypeToString(dst->type), + virCPUTypeToString(src->type)); goto cleanup; } if (src->mode != dst->mode) { - virCPUReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Target CPU mode %s does not match source %s"), - virCPUModeTypeToString(dst->mode), - virCPUModeTypeToString(src->mode)); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target CPU mode %s does not match source %s"), + virCPUModeTypeToString(dst->mode), + virCPUModeTypeToString(src->mode)); goto cleanup; } if (STRNEQ_NULLABLE(src->arch, dst->arch)) { - virCPUReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Target CPU arch %s does not match source %s"), - NULLSTR(dst->arch), NULLSTR(src->arch)); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target CPU arch %s does not match source %s"), + NULLSTR(dst->arch), NULLSTR(src->arch)); goto cleanup; } if (STRNEQ_NULLABLE(src->model, dst->model)) { - virCPUReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Target CPU model %s does not match source %s"), - NULLSTR(dst->model), NULLSTR(src->model)); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target CPU model %s does not match source %s"), + NULLSTR(dst->model), NULLSTR(src->model)); goto cleanup; } if (STRNEQ_NULLABLE(src->vendor, dst->vendor)) { - virCPUReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Target CPU vendor %s does not match source %s"), - NULLSTR(dst->vendor), NULLSTR(src->vendor)); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target CPU vendor %s does not match source %s"), + NULLSTR(dst->vendor), NULLSTR(src->vendor)); goto cleanup; } if (STRNEQ_NULLABLE(src->vendor_id, dst->vendor_id)) { - virCPUReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Target CPU model %s does not match source %s"), - NULLSTR(dst->vendor_id), NULLSTR(src->vendor_id)); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target CPU model %s does not match source %s"), + NULLSTR(dst->vendor_id), NULLSTR(src->vendor_id)); goto cleanup; } if (src->sockets != dst->sockets) { - virCPUReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Target CPU sockets %d does not match source %d"), - dst->sockets, src->sockets); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target CPU sockets %d does not match source %d"), + dst->sockets, src->sockets); goto cleanup; } if (src->cores != dst->cores) { - virCPUReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Target CPU cores %d does not match source %d"), - dst->cores, src->cores); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target CPU cores %d does not match source %d"), + dst->cores, src->cores); goto cleanup; } if (src->threads != dst->threads) { - virCPUReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Target CPU threads %d does not match source %d"), - dst->threads, src->threads); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target CPU threads %d does not match source %d"), + dst->threads, src->threads); goto cleanup; } if (src->nfeatures != dst->nfeatures) { - virCPUReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Target CPU feature count %zu does not match source %zu"), - dst->nfeatures, src->nfeatures); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target CPU feature count %zu does not match source %zu"), + dst->nfeatures, src->nfeatures); goto cleanup; } for (i = 0 ; i < src->nfeatures ; i++) { if (STRNEQ(src->features[i].name, dst->features[i].name)) { - virCPUReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Target CPU feature %s does not match source %s"), - dst->features[i].name, src->features[i].name); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target CPU feature %s does not match source %s"), + dst->features[i].name, src->features[i].name); goto cleanup; } if (src->features[i].policy != dst->features[i].policy) { - virCPUReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Target CPU feature policy %s does not match source %s"), - virCPUFeaturePolicyTypeToString(dst->features[i].policy), - virCPUFeaturePolicyTypeToString(src->features[i].policy)); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target CPU feature policy %s does not match source %s"), + virCPUFeaturePolicyTypeToString(dst->features[i].policy), + virCPUFeaturePolicyTypeToString(src->features[i].policy)); goto cleanup; } } diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 398f630..1b5dad9 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -655,10 +655,6 @@ VIR_ENUM_IMPL(virDomainNumatuneMemPlacementMode, "static", "auto"); -#define virDomainReportError(code, ...) \ - virReportErrorHelper(VIR_FROM_DOMAIN, code, __FILE__, \ - __FUNCTION__, __LINE__, __VA_ARGS__) - #define VIR_DOMAIN_XML_WRITE_FLAGS VIR_DOMAIN_XML_SECURE #define VIR_DOMAIN_XML_READ_FLAGS VIR_DOMAIN_XML_INACTIVE @@ -699,9 +695,9 @@ virDomainBlkioDeviceWeightParseXML(xmlNodePtr root, } else if (xmlStrEqual(node->name, BAD_CAST "weight")) { c = (char *)xmlNodeGetContent(node); if (virStrToLong_ui(c, NULL, 10, &dw->weight) < 0) { - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("could not parse weight %s"), - c); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("could not parse weight %s"), + c); VIR_FREE(c); VIR_FREE(dw->path); return -1; @@ -712,8 +708,8 @@ virDomainBlkioDeviceWeightParseXML(xmlNodePtr root, node = node->next; } if (!dw->path) { - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("missing per-device path")); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("missing per-device path")); return -1; } @@ -1697,8 +1693,8 @@ static virDomainObjPtr virDomainObjNew(virCapsPtr caps) domain->privateDataFreeFunc = caps->privateDataFreeFunc; if (virMutexInit(&domain->lock) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("cannot initialize mutex")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("cannot initialize mutex")); if (domain->privateDataFreeFunc) (domain->privateDataFreeFunc)(domain->privateData); VIR_FREE(domain); @@ -1854,21 +1850,21 @@ virDomainLiveConfigHelperMethod(virCapsPtr caps, } if (!isActive && (*flags & VIR_DOMAIN_AFFECT_LIVE)) { - virDomainReportError(VIR_ERR_OPERATION_INVALID, "%s", - _("domain is not running")); + virReportError(VIR_ERR_OPERATION_INVALID, "%s", + _("domain is not running")); goto cleanup; } if (*flags & VIR_DOMAIN_AFFECT_CONFIG) { if (!dom->persistent) { - virDomainReportError(VIR_ERR_OPERATION_INVALID, "%s", - _("cannot change persistent config of a " - "transient domain")); + virReportError(VIR_ERR_OPERATION_INVALID, "%s", + _("cannot change persistent config of a " + "transient domain")); goto cleanup; } if (!(*persistentDef = virDomainObjGetPersistentDef(caps, dom))) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Get persistent config failed")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Get persistent config failed")); goto cleanup; } } @@ -2121,9 +2117,9 @@ virDomainDeviceInfoFormat(virBufferPtr buf, const char *rombar = virDomainPciRombarModeTypeToString(info->rombar); if (!rombar) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected rom bar value %d"), - info->rombar); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected rom bar value %d"), + info->rombar); return -1; } virBufferAsprintf(buf, " bar='%s'", rombar); @@ -2187,8 +2183,8 @@ virDomainDeviceInfoFormat(virBufferPtr buf, break; default: - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("unknown address type '%d'"), info->type); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unknown address type '%d'"), info->type); return -1; } @@ -2214,43 +2210,43 @@ virDomainDevicePCIAddressParseXML(xmlNodePtr node, if (domain && virStrToLong_ui(domain, NULL, 0, &addr->domain) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Cannot parse <address> 'domain' attribute")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Cannot parse <address> 'domain' attribute")); goto cleanup; } if (bus && virStrToLong_ui(bus, NULL, 0, &addr->bus) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Cannot parse <address> 'bus' attribute")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Cannot parse <address> 'bus' attribute")); goto cleanup; } if (slot && virStrToLong_ui(slot, NULL, 0, &addr->slot) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Cannot parse <address> 'slot' attribute")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Cannot parse <address> 'slot' attribute")); goto cleanup; } if (function && virStrToLong_ui(function, NULL, 0, &addr->function) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Cannot parse <address> 'function' attribute")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Cannot parse <address> 'function' attribute")); goto cleanup; } if (multi && ((addr->multi = virDomainDeviceAddressPciMultiTypeFromString(multi)) <= 0)) { - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Unknown value '%s' for <address> 'multifunction' attribute"), - multi); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Unknown value '%s' for <address> 'multifunction' attribute"), + multi); goto cleanup; } if (!virDomainDevicePCIAddressIsValid(addr)) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Insufficient specification for PCI address")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Insufficient specification for PCI address")); goto cleanup; } @@ -2282,29 +2278,29 @@ virDomainDeviceDriveAddressParseXML(xmlNodePtr node, if (controller && virStrToLong_ui(controller, NULL, 10, &addr->controller) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Cannot parse <address> 'controller' attribute")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Cannot parse <address> 'controller' attribute")); goto cleanup; } if (bus && virStrToLong_ui(bus, NULL, 10, &addr->bus) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Cannot parse <address> 'bus' attribute")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Cannot parse <address> 'bus' attribute")); goto cleanup; } if (target && virStrToLong_ui(target, NULL, 10, &addr->target) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Cannot parse <address> 'target' attribute")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Cannot parse <address> 'target' attribute")); goto cleanup; } if (unit && virStrToLong_ui(unit, NULL, 10, &addr->unit) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Cannot parse <address> 'unit' attribute")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Cannot parse <address> 'unit' attribute")); goto cleanup; } @@ -2336,22 +2332,22 @@ virDomainDeviceVirtioSerialAddressParseXML( if (controller && virStrToLong_ui(controller, NULL, 10, &addr->controller) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Cannot parse <address> 'controller' attribute")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Cannot parse <address> 'controller' attribute")); goto cleanup; } if (bus && virStrToLong_ui(bus, NULL, 10, &addr->bus) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Cannot parse <address> 'bus' attribute")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Cannot parse <address> 'bus' attribute")); goto cleanup; } if (port && virStrToLong_ui(port, NULL, 10, &addr->port) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Cannot parse <address> 'port' attribute")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Cannot parse <address> 'port' attribute")); goto cleanup; } @@ -2378,15 +2374,15 @@ virDomainDeviceCcidAddressParseXML(xmlNodePtr node, if (controller && virStrToLong_ui(controller, NULL, 10, &addr->controller) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Cannot parse <address> 'controller' attribute")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Cannot parse <address> 'controller' attribute")); goto cleanup; } if (slot && virStrToLong_ui(slot, NULL, 10, &addr->slot) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Cannot parse <address> 'slot' attribute")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Cannot parse <address> 'slot' attribute")); goto cleanup; } @@ -2416,8 +2412,8 @@ virDomainDeviceUSBAddressParseXML(xmlNodePtr node, (*tmp == '.' && (virStrToLong_ui(tmp + 1, &tmp, 10, &p) < 0 || (*tmp != '\0' && *tmp != '.'))) || (*tmp == '.' && (virStrToLong_ui(tmp + 1, &tmp, 10, &p) < 0 || (*tmp != '\0' && *tmp != '.'))) || (*tmp == '.' && (virStrToLong_ui(tmp + 1, &tmp, 10, &p) < 0 || (*tmp != '\0'))))) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Cannot parse <address> 'port' attribute")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Cannot parse <address> 'port' attribute")); goto cleanup; } @@ -2426,8 +2422,8 @@ virDomainDeviceUSBAddressParseXML(xmlNodePtr node, if (bus && virStrToLong_ui(bus, NULL, 10, &addr->bus) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Cannot parse <address> 'bus' attribute")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Cannot parse <address> 'bus' attribute")); goto cleanup; } @@ -2451,8 +2447,8 @@ virDomainDeviceSpaprVioAddressParseXML(xmlNodePtr node, reg = virXMLPropString(node, "reg"); if (reg) { if (virStrToLong_ull(reg, NULL, 16, &addr->reg) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Cannot parse <address> 'reg' attribute")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Cannot parse <address> 'reg' attribute")); ret = -1; goto cleanup; } @@ -2479,8 +2475,8 @@ virDomainDeviceUSBMasterParseXML(xmlNodePtr node, if (startport && virStrToLong_ui(startport, NULL, 10, &master->startport) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Cannot parse <master> 'startport' attribute")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Cannot parse <master> 'startport' attribute")); goto cleanup; } @@ -2502,26 +2498,26 @@ virDomainDeviceBootParseXML(xmlNodePtr node, order = virXMLPropString(node, "order"); if (!order) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("missing boot order attribute")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("missing boot order attribute")); goto cleanup; } else if (virStrToLong_i(order, NULL, 10, &boot) < 0 || boot <= 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("incorrect boot order '%s', expecting positive integer"), - order); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("incorrect boot order '%s', expecting positive integer"), + order); goto cleanup; } if (bootMap) { bool set; if (virBitmapGetBit(bootMap, boot - 1, &set) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("boot orders have to be contiguous and starting from 1")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("boot orders have to be contiguous and starting from 1")); goto cleanup; } else if (set) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("boot order %d used for more than one device"), boot); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("boot order %d used for more than one device"), boot); goto cleanup; } ignore_value(virBitmapSetBit(bootMap, boot - 1)); @@ -2599,8 +2595,8 @@ virDomainDeviceInfoParseXML(xmlNodePtr node, char *rombar = virXMLPropString(rom, "bar"); if (rombar && ((info->rombar = virDomainPciRombarModeTypeFromString(rombar)) <= 0)) { - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown rom bar value '%s'"), rombar); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unknown rom bar value '%s'"), rombar); VIR_FREE(rombar); goto cleanup; } @@ -2615,13 +2611,13 @@ virDomainDeviceInfoParseXML(xmlNodePtr node, if (type) { if ((info->type = virDomainDeviceAddressTypeFromString(type)) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("unknown address type '%s'"), type); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unknown address type '%s'"), type); goto cleanup; } } else { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("No type specified for device address")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("No type specified for device address")); goto cleanup; } @@ -2659,8 +2655,8 @@ virDomainDeviceInfoParseXML(xmlNodePtr node, default: /* Should not happen */ - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("Unknown device address type")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("Unknown device address type")); goto cleanup; } @@ -2715,15 +2711,15 @@ virDomainHostdevSubsysUsbDefParseXML(const xmlNodePtr node, got_vendor = 1; if (virStrToLong_ui(vendor, NULL, 0, &def->source.subsys.u.usb.vendor) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("cannot parse vendor id %s"), vendor); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("cannot parse vendor id %s"), vendor); VIR_FREE(vendor); goto out; } VIR_FREE(vendor); } else { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("usb vendor needs id")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("usb vendor needs id")); goto out; } } else if (xmlStrEqual(cur->name, BAD_CAST "product")) { @@ -2733,16 +2729,16 @@ virDomainHostdevSubsysUsbDefParseXML(const xmlNodePtr node, got_product = 1; if (virStrToLong_ui(product, NULL, 0, &def->source.subsys.u.usb.product) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("cannot parse product %s"), - product); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("cannot parse product %s"), + product); VIR_FREE(product); goto out; } VIR_FREE(product); } else { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("usb product needs id")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("usb product needs id")); goto out; } } else if (xmlStrEqual(cur->name, BAD_CAST "address")) { @@ -2752,15 +2748,15 @@ virDomainHostdevSubsysUsbDefParseXML(const xmlNodePtr node, if (bus) { if (virStrToLong_ui(bus, NULL, 0, &def->source.subsys.u.usb.bus) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("cannot parse bus %s"), bus); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("cannot parse bus %s"), bus); VIR_FREE(bus); goto out; } VIR_FREE(bus); } else { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("usb address needs bus id")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("usb address needs bus id")); goto out; } @@ -2768,22 +2764,22 @@ virDomainHostdevSubsysUsbDefParseXML(const xmlNodePtr node, if (device) { if (virStrToLong_ui(device, NULL, 0, &def->source.subsys.u.usb.device) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("cannot parse device %s"), - device); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("cannot parse device %s"), + device); VIR_FREE(device); goto out; } VIR_FREE(device); } else { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("usb address needs device id")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("usb address needs device id")); goto out; } } else { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("unknown usb source type '%s'"), - cur->name); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unknown usb source type '%s'"), + cur->name); goto out; } } @@ -2791,19 +2787,19 @@ virDomainHostdevSubsysUsbDefParseXML(const xmlNodePtr node, } if (got_vendor && def->source.subsys.u.usb.vendor == 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("vendor cannot be 0.")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("vendor cannot be 0.")); goto out; } if (!got_vendor && got_product) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("missing vendor")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("missing vendor")); goto out; } if (got_vendor && !got_product) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("missing product")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("missing product")); goto out; } @@ -2836,9 +2832,9 @@ virDomainHostdevSubsysPciOrigStatesDefParseXML(const xmlNodePtr node, } else if (xmlStrEqual(cur->name, BAD_CAST "reprobe")) { def->states.pci.reprobe = 1; } else { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("unsupported element '%s' of 'origstates'"), - cur->name); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unsupported element '%s' of 'origstates'"), + cur->name); return -1; } } @@ -2872,9 +2868,9 @@ virDomainHostdevSubsysPciDefParseXML(const xmlNodePtr node, if (devaddr && virDomainParseLegacyDeviceAddress(devaddr, &def->info->addr.pci) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("Unable to parse devaddr parameter '%s'"), - devaddr); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Unable to parse devaddr parameter '%s'"), + devaddr); VIR_FREE(devaddr); goto out; } @@ -2885,9 +2881,9 @@ virDomainHostdevSubsysPciDefParseXML(const xmlNodePtr node, if (virDomainHostdevSubsysPciOrigStatesDefParseXML(cur, states) < 0) goto out; } else { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("unknown pci source type '%s'"), - cur->name); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unknown pci source type '%s'"), + cur->name); goto out; } } @@ -2917,8 +2913,8 @@ virDomainHostdevPartsParse(xmlNodePtr node, */ if (mode) { if ((def->mode=virDomainHostdevModeTypeFromString(mode)) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("unknown hostdev mode '%s'"), mode); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unknown hostdev mode '%s'"), mode); goto error; } } else { @@ -2946,20 +2942,20 @@ virDomainHostdevPartsParse(xmlNodePtr node, if (type) { if ((def->source.subsys.type = virDomainHostdevSubsysTypeFromString(type)) < 0) { - virDomainReportError(VIR_ERR_XML_ERROR, - _("unknown host device source address type '%s'"), - type); + virReportError(VIR_ERR_XML_ERROR, + _("unknown host device source address type '%s'"), + type); goto error; } } else { - virDomainReportError(VIR_ERR_XML_ERROR, - "%s", _("missing source address type")); + virReportError(VIR_ERR_XML_ERROR, + "%s", _("missing source address type")); goto error; } if (!(sourcenode = virXPathNode("./source", ctxt))) { - virDomainReportError(VIR_ERR_XML_ERROR, "%s", - _("Missing <source> element in hostdev device")); + virReportError(VIR_ERR_XML_ERROR, "%s", + _("Missing <source> element in hostdev device")); goto error; } switch (def->source.subsys.type) { @@ -2972,9 +2968,9 @@ virDomainHostdevPartsParse(xmlNodePtr node, goto error; break; default: - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("address type='%s' not supported in hostdev interfaces"), - virDomainHostdevSubsysTypeToString(def->source.subsys.type)); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("address type='%s' not supported in hostdev interfaces"), + virDomainHostdevSubsysTypeToString(def->source.subsys.type)); goto error; } ret = 0; @@ -3088,8 +3084,8 @@ virSecurityLabelDefParseXML(virSecurityLabelDefPtr def, def->type = virDomainSeclabelTypeFromString(p); VIR_FREE(p); if (def->type <= 0) { - virDomainReportError(VIR_ERR_XML_ERROR, - "%s", _("invalid security type")); + virReportError(VIR_ERR_XML_ERROR, + "%s", _("invalid security type")); goto error; } } @@ -3102,22 +3098,22 @@ virSecurityLabelDefParseXML(virSecurityLabelDefPtr def, } else if (STREQ(p, "no")) { def->norelabel = true; } else { - virDomainReportError(VIR_ERR_XML_ERROR, - _("invalid security relabel value %s"), p); + virReportError(VIR_ERR_XML_ERROR, + _("invalid security relabel value %s"), p); VIR_FREE(p); goto error; } VIR_FREE(p); if (def->type == VIR_DOMAIN_SECLABEL_DYNAMIC && def->norelabel) { - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, - "%s", _("dynamic label type must use resource relabeling")); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + "%s", _("dynamic label type must use resource relabeling")); goto error; } if (def->type == VIR_DOMAIN_SECLABEL_NONE && !def->norelabel) { - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, - "%s", _("resource relabeling is not compatible with 'none' label type")); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + "%s", _("resource relabeling is not compatible with 'none' label type")); goto error; } } else { @@ -3137,8 +3133,8 @@ virSecurityLabelDefParseXML(virSecurityLabelDefPtr def, p = virXPathStringLimit("string(./seclabel/label[1])", VIR_SECURITY_LABEL_BUFLEN-1, ctxt); if (p == NULL) { - virDomainReportError(VIR_ERR_XML_ERROR, - "%s", _("security label is missing")); + virReportError(VIR_ERR_XML_ERROR, + "%s", _("security label is missing")); goto error; } @@ -3152,8 +3148,8 @@ virSecurityLabelDefParseXML(virSecurityLabelDefPtr def, p = virXPathStringLimit("string(./seclabel/imagelabel[1])", VIR_SECURITY_LABEL_BUFLEN-1, ctxt); if (p == NULL) { - virDomainReportError(VIR_ERR_XML_ERROR, - "%s", _("security imagelabel is missing")); + virReportError(VIR_ERR_XML_ERROR, + "%s", _("security imagelabel is missing")); goto error; } def->imagelabel = p; @@ -3176,8 +3172,8 @@ virSecurityLabelDefParseXML(virSecurityLabelDefPtr def, p = virXPathStringLimit("string(./seclabel/@model)", VIR_SECURITY_MODEL_BUFLEN-1, ctxt); if (p == NULL) { - virDomainReportError(VIR_ERR_XML_ERROR, - "%s", _("missing security model")); + virReportError(VIR_ERR_XML_ERROR, + "%s", _("missing security model")); goto error; } def->model = p; @@ -3205,9 +3201,9 @@ virSecurityDeviceLabelDefParseXML(virSecurityDeviceLabelDefPtr *def, /* Can't use overrides if top-level doesn't allow relabeling. */ if (vmDef && vmDef->norelabel) { - virDomainReportError(VIR_ERR_XML_ERROR, "%s", - _("label overrides require relabeling to be " - "enabled at the domain level")); + virReportError(VIR_ERR_XML_ERROR, "%s", + _("label overrides require relabeling to be " + "enabled at the domain level")); return -1; } @@ -3224,8 +3220,8 @@ virSecurityDeviceLabelDefParseXML(virSecurityDeviceLabelDefPtr *def, } else if (STREQ(p, "no")) { (*def)->norelabel = true; } else { - virDomainReportError(VIR_ERR_XML_ERROR, - _("invalid security relabel value %s"), p); + virReportError(VIR_ERR_XML_ERROR, + _("invalid security relabel value %s"), p); VIR_FREE(p); VIR_FREE(*def); return -1; @@ -3240,8 +3236,8 @@ virSecurityDeviceLabelDefParseXML(virSecurityDeviceLabelDefPtr *def, (*def)->label = p; if ((*def)->label && (*def)->norelabel) { - virDomainReportError(VIR_ERR_XML_ERROR, - _("Cannot specify a label if relabelling is turned off")); + virReportError(VIR_ERR_XML_ERROR, + _("Cannot specify a label if relabelling is turned off")); VIR_FREE((*def)->label); VIR_FREE(*def); return -1; @@ -3286,20 +3282,20 @@ virDomainLeaseDefParseXML(xmlNodePtr node) } if (!key) { - virDomainReportError(VIR_ERR_XML_ERROR, "%s", - _("Missing 'key' element for lease")); + virReportError(VIR_ERR_XML_ERROR, "%s", + _("Missing 'key' element for lease")); goto error; } if (!path) { - virDomainReportError(VIR_ERR_XML_ERROR, "%s", - _("Missing 'target' element for lease")); + virReportError(VIR_ERR_XML_ERROR, "%s", + _("Missing 'target' element for lease")); goto error; } if (offset && virStrToLong_ull(offset, NULL, 10, &def->offset) < 0) { - virDomainReportError(VIR_ERR_XML_ERROR, - _("Malformed lease target offset %s"), offset); + virReportError(VIR_ERR_XML_ERROR, + _("Malformed lease target offset %s"), offset); goto error; } @@ -3380,8 +3376,8 @@ virDomainDiskDefParseXML(virCapsPtr caps, type = virXMLPropString(node, "type"); if (type) { if ((def->type = virDomainDiskTypeFromString(type)) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("unknown disk type '%s'"), type); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unknown disk type '%s'"), type); goto error; } } else { @@ -3414,21 +3410,21 @@ virDomainDiskDefParseXML(virCapsPtr caps, case VIR_DOMAIN_DISK_TYPE_NETWORK: protocol = virXMLPropString(cur, "protocol"); if (protocol == NULL) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("missing protocol type")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("missing protocol type")); goto error; } def->protocol = virDomainDiskProtocolTypeFromString(protocol); if (def->protocol < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("unknown protocol type '%s'"), - protocol); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unknown protocol type '%s'"), + protocol); goto error; } if (!(source = virXMLPropString(cur, "name")) && def->protocol != VIR_DOMAIN_DISK_PROTOCOL_NBD) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("missing name for disk source")); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("missing name for disk source")); goto error; } child = cur->children; @@ -3445,14 +3441,14 @@ virDomainDiskDefParseXML(virCapsPtr caps, hosts[nhosts - 1].name = virXMLPropString(child, "name"); if (!hosts[nhosts - 1].name) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("missing name for host")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("missing name for host")); goto error; } hosts[nhosts - 1].port = virXMLPropString(child, "port"); if (!hosts[nhosts - 1].port) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("missing port for host")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("missing port for host")); goto error; } } @@ -3460,9 +3456,9 @@ virDomainDiskDefParseXML(virCapsPtr caps, } break; default: - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected disk type %s"), - virDomainDiskTypeToString(def->type)); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected disk type %s"), + virDomainDiskTypeToString(def->type)); goto error; } @@ -3500,8 +3496,8 @@ virDomainDiskDefParseXML(virCapsPtr caps, char *ready; mirror = virXMLPropString(cur, "file"); if (!mirror) { - virDomainReportError(VIR_ERR_XML_ERROR, "%s", - _("mirror requires file name")); + virReportError(VIR_ERR_XML_ERROR, "%s", + _("mirror requires file name")); goto error; } mirrorFormat = virXMLPropString(cur, "format"); @@ -3513,8 +3509,8 @@ virDomainDiskDefParseXML(virCapsPtr caps, } else if (xmlStrEqual(cur->name, BAD_CAST "auth")) { authUsername = virXMLPropString(cur, "username"); if (authUsername == NULL) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("missing username for auth")); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("missing username for auth")); goto error; } @@ -3525,15 +3521,15 @@ virDomainDiskDefParseXML(virCapsPtr caps, xmlStrEqual(child->name, BAD_CAST "secret")) { usageType = virXMLPropString(child, "type"); if (usageType == NULL) { - virDomainReportError(VIR_ERR_XML_ERROR, - _("missing type for secret")); + virReportError(VIR_ERR_XML_ERROR, + _("missing type for secret")); goto error; } if (virSecretUsageTypeTypeFromString(usageType) != VIR_SECRET_USAGE_TYPE_CEPH) { - virDomainReportError(VIR_ERR_XML_ERROR, - _("invalid secret type %s"), - usageType); + virReportError(VIR_ERR_XML_ERROR, + _("invalid secret type %s"), + usageType); goto error; } @@ -3541,17 +3537,17 @@ virDomainDiskDefParseXML(virCapsPtr caps, authUsage = virXMLPropString(child, "usage"); if (authUUID != NULL && authUsage != NULL) { - virDomainReportError(VIR_ERR_XML_ERROR, - _("only one of uuid and usage can be specified")); + virReportError(VIR_ERR_XML_ERROR, + _("only one of uuid and usage can be specified")); goto error; } if (authUUID != NULL) { def->auth.secretType = VIR_DOMAIN_DISK_SECRET_TYPE_UUID; if (virUUIDParse(authUUID, def->auth.secret.uuid) < 0) { - virDomainReportError(VIR_ERR_XML_ERROR, - _("malformed uuid %s"), - authUUID); + virReportError(VIR_ERR_XML_ERROR, + _("malformed uuid %s"), + authUUID); goto error; } } else if (authUsage != NULL) { @@ -3603,9 +3599,9 @@ virDomainDiskDefParseXML(virCapsPtr caps, def->blkdeviotune.read_bytes_sec) || (def->blkdeviotune.total_bytes_sec && def->blkdeviotune.write_bytes_sec)) { - virDomainReportError(VIR_ERR_XML_ERROR, - _("total and read/write bytes_sec " - "cannot be set at the same time")); + virReportError(VIR_ERR_XML_ERROR, + _("total and read/write bytes_sec " + "cannot be set at the same time")); goto error; } @@ -3613,9 +3609,9 @@ virDomainDiskDefParseXML(virCapsPtr caps, def->blkdeviotune.read_iops_sec) || (def->blkdeviotune.total_iops_sec && def->blkdeviotune.write_iops_sec)) { - virDomainReportError(VIR_ERR_XML_ERROR, - _("total and read/write iops_sec " - "cannot be set at the same time")); + virReportError(VIR_ERR_XML_ERROR, + _("total and read/write iops_sec " + "cannot be set at the same time")); goto error; } } else if (xmlStrEqual(cur->name, BAD_CAST "readonly")) { @@ -3647,8 +3643,8 @@ virDomainDiskDefParseXML(virCapsPtr caps, device = virXMLPropString(node, "device"); if (device) { if ((def->device = virDomainDiskDeviceTypeFromString(device)) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("unknown disk device '%s'"), device); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unknown disk device '%s'"), device); goto error; } } else { @@ -3660,8 +3656,8 @@ virDomainDiskDefParseXML(virCapsPtr caps, if (source == NULL && hosts == NULL && def->device != VIR_DOMAIN_DISK_DEVICE_CDROM && def->device != VIR_DOMAIN_DISK_DEVICE_FLOPPY) { - virDomainReportError(VIR_ERR_NO_SOURCE, - target ? "%s" : NULL, target); + virReportError(VIR_ERR_NO_SOURCE, + target ? "%s" : NULL, target); goto error; } @@ -3677,15 +3673,15 @@ virDomainDiskDefParseXML(virCapsPtr caps, } if (target == NULL) { - virDomainReportError(VIR_ERR_NO_TARGET, - source ? "%s" : NULL, source); + virReportError(VIR_ERR_NO_TARGET, + source ? "%s" : NULL, source); goto error; } if (def->device == VIR_DOMAIN_DISK_DEVICE_FLOPPY && !STRPREFIX(target, "fd")) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("Invalid floppy device name: %s"), target); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Invalid floppy device name: %s"), target); goto error; } @@ -3700,17 +3696,17 @@ virDomainDiskDefParseXML(virCapsPtr caps, !STRPREFIX((const char *)target, "vd") && !STRPREFIX((const char *)target, "xvd") && !STRPREFIX((const char *)target, "ubd")) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("Invalid harddisk device name: %s"), target); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Invalid harddisk device name: %s"), target); goto error; } if (snapshot) { def->snapshot = virDomainDiskSnapshotTypeFromString(snapshot); if (def->snapshot <= 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("unknown disk snapshot setting '%s'"), - snapshot); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unknown disk snapshot setting '%s'"), + snapshot); goto error; } } else if (def->readonly) { @@ -3725,22 +3721,22 @@ virDomainDiskDefParseXML(virCapsPtr caps, } else if (STREQ(rawio, "no")) { def->rawio = 0; } else { - virDomainReportError(VIR_ERR_XML_ERROR, - _("unknown disk rawio setting '%s'"), - rawio); + virReportError(VIR_ERR_XML_ERROR, + _("unknown disk rawio setting '%s'"), + rawio); goto error; } } else { - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("rawio can be used only with device='lun'")); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("rawio can be used only with device='lun'")); goto error; } } if (bus) { if ((def->bus = virDomainDiskBusTypeFromString(bus)) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("unknown disk bus type '%s'"), bus); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unknown disk bus type '%s'"), bus); goto error; } } else { @@ -3764,15 +3760,15 @@ virDomainDiskDefParseXML(virCapsPtr caps, if (tray) { if ((def->tray_status = virDomainDiskTrayTypeFromString(tray)) < 0) { - virDomainReportError(VIR_ERR_XML_ERROR, - _("unknown disk tray status '%s'"), tray); + virReportError(VIR_ERR_XML_ERROR, + _("unknown disk tray status '%s'"), tray); goto error; } if (def->device != VIR_DOMAIN_DISK_DEVICE_FLOPPY && def->device != VIR_DOMAIN_DISK_DEVICE_CDROM) { - virDomainReportError(VIR_ERR_XML_ERROR, "%s", - _("tray is only valid for cdrom and floppy")); + virReportError(VIR_ERR_XML_ERROR, "%s", + _("tray is only valid for cdrom and floppy")); goto error; } } else { @@ -3783,28 +3779,28 @@ virDomainDiskDefParseXML(virCapsPtr caps, if (def->device == VIR_DOMAIN_DISK_DEVICE_FLOPPY && def->bus != VIR_DOMAIN_DISK_BUS_FDC) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("Invalid bus type '%s' for floppy disk"), bus); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Invalid bus type '%s' for floppy disk"), bus); goto error; } if (def->device != VIR_DOMAIN_DISK_DEVICE_FLOPPY && def->bus == VIR_DOMAIN_DISK_BUS_FDC) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("Invalid bus type '%s' for disk"), bus); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Invalid bus type '%s' for disk"), bus); goto error; } if (cachetag && (def->cachemode = virDomainDiskCacheTypeFromString(cachetag)) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("unknown disk cache mode '%s'"), cachetag); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unknown disk cache mode '%s'"), cachetag); goto error; } if (error_policy && (def->error_policy = virDomainDiskErrorPolicyTypeFromString(error_policy)) <= 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("unknown disk error policy '%s'"), error_policy); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unknown disk error policy '%s'"), error_policy); goto error; } @@ -3812,34 +3808,34 @@ virDomainDiskDefParseXML(virCapsPtr caps, (((def->rerror_policy = virDomainDiskErrorPolicyTypeFromString(rerror_policy)) <= 0) || (def->rerror_policy == VIR_DOMAIN_DISK_ERROR_POLICY_ENOSPACE))) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("unknown disk read error policy '%s'"), - rerror_policy); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unknown disk read error policy '%s'"), + rerror_policy); goto error; } if (iotag) { if ((def->iomode = virDomainDiskIoTypeFromString(iotag)) < 0 || def->iomode == VIR_DOMAIN_DISK_IO_DEFAULT) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("unknown disk io mode '%s'"), iotag); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unknown disk io mode '%s'"), iotag); goto error; } } if (ioeventfd) { if (def->bus != VIR_DOMAIN_DISK_BUS_VIRTIO) { - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("disk ioeventfd mode supported " - "only for virtio bus")); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("disk ioeventfd mode supported " + "only for virtio bus")); goto error; } int i; if ((i = virDomainIoEventFdTypeFromString(ioeventfd)) <= 0) { - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown disk ioeventfd mode '%s'"), - ioeventfd); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unknown disk ioeventfd mode '%s'"), + ioeventfd); goto error; } def->ioeventfd=i; @@ -3847,17 +3843,17 @@ virDomainDiskDefParseXML(virCapsPtr caps, if (event_idx) { if (def->bus != VIR_DOMAIN_DISK_BUS_VIRTIO) { - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("disk event_idx mode supported " - "only for virtio bus")); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("disk event_idx mode supported " + "only for virtio bus")); goto error; } int idx; if ((idx = virDomainVirtioEventIdxTypeFromString(event_idx)) <= 0) { - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown disk event_idx mode '%s'"), - event_idx); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unknown disk event_idx mode '%s'"), + event_idx); goto error; } def->event_idx = idx; @@ -3866,9 +3862,9 @@ virDomainDiskDefParseXML(virCapsPtr caps, if (copy_on_read) { int cor; if ((cor = virDomainDiskCopyOnReadTypeFromString(copy_on_read)) <= 0) { - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown disk copy_on_read mode '%s'"), - copy_on_read); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unknown disk copy_on_read mode '%s'"), + copy_on_read); goto error; } def->copy_on_read = cor; @@ -3877,9 +3873,9 @@ virDomainDiskDefParseXML(virCapsPtr caps, if (devaddr) { if (virDomainParseLegacyDeviceAddress(devaddr, &def->info.addr.pci) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("Unable to parse devaddr parameter '%s'"), - devaddr); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Unable to parse devaddr parameter '%s'"), + devaddr); goto error; } def->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI; @@ -3893,18 +3889,18 @@ virDomainDiskDefParseXML(virCapsPtr caps, int i; if ((i = virDomainStartupPolicyTypeFromString(startupPolicy)) <= 0) { - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown startupPolicy value '%s'"), - startupPolicy); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unknown startupPolicy value '%s'"), + startupPolicy); goto error; } if (def->device != VIR_DOMAIN_DISK_DEVICE_CDROM && def->device != VIR_DOMAIN_DISK_DEVICE_FLOPPY) { - virDomainReportError(VIR_ERR_INVALID_ARG, - _("Setting disk %s is allowed only for " - "cdrom or floppy"), - startupPolicy); + virReportError(VIR_ERR_INVALID_ARG, + _("Setting disk %s is allowed only for " + "cdrom or floppy"), + startupPolicy); goto error; } def->startupPolicy = i; @@ -4034,8 +4030,8 @@ virDomainControllerDefParseXML(xmlNodePtr node, type = virXMLPropString(node, "type"); if (type) { if ((def->type = virDomainControllerTypeFromString(type)) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("Unknown controller type '%s'"), type); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Unknown controller type '%s'"), type); goto error; } } @@ -4043,8 +4039,8 @@ virDomainControllerDefParseXML(xmlNodePtr node, idx = virXMLPropString(node, "index"); if (idx) { if (virStrToLong_i(idx, NULL, 10, &def->idx) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("Cannot parse controller index %s"), idx); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Cannot parse controller index %s"), idx); goto error; } } @@ -4052,8 +4048,8 @@ virDomainControllerDefParseXML(xmlNodePtr node, model = virXMLPropString(node, "model"); if (model) { if ((def->model = virDomainControllerModelTypeFromString(def, model)) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("Unknown model type '%s'"), model); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Unknown model type '%s'"), model); goto error; } } else { @@ -4070,8 +4066,8 @@ virDomainControllerDefParseXML(xmlNodePtr node, int r = virStrToLong_i(ports, NULL, 10, &def->opts.vioserial.ports); if (r != 0 || def->opts.vioserial.ports < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("Invalid ports: %s"), ports); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Invalid ports: %s"), ports); VIR_FREE(ports); goto error; } @@ -4085,8 +4081,8 @@ virDomainControllerDefParseXML(xmlNodePtr node, int r = virStrToLong_i(vectors, NULL, 10, &def->opts.vioserial.vectors); if (r != 0 || def->opts.vioserial.vectors < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("Invalid vectors: %s"), vectors); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Invalid vectors: %s"), vectors); VIR_FREE(vectors); goto error; } @@ -4127,8 +4123,8 @@ virDomainControllerDefParseXML(xmlNodePtr node, def->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO && def->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_S390 && def->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Controllers must use the 'pci' address type")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Controllers must use the 'pci' address type")); goto error; } @@ -4171,13 +4167,13 @@ virDomainParseScaledValue(const char *xpath, ret = virXPathULongLong(xpath_full, ctxt, &bytes); if (ret < 0) { if (ret == -2) - virDomainReportError(VIR_ERR_XML_ERROR, - _("could not parse element %s"), - xpath); + virReportError(VIR_ERR_XML_ERROR, + _("could not parse element %s"), + xpath); else if (required) - virDomainReportError(VIR_ERR_XML_ERROR, - _("missing element %s"), - xpath); + virReportError(VIR_ERR_XML_ERROR, + _("missing element %s"), + xpath); else ret = 0; goto cleanup; @@ -4230,8 +4226,8 @@ virDomainFSDefParseXML(xmlNodePtr node, type = virXMLPropString(node, "type"); if (type) { if ((def->type = virDomainFSTypeFromString(type)) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("unknown filesystem type '%s'"), type); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unknown filesystem type '%s'"), type); goto error; } } else { @@ -4241,8 +4237,8 @@ virDomainFSDefParseXML(xmlNodePtr node, accessmode = virXMLPropString(node, "accessmode"); if (accessmode) { if ((def->accessmode = virDomainFSAccessModeTypeFromString(accessmode)) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("unknown accessmode '%s'"), accessmode); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unknown accessmode '%s'"), accessmode); goto error; } } else { @@ -4293,16 +4289,16 @@ virDomainFSDefParseXML(xmlNodePtr node, if (fsdriver) { if ((def->fsdriver = virDomainFSDriverTypeTypeFromString(fsdriver)) <= 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("unknown fs driver type '%s'"), fsdriver); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unknown fs driver type '%s'"), fsdriver); goto error; } } if (wrpolicy) { if ((def->wrpolicy = virDomainFSWrpolicyTypeFromString(wrpolicy)) <= 0) { - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown filesystem write policy '%s'"), wrpolicy); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unknown filesystem write policy '%s'"), wrpolicy); goto error; } } else { @@ -4311,27 +4307,27 @@ virDomainFSDefParseXML(xmlNodePtr node, if (source == NULL && def->type != VIR_DOMAIN_FS_TYPE_RAM) { - virDomainReportError(VIR_ERR_NO_SOURCE, - target ? "%s" : NULL, target); + virReportError(VIR_ERR_NO_SOURCE, + target ? "%s" : NULL, target); goto error; } if (target == NULL) { - virDomainReportError(VIR_ERR_NO_TARGET, - source ? "%s" : NULL, source); + virReportError(VIR_ERR_NO_TARGET, + source ? "%s" : NULL, source); goto error; } if (def->type == VIR_DOMAIN_FS_TYPE_RAM) { if (!usage) { - virDomainReportError(VIR_ERR_XML_ERROR, "%s", - _("missing 'usage' attribute for RAM filesystem")); + virReportError(VIR_ERR_XML_ERROR, "%s", + _("missing 'usage' attribute for RAM filesystem")); goto error; } if (virStrToLong_ull(usage, NULL, 10, &def->usage) < 0) { - virDomainReportError(VIR_ERR_XML_ERROR, - _("cannot parse usage '%s' for RAM filesystem"), - usage); + virReportError(VIR_ERR_XML_ERROR, + _("cannot parse usage '%s' for RAM filesystem"), + usage); goto error; } if (unit && @@ -4391,22 +4387,22 @@ virDomainActualNetDefParseXML(xmlNodePtr node, type = virXMLPropString(node, "type"); if (!type) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("missing type attribute in interface's <actual> element")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("missing type attribute in interface's <actual> element")); goto error; } if ((actual->type = virDomainNetTypeFromString(type)) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("unknown type '%s' in interface's <actual> element"), type); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unknown type '%s' in interface's <actual> element"), type); goto error; } if (actual->type != VIR_DOMAIN_NET_TYPE_BRIDGE && actual->type != VIR_DOMAIN_NET_TYPE_DIRECT && actual->type != VIR_DOMAIN_NET_TYPE_HOSTDEV && actual->type != VIR_DOMAIN_NET_TYPE_NETWORK) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("unsupported type '%s' in interface's <actual> element"), - type); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unsupported type '%s' in interface's <actual> element"), + type); goto error; } @@ -4425,9 +4421,9 @@ virDomainActualNetDefParseXML(xmlNodePtr node, if (mode) { int m; if ((m = virNetDevMacVLanModeTypeFromString(mode)) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("Unkown mode '%s' in interface <actual> element"), - mode); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Unkown mode '%s' in interface <actual> element"), + mode); goto error; } actual->data.direct.mode = m; @@ -4540,8 +4536,8 @@ virDomainNetDefParseXML(virCapsPtr caps, type = virXMLPropString(node, "type"); if (type != NULL) { if ((int)(def->type = virDomainNetTypeFromString(type)) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("unknown interface type '%s'"), type); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unknown interface type '%s'"), type); goto error; } } else { @@ -4642,15 +4638,15 @@ virDomainNetDefParseXML(virCapsPtr caps, if (macaddr) { if (virMacAddrParse((const char *)macaddr, &def->mac) < 0) { - virDomainReportError(VIR_ERR_XML_ERROR, - _("unable to parse mac address '%s'"), - (const char *)macaddr); + virReportError(VIR_ERR_XML_ERROR, + _("unable to parse mac address '%s'"), + (const char *)macaddr); goto error; } if (virMacAddrIsMulticast(&def->mac)) { - virDomainReportError(VIR_ERR_XML_ERROR, - _("expected unicast mac address, found multicast '%s'"), - (const char *)macaddr); + virReportError(VIR_ERR_XML_ERROR, + _("expected unicast mac address, found multicast '%s'"), + (const char *)macaddr); goto error; } } else { @@ -4660,9 +4656,9 @@ virDomainNetDefParseXML(virCapsPtr caps, if (devaddr) { if (virDomainParseLegacyDeviceAddress(devaddr, &def->info.addr.pci) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("Unable to parse devaddr parameter '%s'"), - devaddr); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Unable to parse devaddr parameter '%s'"), + devaddr); goto error; } def->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI; @@ -4679,16 +4675,17 @@ virDomainNetDefParseXML(virCapsPtr caps, def->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO && def->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_S390 && def->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Network interfaces must use 'pci' address type")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Network interfaces must use 'pci' address type")); goto error; } switch (def->type) { case VIR_DOMAIN_NET_TYPE_NETWORK: if (network == NULL) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("No <source> 'network' attribute specified with <interface type='network'/>")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("No <source> 'network' attribute " + "specified with <interface type='network'/>")); goto error; } def->data.network.name = network; @@ -4714,8 +4711,9 @@ virDomainNetDefParseXML(virCapsPtr caps, case VIR_DOMAIN_NET_TYPE_BRIDGE: if (bridge == NULL) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("No <source> 'bridge' attribute specified with <interface type='bridge'/>")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("No <source> 'bridge' attribute " + "specified with <interface type='bridge'/>")); goto error; } def->data.bridge.brname = bridge; @@ -4732,21 +4730,24 @@ virDomainNetDefParseXML(virCapsPtr caps, case VIR_DOMAIN_NET_TYPE_SERVER: case VIR_DOMAIN_NET_TYPE_MCAST: if (port == NULL) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("No <source> 'port' attribute specified with socket interface")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("No <source> 'port' attribute " + "specified with socket interface")); goto error; } if (virStrToLong_i(port, NULL, 10, &def->data.socket.port) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Cannot parse <source> 'port' attribute with socket interface")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Cannot parse <source> 'port' attribute " + "with socket interface")); goto error; } if (address == NULL) { if (def->type == VIR_DOMAIN_NET_TYPE_CLIENT || def->type == VIR_DOMAIN_NET_TYPE_MCAST) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("No <source> 'address' attribute specified with socket interface")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("No <source> 'address' attribute " + "specified with socket interface")); goto error; } } else { @@ -4757,8 +4758,9 @@ virDomainNetDefParseXML(virCapsPtr caps, case VIR_DOMAIN_NET_TYPE_INTERNAL: if (internal == NULL) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("No <source> 'name' attribute specified with <interface type='internal'/>")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("No <source> 'name' attribute specified " + "with <interface type='internal'/>")); goto error; } def->data.internal.name = internal; @@ -4767,16 +4769,17 @@ virDomainNetDefParseXML(virCapsPtr caps, case VIR_DOMAIN_NET_TYPE_DIRECT: if (dev == NULL) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("No <source> 'dev' attribute specified with <interface type='direct'/>")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("No <source> 'dev' attribute specified " + "with <interface type='direct'/>")); goto error; } if (mode != NULL) { int m; if ((m = virNetDevMacVLanModeTypeFromString(mode)) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Unkown mode has been specified")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Unkown mode has been specified")); goto error; } def->data.direct.mode = m; @@ -4840,8 +4843,8 @@ virDomainNetDefParseXML(virCapsPtr caps, */ if (model != NULL) { if (strspn(model, NET_MODEL_CHARS) < strlen(model)) { - virDomainReportError(VIR_ERR_INVALID_ARG, "%s", - _("Model name contains invalid characters")); + virReportError(VIR_ERR_INVALID_ARG, "%s", + _("Model name contains invalid characters")); goto error; } def->model = model; @@ -4853,10 +4856,10 @@ virDomainNetDefParseXML(virCapsPtr caps, int name; if ((name = virDomainNetBackendTypeFromString(backend)) < 0 || name == VIR_DOMAIN_NET_BACKEND_TYPE_DEFAULT) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("Unknown interface <driver name='%s'> " - "has been specified"), - backend); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Unknown interface <driver name='%s'> " + "has been specified"), + backend); goto error; } def->driver.virtio.name = name; @@ -4865,10 +4868,10 @@ virDomainNetDefParseXML(virCapsPtr caps, int m; if ((m = virDomainNetVirtioTxModeTypeFromString(txmode)) < 0 || m == VIR_DOMAIN_NET_VIRTIO_TX_MODE_DEFAULT) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("Unknown interface <driver txmode='%s'> " - "has been specified"), - txmode); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Unknown interface <driver txmode='%s'> " + "has been specified"), + txmode); goto error; } def->driver.virtio.txmode = m; @@ -4876,9 +4879,9 @@ virDomainNetDefParseXML(virCapsPtr caps, if (ioeventfd) { int i; if ((i = virDomainIoEventFdTypeFromString(ioeventfd)) <= 0) { - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown interface ioeventfd mode '%s'"), - ioeventfd); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unknown interface ioeventfd mode '%s'"), + ioeventfd); goto error; } def->driver.virtio.ioeventfd = i; @@ -4886,9 +4889,9 @@ virDomainNetDefParseXML(virCapsPtr caps, if (event_idx) { int idx; if ((idx = virDomainVirtioEventIdxTypeFromString(event_idx)) <= 0) { - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown interface event_idx mode '%s'"), - event_idx); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unknown interface event_idx mode '%s'"), + event_idx); goto error; } def->driver.virtio.event_idx = idx; @@ -4898,9 +4901,9 @@ virDomainNetDefParseXML(virCapsPtr caps, def->linkstate = VIR_DOMAIN_NET_INTERFACE_LINK_STATE_DEFAULT; if (linkstate != NULL) { if ((def->linkstate = virDomainNetInterfaceLinkStateTypeFromString(linkstate)) <= 0) { - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown interface link state '%s'"), - linkstate); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unknown interface link state '%s'"), + linkstate); goto error; } } @@ -4924,8 +4927,8 @@ virDomainNetDefParseXML(virCapsPtr caps, if (ret >= 0) { def->tune.sndbuf_specified = true; } else if (ret == -2) { - virDomainReportError(VIR_ERR_XML_ERROR, "%s", - _("sndbuf must be a positive integer")); + virReportError(VIR_ERR_XML_ERROR, "%s", + _("sndbuf must be a positive integer")); goto error; } @@ -4973,15 +4976,15 @@ virDomainChrDefaultTargetType(virCapsPtr caps, switch (devtype) { case VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL: - virDomainReportError(VIR_ERR_XML_ERROR, - _("target type must be specified for %s device"), - virDomainChrDeviceTypeToString(devtype)); + virReportError(VIR_ERR_XML_ERROR, + _("target type must be specified for %s device"), + virDomainChrDeviceTypeToString(devtype)); break; case VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE: if (!caps->defaultConsoleTargetType) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Driver does not have a default console type set")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Driver does not have a default console type set")); return -1; } target = caps->defaultConsoleTargetType(def->os.type); @@ -5048,9 +5051,9 @@ virDomainChrDefParseTargetXML(virCapsPtr caps, if ((def->targetType = virDomainChrTargetTypeFromString(caps, vmdef, def->deviceType, targetType)) < 0) { - virDomainReportError(VIR_ERR_XML_ERROR, - _("unknown target type '%s' specified for character device"), - targetType); + virReportError(VIR_ERR_XML_ERROR, + _("unknown target type '%s' specified for character device"), + targetType); goto error; } @@ -5062,9 +5065,9 @@ virDomainChrDefParseTargetXML(virCapsPtr caps, portStr = virXMLPropString(cur, "port"); if (addrStr == NULL) { - virDomainReportError(VIR_ERR_XML_ERROR, "%s", - _("guestfwd channel does not " - "define a target address")); + virReportError(VIR_ERR_XML_ERROR, "%s", + _("guestfwd channel does not " + "define a target address")); goto error; } @@ -5077,23 +5080,23 @@ virDomainChrDefParseTargetXML(virCapsPtr caps, goto error; if (def->target.addr->data.stor.ss_family != AF_INET) { - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, - "%s", _("guestfwd channel only supports " - "IPv4 addresses")); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + "%s", _("guestfwd channel only supports " + "IPv4 addresses")); goto error; } if (portStr == NULL) { - virDomainReportError(VIR_ERR_XML_ERROR, "%s", - _("guestfwd channel does " - "not define a target port")); + virReportError(VIR_ERR_XML_ERROR, "%s", + _("guestfwd channel does " + "not define a target port")); goto error; } if (virStrToLong_ui(portStr, NULL, 10, &port) < 0) { - virDomainReportError(VIR_ERR_XML_ERROR, - _("Invalid port number: %s"), - portStr); + virReportError(VIR_ERR_XML_ERROR, + _("Invalid port number: %s"), + portStr); goto error; } @@ -5115,9 +5118,9 @@ virDomainChrDefParseTargetXML(virCapsPtr caps, } if (virStrToLong_ui(portStr, NULL, 10, &port) < 0) { - virDomainReportError(VIR_ERR_XML_ERROR, - _("Invalid port number: %s"), - portStr); + virReportError(VIR_ERR_XML_ERROR, + _("Invalid port number: %s"), + portStr); goto error; } def->target.port = port; @@ -5187,9 +5190,9 @@ virDomainChrSourceDefParseXML(virDomainChrSourceDefPtr def, if (bindService == NULL) bindService = virXMLPropString(cur, "service"); } else { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("Unknown source mode '%s'"), - mode); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Unknown source mode '%s'"), + mode); goto error; } @@ -5220,8 +5223,8 @@ virDomainChrSourceDefParseXML(virDomainChrSourceDefPtr def, case VIR_DOMAIN_CHR_TYPE_PIPE: if (path == NULL && def->type != VIR_DOMAIN_CHR_TYPE_PTY) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Missing source path attribute for char device")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Missing source path attribute for char device")); goto error; } @@ -5238,13 +5241,13 @@ virDomainChrSourceDefParseXML(virDomainChrSourceDefPtr def, if (mode == NULL || STREQ(mode, "connect")) { if (connectHost == NULL) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Missing source host attribute for char device")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Missing source host attribute for char device")); goto error; } if (connectService == NULL) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Missing source service attribute for char device")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Missing source service attribute for char device")); goto error; } @@ -5255,13 +5258,13 @@ virDomainChrSourceDefParseXML(virDomainChrSourceDefPtr def, def->data.tcp.listen = false; } else { if (bindHost == NULL) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Missing source host attribute for char device")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Missing source host attribute for char device")); goto error; } if (bindService == NULL) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Missing source service attribute for char device")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Missing source service attribute for char device")); goto error; } @@ -5276,8 +5279,8 @@ virDomainChrSourceDefParseXML(virDomainChrSourceDefPtr def, def->data.tcp.protocol = VIR_DOMAIN_CHR_TCP_PROTOCOL_RAW; else if ((def->data.tcp.protocol = virDomainChrTcpProtocolTypeFromString(protocol)) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("Unknown protocol '%s'"), protocol); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Unknown protocol '%s'"), protocol); goto error; } @@ -5285,8 +5288,8 @@ virDomainChrSourceDefParseXML(virDomainChrSourceDefPtr def, case VIR_DOMAIN_CHR_TYPE_UDP: if (connectService == NULL) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Missing source service attribute for char device")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Missing source service attribute for char device")); goto error; } @@ -5303,8 +5306,8 @@ virDomainChrSourceDefParseXML(virDomainChrSourceDefPtr def, case VIR_DOMAIN_CHR_TYPE_UNIX: if (path == NULL) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Missing source path attribute for char device")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Missing source path attribute for char device")); goto error; } @@ -5406,17 +5409,17 @@ virDomainChrDefParseXML(virCapsPtr caps, if (type == NULL) { def->source.type = VIR_DOMAIN_CHR_TYPE_PTY; } else if ((def->source.type = virDomainChrTypeFromString(type)) < 0) { - virDomainReportError(VIR_ERR_XML_ERROR, - _("unknown type presented to host for character device: %s"), - type); + virReportError(VIR_ERR_XML_ERROR, + _("unknown type presented to host for character device: %s"), + type); goto error; } nodeName = (const char *) node->name; if ((def->deviceType = virDomainChrDeviceTypeFromString(nodeName)) < 0) { - virDomainReportError(VIR_ERR_XML_ERROR, - _("unknown character device type: %s"), - nodeName); + virReportError(VIR_ERR_XML_ERROR, + _("unknown character device type: %s"), + nodeName); } cur = node->children; @@ -5443,9 +5446,9 @@ virDomainChrDefParseXML(virCapsPtr caps, if (def->source.type == VIR_DOMAIN_CHR_TYPE_SPICEVMC) { if (def->targetType != VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VIRTIO) { - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("spicevmc device type only supports " - "virtio")); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("spicevmc device type only supports " + "virtio")); goto error; } else { def->source.data.spicevmc = VIR_DOMAIN_CHR_SPICEVMC_VDAGENT; @@ -5483,14 +5486,14 @@ virDomainSmartcardDefParseXML(xmlNodePtr node, mode = virXMLPropString(node, "mode"); if (mode == NULL) { - virDomainReportError(VIR_ERR_XML_ERROR, "%s", - _("missing smartcard device mode")); + virReportError(VIR_ERR_XML_ERROR, "%s", + _("missing smartcard device mode")); goto error; } if ((def->type = virDomainSmartcardTypeFromString(mode)) < 0) { - virDomainReportError(VIR_ERR_XML_ERROR, - _("unknown smartcard device mode: %s"), - mode); + virReportError(VIR_ERR_XML_ERROR, + _("unknown smartcard device mode: %s"), + mode); goto error; } @@ -5505,9 +5508,9 @@ virDomainSmartcardDefParseXML(xmlNodePtr node, if (cur->type == XML_ELEMENT_NODE && xmlStrEqual(cur->name, BAD_CAST "certificate")) { if (i == 3) { - virDomainReportError(VIR_ERR_XML_ERROR, "%s", - _("host-certificates mode needs " - "exactly three certificates")); + virReportError(VIR_ERR_XML_ERROR, "%s", + _("host-certificates mode needs " + "exactly three certificates")); goto error; } def->data.cert.file[i] = (char *)xmlNodeGetContent(cur); @@ -5525,18 +5528,18 @@ virDomainSmartcardDefParseXML(xmlNodePtr node, goto error; } if (*def->data.cert.database != '/') { - virDomainReportError(VIR_ERR_XML_ERROR, - _("expecting absolute path: %s"), - def->data.cert.database); + virReportError(VIR_ERR_XML_ERROR, + _("expecting absolute path: %s"), + def->data.cert.database); goto error; } } cur = cur->next; } if (i < 3) { - virDomainReportError(VIR_ERR_XML_ERROR, "%s", - _("host-certificates mode needs " - "exactly three certificates")); + virReportError(VIR_ERR_XML_ERROR, "%s", + _("host-certificates mode needs " + "exactly three certificates")); goto error; } break; @@ -5544,15 +5547,15 @@ virDomainSmartcardDefParseXML(xmlNodePtr node, case VIR_DOMAIN_SMARTCARD_TYPE_PASSTHROUGH: type = virXMLPropString(node, "type"); if (type == NULL) { - virDomainReportError(VIR_ERR_XML_ERROR, "%s", - _("passthrough mode requires a character " - "device type attribute")); + virReportError(VIR_ERR_XML_ERROR, "%s", + _("passthrough mode requires a character " + "device type attribute")); goto error; } if ((def->data.passthru.type = virDomainChrTypeFromString(type)) < 0) { - virDomainReportError(VIR_ERR_XML_ERROR, - _("unknown type presented to host for " - "character device: %s"), type); + virReportError(VIR_ERR_XML_ERROR, + _("unknown type presented to host for " + "character device: %s"), type); goto error; } @@ -5568,8 +5571,8 @@ virDomainSmartcardDefParseXML(xmlNodePtr node, break; default: - virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("unknown smartcard mode")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("unknown smartcard mode")); goto error; } @@ -5577,8 +5580,8 @@ virDomainSmartcardDefParseXML(xmlNodePtr node, goto error; if (def->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE && def->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCID) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Controllers must use the 'ccid' address type")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Controllers must use the 'ccid' address type")); goto error; } @@ -5613,48 +5616,48 @@ virDomainInputDefParseXML(const char *ostype, bus = virXMLPropString(node, "bus"); if (!type) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("missing input device type")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("missing input device type")); goto error; } if ((def->type = virDomainInputTypeFromString(type)) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("unknown input device type '%s'"), type); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unknown input device type '%s'"), type); goto error; } if (bus) { if ((def->bus = virDomainInputBusTypeFromString(bus)) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("unknown input bus type '%s'"), bus); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unknown input bus type '%s'"), bus); goto error; } if (STREQ(ostype, "hvm")) { if (def->bus == VIR_DOMAIN_INPUT_BUS_PS2 && /* Only allow mouse for ps2 */ def->type != VIR_DOMAIN_INPUT_TYPE_MOUSE) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("ps2 bus does not support %s input device"), - type); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("ps2 bus does not support %s input device"), + type); goto error; } if (def->bus == VIR_DOMAIN_INPUT_BUS_XEN) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("unsupported input bus %s"), - bus); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unsupported input bus %s"), + bus); goto error; } } else { if (def->bus != VIR_DOMAIN_INPUT_BUS_XEN) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("unsupported input bus %s"), - bus); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unsupported input bus %s"), + bus); } if (def->type != VIR_DOMAIN_INPUT_TYPE_MOUSE) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("xen bus does not support %s input device"), - type); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("xen bus does not support %s input device"), + type); goto error; } } @@ -5675,8 +5678,8 @@ virDomainInputDefParseXML(const char *ostype, if (def->bus == VIR_DOMAIN_INPUT_BUS_USB && def->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE && def->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_USB) { - virDomainReportError(VIR_ERR_XML_ERROR, "%s", - _("Invalid address for a USB device")); + virReportError(VIR_ERR_XML_ERROR, "%s", + _("Invalid address for a USB device")); goto error; } @@ -5708,14 +5711,14 @@ virDomainHubDefParseXML(xmlNodePtr node, unsigned int flags) type = virXMLPropString(node, "type"); if (!type) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("missing hub device type")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("missing hub device type")); goto error; } if ((def->type = virDomainHubTypeFromString(type)) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("unknown hub device type '%s'"), type); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unknown hub device type '%s'"), type); goto error; } @@ -5759,13 +5762,13 @@ virDomainTimerDefParseXML(const xmlNodePtr node, name = virXMLPropString(node, "name"); if (name == NULL) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("missing timer name")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("missing timer name")); goto error; } if ((def->name = virDomainTimerNameTypeFromString(name)) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("unknown timer name '%s'"), name); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unknown timer name '%s'"), name); goto error; } @@ -5776,8 +5779,8 @@ virDomainTimerDefParseXML(const xmlNodePtr node, } else if (STREQ(present, "no")) { def->present = 0; } else { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("unknown timer present value '%s'"), present); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unknown timer present value '%s'"), present); goto error; } } @@ -5786,8 +5789,8 @@ virDomainTimerDefParseXML(const xmlNodePtr node, tickpolicy = virXMLPropString(node, "tickpolicy"); if (tickpolicy != NULL) { if ((def->tickpolicy = virDomainTimerTickpolicyTypeFromString(tickpolicy)) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("unknown timer tickpolicy '%s'"), tickpolicy); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unknown timer tickpolicy '%s'"), tickpolicy); goto error; } } @@ -5796,8 +5799,8 @@ virDomainTimerDefParseXML(const xmlNodePtr node, track = virXMLPropString(node, "track"); if (track != NULL) { if ((def->track = virDomainTimerTrackTypeFromString(track)) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("unknown timer track '%s'"), track); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unknown timer track '%s'"), track); goto error; } } @@ -5806,8 +5809,8 @@ virDomainTimerDefParseXML(const xmlNodePtr node, if (ret == -1) { def->frequency = 0; } else if (ret < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("invalid timer frequency")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("invalid timer frequency")); goto error; } @@ -5815,8 +5818,8 @@ virDomainTimerDefParseXML(const xmlNodePtr node, mode = virXMLPropString(node, "mode"); if (mode != NULL) { if ((def->mode = virDomainTimerModeTypeFromString(mode)) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("unknown timer mode '%s'"), mode); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unknown timer mode '%s'"), mode); goto error; } } @@ -5828,8 +5831,8 @@ virDomainTimerDefParseXML(const xmlNodePtr node, if (ret == -1) { def->catchup.threshold = 0; } else if (ret < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("invalid catchup threshold")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("invalid catchup threshold")); goto error; } @@ -5837,8 +5840,8 @@ virDomainTimerDefParseXML(const xmlNodePtr node, if (ret == -1) { def->catchup.slew = 0; } else if (ret < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("invalid catchup slew")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("invalid catchup slew")); goto error; } @@ -5846,8 +5849,8 @@ virDomainTimerDefParseXML(const xmlNodePtr node, if (ret == -1) { def->catchup.limit = 0; } else if (ret < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("invalid catchup limit")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("invalid catchup limit")); goto error; } } @@ -5899,9 +5902,9 @@ virDomainGraphicsAuthDefParseXML(xmlNodePtr node, virStrToLong_i(tmp+1, &tmp, 10, &tm.tm_min) < 0 || *tmp != ':' || /* second */ virStrToLong_i(tmp+1, &tmp, 10, &tm.tm_sec) < 0 || *tmp != '\0') { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("cannot parse password validity time '%s', expect YYYY-MM-DDTHH:MM:SS"), - validTo); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("cannot parse password validity time '%s', expect YYYY-MM-DDTHH:MM:SS"), + validTo); VIR_FREE(validTo); VIR_FREE(def->passwd); return -1; @@ -5918,9 +5921,9 @@ virDomainGraphicsAuthDefParseXML(xmlNodePtr node, if (connected) { int action = virDomainGraphicsAuthConnectedTypeFromString(connected); if (action <= 0) { - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown connected value %s"), - connected); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unknown connected value %s"), + connected); VIR_FREE(connected); return -1; } @@ -5929,8 +5932,8 @@ virDomainGraphicsAuthDefParseXML(xmlNodePtr node, /* VNC supports connected='keep' only */ if (type == VIR_DOMAIN_GRAPHICS_TYPE_VNC && action != VIR_DOMAIN_GRAPHICS_AUTH_CONNECTED_KEEP) { - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("VNC supports connected='keep' only")); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("VNC supports connected='keep' only")); return -1; } @@ -5951,14 +5954,14 @@ virDomainGraphicsListenDefParseXML(virDomainGraphicsListenDefPtr def, char *network = virXMLPropString(node, "network"); if (!type) { - virDomainReportError(VIR_ERR_XML_ERROR, "%s", - _("graphics listen type must be specified")); + virReportError(VIR_ERR_XML_ERROR, "%s", + _("graphics listen type must be specified")); goto error; } if ((def->type = virDomainGraphicsListenTypeFromString(type)) < 0) { - virDomainReportError(VIR_ERR_XML_ERROR, - _("unknown graphics listen type '%s'"), type); + virReportError(VIR_ERR_XML_ERROR, + _("unknown graphics listen type '%s'"), type); goto error; } @@ -5977,8 +5980,8 @@ virDomainGraphicsListenDefParseXML(virDomainGraphicsListenDefPtr def, if (def->type != VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK) { /* network='xxx' never makes sense with anything except * type='address' */ - virDomainReportError(VIR_ERR_XML_ERROR, "%s", - _("network attribute not allowed when listen type is not network")); + virReportError(VIR_ERR_XML_ERROR, "%s", + _("network attribute not allowed when listen type is not network")); goto error; } def->network = network; @@ -6019,14 +6022,14 @@ virDomainGraphicsDefParseXML(xmlNodePtr node, type = virXMLPropString(node, "type"); if (!type) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("missing graphics device type")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("missing graphics device type")); goto error; } if ((def->type = virDomainGraphicsTypeFromString(type)) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("unknown graphics device type '%s'"), type); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unknown graphics device type '%s'"), type); goto error; } @@ -6092,10 +6095,10 @@ virDomainGraphicsDefParseXML(xmlNodePtr node, } } if (!matched) { - virDomainReportError(VIR_ERR_XML_ERROR, - _("graphics listen attribute %s must match address " - "attribute of first listen element (found %s)"), - listenAddr, found ? found : "none"); + virReportError(VIR_ERR_XML_ERROR, + _("graphics listen attribute %s must match address " + "attribute of first listen element (found %s)"), + listenAddr, found ? found : "none"); goto error; } } @@ -6108,8 +6111,8 @@ virDomainGraphicsDefParseXML(xmlNodePtr node, if (port) { if (virStrToLong_i(port, NULL, 10, &def->data.vnc.port) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("cannot parse vnc port %s"), port); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("cannot parse vnc port %s"), port); VIR_FREE(port); goto error; } @@ -6149,8 +6152,8 @@ virDomainGraphicsDefParseXML(xmlNodePtr node, } else if (STREQ(fullscreen, "no")) { def->data.sdl.fullscreen = 0; } else { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("unknown fullscreen value '%s'"), fullscreen); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unknown fullscreen value '%s'"), fullscreen); VIR_FREE(fullscreen); goto error; } @@ -6168,8 +6171,8 @@ virDomainGraphicsDefParseXML(xmlNodePtr node, if (port) { if (virStrToLong_i(port, NULL, 10, &def->data.rdp.port) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("cannot parse rdp port %s"), port); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("cannot parse rdp port %s"), port); VIR_FREE(port); goto error; } @@ -6216,8 +6219,8 @@ virDomainGraphicsDefParseXML(xmlNodePtr node, } else if (STREQ(fullscreen, "no")) { def->data.desktop.fullscreen = 0; } else { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("unknown fullscreen value '%s'"), fullscreen); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unknown fullscreen value '%s'"), fullscreen); VIR_FREE(fullscreen); goto error; } @@ -6237,8 +6240,8 @@ virDomainGraphicsDefParseXML(xmlNodePtr node, if (port) { if (virStrToLong_i(port, NULL, 10, &def->data.spice.port) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("cannot parse spice port %s"), port); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("cannot parse spice port %s"), port); VIR_FREE(port); goto error; } @@ -6250,8 +6253,8 @@ virDomainGraphicsDefParseXML(xmlNodePtr node, tlsPort = virXMLPropString(node, "tlsPort"); if (tlsPort) { if (virStrToLong_i(tlsPort, NULL, 10, &def->data.spice.tlsPort) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("cannot parse spice tlsPort %s"), tlsPort); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("cannot parse spice tlsPort %s"), tlsPort); VIR_FREE(tlsPort); goto error; } @@ -6270,9 +6273,9 @@ virDomainGraphicsDefParseXML(xmlNodePtr node, if ((defaultMode = virXMLPropString(node, "defaultMode")) != NULL) { if ((defaultModeVal = virDomainGraphicsSpiceChannelModeTypeFromString(defaultMode)) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("unknown default spice channel mode %s"), - defaultMode); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unknown default spice channel mode %s"), + defaultMode); VIR_FREE(defaultMode); goto error; } @@ -6306,25 +6309,25 @@ virDomainGraphicsDefParseXML(xmlNodePtr node, mode = virXMLPropString(cur, "mode"); if (!name || !mode) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("spice channel missing name/mode")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("spice channel missing name/mode")); VIR_FREE(name); VIR_FREE(mode); goto error; } if ((nameval = virDomainGraphicsSpiceChannelNameTypeFromString(name)) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("unknown spice channel name %s"), - name); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unknown spice channel name %s"), + name); VIR_FREE(name); VIR_FREE(mode); goto error; } if ((modeval = virDomainGraphicsSpiceChannelModeTypeFromString(mode)) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("unknown spice channel mode %s"), - mode); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unknown spice channel mode %s"), + mode); VIR_FREE(name); VIR_FREE(mode); goto error; @@ -6338,16 +6341,16 @@ virDomainGraphicsDefParseXML(xmlNodePtr node, int compressionVal; if (!compression) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("spice image missing compression")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("spice image missing compression")); goto error; } if ((compressionVal = virDomainGraphicsSpiceImageCompressionTypeFromString(compression)) <= 0) { - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown spice image compression %s"), - compression); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unknown spice image compression %s"), + compression); VIR_FREE(compression); goto error; } @@ -6359,16 +6362,16 @@ virDomainGraphicsDefParseXML(xmlNodePtr node, int compressionVal; if (!compression) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("spice jpeg missing compression")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("spice jpeg missing compression")); goto error; } if ((compressionVal = virDomainGraphicsSpiceJpegCompressionTypeFromString(compression)) <= 0) { - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown spice jpeg compression %s"), - compression); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unknown spice jpeg compression %s"), + compression); VIR_FREE(compression); goto error; } @@ -6380,16 +6383,16 @@ virDomainGraphicsDefParseXML(xmlNodePtr node, int compressionVal; if (!compression) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("spice zlib missing compression")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("spice zlib missing compression")); goto error; } if ((compressionVal = virDomainGraphicsSpiceZlibCompressionTypeFromString(compression)) <= 0) { - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown spice zlib compression %s"), - compression); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unknown spice zlib compression %s"), + compression); VIR_FREE(compression); goto error; } @@ -6401,15 +6404,15 @@ virDomainGraphicsDefParseXML(xmlNodePtr node, int compressionVal; if (!compression) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("spice playback missing compression")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("spice playback missing compression")); goto error; } if ((compressionVal = virDomainGraphicsSpicePlaybackCompressionTypeFromString(compression)) <= 0) { - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown spice playback compression")); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unknown spice playback compression")); VIR_FREE(compression); goto error; @@ -6422,14 +6425,14 @@ virDomainGraphicsDefParseXML(xmlNodePtr node, int modeVal; if (!mode) { - virDomainReportError(VIR_ERR_XML_ERROR, "%s", - _("spice streaming missing mode")); + virReportError(VIR_ERR_XML_ERROR, "%s", + _("spice streaming missing mode")); goto error; } if ((modeVal = virDomainGraphicsSpiceStreamingModeTypeFromString(mode)) <= 0) { - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown spice streaming mode")); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unknown spice streaming mode")); VIR_FREE(mode); goto error; @@ -6442,15 +6445,15 @@ virDomainGraphicsDefParseXML(xmlNodePtr node, int copypasteVal; if (!copypaste) { - virDomainReportError(VIR_ERR_XML_ERROR, "%s", - _("spice clipboard missing copypaste")); + virReportError(VIR_ERR_XML_ERROR, "%s", + _("spice clipboard missing copypaste")); goto error; } if ((copypasteVal = virDomainGraphicsSpiceClipboardCopypasteTypeFromString(copypaste)) <= 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("unknown copypaste value '%s'"), copypaste); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unknown copypaste value '%s'"), copypaste); VIR_FREE(copypaste); goto error; } @@ -6462,15 +6465,15 @@ virDomainGraphicsDefParseXML(xmlNodePtr node, int modeVal; if (!mode) { - virDomainReportError(VIR_ERR_XML_ERROR, "%s", - _("spice mouse missing mode")); + virReportError(VIR_ERR_XML_ERROR, "%s", + _("spice mouse missing mode")); goto error; } if ((modeVal = virDomainGraphicsSpiceMouseModeTypeFromString(mode)) <= 0) { - virDomainReportError(VIR_ERR_XML_ERROR, - _("unknown mouse mode value '%s'"), - mode); + virReportError(VIR_ERR_XML_ERROR, + _("unknown mouse mode value '%s'"), + mode); VIR_FREE(mode); goto error; } @@ -6511,8 +6514,8 @@ virDomainSoundCodecDefParseXML(const xmlNodePtr node) type = virXMLPropString(node, "type"); if ((def->type = virDomainSoundCodecTypeFromString(type)) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("unknown codec type '%s'"), type); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unknown codec type '%s'"), type); goto error; } @@ -6546,8 +6549,8 @@ virDomainSoundDefParseXML(const xmlNodePtr node, model = virXMLPropString(node, "model"); if ((def->model = virDomainSoundModelTypeFromString(model)) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("unknown sound model '%s'"), model); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unknown sound model '%s'"), model); goto error; } @@ -6613,14 +6616,14 @@ virDomainWatchdogDefParseXML(const xmlNodePtr node, model = virXMLPropString (node, "model"); if (model == NULL) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("watchdog must contain model name")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("watchdog must contain model name")); goto error; } def->model = virDomainWatchdogModelTypeFromString (model); if (def->model < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("unknown watchdog model '%s'"), model); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unknown watchdog model '%s'"), model); goto error; } @@ -6630,8 +6633,8 @@ virDomainWatchdogDefParseXML(const xmlNodePtr node, else { def->action = virDomainWatchdogActionTypeFromString (action); if (def->action < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("unknown watchdog action '%s'"), action); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unknown watchdog action '%s'"), action); goto error; } } @@ -6666,13 +6669,13 @@ virDomainMemballoonDefParseXML(const xmlNodePtr node, model = virXMLPropString(node, "model"); if (model == NULL) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("balloon memory must contain model name")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("balloon memory must contain model name")); goto error; } if ((def->model = virDomainMemballoonModelTypeFromString(model)) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("unknown memory balloon model '%s'"), model); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unknown memory balloon model '%s'"), model); goto error; } @@ -6698,8 +6701,8 @@ virSysinfoParseXML(const xmlNodePtr node, char *type; if (!xmlStrEqual(node->name, BAD_CAST "sysinfo")) { - virDomainReportError(VIR_ERR_XML_ERROR, "%s", - _("XML does not contain expected 'sysinfo' element")); + virReportError(VIR_ERR_XML_ERROR, "%s", + _("XML does not contain expected 'sysinfo' element")); return NULL; } @@ -6710,13 +6713,13 @@ virSysinfoParseXML(const xmlNodePtr node, type = virXMLPropString(node, "type"); if (type == NULL) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("sysinfo must contain a type attribute")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("sysinfo must contain a type attribute")); goto error; } if ((def->type = virSysinfoTypeFromString(type)) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("unknown sysinfo type '%s'"), type); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unknown sysinfo type '%s'"), type); goto error; } @@ -6893,22 +6896,22 @@ virDomainVideoDefParseXML(const xmlNodePtr node, if (type) { if ((def->type = virDomainVideoTypeFromString(type)) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("unknown video model '%s'"), type); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unknown video model '%s'"), type); goto error; } } else { if ((def->type = virDomainVideoDefaultType(dom)) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("missing video model and cannot determine default")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("missing video model and cannot determine default")); goto error; } } if (vram) { if (virStrToLong_ui(vram, NULL, 10, &def->vram) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("cannot parse video ram '%s'"), vram); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("cannot parse video ram '%s'"), vram); goto error; } } else { @@ -6917,8 +6920,8 @@ virDomainVideoDefParseXML(const xmlNodePtr node, if (heads) { if (virStrToLong_ui(heads, NULL, 10, &def->heads) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("cannot parse video heads '%s'"), heads); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("cannot parse video heads '%s'"), heads); goto error; } } else { @@ -6974,8 +6977,8 @@ virDomainHostdevDefParseXML(const xmlNodePtr node, case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI: if (def->info->type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE && def->info->type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("PCI host devices must use 'pci' address type")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("PCI host devices must use 'pci' address type")); goto error; } break; @@ -7011,8 +7014,8 @@ virDomainRedirdevDefParseXML(const xmlNodePtr node, bus = virXMLPropString(node, "bus"); if (bus) { if ((def->bus = virDomainRedirdevBusTypeFromString(bus)) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("unknown redirdev bus '%s'"), bus); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unknown redirdev bus '%s'"), bus); goto error; } } else { @@ -7022,13 +7025,13 @@ virDomainRedirdevDefParseXML(const xmlNodePtr node, type = virXMLPropString(node, "type"); if (type) { if ((def->source.chr.type = virDomainChrTypeFromString(type)) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("unknown redirdev character device type '%s'"), type); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unknown redirdev character device type '%s'"), type); goto error; } } else { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("missing type in redirdev")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("missing type in redirdev")); goto error; } @@ -7056,8 +7059,8 @@ virDomainRedirdevDefParseXML(const xmlNodePtr node, if (def->bus == VIR_DOMAIN_REDIRDEV_BUS_USB && def->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE && def->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_USB) { - virDomainReportError(VIR_ERR_XML_ERROR, "%s", - _("Invalid address for a USB device")); + virReportError(VIR_ERR_XML_ERROR, "%s", + _("Invalid address for a USB device")); goto error; } @@ -7085,8 +7088,8 @@ static int virDomainLifecycleParseXML(xmlXPathContextPtr ctxt, } else { *val = convFunc(tmp); if (*val < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("unknown lifecycle action %s"), tmp); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unknown lifecycle action %s"), tmp); VIR_FREE(tmp); return -1; } @@ -7172,8 +7175,8 @@ virDomainDeviceDefPtr virDomainDeviceDefParse(virCapsPtr caps, if (!(dev->data.redirdev = virDomainRedirdevDefParseXML(node, flags))) goto error; } else { - virDomainReportError(VIR_ERR_XML_ERROR, - "%s", _("unknown device type")); + virReportError(VIR_ERR_XML_ERROR, + "%s", _("unknown device type")); goto error; } @@ -7643,8 +7646,8 @@ static char *virDomainDefDefaultEmulator(virDomainDefPtr def, type = virDomainVirtTypeToString(def->virtType); if (!type) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("unknown virt type")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("unknown virt type")); return NULL; } @@ -7654,9 +7657,9 @@ static char *virDomainDefDefaultEmulator(virDomainDefPtr def, type); if (!emulator) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("no emulator for domain %s os type %s on architecture %s"), - type, def->os.type, def->os.arch); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("no emulator for domain %s os type %s on architecture %s"), + type, def->os.type, def->os.arch); return NULL; } @@ -7682,8 +7685,8 @@ virDomainDefParseBootXML(xmlXPathContextPtr ctxt, if (virXPathULong("count(./devices/disk[boot]" "|./devices/interface[boot]" "|./devices/hostdev[boot])", ctxt, &deviceBoot) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("cannot count boot devices")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("cannot count boot devices")); goto cleanup; } @@ -7693,9 +7696,9 @@ virDomainDefParseBootXML(xmlXPathContextPtr ctxt, } if (n > 0 && deviceBoot) { - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("per-device boot elements cannot be used" - " together with os/boot elements")); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("per-device boot elements cannot be used" + " together with os/boot elements")); goto cleanup; } @@ -7703,14 +7706,14 @@ virDomainDefParseBootXML(xmlXPathContextPtr ctxt, int val; char *dev = virXMLPropString(nodes[i], "dev"); if (!dev) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("missing boot device")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("missing boot device")); goto cleanup; } if ((val = virDomainBootTypeFromString(dev)) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("unknown boot device '%s'"), - dev); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unknown boot device '%s'"), + dev); VIR_FREE(dev); goto cleanup; } @@ -7736,9 +7739,9 @@ virDomainDefParseBootXML(xmlXPathContextPtr ctxt, if (STREQ(useserial, "yes")) { if (virXPathULong("count(./devices/serial)", ctxt, &serialPorts) < 0) { - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("need at least one serial port " - "for useserial")); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("need at least one serial port " + "for useserial")); goto cleanup; } def->os.bios.useserial = VIR_DOMAIN_BIOS_USESERIAL_YES; @@ -7777,18 +7780,18 @@ virDomainVcpuPinDefParseXML(const xmlNodePtr node, ret = virXPathUInt("string(./@vcpu)", ctxt, &vcpuid); if (ret == -2) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("vcpu id must be an unsigned integer")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("vcpu id must be an unsigned integer")); goto error; } else if (ret == -1) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("can't parse vcpupin node")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("can't parse vcpupin node")); goto error; } if (vcpuid >= maxvcpus) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("vcpu id must be less than maxvcpus")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("vcpu id must be less than maxvcpus")); goto error; } @@ -7809,8 +7812,8 @@ virDomainVcpuPinDefParseXML(const xmlNodePtr node, goto error; VIR_FREE(tmp); } else { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("missing cpuset for vcpupin")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("missing cpuset for vcpupin")); goto error; } @@ -7927,24 +7930,24 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps, /* Find out what type of virtualization to use */ if (!(tmp = virXPathString("string(./@type)", ctxt))) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("missing domain type attribute")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("missing domain type attribute")); goto error; } if ((def->virtType = virDomainVirtTypeFromString(tmp)) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("invalid domain type %s"), tmp); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("invalid domain type %s"), tmp); goto error; } VIR_FREE(tmp); if ((expectedVirtTypes & (1 << def->virtType)) == 0) { if (count_one_bits(expectedVirtTypes) == 1) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected domain type %s, expecting %s"), - virDomainVirtTypeToString(def->virtType), - virDomainVirtTypeToString(ffs(expectedVirtTypes) - 1)); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected domain type %s, expecting %s"), + virDomainVirtTypeToString(def->virtType), + virDomainVirtTypeToString(ffs(expectedVirtTypes) - 1)); } else { virBuffer buffer = VIR_BUFFER_INITIALIZER; char *string; @@ -7966,11 +7969,11 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps, string = virBufferContentAndReset(&buffer); - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected domain type %s, " - "expecting one of these: %s"), - virDomainVirtTypeToString(def->virtType), - string); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected domain type %s, " + "expecting one of these: %s"), + virDomainVirtTypeToString(def->virtType), + string); VIR_FREE(string); } @@ -7980,7 +7983,7 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps, /* Extract domain name */ if (!(def->name = virXPathString("string(./name[1])", ctxt))) { - virDomainReportError(VIR_ERR_NO_NAME, NULL); + virReportError(VIR_ERR_NO_NAME, NULL); goto error; } @@ -7990,15 +7993,15 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps, tmp = virXPathString("string(./uuid[1])", ctxt); if (!tmp) { if (virUUIDGenerate(def->uuid)) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("Failed to generate UUID")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("Failed to generate UUID")); goto error; } uuid_generated = true; } else { if (virUUIDParse(tmp, def->uuid) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("malformed uuid element")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("malformed uuid element")); goto error; } VIR_FREE(tmp); @@ -8007,8 +8010,8 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps, /* Extract short description of domain (title) */ def->title = virXPathString("string(./title[1])", ctxt); if (def->title && strchr(def->title, '\n')) { - virDomainReportError(VIR_ERR_XML_ERROR, "%s", - _("Domain title can't contain newlines")); + virReportError(VIR_ERR_XML_ERROR, "%s", + _("Domain title can't contain newlines")); goto error; } @@ -8035,10 +8038,10 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps, * round down, otherwise we flag the issue. */ if (VIR_DIV_UP(def->mem.cur_balloon, 1024) > VIR_DIV_UP(def->mem.max_balloon, 1024)) { - virDomainReportError(VIR_ERR_XML_ERROR, - _("current memory '%lluk' exceeds " - "maximum '%lluk'"), - def->mem.cur_balloon, def->mem.max_balloon); + virReportError(VIR_ERR_XML_ERROR, + _("current memory '%lluk' exceeds " + "maximum '%lluk'"), + def->mem.cur_balloon, def->mem.max_balloon); goto error; } else { VIR_DEBUG("Truncating current %lluk to maximum %lluk", @@ -8059,8 +8062,8 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps, def->blkio.weight = 0; if ((n = virXPathNodeSet("./blkiotune/device", ctxt, &nodes)) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("cannot extract blkiotune nodes")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("cannot extract blkiotune nodes")); goto error; } if (n && VIR_ALLOC_N(def->blkio.devices, n) < 0) @@ -8075,9 +8078,9 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps, for (j = 0; j < i; j++) { if (STREQ(def->blkio.devices[j].path, def->blkio.devices[i].path)) { - virDomainReportError(VIR_ERR_XML_ERROR, - _("duplicate device weight path '%s'"), - def->blkio.devices[i].path); + virReportError(VIR_ERR_XML_ERROR, + _("duplicate device weight path '%s'"), + def->blkio.devices[i].path); goto error; } } @@ -8103,39 +8106,39 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps, n = virXPathULong("string(./vcpu[1])", ctxt, &count); if (n == -2) { - virDomainReportError(VIR_ERR_XML_ERROR, "%s", - _("maximum vcpus must be an integer")); + virReportError(VIR_ERR_XML_ERROR, "%s", + _("maximum vcpus must be an integer")); goto error; } else if (n < 0) { def->maxvcpus = 1; } else { def->maxvcpus = count; if (count == 0) { - virDomainReportError(VIR_ERR_XML_ERROR, - _("invalid maxvcpus %lu"), count); + virReportError(VIR_ERR_XML_ERROR, + _("invalid maxvcpus %lu"), count); goto error; } } n = virXPathULong("string(./vcpu[1]/@current)", ctxt, &count); if (n == -2) { - virDomainReportError(VIR_ERR_XML_ERROR, "%s", - _("current vcpus must be an integer")); + virReportError(VIR_ERR_XML_ERROR, "%s", + _("current vcpus must be an integer")); goto error; } else if (n < 0) { def->vcpus = def->maxvcpus; } else { def->vcpus = count; if (count == 0) { - virDomainReportError(VIR_ERR_XML_ERROR, - _("invalid current vcpus %lu"), count); + virReportError(VIR_ERR_XML_ERROR, + _("invalid current vcpus %lu"), count); goto error; } if (def->maxvcpus < count) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("maxvcpus must not be less than current vcpus (%d < %lu)"), - def->maxvcpus, count); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("maxvcpus must not be less than current vcpus (%d < %lu)"), + def->maxvcpus, count); goto error; } } @@ -8144,9 +8147,9 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps, if (tmp) { if ((def->placement_mode = virDomainCpuPlacementModeTypeFromString(tmp)) < 0) { - virDomainReportError(VIR_ERR_XML_ERROR, - _("Unsupported CPU placement mode '%s'"), - tmp); + virReportError(VIR_ERR_XML_ERROR, + _("Unsupported CPU placement mode '%s'"), + tmp); VIR_FREE(tmp); goto error; } @@ -8191,8 +8194,8 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps, goto no_memory; if (n > def->maxvcpus) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("vcpupin nodes must be less than maxvcpus")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("vcpupin nodes must be less than maxvcpus")); goto error; } @@ -8206,8 +8209,8 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps, if (virDomainVcpuPinIsDuplicate(def->cputune.vcpupin, def->cputune.nvcpupin, vcpupin->vcpuid)) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("duplicate vcpupin for same vcpu")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("duplicate vcpupin for same vcpu")); VIR_FREE(vcpupin); goto error; } @@ -8218,14 +8221,14 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps, /* Extract numatune if exists. */ if ((n = virXPathNodeSet("./numatune", ctxt, &nodes)) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("cannot extract numatune nodes")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("cannot extract numatune nodes")); goto error; } if (n > 1) { - virDomainReportError(VIR_ERR_XML_ERROR, "%s", - _("only one numatune is supported")); + virReportError(VIR_ERR_XML_ERROR, "%s", + _("only one numatune is supported")); VIR_FREE(nodes); goto error; } @@ -8243,10 +8246,10 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps, if (mode) { if ((def->numatune.memory.mode = virDomainNumatuneMemModeTypeFromString(mode)) < 0) { - virDomainReportError(VIR_ERR_XML_ERROR, - _("Unsupported NUMA memory " - "tuning mode '%s'"), - mode); + virReportError(VIR_ERR_XML_ERROR, + _("Unsupported NUMA memory " + "tuning mode '%s'"), + mode); VIR_FREE(mode); goto error; } @@ -8281,9 +8284,9 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps, if (placement) { if ((placement_mode = virDomainNumatuneMemPlacementModeTypeFromString(placement)) < 0) { - virDomainReportError(VIR_ERR_XML_ERROR, - _("Unsupported memory placement " - "mode '%s'"), placement); + virReportError(VIR_ERR_XML_ERROR, + _("Unsupported memory placement " + "mode '%s'"), placement); VIR_FREE(placement); goto error; } @@ -8303,9 +8306,9 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps, if (placement_mode == VIR_DOMAIN_NUMATUNE_MEM_PLACEMENT_MODE_STATIC && !def->numatune.memory.nodemask) { - virDomainReportError(VIR_ERR_XML_ERROR, "%s", - _("nodeset for NUMA memory tuning must be set " - "if 'placement' is 'static'")); + virReportError(VIR_ERR_XML_ERROR, "%s", + _("nodeset for NUMA memory tuning must be set " + "if 'placement' is 'static'")); goto error; } @@ -8322,9 +8325,9 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps, def->numatune.memory.placement_mode = placement_mode; } else { - virDomainReportError(VIR_ERR_XML_ERROR, - _("unsupported XML element %s"), - (const char *)cur->name); + virReportError(VIR_ERR_XML_ERROR, + _("unsupported XML element %s"), + (const char *)cur->name); goto error; } } @@ -8348,9 +8351,9 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps, for (i = 0 ; i < n ; i++) { int val = virDomainFeatureTypeFromString((const char *)nodes[i]->name); if (val < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected feature %s"), - nodes[i]->name); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected feature %s"), + nodes[i]->name); goto error; } def->features |= (1 << val); @@ -8377,8 +8380,8 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps, tmp = virXPathString("string(./clock/@offset)", ctxt); if (tmp) { if ((def->clock.offset = virDomainClockOffsetTypeFromString(tmp)) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("unknown clock offset '%s'"), tmp); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unknown clock offset '%s'"), tmp); goto error; } VIR_FREE(tmp); @@ -8395,9 +8398,9 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps, } else { if (virStrToLong_ll(tmp, NULL, 10, &def->clock.data.variable.adjustment) < 0) { - virDomainReportError(VIR_ERR_XML_ERROR, - _("unknown clock adjustment '%s'"), - tmp); + virReportError(VIR_ERR_XML_ERROR, + _("unknown clock adjustment '%s'"), + tmp); goto error; } switch (def->clock.offset) { @@ -8423,8 +8426,8 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps, tmp = virXPathString("string(./clock/@basis)", ctxt); if (tmp) { if ((def->clock.data.variable.basis = virDomainClockBasisTypeFromString(tmp)) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("unknown clock basis '%s'"), tmp); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unknown clock basis '%s'"), tmp); goto error; } VIR_FREE(tmp); @@ -8436,8 +8439,8 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps, case VIR_DOMAIN_CLOCK_OFFSET_TIMEZONE: def->clock.data.timezone = virXPathString("string(./clock/@timezone)", ctxt); if (!def->clock.data.timezone) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("missing 'timezone' attribute for clock with offset='timezone'")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("missing 'timezone' attribute for clock with offset='timezone'")); goto error; } break; @@ -8469,8 +8472,8 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps, goto no_memory; } } else { - virDomainReportError(VIR_ERR_OS_TYPE, - "%s", _("no OS type")); + virReportError(VIR_ERR_OS_TYPE, + "%s", _("no OS type")); goto error; } } @@ -8488,34 +8491,34 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps, } if (!virCapabilitiesSupportsGuestOSType(caps, def->os.type)) { - virDomainReportError(VIR_ERR_OS_TYPE, - "%s", def->os.type); + virReportError(VIR_ERR_OS_TYPE, + "%s", def->os.type); goto error; } def->os.arch = virXPathString("string(./os/type[1]/@arch)", ctxt); if (def->os.arch) { if (!virCapabilitiesSupportsGuestArch(caps, def->os.arch)) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("No guest options available for arch '%s'"), - def->os.arch); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("No guest options available for arch '%s'"), + def->os.arch); goto error; } if (!virCapabilitiesSupportsGuestOSTypeArch(caps, def->os.type, def->os.arch)) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("No os type '%s' available for arch '%s'"), - def->os.type, def->os.arch); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("No os type '%s' available for arch '%s'"), + def->os.type, def->os.arch); goto error; } } else { const char *defaultArch = virCapabilitiesDefaultGuestArch(caps, def->os.type, virDomainVirtTypeToString(def->virtType)); if (defaultArch == NULL) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("no supported architecture for os type '%s'"), - def->os.type); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("no supported architecture for os type '%s'"), + def->os.type); goto error; } if (!(def->os.arch = strdup(defaultArch))) { @@ -8554,8 +8557,8 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps, goto no_memory; } } else { - virDomainReportError(VIR_ERR_XML_ERROR, "%s", - _("init binary must be specified")); + virReportError(VIR_ERR_XML_ERROR, "%s", + _("init binary must be specified")); goto error; } } @@ -8570,8 +8573,8 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps, for (i = 0 ; i < n ; i++) { if (!nodes[i]->children || !nodes[i]->children->content) { - virDomainReportError(VIR_ERR_XML_ERROR, "%s", - _("No data supplied for <initarg> element")); + virReportError(VIR_ERR_XML_ERROR, "%s", + _("No data supplied for <initarg> element")); goto error; } if (!(def->os.initargv[i] = strdup((const char*)nodes[i]->children->content))) @@ -8649,8 +8652,8 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps, /* analysis of the resource leases */ if ((n = virXPathNodeSet("./devices/lease", ctxt, &nodes)) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("cannot extract device leases")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("cannot extract device leases")); goto error; } if (n && VIR_ALLOC_N(def->leases, n) < 0) @@ -8780,8 +8783,8 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps, VIR_FREE(nodes); if ((n = virXPathNodeSet("./devices/console", ctxt, &nodes)) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("cannot extract console devices")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("cannot extract console devices")); goto error; } if (n && VIR_ALLOC_N(def->consoles, n) < 0) @@ -8817,8 +8820,8 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps, if (STREQ(def->os.type, "hvm") && (chr->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL)) { if (i != 0) { - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("Only the first console can be a serial port")); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Only the first console can be a serial port")); virDomainChrDefFree(chr); goto error; } @@ -9011,8 +9014,8 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps, goto no_memory; video->type = virDomainVideoDefaultType(def); if (video->type < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("cannot determine default video type")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("cannot determine default video type")); VIR_FREE(video); goto error; } @@ -9048,8 +9051,8 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps, goto error; } if (n > 1) { - virDomainReportError (VIR_ERR_INTERNAL_ERROR, - "%s", _("only a single watchdog device is supported")); + virReportError (VIR_ERR_INTERNAL_ERROR, + "%s", _("only a single watchdog device is supported")); goto error; } if (n > 0) { @@ -9068,8 +9071,8 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps, goto error; } if (n > 1) { - virDomainReportError (VIR_ERR_INTERNAL_ERROR, - "%s", _("only a single memory balloon device is supported")); + virReportError (VIR_ERR_INTERNAL_ERROR, + "%s", _("only a single memory balloon device is supported")); goto error; } if (n > 0) { @@ -9140,15 +9143,15 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps, if (def->cpu->sockets && def->maxvcpus > def->cpu->sockets * def->cpu->cores * def->cpu->threads) { - virDomainReportError(VIR_ERR_XML_DETAIL, "%s", - _("Maximum CPUs greater than topology limit")); + virReportError(VIR_ERR_XML_DETAIL, "%s", + _("Maximum CPUs greater than topology limit")); goto error; } if (def->cpu->cells_cpus > def->maxvcpus) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Number of CPUs in <numa> exceeds the" - " <vcpu> count")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Number of CPUs in <numa> exceeds the" + " <vcpu> count")); goto error; } } @@ -9164,16 +9167,16 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps, if (def->sysinfo->system_uuid != NULL) { unsigned char uuidbuf[VIR_UUID_BUFLEN]; if (virUUIDParse(def->sysinfo->system_uuid, uuidbuf) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("malformed uuid element")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("malformed uuid element")); goto error; } if (uuid_generated) memcpy(def->uuid, uuidbuf, VIR_UUID_BUFLEN); else if (memcmp(def->uuid, uuidbuf, VIR_UUID_BUFLEN) != 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("UUID mismatch between <uuid> and " - "<sysinfo>")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("UUID mismatch between <uuid> and " + "<sysinfo>")); goto error; } } @@ -9183,8 +9186,8 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps, int mode; if ((mode = virDomainSmbiosModeTypeFromString(tmp)) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("unknown smbios mode '%s'"), tmp); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unknown smbios mode '%s'"), tmp); goto error; } def->os.smbios_mode = mode; @@ -9250,8 +9253,8 @@ static virDomainObjPtr virDomainObjParseXML(virCapsPtr caps, return NULL; if (!(config = virXPathNode("./domain", ctxt))) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("no domain config")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("no domain config")); goto error; } @@ -9264,13 +9267,13 @@ static virDomainObjPtr virDomainObjParseXML(virCapsPtr caps, goto error; if (!(tmp = virXPathString("string(./@state)", ctxt))) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("missing domain state")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("missing domain state")); goto error; } if ((state = virDomainStateTypeFromString(tmp)) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("invalid domain state '%s'"), tmp); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("invalid domain state '%s'"), tmp); VIR_FREE(tmp); goto error; } @@ -9278,8 +9281,8 @@ static virDomainObjPtr virDomainObjParseXML(virCapsPtr caps, if ((tmp = virXPathString("string(./@reason)", ctxt))) { if ((reason = virDomainStateReasonFromString(state, tmp)) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("invalid domain state reason '%s'"), tmp); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("invalid domain state reason '%s'"), tmp); VIR_FREE(tmp); goto error; } @@ -9289,8 +9292,8 @@ static virDomainObjPtr virDomainObjParseXML(virCapsPtr caps, virDomainObjSetState(obj, state, reason); if (virXPathLong("string(./@pid)", ctxt, &val) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("invalid pid")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("invalid pid")); goto error; } obj->pid = (pid_t)val; @@ -9303,8 +9306,8 @@ static virDomainObjPtr virDomainObjParseXML(virCapsPtr caps, if (str) { int flag = virDomainTaintTypeFromString(str); if (flag < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("Unknown taint flag %s"), str); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Unknown taint flag %s"), str); VIR_FREE(str); goto error; } @@ -9376,10 +9379,10 @@ virDomainDefPtr virDomainDefParseNode(virCapsPtr caps, virDomainDefPtr def = NULL; if (!xmlStrEqual(root->name, BAD_CAST "domain")) { - virDomainReportError(VIR_ERR_XML_ERROR, - _("unexpected root element <%s>, " - "expecting <domain>"), - root->name); + virReportError(VIR_ERR_XML_ERROR, + _("unexpected root element <%s>, " + "expecting <domain>"), + root->name); goto cleanup; } @@ -9409,10 +9412,10 @@ virDomainObjParseNode(virCapsPtr caps, virDomainObjPtr obj = NULL; if (!xmlStrEqual(root->name, BAD_CAST "domstatus")) { - virDomainReportError(VIR_ERR_XML_ERROR, - _("unexpected root element <%s>, " - "expecting <domstatus>"), - root->name); + virReportError(VIR_ERR_XML_ERROR, + _("unexpected root element <%s>, " + "expecting <domstatus>"), + root->name); goto cleanup; } @@ -9459,33 +9462,33 @@ static bool virDomainTimerDefCheckABIStability(virDomainTimerDefPtr src, bool identical = false; if (src->name != dst->name) { - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Target timer %s does not match source %s"), - virDomainTimerNameTypeToString(dst->name), - virDomainTimerNameTypeToString(src->name)); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target timer %s does not match source %s"), + virDomainTimerNameTypeToString(dst->name), + virDomainTimerNameTypeToString(src->name)); goto cleanup; } if (src->present != dst->present) { - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Target timer presence %d does not match source %d"), - dst->present, src->present); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target timer presence %d does not match source %d"), + dst->present, src->present); goto cleanup; } if (src->name == VIR_DOMAIN_TIMER_NAME_TSC) { if (src->frequency != dst->frequency) { - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Target TSC frequency %lu does not match source %lu"), - dst->frequency, src->frequency); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target TSC frequency %lu does not match source %lu"), + dst->frequency, src->frequency); goto cleanup; } if (src->mode != dst->mode) { - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Target TSC mode %s does not match source %s"), - virDomainTimerModeTypeToString(dst->mode), - virDomainTimerModeTypeToString(src->mode)); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target TSC mode %s does not match source %s"), + virDomainTimerModeTypeToString(dst->mode), + virDomainTimerModeTypeToString(src->mode)); goto cleanup; } } @@ -9503,10 +9506,10 @@ static bool virDomainDeviceInfoCheckABIStability(virDomainDeviceInfoPtr src, bool identical = false; if (src->type != dst->type) { - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Target device address type %s does not match source %s"), - virDomainDeviceAddressTypeToString(dst->type), - virDomainDeviceAddressTypeToString(src->type)); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target device address type %s does not match source %s"), + virDomainDeviceAddressTypeToString(dst->type), + virDomainDeviceAddressTypeToString(src->type)); goto cleanup; } @@ -9516,12 +9519,12 @@ static bool virDomainDeviceInfoCheckABIStability(virDomainDeviceInfoPtr src, src->addr.pci.bus != dst->addr.pci.bus || src->addr.pci.slot != dst->addr.pci.slot || src->addr.pci.function != dst->addr.pci.function) { - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Target device PCI address %04x:%02x:%02x.%02x does not match source %04x:%02x:%02x.%02x"), - dst->addr.pci.domain, dst->addr.pci.bus, - dst->addr.pci.slot, dst->addr.pci.function, - src->addr.pci.domain, src->addr.pci.bus, - src->addr.pci.slot, src->addr.pci.function); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target device PCI address %04x:%02x:%02x.%02x does not match source %04x:%02x:%02x.%02x"), + dst->addr.pci.domain, dst->addr.pci.bus, + dst->addr.pci.slot, dst->addr.pci.function, + src->addr.pci.domain, src->addr.pci.bus, + src->addr.pci.slot, src->addr.pci.function); goto cleanup; } break; @@ -9530,12 +9533,12 @@ static bool virDomainDeviceInfoCheckABIStability(virDomainDeviceInfoPtr src, if (src->addr.drive.controller != dst->addr.drive.controller || src->addr.drive.bus != dst->addr.drive.bus || src->addr.drive.unit != dst->addr.drive.unit) { - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Target device drive address %d:%d:%d does not match source %d:%d:%d"), - dst->addr.drive.controller, dst->addr.drive.bus, - dst->addr.drive.unit, - src->addr.drive.controller, src->addr.drive.bus, - src->addr.drive.unit); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target device drive address %d:%d:%d does not match source %d:%d:%d"), + dst->addr.drive.controller, dst->addr.drive.bus, + dst->addr.drive.unit, + src->addr.drive.controller, src->addr.drive.bus, + src->addr.drive.unit); goto cleanup; } break; @@ -9544,12 +9547,12 @@ static bool virDomainDeviceInfoCheckABIStability(virDomainDeviceInfoPtr src, if (src->addr.vioserial.controller != dst->addr.vioserial.controller || src->addr.vioserial.bus != dst->addr.vioserial.bus || src->addr.vioserial.port != dst->addr.vioserial.port) { - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Target device virtio serial address %d:%d:%d does not match source %d:%d:%d"), - dst->addr.vioserial.controller, dst->addr.vioserial.bus, - dst->addr.vioserial.port, - src->addr.vioserial.controller, src->addr.vioserial.bus, - src->addr.vioserial.port); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target device virtio serial address %d:%d:%d does not match source %d:%d:%d"), + dst->addr.vioserial.controller, dst->addr.vioserial.bus, + dst->addr.vioserial.port, + src->addr.vioserial.controller, src->addr.vioserial.bus, + src->addr.vioserial.port); goto cleanup; } break; @@ -9557,12 +9560,12 @@ static bool virDomainDeviceInfoCheckABIStability(virDomainDeviceInfoPtr src, case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCID: if (src->addr.ccid.controller != dst->addr.ccid.controller || src->addr.ccid.slot != dst->addr.ccid.slot) { - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Target device ccid address %d:%d does not match source %d:%d"), - dst->addr.ccid.controller, - dst->addr.ccid.slot, - src->addr.ccid.controller, - src->addr.ccid.slot); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target device ccid address %d:%d does not match source %d:%d"), + dst->addr.ccid.controller, + dst->addr.ccid.slot, + src->addr.ccid.controller, + src->addr.ccid.slot); goto cleanup; } break; @@ -9581,38 +9584,38 @@ static bool virDomainDiskDefCheckABIStability(virDomainDiskDefPtr src, bool identical = false; if (src->device != dst->device) { - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Target disk device %s does not match source %s"), - virDomainDiskDeviceTypeToString(dst->device), - virDomainDiskDeviceTypeToString(src->device)); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target disk device %s does not match source %s"), + virDomainDiskDeviceTypeToString(dst->device), + virDomainDiskDeviceTypeToString(src->device)); goto cleanup; } if (src->bus != dst->bus) { - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Target disk bus %s does not match source %s"), - virDomainDiskBusTypeToString(dst->bus), - virDomainDiskBusTypeToString(src->bus)); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target disk bus %s does not match source %s"), + virDomainDiskBusTypeToString(dst->bus), + virDomainDiskBusTypeToString(src->bus)); goto cleanup; } if (STRNEQ(src->dst, dst->dst)) { - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Target disk %s does not match source %s"), - dst->dst, src->dst); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target disk %s does not match source %s"), + dst->dst, src->dst); goto cleanup; } if (STRNEQ_NULLABLE(src->serial, dst->serial)) { - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Target disk serial %s does not match source %s"), - NULLSTR(dst->serial), NULLSTR(src->serial)); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target disk serial %s does not match source %s"), + NULLSTR(dst->serial), NULLSTR(src->serial)); goto cleanup; } if (src->readonly != dst->readonly || src->shared != dst->shared) { - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("Target disk access mode does not match source")); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Target disk access mode does not match source")); goto cleanup; } @@ -9632,39 +9635,39 @@ static bool virDomainControllerDefCheckABIStability(virDomainControllerDefPtr sr bool identical = false; if (src->type != dst->type) { - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Target controller type %s does not match source %s"), - virDomainControllerTypeToString(dst->type), - virDomainControllerTypeToString(src->type)); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target controller type %s does not match source %s"), + virDomainControllerTypeToString(dst->type), + virDomainControllerTypeToString(src->type)); goto cleanup; } if (src->idx != dst->idx) { - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Target controller index %d does not match source %d"), - dst->idx, src->idx); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target controller index %d does not match source %d"), + dst->idx, src->idx); goto cleanup; } if (src->model != dst->model) { - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Target controller model %d does not match source %d"), - dst->model, src->model); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target controller model %d does not match source %d"), + dst->model, src->model); goto cleanup; } if (src->type == VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL) { if (src->opts.vioserial.ports != dst->opts.vioserial.ports) { - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Target controller ports %d does not match source %d"), - dst->opts.vioserial.ports, src->opts.vioserial.ports); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target controller ports %d does not match source %d"), + dst->opts.vioserial.ports, src->opts.vioserial.ports); goto cleanup; } if (src->opts.vioserial.vectors != dst->opts.vioserial.vectors) { - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Target controller vectors %d does not match source %d"), - dst->opts.vioserial.vectors, src->opts.vioserial.vectors); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target controller vectors %d does not match source %d"), + dst->opts.vioserial.vectors, src->opts.vioserial.vectors); goto cleanup; } } @@ -9685,15 +9688,15 @@ static bool virDomainFsDefCheckABIStability(virDomainFSDefPtr src, bool identical = false; if (STRNEQ(src->dst, dst->dst)) { - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Target filesystem guest target %s does not match source %s"), - dst->dst, src->dst); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target filesystem guest target %s does not match source %s"), + dst->dst, src->dst); goto cleanup; } if (src->readonly != dst->readonly) { - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("Target filesystem access mode does not match source")); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Target filesystem access mode does not match source")); goto cleanup; } @@ -9713,20 +9716,20 @@ static bool virDomainNetDefCheckABIStability(virDomainNetDefPtr src, bool identical = false; if (virMacAddrCmp(&src->mac, &dst->mac) != 0) { - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Target network card mac %02x:%02x:%02x:%02x:%02x:%02x" - "does not match source %02x:%02x:%02x:%02x:%02x:%02x"), - dst->mac.addr[0], dst->mac.addr[1], dst->mac.addr[2], - dst->mac.addr[3], dst->mac.addr[4], dst->mac.addr[5], - src->mac.addr[0], src->mac.addr[1], src->mac.addr[2], - src->mac.addr[3], src->mac.addr[4], src->mac.addr[5]); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target network card mac %02x:%02x:%02x:%02x:%02x:%02x" + "does not match source %02x:%02x:%02x:%02x:%02x:%02x"), + dst->mac.addr[0], dst->mac.addr[1], dst->mac.addr[2], + dst->mac.addr[3], dst->mac.addr[4], dst->mac.addr[5], + src->mac.addr[0], src->mac.addr[1], src->mac.addr[2], + src->mac.addr[3], src->mac.addr[4], src->mac.addr[5]); goto cleanup; } if (STRNEQ_NULLABLE(src->model, dst->model)) { - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Target network card model %s does not match source %s"), - NULLSTR(dst->model), NULLSTR(src->model)); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target network card model %s does not match source %s"), + NULLSTR(dst->model), NULLSTR(src->model)); goto cleanup; } @@ -9746,18 +9749,18 @@ static bool virDomainInputDefCheckABIStability(virDomainInputDefPtr src, bool identical = false; if (src->type != dst->type) { - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Target input device type %s does not match source %s"), - virDomainInputTypeToString(dst->type), - virDomainInputTypeToString(src->type)); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target input device type %s does not match source %s"), + virDomainInputTypeToString(dst->type), + virDomainInputTypeToString(src->type)); goto cleanup; } if (src->bus != dst->bus) { - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Target input device bus %s does not match source %s"), - virDomainInputBusTypeToString(dst->bus), - virDomainInputBusTypeToString(src->bus)); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target input device bus %s does not match source %s"), + virDomainInputBusTypeToString(dst->bus), + virDomainInputBusTypeToString(src->bus)); goto cleanup; } @@ -9777,10 +9780,10 @@ static bool virDomainSoundDefCheckABIStability(virDomainSoundDefPtr src, bool identical = false; if (src->model != dst->model) { - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Target sound card model %s does not match source %s"), - virDomainSoundModelTypeToString(dst->model), - virDomainSoundModelTypeToString(src->model)); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target sound card model %s does not match source %s"), + virDomainSoundModelTypeToString(dst->model), + virDomainSoundModelTypeToString(src->model)); goto cleanup; } @@ -9800,46 +9803,46 @@ static bool virDomainVideoDefCheckABIStability(virDomainVideoDefPtr src, bool identical = false; if (src->type != dst->type) { - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Target video card model %s does not match source %s"), - virDomainVideoTypeToString(dst->type), - virDomainVideoTypeToString(src->type)); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target video card model %s does not match source %s"), + virDomainVideoTypeToString(dst->type), + virDomainVideoTypeToString(src->type)); goto cleanup; } if (src->vram != dst->vram) { - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Target video card vram %u does not match source %u"), - dst->vram, src->vram); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target video card vram %u does not match source %u"), + dst->vram, src->vram); goto cleanup; } if (src->heads != dst->heads) { - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Target video card heads %u does not match source %u"), - dst->heads, src->heads); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target video card heads %u does not match source %u"), + dst->heads, src->heads); goto cleanup; } if ((src->accel && !dst->accel) || (!src->accel && dst->accel)) { - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("Target video card acceleration does not match source")); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Target video card acceleration does not match source")); goto cleanup; } if (src->accel) { if (src->accel->support2d != dst->accel->support2d) { - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Target video card 2d accel %u does not match source %u"), - dst->accel->support2d, src->accel->support2d); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target video card 2d accel %u does not match source %u"), + dst->accel->support2d, src->accel->support2d); goto cleanup; } if (src->accel->support3d != dst->accel->support3d) { - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Target video card 3d accel %u does not match source %u"), - dst->accel->support3d, src->accel->support3d); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target video card 3d accel %u does not match source %u"), + dst->accel->support3d, src->accel->support3d); goto cleanup; } } @@ -9860,19 +9863,19 @@ static bool virDomainHostdevDefCheckABIStability(virDomainHostdevDefPtr src, bool identical = false; if (src->mode != dst->mode) { - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Target host device mode %s does not match source %s"), - virDomainHostdevModeTypeToString(dst->mode), - virDomainHostdevModeTypeToString(src->mode)); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target host device mode %s does not match source %s"), + virDomainHostdevModeTypeToString(dst->mode), + virDomainHostdevModeTypeToString(src->mode)); goto cleanup; } if (src->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS) { if (src->source.subsys.type != dst->source.subsys.type) { - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Target host device subsystem %s does not match source %s"), - virDomainHostdevSubsysTypeToString(dst->source.subsys.type), - virDomainHostdevSubsysTypeToString(src->source.subsys.type)); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target host device subsystem %s does not match source %s"), + virDomainHostdevSubsysTypeToString(dst->source.subsys.type), + virDomainHostdevSubsysTypeToString(src->source.subsys.type)); goto cleanup; } } @@ -9908,9 +9911,9 @@ static bool virDomainSerialDefCheckABIStability(virDomainChrDefPtr src, bool identical = false; if (src->target.port != dst->target.port) { - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Target serial port %d does not match source %d"), - dst->target.port, src->target.port); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target serial port %d does not match source %d"), + dst->target.port, src->target.port); goto cleanup; } @@ -9930,9 +9933,9 @@ static bool virDomainParallelDefCheckABIStability(virDomainChrDefPtr src, bool identical = false; if (src->target.port != dst->target.port) { - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Target serial port %d does not match source %d"), - dst->target.port, src->target.port); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target serial port %d does not match source %d"), + dst->target.port, src->target.port); goto cleanup; } @@ -9952,19 +9955,19 @@ static bool virDomainChannelDefCheckABIStability(virDomainChrDefPtr src, bool identical = false; if (src->targetType != dst->targetType) { - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Target channel type %s does not match source %s"), - virDomainChrChannelTargetTypeToString(dst->targetType), - virDomainChrChannelTargetTypeToString(src->targetType)); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target channel type %s does not match source %s"), + virDomainChrChannelTargetTypeToString(dst->targetType), + virDomainChrChannelTargetTypeToString(src->targetType)); goto cleanup; } switch (src->targetType) { case VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VIRTIO: if (STRNEQ_NULLABLE(src->target.name, dst->target.name)) { - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Target channel name %s does not match source %s"), - NULLSTR(dst->target.name), NULLSTR(src->target.name)); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target channel name %s does not match source %s"), + NULLSTR(dst->target.name), NULLSTR(src->target.name)); goto cleanup; } break; @@ -9973,9 +9976,9 @@ static bool virDomainChannelDefCheckABIStability(virDomainChrDefPtr src, sizeof(*src->target.addr)) != 0) { char *saddr = virSocketAddrFormatFull(src->target.addr, true, ":"); char *daddr = virSocketAddrFormatFull(dst->target.addr, true, ":"); - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Target channel addr %s does not match source %s"), - NULLSTR(daddr), NULLSTR(saddr)); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target channel addr %s does not match source %s"), + NULLSTR(daddr), NULLSTR(saddr)); VIR_FREE(saddr); VIR_FREE(daddr); goto cleanup; @@ -9999,10 +10002,10 @@ static bool virDomainConsoleDefCheckABIStability(virDomainChrDefPtr src, bool identical = false; if (src->targetType != dst->targetType) { - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Target console type %s does not match source %s"), - virDomainChrConsoleTargetTypeToString(dst->targetType), - virDomainChrConsoleTargetTypeToString(src->targetType)); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target console type %s does not match source %s"), + virDomainChrConsoleTargetTypeToString(dst->targetType), + virDomainChrConsoleTargetTypeToString(src->targetType)); goto cleanup; } @@ -10022,10 +10025,10 @@ static bool virDomainWatchdogDefCheckABIStability(virDomainWatchdogDefPtr src, bool identical = false; if (src->model != dst->model) { - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Target watchdog model %s does not match source %s"), - virDomainWatchdogModelTypeToString(dst->model), - virDomainWatchdogModelTypeToString(src->model)); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target watchdog model %s does not match source %s"), + virDomainWatchdogModelTypeToString(dst->model), + virDomainWatchdogModelTypeToString(src->model)); goto cleanup; } @@ -10045,10 +10048,10 @@ static bool virDomainMemballoonDefCheckABIStability(virDomainMemballoonDefPtr sr bool identical = false; if (src->model != dst->model) { - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Target balloon model %s does not match source %s"), - virDomainMemballoonModelTypeToString(dst->model), - virDomainMemballoonModelTypeToString(src->model)); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target balloon model %s does not match source %s"), + virDomainMemballoonModelTypeToString(dst->model), + virDomainMemballoonModelTypeToString(src->model)); goto cleanup; } @@ -10068,10 +10071,10 @@ static bool virDomainHubDefCheckABIStability(virDomainHubDefPtr src, bool identical = false; if (src->type != dst->type) { - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Target hub device type %s does not match source %s"), - virDomainHubTypeToString(dst->type), - virDomainHubTypeToString(src->type)); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target hub device type %s does not match source %s"), + virDomainHubTypeToString(dst->type), + virDomainHubTypeToString(src->type)); goto cleanup; } @@ -10096,10 +10099,10 @@ bool virDomainDefCheckABIStability(virDomainDefPtr src, int i; if (src->virtType != dst->virtType) { - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Target domain virt type %s does not match source %s"), - virDomainVirtTypeToString(dst->virtType), - virDomainVirtTypeToString(src->virtType)); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target domain virt type %s does not match source %s"), + virDomainVirtTypeToString(dst->virtType), + virDomainVirtTypeToString(src->virtType)); goto cleanup; } @@ -10108,82 +10111,82 @@ bool virDomainDefCheckABIStability(virDomainDefPtr src, char uuiddst[VIR_UUID_STRING_BUFLEN]; virUUIDFormat(src->uuid, uuidsrc); virUUIDFormat(dst->uuid, uuiddst); - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Target domain uuid %s does not match source %s"), - uuiddst, uuidsrc); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target domain uuid %s does not match source %s"), + uuiddst, uuidsrc); goto cleanup; } if (src->mem.max_balloon != dst->mem.max_balloon) { - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Target domain max memory %lld does not match source %lld"), - dst->mem.max_balloon, src->mem.max_balloon); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target domain max memory %lld does not match source %lld"), + dst->mem.max_balloon, src->mem.max_balloon); goto cleanup; } if (src->mem.cur_balloon != dst->mem.cur_balloon) { - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Target domain current memory %lld does not match source %lld"), - dst->mem.cur_balloon, src->mem.cur_balloon); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target domain current memory %lld does not match source %lld"), + dst->mem.cur_balloon, src->mem.cur_balloon); goto cleanup; } if (src->mem.hugepage_backed != dst->mem.hugepage_backed) { - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Target domain huge page backing %d does not match source %d"), - dst->mem.hugepage_backed, - src->mem.hugepage_backed); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target domain huge page backing %d does not match source %d"), + dst->mem.hugepage_backed, + src->mem.hugepage_backed); goto cleanup; } if (src->vcpus != dst->vcpus) { - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Target domain vpu count %d does not match source %d"), - dst->vcpus, src->vcpus); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target domain vpu count %d does not match source %d"), + dst->vcpus, src->vcpus); goto cleanup; } if (src->maxvcpus != dst->maxvcpus) { - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Target domain vpu max %d does not match source %d"), - dst->maxvcpus, src->maxvcpus); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target domain vpu max %d does not match source %d"), + dst->maxvcpus, src->maxvcpus); goto cleanup; } if (STRNEQ(src->os.type, dst->os.type)) { - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Target domain OS type %s does not match source %s"), - dst->os.type, src->os.type); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target domain OS type %s does not match source %s"), + dst->os.type, src->os.type); goto cleanup; } if (STRNEQ(src->os.arch, dst->os.arch)) { - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Target domain architecture %s does not match source %s"), - dst->os.arch, src->os.arch); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target domain architecture %s does not match source %s"), + dst->os.arch, src->os.arch); goto cleanup; } if (STRNEQ(src->os.machine, dst->os.machine)) { - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Target domain OS type %s does not match source %s"), - dst->os.machine, src->os.machine); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target domain OS type %s does not match source %s"), + dst->os.machine, src->os.machine); goto cleanup; } if (src->os.smbios_mode != dst->os.smbios_mode) { - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Target domain SMBIOS mode %s does not match source %s"), - virDomainSmbiosModeTypeToString(dst->os.smbios_mode), - virDomainSmbiosModeTypeToString(src->os.smbios_mode)); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target domain SMBIOS mode %s does not match source %s"), + virDomainSmbiosModeTypeToString(dst->os.smbios_mode), + virDomainSmbiosModeTypeToString(src->os.smbios_mode)); goto cleanup; } if (src->features != dst->features) { - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Target domain features %d does not match source %d"), - dst->features, src->features); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target domain features %d does not match source %d"), + dst->features, src->features); goto cleanup; } if (src->clock.ntimers != dst->clock.ntimers) { - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("Target domain timers do not match source")); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Target domain timers do not match source")); goto cleanup; } @@ -10199,9 +10202,9 @@ bool virDomainDefCheckABIStability(virDomainDefPtr src, goto cleanup; if (src->ndisks != dst->ndisks) { - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Target domain disk count %d does not match source %d"), - dst->ndisks, src->ndisks); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target domain disk count %d does not match source %d"), + dst->ndisks, src->ndisks); goto cleanup; } @@ -10210,9 +10213,9 @@ bool virDomainDefCheckABIStability(virDomainDefPtr src, goto cleanup; if (src->ncontrollers != dst->ncontrollers) { - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Target domain disk controller count %d does not match source %d"), - dst->ncontrollers, src->ncontrollers); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target domain disk controller count %d does not match source %d"), + dst->ncontrollers, src->ncontrollers); goto cleanup; } @@ -10221,9 +10224,9 @@ bool virDomainDefCheckABIStability(virDomainDefPtr src, goto cleanup; if (src->nfss != dst->nfss) { - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Target domain filesystem count %d does not match source %d"), - dst->nfss, src->nfss); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target domain filesystem count %d does not match source %d"), + dst->nfss, src->nfss); goto cleanup; } @@ -10232,9 +10235,9 @@ bool virDomainDefCheckABIStability(virDomainDefPtr src, goto cleanup; if (src->nnets != dst->nnets) { - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Target domain net card count %d does not match source %d"), - dst->nnets, src->nnets); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target domain net card count %d does not match source %d"), + dst->nnets, src->nnets); goto cleanup; } @@ -10243,9 +10246,9 @@ bool virDomainDefCheckABIStability(virDomainDefPtr src, goto cleanup; if (src->ninputs != dst->ninputs) { - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Target domain input device count %d does not match source %d"), - dst->ninputs, src->ninputs); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target domain input device count %d does not match source %d"), + dst->ninputs, src->ninputs); goto cleanup; } @@ -10254,9 +10257,9 @@ bool virDomainDefCheckABIStability(virDomainDefPtr src, goto cleanup; if (src->nsounds != dst->nsounds) { - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Target domain sound card count %d does not match source %d"), - dst->nsounds, src->nsounds); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target domain sound card count %d does not match source %d"), + dst->nsounds, src->nsounds); goto cleanup; } @@ -10265,9 +10268,9 @@ bool virDomainDefCheckABIStability(virDomainDefPtr src, goto cleanup; if (src->nvideos != dst->nvideos) { - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Target domain video card count %d does not match source %d"), - dst->nvideos, src->nvideos); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target domain video card count %d does not match source %d"), + dst->nvideos, src->nvideos); goto cleanup; } @@ -10276,9 +10279,9 @@ bool virDomainDefCheckABIStability(virDomainDefPtr src, goto cleanup; if (src->nhostdevs != dst->nhostdevs) { - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Target domain host device count %d does not match source %d"), - dst->nhostdevs, src->nhostdevs); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target domain host device count %d does not match source %d"), + dst->nhostdevs, src->nhostdevs); goto cleanup; } @@ -10287,9 +10290,9 @@ bool virDomainDefCheckABIStability(virDomainDefPtr src, goto cleanup; if (src->nsmartcards != dst->nsmartcards) { - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Target domain smartcard count %d does not match source %d"), - dst->nsmartcards, src->nsmartcards); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target domain smartcard count %d does not match source %d"), + dst->nsmartcards, src->nsmartcards); goto cleanup; } @@ -10298,9 +10301,9 @@ bool virDomainDefCheckABIStability(virDomainDefPtr src, goto cleanup; if (src->nserials != dst->nserials) { - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Target domain serial port count %d does not match source %d"), - dst->nserials, src->nserials); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target domain serial port count %d does not match source %d"), + dst->nserials, src->nserials); goto cleanup; } @@ -10309,9 +10312,9 @@ bool virDomainDefCheckABIStability(virDomainDefPtr src, goto cleanup; if (src->nparallels != dst->nparallels) { - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Target domain parallel port count %d does not match source %d"), - dst->nparallels, src->nparallels); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target domain parallel port count %d does not match source %d"), + dst->nparallels, src->nparallels); goto cleanup; } @@ -10320,9 +10323,9 @@ bool virDomainDefCheckABIStability(virDomainDefPtr src, goto cleanup; if (src->nchannels != dst->nchannels) { - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Target domain channel count %d does not match source %d"), - dst->nchannels, src->nchannels); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target domain channel count %d does not match source %d"), + dst->nchannels, src->nchannels); goto cleanup; } @@ -10331,9 +10334,9 @@ bool virDomainDefCheckABIStability(virDomainDefPtr src, goto cleanup; if (src->nconsoles != dst->nconsoles) { - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Target domain console count %d does not match source %d"), - dst->nconsoles, src->nconsoles); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target domain console count %d does not match source %d"), + dst->nconsoles, src->nconsoles); goto cleanup; } @@ -10342,9 +10345,9 @@ bool virDomainDefCheckABIStability(virDomainDefPtr src, goto cleanup; if (src->nhubs != dst->nhubs) { - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Target domain hub device count %d does not match source %d"), - dst->nhubs, src->nhubs); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target domain hub device count %d does not match source %d"), + dst->nhubs, src->nhubs); goto cleanup; } @@ -10355,9 +10358,9 @@ bool virDomainDefCheckABIStability(virDomainDefPtr src, if ((!src->watchdog && dst->watchdog) || (src->watchdog && !dst->watchdog)) { - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Target domain watchdog count %d does not match source %d"), - dst->watchdog ? 1 : 0, src->watchdog ? 1 : 0); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target domain watchdog count %d does not match source %d"), + dst->watchdog ? 1 : 0, src->watchdog ? 1 : 0); goto cleanup; } @@ -10367,9 +10370,9 @@ bool virDomainDefCheckABIStability(virDomainDefPtr src, if ((!src->memballoon && dst->memballoon) || (src->memballoon && !dst->memballoon)) { - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Target domain memory balloon count %d does not match source %d"), - dst->memballoon ? 1 : 0, src->memballoon ? 1 : 0); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target domain memory balloon count %d does not match source %d"), + dst->memballoon ? 1 : 0, src->memballoon ? 1 : 0); goto cleanup; } @@ -10714,8 +10717,8 @@ virDomainCpuSetParse(const char *str, char sep, return ret; parse_error: - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("topology cpuset syntax error")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("topology cpuset syntax error")); return -1; } @@ -10887,8 +10890,8 @@ virDomainLifecycleDefFormat(virBufferPtr buf, { const char *typeStr = convFunc(type); if (!typeStr) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected lifecycle type %d"), type); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected lifecycle type %d"), type); return -1; } @@ -10993,28 +10996,28 @@ virDomainDiskDefFormat(virBufferPtr buf, char uuidstr[VIR_UUID_STRING_BUFLEN]; if (!type) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected disk type %d"), def->type); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected disk type %d"), def->type); return -1; } if (!device) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected disk device %d"), def->device); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected disk device %d"), def->device); return -1; } if (!bus) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected disk bus %d"), def->bus); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected disk bus %d"), def->bus); return -1; } if (!cachemode) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected disk cache mode %d"), def->cachemode); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected disk cache mode %d"), def->cachemode); return -1; } if (!iomode) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected disk io mode %d"), def->iomode); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected disk io mode %d"), def->iomode); return -1; } @@ -11134,9 +11137,9 @@ virDomainDiskDefFormat(virBufferPtr buf, } break; default: - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected disk type %s"), - virDomainDiskTypeToString(def->type)); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected disk type %s"), + virDomainDiskTypeToString(def->type)); return -1; } } @@ -11249,8 +11252,8 @@ virDomainControllerDefFormat(virBufferPtr buf, const char *model = NULL; if (!type) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected controller type %d"), def->type); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected controller type %d"), def->type); return -1; } @@ -11258,8 +11261,8 @@ virDomainControllerDefFormat(virBufferPtr buf, model = virDomainControllerModelTypeToString(def, def->model); if (!model) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected model type %d"), def->model); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected model type %d"), def->model); return -1; } } @@ -11327,14 +11330,14 @@ virDomainFSDefFormat(virBufferPtr buf, const char *wrpolicy = virDomainFSWrpolicyTypeToString(def->wrpolicy); if (!type) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected filesystem type %d"), def->type); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected filesystem type %d"), def->type); return -1; } if (!accessmode) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected accessmode %d"), def->accessmode); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected accessmode %d"), def->accessmode); return -1; } @@ -11452,9 +11455,9 @@ virDomainHostdevSourceFormat(virBufferPtr buf, } break; default: - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected hostdev type %d"), - def->source.subsys.type); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected hostdev type %d"), + def->source.subsys.type); return -1; } @@ -11476,8 +11479,8 @@ virDomainActualNetDefFormat(virBufferPtr buf, type = virDomainNetTypeToString(def->type); if (!type) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected net type %d"), def->type); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected net type %d"), def->type); return ret; } @@ -11508,9 +11511,9 @@ virDomainActualNetDefFormat(virBufferPtr buf, mode = virNetDevMacVLanModeTypeToString(def->data.direct.mode); if (!mode) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected source mode %d"), - def->data.direct.mode); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected source mode %d"), + def->data.direct.mode); return ret; } virBufferAsprintf(buf, " mode='%s'/>\n", mode); @@ -11536,8 +11539,8 @@ virDomainActualNetDefFormat(virBufferPtr buf, case VIR_DOMAIN_NET_TYPE_NETWORK: break; default: - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected net type %s"), type); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected net type %s"), type); goto error; } @@ -11561,8 +11564,8 @@ virDomainNetDefFormat(virBufferPtr buf, const char *type = virDomainNetTypeToString(def->type); if (!type) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected net type %d"), def->type); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected net type %d"), def->type); return -1; } @@ -11742,8 +11745,8 @@ virDomainChrSourceDefFormat(virBufferPtr buf, const char *type = virDomainChrTypeToString(def->type); if (!type) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected char type %d"), def->type); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected char type %d"), def->type); return -1; } @@ -11843,9 +11846,9 @@ virDomainChrDefFormat(virBufferPtr buf, int ret = 0; if (!elementName) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected char device type %d"), - def->deviceType); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected char device type %d"), + def->deviceType); return -1; } @@ -11862,8 +11865,8 @@ virDomainChrDefFormat(virBufferPtr buf, switch (def->deviceType) { case VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL: { if (!targetType) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Could not format channel target type")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Could not format channel target type")); return -1; } virBufferAsprintf(buf, " <target type='%s'", targetType); @@ -11872,8 +11875,8 @@ virDomainChrDefFormat(virBufferPtr buf, case VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_GUESTFWD: { int port = virSocketAddrGetPort(def->target.addr); if (port < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Unable to format guestfwd port")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Unable to format guestfwd port")); return -1; } @@ -11932,8 +11935,8 @@ virDomainSmartcardDefFormat(virBufferPtr buf, size_t i; if (!mode) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected smartcard type %d"), def->type); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected smartcard type %d"), def->type); return -1; } @@ -11963,8 +11966,8 @@ virDomainSmartcardDefFormat(virBufferPtr buf, break; default: - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected smartcard type %d"), def->type); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected smartcard type %d"), def->type); return -1; } if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0) @@ -11980,8 +11983,8 @@ virDomainSoundCodecDefFormat(virBufferPtr buf, const char *type = virDomainSoundCodecTypeToString(def->type); if (!type) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected codec type %d"), def->type); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected codec type %d"), def->type); return -1; } @@ -12000,8 +12003,8 @@ virDomainSoundDefFormat(virBufferPtr buf, int i; if (!model) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected sound model %d"), def->model); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected sound model %d"), def->model); return -1; } @@ -12042,8 +12045,8 @@ virDomainMemballoonDefFormat(virBufferPtr buf, const char *model = virDomainMemballoonModelTypeToString(def->model); if (!model) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected memballoon model %d"), def->model); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected memballoon model %d"), def->model); return -1; } @@ -12082,14 +12085,14 @@ virDomainWatchdogDefFormat(virBufferPtr buf, const char *action = virDomainWatchdogActionTypeToString (def->action); if (!model) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected watchdog model %d"), def->model); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected watchdog model %d"), def->model); return -1; } if (!action) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected watchdog action %d"), def->action); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected watchdog action %d"), def->action); return -1; } @@ -12129,8 +12132,8 @@ virDomainVideoDefFormat(virBufferPtr buf, const char *model = virDomainVideoTypeToString(def->type); if (!model) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected video model %d"), def->type); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected video model %d"), def->type); return -1; } @@ -12166,13 +12169,13 @@ virDomainInputDefFormat(virBufferPtr buf, const char *bus = virDomainInputBusTypeToString(def->bus); if (!type) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected input type %d"), def->type); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected input type %d"), def->type); return -1; } if (!bus) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected input bus type %d"), def->bus); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected input bus type %d"), def->bus); return -1; } @@ -12199,8 +12202,8 @@ virDomainTimerDefFormat(virBufferPtr buf, const char *name = virDomainTimerNameTypeToString(def->name); if (!name) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected timer name %d"), def->name); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected timer name %d"), def->name); return -1; } virBufferAsprintf(buf, " <timer name='%s'", name); @@ -12215,9 +12218,9 @@ virDomainTimerDefFormat(virBufferPtr buf, const char *tickpolicy = virDomainTimerTickpolicyTypeToString(def->tickpolicy); if (!tickpolicy) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected timer tickpolicy %d"), - def->tickpolicy); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected timer tickpolicy %d"), + def->tickpolicy); return -1; } virBufferAsprintf(buf, " tickpolicy='%s'", tickpolicy); @@ -12229,9 +12232,9 @@ virDomainTimerDefFormat(virBufferPtr buf, const char *track = virDomainTimerTrackTypeToString(def->track); if (!track) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected timer track %d"), - def->track); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected timer track %d"), + def->track); return -1; } virBufferAsprintf(buf, " track='%s'", track); @@ -12247,9 +12250,9 @@ virDomainTimerDefFormat(virBufferPtr buf, const char *mode = virDomainTimerModeTypeToString(def->mode); if (!mode) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected timer mode %d"), - def->mode); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected timer mode %d"), + def->mode); return -1; } virBufferAsprintf(buf, " mode='%s'", mode); @@ -12345,8 +12348,8 @@ virDomainGraphicsDefFormat(virBufferPtr buf, int i; if (!type) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected net type %d"), def->type); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected net type %d"), def->type); return -1; } @@ -12538,8 +12541,8 @@ virDomainHostdevDefFormat(virBufferPtr buf, const char *type; if (!mode || def->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected hostdev mode %d"), def->mode); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected hostdev mode %d"), def->mode); return -1; } @@ -12547,9 +12550,9 @@ virDomainHostdevDefFormat(virBufferPtr buf, if (!type || (def->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB && def->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI)) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected hostdev type %d"), - def->source.subsys.type); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected hostdev type %d"), + def->source.subsys.type); return -1; } @@ -12598,8 +12601,8 @@ virDomainHubDefFormat(virBufferPtr buf, const char *type = virDomainHubTypeToString(def->type); if (!type) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected hub type %d"), def->type); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected hub type %d"), def->type); return -1; } @@ -12651,8 +12654,8 @@ virDomainDefFormatInternal(virDomainDefPtr def, -1); if (!(type = virDomainVirtTypeToString(def->virtType))) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected domain type %d"), def->virtType); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected domain type %d"), def->virtType); goto cleanup; } @@ -12811,8 +12814,8 @@ virDomainDefFormatInternal(virDomainDefPtr def, VIR_DOMAIN_CPUMASK_LEN); if (cpumask == NULL) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("failed to format cpuset for vcpupin")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("failed to format cpuset for vcpupin")); goto cleanup; } @@ -12840,9 +12843,9 @@ virDomainDefFormatInternal(virDomainDefPtr def, nodemask = virDomainCpuSetFormat(def->numatune.memory.nodemask, VIR_DOMAIN_CPUMASK_LEN); if (nodemask == NULL) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("failed to format nodeset for " - "NUMA memory tuning")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("failed to format nodeset for " + "NUMA memory tuning")); goto cleanup; } virBufferAsprintf(buf, "nodeset='%s'/>\n", nodemask); @@ -12903,9 +12906,9 @@ virDomainDefFormatInternal(virDomainDefPtr def, const char *boottype = virDomainBootTypeToString(def->os.bootDevs[n]); if (!boottype) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected boot device type %d"), - def->os.bootDevs[n]); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected boot device type %d"), + def->os.bootDevs[n]); goto cleanup; } virBufferAsprintf(buf, " <boot dev='%s'/>\n", boottype); @@ -12931,8 +12934,8 @@ virDomainDefFormatInternal(virDomainDefPtr def, mode = virDomainSmbiosModeTypeToString(def->os.smbios_mode); if (mode == NULL) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected smbios mode %d"), def->os.smbios_mode); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected smbios mode %d"), def->os.smbios_mode); goto cleanup; } virBufferAsprintf(buf, " <smbios mode='%s'/>\n", mode); @@ -12946,8 +12949,8 @@ virDomainDefFormatInternal(virDomainDefPtr def, if (def->features & (1 << i)) { const char *name = virDomainFeatureTypeToString(i); if (!name) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected feature %d"), i); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected feature %d"), i); goto cleanup; } virBufferAsprintf(buf, " <%s/>\n", name); @@ -13363,9 +13366,9 @@ static virDomainObjPtr virDomainLoadStatus(virCapsPtr caps, virUUIDFormat(obj->def->uuid, uuidstr); if (virHashLookup(doms->objs, uuidstr) != NULL) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected domain %s already exists"), - obj->def->name); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected domain %s already exists"), + obj->def->name); goto error; } @@ -13573,18 +13576,18 @@ virDomainObjIsDuplicate(virDomainObjListPtr doms, if (STRNEQ(vm->def->name, def->name)) { char uuidstr[VIR_UUID_STRING_BUFLEN]; virUUIDFormat(vm->def->uuid, uuidstr); - virDomainReportError(VIR_ERR_OPERATION_FAILED, - _("domain '%s' is already defined with uuid %s"), - vm->def->name, uuidstr); + virReportError(VIR_ERR_OPERATION_FAILED, + _("domain '%s' is already defined with uuid %s"), + vm->def->name, uuidstr); goto cleanup; } if (check_active) { /* UUID & name match, but if VM is already active, refuse it */ if (virDomainObjIsActive(vm)) { - virDomainReportError(VIR_ERR_OPERATION_INVALID, - _("domain is already active as '%s'"), - vm->def->name); + virReportError(VIR_ERR_OPERATION_INVALID, + _("domain is already active as '%s'"), + vm->def->name); goto cleanup; } } @@ -13596,9 +13599,9 @@ virDomainObjIsDuplicate(virDomainObjListPtr doms, if (vm) { char uuidstr[VIR_UUID_STRING_BUFLEN]; virUUIDFormat(vm->def->uuid, uuidstr); - virDomainReportError(VIR_ERR_OPERATION_FAILED, - _("domain '%s' already exists with uuid %s"), - def->name, uuidstr); + virReportError(VIR_ERR_OPERATION_FAILED, + _("domain '%s' already exists with uuid %s"), + def->name, uuidstr); goto cleanup; } } @@ -13759,8 +13762,8 @@ virDomainSnapshotDiskDefParseXML(xmlNodePtr node, def->name = virXMLPropString(node, "name"); if (!def->name) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("missing name from disk snapshot element")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("missing name from disk snapshot element")); goto cleanup; } @@ -13768,9 +13771,9 @@ virDomainSnapshotDiskDefParseXML(xmlNodePtr node, if (snapshot) { def->snapshot = virDomainDiskSnapshotTypeFromString(snapshot); if (def->snapshot <= 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("unknown disk snapshot setting '%s'"), - snapshot); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unknown disk snapshot setting '%s'"), + snapshot); goto cleanup; } } @@ -13835,7 +13838,7 @@ virDomainSnapshotDefParseString(const char *xmlStr, } if (!xmlStrEqual(ctxt->node->name, BAD_CAST "domainsnapshot")) { - virDomainReportError(VIR_ERR_XML_ERROR, "%s", _("domainsnapshot")); + virReportError(VIR_ERR_XML_ERROR, "%s", _("domainsnapshot")); goto cleanup; } @@ -13844,8 +13847,8 @@ virDomainSnapshotDefParseString(const char *xmlStr, def->name = virXPathString("string(./name)", ctxt); if (def->name == NULL) { if (flags & VIR_DOMAIN_SNAPSHOT_PARSE_REDEFINE) { - virDomainReportError(VIR_ERR_XML_ERROR, "%s", - _("a redefined snapshot must have a name")); + virReportError(VIR_ERR_XML_ERROR, "%s", + _("a redefined snapshot must have a name")); goto cleanup; } else { ignore_value(virAsprintf(&def->name, "%lld", @@ -13863,8 +13866,8 @@ virDomainSnapshotDefParseString(const char *xmlStr, if (flags & VIR_DOMAIN_SNAPSHOT_PARSE_REDEFINE) { if (virXPathLongLong("string(./creationTime)", ctxt, &def->creationTime) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("missing creationTime from existing snapshot")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("missing creationTime from existing snapshot")); goto cleanup; } @@ -13875,15 +13878,15 @@ virDomainSnapshotDefParseString(const char *xmlStr, /* there was no state in an existing snapshot; this * should never happen */ - virDomainReportError(VIR_ERR_XML_ERROR, "%s", - _("missing state from existing snapshot")); + virReportError(VIR_ERR_XML_ERROR, "%s", + _("missing state from existing snapshot")); goto cleanup; } def->state = virDomainSnapshotStateTypeFromString(state); if (def->state < 0) { - virDomainReportError(VIR_ERR_XML_ERROR, - _("Invalid state '%s' in domain snapshot XML"), - state); + virReportError(VIR_ERR_XML_ERROR, + _("Invalid state '%s' in domain snapshot XML"), + state); goto cleanup; } @@ -13896,8 +13899,8 @@ virDomainSnapshotDefParseString(const char *xmlStr, VIR_FREE(tmp); if (!domainNode) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("missing domain in snapshot")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("missing domain in snapshot")); goto cleanup; } def->dom = virDomainDefParseNode(caps, xml, domainNode, @@ -13929,15 +13932,15 @@ virDomainSnapshotDefParseString(const char *xmlStr, } VIR_FREE(nodes); } else if (i) { - virDomainReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", - _("unable to handle disk requests in snapshot")); + virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", + _("unable to handle disk requests in snapshot")); goto cleanup; } if (flags & VIR_DOMAIN_SNAPSHOT_PARSE_INTERNAL) { if (virXPathInt("string(./active)", ctxt, &active) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Could not find 'active' element")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Could not find 'active' element")); goto cleanup; } def->current = active != 0; @@ -13987,14 +13990,14 @@ virDomainSnapshotAlignDisks(virDomainSnapshotDefPtr def, bool inuse; if (!def->dom) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("missing domain in snapshot")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("missing domain in snapshot")); goto cleanup; } if (def->ndisks > def->dom->ndisks) { - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("too many disk snapshot requests for domain")); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("too many disk snapshot requests for domain")); goto cleanup; } @@ -14016,16 +14019,16 @@ virDomainSnapshotAlignDisks(virDomainSnapshotDefPtr def, int disk_snapshot; if (idx < 0) { - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("no disk named '%s'"), disk->name); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("no disk named '%s'"), disk->name); goto cleanup; } disk_snapshot = def->dom->disks[idx]->snapshot; if (virBitmapGetBit(map, idx, &inuse) < 0 || inuse) { - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("disk '%s' specified twice"), - disk->name); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("disk '%s' specified twice"), + disk->name); goto cleanup; } ignore_value(virBitmapSetBit(map, idx)); @@ -14037,17 +14040,17 @@ virDomainSnapshotAlignDisks(virDomainSnapshotDefPtr def, } else if (disk_snapshot && require_match && disk->snapshot != disk_snapshot) { const char *tmp = virDomainDiskSnapshotTypeToString(disk_snapshot); - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("disk '%s' must use snapshot mode '%s'"), - disk->name, tmp); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("disk '%s' must use snapshot mode '%s'"), + disk->name, tmp); goto cleanup; } if (disk->file && disk->snapshot != VIR_DOMAIN_DISK_SNAPSHOT_EXTERNAL) { - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("file '%s' for disk '%s' requires " - "use of external snapshot mode"), - disk->file, disk->name); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("file '%s' for disk '%s' requires " + "use of external snapshot mode"), + disk->file, disk->name); goto cleanup; } if (STRNEQ(disk->name, def->dom->disks[idx]->dst)) { @@ -14098,18 +14101,18 @@ virDomainSnapshotAlignDisks(virDomainSnapshotDefPtr def, struct stat sb; if (!original) { - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("cannot generate external snapshot name " - "for disk '%s' without source"), - disk->name); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("cannot generate external snapshot name " + "for disk '%s' without source"), + disk->name); goto cleanup; } if (stat(original, &sb) < 0 || !S_ISREG(sb.st_mode)) { - virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("source for disk '%s' is not a regular " - "file; refusing to generate external " - "snapshot name"), - disk->name); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("source for disk '%s' is not a regular " + "file; refusing to generate external " + "snapshot name"), + disk->name); goto cleanup; } @@ -14119,8 +14122,8 @@ virDomainSnapshotAlignDisks(virDomainSnapshotDefPtr def, original, def->name)); } else { if ((tmp - original) > INT_MAX) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("integer overflow")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("integer overflow")); goto cleanup; } ignore_value(virAsprintf(&disk->file, "%.*s.%s", @@ -14253,9 +14256,9 @@ virDomainSnapshotObjPtr virDomainSnapshotAssignDef(virDomainSnapshotObjListPtr s virDomainSnapshotObjPtr snap; if (virHashLookup(snapshots->objs, def->name) != NULL) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected domain snapshot %s already exists"), - def->name); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected domain snapshot %s already exists"), + def->name); return NULL; } @@ -14657,18 +14660,18 @@ int virDomainDiskDefForeachPath(virDomainDiskDefPtr disk, formatStr = "raw"; /* Xen compat */ if ((format = virStorageFileFormatTypeFromString(formatStr)) < 0) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("unknown disk format '%s' for %s"), - disk->driverType, disk->src); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unknown disk format '%s' for %s"), + disk->driverType, disk->src); goto cleanup; } } else { if (allowProbing) { format = VIR_STORAGE_FILE_AUTO; } else { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("no disk format for %s and probing is disabled"), - disk->src); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("no disk format for %s and probing is disabled"), + disk->src); goto cleanup; } } @@ -14683,9 +14686,9 @@ int virDomainDiskDefForeachPath(virDomainDiskDefPtr disk, goto cleanup; if (virHashLookup(paths, path)) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("backing store for %s is self-referential"), - disk->src); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("backing store for %s is self-referential"), + disk->src); goto cleanup; } @@ -15237,10 +15240,10 @@ virDomainDeviceDefCopy(virCapsPtr caps, rc = virDomainRedirdevDefFormat(&buf, src->data.redirdev, flags); break; default: - virDomainReportError(VIR_ERR_INTERNAL_ERROR, - _("Copying definition of '%d' type " - "is not implemented yet."), - src->type); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Copying definition of '%d' type " + "is not implemented yet."), + src->type); goto cleanup; } diff --git a/src/conf/domain_event.c b/src/conf/domain_event.c index 8517fb4..c2a3127 100644 --- a/src/conf/domain_event.c +++ b/src/conf/domain_event.c @@ -31,10 +31,6 @@ #define VIR_FROM_THIS VIR_FROM_NONE -#define eventReportError(code, ...) \ - virReportErrorHelper(VIR_FROM_THIS, code, __FILE__, \ - __FUNCTION__, __LINE__, __VA_ARGS__) - struct _virDomainMeta { int id; char *name; @@ -196,8 +192,8 @@ virDomainEventCallbackListRemove(virConnectPtr conn, } } - eventReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("could not find event callback for removal")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("could not find event callback for removal")); return -1; } @@ -246,8 +242,8 @@ virDomainEventCallbackListRemoveID(virConnectPtr conn, } } - eventReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("could not find event callback for removal")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("could not find event callback for removal")); return -1; } @@ -272,8 +268,8 @@ virDomainEventCallbackListMarkDelete(virConnectPtr conn, } } - eventReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("could not find event callback for deletion")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("could not find event callback for deletion")); return -1; } @@ -297,8 +293,8 @@ virDomainEventCallbackListMarkDeleteID(virConnectPtr conn, } } - eventReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("could not find event callback for deletion")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("could not find event callback for deletion")); return -1; } @@ -372,8 +368,8 @@ virDomainEventCallbackListAddID(virConnectPtr conn, memcmp(cbList->callbacks[i]->dom->uuid, dom->uuid, VIR_UUID_BUFLEN) == 0) || (!dom && !cbList->callbacks[i]->dom))) { - eventReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("event callback already tracked")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("event callback already tracked")); return -1; } } @@ -1456,8 +1452,8 @@ virDomainEventStateRegister(virConnectPtr conn, virDomainEventTimer, state, NULL)) < 0) { - eventReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("could not initialize domain event timer")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("could not initialize domain event timer")); goto cleanup; } @@ -1512,8 +1508,8 @@ virDomainEventStateRegisterID(virConnectPtr conn, virDomainEventTimer, state, NULL)) < 0) { - eventReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("could not initialize domain event timer")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("could not initialize domain event timer")); goto cleanup; } diff --git a/src/conf/interface_conf.c b/src/conf/interface_conf.c index 0aeb1e2..e054210 100644 --- a/src/conf/interface_conf.c +++ b/src/conf/interface_conf.c @@ -45,10 +45,6 @@ static int virInterfaceDefDevFormat(virBufferPtr buf, const virInterfaceDefPtr def, int level); -#define virInterfaceReportError(code, ...) \ - virReportErrorHelper(VIR_FROM_INTERFACE, code, __FILE__, \ - __FUNCTION__, __LINE__, __VA_ARGS__) - static void virInterfaceIpDefFree(virInterfaceIpDefPtr def) { if (def == NULL) @@ -122,8 +118,8 @@ virInterfaceDefParseName(virInterfaceDefPtr def, tmp = virXPathString("string(./@name)", ctxt); if (tmp == NULL) { - virInterfaceReportError(VIR_ERR_XML_ERROR, - "%s", _("interface has no name")); + virReportError(VIR_ERR_XML_ERROR, + "%s", _("interface has no name")); return -1; } def->name = tmp; @@ -138,8 +134,8 @@ virInterfaceDefParseMtu(virInterfaceDefPtr def, ret = virXPathULong("string(./mtu/@size)", ctxt, &mtu); if ((ret == -2) || ((ret == 0) && (mtu > 100000))) { - virInterfaceReportError(VIR_ERR_XML_ERROR, - "%s", _("interface mtu value is improper")); + virReportError(VIR_ERR_XML_ERROR, + "%s", _("interface mtu value is improper")); return -1; } else if (ret == 0) { def->mtu = (unsigned int) mtu; @@ -162,8 +158,8 @@ virInterfaceDefParseStartMode(virInterfaceDefPtr def, else if (STREQ(tmp, "none")) def->startmode = VIR_INTERFACE_START_NONE; else { - virInterfaceReportError(VIR_ERR_XML_ERROR, - _("unknown interface startmode %s"), tmp); + virReportError(VIR_ERR_XML_ERROR, + _("unknown interface startmode %s"), tmp); VIR_FREE(tmp); return -1; } @@ -194,8 +190,8 @@ virInterfaceDefParseBondMode(xmlXPathContextPtr ctxt) { else if (STREQ(tmp, "balance-alb")) ret = VIR_INTERFACE_BOND_BALALB; else { - virInterfaceReportError(VIR_ERR_XML_ERROR, - _("unknown bonding mode %s"), tmp); + virReportError(VIR_ERR_XML_ERROR, + _("unknown bonding mode %s"), tmp); ret = -1; } VIR_FREE(tmp); @@ -215,8 +211,8 @@ virInterfaceDefParseBondMiiCarrier(xmlXPathContextPtr ctxt) { else if (STREQ(tmp, "netif")) ret = VIR_INTERFACE_BOND_MII_NETIF; else { - virInterfaceReportError(VIR_ERR_XML_ERROR, - _("unknown mii bonding carrier %s"), tmp); + virReportError(VIR_ERR_XML_ERROR, + _("unknown mii bonding carrier %s"), tmp); ret = -1; } VIR_FREE(tmp); @@ -238,8 +234,8 @@ virInterfaceDefParseBondArpValid(xmlXPathContextPtr ctxt) { else if (STREQ(tmp, "all")) ret = VIR_INTERFACE_BOND_ARP_ALL; else { - virInterfaceReportError(VIR_ERR_XML_ERROR, - _("unknown arp bonding validate %s"), tmp); + virReportError(VIR_ERR_XML_ERROR, + _("unknown arp bonding validate %s"), tmp); ret = -1; } VIR_FREE(tmp); @@ -264,8 +260,8 @@ virInterfaceDefParseDhcp(virInterfaceProtocolDefPtr def, else if (STREQ(tmp, "no")) def->peerdns = 0; else { - virInterfaceReportError(VIR_ERR_XML_ERROR, - _("unknown dhcp peerdns value %s"), tmp); + virReportError(VIR_ERR_XML_ERROR, + _("unknown dhcp peerdns value %s"), tmp); ret = -1; } VIR_FREE(tmp); @@ -290,8 +286,8 @@ virInterfaceDefParseIp(virInterfaceIpDefPtr def, if (ret == 0) def->prefix = (int) l; else if (ret == -2) { - virInterfaceReportError(VIR_ERR_XML_ERROR, - "%s", _("Invalid ip address prefix value")); + virReportError(VIR_ERR_XML_ERROR, + "%s", _("Invalid ip address prefix value")); return -1; } } @@ -450,8 +446,8 @@ virInterfaceDefParseIfAdressing(virInterfaceDefPtr def, ctxt->node = protoNodes[pp]; tmp = virXPathString("string(./@family)", ctxt); if (tmp == NULL) { - virInterfaceReportError(VIR_ERR_XML_ERROR, - "%s", _("protocol misses the family attribute")); + virReportError(VIR_ERR_XML_ERROR, + "%s", _("protocol misses the family attribute")); virInterfaceProtocolDefFree(proto); goto error; } @@ -469,8 +465,8 @@ virInterfaceDefParseIfAdressing(virInterfaceDefPtr def, goto error; } } else { - virInterfaceReportError(VIR_ERR_XML_ERROR, - _("unsupported protocol family '%s'"), tmp); + virReportError(VIR_ERR_XML_ERROR, + _("unsupported protocol family '%s'"), tmp); virInterfaceProtocolDefFree(proto); goto error; } @@ -543,8 +539,8 @@ virInterfaceDefParseBondItfs(virInterfaceDefPtr def, } if (nbItf == 0) { - virInterfaceReportError(VIR_ERR_XML_ERROR, - "%s", _("bond has no interfaces")); + virReportError(VIR_ERR_XML_ERROR, + "%s", _("bond has no interfaces")); ret = -1; goto error; } @@ -592,16 +588,16 @@ virInterfaceDefParseBond(virInterfaceDefPtr def, ret = virXPathULong("string(./miimon/@freq)", ctxt, &tmp); if ((ret == -2) || (ret == -1)) { - virInterfaceReportError(VIR_ERR_XML_ERROR, - "%s", _("bond interface miimon freq missing or invalid")); + virReportError(VIR_ERR_XML_ERROR, + "%s", _("bond interface miimon freq missing or invalid")); goto error; } def->data.bond.frequency = (int) tmp; ret = virXPathULong("string(./miimon/@downdelay)", ctxt, &tmp); if (ret == -2) { - virInterfaceReportError(VIR_ERR_XML_ERROR, - "%s", _("bond interface miimon downdelay invalid")); + virReportError(VIR_ERR_XML_ERROR, + "%s", _("bond interface miimon downdelay invalid")); goto error; } else if (ret == 0) { def->data.bond.downdelay = (int) tmp; @@ -609,8 +605,8 @@ virInterfaceDefParseBond(virInterfaceDefPtr def, ret = virXPathULong("string(./miimon/@updelay)", ctxt, &tmp); if (ret == -2) { - virInterfaceReportError(VIR_ERR_XML_ERROR, - "%s", _("bond interface miimon updelay invalid")); + virReportError(VIR_ERR_XML_ERROR, + "%s", _("bond interface miimon updelay invalid")); goto error; } else if (ret == 0) { def->data.bond.updelay = (int) tmp; @@ -628,8 +624,8 @@ virInterfaceDefParseBond(virInterfaceDefPtr def, ret = virXPathULong("string(./arpmon/@interval)", ctxt, &tmp); if ((ret == -2) || (ret == -1)) { - virInterfaceReportError(VIR_ERR_XML_ERROR, - "%s", _("bond interface arpmon interval missing or invalid")); + virReportError(VIR_ERR_XML_ERROR, + "%s", _("bond interface arpmon interval missing or invalid")); goto error; } def->data.bond.interval = (int) tmp; @@ -637,8 +633,8 @@ virInterfaceDefParseBond(virInterfaceDefPtr def, def->data.bond.target = virXPathString("string(./arpmon/@target)", ctxt); if (def->data.bond.target == NULL) { - virInterfaceReportError(VIR_ERR_XML_ERROR, - "%s", _("bond interface arpmon target missing")); + virReportError(VIR_ERR_XML_ERROR, + "%s", _("bond interface arpmon target missing")); ret = -1; goto error; } @@ -658,16 +654,16 @@ virInterfaceDefParseVlan(virInterfaceDefPtr def, xmlXPathContextPtr ctxt) { def->data.vlan.tag = virXPathString("string(./@tag)", ctxt); if (def->data.vlan.tag == NULL) { - virInterfaceReportError(VIR_ERR_XML_ERROR, - "%s", _("vlan interface misses the tag attribute")); + virReportError(VIR_ERR_XML_ERROR, + "%s", _("vlan interface misses the tag attribute")); return -1; } def->data.vlan.devname = virXPathString("string(./interface/@name)", ctxt); if (def->data.vlan.devname == NULL) { - virInterfaceReportError(VIR_ERR_XML_ERROR, - "%s", _("vlan interface misses name attribute")); + virReportError(VIR_ERR_XML_ERROR, + "%s", _("vlan interface misses name attribute")); return -1; } return 0; @@ -683,14 +679,14 @@ virInterfaceDefParseXML(xmlXPathContextPtr ctxt, int parentIfType) { /* check @type */ tmp = virXPathString("string(./@type)", ctxt); if (tmp == NULL) { - virInterfaceReportError(VIR_ERR_XML_ERROR, - "%s", _("interface misses the type attribute")); + virReportError(VIR_ERR_XML_ERROR, + "%s", _("interface misses the type attribute")); return NULL; } type = virInterfaceTypeFromString(tmp); if (type == -1) { - virInterfaceReportError(VIR_ERR_XML_ERROR, - _("unknown interface type %s"), tmp); + virReportError(VIR_ERR_XML_ERROR, + _("unknown interface type %s"), tmp); VIR_FREE(tmp); return NULL; } @@ -710,9 +706,9 @@ virInterfaceDefParseXML(xmlXPathContextPtr ctxt, int parentIfType) { || (parentIfType == VIR_INTERFACE_TYPE_ETHERNET) || (parentIfType == VIR_INTERFACE_TYPE_VLAN)) { - virInterfaceReportError(VIR_ERR_XML_ERROR, - _("interface has unsupported type '%s'"), - virInterfaceTypeToString(type)); + virReportError(VIR_ERR_XML_ERROR, + _("interface has unsupported type '%s'"), + virInterfaceTypeToString(type)); goto error; } def->type = type; @@ -747,8 +743,8 @@ virInterfaceDefParseXML(xmlXPathContextPtr ctxt, int parentIfType) { bridge = virXPathNode("./bridge[1]", ctxt); if (bridge == NULL) { - virInterfaceReportError(VIR_ERR_XML_ERROR, - "%s", _("bridge interface misses the bridge element")); + virReportError(VIR_ERR_XML_ERROR, + "%s", _("bridge interface misses the bridge element")); goto error; } tmp = virXMLPropString(bridge, "stp"); @@ -759,9 +755,9 @@ virInterfaceDefParseXML(xmlXPathContextPtr ctxt, int parentIfType) { } else if (STREQ(tmp, "off")) { def->data.bridge.stp = 0; } else { - virInterfaceReportError(VIR_ERR_XML_ERROR, - _("bridge interface stp should be on or off got %s"), - tmp); + virReportError(VIR_ERR_XML_ERROR, + _("bridge interface stp should be on or off got %s"), + tmp); VIR_FREE(tmp); goto error; } @@ -790,8 +786,8 @@ virInterfaceDefParseXML(xmlXPathContextPtr ctxt, int parentIfType) { bond = virXPathNode("./bond[1]", ctxt); if (bond == NULL) { - virInterfaceReportError(VIR_ERR_XML_ERROR, - "%s", _("bond interface misses the bond element")); + virReportError(VIR_ERR_XML_ERROR, + "%s", _("bond interface misses the bond element")); goto error; } ctxt->node = bond; @@ -811,8 +807,8 @@ virInterfaceDefParseXML(xmlXPathContextPtr ctxt, int parentIfType) { goto error; vlan = virXPathNode("./vlan[1]", ctxt); if (vlan == NULL) { - virInterfaceReportError(VIR_ERR_XML_ERROR, - "%s", _("vlan interface misses the vlan element")); + virReportError(VIR_ERR_XML_ERROR, + "%s", _("vlan interface misses the vlan element")); goto error; } ctxt->node = vlan; @@ -839,10 +835,10 @@ virInterfaceDefPtr virInterfaceDefParseNode(xmlDocPtr xml, virInterfaceDefPtr def = NULL; if (!xmlStrEqual(root->name, BAD_CAST "interface")) { - virInterfaceReportError(VIR_ERR_XML_ERROR, - _("unexpected root element <%s>, " - "expecting <interface>"), - root->name); + virReportError(VIR_ERR_XML_ERROR, + _("unexpected root element <%s>, " + "expecting <interface>"), + root->name); return NULL; } @@ -947,8 +943,8 @@ virInterfaceBondDefFormat(virBufferPtr buf, virBufferAddLit(buf, "/>\n"); } else if (def->data.bond.monit == VIR_INTERFACE_BOND_MONIT_ARP) { if (def->data.bond.target == NULL) { - virInterfaceReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("bond arp monitoring has no target")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("bond arp monitoring has no target")); return -1; } virBufferAsprintf(buf, "%*s <arpmon interval='%d' target='%s'", @@ -975,8 +971,8 @@ static int virInterfaceVlanDefFormat(virBufferPtr buf, const virInterfaceDefPtr def, int level) { if (def->data.vlan.tag == NULL) { - virInterfaceReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("vlan misses the tag name")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("vlan misses the tag name")); return -1; } @@ -1057,8 +1053,8 @@ virInterfaceStartmodeDefFormat(virBufferPtr buf, mode = "hotplug"; break; default: - virInterfaceReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("virInterfaceDefFormat unknown startmode")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("virInterfaceDefFormat unknown startmode")); return -1; } virBufferAsprintf(buf, "%*s <start mode='%s'/>\n", level*2, "", mode); @@ -1071,20 +1067,20 @@ virInterfaceDefDevFormat(virBufferPtr buf, const char *type = NULL; if (def == NULL) { - virInterfaceReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("virInterfaceDefFormat NULL def")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("virInterfaceDefFormat NULL def")); goto cleanup; } if ((def->name == NULL) && (def->type != VIR_INTERFACE_TYPE_VLAN)) { - virInterfaceReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("virInterfaceDefFormat missing interface name")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("virInterfaceDefFormat missing interface name")); goto cleanup; } if (!(type = virInterfaceTypeToString(def->type))) { - virInterfaceReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected interface type %d"), def->type); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected interface type %d"), def->type); goto cleanup; } @@ -1285,8 +1281,8 @@ virInterfaceObjPtr virInterfaceAssignDef(virInterfaceObjListPtr interfaces, return NULL; } if (virMutexInit(&iface->lock) < 0) { - virInterfaceReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("cannot initialize mutex")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("cannot initialize mutex")); VIR_FREE(iface); return NULL; } diff --git a/src/conf/netdev_bandwidth_conf.c b/src/conf/netdev_bandwidth_conf.c index 24cd13d..4dbf18d 100644 --- a/src/conf/netdev_bandwidth_conf.c +++ b/src/conf/netdev_bandwidth_conf.c @@ -28,10 +28,6 @@ #include "memory.h" #define VIR_FROM_THIS VIR_FROM_NONE -#define virNetDevError(code, ...) \ - virReportErrorHelper(VIR_FROM_THIS, code, __FILE__, \ - __FUNCTION__, __LINE__, __VA_ARGS__) - static int virNetDevBandwidthParseRate(xmlNodePtr node, virNetDevBandwidthRatePtr rate) @@ -42,7 +38,7 @@ virNetDevBandwidthParseRate(xmlNodePtr node, virNetDevBandwidthRatePtr rate) char *burst = NULL; if (!node || !rate) { - virNetDevError(VIR_ERR_INVALID_ARG, "%s", + virReportError(VIR_ERR_INVALID_ARG, "%s", _("invalid argument supplied")); return -1; } @@ -53,26 +49,26 @@ virNetDevBandwidthParseRate(xmlNodePtr node, virNetDevBandwidthRatePtr rate) if (average) { if (virStrToLong_ull(average, NULL, 10, &rate->average) < 0) { - virNetDevError(VIR_ERR_CONFIG_UNSUPPORTED, + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("could not convert %s"), average); goto cleanup; } } else { - virNetDevError(VIR_ERR_XML_DETAIL, "%s", + virReportError(VIR_ERR_XML_DETAIL, "%s", _("Missing mandatory average attribute")); goto cleanup; } if (peak && virStrToLong_ull(peak, NULL, 10, &rate->peak) < 0) { - virNetDevError(VIR_ERR_CONFIG_UNSUPPORTED, + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("could not convert %s"), peak); goto cleanup; } if (burst && virStrToLong_ull(burst, NULL, 10, &rate->burst) < 0) { - virNetDevError(VIR_ERR_CONFIG_UNSUPPORTED, + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("could not convert %s"), burst); goto cleanup; @@ -109,7 +105,7 @@ virNetDevBandwidthParse(xmlNodePtr node) } if (!node || !xmlStrEqual(node->name, BAD_CAST "bandwidth")) { - virNetDevError(VIR_ERR_INVALID_ARG, "%s", + virReportError(VIR_ERR_INVALID_ARG, "%s", _("invalid argument supplied")); goto error; } @@ -118,7 +114,7 @@ virNetDevBandwidthParse(xmlNodePtr node) if (cur->type == XML_ELEMENT_NODE) { if (xmlStrEqual(cur->name, BAD_CAST "inbound")) { if (in) { - virNetDevError(VIR_ERR_XML_DETAIL, "%s", + virReportError(VIR_ERR_XML_DETAIL, "%s", _("Only one child <inbound> " "element allowed")); goto error; @@ -126,7 +122,7 @@ virNetDevBandwidthParse(xmlNodePtr node) in = cur; } else if (xmlStrEqual(cur->name, BAD_CAST "outbound")) { if (out) { - virNetDevError(VIR_ERR_XML_DETAIL, "%s", + virReportError(VIR_ERR_XML_DETAIL, "%s", _("Only one child <outbound> " "element allowed")); goto error; diff --git a/src/conf/netdev_vport_profile_conf.c b/src/conf/netdev_vport_profile_conf.c index 6bc29ba..2699310 100644 --- a/src/conf/netdev_vport_profile_conf.c +++ b/src/conf/netdev_vport_profile_conf.c @@ -27,9 +27,6 @@ #include "memory.h" #define VIR_FROM_THIS VIR_FROM_NONE -#define virNetDevError(code, ...) \ - virReportErrorHelper(VIR_FROM_THIS, code, __FILE__, \ - __FUNCTION__, __LINE__, __VA_ARGS__) VIR_ENUM_IMPL(virNetDevVPort, VIR_NETDEV_VPORT_PROFILE_LAST, @@ -59,13 +56,13 @@ virNetDevVPortProfileParse(xmlNodePtr node) virtPortType = virXMLPropString(node, "type"); if (!virtPortType) { - virNetDevError(VIR_ERR_XML_ERROR, "%s", + virReportError(VIR_ERR_XML_ERROR, "%s", _("missing virtualportprofile type")); goto error; } if ((virtPort->virtPortType = virNetDevVPortTypeFromString(virtPortType)) <= 0) { - virNetDevError(VIR_ERR_XML_ERROR, + virReportError(VIR_ERR_XML_ERROR, _("unknown virtualportprofile type %s"), virtPortType); goto error; } @@ -92,13 +89,13 @@ virNetDevVPortProfileParse(xmlNodePtr node) unsigned int val; if (virStrToLong_ui(virtPortManagerID, NULL, 0, &val)) { - virNetDevError(VIR_ERR_XML_ERROR, "%s", + virReportError(VIR_ERR_XML_ERROR, "%s", _("cannot parse value of managerid parameter")); goto error; } if (val > 0xff) { - virNetDevError(VIR_ERR_XML_ERROR, "%s", + virReportError(VIR_ERR_XML_ERROR, "%s", _("value of managerid out of range")); goto error; } @@ -106,13 +103,13 @@ virNetDevVPortProfileParse(xmlNodePtr node) virtPort->u.virtPort8021Qbg.managerID = (uint8_t)val; if (virStrToLong_ui(virtPortTypeID, NULL, 0, &val)) { - virNetDevError(VIR_ERR_XML_ERROR, "%s", + virReportError(VIR_ERR_XML_ERROR, "%s", _("cannot parse value of typeid parameter")); goto error; } if (val > 0xffffff) { - virNetDevError(VIR_ERR_XML_ERROR, "%s", + virReportError(VIR_ERR_XML_ERROR, "%s", _("value for typeid out of range")); goto error; } @@ -120,13 +117,13 @@ virNetDevVPortProfileParse(xmlNodePtr node) virtPort->u.virtPort8021Qbg.typeID = (uint32_t)val; if (virStrToLong_ui(virtPortTypeIDVersion, NULL, 0, &val)) { - virNetDevError(VIR_ERR_XML_ERROR, "%s", + virReportError(VIR_ERR_XML_ERROR, "%s", _("cannot parse value of typeidversion parameter")); goto error; } if (val > 0xff) { - virNetDevError(VIR_ERR_XML_ERROR, "%s", + virReportError(VIR_ERR_XML_ERROR, "%s", _("value of typeidversion out of range")); goto error; } @@ -136,13 +133,13 @@ virNetDevVPortProfileParse(xmlNodePtr node) if (virtPortInstanceID != NULL) { if (virUUIDParse(virtPortInstanceID, virtPort->u.virtPort8021Qbg.instanceID)) { - virNetDevError(VIR_ERR_XML_ERROR, "%s", + virReportError(VIR_ERR_XML_ERROR, "%s", _("cannot parse instanceid parameter as a uuid")); goto error; } } else { if (virUUIDGenerate(virtPort->u.virtPort8021Qbg.instanceID)) { - virNetDevError(VIR_ERR_XML_ERROR, "%s", + virReportError(VIR_ERR_XML_ERROR, "%s", _("cannot generate a random uuid for instanceid")); goto error; } @@ -151,7 +148,7 @@ virNetDevVPortProfileParse(xmlNodePtr node) virtPort->virtPortType = VIR_NETDEV_VPORT_PROFILE_8021QBG; } else { - virNetDevError(VIR_ERR_XML_ERROR, "%s", + virReportError(VIR_ERR_XML_ERROR, "%s", _("a parameter is missing for 802.1Qbg description")); goto error; } @@ -163,12 +160,12 @@ virNetDevVPortProfileParse(xmlNodePtr node) virtPortProfileID) != NULL) { virtPort->virtPortType = VIR_NETDEV_VPORT_PROFILE_8021QBH; } else { - virNetDevError(VIR_ERR_XML_ERROR, "%s", + virReportError(VIR_ERR_XML_ERROR, "%s", _("profileid parameter too long")); goto error; } } else { - virNetDevError(VIR_ERR_XML_ERROR, "%s", + virReportError(VIR_ERR_XML_ERROR, "%s", _("profileid parameter is missing for 802.1Qbh description")); goto error; } @@ -177,13 +174,13 @@ virNetDevVPortProfileParse(xmlNodePtr node) if (virtPortInterfaceID != NULL) { if (virUUIDParse(virtPortInterfaceID, virtPort->u.openvswitch.interfaceID)) { - virNetDevError(VIR_ERR_XML_ERROR, "%s", + virReportError(VIR_ERR_XML_ERROR, "%s", _("cannot parse interfaceid parameter as a uuid")); goto error; } } else { if (virUUIDGenerate(virtPort->u.openvswitch.interfaceID)) { - virNetDevError(VIR_ERR_XML_ERROR, "%s", + virReportError(VIR_ERR_XML_ERROR, "%s", _("cannot generate a random uuid for interfaceid")); goto error; } @@ -192,7 +189,7 @@ virNetDevVPortProfileParse(xmlNodePtr node) if (virtPortProfileID != NULL) { if (virStrcpyStatic(virtPort->u.openvswitch.profileID, virtPortProfileID) == NULL) { - virNetDevError(VIR_ERR_XML_ERROR, "%s", + virReportError(VIR_ERR_XML_ERROR, "%s", _("profileid parameter too long")); goto error; } @@ -202,7 +199,7 @@ virNetDevVPortProfileParse(xmlNodePtr node) break; default: - virNetDevError(VIR_ERR_XML_ERROR, + virReportError(VIR_ERR_XML_ERROR, _("unexpected virtualport type %d"), virtPort->virtPortType); goto error; } @@ -269,7 +266,7 @@ virNetDevVPortProfileFormat(virNetDevVPortProfilePtr virtPort, break; default: - virNetDevError(VIR_ERR_XML_ERROR, + virReportError(VIR_ERR_XML_ERROR, _("unexpected virtualport type %d"), virtPort->virtPortType); return -1; } diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c index 8fe1f70..41864be 100644 --- a/src/conf/network_conf.c +++ b/src/conf/network_conf.c @@ -53,10 +53,6 @@ VIR_ENUM_IMPL(virNetworkForward, VIR_NETWORK_FORWARD_LAST, "none", "nat", "route", "bridge", "private", "vepa", "passthrough" ) -#define virNetworkReportError(code, ...) \ - virReportErrorHelper(VIR_FROM_NETWORK, code, __FILE__, \ - __FUNCTION__, __LINE__, __VA_ARGS__) - virNetworkObjPtr virNetworkFindByUUID(const virNetworkObjListPtr nets, const unsigned char *uuid) { @@ -237,8 +233,8 @@ virNetworkObjPtr virNetworkAssignDef(virNetworkObjListPtr nets, return NULL; } if (virMutexInit(&network->lock) < 0) { - virNetworkReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("cannot initialize mutex")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("cannot initialize mutex")); VIR_FREE(network); return NULL; } @@ -400,9 +396,9 @@ virNetworkDHCPRangeDefParseXML(const char *networkName, range = virSocketAddrGetRange(&saddr, &eaddr); if (range < 0) { - virNetworkReportError(VIR_ERR_XML_ERROR, - _("Invalid dhcp range '%s' to '%s' in network '%s'"), - start, end, networkName); + virReportError(VIR_ERR_XML_ERROR, + _("Invalid dhcp range '%s' to '%s' in network '%s'"), + start, end, networkName); VIR_FREE(start); VIR_FREE(end); return -1; @@ -426,25 +422,25 @@ virNetworkDHCPRangeDefParseXML(const char *networkName, mac = virXMLPropString(cur, "mac"); if (mac != NULL) { if (virMacAddrParse(mac, &addr) < 0) { - virNetworkReportError(VIR_ERR_XML_ERROR, - _("Cannot parse MAC address '%s' in network '%s'"), - mac, networkName); + virReportError(VIR_ERR_XML_ERROR, + _("Cannot parse MAC address '%s' in network '%s'"), + mac, networkName); VIR_FREE(mac); return -1; } if (virMacAddrIsMulticast(&addr)) { - virNetworkReportError(VIR_ERR_XML_ERROR, - _("expected unicast mac address, found multicast '%s' in network '%s'"), - (const char *)mac, networkName); + virReportError(VIR_ERR_XML_ERROR, + _("expected unicast mac address, found multicast '%s' in network '%s'"), + (const char *)mac, networkName); VIR_FREE(mac); return -1; } } name = virXMLPropString(cur, "name"); if ((name != NULL) && (!c_isalpha(name[0]))) { - virNetworkReportError(VIR_ERR_XML_ERROR, - _("Cannot use name address '%s' in network '%s'"), - name, networkName); + virReportError(VIR_ERR_XML_ERROR, + _("Cannot use name address '%s' in network '%s'"), + name, networkName); VIR_FREE(mac); VIR_FREE(name); return -1; @@ -453,17 +449,17 @@ virNetworkDHCPRangeDefParseXML(const char *networkName, * You need at least one MAC address or one host name */ if ((mac == NULL) && (name == NULL)) { - virNetworkReportError(VIR_ERR_XML_ERROR, - _("Static host definition in network '%s' must have mac or name attribute"), - networkName); + virReportError(VIR_ERR_XML_ERROR, + _("Static host definition in network '%s' must have mac or name attribute"), + networkName); return -1; } ip = virXMLPropString(cur, "ip"); if ((ip == NULL) || (virSocketAddrParse(&inaddr, ip, AF_UNSPEC) < 0)) { - virNetworkReportError(VIR_ERR_XML_ERROR, - _("Missing IP address in static host definition for network '%s'"), - networkName); + virReportError(VIR_ERR_XML_ERROR, + _("Missing IP address in static host definition for network '%s'"), + networkName); VIR_FREE(ip); VIR_FREE(mac); VIR_FREE(name); @@ -523,8 +519,8 @@ virNetworkDNSHostsDefParseXML(virNetworkDNSDefPtr def, if (!(ip = virXMLPropString(node, "ip")) || (virSocketAddrParse(&inaddr, ip, AF_UNSPEC) < 0)) { - virNetworkReportError(VIR_ERR_XML_DETAIL, - _("Missing IP address in DNS host definition")); + virReportError(VIR_ERR_XML_DETAIL, + _("Missing IP address in DNS host definition")); VIR_FREE(ip); goto error; } @@ -584,28 +580,28 @@ virNetworkDNSSrvDefParseXML(virNetworkDNSDefPtr def, int ret = 0; if (!(service = virXMLPropString(cur, "service"))) { - virNetworkReportError(VIR_ERR_XML_DETAIL, - "%s", _("Missing required service attribute in dns srv record")); + virReportError(VIR_ERR_XML_DETAIL, + "%s", _("Missing required service attribute in dns srv record")); goto error; } if (strlen(service) > DNS_RECORD_LENGTH_SRV) { - virNetworkReportError(VIR_ERR_XML_DETAIL, - _("Service name is too long, limit is %d bytes"), - DNS_RECORD_LENGTH_SRV); + virReportError(VIR_ERR_XML_DETAIL, + _("Service name is too long, limit is %d bytes"), + DNS_RECORD_LENGTH_SRV); goto error; } if (!(protocol = virXMLPropString(cur, "protocol"))) { - virNetworkReportError(VIR_ERR_XML_DETAIL, - _("Missing required protocol attribute in dns srv record '%s'"), service); + virReportError(VIR_ERR_XML_DETAIL, + _("Missing required protocol attribute in dns srv record '%s'"), service); goto error; } /* Check whether protocol value is the supported one */ if (STRNEQ(protocol, "tcp") && (STRNEQ(protocol, "udp"))) { - virNetworkReportError(VIR_ERR_XML_DETAIL, - _("Invalid protocol attribute value '%s'"), protocol); + virReportError(VIR_ERR_XML_DETAIL, + _("Invalid protocol attribute value '%s'"), protocol); goto error; } @@ -681,19 +677,19 @@ virNetworkDNSDefParseXML(virNetworkDNSDefPtr *dnsdef, if (cur->type == XML_ELEMENT_NODE && xmlStrEqual(cur->name, BAD_CAST "txt")) { if (!(name = virXMLPropString(cur, "name"))) { - virNetworkReportError(VIR_ERR_XML_DETAIL, - "%s", _("Missing required name attribute in dns txt record")); + virReportError(VIR_ERR_XML_DETAIL, + "%s", _("Missing required name attribute in dns txt record")); goto error; } if (!(value = virXMLPropString(cur, "value"))) { - virNetworkReportError(VIR_ERR_XML_DETAIL, - _("Missing required value attribute in dns txt record '%s'"), name); + virReportError(VIR_ERR_XML_DETAIL, + _("Missing required value attribute in dns txt record '%s'"), name); goto error; } if (strchr(name, ' ') != NULL) { - virNetworkReportError(VIR_ERR_XML_DETAIL, - _("spaces are not allowed in DNS TXT record names (name is '%s')"), name); + virReportError(VIR_ERR_XML_DETAIL, + _("spaces are not allowed in DNS TXT record names (name is '%s')"), name); goto error; } @@ -765,9 +761,9 @@ virNetworkIPParseXML(const char *networkName, if (address) { if (virSocketAddrParse(&def->address, address, AF_UNSPEC) < 0) { - virNetworkReportError(VIR_ERR_XML_ERROR, - _("Bad address '%s' in definition of network '%s'"), - address, networkName); + virReportError(VIR_ERR_XML_ERROR, + _("Bad address '%s' in definition of network '%s'"), + address, networkName); goto error; } @@ -777,29 +773,29 @@ virNetworkIPParseXML(const char *networkName, if (def->family == NULL) { if (!(VIR_SOCKET_ADDR_IS_FAMILY(&def->address, AF_INET) || VIR_SOCKET_ADDR_IS_FAMILY(&def->address, AF_UNSPEC))) { - virNetworkReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("no family specified for non-IPv4 address '%s' in network '%s'"), - address, networkName); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("no family specified for non-IPv4 address '%s' in network '%s'"), + address, networkName); goto error; } } else if (STREQ(def->family, "ipv4")) { if (!VIR_SOCKET_ADDR_IS_FAMILY(&def->address, AF_INET)) { - virNetworkReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("family 'ipv4' specified for non-IPv4 address '%s' in network '%s'"), - address, networkName); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("family 'ipv4' specified for non-IPv4 address '%s' in network '%s'"), + address, networkName); goto error; } } else if (STREQ(def->family, "ipv6")) { if (!VIR_SOCKET_ADDR_IS_FAMILY(&def->address, AF_INET6)) { - virNetworkReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("family 'ipv6' specified for non-IPv6 address '%s' in network '%s'"), - address, networkName); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("family 'ipv6' specified for non-IPv6 address '%s' in network '%s'"), + address, networkName); goto error; } } else { - virNetworkReportError(VIR_ERR_XML_ERROR, - _("Unrecognized family '%s' in definition of network '%s'"), - def->family, networkName); + virReportError(VIR_ERR_XML_ERROR, + _("Unrecognized family '%s' in definition of network '%s'"), + def->family, networkName); goto error; } @@ -807,24 +803,24 @@ virNetworkIPParseXML(const char *networkName, if (netmask) { if (address == NULL) { /* netmask is meaningless without an address */ - virNetworkReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("netmask specified without address in network '%s'"), - networkName); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("netmask specified without address in network '%s'"), + networkName); goto error; } if (!VIR_SOCKET_ADDR_IS_FAMILY(&def->address, AF_INET)) { - virNetworkReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("netmask not supported for address '%s' in network '%s' (IPv4 only)"), - address, networkName); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("netmask not supported for address '%s' in network '%s' (IPv4 only)"), + address, networkName); goto error; } if (def->prefix > 0) { /* can't have both netmask and prefix at the same time */ - virNetworkReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("network '%s' cannot have both prefix='%u' and a netmask"), - networkName, def->prefix); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("network '%s' cannot have both prefix='%u' and a netmask"), + networkName, def->prefix); goto error; } @@ -832,9 +828,9 @@ virNetworkIPParseXML(const char *networkName, goto error; if (!VIR_SOCKET_ADDR_IS_FAMILY(&def->netmask, AF_INET)) { - virNetworkReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("network '%s' has invalid netmask '%s' for address '%s' (both must be IPv4)"), - networkName, netmask, address); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("network '%s' has invalid netmask '%s' for address '%s' (both must be IPv4)"), + networkName, netmask, address); goto error; } } @@ -951,7 +947,7 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt) /* Extract network name */ def->name = virXPathString("string(./name[1])", ctxt); if (!def->name) { - virNetworkReportError(VIR_ERR_NO_NAME, NULL); + virReportError(VIR_ERR_NO_NAME, NULL); goto error; } @@ -959,15 +955,15 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt) tmp = virXPathString("string(./uuid[1])", ctxt); if (!tmp) { if (virUUIDGenerate(def->uuid)) { - virNetworkReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("Failed to generate UUID")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("Failed to generate UUID")); goto error; } } else { if (virUUIDParse(tmp, def->uuid) < 0) { VIR_FREE(tmp); - virNetworkReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("malformed uuid element")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("malformed uuid element")); goto error; } VIR_FREE(tmp); @@ -990,16 +986,16 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt) tmp = virXPathString("string(./mac[1]/@address)", ctxt); if (tmp) { if (virMacAddrParse(tmp, &def->mac) < 0) { - virNetworkReportError(VIR_ERR_XML_ERROR, - _("Invalid bridge mac address '%s' in network '%s'"), - tmp, def->name); + virReportError(VIR_ERR_XML_ERROR, + _("Invalid bridge mac address '%s' in network '%s'"), + tmp, def->name); VIR_FREE(tmp); goto error; } if (virMacAddrIsMulticast(&def->mac)) { - virNetworkReportError(VIR_ERR_XML_ERROR, - _("Invalid multicast bridge mac address '%s' in network '%s'"), - tmp, def->name); + virReportError(VIR_ERR_XML_ERROR, + _("Invalid multicast bridge mac address '%s' in network '%s'"), + tmp, def->name); VIR_FREE(tmp); goto error; } @@ -1073,8 +1069,8 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt) tmp = virXPathString("string(./@mode)", ctxt); if (tmp) { if ((def->forwardType = virNetworkForwardTypeFromString(tmp)) < 0) { - virNetworkReportError(VIR_ERR_XML_ERROR, - _("unknown forwarding type '%s'"), tmp); + virReportError(VIR_ERR_XML_ERROR, + _("unknown forwarding type '%s'"), tmp); VIR_FREE(tmp); goto error; } @@ -1090,8 +1086,8 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt) nForwardPfs = virXPathNodeSet("./pf", ctxt, &forwardPfNodes); if (nForwardIfs < 0 || nForwardPfs < 0) { - virNetworkReportError(VIR_ERR_XML_ERROR, - _("No interface pool or SRIOV physical device given")); + virReportError(VIR_ERR_XML_ERROR, + _("No interface pool or SRIOV physical device given")); goto error; } @@ -1102,16 +1098,16 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt) } if (forwardDev) { - virNetworkReportError(VIR_ERR_XML_ERROR, - _("A forward Dev should not be used when using a SRIOV PF")); + virReportError(VIR_ERR_XML_ERROR, + _("A forward Dev should not be used when using a SRIOV PF")); goto error; } forwardDev = virXMLPropString(*forwardPfNodes, "dev"); if (!forwardDev) { - virNetworkReportError(VIR_ERR_XML_ERROR, - _("Missing required dev attribute in network '%s' pf element"), - def->name); + virReportError(VIR_ERR_XML_ERROR, + _("Missing required dev attribute in network '%s' pf element"), + def->name); goto error; } @@ -1120,8 +1116,8 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt) forwardDev = NULL; def->nForwardPfs++; } else if (nForwardPfs > 1) { - virNetworkReportError(VIR_ERR_XML_ERROR, - _("Use of more than one physical interface is not allowed")); + virReportError(VIR_ERR_XML_ERROR, + _("Use of more than one physical interface is not allowed")); goto error; } if (nForwardIfs > 0 || forwardDev) { @@ -1144,9 +1140,9 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt) for (ii = 0; ii < nForwardIfs; ii++) { forwardDev = virXMLPropString(forwardIfNodes[ii], "dev"); if (!forwardDev) { - virNetworkReportError(VIR_ERR_XML_ERROR, - _("Missing required dev attribute in network '%s' forward interface element"), - def->name); + virReportError(VIR_ERR_XML_ERROR, + _("Missing required dev attribute in network '%s' forward interface element"), + def->name); goto error; } @@ -1154,10 +1150,10 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt) /* both forwardDev and an interface element are present. * If they don't match, it's an error. */ if (STRNEQ(forwardDev, def->forwardIfs[0].dev)) { - virNetworkReportError(VIR_ERR_XML_ERROR, - _("forward dev '%s' must match first interface element dev '%s' in network '%s'"), - def->forwardIfs[0].dev, - forwardDev, def->name); + virReportError(VIR_ERR_XML_ERROR, + _("forward dev '%s' must match first interface element dev '%s' in network '%s'"), + def->forwardIfs[0].dev, + forwardDev, def->name); goto error; } VIR_FREE(forwardDev); @@ -1181,16 +1177,16 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt) * the network we're on. */ if (def->nips == 0) { - virNetworkReportError(VIR_ERR_XML_ERROR, - _("%s forwarding requested, but no IP address provided for network '%s'"), - virNetworkForwardTypeToString(def->forwardType), - def->name); + virReportError(VIR_ERR_XML_ERROR, + _("%s forwarding requested, but no IP address provided for network '%s'"), + virNetworkForwardTypeToString(def->forwardType), + def->name); goto error; } if (def->nForwardIfs > 1) { - virNetworkReportError(VIR_ERR_XML_ERROR, - _("multiple forwarding interfaces specified for network '%s', only one is supported"), - def->name); + virReportError(VIR_ERR_XML_ERROR, + _("multiple forwarding interfaces specified for network '%s', only one is supported"), + def->name); goto error; } def->stp = (stp && STREQ(stp, "off")) ? 0 : 1; @@ -1199,19 +1195,19 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt) case VIR_NETWORK_FORWARD_VEPA: case VIR_NETWORK_FORWARD_PASSTHROUGH: if (def->bridge) { - virNetworkReportError(VIR_ERR_XML_ERROR, - _("bridge name not allowed in %s mode (network '%s')"), - virNetworkForwardTypeToString(def->forwardType), - def->name); + virReportError(VIR_ERR_XML_ERROR, + _("bridge name not allowed in %s mode (network '%s')"), + virNetworkForwardTypeToString(def->forwardType), + def->name); goto error; } /* fall through to next case */ case VIR_NETWORK_FORWARD_BRIDGE: if (def->delay || stp) { - virNetworkReportError(VIR_ERR_XML_ERROR, - _("bridge delay/stp options only allowed in route, nat, and isolated mode, not in %s (network '%s')"), - virNetworkForwardTypeToString(def->forwardType), - def->name); + virReportError(VIR_ERR_XML_ERROR, + _("bridge delay/stp options only allowed in route, nat, and isolated mode, not in %s (network '%s')"), + virNetworkForwardTypeToString(def->forwardType), + def->name); goto error; } break; @@ -1266,10 +1262,10 @@ virNetworkDefPtr virNetworkDefParseNode(xmlDocPtr xml, virNetworkDefPtr def = NULL; if (!xmlStrEqual(root->name, BAD_CAST "network")) { - virNetworkReportError(VIR_ERR_XML_ERROR, - _("unexpected root element <%s>, " - "expecting <network>"), - root->name); + virReportError(VIR_ERR_XML_ERROR, + _("unexpected root element <%s>, " + "expecting <network>"), + root->name); return NULL; } @@ -1476,9 +1472,9 @@ char *virNetworkDefFormat(const virNetworkDefPtr def, unsigned int flags) const char *mode = virNetworkForwardTypeToString(def->forwardType); if (!mode) { - virNetworkReportError(VIR_ERR_INTERNAL_ERROR, - _("Unknown forward type %d in network '%s'"), - def->forwardType, def->name); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Unknown forward type %d in network '%s'"), + def->forwardType, def->name); goto error; } virBufferAddLit(&buf, " <forward"); @@ -1644,10 +1640,10 @@ virNetworkObjPtr virNetworkLoadConfig(virNetworkObjListPtr nets, goto error; if (!STREQ(name, def->name)) { - virNetworkReportError(VIR_ERR_INTERNAL_ERROR, - _("Network config filename '%s'" - " does not match network name '%s'"), - configFile, def->name); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Network config filename '%s'" + " does not match network name '%s'"), + configFile, def->name); goto error; } @@ -1806,9 +1802,9 @@ char *virNetworkAllocateBridge(const virNetworkObjListPtr nets, id++; } while (id <= MAX_BRIDGE_ID); - virNetworkReportError(VIR_ERR_INTERNAL_ERROR, - _("Bridge generation exceeded max id %d"), - MAX_BRIDGE_ID); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Bridge generation exceeded max id %d"), + MAX_BRIDGE_ID); return NULL; } @@ -1824,9 +1820,9 @@ int virNetworkSetBridgeName(const virNetworkObjListPtr nets, * defined. */ if (check_collision && virNetworkBridgeInUse(nets, def->bridge, def->name)) { - virNetworkReportError(VIR_ERR_INTERNAL_ERROR, - _("bridge name '%s' already in use."), - def->bridge); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("bridge name '%s' already in use."), + def->bridge); goto error; } } else { @@ -1879,18 +1875,18 @@ virNetworkObjIsDuplicate(virNetworkObjListPtr doms, if (STRNEQ(vm->def->name, def->name)) { char uuidstr[VIR_UUID_STRING_BUFLEN]; virUUIDFormat(vm->def->uuid, uuidstr); - virNetworkReportError(VIR_ERR_OPERATION_FAILED, - _("network '%s' is already defined with uuid %s"), - vm->def->name, uuidstr); + virReportError(VIR_ERR_OPERATION_FAILED, + _("network '%s' is already defined with uuid %s"), + vm->def->name, uuidstr); goto cleanup; } if (check_active) { /* UUID & name match, but if VM is already active, refuse it */ if (virNetworkObjIsActive(vm)) { - virNetworkReportError(VIR_ERR_OPERATION_INVALID, - _("network is already active as '%s'"), - vm->def->name); + virReportError(VIR_ERR_OPERATION_INVALID, + _("network is already active as '%s'"), + vm->def->name); goto cleanup; } } @@ -1902,9 +1898,9 @@ virNetworkObjIsDuplicate(virNetworkObjListPtr doms, if (vm) { char uuidstr[VIR_UUID_STRING_BUFLEN]; virUUIDFormat(vm->def->uuid, uuidstr); - virNetworkReportError(VIR_ERR_OPERATION_FAILED, - _("network '%s' already exists with uuid %s"), - def->name, uuidstr); + virReportError(VIR_ERR_OPERATION_FAILED, + _("network '%s' already exists with uuid %s"), + def->name, uuidstr); goto cleanup; } } diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index c21150d..7144415 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -185,8 +185,8 @@ virNodeDeviceObjPtr virNodeDeviceAssignDef(virNodeDeviceObjListPtr devs, } if (virMutexInit(&device->lock) < 0) { - virNodeDeviceReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("cannot initialize mutex")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("cannot initialize mutex")); VIR_FREE(device); return NULL; } @@ -506,9 +506,9 @@ virNodeDevCapsDefParseULong(const char *xpath, ret = virXPathULong(xpath, ctxt, &val); if (ret < 0) { - virNodeDeviceReportError(VIR_ERR_INTERNAL_ERROR, - ret == -1 ? missing_error_fmt : invalid_error_fmt, - def->name); + virReportError(VIR_ERR_INTERNAL_ERROR, + ret == -1 ? missing_error_fmt : invalid_error_fmt, + def->name); return -1; } @@ -529,9 +529,9 @@ virNodeDevCapsDefParseULongLong(const char *xpath, ret = virXPathULongLong(xpath, ctxt, &val); if (ret < 0) { - virNodeDeviceReportError(VIR_ERR_INTERNAL_ERROR, - ret == -1 ? missing_error_fmt : invalid_error_fmt, - def->name); + virReportError(VIR_ERR_INTERNAL_ERROR, + ret == -1 ? missing_error_fmt : invalid_error_fmt, + def->name); return -1; } @@ -554,9 +554,9 @@ virNodeDevCapStorageParseXML(xmlXPathContextPtr ctxt, data->storage.block = virXPathString("string(./block[1])", ctxt); if (!data->storage.block) { - virNodeDeviceReportError(VIR_ERR_INTERNAL_ERROR, - _("no block device path supplied for '%s'"), - def->name); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("no block device path supplied for '%s'"), + def->name); goto out; } @@ -574,9 +574,9 @@ virNodeDevCapStorageParseXML(xmlXPathContextPtr ctxt, char *type = virXMLPropString(nodes[i], "type"); if (!type) { - virNodeDeviceReportError(VIR_ERR_INTERNAL_ERROR, - _("missing storage capability type for '%s'"), - def->name); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("missing storage capability type for '%s'"), + def->name); goto out; } @@ -607,9 +607,9 @@ virNodeDevCapStorageParseXML(xmlXPathContextPtr ctxt, ctxt->node = orignode2; } else { - virNodeDeviceReportError(VIR_ERR_INTERNAL_ERROR, - _("unknown storage capability type '%s' for '%s'"), - type, def->name); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unknown storage capability type '%s' for '%s'"), + type, def->name); VIR_FREE(type); goto out; } @@ -692,9 +692,9 @@ virNodeDevCapScsiTargetParseXML(xmlXPathContextPtr ctxt, data->scsi_target.name = virXPathString("string(./name[1])", ctxt); if (!data->scsi_target.name) { - virNodeDeviceReportError(VIR_ERR_INTERNAL_ERROR, - _("no target name supplied for '%s'"), - def->name); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("no target name supplied for '%s'"), + def->name); goto out; } @@ -737,9 +737,9 @@ virNodeDevCapScsiHostParseXML(xmlXPathContextPtr ctxt, type = virXMLPropString(nodes[i], "type"); if (!type) { - virNodeDeviceReportError(VIR_ERR_INTERNAL_ERROR, - _("missing SCSI host capability type for '%s'"), - def->name); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("missing SCSI host capability type for '%s'"), + def->name); goto out; } @@ -760,10 +760,10 @@ virNodeDevCapScsiHostParseXML(xmlXPathContextPtr ctxt, ctxt, &data->scsi_host.wwnn) < 0) { if (virRandomGenerateWWN(&data->scsi_host.wwnn, virt_type) < 0) { - virNodeDeviceReportError(VIR_ERR_INTERNAL_ERROR, - _("no WWNN supplied for '%s', and " - "auto-generation failed"), - def->name); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("no WWNN supplied for '%s', and " + "auto-generation failed"), + def->name); goto out; } } @@ -772,10 +772,10 @@ virNodeDevCapScsiHostParseXML(xmlXPathContextPtr ctxt, ctxt, &data->scsi_host.wwpn) < 0) { if (virRandomGenerateWWN(&data->scsi_host.wwpn, virt_type) < 0) { - virNodeDeviceReportError(VIR_ERR_INTERNAL_ERROR, - _("no WWPN supplied for '%s', and " - "auto-generation failed"), - def->name); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("no WWPN supplied for '%s', and " + "auto-generation failed"), + def->name); goto out; } } @@ -783,9 +783,9 @@ virNodeDevCapScsiHostParseXML(xmlXPathContextPtr ctxt, ctxt->node = orignode2; } else { - virNodeDeviceReportError(VIR_ERR_INTERNAL_ERROR, - _("unknown SCSI host capability type '%s' for '%s'"), - type, def->name); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unknown SCSI host capability type '%s' for '%s'"), + type, def->name); goto out; } @@ -817,9 +817,9 @@ virNodeDevCapNetParseXML(xmlXPathContextPtr ctxt, data->net.ifname = virXPathString("string(./interface[1])", ctxt); if (!data->net.ifname) { - virNodeDeviceReportError(VIR_ERR_INTERNAL_ERROR, - _("no network interface supplied for '%s'"), - def->name); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("no network interface supplied for '%s'"), + def->name); goto out; } @@ -832,9 +832,9 @@ virNodeDevCapNetParseXML(xmlXPathContextPtr ctxt, int val = virNodeDevNetCapTypeFromString(tmp); VIR_FREE(tmp); if (val < 0) { - virNodeDeviceReportError(VIR_ERR_INTERNAL_ERROR, - _("invalid network type supplied for '%s'"), - def->name); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("invalid network type supplied for '%s'"), + def->name); goto out; } data->net.subtype = val; @@ -903,9 +903,9 @@ virNodeDevCapsDefParseHexId(const char *xpath, ret = virXPathULongHex(xpath, ctxt, &val); if (ret < 0) { - virNodeDeviceReportError(VIR_ERR_INTERNAL_ERROR, - ret == -1 ? missing_error_fmt : invalid_error_fmt, - def->name); + virReportError(VIR_ERR_INTERNAL_ERROR, + ret == -1 ? missing_error_fmt : invalid_error_fmt, + def->name); return -1; } @@ -1036,14 +1036,14 @@ virNodeDevCapSystemParseXML(xmlXPathContextPtr ctxt, tmp = virXPathString("string(./hardware/uuid[1])", ctxt); if (!tmp) { - virNodeDeviceReportError(VIR_ERR_INTERNAL_ERROR, - _("no system UUID supplied for '%s'"), def->name); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("no system UUID supplied for '%s'"), def->name); goto out; } if (virUUIDParse(tmp, data->system.hardware.uuid) < 0) { - virNodeDeviceReportError(VIR_ERR_INTERNAL_ERROR, - _("malformed uuid element for '%s'"), def->name); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("malformed uuid element for '%s'"), def->name); VIR_FREE(tmp); goto out; } @@ -1077,14 +1077,14 @@ virNodeDevCapsDefParseXML(xmlXPathContextPtr ctxt, tmp = virXMLPropString(node, "type"); if (!tmp) { - virNodeDeviceReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("missing capability type")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("missing capability type")); goto error; } if ((val = virNodeDevCapTypeFromString(tmp)) < 0) { - virNodeDeviceReportError(VIR_ERR_INTERNAL_ERROR, - _("unknown capability type '%s'"), tmp); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unknown capability type '%s'"), tmp); VIR_FREE(tmp); goto error; } @@ -1123,9 +1123,9 @@ virNodeDevCapsDefParseXML(xmlXPathContextPtr ctxt, ret = virNodeDevCapStorageParseXML(ctxt, def, node, &caps->data); break; default: - virNodeDeviceReportError(VIR_ERR_INTERNAL_ERROR, - _("unknown capability type '%d' for '%s'"), - caps->type, def->name); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unknown capability type '%d' for '%s'"), + caps->type, def->name); ret = -1; break; } @@ -1159,7 +1159,7 @@ virNodeDeviceDefParseXML(xmlXPathContextPtr ctxt, def->name = virXPathString("string(./name[1])", ctxt); if (!def->name) { - virNodeDeviceReportError(VIR_ERR_NO_NAME, NULL); + virReportError(VIR_ERR_NO_NAME, NULL); goto error; } } else { @@ -1181,9 +1181,9 @@ virNodeDeviceDefParseXML(xmlXPathContextPtr ctxt, } if (n == 0) { - virNodeDeviceReportError(VIR_ERR_INTERNAL_ERROR, - _("no device capabilities for '%s'"), - def->name); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("no device capabilities for '%s'"), + def->name); goto error; } @@ -1219,10 +1219,10 @@ virNodeDeviceDefParseNode(xmlDocPtr xml, virNodeDeviceDefPtr def = NULL; if (!xmlStrEqual(root->name, BAD_CAST "device")) { - virNodeDeviceReportError(VIR_ERR_XML_ERROR, - _("unexpected root element <%s> " - "expecting <device>"), - root->name); + virReportError(VIR_ERR_XML_ERROR, + _("unexpected root element <%s> " + "expecting <device>"), + root->name); return NULL; } @@ -1298,8 +1298,8 @@ virNodeDeviceGetWWNs(virNodeDeviceDefPtr def, } if (cap == NULL) { - virNodeDeviceReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("Device is not a fibre channel HBA")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("Device is not a fibre channel HBA")); ret = -1; } else if (*wwnn == NULL || *wwpn == NULL) { /* Free the other one, if allocated... */ @@ -1327,9 +1327,9 @@ virNodeDeviceGetParentHost(const virNodeDeviceObjListPtr devs, parent = virNodeDeviceFindByName(devs, parent_name); if (parent == NULL) { - virNodeDeviceReportError(VIR_ERR_INTERNAL_ERROR, - _("Could not find parent device for '%s'"), - dev_name); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Could not find parent device for '%s'"), + dev_name); ret = -1; goto out; } @@ -1347,10 +1347,10 @@ virNodeDeviceGetParentHost(const virNodeDeviceObjListPtr devs, } if (cap == NULL) { - virNodeDeviceReportError(VIR_ERR_INTERNAL_ERROR, - _("Parent device %s is not capable " - "of vport operations"), - parent->def->name); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Parent device %s is not capable " + "of vport operations"), + parent->def->name); ret = -1; } diff --git a/src/conf/node_device_conf.h b/src/conf/node_device_conf.h index 4aaf4c8..ddf5fca 100644 --- a/src/conf/node_device_conf.h +++ b/src/conf/node_device_conf.h @@ -212,9 +212,6 @@ struct _virDeviceMonitorState { void *privateData; /* driver-specific private data */ }; -# define virNodeDeviceReportError(code, ...) \ - virReportErrorHelper(VIR_FROM_NODEDEV, code, __FILE__, \ - __FUNCTION__, __LINE__, __VA_ARGS__) int virNodeDeviceHasCap(const virNodeDeviceObjPtr dev, const char *cap); diff --git a/src/conf/nwfilter_conf.c b/src/conf/nwfilter_conf.c index a13f705..70fadaa 100644 --- a/src/conf/nwfilter_conf.c +++ b/src/conf/nwfilter_conf.c @@ -1007,8 +1007,8 @@ ipsetValidator(enum attrDatatype datatype ATTRIBUTE_UNUSED, union data *val, return true; arg_err_exit: - virNWFilterReportError(VIR_ERR_INVALID_ARG, - "%s", errmsg); + virReportError(VIR_ERR_INVALID_ARG, + "%s", errmsg); return false; } @@ -1053,8 +1053,8 @@ ipsetFlagsValidator(enum attrDatatype datatype ATTRIBUTE_UNUSED, union data *val return true; arg_err_exit: - virNWFilterReportError(VIR_ERR_INVALID_ARG, - "%s", errmsg); + virReportError(VIR_ERR_INVALID_ARG, + "%s", errmsg); return false; } @@ -2014,9 +2014,9 @@ virNWFilterRuleDetailsParse(xmlNodePtr node, } if (!found || rc) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, - _("%s has illegal value %s"), - att[idx].name, prop); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("%s has illegal value %s"), + att[idx].name, prop); rc = -1; } VIR_FREE(prop); @@ -2048,9 +2048,9 @@ virNWFilterIncludeParse(xmlNodePtr cur) ret->filterref = virXMLPropString(cur, "filter"); if (!ret->filterref) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, - "%s", - _("rule node requires action attribute")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", + _("rule node requires action attribute")); goto err_exit; } @@ -2316,30 +2316,30 @@ virNWFilterRuleParse(xmlNodePtr node) statematch= virXMLPropString(node, "statematch"); if (!action) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, - "%s", - _("rule node requires action attribute")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", + _("rule node requires action attribute")); goto err_exit; } if ((ret->action = virNWFilterRuleActionTypeFromString(action)) < 0) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, - "%s", - _("unknown rule action attribute value")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", + _("unknown rule action attribute value")); goto err_exit; } if (!direction) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, - "%s", - _("rule node requires direction attribute")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", + _("rule node requires direction attribute")); goto err_exit; } if ((ret->tt = virNWFilterRuleDirectionTypeFromString(direction)) < 0) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, - "%s", - _("unknown rule direction attribute value")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", + _("unknown rule direction attribute value")); goto err_exit; } @@ -2415,16 +2415,16 @@ static bool virNWFilterIsValidChainName(const char *chainname) { if (strlen(chainname) > MAX_CHAIN_SUFFIX_SIZE) { - virNWFilterReportError(VIR_ERR_INVALID_ARG, - _("Name of chain is longer than " - "%u characters"), - MAX_CHAIN_SUFFIX_SIZE); + virReportError(VIR_ERR_INVALID_ARG, + _("Name of chain is longer than " + "%u characters"), + MAX_CHAIN_SUFFIX_SIZE); return false; } if (chainname[strspn(chainname, VALID_CHAINNAME)] != 0) { - virNWFilterReportError(VIR_ERR_INVALID_ARG, - _("Chain name contains invalid characters")); + virReportError(VIR_ERR_INVALID_ARG, + _("Chain name contains invalid characters")); return false; } @@ -2483,7 +2483,7 @@ virNWFilterIsAllowedChain(const char *chainname) msg = virBufferContentAndReset(&buf); - virNWFilterReportError(VIR_ERR_INVALID_ARG, "%s", msg); + virReportError(VIR_ERR_INVALID_ARG, "%s", msg); VIR_FREE(msg); err_exit: @@ -2508,27 +2508,27 @@ virNWFilterDefParseXML(xmlXPathContextPtr ctxt) { ret->name = virXPathString("string(./@name)", ctxt); if (!ret->name) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("filter has no name")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("filter has no name")); goto cleanup; } chain_pri_s = virXPathString("string(./@priority)", ctxt); if (chain_pri_s) { if (virStrToLong_i(chain_pri_s, NULL, 10, &chain_priority) < 0) { - virNWFilterReportError(VIR_ERR_INVALID_ARG, - _("Could not parse chain priority '%s'"), - chain_pri_s); + virReportError(VIR_ERR_INVALID_ARG, + _("Could not parse chain priority '%s'"), + chain_pri_s); goto cleanup; } if (chain_priority < NWFILTER_MIN_FILTER_PRIORITY || chain_priority > NWFILTER_MAX_FILTER_PRIORITY) { - virNWFilterReportError(VIR_ERR_INVALID_ARG, - _("Priority '%d' is outside valid " - "range of [%d,%d]"), - chain_priority, - NWFILTER_MIN_FILTER_PRIORITY, - NWFILTER_MAX_FILTER_PRIORITY); + virReportError(VIR_ERR_INVALID_ARG, + _("Priority '%d' is outside valid " + "range of [%d,%d]"), + chain_priority, + NWFILTER_MIN_FILTER_PRIORITY, + NWFILTER_MAX_FILTER_PRIORITY); goto cleanup; } } @@ -2565,14 +2565,14 @@ virNWFilterDefParseXML(xmlXPathContextPtr ctxt) { uuid = virXPathString("string(./uuid)", ctxt); if (uuid == NULL) { if (virUUIDGenerate(ret->uuid) < 0) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("unable to generate uuid")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("unable to generate uuid")); goto cleanup; } } else { if (virUUIDParse(uuid, ret->uuid) < 0) { - virNWFilterReportError(VIR_ERR_XML_ERROR, - "%s", _("malformed uuid element")); + virReportError(VIR_ERR_XML_ERROR, + "%s", _("malformed uuid element")); goto cleanup; } VIR_FREE(uuid); @@ -2627,9 +2627,9 @@ virNWFilterDefParseNode(xmlDocPtr xml, virNWFilterDefPtr def = NULL; if (STRNEQ((const char *)root->name, "filter")) { - virNWFilterReportError(VIR_ERR_XML_ERROR, - "%s", - _("unknown root element for nw filter")); + virReportError(VIR_ERR_XML_ERROR, + "%s", + _("unknown root element for nw filter")); goto cleanup; } @@ -2976,10 +2976,10 @@ virNWFilterObjAssignDef(virConnectPtr conn, if (nwfilter) { if (!STREQ(def->name, nwfilter->def->name)) { - virNWFilterReportError(VIR_ERR_OPERATION_FAILED, - _("filter with same UUID but different name " - "('%s') already exists"), - nwfilter->def->name); + virReportError(VIR_ERR_OPERATION_FAILED, + _("filter with same UUID but different name " + "('%s') already exists"), + nwfilter->def->name); virNWFilterObjUnlock(nwfilter); return NULL; } @@ -2987,8 +2987,8 @@ virNWFilterObjAssignDef(virConnectPtr conn, } if (virNWFilterDefLoopDetect(conn, nwfilters, def) < 0) { - virNWFilterReportError(VIR_ERR_OPERATION_FAILED, - "%s", _("filter would introduce a loop")); + virReportError(VIR_ERR_OPERATION_FAILED, + "%s", _("filter would introduce a loop")); return NULL; } @@ -3027,8 +3027,8 @@ virNWFilterObjAssignDef(virConnectPtr conn, } if (virMutexInitRecursive(&nwfilter->lock) < 0) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("cannot initialize mutex")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("cannot initialize mutex")); VIR_FREE(nwfilter); return NULL; } @@ -3063,9 +3063,9 @@ virNWFilterObjLoad(virConnectPtr conn, } if (!virFileMatchesNameSuffix(file, def->name, ".xml")) { - virNWFilterReportError(VIR_ERR_XML_ERROR, - _("network filter config filename '%s' does not match name '%s'"), - path, def->name); + virReportError(VIR_ERR_XML_ERROR, + _("network filter config filename '%s' does not match name '%s'"), + path, def->name); virNWFilterDefFree(def); return NULL; } @@ -3153,8 +3153,8 @@ virNWFilterObjSaveDef(virNWFilterDriverStatePtr driver, } if (!(xml = virNWFilterDefFormat(def))) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("failed to generate XML")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("failed to generate XML")); return -1; } @@ -3169,15 +3169,15 @@ int virNWFilterObjDeleteDef(virNWFilterObjPtr nwfilter) { if (!nwfilter->configFile) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, - _("no config file for %s"), nwfilter->def->name); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("no config file for %s"), nwfilter->def->name); return -1; } if (unlink(nwfilter->configFile) < 0) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, - _("cannot remove config for %s"), - nwfilter->def->name); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("cannot remove config for %s"), + nwfilter->def->name); return -1; } @@ -3248,10 +3248,10 @@ virNWFilterRuleDefDetailsFormat(virBufferPtr buf, att[i].name); if (att[i].formatter && !(flags & NWFILTER_ENTRY_ITEM_FLAG_HAS_VAR)) { if (!att[i].formatter(buf, def, item)) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, - _("formatter for %s %s reported error"), - type, - att[i].name); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("formatter for %s %s reported error"), + type, + att[i].name); goto err_exit; } } else if ((flags & NWFILTER_ENTRY_ITEM_FLAG_HAS_VAR)) { diff --git a/src/conf/nwfilter_conf.h b/src/conf/nwfilter_conf.h index ad4a175..5cffded 100644 --- a/src/conf/nwfilter_conf.h +++ b/src/conf/nwfilter_conf.h @@ -731,10 +731,6 @@ void virNWFilterConfLayerShutdown(void); int virNWFilterInstFiltersOnAllVMs(virConnectPtr conn); -# define virNWFilterReportError(code, fmt...) \ - virReportErrorHelper(VIR_FROM_NWFILTER, code, __FILE__, \ - __FUNCTION__, __LINE__, fmt) - typedef int (*virNWFilterRebuild)(virConnectPtr conn, virHashIterator, void *data); diff --git a/src/conf/nwfilter_params.c b/src/conf/nwfilter_params.c index 79f7800..d08e860 100644 --- a/src/conf/nwfilter_params.c +++ b/src/conf/nwfilter_params.c @@ -113,8 +113,8 @@ virNWFilterVarValueCreateSimple(char *value) virNWFilterVarValuePtr val; if (!isValidVarValue(value)) { - virNWFilterReportError(VIR_ERR_INVALID_ARG, - _("Variable value contains invalid character")); + virReportError(VIR_ERR_INVALID_ARG, + _("Variable value contains invalid character")); return NULL; } @@ -324,9 +324,9 @@ virNWFilterVarCombIterAddVariable(virNWFilterVarCombIterEntryPtr cie, varValue = virHashLookup(hash->hashTable, varName); if (varValue == NULL) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, - _("Could not find value for variable '%s'"), - varName); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Could not find value for variable '%s'"), + varName); return -1; } @@ -349,10 +349,10 @@ virNWFilterVarCombIterAddVariable(virNWFilterVarCombIterEntryPtr cie, cie->curValue = minValue; } else { if (cie->maxValue != maxValue) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, - _("Cardinality of list items must be " - "the same for processing them in " - "parallel")); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Cardinality of list items must be " + "the same for processing them in " + "parallel")); return -1; } } @@ -541,9 +541,9 @@ virNWFilterVarCombIterGetVarValue(virNWFilterVarCombIterPtr ci, iterId = virNWFilterVarAccessGetIterId(vap); iterIndex = virNWFilterVarCombIterGetIndexByIterId(ci, iterId); if (iterIndex < 0) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, - _("Could not get iterator index for " - "iterator ID %u"), iterId); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Could not get iterator index for " + "iterator ID %u"), iterId); return NULL; } break; @@ -551,9 +551,9 @@ virNWFilterVarCombIterGetVarValue(virNWFilterVarCombIterPtr ci, iterId = virNWFilterVarAccessGetIntIterId(vap); iterIndex = virNWFilterVarCombIterGetIndexByIterId(ci, iterId); if (iterIndex < 0) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, - _("Could not get iterator index for " - "(internal) iterator ID %u"), iterId); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Could not get iterator index for " + "(internal) iterator ID %u"), iterId); return NULL; } break; @@ -569,26 +569,26 @@ virNWFilterVarCombIterGetVarValue(virNWFilterVarCombIterPtr ci, } if (!found) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, - _("Could not find variable '%s' in iterator"), - varName); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Could not find variable '%s' in iterator"), + varName); return NULL; } value = virHashLookup(ci->hashTable->hashTable, varName); if (!value) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, - _("Could not find value for variable '%s'"), - varName); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Could not find value for variable '%s'"), + varName); return NULL; } res = virNWFilterVarValueGetNthValue(value, ci->iter[iterIndex].curValue); if (!res) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, - _("Could not get nth (%u) value of " - "variable '%s'"), - ci->iter[iterIndex].curValue, varName); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Could not get nth (%u) value of " + "variable '%s'"), + ci->iter[iterIndex].curValue, varName); return NULL; } @@ -736,9 +736,9 @@ addToTable(void *payload, const void *name, void *data) } if (virNWFilterHashTablePut(atts->target, (const char *)name, val, 1) < 0){ - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, - _("Could not put variable '%s' into hashmap"), - (const char *)name); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Could not put variable '%s' into hashmap"), + (const char *)name); atts->errOccurred = 1; virNWFilterVarValueFree(val); } @@ -863,8 +863,8 @@ virNWFilterFormatParamAttributes(virBufferPtr buf, numKeys = virHashSize(table->hashTable); if (numKeys < 0) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("missing filter parameter table")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("missing filter parameter table")); return -1; } @@ -998,11 +998,11 @@ virNWFilterVarAccessParse(const char *varAccess) } if (parseError) { if (dest->accessType == VIR_NWFILTER_VAR_ACCESS_ELEMENT) - virNWFilterReportError(VIR_ERR_INVALID_ARG, - _("Malformatted array index")); + virReportError(VIR_ERR_INVALID_ARG, + _("Malformatted array index")); else - virNWFilterReportError(VIR_ERR_INVALID_ARG, - _("Malformatted iterator id")); + virReportError(VIR_ERR_INVALID_ARG, + _("Malformatted iterator id")); goto err_exit; } @@ -1013,9 +1013,9 @@ virNWFilterVarAccessParse(const char *varAccess) break; case VIR_NWFILTER_VAR_ACCESS_ITERATOR: if (result > VIR_NWFILTER_MAX_ITERID) { - virNWFilterReportError(VIR_ERR_INVALID_ARG, - _("Iterator ID exceeds maximum ID " - "of %u"), VIR_NWFILTER_MAX_ITERID); + virReportError(VIR_ERR_INVALID_ARG, + _("Iterator ID exceeds maximum ID " + "of %u"), VIR_NWFILTER_MAX_ITERID); goto err_exit; } dest->u.iterId = result; @@ -1026,8 +1026,8 @@ virNWFilterVarAccessParse(const char *varAccess) return dest; } else { - virNWFilterReportError(VIR_ERR_INVALID_ARG, - _("Malformatted variable")); + virReportError(VIR_ERR_INVALID_ARG, + _("Malformatted variable")); } err_exit: diff --git a/src/conf/secret_conf.c b/src/conf/secret_conf.c index 6e80733..0f72596 100644 --- a/src/conf/secret_conf.c +++ b/src/conf/secret_conf.c @@ -73,14 +73,14 @@ virSecretDefParseUsage(xmlXPathContextPtr ctxt, type_str = virXPathString("string(./usage/@type)", ctxt); if (type_str == NULL) { - virSecretReportError(VIR_ERR_XML_ERROR, "%s", - _("unknown secret usage type")); + virReportError(VIR_ERR_XML_ERROR, "%s", + _("unknown secret usage type")); return -1; } type = virSecretUsageTypeTypeFromString(type_str); if (type < 0) { - virSecretReportError(VIR_ERR_XML_ERROR, - _("unknown secret usage type %s"), type_str); + virReportError(VIR_ERR_XML_ERROR, + _("unknown secret usage type %s"), type_str); VIR_FREE(type_str); return -1; } @@ -93,8 +93,8 @@ virSecretDefParseUsage(xmlXPathContextPtr ctxt, case VIR_SECRET_USAGE_TYPE_VOLUME: def->usage.volume = virXPathString("string(./usage/volume)", ctxt); if (!def->usage.volume) { - virSecretReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("volume usage specified, but volume path is missing")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("volume usage specified, but volume path is missing")); return -1; } break; @@ -102,16 +102,16 @@ virSecretDefParseUsage(xmlXPathContextPtr ctxt, case VIR_SECRET_USAGE_TYPE_CEPH: def->usage.ceph = virXPathString("string(./usage/name)", ctxt); if (!def->usage.ceph) { - virSecretReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Ceph usage specified, but name is missing")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Ceph usage specified, but name is missing")); return -1; } break; default: - virSecretReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected secret usage type %d"), - def->usage_type); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected secret usage type %d"), + def->usage_type); return -1; } return 0; @@ -126,10 +126,10 @@ secretXMLParseNode(xmlDocPtr xml, xmlNodePtr root) char *uuidstr = NULL; if (!xmlStrEqual(root->name, BAD_CAST "secret")) { - virSecretReportError(VIR_ERR_XML_ERROR, - _("unexpected root element <%s>, " - "expecting <secret>"), - root->name); + virReportError(VIR_ERR_XML_ERROR, + _("unexpected root element <%s>, " + "expecting <secret>"), + root->name); goto cleanup; } @@ -152,8 +152,8 @@ secretXMLParseNode(xmlDocPtr xml, xmlNodePtr root) else if (STREQ(prop, "no")) def->ephemeral = 0; else { - virSecretReportError(VIR_ERR_XML_ERROR, "%s", - _("invalid value of 'ephemeral'")); + virReportError(VIR_ERR_XML_ERROR, "%s", + _("invalid value of 'ephemeral'")); goto cleanup; } VIR_FREE(prop); @@ -166,8 +166,8 @@ secretXMLParseNode(xmlDocPtr xml, xmlNodePtr root) else if (STREQ(prop, "no")) def->private = 0; else { - virSecretReportError(VIR_ERR_XML_ERROR, "%s", - _("invalid value of 'private'")); + virReportError(VIR_ERR_XML_ERROR, "%s", + _("invalid value of 'private'")); goto cleanup; } VIR_FREE(prop); @@ -176,14 +176,14 @@ secretXMLParseNode(xmlDocPtr xml, xmlNodePtr root) uuidstr = virXPathString("string(./uuid)", ctxt); if (!uuidstr) { if (virUUIDGenerate(def->uuid)) { - virSecretReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("Failed to generate UUID")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("Failed to generate UUID")); goto cleanup; } } else { if (virUUIDParse(uuidstr, def->uuid) < 0) { - virSecretReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("malformed uuid element")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("malformed uuid element")); goto cleanup; } VIR_FREE(uuidstr); @@ -239,9 +239,9 @@ virSecretDefFormatUsage(virBufferPtr buf, type = virSecretUsageTypeTypeToString(def->usage_type); if (type == NULL) { - virSecretReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected secret usage type %d"), - def->usage_type); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected secret usage type %d"), + def->usage_type); return -1; } virBufferAsprintf(buf, " <usage type='%s'>\n", type); @@ -263,9 +263,9 @@ virSecretDefFormatUsage(virBufferPtr buf, break; default: - virSecretReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected secret usage type %d"), - def->usage_type); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected secret usage type %d"), + def->usage_type); return -1; } virBufferAddLit(buf, " </usage>\n"); diff --git a/src/conf/secret_conf.h b/src/conf/secret_conf.h index b5d72d4..854b380 100644 --- a/src/conf/secret_conf.h +++ b/src/conf/secret_conf.h @@ -26,10 +26,6 @@ # include "internal.h" # include "util.h" -# define virSecretReportError(code, ...) \ - virReportErrorHelper(VIR_FROM_SECRET, code, __FILE__, \ - __FUNCTION__, __LINE__, __VA_ARGS__) - VIR_ENUM_DECL(virSecretUsageType) typedef struct _virSecretDef virSecretDef; diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c index 36a3bb9..44387b2 100644 --- a/src/conf/storage_conf.c +++ b/src/conf/storage_conf.c @@ -236,8 +236,8 @@ virStoragePoolTypeInfoLookup(int type) { if (poolTypeInfo[i].poolType == type) return &poolTypeInfo[i]; - virStorageReportError(VIR_ERR_INTERNAL_ERROR, - _("missing backend for pool type %d"), type); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("missing backend for pool type %d"), type); return NULL; } @@ -402,15 +402,15 @@ virStoragePoolDefParseAuthChap(xmlXPathContextPtr ctxt, virStoragePoolAuthChapPtr auth) { auth->login = virXPathString("string(./auth/@login)", ctxt); if (auth->login == NULL) { - virStorageReportError(VIR_ERR_XML_ERROR, - "%s", _("missing auth host attribute")); + virReportError(VIR_ERR_XML_ERROR, + "%s", _("missing auth host attribute")); return -1; } auth->passwd = virXPathString("string(./auth/@passwd)", ctxt); if (auth->passwd == NULL) { - virStorageReportError(VIR_ERR_XML_ERROR, - "%s", _("missing auth passwd attribute")); + virReportError(VIR_ERR_XML_ERROR, + "%s", _("missing auth passwd attribute")); return -1; } @@ -423,22 +423,22 @@ virStoragePoolDefParseAuthCephx(xmlXPathContextPtr ctxt, char *uuid = NULL; auth->username = virXPathString("string(./auth/@username)", ctxt); if (auth->username == NULL) { - virStorageReportError(VIR_ERR_XML_ERROR, - "%s", _("missing auth username attribute")); + virReportError(VIR_ERR_XML_ERROR, + "%s", _("missing auth username attribute")); return -1; } uuid = virXPathString("string(./auth/secret/@uuid)", ctxt); auth->secret.usage = virXPathString("string(./auth/secret/@usage)", ctxt); if (uuid == NULL && auth->secret.usage == NULL) { - virStorageReportError(VIR_ERR_XML_ERROR, "%s", - _("missing auth secret uuid or usage attribute")); + virReportError(VIR_ERR_XML_ERROR, "%s", + _("missing auth secret uuid or usage attribute")); return -1; } if (virUUIDParse(uuid, auth->secret.uuid) < 0) { - virStorageReportError(VIR_ERR_XML_ERROR, - "%s", _("invalid auth secret uuid")); + virReportError(VIR_ERR_XML_ERROR, + "%s", _("invalid auth secret uuid")); return -1; } @@ -467,8 +467,8 @@ virStoragePoolDefParseSource(xmlXPathContextPtr ctxt, source->name = virXPathString("string(./name)", ctxt); if (pool_type == VIR_STORAGE_POOL_RBD && source->name == NULL) { - virStorageReportError(VIR_ERR_XML_ERROR, "%s", - _("missing mandatory 'name' field for RBD pool name")); + virReportError(VIR_ERR_XML_ERROR, "%s", + _("missing mandatory 'name' field for RBD pool name")); goto cleanup; } @@ -480,8 +480,8 @@ virStoragePoolDefParseSource(xmlXPathContextPtr ctxt, source->format = options->formatFromString(format); if (source->format < 0) { - virStorageReportError(VIR_ERR_XML_ERROR, - _("unknown pool format type %s"), format); + virReportError(VIR_ERR_XML_ERROR, + _("unknown pool format type %s"), format); VIR_FREE(format); goto cleanup; } @@ -499,8 +499,8 @@ virStoragePoolDefParseSource(xmlXPathContextPtr ctxt, for (i = 0 ; i < source->nhost ; i++) { name = virXMLPropString(nodeset[i], "name"); if (name == NULL) { - virStorageReportError(VIR_ERR_XML_ERROR, - "%s", _("missing storage pool host name")); + virReportError(VIR_ERR_XML_ERROR, + "%s", _("missing storage pool host name")); goto cleanup; } source->hosts[i].name = name; @@ -508,9 +508,9 @@ virStoragePoolDefParseSource(xmlXPathContextPtr ctxt, port = virXMLPropString(nodeset[i], "port"); if (port) { if (virStrToLong_i(port, NULL, 10, &source->hosts[i].port) < 0) { - virStorageReportError(VIR_ERR_XML_ERROR, - _("Invalid port number: %s"), - port); + virReportError(VIR_ERR_XML_ERROR, + _("Invalid port number: %s"), + port); goto cleanup; } } @@ -535,8 +535,8 @@ virStoragePoolDefParseSource(xmlXPathContextPtr ctxt, char *path = virXMLPropString(nodeset[i], "path"); if (path == NULL) { VIR_FREE(nodeset); - virStorageReportError(VIR_ERR_XML_ERROR, - "%s", _("missing storage pool source device path")); + virReportError(VIR_ERR_XML_ERROR, + "%s", _("missing storage pool source device path")); goto cleanup; } source->devices[i].path = path; @@ -556,9 +556,9 @@ virStoragePoolDefParseSource(xmlXPathContextPtr ctxt, } else if (STREQ(authType, "ceph")) { source->authType = VIR_STORAGE_POOL_AUTH_CEPHX; } else { - virStorageReportError(VIR_ERR_XML_ERROR, - _("unknown auth type '%s'"), - (const char *)authType); + virReportError(VIR_ERR_XML_ERROR, + _("unknown auth type '%s'"), + (const char *)authType); goto cleanup; } } @@ -606,8 +606,8 @@ virStoragePoolDefParseSourceString(const char *srcSpec, } if (!(node = virXPathNode("/source", xpath_ctxt))) { - virStorageReportError(VIR_ERR_XML_ERROR, "%s", - _("root element was not source")); + virReportError(VIR_ERR_XML_ERROR, "%s", + _("root element was not source")); goto cleanup; } @@ -656,8 +656,8 @@ virStorageDefParsePerms(xmlXPathContextPtr ctxt, if (virStrToLong_i(mode, NULL, 8, &tmp) < 0 || (tmp & ~0777)) { VIR_FREE(mode); - virStorageReportError(VIR_ERR_XML_ERROR, - "%s", _("malformed octal mode")); + virReportError(VIR_ERR_XML_ERROR, + "%s", _("malformed octal mode")); goto error; } perms->mode = tmp; @@ -668,8 +668,8 @@ virStorageDefParsePerms(xmlXPathContextPtr ctxt, perms->uid = -1; } else { if (virXPathLong("number(./owner)", ctxt, &v) < 0) { - virStorageReportError(VIR_ERR_XML_ERROR, - "%s", _("malformed owner element")); + virReportError(VIR_ERR_XML_ERROR, + "%s", _("malformed owner element")); goto error; } perms->uid = (int)v; @@ -679,8 +679,8 @@ virStorageDefParsePerms(xmlXPathContextPtr ctxt, perms->gid = -1; } else { if (virXPathLong("number(./group)", ctxt, &v) < 0) { - virStorageReportError(VIR_ERR_XML_ERROR, - "%s", _("malformed group element")); + virReportError(VIR_ERR_XML_ERROR, + "%s", _("malformed group element")); goto error; } perms->gid = (int)v; @@ -711,8 +711,8 @@ virStoragePoolDefParseXML(xmlXPathContextPtr ctxt) { type = virXPathString("string(./@type)", ctxt); if ((ret->type = virStoragePoolTypeFromString((const char *)type)) < 0) { - virStorageReportError(VIR_ERR_INTERNAL_ERROR, - _("unknown storage pool type %s"), (const char*)type); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unknown storage pool type %s"), (const char*)type); goto cleanup; } @@ -735,22 +735,22 @@ virStoragePoolDefParseXML(xmlXPathContextPtr ctxt) { options->flags & VIR_STORAGE_POOL_SOURCE_NAME) ret->name = ret->source.name; if (ret->name == NULL) { - virStorageReportError(VIR_ERR_XML_ERROR, - "%s", _("missing pool source name element")); + virReportError(VIR_ERR_XML_ERROR, + "%s", _("missing pool source name element")); goto cleanup; } uuid = virXPathString("string(./uuid)", ctxt); if (uuid == NULL) { if (virUUIDGenerate(ret->uuid) < 0) { - virStorageReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("unable to generate uuid")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("unable to generate uuid")); goto cleanup; } } else { if (virUUIDParse(uuid, ret->uuid) < 0) { - virStorageReportError(VIR_ERR_XML_ERROR, - "%s", _("malformed uuid element")); + virReportError(VIR_ERR_XML_ERROR, + "%s", _("malformed uuid element")); goto cleanup; } VIR_FREE(uuid); @@ -758,17 +758,17 @@ virStoragePoolDefParseXML(xmlXPathContextPtr ctxt) { if (options->flags & VIR_STORAGE_POOL_SOURCE_HOST) { if (!ret->source.nhost) { - virStorageReportError(VIR_ERR_XML_ERROR, - "%s", - _("missing storage pool source host name")); + virReportError(VIR_ERR_XML_ERROR, + "%s", + _("missing storage pool source host name")); goto cleanup; } } if (options->flags & VIR_STORAGE_POOL_SOURCE_DIR) { if (!ret->source.dir) { - virStorageReportError(VIR_ERR_XML_ERROR, - "%s", _("missing storage pool source path")); + virReportError(VIR_ERR_XML_ERROR, + "%s", _("missing storage pool source path")); goto cleanup; } } @@ -785,8 +785,8 @@ virStoragePoolDefParseXML(xmlXPathContextPtr ctxt) { if (options->flags & VIR_STORAGE_POOL_SOURCE_ADAPTER) { if (!ret->source.adapter) { - virStorageReportError(VIR_ERR_XML_ERROR, - "%s", _("missing storage pool source adapter name")); + virReportError(VIR_ERR_XML_ERROR, + "%s", _("missing storage pool source adapter name")); goto cleanup; } } @@ -794,8 +794,8 @@ virStoragePoolDefParseXML(xmlXPathContextPtr ctxt) { /* If DEVICE is the only source type, then its required */ if (options->flags == VIR_STORAGE_POOL_SOURCE_DEVICE) { if (!ret->source.ndevice) { - virStorageReportError(VIR_ERR_XML_ERROR, - "%s", _("missing storage pool source device name")); + virReportError(VIR_ERR_XML_ERROR, + "%s", _("missing storage pool source device name")); goto cleanup; } } @@ -804,8 +804,8 @@ virStoragePoolDefParseXML(xmlXPathContextPtr ctxt) { * path and permissions */ if (!(options->flags & VIR_STORAGE_POOL_SOURCE_NETWORK)) { if ((tmppath = virXPathString("string(./target/path)", ctxt)) == NULL) { - virStorageReportError(VIR_ERR_XML_ERROR, - "%s", _("missing storage pool target path")); + virReportError(VIR_ERR_XML_ERROR, + "%s", _("missing storage pool target path")); goto cleanup; } ret->target.path = virFileSanitizePath(tmppath); @@ -835,8 +835,8 @@ virStoragePoolDefParseNode(xmlDocPtr xml, virStoragePoolDefPtr def = NULL; if (STRNEQ((const char *)root->name, "pool")) { - virStorageReportError(VIR_ERR_XML_ERROR, - "%s", _("unknown root element for storage pool")); + virReportError(VIR_ERR_XML_ERROR, + "%s", _("unknown root element for storage pool")); goto cleanup; } @@ -935,9 +935,9 @@ virStoragePoolSourceFormat(virBufferPtr buf, if (options->formatToString) { const char *format = (options->formatToString)(src->format); if (!format) { - virStorageReportError(VIR_ERR_INTERNAL_ERROR, - _("unknown pool format number %d"), - src->format); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unknown pool format number %d"), + src->format); return -1; } virBufferAsprintf(buf," <format type='%s'/>\n", format); @@ -994,8 +994,8 @@ virStoragePoolDefFormat(virStoragePoolDefPtr def) { type = virStoragePoolTypeToString(def->type); if (!type) { - virStorageReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("unexpected pool type")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("unexpected pool type")); goto cleanup; } virBufferAsprintf(&buf, "<pool type='%s'>\n", type); @@ -1058,8 +1058,8 @@ virStorageSize(const char *unit, unsigned long long *ret) { if (virStrToLong_ull(val, NULL, 10, ret) < 0) { - virStorageReportError(VIR_ERR_XML_ERROR, - "%s", _("malformed capacity element")); + virReportError(VIR_ERR_XML_ERROR, + "%s", _("malformed capacity element")); return -1; } /* off_t is signed, so you cannot create a file larger than 2**63 @@ -1091,8 +1091,8 @@ virStorageVolDefParseXML(virStoragePoolDefPtr pool, ret->name = virXPathString("string(./name)", ctxt); if (ret->name == NULL) { - virStorageReportError(VIR_ERR_XML_ERROR, - "%s", _("missing volume name element")); + virReportError(VIR_ERR_XML_ERROR, + "%s", _("missing volume name element")); goto cleanup; } @@ -1102,8 +1102,8 @@ virStorageVolDefParseXML(virStoragePoolDefPtr pool, capacity = virXPathString("string(./capacity)", ctxt); unit = virXPathString("string(./capacity/@unit)", ctxt); if (capacity == NULL) { - virStorageReportError(VIR_ERR_XML_ERROR, - "%s", _("missing capacity element")); + virReportError(VIR_ERR_XML_ERROR, + "%s", _("missing capacity element")); goto cleanup; } if (virStorageSize(unit, capacity, &ret->capacity) < 0) @@ -1131,8 +1131,8 @@ virStorageVolDefParseXML(virStoragePoolDefPtr pool, ret->target.format = (options->formatFromString)(format); if (ret->target.format < 0) { - virStorageReportError(VIR_ERR_XML_ERROR, - _("unknown volume format type %s"), format); + virReportError(VIR_ERR_XML_ERROR, + _("unknown volume format type %s"), format); VIR_FREE(format); goto cleanup; } @@ -1163,8 +1163,8 @@ virStorageVolDefParseXML(virStoragePoolDefPtr pool, ret->backingStore.format = (options->formatFromString)(format); if (ret->backingStore.format < 0) { - virStorageReportError(VIR_ERR_XML_ERROR, - _("unknown volume format type %s"), format); + virReportError(VIR_ERR_XML_ERROR, + _("unknown volume format type %s"), format); VIR_FREE(format); goto cleanup; } @@ -1194,8 +1194,8 @@ virStorageVolDefParseNode(virStoragePoolDefPtr pool, virStorageVolDefPtr def = NULL; if (STRNEQ((const char *)root->name, "volume")) { - virStorageReportError(VIR_ERR_XML_ERROR, - "%s", _("unknown root element for storage vol")); + virReportError(VIR_ERR_XML_ERROR, + "%s", _("unknown root element for storage vol")); goto cleanup; } @@ -1254,9 +1254,9 @@ virStorageVolTargetDefFormat(virStorageVolOptionsPtr options, if (options->formatToString) { const char *format = (options->formatToString)(def->format); if (!format) { - virStorageReportError(VIR_ERR_INTERNAL_ERROR, - _("unknown volume format number %d"), - def->format); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unknown volume format number %d"), + def->format); return -1; } virBufferAsprintf(buf," <format type='%s'/>\n", format); @@ -1471,8 +1471,8 @@ virStoragePoolObjAssignDef(virStoragePoolObjListPtr pools, } if (virMutexInit(&pool->lock) < 0) { - virStorageReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("cannot initialize mutex")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("cannot initialize mutex")); VIR_FREE(pool); return NULL; } @@ -1505,9 +1505,9 @@ virStoragePoolObjLoad(virStoragePoolObjListPtr pools, } if (!virFileMatchesNameSuffix(file, def->name, ".xml")) { - virStorageReportError(VIR_ERR_XML_ERROR, - _("Storage pool config filename '%s' does not match pool name '%s'"), - path, def->name); + virReportError(VIR_ERR_XML_ERROR, + _("Storage pool config filename '%s' does not match pool name '%s'"), + path, def->name); virStoragePoolDefFree(def); return NULL; } @@ -1617,8 +1617,8 @@ virStoragePoolObjSaveDef(virStorageDriverStatePtr driver, } if (!(xml = virStoragePoolDefFormat(def))) { - virStorageReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("failed to generate XML")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("failed to generate XML")); return -1; } @@ -1631,15 +1631,15 @@ virStoragePoolObjSaveDef(virStorageDriverStatePtr driver, int virStoragePoolObjDeleteDef(virStoragePoolObjPtr pool) { if (!pool->configFile) { - virStorageReportError(VIR_ERR_INTERNAL_ERROR, - _("no config file for %s"), pool->def->name); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("no config file for %s"), pool->def->name); return -1; } if (unlink(pool->configFile) < 0) { - virStorageReportError(VIR_ERR_INTERNAL_ERROR, - _("cannot remove config for %s"), - pool->def->name); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("cannot remove config for %s"), + pool->def->name); return -1; } @@ -1675,8 +1675,8 @@ char *virStoragePoolSourceListFormat(virStoragePoolSourceListPtr def) type = virStoragePoolTypeToString(def->type); if (!type) { - virStorageReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("unexpected pool type")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("unexpected pool type")); goto cleanup; } @@ -1726,18 +1726,18 @@ int virStoragePoolObjIsDuplicate(virStoragePoolObjListPtr pools, if (STRNEQ(pool->def->name, def->name)) { char uuidstr[VIR_UUID_STRING_BUFLEN]; virUUIDFormat(pool->def->uuid, uuidstr); - virStorageReportError(VIR_ERR_OPERATION_FAILED, - _("pool '%s' is already defined with uuid %s"), - pool->def->name, uuidstr); + virReportError(VIR_ERR_OPERATION_FAILED, + _("pool '%s' is already defined with uuid %s"), + pool->def->name, uuidstr); goto cleanup; } if (check_active) { /* UUID & name match, but if Pool is already active, refuse it */ if (virStoragePoolObjIsActive(pool)) { - virStorageReportError(VIR_ERR_OPERATION_INVALID, - _("pool is already active as '%s'"), - pool->def->name); + virReportError(VIR_ERR_OPERATION_INVALID, + _("pool is already active as '%s'"), + pool->def->name); goto cleanup; } } @@ -1749,9 +1749,9 @@ int virStoragePoolObjIsDuplicate(virStoragePoolObjListPtr pools, if (pool) { char uuidstr[VIR_UUID_STRING_BUFLEN]; virUUIDFormat(pool->def->uuid, uuidstr); - virStorageReportError(VIR_ERR_OPERATION_FAILED, - _("pool '%s' already exists with uuid %s"), - def->name, uuidstr); + virReportError(VIR_ERR_OPERATION_FAILED, + _("pool '%s' already exists with uuid %s"), + def->name, uuidstr); goto cleanup; } } @@ -1831,9 +1831,9 @@ int virStoragePoolSourceFindDuplicate(virStoragePoolObjListPtr pools, } if (matchpool) { - virStorageReportError(VIR_ERR_OPERATION_FAILED, - _("Storage source conflict with pool: '%s'"), - matchpool->def->name); + virReportError(VIR_ERR_OPERATION_FAILED, + _("Storage source conflict with pool: '%s'"), + matchpool->def->name); ret = -1; } return ret; diff --git a/src/conf/storage_conf.h b/src/conf/storage_conf.h index 5733b57..6e63671 100644 --- a/src/conf/storage_conf.h +++ b/src/conf/storage_conf.h @@ -336,10 +336,6 @@ static inline int virStoragePoolObjIsActive(virStoragePoolObjPtr pool) { return pool->active; } -# define virStorageReportError(code, ...) \ - virReportErrorHelper(VIR_FROM_STORAGE, code, __FILE__, \ - __FUNCTION__, __LINE__, __VA_ARGS__) - int virStoragePoolLoadAllConfigs(virStoragePoolObjListPtr pools, const char *configDir, const char *autostartDir); diff --git a/src/conf/storage_encryption_conf.c b/src/conf/storage_encryption_conf.c index 3208333..63cb7f4 100644 --- a/src/conf/storage_encryption_conf.c +++ b/src/conf/storage_encryption_conf.c @@ -88,15 +88,15 @@ virStorageEncryptionSecretParse(xmlXPathContextPtr ctxt, type_str = virXPathString("string(./@type)", ctxt); if (type_str == NULL) { - virStorageReportError(VIR_ERR_XML_ERROR, "%s", - _("unknown volume encryption secret type")); + virReportError(VIR_ERR_XML_ERROR, "%s", + _("unknown volume encryption secret type")); goto cleanup; } type = virStorageEncryptionSecretTypeTypeFromString(type_str); if (type < 0) { - virStorageReportError(VIR_ERR_XML_ERROR, - _("unknown volume encryption secret type %s"), - type_str); + virReportError(VIR_ERR_XML_ERROR, + _("unknown volume encryption secret type %s"), + type_str); VIR_FREE(type_str); goto cleanup; } @@ -106,15 +106,15 @@ virStorageEncryptionSecretParse(xmlXPathContextPtr ctxt, uuidstr = virXPathString("string(./@uuid)", ctxt); if (uuidstr) { if (virUUIDParse(uuidstr, ret->uuid) < 0) { - virStorageReportError(VIR_ERR_XML_ERROR, - _("malformed volume encryption uuid '%s'"), - uuidstr); + virReportError(VIR_ERR_XML_ERROR, + _("malformed volume encryption uuid '%s'"), + uuidstr); goto cleanup; } VIR_FREE(uuidstr); } else { - virStorageReportError(VIR_ERR_XML_ERROR, "%s", - _("missing volume encryption uuid")); + virReportError(VIR_ERR_XML_ERROR, "%s", + _("missing volume encryption uuid")); goto cleanup; } ctxt->node = old_node; @@ -142,15 +142,15 @@ virStorageEncryptionParseXML(xmlXPathContextPtr ctxt) format_str = virXPathString("string(./@format)", ctxt); if (format_str == NULL) { - virStorageReportError(VIR_ERR_XML_ERROR, "%s", - _("unknown volume encryption format")); + virReportError(VIR_ERR_XML_ERROR, "%s", + _("unknown volume encryption format")); goto cleanup; } format = virStorageEncryptionFormatTypeFromString(format_str); if (format < 0) { - virStorageReportError(VIR_ERR_XML_ERROR, - _("unknown volume encryption format type %s"), - format_str); + virReportError(VIR_ERR_XML_ERROR, + _("unknown volume encryption format type %s"), + format_str); VIR_FREE(format_str); goto cleanup; } @@ -188,9 +188,9 @@ virStorageEncryptionParseNode(xmlDocPtr xml, xmlNodePtr root) virStorageEncryptionPtr enc = NULL; if (STRNEQ((const char *) root->name, "encryption")) { - virStorageReportError(VIR_ERR_XML_ERROR, - "%s", _("unknown root element for volume " - "encryption information")); + virReportError(VIR_ERR_XML_ERROR, + "%s", _("unknown root element for volume " + "encryption information")); goto cleanup; } @@ -218,8 +218,8 @@ virStorageEncryptionSecretFormat(virBufferPtr buf, type = virStorageEncryptionSecretTypeTypeToString(secret->type); if (!type) { - virStorageReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("unexpected volume encryption secret type")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("unexpected volume encryption secret type")); return -1; } @@ -238,8 +238,8 @@ virStorageEncryptionFormat(virBufferPtr buf, format = virStorageEncryptionFormatTypeToString(enc->format); if (!format) { - virStorageReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("unexpected encryption format")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("unexpected encryption format")); return -1; } virBufferAsprintf(buf, "<encryption format='%s'>\n", format); @@ -265,8 +265,8 @@ virStorageGenerateQcowPassphrase(unsigned char *dest) unpleasant surprises with the qemu monitor input mechanism. */ fd = open("/dev/urandom", O_RDONLY); if (fd < 0) { - virStorageReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Cannot open /dev/urandom")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Cannot open /dev/urandom")); return -1; } i = 0; @@ -276,8 +276,8 @@ virStorageGenerateQcowPassphrase(unsigned char *dest) while ((r = read(fd, dest + i, 1)) == -1 && errno == EINTR) ; if (r <= 0) { - virStorageReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Cannot read from /dev/urandom")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Cannot read from /dev/urandom")); VIR_FORCE_CLOSE(fd); return -1; } diff --git a/src/conf/virconsole.c b/src/conf/virconsole.c index 443d80d..fe47039 100644 --- a/src/conf/virconsole.c +++ b/src/conf/virconsole.c @@ -39,9 +39,6 @@ #include "virfile.h" #define VIR_FROM_THIS VIR_FROM_NONE -#define virConsoleError(code, ...) \ - virReportErrorHelper(VIR_FROM_THIS, code, __FILE__, \ - __FUNCTION__, __LINE__, __VA_ARGS__) /* structure holding information about consoles * open in a given domain */ @@ -127,10 +124,10 @@ static int virConsoleLockFileCreate(const char *pty) /* check if a log file and process holding the lock still exists */ if (virPidFileReadPathIfAlive(path, &pid, NULL) == 0 && pid >= 0) { /* the process exists, the lockfile is valid */ - virConsoleError(VIR_ERR_OPERATION_FAILED, - _("Requested console pty '%s' is locked by " - "lock file '%s' held by process %lld"), - pty, path, (long long) pid); + virReportError(VIR_ERR_OPERATION_FAILED, + _("Requested console pty '%s' is locked by " + "lock file '%s' held by process %lld"), + pty, path, (long long) pid); goto cleanup; } else { /* clean up the stale/corrupted/nonexistent lockfile */ diff --git a/src/node_device/node_device_driver.h b/src/node_device/node_device_driver.h index 673e95b..c94e870 100644 --- a/src/node_device/node_device_driver.h +++ b/src/node_device/node_device_driver.h @@ -28,6 +28,10 @@ # include "driver.h" # include "node_device_conf.h" +# define virNodeDeviceReportError(code, ...) \ + virReportErrorHelper(VIR_FROM_NODEDEV, code, __FILE__, \ + __FUNCTION__, __LINE__, __VA_ARGS__) + # define LINUX_SYSFS_SCSI_HOST_PREFIX "/sys/class/scsi_host/" # define LINUX_SYSFS_SCSI_HOST_POSTFIX "device" # define LINUX_SYSFS_FC_HOST_PREFIX "/sys/class/fc_host/" diff --git a/src/nwfilter/nwfilter_dhcpsnoop.c b/src/nwfilter/nwfilter_dhcpsnoop.c index b38e780..db367e1 100644 --- a/src/nwfilter/nwfilter_dhcpsnoop.c +++ b/src/nwfilter/nwfilter_dhcpsnoop.c @@ -69,6 +69,10 @@ #define VIR_FROM_THIS VIR_FROM_NWFILTER +#define virNWFilterReportError(code, fmt...) \ + virReportErrorHelper(VIR_FROM_NWFILTER, code, __FILE__, \ + __FUNCTION__, __LINE__, fmt) + #ifdef HAVE_LIBPCAP # define LEASEFILE LOCALSTATEDIR "/run/libvirt/network/nwfilter.leases" diff --git a/src/nwfilter/nwfilter_driver.c b/src/nwfilter/nwfilter_driver.c index e24cd26..52560b7 100644 --- a/src/nwfilter/nwfilter_driver.c +++ b/src/nwfilter/nwfilter_driver.c @@ -44,6 +44,9 @@ #include "nwfilter_learnipaddr.h" #define VIR_FROM_THIS VIR_FROM_NWFILTER +#define virNWFilterReportError(code, fmt...) \ + virReportErrorHelper(VIR_FROM_NWFILTER, code, __FILE__, \ + __FUNCTION__, __LINE__, fmt) static virNWFilterDriverStatePtr driverState; diff --git a/src/nwfilter/nwfilter_ebiptables_driver.c b/src/nwfilter/nwfilter_ebiptables_driver.c index 3ef627d..cbf6d14 100644 --- a/src/nwfilter/nwfilter_ebiptables_driver.c +++ b/src/nwfilter/nwfilter_ebiptables_driver.c @@ -45,7 +45,9 @@ #define VIR_FROM_THIS VIR_FROM_NWFILTER - +#define virNWFilterReportError(code, fmt...) \ + virReportErrorHelper(VIR_FROM_NWFILTER, code, __FILE__, \ + __FUNCTION__, __LINE__, fmt) #define EBTABLES_CHAIN_INCOMING "PREROUTING" #define EBTABLES_CHAIN_OUTGOING "POSTROUTING" diff --git a/src/nwfilter/nwfilter_gentech_driver.c b/src/nwfilter/nwfilter_gentech_driver.c index 0dd1aa2..fb13fbe 100644 --- a/src/nwfilter/nwfilter_gentech_driver.c +++ b/src/nwfilter/nwfilter_gentech_driver.c @@ -39,6 +39,9 @@ #include "datatypes.h" #define VIR_FROM_THIS VIR_FROM_NWFILTER +#define virNWFilterReportError(code, fmt...) \ + virReportErrorHelper(VIR_FROM_NWFILTER, code, __FILE__, \ + __FUNCTION__, __LINE__, fmt) #define NWFILTER_STD_VAR_MAC NWFILTER_VARNAME_MAC diff --git a/src/nwfilter/nwfilter_learnipaddr.c b/src/nwfilter/nwfilter_learnipaddr.c index a04057f..d5005eb 100644 --- a/src/nwfilter/nwfilter_learnipaddr.c +++ b/src/nwfilter/nwfilter_learnipaddr.c @@ -56,6 +56,9 @@ #include "nwfilter_learnipaddr.h" #define VIR_FROM_THIS VIR_FROM_NWFILTER +#define virNWFilterReportError(code, fmt...) \ + virReportErrorHelper(VIR_FROM_NWFILTER, code, __FILE__, \ + __FUNCTION__, __LINE__, fmt) #define IFINDEX2STR(VARNAME, ifindex) \ char VARNAME[INT_BUFSIZE_BOUND(ifindex)]; \ diff --git a/src/secret/secret_driver.c b/src/secret/secret_driver.c index 49ca29b..cf2315a 100644 --- a/src/secret/secret_driver.c +++ b/src/secret/secret_driver.c @@ -45,6 +45,10 @@ #define VIR_FROM_THIS VIR_FROM_SECRET +#define virSecretReportError(code, ...) \ + virReportErrorHelper(VIR_FROM_SECRET, code, __FILE__, \ + __FUNCTION__, __LINE__, __VA_ARGS__) + enum { SECRET_MAX_XML_FILE = 10*1024*1024 }; /* Internal driver state */ diff --git a/src/storage/storage_backend.h b/src/storage/storage_backend.h index 4c371fb..66a2d78 100644 --- a/src/storage/storage_backend.h +++ b/src/storage/storage_backend.h @@ -29,6 +29,10 @@ # include "storage_conf.h" # include "command.h" +# define virStorageReportError(code, ...) \ + virReportErrorHelper(VIR_FROM_STORAGE, code, __FILE__, \ + __FUNCTION__, __LINE__, __VA_ARGS__) + typedef char * (*virStorageBackendFindPoolSources)(virConnectPtr conn, const char *srcSpec, unsigned int flags); typedef int (*virStorageBackendCheckPool)(virConnectPtr conn, virStoragePoolObjPtr pool, bool *active); typedef int (*virStorageBackendStartPool)(virConnectPtr conn, virStoragePoolObjPtr pool); diff --git a/src/test/test_driver.c b/src/test/test_driver.c index b3b774d..f38a5c8 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -5129,7 +5129,7 @@ testNodeDeviceLookupByName(virConnectPtr conn, const char *name) testDriverUnlock(driver); if (!obj) { - virNodeDeviceReportError(VIR_ERR_NO_NODE_DEVICE, NULL); + testError(VIR_ERR_NO_NODE_DEVICE, NULL); goto cleanup; } @@ -5156,9 +5156,9 @@ testNodeDeviceGetXMLDesc(virNodeDevicePtr dev, testDriverUnlock(driver); if (!obj) { - virNodeDeviceReportError(VIR_ERR_NO_NODE_DEVICE, - _("no node device with matching name '%s'"), - dev->name); + testError(VIR_ERR_NO_NODE_DEVICE, + _("no node device with matching name '%s'"), + dev->name); goto cleanup; } @@ -5182,9 +5182,9 @@ testNodeDeviceGetParent(virNodeDevicePtr dev) testDriverUnlock(driver); if (!obj) { - virNodeDeviceReportError(VIR_ERR_NO_NODE_DEVICE, - _("no node device with matching name '%s'"), - dev->name); + testError(VIR_ERR_NO_NODE_DEVICE, + _("no node device with matching name '%s'"), + dev->name); goto cleanup; } @@ -5193,8 +5193,8 @@ testNodeDeviceGetParent(virNodeDevicePtr dev) if (!ret) virReportOOMError(); } else { - virNodeDeviceReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("no parent for this device")); + testError(VIR_ERR_INTERNAL_ERROR, + "%s", _("no parent for this device")); } cleanup: @@ -5218,9 +5218,9 @@ testNodeDeviceNumOfCaps(virNodeDevicePtr dev) testDriverUnlock(driver); if (!obj) { - virNodeDeviceReportError(VIR_ERR_NO_NODE_DEVICE, - _("no node device with matching name '%s'"), - dev->name); + testError(VIR_ERR_NO_NODE_DEVICE, + _("no node device with matching name '%s'"), + dev->name); goto cleanup; } @@ -5249,9 +5249,9 @@ testNodeDeviceListCaps(virNodeDevicePtr dev, char **const names, int maxnames) testDriverUnlock(driver); if (!obj) { - virNodeDeviceReportError(VIR_ERR_NO_NODE_DEVICE, - _("no node device with matching name '%s'"), - dev->name); + testError(VIR_ERR_NO_NODE_DEVICE, + _("no node device with matching name '%s'"), + dev->name); goto cleanup; } @@ -5356,7 +5356,7 @@ testNodeDeviceDestroy(virNodeDevicePtr dev) testDriverUnlock(driver); if (!obj) { - virNodeDeviceReportError(VIR_ERR_NO_NODE_DEVICE, NULL); + testError(VIR_ERR_NO_NODE_DEVICE, NULL); goto out; } -- 1.7.10.4

On 07/18/2012 05:52 AM, Daniel P. Berrange wrote:
From: "Daniel P. Berrange" <berrange@redhat.com>
This rmoves all the per-file error reporting macros
s/rmoves/removes/
from the code in src/conf/
Signed-off-by: Daniel P. Berrange <berrange@redhat.com> --- 28 files changed, 1912 insertions(+), 1927 deletions(-)
Eep, that's big, so I'm assuming it's mostly mechanical. But I didn't spot anything obviously wrong while skimming through this message, other than the typo in the commit log. ACK.
+++ b/src/nwfilter/nwfilter_dhcpsnoop.c @@ -69,6 +69,10 @@
#define VIR_FROM_THIS VIR_FROM_NWFILTER
+#define virNWFilterReportError(code, fmt...) \ + virReportErrorHelper(VIR_FROM_NWFILTER, code, __FILE__, \ + __FUNCTION__, __LINE__, fmt) + #ifdef HAVE_LIBPCAP
# define LEASEFILE LOCALSTATEDIR "/run/libvirt/network/nwfilter.leases"
I first thought "What for?" when I saw this; then I realized - you removed it out of the .h, but as this is src/nwfilter and not src/conf, you had to (temporarily) re-add it here in the .c to keep things compiling, and a later patch will again nuke it. Nothing to see here, move on...
+++ b/src/test/test_driver.c @@ -5129,7 +5129,7 @@ testNodeDeviceLookupByName(virConnectPtr conn, const char *name) testDriverUnlock(driver);
if (!obj) { - virNodeDeviceReportError(VIR_ERR_NO_NODE_DEVICE, NULL); + testError(VIR_ERR_NO_NODE_DEVICE, NULL);
Even more fun - we were using the wrong error (thanks to the .h pollution), but will still touch this line again in later patches. -- Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

From: "Daniel P. Berrange" <berrange@redhat.com> Update the storage driver to use virReportError instead of the virStorageReportError custom macro Signed-off-by: Daniel P. Berrange <berrange@redhat.com> --- cfg.mk | 1 - src/storage/storage_backend.c | 133 ++++++------ src/storage/storage_backend.h | 4 - src/storage/storage_backend_disk.c | 66 +++--- src/storage/storage_backend_fs.c | 162 +++++++------- src/storage/storage_backend_iscsi.c | 94 ++++---- src/storage/storage_backend_logical.c | 40 ++-- src/storage/storage_backend_mpath.c | 6 +- src/storage/storage_backend_rbd.c | 132 +++++------ src/storage/storage_backend_scsi.c | 24 +- src/storage/storage_driver.c | 386 ++++++++++++++++----------------- 11 files changed, 522 insertions(+), 526 deletions(-) diff --git a/cfg.mk b/cfg.mk index 0f62a89..3363aa2 100644 --- a/cfg.mk +++ b/cfg.mk @@ -549,7 +549,6 @@ msg_gen_function += virReportErrorHelper msg_gen_function += virReportSystemError msg_gen_function += virSecretReportError msg_gen_function += virSecurityReportError -msg_gen_function += virStorageReportError msg_gen_function += virXenInotifyError msg_gen_function += virXenStoreError msg_gen_function += virXendError diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c index 6ea0881..0c17aea 100644 --- a/src/storage/storage_backend.c +++ b/src/storage/storage_backend.c @@ -385,9 +385,9 @@ virStorageBackendCreateRaw(virConnectPtr conn ATTRIBUTE_UNUSED, virCheckFlags(0, -1); if (vol->target.encryption != NULL) { - virStorageReportError(VIR_ERR_CONFIG_UNSUPPORTED, - "%s", _("storage pool does not support encrypted " - "volumes")); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + "%s", _("storage pool does not support encrypted " + "volumes")); goto cleanup; } @@ -425,8 +425,8 @@ virStorageGenerateSecretUUID(virConnectPtr conn, for (attempt = 0; attempt < 65536; attempt++) { virSecretPtr tmp; if (virUUIDGenerate(uuid) < 0) { - virStorageReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("unable to generate uuid")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("unable to generate uuid")); return -1; } tmp = conn->secretDriver->lookupByUUID(conn, uuid); @@ -436,8 +436,8 @@ virStorageGenerateSecretUUID(virConnectPtr conn, virSecretFree(tmp); } - virStorageReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("too many conflicts when generating an uuid")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("too many conflicts when generating an uuid")); return -1; } @@ -459,15 +459,15 @@ virStorageGenerateQcowEncryption(virConnectPtr conn, conn->secretDriver->lookupByUUID == NULL || conn->secretDriver->defineXML == NULL || conn->secretDriver->setValue == NULL) { - virStorageReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("secret storage not supported")); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("secret storage not supported")); goto cleanup; } enc = vol->target.encryption; if (enc->nsecrets != 0) { - virStorageReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("secrets already defined")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("secrets already defined")); goto cleanup; } @@ -631,9 +631,9 @@ static int virStorageBackendQEMUImgBackingFormat(const char *qemuimg) if ((start = strstr(help, " create ")) == NULL || (end = strstr(start, "\n")) == NULL) { - virStorageReportError(VIR_ERR_INTERNAL_ERROR, - _("unable to parse qemu-img output '%s'"), - help); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unable to parse qemu-img output '%s'"), + help); goto cleanup; } if (((tmp = strstr(start, "-F fmt")) && tmp < end) || @@ -682,15 +682,15 @@ virStorageBackendCreateQemuImg(virConnectPtr conn, NULL; if (type == NULL) { - virStorageReportError(VIR_ERR_INTERNAL_ERROR, - _("unknown storage vol type %d"), - vol->target.format); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unknown storage vol type %d"), + vol->target.format); return -1; } if (inputvol && inputType == NULL) { - virStorageReportError(VIR_ERR_INTERNAL_ERROR, - _("unknown storage vol type %d"), - inputvol->target.format); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unknown storage vol type %d"), + inputvol->target.format); return -1; } @@ -705,16 +705,16 @@ virStorageBackendCreateQemuImg(virConnectPtr conn, if (inputvol && (!inputBackingPath || STRNEQ(inputBackingPath, vol->backingStore.path))) { - virStorageReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("a different backing store cannot " - "be specified.")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("a different backing store cannot " + "be specified.")); return -1; } if (backingType == NULL) { - virStorageReportError(VIR_ERR_INTERNAL_ERROR, - _("unknown storage vol backing store type %d"), - vol->backingStore.format); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unknown storage vol backing store type %d"), + vol->backingStore.format); return -1; } @@ -743,22 +743,22 @@ virStorageBackendCreateQemuImg(virConnectPtr conn, if (vol->target.format != VIR_STORAGE_FILE_QCOW && vol->target.format != VIR_STORAGE_FILE_QCOW2) { - virStorageReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("qcow volume encryption unsupported with " - "volume format %s"), type); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("qcow volume encryption unsupported with " + "volume format %s"), type); return -1; } enc = vol->target.encryption; if (enc->format != VIR_STORAGE_ENCRYPTION_FORMAT_QCOW && enc->format != VIR_STORAGE_ENCRYPTION_FORMAT_DEFAULT) { - virStorageReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unsupported volume encryption format %d"), - vol->target.encryption->format); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unsupported volume encryption format %d"), + vol->target.encryption->format); return -1; } if (enc->nsecrets > 1) { - virStorageReportError(VIR_ERR_XML_ERROR, "%s", - _("too many secrets for qcow encryption")); + virReportError(VIR_ERR_XML_ERROR, "%s", + _("too many secrets for qcow encryption")); return -1; } if (enc->format == VIR_STORAGE_ENCRYPTION_FORMAT_DEFAULT || @@ -777,8 +777,8 @@ virStorageBackendCreateQemuImg(virConnectPtr conn, create_tool = virFindFileInPath("qemu-img"); if (!create_tool) { - virStorageReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("unable to find kvm-img or qemu-img")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("unable to find kvm-img or qemu-img")); return -1; } @@ -871,27 +871,27 @@ virStorageBackendCreateQcowCreate(virConnectPtr conn ATTRIBUTE_UNUSED, virCheckFlags(0, -1); if (inputvol) { - virStorageReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("cannot copy from volume with qcow-create")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("cannot copy from volume with qcow-create")); return -1; } if (vol->target.format != VIR_STORAGE_FILE_QCOW2) { - virStorageReportError(VIR_ERR_INTERNAL_ERROR, - _("unsupported storage vol type %d"), - vol->target.format); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unsupported storage vol type %d"), + vol->target.format); return -1; } if (vol->backingStore.path != NULL) { - virStorageReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("copy-on-write image not supported with " - "qcow-create")); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("copy-on-write image not supported with " + "qcow-create")); return -1; } if (vol->target.encryption != NULL) { - virStorageReportError(VIR_ERR_CONFIG_UNSUPPORTED, - "%s", _("encrypted volumes not supported with " - "qcow-create")); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + "%s", _("encrypted volumes not supported with " + "qcow-create")); return -1; } @@ -921,9 +921,9 @@ virStorageBackendFSImageToolTypeToFunc(int tool_type) case TOOL_QCOW_CREATE: return virStorageBackendCreateQcowCreate; default: - virStorageReportError(VIR_ERR_INTERNAL_ERROR, - _("Unknown file create tool type '%d'."), - tool_type); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Unknown file create tool type '%d'."), + tool_type); } return NULL; @@ -969,9 +969,9 @@ virStorageBackendGetBuildVolFromFunction(virStorageVolDefPtr vol, inputvol->target.format != VIR_STORAGE_FILE_RAW)) { if ((tool_type = virStorageBackendFindFSImageTool(NULL)) < 0) { - virStorageReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("creation of non-raw file images is " - "not supported without qemu-img.")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("creation of non-raw file images is " + "not supported without qemu-img.")); return NULL; } @@ -992,8 +992,8 @@ virStorageBackendForType(int type) { if (backends[i]->type == type) return backends[i]; - virStorageReportError(VIR_ERR_INTERNAL_ERROR, - _("missing backend for pool type %d"), type); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("missing backend for pool type %d"), type); return NULL; } @@ -1069,8 +1069,8 @@ virStorageBackendVolOpenCheckMode(const char *path, unsigned int flags) VIR_INFO("Skipping volume '%s'", path); if (mode & VIR_STORAGE_VOL_OPEN_ERROR) { - virStorageReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected storage mode for '%s'"), path); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected storage mode for '%s'"), path); return -1; } @@ -1444,8 +1444,8 @@ virStorageBackendRunProgRegex(virStoragePoolObjPtr pool, if (err != 0) { char error[100]; regerror(err, ®[i], error, sizeof(error)); - virStorageReportError(VIR_ERR_INTERNAL_ERROR, - _("Failed to compile regex %s"), error); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Failed to compile regex %s"), error); for (j = 0 ; j <= i ; j++) regfree(®[j]); VIR_FREE(reg); @@ -1474,8 +1474,8 @@ virStorageBackendRunProgRegex(virStoragePoolObjPtr pool, } if ((list = VIR_FDOPEN(fd, "r")) == NULL) { - virStorageReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("cannot read fd")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("cannot read fd")); goto cleanup; } @@ -1586,8 +1586,8 @@ virStorageBackendRunProgNul(virStoragePoolObjPtr pool, } if ((fp = VIR_FDOPEN(fd, "r")) == NULL) { - virStorageReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("cannot open file using fd")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("cannot open file using fd")); goto cleanup; } @@ -1646,8 +1646,8 @@ virStorageBackendRunProgRegex(virConnectPtr conn, virStorageBackendListVolRegexFunc func ATTRIBUTE_UNUSED, void *data ATTRIBUTE_UNUSED) { - virStorageReportError(VIR_ERR_INTERNAL_ERROR, - _("%s not implemented on Win32"), __FUNCTION__); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("%s not implemented on Win32"), __FUNCTION__); return -1; } @@ -1659,7 +1659,8 @@ virStorageBackendRunProgNul(virConnectPtr conn, virStorageBackendListVolNulFunc func ATTRIBUTE_UNUSED, void *data ATTRIBUTE_UNUSED) { - virStorageReportError(VIR_ERR_INTERNAL_ERROR, _("%s not implemented on Win32"), __FUNCTION__); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("%s not implemented on Win32"), __FUNCTION__); return -1; } #endif /* WIN32 */ diff --git a/src/storage/storage_backend.h b/src/storage/storage_backend.h index 66a2d78..4c371fb 100644 --- a/src/storage/storage_backend.h +++ b/src/storage/storage_backend.h @@ -29,10 +29,6 @@ # include "storage_conf.h" # include "command.h" -# define virStorageReportError(code, ...) \ - virReportErrorHelper(VIR_FROM_STORAGE, code, __FILE__, \ - __FUNCTION__, __LINE__, __VA_ARGS__) - typedef char * (*virStorageBackendFindPoolSources)(virConnectPtr conn, const char *srcSpec, unsigned int flags); typedef int (*virStorageBackendCheckPool)(virConnectPtr conn, virStoragePoolObjPtr pool, bool *active); typedef int (*virStorageBackendStartPool)(virConnectPtr conn, virStoragePoolObjPtr pool); diff --git a/src/storage/storage_backend_disk.c b/src/storage/storage_backend_disk.c index ecc51fd..75d2927 100644 --- a/src/storage/storage_backend_disk.c +++ b/src/storage/storage_backend_disk.c @@ -106,15 +106,15 @@ virStorageBackendDiskMakeDataVol(virStoragePoolObjPtr pool, if (virStrToLong_ull(groups[3], NULL, 10, &vol->source.extents[0].start) < 0) { - virStorageReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("cannot parse device start location")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("cannot parse device start location")); return -1; } if (virStrToLong_ull(groups[4], NULL, 10, &vol->source.extents[0].end) < 0) { - virStorageReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("cannot parse device end location")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("cannot parse device end location")); return -1; } @@ -327,9 +327,9 @@ virStorageBackendDiskRefreshPool(virConnectPtr conn ATTRIBUTE_UNUSED, virFileWaitForDevices(); if (!virFileExists(pool->def->source.devices[0].path)) { - virStorageReportError(VIR_ERR_INVALID_ARG, - _("device path '%s' doesn't exist"), - pool->def->source.devices[0].path); + virReportError(VIR_ERR_INVALID_ARG, + _("device path '%s' doesn't exist"), + pool->def->source.devices[0].path); return -1; } @@ -399,9 +399,9 @@ virStorageBackendDiskBuildPool(virConnectPtr conn ATTRIBUTE_UNUSED, if (flags == (VIR_STORAGE_POOL_BUILD_OVERWRITE | VIR_STORAGE_POOL_BUILD_NO_OVERWRITE)) { - virStorageReportError(VIR_ERR_OPERATION_INVALID, - _("Overwrite and no overwrite flags" - " are mutually exclusive")); + virReportError(VIR_ERR_OPERATION_INVALID, + _("Overwrite and no overwrite flags" + " are mutually exclusive")); goto error; } @@ -415,11 +415,11 @@ virStorageBackendDiskBuildPool(virConnectPtr conn ATTRIBUTE_UNUSED, if (check > 0) { ok_to_mklabel = true; } else if (check < 0) { - virStorageReportError(VIR_ERR_OPERATION_FAILED, - _("Error checking for disk label")); + virReportError(VIR_ERR_OPERATION_FAILED, + _("Error checking for disk label")); } else { - virStorageReportError(VIR_ERR_OPERATION_INVALID, - _("Disk label already present")); + virReportError(VIR_ERR_OPERATION_INVALID, + _("Disk label already present")); } } @@ -468,8 +468,8 @@ virStorageBackendDiskPartFormat(virStoragePoolObjPtr pool, const char *partedFormat; partedFormat = virStoragePartedFsTypeTypeToString(vol->target.format); if (partedFormat == NULL) { - virStorageReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("Invalid partition type")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("Invalid partition type")); return -1; } if (vol->target.format == VIR_STORAGE_VOL_DISK_EXTENDED) { @@ -477,8 +477,8 @@ virStorageBackendDiskPartFormat(virStoragePoolObjPtr pool, for (i = 0; i < pool->volumes.count; i++) { if (pool->volumes.objs[i]->target.format == VIR_STORAGE_VOL_DISK_EXTENDED) { - virStorageReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("extended partition already exists")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("extended partition already exists")); return -1; } } @@ -512,14 +512,14 @@ virStorageBackendDiskPartFormat(virStoragePoolObjPtr pool, } } if (i == pool->volumes.count) { - virStorageReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("no extended partition found and no primary partition available")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("no extended partition found and no primary partition available")); return -1; } break; default: - virStorageReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("unknown partition type")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("unknown partition type")); return -1; } } @@ -602,8 +602,8 @@ virStorageBackendDiskPartBoundries(virStoragePoolObjPtr pool, } if (smallestExtent == -1) { - virStorageReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("no large enough free extent")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("no large enough free extent")); return -1; } @@ -643,9 +643,9 @@ virStorageBackendDiskCreateVol(virConnectPtr conn ATTRIBUTE_UNUSED, NULL); if (vol->target.encryption != NULL) { - virStorageReportError(VIR_ERR_CONFIG_UNSUPPORTED, - "%s", _("storage pool does not support encrypted " - "volumes")); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + "%s", _("storage pool does not support encrypted " + "volumes")); return -1; } @@ -733,9 +733,9 @@ virStorageBackendDiskDeleteVol(virConnectPtr conn ATTRIBUTE_UNUSED, isDevMapperDevice = virIsDevMapperDevice(devpath); if (!isDevMapperDevice && !STRPREFIX(dev_name, srcname)) { - virStorageReportError(VIR_ERR_INTERNAL_ERROR, - _("Volume path '%s' did not start with parent " - "pool source device name."), dev_name); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Volume path '%s' did not start with parent " + "pool source device name."), dev_name); goto cleanup; } @@ -743,9 +743,9 @@ virStorageBackendDiskDeleteVol(virConnectPtr conn ATTRIBUTE_UNUSED, part_num = dev_name + strlen(srcname); if (*part_num == 0) { - virStorageReportError(VIR_ERR_INTERNAL_ERROR, - _("cannot parse partition number from target " - "'%s'"), dev_name); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("cannot parse partition number from target " + "'%s'"), dev_name); goto cleanup; } diff --git a/src/storage/storage_backend_fs.c b/src/storage/storage_backend_fs.c index b318f38..8da985e 100644 --- a/src/storage/storage_backend_fs.c +++ b/src/storage/storage_backend_fs.c @@ -113,9 +113,9 @@ virStorageBackendProbeTarget(virStorageVolTargetPtr target, /* If the backing file is currently unavailable, only log an error, * but continue. Returning -1 here would disable the whole storage * pool, making it unavailable for even maintenance. */ - virStorageReportError(VIR_ERR_INTERNAL_ERROR, - _("cannot probe backing volume format: %s"), - *backingStore); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("cannot probe backing volume format: %s"), + *backingStore); ret = -3; } else { *backingStoreFormat = ret; @@ -191,14 +191,14 @@ virStorageBackendFileSystemNetFindPoolSourcesFunc(virStoragePoolObjPtr pool ATTR path = groups[0]; if (!(name = strrchr(path, '/'))) { - virStorageReportError(VIR_ERR_INTERNAL_ERROR, - _("invalid netfs path (no /): %s"), path); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("invalid netfs path (no /): %s"), path); goto cleanup; } name += 1; if (*name == '\0') { - virStorageReportError(VIR_ERR_INTERNAL_ERROR, - _("invalid netfs path (ends in /): %s"), path); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("invalid netfs path (ends in /): %s"), path); goto cleanup; } @@ -264,8 +264,8 @@ virStorageBackendFileSystemNetFindPoolSources(virConnectPtr conn ATTRIBUTE_UNUSE goto cleanup; if (source->nhost != 1) { - virStorageReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("Expected exactly 1 host for the storage pool")); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Expected exactly 1 host for the storage pool")); goto cleanup; } @@ -355,33 +355,33 @@ virStorageBackendFileSystemMount(virStoragePoolObjPtr pool) { if (pool->def->type == VIR_STORAGE_POOL_NETFS) { if (pool->def->source.nhost != 1) { - virStorageReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("Expected exactly 1 host for the storage pool")); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Expected exactly 1 host for the storage pool")); return -1; } if (pool->def->source.hosts[0].name == NULL) { - virStorageReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("missing source host")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("missing source host")); return -1; } if (pool->def->source.dir == NULL) { - virStorageReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("missing source path")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("missing source path")); return -1; } } else { if (pool->def->source.ndevice != 1) { - virStorageReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("missing source device")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("missing source device")); return -1; } } /* Short-circuit if already mounted */ if ((ret = virStorageBackendFileSystemIsMounted(pool)) != 0) { - virStorageReportError(VIR_ERR_OPERATION_INVALID, - _("Target '%s' is already mounted"), - pool->def->target.path); + virReportError(VIR_ERR_OPERATION_INVALID, + _("Target '%s' is already mounted"), + pool->def->target.path); return -1; } @@ -452,24 +452,24 @@ virStorageBackendFileSystemUnmount(virStoragePoolObjPtr pool) { if (pool->def->type == VIR_STORAGE_POOL_NETFS) { if (pool->def->source.nhost != 1) { - virStorageReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("Expected exactly 1 host for the storage pool")); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Expected exactly 1 host for the storage pool")); return -1; } if (pool->def->source.hosts[0].name == NULL) { - virStorageReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("missing source host")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("missing source host")); return -1; } if (pool->def->source.dir == NULL) { - virStorageReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("missing source dir")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("missing source dir")); return -1; } } else { if (pool->def->source.ndevice != 1) { - virStorageReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("missing source device")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("missing source device")); return -1; } } @@ -557,19 +557,19 @@ virStorageBackendFileSystemProbe(const char *device, format, device); if (blkid_known_fstype(format) == 0) { - virStorageReportError(VIR_ERR_STORAGE_PROBE_FAILED, - _("Not capable of probing for " - "filesystem of type %s"), - format); + virReportError(VIR_ERR_STORAGE_PROBE_FAILED, + _("Not capable of probing for " + "filesystem of type %s"), + format); goto error; } probe = blkid_new_probe_from_filename(device); if (probe == NULL) { - virStorageReportError(VIR_ERR_STORAGE_PROBE_FAILED, - _("Failed to create filesystem probe " - "for device %s"), - device); + virReportError(VIR_ERR_STORAGE_PROBE_FAILED, + _("Failed to create filesystem probe " + "for device %s"), + device); goto error; } @@ -590,17 +590,17 @@ virStorageBackendFileSystemProbe(const char *device, format, device); ret = FILESYSTEM_PROBE_NOT_FOUND; } else if (blkid_probe_lookup_value(probe, "TYPE", &fstype, NULL) == 0) { - virStorageReportError(VIR_ERR_STORAGE_POOL_BUILT, - _("Existing filesystem of type '%s' found on " - "device '%s'"), - fstype, device); + virReportError(VIR_ERR_STORAGE_POOL_BUILT, + _("Existing filesystem of type '%s' found on " + "device '%s'"), + fstype, device); ret = FILESYSTEM_PROBE_FOUND; } if (blkid_do_probe(probe) != 1) { - virStorageReportError(VIR_ERR_STORAGE_PROBE_FAILED, - _("Found additional probes to run, " - "filesystem probing may be incorrect")); + virReportError(VIR_ERR_STORAGE_PROBE_FAILED, + _("Found additional probes to run, " + "filesystem probing may be incorrect")); ret = FILESYSTEM_PROBE_ERROR; } @@ -620,9 +620,9 @@ static virStoragePoolProbeResult virStorageBackendFileSystemProbe(const char *device ATTRIBUTE_UNUSED, const char *format ATTRIBUTE_UNUSED) { - virStorageReportError(VIR_ERR_OPERATION_INVALID, - _("probing for filesystems is unsupported " - "by this build")); + virReportError(VIR_ERR_OPERATION_INVALID, + _("probing for filesystems is unsupported " + "by this build")); return FILESYSTEM_PROBE_ERROR; } @@ -658,11 +658,11 @@ static int virStorageBackendExecuteMKFS(const char *device ATTRIBUTE_UNUSED, const char *format ATTRIBUTE_UNUSED) { - virStorageReportError(VIR_ERR_INTERNAL_ERROR, - _("mkfs is not supported on this platform: " - "Failed to make filesystem of " - "type '%s' on device '%s'"), - format, device); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("mkfs is not supported on this platform: " + "Failed to make filesystem of " + "type '%s' on device '%s'"), + format, device); return -1; } #endif /* #ifdef MKFS */ @@ -676,9 +676,9 @@ virStorageBackendMakeFileSystem(virStoragePoolObjPtr pool, int ret = -1; if (pool->def->source.devices == NULL) { - virStorageReportError(VIR_ERR_OPERATION_INVALID, - _("No source device specified when formatting pool '%s'"), - pool->def->name); + virReportError(VIR_ERR_OPERATION_INVALID, + _("No source device specified when formatting pool '%s'"), + pool->def->name); goto error; } @@ -687,9 +687,9 @@ virStorageBackendMakeFileSystem(virStoragePoolObjPtr pool, VIR_DEBUG("source device: '%s' format: '%s'", device, format); if (!virFileExists(device)) { - virStorageReportError(VIR_ERR_OPERATION_INVALID, - _("Source device does not exist when formatting pool '%s'"), - pool->def->name); + virReportError(VIR_ERR_OPERATION_INVALID, + _("Source device does not exist when formatting pool '%s'"), + pool->def->name); goto error; } @@ -743,9 +743,9 @@ virStorageBackendFileSystemBuild(virConnectPtr conn ATTRIBUTE_UNUSED, if (flags == (VIR_STORAGE_POOL_BUILD_OVERWRITE | VIR_STORAGE_POOL_BUILD_NO_OVERWRITE)) { - virStorageReportError(VIR_ERR_OPERATION_INVALID, - _("Overwrite and no overwrite flags" - " are mutually exclusive")); + virReportError(VIR_ERR_OPERATION_INVALID, + _("Overwrite and no overwrite flags" + " are mutually exclusive")); goto error; } @@ -754,9 +754,9 @@ virStorageBackendFileSystemBuild(virConnectPtr conn ATTRIBUTE_UNUSED, goto error; } if (!(p = strrchr(parent, '/'))) { - virStorageReportError(VIR_ERR_INVALID_ARG, - _("path '%s' is not absolute"), - pool->def->target.path); + virReportError(VIR_ERR_INVALID_ARG, + _("path '%s' is not absolute"), + pool->def->target.path); goto error; } @@ -886,9 +886,9 @@ virStorageBackendFileSystemRefresh(virConnectPtr conn ATTRIBUTE_UNUSED, * Unfortunately virStorageBackendProbeTarget() might already * have logged a similar message for the same problem, but only * if AUTO format detection was used. */ - virStorageReportError(VIR_ERR_INTERNAL_ERROR, - _("cannot probe backing volume info: %s"), - vol->backingStore.path); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("cannot probe backing volume info: %s"), + vol->backingStore.path); } } @@ -1025,9 +1025,9 @@ static int createFileDir(virConnectPtr conn ATTRIBUTE_UNUSED, virCheckFlags(0, -1); if (inputvol) { - virStorageReportError(VIR_ERR_INTERNAL_ERROR, - "%s", - _("cannot copy from volume to a directory volume")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", + _("cannot copy from volume to a directory volume")); return -1; } @@ -1056,10 +1056,10 @@ _virStorageBackendFileSystemVolBuild(virConnectPtr conn, if (inputvol) { if (vol->target.encryption != NULL) { - virStorageReportError(VIR_ERR_CONFIG_UNSUPPORTED, - "%s", _("storage pool does not support " - "building encrypted volumes from " - "other volumes")); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + "%s", _("storage pool does not support " + "building encrypted volumes from " + "other volumes")); return -1; } create_func = virStorageBackendGetBuildVolFromFunction(vol, @@ -1076,9 +1076,9 @@ _virStorageBackendFileSystemVolBuild(virConnectPtr conn, if (!create_func) return -1; } else { - virStorageReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("creation of non-raw images " - "is not supported without qemu-img")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("creation of non-raw images " + "is not supported without qemu-img")); return -1; } @@ -1148,9 +1148,9 @@ virStorageBackendFileSystemVolDelete(virConnectPtr conn ATTRIBUTE_UNUSED, case VIR_STORAGE_VOL_BLOCK: case VIR_STORAGE_VOL_NETWORK: default: - virStorageReportError(VIR_ERR_NO_SUPPORT, - _("removing block or network volumes is not supported: %s"), - vol->target.path); + virReportError(VIR_ERR_NO_SUPPORT, + _("removing block or network volumes is not supported: %s"), + vol->target.path); return -1; } return 0; @@ -1218,8 +1218,8 @@ virStorageBackendFilesystemResizeQemuImg(const char *path, img_tool = virFindFileInPath("qemu-img"); if (!img_tool) { - virStorageReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("unable to find kvm-img or qemu-img")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("unable to find kvm-img or qemu-img")); return -1; } diff --git a/src/storage/storage_backend_iscsi.c b/src/storage/storage_backend_iscsi.c index 88de9fd..0e14558 100644 --- a/src/storage/storage_backend_iscsi.c +++ b/src/storage/storage_backend_iscsi.c @@ -63,25 +63,25 @@ virStorageBackendISCSITargetIP(const char *hostname, ret = getaddrinfo(hostname, NULL, &hints, &result); if (ret != 0) { - virStorageReportError(VIR_ERR_INTERNAL_ERROR, - _("host lookup failed %s"), - gai_strerror(ret)); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("host lookup failed %s"), + gai_strerror(ret)); return -1; } if (result == NULL) { - virStorageReportError(VIR_ERR_INTERNAL_ERROR, - _("no IP address for target %s"), - hostname); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("no IP address for target %s"), + hostname); return -1; } if (getnameinfo(result->ai_addr, result->ai_addrlen, ipaddr, ipaddrlen, NULL, 0, NI_NUMERICHOST) < 0) { - virStorageReportError(VIR_ERR_INTERNAL_ERROR, - _("cannot format ip addr for %s"), - hostname); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("cannot format ip addr for %s"), + hostname); freeaddrinfo(result); return -1; } @@ -97,8 +97,8 @@ virStorageBackendISCSIPortal(virStoragePoolSourcePtr source) char *portal; if (source->nhost != 1) { - virStorageReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("Expected exactly 1 host for the storage pool")); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Expected exactly 1 host for the storage pool")); return NULL; } @@ -170,8 +170,8 @@ virStorageBackendISCSISession(virStoragePoolObjPtr pool, if (session == NULL && !probe) { - virStorageReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("cannot find session")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("cannot find session")); goto cleanup; } @@ -196,9 +196,9 @@ virStorageBackendIQNFound(const char *initiatoriqn, if (VIR_ALLOC_N(line, LINE_SIZE) != 0) { ret = IQN_ERROR; - virStorageReportError(VIR_ERR_INTERNAL_ERROR, - _("Could not allocate memory for output of '%s'"), - ISCSIADM); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Could not allocate memory for output of '%s'"), + ISCSIADM); goto out; } @@ -211,10 +211,10 @@ virStorageBackendIQNFound(const char *initiatoriqn, } if ((fp = VIR_FDOPEN(fd, "r")) == NULL) { - virStorageReportError(VIR_ERR_INTERNAL_ERROR, - _("Failed to open stream for file descriptor " - "when reading output from '%s': '%s'"), - ISCSIADM, virStrerror(errno, ebuf, sizeof(ebuf))); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Failed to open stream for file descriptor " + "when reading output from '%s': '%s'"), + ISCSIADM, virStrerror(errno, ebuf, sizeof(ebuf))); ret = IQN_ERROR; goto out; } @@ -223,10 +223,10 @@ virStorageBackendIQNFound(const char *initiatoriqn, newline = strrchr(line, '\n'); if (newline == NULL) { ret = IQN_ERROR; - virStorageReportError(VIR_ERR_INTERNAL_ERROR, - _("Unexpected line > %d characters " - "when parsing output of '%s'"), - LINE_SIZE, ISCSIADM); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Unexpected line > %d characters " + "when parsing output of '%s'"), + LINE_SIZE, ISCSIADM); goto out; } *newline = '\0'; @@ -241,9 +241,9 @@ virStorageBackendIQNFound(const char *initiatoriqn, token = strchr(line, ' '); if (!token) { ret = IQN_ERROR; - virStorageReportError(VIR_ERR_INTERNAL_ERROR, - _("Missing space when parsing output " - "of '%s'"), ISCSIADM); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Missing space when parsing output " + "of '%s'"), ISCSIADM); goto out; } *ifacename = strndup(line, token - line); @@ -303,9 +303,9 @@ virStorageBackendCreateIfaceIQN(const char *initiatoriqn, * We will just rely on whether the interface got created * properly. */ if (virCommandRun(cmd, &exitstatus) < 0) { - virStorageReportError(VIR_ERR_INTERNAL_ERROR, - _("Failed to run command '%s' to create new iscsi interface"), - ISCSIADM); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Failed to run command '%s' to create new iscsi interface"), + ISCSIADM); goto cleanup; } virCommandFree(cmd); @@ -322,9 +322,9 @@ virStorageBackendCreateIfaceIQN(const char *initiatoriqn, * returned an exit status of > 0, even if they succeeded. We will just * rely on whether iface file got updated properly. */ if (virCommandRun(cmd, &exitstatus) < 0) { - virStorageReportError(VIR_ERR_INTERNAL_ERROR, - _("Failed to run command '%s' to update iscsi interface with IQN '%s'"), - ISCSIADM, initiatoriqn); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Failed to run command '%s' to update iscsi interface with IQN '%s'"), + ISCSIADM, initiatoriqn); goto cleanup; } @@ -587,8 +587,8 @@ virStorageBackendISCSIFindPoolSources(virConnectPtr conn ATTRIBUTE_UNUSED, return NULL; if (source->nhost != 1) { - virStorageReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("Expected exactly 1 host for the storage pool")); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Expected exactly 1 host for the storage pool")); goto cleanup; } @@ -651,21 +651,21 @@ virStorageBackendISCSICheckPool(virConnectPtr conn ATTRIBUTE_UNUSED, *isActive = false; if (pool->def->source.nhost != 1) { - virStorageReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("Expected exactly 1 host for the storage pool")); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Expected exactly 1 host for the storage pool")); return -1; } if (pool->def->source.hosts[0].name == NULL) { - virStorageReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("missing source host")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("missing source host")); return -1; } if (pool->def->source.ndevice != 1 || pool->def->source.devices[0].path == NULL) { - virStorageReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("missing source device")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("missing source device")); return -1; } @@ -689,21 +689,21 @@ virStorageBackendISCSIStartPool(virConnectPtr conn ATTRIBUTE_UNUSED, const char *loginargv[] = { "--login", NULL }; if (pool->def->source.nhost != 1) { - virStorageReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("Expected exactly 1 host for the storage pool")); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Expected exactly 1 host for the storage pool")); return -1; } if (pool->def->source.hosts[0].name == NULL) { - virStorageReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("missing source host")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("missing source host")); return -1; } if (pool->def->source.ndevice != 1 || pool->def->source.devices[0].path == NULL) { - virStorageReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("missing source device")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("missing source device")); return -1; } diff --git a/src/storage/storage_backend_logical.c b/src/storage/storage_backend_logical.c index c6e09e6..ac116de 100644 --- a/src/storage/storage_backend_logical.c +++ b/src/storage/storage_backend_logical.c @@ -148,8 +148,8 @@ virStorageBackendLogicalMakeVol(virStoragePoolObjPtr pool, nextents = 1; if (STREQ(groups[4], VIR_STORAGE_VOL_LOGICAL_SEGTYPE_STRIPED)) { if (virStrToLong_i(groups[5], NULL, 10, &nextents) < 0) { - virStorageReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("malformed volume extent stripes value")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("malformed volume extent stripes value")); goto cleanup; } } @@ -162,18 +162,18 @@ virStorageBackendLogicalMakeVol(virStoragePoolObjPtr pool, } if (virStrToLong_ull(groups[6], NULL, 10, &length) < 0) { - virStorageReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("malformed volume extent length value")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("malformed volume extent length value")); goto cleanup; } if (virStrToLong_ull(groups[7], NULL, 10, &size) < 0) { - virStorageReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("malformed volume extent size value")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("malformed volume extent size value")); goto cleanup; } if (virStrToLong_ull(groups[8], NULL, 10, &vol->allocation) < 0) { - virStorageReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("malformed volume allocation value")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("malformed volume allocation value")); goto cleanup; } @@ -208,15 +208,15 @@ virStorageBackendLogicalMakeVol(virStoragePoolObjPtr pool, if (err != 0) { char error[100]; regerror(err, reg, error, sizeof(error)); - virStorageReportError(VIR_ERR_INTERNAL_ERROR, - _("Failed to compile regex %s"), - error); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Failed to compile regex %s"), + error); goto cleanup; } if (regexec(reg, groups[3], nvars, vars, 0) != 0) { - virStorageReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("malformed volume extent devices value")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("malformed volume extent devices value")); goto cleanup; } @@ -244,8 +244,8 @@ virStorageBackendLogicalMakeVol(virStoragePoolObjPtr pool, } if (virStrToLong_ull(offset_str, NULL, 10, &offset) < 0) { - virStorageReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("malformed volume extent offset value")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("malformed volume extent offset value")); VIR_FREE(offset_str); goto cleanup; } @@ -450,8 +450,8 @@ virStorageBackendLogicalFindPoolSources(virConnectPtr conn ATTRIBUTE_UNUSED, retval = virStoragePoolSourceListFormat(&sourceList); if (retval == NULL) { - virStorageReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("failed to get source from sourceList")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("failed to get source from sourceList")); goto cleanup; } @@ -701,9 +701,9 @@ virStorageBackendLogicalCreateVol(virConnectPtr conn, virCommandPtr cmd = NULL; if (vol->target.encryption != NULL) { - virStorageReportError(VIR_ERR_CONFIG_UNSUPPORTED, - "%s", _("storage pool does not support encrypted " - "volumes")); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + "%s", _("storage pool does not support encrypted " + "volumes")); return -1; } diff --git a/src/storage/storage_backend_mpath.c b/src/storage/storage_backend_mpath.c index f09ce9b..685cbf4 100644 --- a/src/storage/storage_backend_mpath.c +++ b/src/storage/storage_backend_mpath.c @@ -228,9 +228,9 @@ virStorageBackendCreateVols(virStoragePoolObjPtr pool, } if (virStorageBackendGetMinorNumber(names->name, &minor) < 0) { - virStorageReportError(VIR_ERR_INTERNAL_ERROR, - _("Failed to get %s minor number"), - names->name); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Failed to get %s minor number"), + names->name); goto out; } diff --git a/src/storage/storage_backend_rbd.c b/src/storage/storage_backend_rbd.c index 7615dcc..dc66dc1 100644 --- a/src/storage/storage_backend_rbd.c +++ b/src/storage/storage_backend_rbd.c @@ -65,8 +65,8 @@ static int virStorageBackendRBDOpenRADOSConn(virStorageBackendRBDStatePtr *ptr, VIR_DEBUG("Using cephx authorization"); if (rados_create(&ptr->cluster, pool->def->source.auth.cephx.username) < 0) { - virStorageReportError(VIR_ERR_INTERNAL_ERROR, - _("failed to initialize RADOS")); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("failed to initialize RADOS")); goto cleanup; } @@ -84,8 +84,8 @@ static int virStorageBackendRBDOpenRADOSConn(virStorageBackendRBDStatePtr *ptr, } if (secret == NULL) { - virStorageReportError(VIR_ERR_NO_SECRET, - _("failed to find the secret")); + virReportError(VIR_ERR_NO_SECRET, + _("failed to find the secret")); goto cleanup; } @@ -95,38 +95,38 @@ static int virStorageBackendRBDOpenRADOSConn(virStorageBackendRBDStatePtr *ptr, memset(secret_value, 0, secret_value_size); if (rados_key == NULL) { - virStorageReportError(VIR_ERR_INTERNAL_ERROR, - _("failed to decode the RADOS key")); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("failed to decode the RADOS key")); goto cleanup; } VIR_DEBUG("Found cephx key: %s", rados_key); if (rados_conf_set(ptr->cluster, "key", rados_key) < 0) { - virStorageReportError(VIR_ERR_INTERNAL_ERROR, - _("failed to set RADOS option: %s"), - "rados_key"); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("failed to set RADOS option: %s"), + "rados_key"); goto cleanup; } memset(rados_key, 0, strlen(rados_key)); if (rados_conf_set(ptr->cluster, "auth_supported", "cephx") < 0) { - virStorageReportError(VIR_ERR_INTERNAL_ERROR, - _("failed to set RADOS option: %s"), - "auth_supported"); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("failed to set RADOS option: %s"), + "auth_supported"); goto cleanup; } } else { VIR_DEBUG("Not using cephx authorization"); if (rados_create(&ptr->cluster, NULL) < 0) { - virStorageReportError(VIR_ERR_INTERNAL_ERROR, - _("failed to create the RADOS cluster")); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("failed to create the RADOS cluster")); goto cleanup; } if (rados_conf_set(ptr->cluster, "auth_supported", "none") < 0) { - virStorageReportError(VIR_ERR_INTERNAL_ERROR, - _("failed to set RADOS option: %s"), - "auth_supported"); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("failed to set RADOS option: %s"), + "auth_supported"); goto cleanup; } } @@ -145,8 +145,8 @@ static int virStorageBackendRBDOpenRADOSConn(virStorageBackendRBDStatePtr *ptr, pool->def->source.hosts[i].name, pool->def->source.hosts[i].port); } else { - virStorageReportError(VIR_ERR_INTERNAL_ERROR, - _("received malformed monitor, check the XML definition")); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("received malformed monitor, check the XML definition")); } } @@ -158,17 +158,17 @@ static int virStorageBackendRBDOpenRADOSConn(virStorageBackendRBDStatePtr *ptr, mon_buff = virBufferContentAndReset(&mon_host); VIR_DEBUG("RADOS mon_host has been set to: %s", mon_buff); if (rados_conf_set(ptr->cluster, "mon_host", mon_buff) < 0) { - virStorageReportError(VIR_ERR_INTERNAL_ERROR, - _("failed to set RADOS option: %s"), - "mon_host"); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("failed to set RADOS option: %s"), + "mon_host"); goto cleanup; } ptr->starttime = time(0); if (rados_connect(ptr->cluster) < 0) { - virStorageReportError(VIR_ERR_INTERNAL_ERROR, - _("failed to connect to the RADOS monitor on: %s"), - mon_buff); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("failed to connect to the RADOS monitor on: %s"), + mon_buff); goto cleanup; } @@ -214,16 +214,16 @@ static int volStorageBackendRBDRefreshVolInfo(virStorageVolDefPtr vol, int ret = -1; rbd_image_t image; if (rbd_open(ptr.ioctx, vol->name, &image, NULL) < 0) { - virStorageReportError(VIR_ERR_INTERNAL_ERROR, - _("failed to open the RBD image '%s'"), - vol->name); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("failed to open the RBD image '%s'"), + vol->name); return ret; } rbd_image_info_t info; if (rbd_stat(image, &info, sizeof(info)) < 0) { - virStorageReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("failed to stat the RBD image")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("failed to stat the RBD image")); goto cleanup; } @@ -277,24 +277,24 @@ static int virStorageBackendRBDRefreshPool(virConnectPtr conn ATTRIBUTE_UNUSED, if (rados_ioctx_create(ptr.cluster, pool->def->source.name, &ptr.ioctx) < 0) { - virStorageReportError(VIR_ERR_INTERNAL_ERROR, - _("failed to create the RBD IoCTX. Does the pool '%s' exist?"), - pool->def->source.name); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("failed to create the RBD IoCTX. Does the pool '%s' exist?"), + pool->def->source.name); goto cleanup; } struct rados_cluster_stat_t stat; if (rados_cluster_stat(ptr.cluster, &stat) < 0) { - virStorageReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("failed to stat the RADOS cluster")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("failed to stat the RADOS cluster")); goto cleanup; } struct rados_pool_stat_t poolstat; if (rados_ioctx_pool_stat(ptr.ioctx, &poolstat) < 0) { - virStorageReportError(VIR_ERR_INTERNAL_ERROR, - _("failed to stat the RADOS pool '%s'"), - pool->def->source.name); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("failed to stat the RADOS pool '%s'"), + pool->def->source.name); goto cleanup; } @@ -382,17 +382,17 @@ static int virStorageBackendRBDDeleteVol(virConnectPtr conn, if (rados_ioctx_create(ptr.cluster, pool->def->source.name, &ptr.ioctx) < 0) { - virStorageReportError(VIR_ERR_INTERNAL_ERROR, - _("failed to create the RBD IoCTX. Does the pool '%s' exist?"), - pool->def->source.name); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("failed to create the RBD IoCTX. Does the pool '%s' exist?"), + pool->def->source.name); goto cleanup; } if (rbd_remove(ptr.ioctx, vol->name) < 0) { - virStorageReportError(VIR_ERR_INTERNAL_ERROR, - _("failed to remove volume '%s/%s'"), - pool->def->source.name, - vol->name); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("failed to remove volume '%s/%s'"), + pool->def->source.name, + vol->name); goto cleanup; } @@ -423,23 +423,23 @@ static int virStorageBackendRBDCreateVol(virConnectPtr conn, if (rados_ioctx_create(ptr.cluster, pool->def->source.name,&ptr.ioctx) < 0) { - virStorageReportError(VIR_ERR_INTERNAL_ERROR, - _("failed to create the RBD IoCTX. Does the pool '%s' exist?"), - pool->def->source.name); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("failed to create the RBD IoCTX. Does the pool '%s' exist?"), + pool->def->source.name); goto cleanup; } if (vol->target.encryption != NULL) { - virStorageReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("storage pool does not support encrypted volumes")); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("storage pool does not support encrypted volumes")); goto cleanup; } if (rbd_create(ptr.ioctx, vol->name, vol->capacity, &order) < 0) { - virStorageReportError(VIR_ERR_INTERNAL_ERROR, - _("failed to create volume '%s/%s'"), - pool->def->source.name, - vol->name); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("failed to create volume '%s/%s'"), + pool->def->source.name, + vol->name); goto cleanup; } @@ -469,9 +469,9 @@ static int virStorageBackendRBDRefreshVol(virConnectPtr conn, if (rados_ioctx_create(ptr.cluster, pool->def->source.name, &ptr.ioctx) < 0) { - virStorageReportError(VIR_ERR_INTERNAL_ERROR, - _("failed to create the RBD IoCTX. Does the pool '%s' exist?"), - pool->def->source.name); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("failed to create the RBD IoCTX. Does the pool '%s' exist?"), + pool->def->source.name); goto cleanup; } @@ -506,23 +506,23 @@ static int virStorageBackendRBDResizeVol(virConnectPtr conn ATTRIBUTE_UNUSED, if (rados_ioctx_create(ptr.cluster, pool->def->source.name, &ptr.ioctx) < 0) { - virStorageReportError(VIR_ERR_INTERNAL_ERROR, - _("failed to create the RBD IoCTX. Does the pool '%s' exist?"), - pool->def->source.name); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("failed to create the RBD IoCTX. Does the pool '%s' exist?"), + pool->def->source.name); goto cleanup; } if (rbd_open(ptr.ioctx, vol->name, &image, NULL) < 0) { - virStorageReportError(VIR_ERR_INTERNAL_ERROR, - _("failed to open the RBD image '%s'"), - vol->name); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("failed to open the RBD image '%s'"), + vol->name); goto cleanup; } if (rbd_resize(image, capacity) < 0) { - virStorageReportError(VIR_ERR_INTERNAL_ERROR, - _("failed to resize the RBD image '%s'"), - vol->name); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("failed to resize the RBD image '%s'"), + vol->name); goto cleanup; } diff --git a/src/storage/storage_backend_scsi.c b/src/storage/storage_backend_scsi.c index 465d557..f215876 100644 --- a/src/storage/storage_backend_scsi.c +++ b/src/storage/storage_backend_scsi.c @@ -86,9 +86,9 @@ getDeviceType(uint32_t host, * character is not \0, virStrToLong_i complains */ if (virStrToLong_i(typestr, &p, 10, type) < 0) { - virStorageReportError(VIR_ERR_INTERNAL_ERROR, - _("Device type '%s' is not an integer"), - typestr); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Device type '%s' is not an integer"), + typestr); /* Hm, type wasn't an integer; seems strange */ retval = -1; goto out; @@ -266,9 +266,9 @@ virStorageBackendSCSINewLun(virStoragePoolObjPtr pool, &vol->allocation, &vol->capacity) < 0) { - virStorageReportError(VIR_ERR_INTERNAL_ERROR, - _("Failed to update volume for '%s'"), - devpath); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Failed to update volume for '%s'"), + devpath); retval = -1; goto free_vol; } @@ -365,9 +365,9 @@ getOldStyleBlockDevice(const char *lun_path ATTRIBUTE_UNUSED, blockp = strrchr(block_name, ':'); if (blockp == NULL) { /* Hm, wasn't what we were expecting; have to give up */ - virStorageReportError(VIR_ERR_INTERNAL_ERROR, - _("Failed to parse block name %s"), - block_name); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Failed to parse block name %s"), + block_name); retval = -1; } else { blockp++; @@ -453,9 +453,9 @@ processLU(virStoragePoolObjPtr pool, host, bus, target, lun); if (getDeviceType(host, bus, target, lun, &device_type) < 0) { - virStorageReportError(VIR_ERR_INTERNAL_ERROR, - _("Failed to determine if %u:%u:%u:%u is a Direct-Access LUN"), - host, bus, target, lun); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Failed to determine if %u:%u:%u:%u is a Direct-Access LUN"), + host, bus, target, lun); retval = -1; goto out; } diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c index fbc630d..c9b8021 100644 --- a/src/storage/storage_driver.c +++ b/src/storage/storage_driver.c @@ -268,8 +268,8 @@ storagePoolLookupByUUID(virConnectPtr conn, storageDriverUnlock(driver); if (!pool) { - virStorageReportError(VIR_ERR_NO_STORAGE_POOL, - "%s", _("no pool with matching uuid")); + virReportError(VIR_ERR_NO_STORAGE_POOL, + "%s", _("no pool with matching uuid")); goto cleanup; } @@ -293,8 +293,8 @@ storagePoolLookupByName(virConnectPtr conn, storageDriverUnlock(driver); if (!pool) { - virStorageReportError(VIR_ERR_NO_STORAGE_POOL, - _("no pool with matching name '%s'"), name); + virReportError(VIR_ERR_NO_STORAGE_POOL, + _("no pool with matching name '%s'"), name); goto cleanup; } @@ -442,8 +442,8 @@ storageFindPoolSources(virConnectPtr conn, backend_type = virStoragePoolTypeFromString(type); if (backend_type < 0) { - virStorageReportError(VIR_ERR_INTERNAL_ERROR, - _("unknown storage pool type %s"), type); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unknown storage pool type %s"), type); goto cleanup; } @@ -452,9 +452,9 @@ storageFindPoolSources(virConnectPtr conn, goto cleanup; if (!backend->findPoolSources) { - virStorageReportError(VIR_ERR_NO_SUPPORT, - _("pool type '%s' does not support source " - "discovery"), type); + virReportError(VIR_ERR_NO_SUPPORT, + _("pool type '%s' does not support source " + "discovery"), type); goto cleanup; } @@ -475,7 +475,7 @@ static int storagePoolIsActive(virStoragePoolPtr pool) obj = virStoragePoolObjFindByUUID(&driver->pools, pool->uuid); storageDriverUnlock(driver); if (!obj) { - virStorageReportError(VIR_ERR_NO_STORAGE_POOL, NULL); + virReportError(VIR_ERR_NO_STORAGE_POOL, NULL); goto cleanup; } ret = virStoragePoolObjIsActive(obj); @@ -496,7 +496,7 @@ static int storagePoolIsPersistent(virStoragePoolPtr pool) obj = virStoragePoolObjFindByUUID(&driver->pools, pool->uuid); storageDriverUnlock(driver); if (!obj) { - virStorageReportError(VIR_ERR_NO_STORAGE_POOL, NULL); + virReportError(VIR_ERR_NO_STORAGE_POOL, NULL); goto cleanup; } ret = obj->configFile ? 1 : 0; @@ -620,21 +620,21 @@ storagePoolUndefine(virStoragePoolPtr obj) { storageDriverLock(driver); pool = virStoragePoolObjFindByUUID(&driver->pools, obj->uuid); if (!pool) { - virStorageReportError(VIR_ERR_NO_STORAGE_POOL, - "%s", _("no storage pool with matching uuid")); + virReportError(VIR_ERR_NO_STORAGE_POOL, + "%s", _("no storage pool with matching uuid")); goto cleanup; } if (virStoragePoolObjIsActive(pool)) { - virStorageReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("pool is still active")); + virReportError(VIR_ERR_OPERATION_INVALID, + "%s", _("pool is still active")); goto cleanup; } if (pool->asyncjobs > 0) { - virStorageReportError(VIR_ERR_INTERNAL_ERROR, - _("pool '%s' has asynchronous jobs running."), - pool->def->name); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("pool '%s' has asynchronous jobs running."), + pool->def->name); goto cleanup; } @@ -678,8 +678,8 @@ storagePoolStart(virStoragePoolPtr obj, storageDriverUnlock(driver); if (!pool) { - virStorageReportError(VIR_ERR_NO_STORAGE_POOL, - "%s", _("no storage pool with matching uuid")); + virReportError(VIR_ERR_NO_STORAGE_POOL, + "%s", _("no storage pool with matching uuid")); goto cleanup; } @@ -687,8 +687,8 @@ storagePoolStart(virStoragePoolPtr obj, goto cleanup; if (virStoragePoolObjIsActive(pool)) { - virStorageReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("pool already active")); + virReportError(VIR_ERR_OPERATION_INVALID, + "%s", _("pool already active")); goto cleanup; } if (backend->startPool && @@ -724,8 +724,8 @@ storagePoolBuild(virStoragePoolPtr obj, storageDriverUnlock(driver); if (!pool) { - virStorageReportError(VIR_ERR_NO_STORAGE_POOL, - "%s", _("no storage pool with matching uuid")); + virReportError(VIR_ERR_NO_STORAGE_POOL, + "%s", _("no storage pool with matching uuid")); goto cleanup; } @@ -733,8 +733,8 @@ storagePoolBuild(virStoragePoolPtr obj, goto cleanup; if (virStoragePoolObjIsActive(pool)) { - virStorageReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("storage pool is already active")); + virReportError(VIR_ERR_OPERATION_INVALID, + "%s", _("storage pool is already active")); goto cleanup; } @@ -761,8 +761,8 @@ storagePoolDestroy(virStoragePoolPtr obj) { pool = virStoragePoolObjFindByUUID(&driver->pools, obj->uuid); if (!pool) { - virStorageReportError(VIR_ERR_NO_STORAGE_POOL, - "%s", _("no storage pool with matching uuid")); + virReportError(VIR_ERR_NO_STORAGE_POOL, + "%s", _("no storage pool with matching uuid")); goto cleanup; } @@ -770,15 +770,15 @@ storagePoolDestroy(virStoragePoolPtr obj) { goto cleanup; if (!virStoragePoolObjIsActive(pool)) { - virStorageReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("storage pool is not active")); + virReportError(VIR_ERR_OPERATION_INVALID, + "%s", _("storage pool is not active")); goto cleanup; } if (pool->asyncjobs > 0) { - virStorageReportError(VIR_ERR_INTERNAL_ERROR, - _("pool '%s' has asynchronous jobs running."), - pool->def->name); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("pool '%s' has asynchronous jobs running."), + pool->def->name); goto cleanup; } @@ -821,8 +821,8 @@ storagePoolDelete(virStoragePoolPtr obj, storageDriverUnlock(driver); if (!pool) { - virStorageReportError(VIR_ERR_NO_STORAGE_POOL, - "%s", _("no storage pool with matching uuid")); + virReportError(VIR_ERR_NO_STORAGE_POOL, + "%s", _("no storage pool with matching uuid")); goto cleanup; } @@ -830,21 +830,21 @@ storagePoolDelete(virStoragePoolPtr obj, goto cleanup; if (virStoragePoolObjIsActive(pool)) { - virStorageReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("storage pool is still active")); + virReportError(VIR_ERR_OPERATION_INVALID, + "%s", _("storage pool is still active")); goto cleanup; } if (pool->asyncjobs > 0) { - virStorageReportError(VIR_ERR_INTERNAL_ERROR, - _("pool '%s' has asynchronous jobs running."), + virReportError(VIR_ERR_INTERNAL_ERROR, + _("pool '%s' has asynchronous jobs running."), pool->def->name); goto cleanup; } if (!backend->deletePool) { - virStorageReportError(VIR_ERR_NO_SUPPORT, - "%s", _("pool does not support pool deletion")); + virReportError(VIR_ERR_NO_SUPPORT, + "%s", _("pool does not support pool deletion")); goto cleanup; } if (backend->deletePool(obj->conn, pool, flags) < 0) @@ -874,8 +874,8 @@ storagePoolRefresh(virStoragePoolPtr obj, pool = virStoragePoolObjFindByUUID(&driver->pools, obj->uuid); if (!pool) { - virStorageReportError(VIR_ERR_NO_STORAGE_POOL, - "%s", _("no storage pool with matching uuid")); + virReportError(VIR_ERR_NO_STORAGE_POOL, + "%s", _("no storage pool with matching uuid")); goto cleanup; } @@ -883,15 +883,15 @@ storagePoolRefresh(virStoragePoolPtr obj, goto cleanup; if (!virStoragePoolObjIsActive(pool)) { - virStorageReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("storage pool is not active")); + virReportError(VIR_ERR_OPERATION_INVALID, + "%s", _("storage pool is not active")); goto cleanup; } if (pool->asyncjobs > 0) { - virStorageReportError(VIR_ERR_INTERNAL_ERROR, - _("pool '%s' has asynchronous jobs running."), - pool->def->name); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("pool '%s' has asynchronous jobs running."), + pool->def->name); goto cleanup; } @@ -930,8 +930,8 @@ storagePoolGetInfo(virStoragePoolPtr obj, storageDriverUnlock(driver); if (!pool) { - virStorageReportError(VIR_ERR_NO_STORAGE_POOL, - "%s", _("no storage pool with matching uuid")); + virReportError(VIR_ERR_NO_STORAGE_POOL, + "%s", _("no storage pool with matching uuid")); goto cleanup; } @@ -970,8 +970,8 @@ storagePoolGetXMLDesc(virStoragePoolPtr obj, storageDriverUnlock(driver); if (!pool) { - virStorageReportError(VIR_ERR_NO_STORAGE_POOL, - "%s", _("no storage pool with matching uuid")); + virReportError(VIR_ERR_NO_STORAGE_POOL, + "%s", _("no storage pool with matching uuid")); goto cleanup; } @@ -1000,8 +1000,8 @@ storagePoolGetAutostart(virStoragePoolPtr obj, storageDriverUnlock(driver); if (!pool) { - virStorageReportError(VIR_ERR_NO_STORAGE_POOL, - "%s", _("no pool with matching uuid")); + virReportError(VIR_ERR_NO_STORAGE_POOL, + "%s", _("no pool with matching uuid")); goto cleanup; } @@ -1029,14 +1029,14 @@ storagePoolSetAutostart(virStoragePoolPtr obj, pool = virStoragePoolObjFindByUUID(&driver->pools, obj->uuid); if (!pool) { - virStorageReportError(VIR_ERR_NO_STORAGE_POOL, - "%s", _("no pool with matching uuid")); + virReportError(VIR_ERR_NO_STORAGE_POOL, + "%s", _("no pool with matching uuid")); goto cleanup; } if (!pool->configFile) { - virStorageReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("pool has no config file")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("pool has no config file")); goto cleanup; } @@ -1089,14 +1089,14 @@ storagePoolNumVolumes(virStoragePoolPtr obj) { storageDriverUnlock(driver); if (!pool) { - virStorageReportError(VIR_ERR_NO_STORAGE_POOL, - "%s", _("no storage pool with matching uuid")); + virReportError(VIR_ERR_NO_STORAGE_POOL, + "%s", _("no storage pool with matching uuid")); goto cleanup; } if (!virStoragePoolObjIsActive(pool)) { - virStorageReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("storage pool is not active")); + virReportError(VIR_ERR_OPERATION_INVALID, + "%s", _("storage pool is not active")); goto cleanup; } ret = pool->volumes.count; @@ -1122,14 +1122,14 @@ storagePoolListVolumes(virStoragePoolPtr obj, storageDriverUnlock(driver); if (!pool) { - virStorageReportError(VIR_ERR_NO_STORAGE_POOL, - "%s", _("no storage pool with matching uuid")); + virReportError(VIR_ERR_NO_STORAGE_POOL, + "%s", _("no storage pool with matching uuid")); goto cleanup; } if (!virStoragePoolObjIsActive(pool)) { - virStorageReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("storage pool is not active")); + virReportError(VIR_ERR_OPERATION_INVALID, + "%s", _("storage pool is not active")); goto cleanup; } @@ -1167,23 +1167,23 @@ storageVolumeLookupByName(virStoragePoolPtr obj, storageDriverUnlock(driver); if (!pool) { - virStorageReportError(VIR_ERR_NO_STORAGE_POOL, - "%s", _("no storage pool with matching uuid")); + virReportError(VIR_ERR_NO_STORAGE_POOL, + "%s", _("no storage pool with matching uuid")); goto cleanup; } if (!virStoragePoolObjIsActive(pool)) { - virStorageReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("storage pool is not active")); + virReportError(VIR_ERR_OPERATION_INVALID, + "%s", _("storage pool is not active")); goto cleanup; } vol = virStorageVolDefFindByName(pool, name); if (!vol) { - virStorageReportError(VIR_ERR_NO_STORAGE_VOL, - _("no storage vol with matching name '%s'"), - name); + virReportError(VIR_ERR_NO_STORAGE_VOL, + _("no storage vol with matching name '%s'"), + name); goto cleanup; } @@ -1221,8 +1221,8 @@ storageVolumeLookupByKey(virConnectPtr conn, storageDriverUnlock(driver); if (!ret) - virStorageReportError(VIR_ERR_NO_STORAGE_VOL, - "%s", _("no storage vol with matching key")); + virReportError(VIR_ERR_NO_STORAGE_VOL, + "%s", _("no storage vol with matching key")); return ret; } @@ -1272,8 +1272,8 @@ storageVolumeLookupByPath(virConnectPtr conn, } if (!ret) - virStorageReportError(VIR_ERR_NO_STORAGE_VOL, - "%s", _("no storage vol with matching path")); + virReportError(VIR_ERR_NO_STORAGE_VOL, + "%s", _("no storage vol with matching path")); VIR_FREE(cleanpath); storageDriverUnlock(driver); @@ -1300,14 +1300,14 @@ storageVolumeCreateXML(virStoragePoolPtr obj, storageDriverUnlock(driver); if (!pool) { - virStorageReportError(VIR_ERR_NO_STORAGE_POOL, - "%s", _("no storage pool with matching uuid")); + virReportError(VIR_ERR_NO_STORAGE_POOL, + "%s", _("no storage pool with matching uuid")); goto cleanup; } if (!virStoragePoolObjIsActive(pool)) { - virStorageReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("storage pool is not active")); + virReportError(VIR_ERR_OPERATION_INVALID, + "%s", _("storage pool is not active")); goto cleanup; } @@ -1319,8 +1319,8 @@ storageVolumeCreateXML(virStoragePoolPtr obj, goto cleanup; if (virStorageVolDefFindByName(pool, voldef->name)) { - virStorageReportError(VIR_ERR_NO_STORAGE_VOL, - "%s", _("storage vol already exists")); + virReportError(VIR_ERR_NO_STORAGE_VOL, + "%s", _("storage vol already exists")); goto cleanup; } @@ -1331,9 +1331,9 @@ storageVolumeCreateXML(virStoragePoolPtr obj, } if (!backend->createVol) { - virStorageReportError(VIR_ERR_NO_SUPPORT, - "%s", _("storage pool does not support volume " - "creation")); + virReportError(VIR_ERR_NO_SUPPORT, + "%s", _("storage pool does not support volume " + "creation")); goto cleanup; } @@ -1430,27 +1430,27 @@ storageVolumeCreateXMLFrom(virStoragePoolPtr obj, } storageDriverUnlock(driver); if (!pool) { - virStorageReportError(VIR_ERR_NO_STORAGE_POOL, - "%s", _("no storage pool with matching uuid")); + virReportError(VIR_ERR_NO_STORAGE_POOL, + "%s", _("no storage pool with matching uuid")); goto cleanup; } if (STRNEQ(obj->name, vobj->pool) && !origpool) { - virStorageReportError(VIR_ERR_NO_STORAGE_POOL, - _("no storage pool with matching name '%s'"), - vobj->pool); + virReportError(VIR_ERR_NO_STORAGE_POOL, + _("no storage pool with matching name '%s'"), + vobj->pool); goto cleanup; } if (!virStoragePoolObjIsActive(pool)) { - virStorageReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("storage pool is not active")); + virReportError(VIR_ERR_OPERATION_INVALID, + "%s", _("storage pool is not active")); goto cleanup; } if (origpool && !virStoragePoolObjIsActive(origpool)) { - virStorageReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("storage pool is not active")); + virReportError(VIR_ERR_OPERATION_INVALID, + "%s", _("storage pool is not active")); goto cleanup; } @@ -1459,9 +1459,9 @@ storageVolumeCreateXMLFrom(virStoragePoolPtr obj, origvol = virStorageVolDefFindByName(origpool ? origpool : pool, vobj->name); if (!origvol) { - virStorageReportError(VIR_ERR_NO_STORAGE_VOL, - _("no storage vol with matching name '%s'"), - vobj->name); + virReportError(VIR_ERR_NO_STORAGE_VOL, + _("no storage vol with matching name '%s'"), + vobj->name); goto cleanup; } @@ -1470,9 +1470,9 @@ storageVolumeCreateXMLFrom(virStoragePoolPtr obj, goto cleanup; if (virStorageVolDefFindByName(pool, newvol->name)) { - virStorageReportError(VIR_ERR_INTERNAL_ERROR, - _("storage volume name '%s' already in use."), - newvol->name); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("storage volume name '%s' already in use."), + newvol->name); goto cleanup; } @@ -1486,15 +1486,15 @@ storageVolumeCreateXMLFrom(virStoragePoolPtr obj, newvol->allocation = origvol->capacity; if (!backend->buildVolFrom) { - virStorageReportError(VIR_ERR_NO_SUPPORT, - "%s", _("storage pool does not support volume creation from an existing volume")); + virReportError(VIR_ERR_NO_SUPPORT, + "%s", _("storage pool does not support volume creation from an existing volume")); goto cleanup; } if (origvol->building) { - virStorageReportError(VIR_ERR_OPERATION_INVALID, - _("volume '%s' is still being allocated."), - origvol->name); + virReportError(VIR_ERR_OPERATION_INVALID, + _("volume '%s' is still being allocated."), + origvol->name); goto cleanup; } @@ -1590,30 +1590,30 @@ storageVolumeDownload(virStorageVolPtr obj, storageDriverUnlock(driver); if (!pool) { - virStorageReportError(VIR_ERR_NO_STORAGE_POOL, - "%s", _("no storage pool with matching uuid")); + virReportError(VIR_ERR_NO_STORAGE_POOL, + "%s", _("no storage pool with matching uuid")); goto out; } if (!virStoragePoolObjIsActive(pool)) { - virStorageReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("storage pool is not active")); + virReportError(VIR_ERR_OPERATION_INVALID, + "%s", _("storage pool is not active")); goto out; } vol = virStorageVolDefFindByName(pool, obj->name); if (vol == NULL) { - virStorageReportError(VIR_ERR_NO_STORAGE_VOL, - _("no storage vol with matching name '%s'"), - obj->name); + virReportError(VIR_ERR_NO_STORAGE_VOL, + _("no storage vol with matching name '%s'"), + obj->name); goto out; } if (vol->building) { - virStorageReportError(VIR_ERR_OPERATION_INVALID, - _("volume '%s' is still being allocated."), - vol->name); + virReportError(VIR_ERR_OPERATION_INVALID, + _("volume '%s' is still being allocated."), + vol->name); goto out; } @@ -1652,30 +1652,30 @@ storageVolumeUpload(virStorageVolPtr obj, storageDriverUnlock(driver); if (!pool) { - virStorageReportError(VIR_ERR_NO_STORAGE_POOL, - "%s", _("no storage pool with matching uuid")); + virReportError(VIR_ERR_NO_STORAGE_POOL, + "%s", _("no storage pool with matching uuid")); goto out; } if (!virStoragePoolObjIsActive(pool)) { - virStorageReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("storage pool is not active")); + virReportError(VIR_ERR_OPERATION_INVALID, + "%s", _("storage pool is not active")); goto out; } vol = virStorageVolDefFindByName(pool, obj->name); if (vol == NULL) { - virStorageReportError(VIR_ERR_NO_STORAGE_VOL, - _("no storage vol with matching name '%s'"), - obj->name); + virReportError(VIR_ERR_NO_STORAGE_VOL, + _("no storage vol with matching name '%s'"), + obj->name); goto out; } if (vol->building) { - virStorageReportError(VIR_ERR_OPERATION_INVALID, - _("volume '%s' is still being allocated."), - vol->name); + virReportError(VIR_ERR_OPERATION_INVALID, + _("volume '%s' is still being allocated."), + vol->name); goto out; } @@ -1715,14 +1715,14 @@ storageVolumeResize(virStorageVolPtr obj, storageDriverUnlock(driver); if (!pool) { - virStorageReportError(VIR_ERR_NO_STORAGE_POOL, - _("no storage pool with matching uuid")); + virReportError(VIR_ERR_NO_STORAGE_POOL, + _("no storage pool with matching uuid")); goto out; } if (!virStoragePoolObjIsActive(pool)) { - virStorageReportError(VIR_ERR_OPERATION_INVALID, - _("storage pool is not active")); + virReportError(VIR_ERR_OPERATION_INVALID, + _("storage pool is not active")); goto out; } @@ -1732,16 +1732,16 @@ storageVolumeResize(virStorageVolPtr obj, vol = virStorageVolDefFindByName(pool, obj->name); if (vol == NULL) { - virStorageReportError(VIR_ERR_NO_STORAGE_VOL, - _("no storage vol with matching name '%s'"), - obj->name); + virReportError(VIR_ERR_NO_STORAGE_VOL, + _("no storage vol with matching name '%s'"), + obj->name); goto out; } if (vol->building) { - virStorageReportError(VIR_ERR_OPERATION_INVALID, - _("volume '%s' is still being allocated."), - vol->name); + virReportError(VIR_ERR_OPERATION_INVALID, + _("volume '%s' is still being allocated."), + vol->name); goto out; } @@ -1753,22 +1753,22 @@ storageVolumeResize(virStorageVolPtr obj, } if (abs_capacity < vol->allocation) { - virStorageReportError(VIR_ERR_INVALID_ARG, - _("can't shrink capacity below " - "existing allocation")); + virReportError(VIR_ERR_INVALID_ARG, + _("can't shrink capacity below " + "existing allocation")); goto out; } if (abs_capacity > vol->capacity + pool->def->available) { - virStorageReportError(VIR_ERR_OPERATION_FAILED, - _("Not enough space left on storage pool")); + virReportError(VIR_ERR_OPERATION_FAILED, + _("Not enough space left on storage pool")); goto out; } if (!backend->resizeVol) { - virStorageReportError(VIR_ERR_NO_SUPPORT, - _("storage pool does not support changing of " - "volume capacity")); + virReportError(VIR_ERR_NO_SUPPORT, + _("storage pool does not support changing of " + "volume capacity")); goto out; } @@ -1944,9 +1944,9 @@ storageVolumeWipeInternal(virStorageVolDefPtr def, alg_char = "random"; break; default: - virStorageReportError(VIR_ERR_INVALID_ARG, - _("unsupported algorithm %d"), - algorithm); + virReportError(VIR_ERR_INVALID_ARG, + _("unsupported algorithm %d"), + algorithm); } cmd = virCommandNew(SCRUB); virCommandAddArgList(cmd, "-f", "-p", alg_char, @@ -1998,9 +1998,9 @@ storageVolumeWipePattern(virStorageVolPtr obj, virCheckFlags(0, -1); if (algorithm >= VIR_STORAGE_VOL_WIPE_ALG_LAST) { - virStorageReportError(VIR_ERR_INVALID_ARG, - _("wiping algorithm %d not supported"), - algorithm); + virReportError(VIR_ERR_INVALID_ARG, + _("wiping algorithm %d not supported"), + algorithm); return -1; } @@ -2009,30 +2009,30 @@ storageVolumeWipePattern(virStorageVolPtr obj, storageDriverUnlock(driver); if (!pool) { - virStorageReportError(VIR_ERR_NO_STORAGE_POOL, - "%s", _("no storage pool with matching uuid")); + virReportError(VIR_ERR_NO_STORAGE_POOL, + "%s", _("no storage pool with matching uuid")); goto out; } if (!virStoragePoolObjIsActive(pool)) { - virStorageReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("storage pool is not active")); + virReportError(VIR_ERR_OPERATION_INVALID, + "%s", _("storage pool is not active")); goto out; } vol = virStorageVolDefFindByName(pool, obj->name); if (vol == NULL) { - virStorageReportError(VIR_ERR_NO_STORAGE_VOL, - _("no storage vol with matching name '%s'"), - obj->name); + virReportError(VIR_ERR_NO_STORAGE_VOL, + _("no storage vol with matching name '%s'"), + obj->name); goto out; } if (vol->building) { - virStorageReportError(VIR_ERR_OPERATION_INVALID, - _("volume '%s' is still being allocated."), - vol->name); + virReportError(VIR_ERR_OPERATION_INVALID, + _("volume '%s' is still being allocated."), + vol->name); goto out; } @@ -2073,14 +2073,14 @@ storageVolumeDelete(virStorageVolPtr obj, storageDriverUnlock(driver); if (!pool) { - virStorageReportError(VIR_ERR_NO_STORAGE_POOL, - "%s", _("no storage pool with matching uuid")); + virReportError(VIR_ERR_NO_STORAGE_POOL, + "%s", _("no storage pool with matching uuid")); goto cleanup; } if (!virStoragePoolObjIsActive(pool)) { - virStorageReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("storage pool is not active")); + virReportError(VIR_ERR_OPERATION_INVALID, + "%s", _("storage pool is not active")); goto cleanup; } @@ -2090,22 +2090,22 @@ storageVolumeDelete(virStorageVolPtr obj, vol = virStorageVolDefFindByName(pool, obj->name); if (!vol) { - virStorageReportError(VIR_ERR_NO_STORAGE_VOL, - _("no storage vol with matching name '%s'"), - obj->name); + virReportError(VIR_ERR_NO_STORAGE_VOL, + _("no storage vol with matching name '%s'"), + obj->name); goto cleanup; } if (vol->building) { - virStorageReportError(VIR_ERR_OPERATION_INVALID, - _("volume '%s' is still being allocated."), - vol->name); + virReportError(VIR_ERR_OPERATION_INVALID, + _("volume '%s' is still being allocated."), + vol->name); goto cleanup; } if (!backend->deleteVol) { - virStorageReportError(VIR_ERR_NO_SUPPORT, - "%s", _("storage pool does not support vol deletion")); + virReportError(VIR_ERR_NO_SUPPORT, + "%s", _("storage pool does not support vol deletion")); goto cleanup; } @@ -2154,23 +2154,23 @@ storageVolumeGetInfo(virStorageVolPtr obj, storageDriverUnlock(driver); if (!pool) { - virStorageReportError(VIR_ERR_NO_STORAGE_POOL, - "%s", _("no storage pool with matching uuid")); + virReportError(VIR_ERR_NO_STORAGE_POOL, + "%s", _("no storage pool with matching uuid")); goto cleanup; } if (!virStoragePoolObjIsActive(pool)) { - virStorageReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("storage pool is not active")); + virReportError(VIR_ERR_OPERATION_INVALID, + "%s", _("storage pool is not active")); goto cleanup; } vol = virStorageVolDefFindByName(pool, obj->name); if (!vol) { - virStorageReportError(VIR_ERR_NO_STORAGE_VOL, - _("no storage vol with matching name '%s'"), - obj->name); + virReportError(VIR_ERR_NO_STORAGE_VOL, + _("no storage vol with matching name '%s'"), + obj->name); goto cleanup; } @@ -2210,23 +2210,23 @@ storageVolumeGetXMLDesc(virStorageVolPtr obj, storageDriverUnlock(driver); if (!pool) { - virStorageReportError(VIR_ERR_NO_STORAGE_POOL, - "%s", _("no storage pool with matching uuid")); + virReportError(VIR_ERR_NO_STORAGE_POOL, + "%s", _("no storage pool with matching uuid")); goto cleanup; } if (!virStoragePoolObjIsActive(pool)) { - virStorageReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("storage pool is not active")); + virReportError(VIR_ERR_OPERATION_INVALID, + "%s", _("storage pool is not active")); goto cleanup; } vol = virStorageVolDefFindByName(pool, obj->name); if (!vol) { - virStorageReportError(VIR_ERR_NO_STORAGE_VOL, - _("no storage vol with matching name '%s'"), - obj->name); + virReportError(VIR_ERR_NO_STORAGE_VOL, + _("no storage vol with matching name '%s'"), + obj->name); goto cleanup; } @@ -2257,23 +2257,23 @@ storageVolumeGetPath(virStorageVolPtr obj) { pool = virStoragePoolObjFindByName(&driver->pools, obj->pool); storageDriverUnlock(driver); if (!pool) { - virStorageReportError(VIR_ERR_NO_STORAGE_POOL, - "%s", _("no storage pool with matching uuid")); + virReportError(VIR_ERR_NO_STORAGE_POOL, + "%s", _("no storage pool with matching uuid")); goto cleanup; } if (!virStoragePoolObjIsActive(pool)) { - virStorageReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("storage pool is not active")); + virReportError(VIR_ERR_OPERATION_INVALID, + "%s", _("storage pool is not active")); goto cleanup; } vol = virStorageVolDefFindByName(pool, obj->name); if (!vol) { - virStorageReportError(VIR_ERR_NO_STORAGE_VOL, - _("no storage vol with matching name '%s'"), - obj->name); + virReportError(VIR_ERR_NO_STORAGE_VOL, + _("no storage vol with matching name '%s'"), + obj->name); goto cleanup; } -- 1.7.10.4

On 07/18/2012 05:52 AM, Daniel P. Berrange wrote:
From: "Daniel P. Berrange" <berrange@redhat.com>
Update the storage driver to use virReportError instead of the virStorageReportError custom macro
Signed-off-by: Daniel P. Berrange <berrange@redhat.com> ---
Still big, but not as big as 7/13. Again, mostly mechanical, and I didn't spot any blatant problems. ACK.
+++ b/src/storage/storage_backend_rbd.c @@ -145,8 +145,8 @@ static int virStorageBackendRBDOpenRADOSConn(virStorageBackendRBDStatePtr *ptr, pool->def->source.hosts[i].name, pool->def->source.hosts[i].port); } else { - virStorageReportError(VIR_ERR_INTERNAL_ERROR, - _("received malformed monitor, check the XML definition")); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("received malformed monitor, check the XML definition"));
Another case of missing "%s", worth a separate cleanup patch. [hmm, wonder how hard it would be to make cfg.mk detect a message without a '%' as part of syntax-check, rather than the current approach of building with NLS disabled to trigger a gcc warning]
+++ b/src/storage/storage_driver.c @@ -475,7 +475,7 @@ static int storagePoolIsActive(virStoragePoolPtr pool) obj = virStoragePoolObjFindByUUID(&driver->pools, pool->uuid); storageDriverUnlock(driver); if (!obj) { - virStorageReportError(VIR_ERR_NO_STORAGE_POOL, NULL); + virReportError(VIR_ERR_NO_STORAGE_POOL, NULL);
While this still gives a working error message, it's pretty weak, and I've noticed that at least on FreeBSD, the gcc version tends to issue warnings about a NULL format string. Maybe someday we should require all errors to have a message, rather than our current practice of permitting NULL for a default message. Or perhaps we could trivially silence those warnings if we make the virReportError macro expand to 'format ? format : ""' instead of 'format', but then you get into issues that gcc also warns about passing "" as a format string. But that gets hairy fast to support a macro with no format string by default (witness VIR_HAS_COMMA and other goop in libvirt.c to allow VIR_DOMAIN_DEBUG() to be smart). So for now, nothing to change here, at least without a real report of a build failure somewhere. -- Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

On Wed, Jul 18, 2012 at 12:05:20PM -0600, Eric Blake wrote:
On 07/18/2012 05:52 AM, Daniel P. Berrange wrote:
From: "Daniel P. Berrange" <berrange@redhat.com>
Update the storage driver to use virReportError instead of the virStorageReportError custom macro
Signed-off-by: Daniel P. Berrange <berrange@redhat.com> ---
Still big, but not as big as 7/13. Again, mostly mechanical, and I didn't spot any blatant problems.
ACK.
+++ b/src/storage/storage_backend_rbd.c @@ -145,8 +145,8 @@ static int virStorageBackendRBDOpenRADOSConn(virStorageBackendRBDStatePtr *ptr, pool->def->source.hosts[i].name, pool->def->source.hosts[i].port); } else { - virStorageReportError(VIR_ERR_INTERNAL_ERROR, - _("received malformed monitor, check the XML definition")); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("received malformed monitor, check the XML definition"));
Another case of missing "%s", worth a separate cleanup patch. [hmm, wonder how hard it would be to make cfg.mk detect a message without a '%' as part of syntax-check, rather than the current approach of building with NLS disabled to trigger a gcc warning]
I've pushed a fix for this bug /before/ applying this change.
+++ b/src/storage/storage_driver.c @@ -475,7 +475,7 @@ static int storagePoolIsActive(virStoragePoolPtr pool) obj = virStoragePoolObjFindByUUID(&driver->pools, pool->uuid); storageDriverUnlock(driver); if (!obj) { - virStorageReportError(VIR_ERR_NO_STORAGE_POOL, NULL); + virReportError(VIR_ERR_NO_STORAGE_POOL, NULL);
While this still gives a working error message, it's pretty weak, and I've noticed that at least on FreeBSD, the gcc version tends to issue warnings about a NULL format string.
Yeah, there are quite a few areas of the code which pass a NULL error string that I've seen. Another thing to put on the TODO list.... Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|

From: "Daniel P. Berrange" <berrange@redhat.com> Update the secret driver to use virReportError instead of the virSecretReportError custom macro Signed-off-by: Daniel P. Berrange <berrange@redhat.com> --- cfg.mk | 1 - src/secret/secret_driver.c | 70 +++++++++++++++++++++----------------------- 2 files changed, 33 insertions(+), 38 deletions(-) diff --git a/cfg.mk b/cfg.mk index 3363aa2..d1a6d23 100644 --- a/cfg.mk +++ b/cfg.mk @@ -547,7 +547,6 @@ msg_gen_function += virRaiseError msg_gen_function += virReportError msg_gen_function += virReportErrorHelper msg_gen_function += virReportSystemError -msg_gen_function += virSecretReportError msg_gen_function += virSecurityReportError msg_gen_function += virXenInotifyError msg_gen_function += virXenStoreError diff --git a/src/secret/secret_driver.c b/src/secret/secret_driver.c index cf2315a..af3bfcf 100644 --- a/src/secret/secret_driver.c +++ b/src/secret/secret_driver.c @@ -45,10 +45,6 @@ #define VIR_FROM_THIS VIR_FROM_SECRET -#define virSecretReportError(code, ...) \ - virReportErrorHelper(VIR_FROM_SECRET, code, __FILE__, \ - __FUNCTION__, __LINE__, __VA_ARGS__) - enum { SECRET_MAX_XML_FILE = 10*1024*1024 }; /* Internal driver state */ @@ -354,9 +350,9 @@ secretLoadValidateUUID(virSecretDefPtr def, virUUIDFormat(def->uuid, uuidstr); if (!virFileMatchesNameSuffix(xml_basename, uuidstr, ".xml")) { - virSecretReportError(VIR_ERR_INTERNAL_ERROR, - _("<uuid> does not match secret file name '%s'"), - xml_basename); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("<uuid> does not match secret file name '%s'"), + xml_basename); return -1; } @@ -390,8 +386,8 @@ secretLoadValue(virSecretDriverStatePtr driver, goto cleanup; } if ((size_t)st.st_size != st.st_size) { - virSecretReportError(VIR_ERR_INTERNAL_ERROR, - _("'%s' file does not fit in memory"), filename); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("'%s' file does not fit in memory"), filename); goto cleanup; } @@ -406,8 +402,8 @@ secretLoadValue(virSecretDriverStatePtr driver, VIR_FORCE_CLOSE(fd); if (!base64_decode_alloc(contents, st.st_size, &value, &value_size)) { - virSecretReportError(VIR_ERR_INTERNAL_ERROR, - _("invalid base64 in '%s'"), filename); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("invalid base64 in '%s'"), filename); goto cleanup; } if (value == NULL) { @@ -637,8 +633,8 @@ secretLookupByUUID(virConnectPtr conn, const unsigned char *uuid) if (secret == NULL) { char uuidstr[VIR_UUID_STRING_BUFLEN]; virUUIDFormat(uuid, uuidstr); - virSecretReportError(VIR_ERR_NO_SECRET, - _("no secret with matching uuid '%s'"), uuidstr); + virReportError(VIR_ERR_NO_SECRET, + _("no secret with matching uuid '%s'"), uuidstr); goto cleanup; } @@ -664,8 +660,8 @@ secretLookupByUsage(virConnectPtr conn, int usageType, const char *usageID) secret = secretFindByUsage(driver, usageType, usageID); if (secret == NULL) { - virSecretReportError(VIR_ERR_NO_SECRET, - _("no secret with matching usage '%s'"), usageID); + virReportError(VIR_ERR_NO_SECRET, + _("no secret with matching usage '%s'"), usageID); goto cleanup; } @@ -706,9 +702,9 @@ secretDefineXML(virConnectPtr conn, const char *xml, if (secret) { char uuidstr[VIR_UUID_STRING_BUFLEN]; virUUIDFormat(secret->def->uuid, uuidstr); - virSecretReportError(VIR_ERR_INTERNAL_ERROR, - _("a secret with UUID %s already defined for use with %s"), - uuidstr, usageID); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("a secret with UUID %s already defined for use with %s"), + uuidstr, usageID); goto cleanup; } @@ -726,15 +722,15 @@ secretDefineXML(virConnectPtr conn, const char *xml, if (STRNEQ(oldUsageID, newUsageID)) { char uuidstr[VIR_UUID_STRING_BUFLEN]; virUUIDFormat(secret->def->uuid, uuidstr); - virSecretReportError(VIR_ERR_INTERNAL_ERROR, - _("a secret with UUID %s is already defined for use with %s"), - uuidstr, oldUsageID); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("a secret with UUID %s is already defined for use with %s"), + uuidstr, oldUsageID); goto cleanup; } if (secret->def->private && !new_attrs->private) { - virSecretReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("cannot change private flag on existing secret")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("cannot change private flag on existing secret")); goto cleanup; } @@ -781,8 +777,8 @@ restore_backup: } else { /* "secret" was added to the head of the list above */ if (listUnlink(&driverState->secrets) != secret) - virSecretReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("list of secrets is inconsistent")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("list of secrets is inconsistent")); else secretFree(secret); } @@ -809,8 +805,8 @@ secretGetXMLDesc(virSecretPtr obj, unsigned int flags) if (secret == NULL) { char uuidstr[VIR_UUID_STRING_BUFLEN]; virUUIDFormat(obj->uuid, uuidstr); - virSecretReportError(VIR_ERR_NO_SECRET, - _("no secret with matching uuid '%s'"), uuidstr); + virReportError(VIR_ERR_NO_SECRET, + _("no secret with matching uuid '%s'"), uuidstr); goto cleanup; } @@ -845,8 +841,8 @@ secretSetValue(virSecretPtr obj, const unsigned char *value, if (secret == NULL) { char uuidstr[VIR_UUID_STRING_BUFLEN]; virUUIDFormat(obj->uuid, uuidstr); - virSecretReportError(VIR_ERR_NO_SECRET, - _("no secret with matching uuid '%s'"), uuidstr); + virReportError(VIR_ERR_NO_SECRET, + _("no secret with matching uuid '%s'"), uuidstr); goto cleanup; } @@ -900,23 +896,23 @@ secretGetValue(virSecretPtr obj, size_t *value_size, unsigned int flags, if (secret == NULL) { char uuidstr[VIR_UUID_STRING_BUFLEN]; virUUIDFormat(obj->uuid, uuidstr); - virSecretReportError(VIR_ERR_NO_SECRET, - _("no secret with matching uuid '%s'"), uuidstr); + virReportError(VIR_ERR_NO_SECRET, + _("no secret with matching uuid '%s'"), uuidstr); goto cleanup; } if (secret->value == NULL) { char uuidstr[VIR_UUID_STRING_BUFLEN]; virUUIDFormat(obj->uuid, uuidstr); - virSecretReportError(VIR_ERR_NO_SECRET, - _("secret '%s' does not have a value"), uuidstr); + virReportError(VIR_ERR_NO_SECRET, + _("secret '%s' does not have a value"), uuidstr); goto cleanup; } if ((internalFlags & VIR_SECRET_GET_VALUE_INTERNAL_CALL) == 0 && secret->def->private) { - virSecretReportError(VIR_ERR_OPERATION_DENIED, "%s", - _("secret is private")); + virReportError(VIR_ERR_OPERATION_DENIED, "%s", + _("secret is private")); goto cleanup; } @@ -946,8 +942,8 @@ secretUndefine(virSecretPtr obj) if (secret == NULL) { char uuidstr[VIR_UUID_STRING_BUFLEN]; virUUIDFormat(obj->uuid, uuidstr); - virSecretReportError(VIR_ERR_NO_SECRET, - _("no secret with matching uuid '%s'"), uuidstr); + virReportError(VIR_ERR_NO_SECRET, + _("no secret with matching uuid '%s'"), uuidstr); goto cleanup; } -- 1.7.10.4

On 07/18/2012 05:52 AM, Daniel P. Berrange wrote:
From: "Daniel P. Berrange" <berrange@redhat.com>
Update the secret driver to use virReportError instead of the virSecretReportError custom macro
Signed-off-by: Daniel P. Berrange <berrange@redhat.com> --- cfg.mk | 1 - src/secret/secret_driver.c | 70 +++++++++++++++++++++----------------------- 2 files changed, 33 insertions(+), 38 deletions(-)
Much faster to review :) ACK. -- Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

From: "Daniel P. Berrange" <berrange@redhat.com> Update the node device driver to use virReportError instead of the virNodeDeviceReportError custom macro Signed-off-by: Daniel P. Berrange <berrange@redhat.com> --- cfg.mk | 1 - src/node_device/node_device_driver.c | 42 +++++++++++++++++----------------- src/node_device/node_device_driver.h | 4 ---- src/node_device/node_device_udev.c | 6 ++--- 4 files changed, 24 insertions(+), 29 deletions(-) diff --git a/cfg.mk b/cfg.mk index d1a6d23..f2a7e29 100644 --- a/cfg.mk +++ b/cfg.mk @@ -541,7 +541,6 @@ msg_gen_function += virLibNWFilterError msg_gen_function += virLibSecretError msg_gen_function += virLibStoragePoolError msg_gen_function += virLibStorageVolError -msg_gen_function += virNodeDeviceReportError msg_gen_function += virNWFilterReportError msg_gen_function += virRaiseError msg_gen_function += virReportError diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_device_driver.c index b0a29cd..83db775 100644 --- a/src/node_device/node_device_driver.c +++ b/src/node_device/node_device_driver.c @@ -196,7 +196,7 @@ nodeDeviceLookupByName(virConnectPtr conn, const char *name) nodeDeviceUnlock(driver); if (!obj) { - virNodeDeviceReportError(VIR_ERR_NO_NODE_DEVICE, NULL); + virReportError(VIR_ERR_NO_NODE_DEVICE, NULL); goto cleanup; } @@ -271,9 +271,9 @@ nodeDeviceGetXMLDesc(virNodeDevicePtr dev, nodeDeviceUnlock(driver); if (!obj) { - virNodeDeviceReportError(VIR_ERR_NO_NODE_DEVICE, - _("no node device with matching name '%s'"), - dev->name); + virReportError(VIR_ERR_NO_NODE_DEVICE, + _("no node device with matching name '%s'"), + dev->name); goto cleanup; } @@ -301,9 +301,9 @@ nodeDeviceGetParent(virNodeDevicePtr dev) nodeDeviceUnlock(driver); if (!obj) { - virNodeDeviceReportError(VIR_ERR_NO_NODE_DEVICE, - _("no node device with matching name '%s'"), - dev->name); + virReportError(VIR_ERR_NO_NODE_DEVICE, + _("no node device with matching name '%s'"), + dev->name); goto cleanup; } @@ -312,8 +312,8 @@ nodeDeviceGetParent(virNodeDevicePtr dev) if (!ret) virReportOOMError(); } else { - virNodeDeviceReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("no parent for this device")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("no parent for this device")); } cleanup: @@ -337,9 +337,9 @@ nodeDeviceNumOfCaps(virNodeDevicePtr dev) nodeDeviceUnlock(driver); if (!obj) { - virNodeDeviceReportError(VIR_ERR_NO_NODE_DEVICE, - _("no node device with matching name '%s'"), - dev->name); + virReportError(VIR_ERR_NO_NODE_DEVICE, + _("no node device with matching name '%s'"), + dev->name); goto cleanup; } @@ -368,9 +368,9 @@ nodeDeviceListCaps(virNodeDevicePtr dev, char **const names, int maxnames) nodeDeviceUnlock(driver); if (!obj) { - virNodeDeviceReportError(VIR_ERR_NO_NODE_DEVICE, - _("no node device with matching name '%s'"), - dev->name); + virReportError(VIR_ERR_NO_NODE_DEVICE, + _("no node device with matching name '%s'"), + dev->name); goto cleanup; } @@ -414,8 +414,8 @@ nodeDeviceVportCreateDelete(const int parent_host, operation_file = LINUX_SYSFS_VPORT_DELETE_POSTFIX; break; default: - virNodeDeviceReportError(VIR_ERR_INTERNAL_ERROR, - _("Invalid vport operation (%d)"), operation); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Invalid vport operation (%d)"), operation); retval = -1; goto cleanup; break; @@ -487,8 +487,8 @@ get_time(time_t *t) *t = time(NULL); if (*t == (time_t)-1) { - virNodeDeviceReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("Could not get current time")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("Could not get current time")); *t = 0; ret = -1; @@ -593,7 +593,7 @@ nodeDeviceCreateXML(virConnectPtr conn, * we're returning what we get... */ if (dev == NULL) { - virNodeDeviceReportError(VIR_ERR_NO_NODE_DEVICE, NULL); + virReportError(VIR_ERR_NO_NODE_DEVICE, NULL); } cleanup: @@ -619,7 +619,7 @@ nodeDeviceDestroy(virNodeDevicePtr dev) nodeDeviceUnlock(driver); if (!obj) { - virNodeDeviceReportError(VIR_ERR_NO_NODE_DEVICE, NULL); + virReportError(VIR_ERR_NO_NODE_DEVICE, NULL); goto out; } diff --git a/src/node_device/node_device_driver.h b/src/node_device/node_device_driver.h index c94e870..673e95b 100644 --- a/src/node_device/node_device_driver.h +++ b/src/node_device/node_device_driver.h @@ -28,10 +28,6 @@ # include "driver.h" # include "node_device_conf.h" -# define virNodeDeviceReportError(code, ...) \ - virReportErrorHelper(VIR_FROM_NODEDEV, code, __FILE__, \ - __FUNCTION__, __LINE__, __VA_ARGS__) - # define LINUX_SYSFS_SCSI_HOST_PREFIX "/sys/class/scsi_host/" # define LINUX_SYSFS_SCSI_HOST_POSTFIX "device" # define LINUX_SYSFS_FC_HOST_PREFIX "/sys/class/fc_host/" diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c index 6418015..aa96abd 100644 --- a/src/node_device/node_device_udev.c +++ b/src/node_device/node_device_udev.c @@ -1241,9 +1241,9 @@ static int udevSetParent(struct udev_device *device, parent_sysfs_path = udev_device_get_syspath(parent_device); if (parent_sysfs_path == NULL) { - virNodeDeviceReportError(VIR_ERR_INTERNAL_ERROR, - _("Could not get syspath for parent of '%s'"), - udev_device_get_syspath(parent_device)); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Could not get syspath for parent of '%s'"), + udev_device_get_syspath(parent_device)); goto out; } -- 1.7.10.4

On 07/18/2012 05:52 AM, Daniel P. Berrange wrote:
From: "Daniel P. Berrange" <berrange@redhat.com>
Update the node device driver to use virReportError instead of the virNodeDeviceReportError custom macro
Signed-off-by: Daniel P. Berrange <berrange@redhat.com> --- cfg.mk | 1 - src/node_device/node_device_driver.c | 42 +++++++++++++++++----------------- src/node_device/node_device_driver.h | 4 ---- src/node_device/node_device_udev.c | 6 ++--- 4 files changed, 24 insertions(+), 29 deletions(-)
ACK. -- Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

From: "Daniel P. Berrange" <berrange@redhat.com> Update the network filter driver to use virReportError instead of the virNWFilterReportError custom macro Signed-off-by: Daniel P. Berrange <berrange@redhat.com> --- cfg.mk | 1 - src/nwfilter/nwfilter_dhcpsnoop.c | 153 ++++++++++++++--------------- src/nwfilter/nwfilter_ebiptables_driver.c | 131 ++++++++++++------------ src/nwfilter/nwfilter_learnipaddr.c | 43 ++++---- 4 files changed, 159 insertions(+), 169 deletions(-) diff --git a/cfg.mk b/cfg.mk index f2a7e29..2f02562 100644 --- a/cfg.mk +++ b/cfg.mk @@ -541,7 +541,6 @@ msg_gen_function += virLibNWFilterError msg_gen_function += virLibSecretError msg_gen_function += virLibStoragePoolError msg_gen_function += virLibStorageVolError -msg_gen_function += virNWFilterReportError msg_gen_function += virRaiseError msg_gen_function += virReportError msg_gen_function += virReportErrorHelper diff --git a/src/nwfilter/nwfilter_dhcpsnoop.c b/src/nwfilter/nwfilter_dhcpsnoop.c index db367e1..13ec5bd 100644 --- a/src/nwfilter/nwfilter_dhcpsnoop.c +++ b/src/nwfilter/nwfilter_dhcpsnoop.c @@ -69,10 +69,6 @@ #define VIR_FROM_THIS VIR_FROM_NWFILTER -#define virNWFilterReportError(code, fmt...) \ - virReportErrorHelper(VIR_FROM_NWFILTER, code, __FILE__, \ - __FUNCTION__, __LINE__, fmt) - #ifdef HAVE_LIBPCAP # define LEASEFILE LOCALSTATEDIR "/run/libvirt/network/nwfilter.leases" @@ -576,11 +572,11 @@ virNWFilterSnoopReqNew(const char *ifkey) virNWFilterSnoopReqPtr req; if (ifkey == NULL || strlen(ifkey) != VIR_IFKEY_LEN - 1) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, - _("virNWFilterSnoopReqNew called with invalid " - "key \"%s\" (%zu)"), - ifkey ? ifkey : "", - strlen(ifkey)); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("virNWFilterSnoopReqNew called with invalid " + "key \"%s\" (%zu)"), + ifkey ? ifkey : "", + strlen(ifkey)); return NULL; } @@ -890,8 +886,8 @@ virNWFilterSnoopReqLeaseDel(virNWFilterSnoopReqPtr req, if (req->techdriver && req->techdriver->applyDHCPOnlyRules(req->ifname, &req->macaddr, dhcpsrvrs, false) < 0) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, - _("virNWFilterSnoopListDel failed")); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("virNWFilterSnoopListDel failed")); ret = -1; } @@ -1097,35 +1093,35 @@ virNWFilterSnoopDHCPOpen(const char *ifname, virMacAddr *mac, handle = pcap_create(ifname, pcap_errbuf); if (handle == NULL) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, - _("pcap_create failed")); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("pcap_create failed")); goto cleanup_nohandle; } if (pcap_set_snaplen(handle, PCAP_PBUFSIZE) < 0 || pcap_set_buffer_size(handle, PCAP_BUFFERSIZE) < 0 || pcap_activate(handle) < 0) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, - _("setup of pcap handle failed")); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("setup of pcap handle failed")); goto cleanup; } if (pcap_compile(handle, &fp, ext_filter, 1, PCAP_NETMASK_UNKNOWN) != 0) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, - _("pcap_compile: %s"), pcap_geterr(handle)); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("pcap_compile: %s"), pcap_geterr(handle)); goto cleanup; } if (pcap_setfilter(handle, &fp) != 0) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, - _("pcap_setfilter: %s"), pcap_geterr(handle)); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("pcap_setfilter: %s"), pcap_geterr(handle)); goto cleanup_freecode; } if (pcap_setdirection(handle, dir) < 0) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, - _("pcap_setdirection: %s"), - pcap_geterr(handle)); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("pcap_setdirection: %s"), + pcap_geterr(handle)); goto cleanup_freecode; } @@ -1158,9 +1154,9 @@ static void virNWFilterDHCPDecodeWorker(void *jobdata, void *opaque) job->caplen, job->fromVM) == -1) { req->jobCompletionStatus = -1; - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, - _("Instantiation of rules failed on " - "interface '%s'"), req->ifname); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Instantiation of rules failed on " + "interface '%s'"), req->ifname); } virAtomicIntDec(job->qCtr); VIR_FREE(job); @@ -1465,10 +1461,10 @@ virNWFilterDHCPSnoopThread(void *req0) /* protect req->ifname */ virNWFilterSnoopReqLock(req); - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, - _("interface '%s' failing; " - "reopening"), - req->ifname); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("interface '%s' failing; " + "reopening"), + req->ifname); if (req->ifname) pcapConf[i].handle = virNWFilterSnoopDHCPOpen(req->ifname, &req->macaddr, @@ -1519,9 +1515,9 @@ virNWFilterDHCPSnoopThread(void *req0) hdr->caplen, pcapConf[i].dir, &pcapConf[i].qCtr) < 0) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, - _("Job submission failed on " - "interface '%s'"), req->ifname); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Job submission failed on " + "interface '%s'"), req->ifname); error = true; break; } @@ -1625,10 +1621,10 @@ virNWFilterDHCPSnoopReq(virNWFilterTechDriverPtr techdriver, /* check that all tools are available for applying the filters (late) */ if ( !techdriver->canApplyBasicRules()) { - virNWFilterReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("IP parameter must be provided since " - "snooping the IP address does not work " - "possibly due to missing tools")); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("IP parameter must be provided since " + "snooping the IP address does not work " + "possibly due to missing tools")); goto exit_snoopreqput; } @@ -1637,15 +1633,16 @@ virNWFilterDHCPSnoopReq(virNWFilterTechDriverPtr techdriver, if (techdriver->applyDHCPOnlyRules(req->ifname, &req->macaddr, dhcpsrvrs, false) < 0) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, _("applyDHCPOnlyRules " - "failed - spoofing not protected!")); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("applyDHCPOnlyRules " + "failed - spoofing not protected!")); goto exit_snoopreqput; } if (virNWFilterHashTablePutAll(filterparams, req->vars) < 0) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, - _("virNWFilterDHCPSnoopReq: can't copy variables" - " on if %s"), ifkey); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("virNWFilterDHCPSnoopReq: can't copy variables" + " on if %s"), ifkey); goto exit_snoopreqput; } @@ -1653,19 +1650,19 @@ virNWFilterDHCPSnoopReq(virNWFilterTechDriverPtr techdriver, if (virHashAddEntry(virNWFilterSnoopState.ifnameToKey, ifname, req->ifkey) < 0) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, - _("virNWFilterDHCPSnoopReq ifname map failed" - " on interface \"%s\" key \"%s\""), ifname, - ifkey); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("virNWFilterDHCPSnoopReq ifname map failed" + " on interface \"%s\" key \"%s\""), ifname, + ifkey); goto exit_snoopunlock; } if (isnewreq && virHashAddEntry(virNWFilterSnoopState.snoopReqs, ifkey, req) < 0) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, - _("virNWFilterDHCPSnoopReq req add failed on" - " interface \"%s\" ifkey \"%s\""), ifname, - ifkey); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("virNWFilterDHCPSnoopReq req add failed on" + " interface \"%s\" ifkey \"%s\""), ifname, + ifkey); goto exit_rem_ifnametokey; } @@ -1674,9 +1671,9 @@ virNWFilterDHCPSnoopReq(virNWFilterTechDriverPtr techdriver, if (virThreadCreate(&thread, false, virNWFilterDHCPSnoopThread, req) != 0) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, - _("virNWFilterDHCPSnoopReq virThreadCreate " - "failed on interface '%s'"), ifname); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("virNWFilterDHCPSnoopReq virThreadCreate " + "failed on interface '%s'"), ifname); goto exit_snoopreq_unlock; } @@ -1684,16 +1681,16 @@ virNWFilterDHCPSnoopReq(virNWFilterTechDriverPtr techdriver, req->threadkey = virNWFilterSnoopActivate(req); if (!req->threadkey) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, - _("Activation of snoop request failed on " - "interface '%s'"), req->ifname); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Activation of snoop request failed on " + "interface '%s'"), req->ifname); goto exit_snoopreq_unlock; } if (virNWFilterSnoopReqRestore(req) < 0) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, - _("Restoring of leases failed on " - "interface '%s'"), req->ifname); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Restoring of leases failed on " + "interface '%s'"), req->ifname); goto exit_snoop_cancel; } @@ -1932,18 +1929,18 @@ virNWFilterSnoopLeaseFileLoad(void) time(&now); while (fp && fgets(line, sizeof(line), fp)) { if (line[strlen(line)-1] != '\n') { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, - _("virNWFilterSnoopLeaseFileLoad lease file " - "line %d corrupt"), ln); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("virNWFilterSnoopLeaseFileLoad lease file " + "line %d corrupt"), ln); break; } ln++; /* key len 55 = "VMUUID"+'-'+"MAC" */ if (sscanf(line, "%u %55s %16s %16s", &ipl.timeout, ifkey, ipstr, srvstr) < 4) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, - _("virNWFilterSnoopLeaseFileLoad lease file " - "line %d corrupt"), ln); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("virNWFilterSnoopLeaseFileLoad lease file " + "line %d corrupt"), ln); break; } if (ipl.timeout && ipl.timeout < now) @@ -1958,17 +1955,17 @@ virNWFilterSnoopLeaseFileLoad(void) if (tmp < 0) { virNWFilterSnoopReqPut(req); - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, - _("virNWFilterSnoopLeaseFileLoad req add" - " failed on interface \"%s\""), ifkey); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("virNWFilterSnoopLeaseFileLoad req add" + " failed on interface \"%s\""), ifkey); continue; } } if (virSocketAddrParseIPv4(&ipl.ipAddress, ipstr) < 0) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, - _("line %d corrupt ipaddr \"%s\""), - ln, ipstr); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("line %d corrupt ipaddr \"%s\""), + ln, ipstr); virNWFilterSnoopReqPut(req); continue; } @@ -2113,8 +2110,8 @@ virNWFilterDHCPSnoopEnd(const char *ifname) ifkey = (char *)virHashLookup(virNWFilterSnoopState.ifnameToKey, ifname); if (!ifkey) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, - _("ifname \"%s\" not in key map"), ifname); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("ifname \"%s\" not in key map"), ifname); goto cleanup; } @@ -2127,8 +2124,8 @@ virNWFilterDHCPSnoopEnd(const char *ifname) req = virNWFilterSnoopReqGetByIFKey(ifkey); if (!req) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, - _("ifkey \"%s\" has no req"), ifkey); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("ifkey \"%s\" has no req"), ifkey); goto cleanup; } @@ -2209,10 +2206,10 @@ virNWFilterDHCPSnoopReq(virNWFilterTechDriverPtr techdriver ATTRIBUTE_UNUSED, virNWFilterHashTablePtr filterparams ATTRIBUTE_UNUSED, virNWFilterDriverStatePtr driver ATTRIBUTE_UNUSED) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, - _("libvirt was not compiled with libpcap and \"" - NWFILTER_VARNAME_CTRL_IP_LEARNING - "='dhcp'\" requires it.")); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("libvirt was not compiled with libpcap and \"" + NWFILTER_VARNAME_CTRL_IP_LEARNING + "='dhcp'\" requires it.")); return -1; } #endif /* HAVE_LIBPCAP */ diff --git a/src/nwfilter/nwfilter_ebiptables_driver.c b/src/nwfilter/nwfilter_ebiptables_driver.c index cbf6d14..18195c3 100644 --- a/src/nwfilter/nwfilter_ebiptables_driver.c +++ b/src/nwfilter/nwfilter_ebiptables_driver.c @@ -45,9 +45,6 @@ #define VIR_FROM_THIS VIR_FROM_NWFILTER -#define virNWFilterReportError(code, fmt...) \ - virReportErrorHelper(VIR_FROM_NWFILTER, code, __FILE__, \ - __FUNCTION__, __LINE__, fmt) #define EBTABLES_CHAIN_INCOMING "PREROUTING" #define EBTABLES_CHAIN_OUTGOING "POSTROUTING" @@ -242,9 +239,9 @@ printVar(virNWFilterVarCombIterPtr vars, const char *varName; varName = virNWFilterVarAccessGetVarName(item->varAccess); - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, - _("Buffer too small to print variable " - "'%s' into"), varName); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Buffer too small to print variable " + "'%s' into"), varName); return -1; } @@ -278,8 +275,8 @@ _printDataType(virNWFilterVarCombIterPtr vars, if (!data) return -1; if (snprintf(buf, bufsize, "%s", data) >= bufsize) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("buffer too small for IP address")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("buffer too small for IP address")); VIR_FREE(data); return -1; } @@ -292,8 +289,8 @@ _printDataType(virNWFilterVarCombIterPtr vars, return -1; if (snprintf(buf, bufsize, "%s", data) >= bufsize) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("buffer too small for IPv6 address")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("buffer too small for IPv6 address")); VIR_FREE(data); return -1; } @@ -303,8 +300,8 @@ _printDataType(virNWFilterVarCombIterPtr vars, case DATATYPE_MACADDR: case DATATYPE_MACMASK: if (bufsize < VIR_MAC_STRING_BUFLEN) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Buffer too small for MAC address")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Buffer too small for MAC address")); return -1; } @@ -315,8 +312,8 @@ _printDataType(virNWFilterVarCombIterPtr vars, case DATATYPE_IPMASK: if (snprintf(buf, bufsize, "%d", item->u.u8) >= bufsize) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Buffer too small for uint8 type")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Buffer too small for uint8 type")); return -1; } break; @@ -325,8 +322,8 @@ _printDataType(virNWFilterVarCombIterPtr vars, case DATATYPE_UINT32_HEX: if (snprintf(buf, bufsize, asHex ? "0x%x" : "%u", item->u.u32) >= bufsize) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Buffer too small for uint32 type")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Buffer too small for uint32 type")); return -1; } break; @@ -335,8 +332,8 @@ _printDataType(virNWFilterVarCombIterPtr vars, case DATATYPE_UINT16_HEX: if (snprintf(buf, bufsize, asHex ? "0x%x" : "%d", item->u.u16) >= bufsize) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Buffer too small for uint16 type")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Buffer too small for uint16 type")); return -1; } break; @@ -345,16 +342,16 @@ _printDataType(virNWFilterVarCombIterPtr vars, case DATATYPE_UINT8_HEX: if (snprintf(buf, bufsize, asHex ? "0x%x" : "%d", item->u.u8) >= bufsize) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Buffer too small for uint8 type")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Buffer too small for uint8 type")); return -1; } break; case DATATYPE_IPSETNAME: if (virStrcpy(buf, item->u.ipset.setname, bufsize) == NULL) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Buffer to small for ipset name")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Buffer to small for ipset name")); return -1; } break; @@ -385,8 +382,8 @@ _printDataType(virNWFilterVarCombIterPtr vars, flags = virBufferContentAndReset(&vb); if (virStrcpy(buf, flags, bufsize) == NULL) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Buffer too small for IPSETFLAGS type")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Buffer too small for IPSETFLAGS type")); VIR_FREE(flags); return -1; } @@ -394,8 +391,8 @@ _printDataType(virNWFilterVarCombIterPtr vars, break; default: - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, - _("Unhandled datatype %x"), item->datatype); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Unhandled datatype %x"), item->datatype); return -1; break; } @@ -1297,10 +1294,10 @@ _iptablesCreateRuleInstance(int directionIn, bool hasICMPType = false; if (!iptables_cmd) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, - _("cannot create rule since %s tool is " - "missing."), - isIPv6 ? "ip6tables" : "iptables"); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("cannot create rule since %s tool is " + "missing."), + isIPv6 ? "ip6tables" : "iptables"); goto err_exit; } @@ -2015,9 +2012,9 @@ ebtablesCreateRuleInstance(char chainPrefix, const char *target; if (!ebtables_cmd_path) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("cannot create rule since ebtables tool is " - "missing.")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("cannot create rule since ebtables tool is " + "missing.")); goto err_exit; } @@ -2116,11 +2113,11 @@ ebtablesCreateRuleInstance(char chainPrefix, since this clashes with -d below... */ if (reverse && HAS_ENTRY_ITEM(&rule->p.stpHdrFilter.ethHdr.dataSrcMACAddr)) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, - _("STP filtering in %s direction with " - "source MAC address set is not supported"), - virNWFilterRuleDirectionTypeToString( - VIR_NWFILTER_RULE_DIRECTION_INOUT)); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("STP filtering in %s direction with " + "source MAC address set is not supported"), + virNWFilterRuleDirectionTypeToString( + VIR_NWFILTER_RULE_DIRECTION_INOUT)); return -1; } @@ -2683,8 +2680,8 @@ ebiptablesCreateRuleInstance(enum virDomainNetType nettype ATTRIBUTE_UNUSED, break; case VIR_NWFILTER_RULE_PROTOCOL_LAST: - virNWFilterReportError(VIR_ERR_OPERATION_FAILED, - "%s", _("illegal protocol type")); + virReportError(VIR_ERR_OPERATION_FAILED, + "%s", _("illegal protocol type")); rc = -1; break; } @@ -3199,9 +3196,9 @@ ebtablesApplyBasicRules(const char *ifname, char macaddr_str[VIR_MAC_STRING_BUFLEN]; if (!ebtables_cmd_path) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("cannot create rules since ebtables tool is " - "missing.")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("cannot create rules since ebtables tool is " + "missing.")); return -1; } @@ -3257,9 +3254,9 @@ ebtablesApplyBasicRules(const char *ifname, tear_down_tmpebchains: ebtablesCleanAll(ifname); - virNWFilterReportError(VIR_ERR_BUILD_FIREWALL, - "%s", - _("Some rules could not be created.")); + virReportError(VIR_ERR_BUILD_FIREWALL, + "%s", + _("Some rules could not be created.")); return -1; } @@ -3296,9 +3293,9 @@ ebtablesApplyDHCPOnlyRules(const char *ifname, unsigned int num_dhcpsrvrs; if (!ebtables_cmd_path) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("cannot create rules since ebtables tool is " - "missing.")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("cannot create rules since ebtables tool is " + "missing.")); return -1; } @@ -3400,9 +3397,9 @@ ebtablesApplyDHCPOnlyRules(const char *ifname, tear_down_tmpebchains: ebtablesCleanAll(ifname); - virNWFilterReportError(VIR_ERR_BUILD_FIREWALL, - "%s", - _("Some rules could not be created.")); + virReportError(VIR_ERR_BUILD_FIREWALL, + "%s", + _("Some rules could not be created.")); return -1; } @@ -3425,9 +3422,9 @@ ebtablesApplyDropAllRules(const char *ifname) chain_out[MAX_CHAINNAME_LENGTH]; if (!ebtables_cmd_path) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("cannot create rules since ebtables tool is " - "missing.")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("cannot create rules since ebtables tool is " + "missing.")); return -1; } @@ -3470,9 +3467,9 @@ ebtablesApplyDropAllRules(const char *ifname) tear_down_tmpebchains: ebtablesCleanAll(ifname); - virNWFilterReportError(VIR_ERR_BUILD_FIREWALL, - "%s", - _("Some rules could not be created.")); + virReportError(VIR_ERR_BUILD_FIREWALL, + "%s", + _("Some rules could not be created.")); return -1; } @@ -3903,12 +3900,12 @@ tear_down_tmpebchains: ebiptablesExecCLI(&buf, &cli_status, NULL); - virNWFilterReportError(VIR_ERR_BUILD_FIREWALL, - _("Some rules could not be created for " - "interface %s%s%s"), - ifname, - errmsg ? ": " : "", - errmsg ? errmsg : ""); + virReportError(VIR_ERR_BUILD_FIREWALL, + _("Some rules could not be created for " + "interface %s%s%s"), + ifname, + errmsg ? ": " : "", + errmsg ? errmsg : ""); exit_free_sets: virHashFree(chains_in_set); @@ -4042,9 +4039,9 @@ ebiptablesRemoveRules(const char *ifname ATTRIBUTE_UNUSED, goto err_exit; if (cli_status) { - virNWFilterReportError(VIR_ERR_BUILD_FIREWALL, - "%s", - _("error while executing CLI commands")); + virReportError(VIR_ERR_BUILD_FIREWALL, + "%s", + _("error while executing CLI commands")); rc = -1; } diff --git a/src/nwfilter/nwfilter_learnipaddr.c b/src/nwfilter/nwfilter_learnipaddr.c index d5005eb..f86fc97 100644 --- a/src/nwfilter/nwfilter_learnipaddr.c +++ b/src/nwfilter/nwfilter_learnipaddr.c @@ -56,9 +56,6 @@ #include "nwfilter_learnipaddr.h" #define VIR_FROM_THIS VIR_FROM_NWFILTER -#define virNWFilterReportError(code, fmt...) \ - virReportErrorHelper(VIR_FROM_NWFILTER, code, __FILE__, \ - __FUNCTION__, __LINE__, fmt) #define IFINDEX2STR(VARNAME, ifindex) \ char VARNAME[INT_BUFSIZE_BOUND(ifindex)]; \ @@ -151,17 +148,17 @@ virNWFilterLockIface(const char *ifname) { } if (virMutexInitRecursive(&ifaceLock->lock) < 0) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("mutex initialization failed")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("mutex initialization failed")); VIR_FREE(ifaceLock); goto err_exit; } if (virStrcpyStatic(ifaceLock->ifname, ifname) == NULL) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, - _("interface name %s does not fit into " - "buffer "), - ifaceLock->ifname); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("interface name %s does not fit into " + "buffer "), + ifaceLock->ifname); VIR_FREE(ifaceLock); goto err_exit; } @@ -675,10 +672,10 @@ virNWFilterLearnIPAddress(virNWFilterTechDriverPtr techdriver, return -1; if ( !techdriver->canApplyBasicRules()) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("IP parameter must be provided since " - "snooping the IP address does not work " - "possibly due to missing tools")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("IP parameter must be provided since " + "snooping the IP address does not work " + "possibly due to missing tools")); return -1; } @@ -703,17 +700,17 @@ virNWFilterLearnIPAddress(virNWFilterTechDriverPtr techdriver, } if (virStrcpyStatic(req->ifname, ifname) == NULL) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, - _("Destination buffer for ifname ('%s') " - "not large enough"), ifname); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Destination buffer for ifname ('%s') " + "not large enough"), ifname); goto err_free_ht; } if (linkdev) { if (virStrcpyStatic(req->linkdev, linkdev) == NULL) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, - _("Destination buffer for linkdev ('%s') " - "not large enough"), linkdev); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Destination buffer for linkdev ('%s') " + "not large enough"), linkdev); goto err_free_ht; } } @@ -763,10 +760,10 @@ virNWFilterLearnIPAddress(virNWFilterTechDriverPtr techdriver ATTRIBUTE_UNUSED, virNWFilterHashTablePtr filterparams ATTRIBUTE_UNUSED, virNWFilterDriverStatePtr driver ATTRIBUTE_UNUSED, enum howDetect howDetect ATTRIBUTE_UNUSED) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("IP parameter must be given since libvirt " - "was not compiled with IP address learning " - "support")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("IP parameter must be given since libvirt " + "was not compiled with IP address learning " + "support")); return -1; } #endif /* HAVE_LIBPCAP */ -- 1.7.10.4

On 07/18/2012 05:52 AM, Daniel P. Berrange wrote:
From: "Daniel P. Berrange" <berrange@redhat.com>
Update the network filter driver to use virReportError instead of the virNWFilterReportError custom macro
Signed-off-by: Daniel P. Berrange <berrange@redhat.com> ---
+++ b/src/nwfilter/nwfilter_dhcpsnoop.c @@ -1097,35 +1093,35 @@ virNWFilterSnoopDHCPOpen(const char *ifname, virMacAddr *mac, handle = pcap_create(ifname, pcap_errbuf);
if (handle == NULL) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, - _("pcap_create failed")); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("pcap_create failed"));
Missing a %s.
goto cleanup_nohandle; }
if (pcap_set_snaplen(handle, PCAP_PBUFSIZE) < 0 || pcap_set_buffer_size(handle, PCAP_BUFFERSIZE) < 0 || pcap_activate(handle) < 0) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, - _("setup of pcap handle failed")); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("setup of pcap handle failed"));
and again.
+++ b/src/nwfilter/nwfilter_ebiptables_driver.c @@ -2683,8 +2680,8 @@ ebiptablesCreateRuleInstance(enum virDomainNetType nettype ATTRIBUTE_UNUSED, break;
case VIR_NWFILTER_RULE_PROTOCOL_LAST: - virNWFilterReportError(VIR_ERR_OPERATION_FAILED, - "%s", _("illegal protocol type")); + virReportError(VIR_ERR_OPERATION_FAILED, + "%s", _("illegal protocol type"));
I hate the word 'illegal' in error messages - the user didn't break a law, they just violated constraints. 'invalid' is nicer. But that's a separate cleanup.
+++ b/src/nwfilter/nwfilter_learnipaddr.c @@ -151,17 +148,17 @@ virNWFilterLockIface(const char *ifname) {
if (virStrcpyStatic(ifaceLock->ifname, ifname) == NULL) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, - _("interface name %s does not fit into " - "buffer "), - ifaceLock->ifname); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("interface name %s does not fit into " + "buffer "),
This might fit in 80 columns without the split format string now. But rewrapping format strings is not necessary for this series. ACK. -- Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

From: "Daniel P. Berrange" <berrange@redhat.com> Update the netcf driver to use virReportError instead of the interfaceReportError custom macro --- cfg.mk | 1 - src/interface/netcf_driver.c | 150 ++++++++++++++++++++---------------------- 2 files changed, 73 insertions(+), 78 deletions(-) diff --git a/cfg.mk b/cfg.mk index 2f02562..ed2838c 100644 --- a/cfg.mk +++ b/cfg.mk @@ -513,7 +513,6 @@ msg_gen_function += PHYP_ERROR msg_gen_function += VIR_ERROR msg_gen_function += VMX_ERROR msg_gen_function += XENXS_ERROR -msg_gen_function += interfaceReportError msg_gen_function += lxcError msg_gen_function += libxlError msg_gen_function += networkReportError diff --git a/src/interface/netcf_driver.c b/src/interface/netcf_driver.c index 45e6442..39fa721 100644 --- a/src/interface/netcf_driver.c +++ b/src/interface/netcf_driver.c @@ -33,10 +33,6 @@ #define VIR_FROM_THIS VIR_FROM_INTERFACE -#define interfaceReportError(code, ...) \ - virReportErrorHelper(VIR_FROM_THIS, code, __FILE__, \ - __FUNCTION__, __LINE__, __VA_ARGS__) - /* Main driver state */ struct interface_driver { @@ -106,14 +102,14 @@ static struct netcf_if *interfaceDriverGetNetcfIF(struct netcf *ncf, virInterfac const char *errmsg, *details; int errcode = ncf_error(ncf, &errmsg, &details); if (errcode != NETCF_NOERROR) { - interfaceReportError(netcf_to_vir_err(errcode), - _("couldn't find interface named '%s': %s%s%s"), - ifinfo->name, errmsg, details ? " - " : "", - details ? details : ""); + virReportError(netcf_to_vir_err(errcode), + _("couldn't find interface named '%s': %s%s%s"), + ifinfo->name, errmsg, details ? " - " : "", + details ? details : ""); } else { - interfaceReportError(VIR_ERR_NO_INTERFACE, - _("couldn't find interface named '%s'"), - ifinfo->name); + virReportError(VIR_ERR_NO_INTERFACE, + _("couldn't find interface named '%s'"), + ifinfo->name); } } return iface; @@ -190,9 +186,9 @@ static int interfaceNumOfInterfaces(virConnectPtr conn) if (count < 0) { const char *errmsg, *details; int errcode = ncf_error(driver->netcf, &errmsg, &details); - interfaceReportError(netcf_to_vir_err(errcode), - _("failed to get number of interfaces on host: %s%s%s"), - errmsg, details ? " - " : "", details ? details : ""); + virReportError(netcf_to_vir_err(errcode), + _("failed to get number of interfaces on host: %s%s%s"), + errmsg, details ? " - " : "", details ? details : ""); } interfaceDriverUnlock(driver); @@ -210,10 +206,10 @@ static int interfaceListInterfaces(virConnectPtr conn, char **const names, int n if (count < 0) { const char *errmsg, *details; int errcode = ncf_error(driver->netcf, &errmsg, &details); - interfaceReportError(netcf_to_vir_err(errcode), - _("failed to list host interfaces: %s%s%s"), - errmsg, details ? " - " : "", - details ? details : ""); + virReportError(netcf_to_vir_err(errcode), + _("failed to list host interfaces: %s%s%s"), + errmsg, details ? " - " : "", + details ? details : ""); } interfaceDriverUnlock(driver); @@ -231,10 +227,10 @@ static int interfaceNumOfDefinedInterfaces(virConnectPtr conn) if (count < 0) { const char *errmsg, *details; int errcode = ncf_error(driver->netcf, &errmsg, &details); - interfaceReportError(netcf_to_vir_err(errcode), - _("failed to get number of defined interfaces on host: %s%s%s"), - errmsg, details ? " - " : "", - details ? details : ""); + virReportError(netcf_to_vir_err(errcode), + _("failed to get number of defined interfaces on host: %s%s%s"), + errmsg, details ? " - " : "", + details ? details : ""); } interfaceDriverUnlock(driver); @@ -252,10 +248,10 @@ static int interfaceListDefinedInterfaces(virConnectPtr conn, char **const names if (count < 0) { const char *errmsg, *details; int errcode = ncf_error(driver->netcf, &errmsg, &details); - interfaceReportError(netcf_to_vir_err(errcode), - _("failed to list host defined interfaces: %s%s%s"), - errmsg, details ? " - " : "", - details ? details : ""); + virReportError(netcf_to_vir_err(errcode), + _("failed to list host defined interfaces: %s%s%s"), + errmsg, details ? " - " : "", + details ? details : ""); } interfaceDriverUnlock(driver); @@ -276,13 +272,13 @@ static virInterfacePtr interfaceLookupByName(virConnectPtr conn, const char *errmsg, *details; int errcode = ncf_error(driver->netcf, &errmsg, &details); if (errcode != NETCF_NOERROR) { - interfaceReportError(netcf_to_vir_err(errcode), - _("couldn't find interface named '%s': %s%s%s"), - name, errmsg, - details ? " - " : "", details ? details : ""); + virReportError(netcf_to_vir_err(errcode), + _("couldn't find interface named '%s': %s%s%s"), + name, errmsg, + details ? " - " : "", details ? details : ""); } else { - interfaceReportError(VIR_ERR_NO_INTERFACE, - _("couldn't find interface named '%s'"), name); + virReportError(VIR_ERR_NO_INTERFACE, + _("couldn't find interface named '%s'"), name); } goto cleanup; } @@ -309,21 +305,21 @@ static virInterfacePtr interfaceLookupByMACString(virConnectPtr conn, if (niface < 0) { const char *errmsg, *details; int errcode = ncf_error(driver->netcf, &errmsg, &details); - interfaceReportError(netcf_to_vir_err(errcode), - _("couldn't find interface with MAC address '%s': %s%s%s"), - macstr, errmsg, details ? " - " : "", - details ? details : ""); + virReportError(netcf_to_vir_err(errcode), + _("couldn't find interface with MAC address '%s': %s%s%s"), + macstr, errmsg, details ? " - " : "", + details ? details : ""); goto cleanup; } if (niface == 0) { - interfaceReportError(VIR_ERR_NO_INTERFACE, - _("couldn't find interface with MAC address '%s'"), - macstr); + virReportError(VIR_ERR_NO_INTERFACE, + _("couldn't find interface with MAC address '%s'"), + macstr); goto cleanup; } if (niface > 1) { - interfaceReportError(VIR_ERR_MULTIPLE_INTERFACES, - "%s", _("multiple interfaces with matching MAC address")); + virReportError(VIR_ERR_MULTIPLE_INTERFACES, + "%s", _("multiple interfaces with matching MAC address")); goto cleanup; } @@ -362,10 +358,10 @@ static char *interfaceGetXMLDesc(virInterfacePtr ifinfo, if (!xmlstr) { const char *errmsg, *details; int errcode = ncf_error(driver->netcf, &errmsg, &details); - interfaceReportError(netcf_to_vir_err(errcode), - _("could not get interface XML description: %s%s%s"), - errmsg, details ? " - " : "", - details ? details : ""); + virReportError(netcf_to_vir_err(errcode), + _("could not get interface XML description: %s%s%s"), + errmsg, details ? " - " : "", + details ? details : ""); goto cleanup; } @@ -419,10 +415,10 @@ static virInterfacePtr interfaceDefineXML(virConnectPtr conn, if (!iface) { const char *errmsg, *details; int errcode = ncf_error(driver->netcf, &errmsg, &details); - interfaceReportError(netcf_to_vir_err(errcode), - _("could not get interface XML description: %s%s%s"), - errmsg, details ? " - " : "", - details ? details : ""); + virReportError(netcf_to_vir_err(errcode), + _("could not get interface XML description: %s%s%s"), + errmsg, details ? " - " : "", + details ? details : ""); goto cleanup; } @@ -453,10 +449,10 @@ static int interfaceUndefine(virInterfacePtr ifinfo) { if (ret < 0) { const char *errmsg, *details; int errcode = ncf_error(driver->netcf, &errmsg, &details); - interfaceReportError(netcf_to_vir_err(errcode), - _("failed to undefine interface %s: %s%s%s"), - ifinfo->name, errmsg, details ? " - " : "", - details ? details : ""); + virReportError(netcf_to_vir_err(errcode), + _("failed to undefine interface %s: %s%s%s"), + ifinfo->name, errmsg, details ? " - " : "", + details ? details : ""); goto cleanup; } @@ -487,10 +483,10 @@ static int interfaceCreate(virInterfacePtr ifinfo, if (ret < 0) { const char *errmsg, *details; int errcode = ncf_error(driver->netcf, &errmsg, &details); - interfaceReportError(netcf_to_vir_err(errcode), - _("failed to create (start) interface %s: %s%s%s"), - ifinfo->name, errmsg, details ? " - " : "", - details ? details : ""); + virReportError(netcf_to_vir_err(errcode), + _("failed to create (start) interface %s: %s%s%s"), + ifinfo->name, errmsg, details ? " - " : "", + details ? details : ""); goto cleanup; } @@ -521,10 +517,10 @@ static int interfaceDestroy(virInterfacePtr ifinfo, if (ret < 0) { const char *errmsg, *details; int errcode = ncf_error(driver->netcf, &errmsg, &details); - interfaceReportError(netcf_to_vir_err(errcode), - _("failed to destroy (stop) interface %s: %s%s%s"), - ifinfo->name, errmsg, details ? " - " : "", - details ? details : ""); + virReportError(netcf_to_vir_err(errcode), + _("failed to destroy (stop) interface %s: %s%s%s"), + ifinfo->name, errmsg, details ? " - " : "", + details ? details : ""); goto cleanup; } @@ -552,10 +548,10 @@ static int interfaceIsActive(virInterfacePtr ifinfo) if (ncf_if_status(iface, &flags) < 0) { const char *errmsg, *details; int errcode = ncf_error(driver->netcf, &errmsg, &details); - interfaceReportError(netcf_to_vir_err(errcode), - _("failed to get status of interface %s: %s%s%s"), - ifinfo->name, errmsg, details ? " - " : "", - details ? details : ""); + virReportError(netcf_to_vir_err(errcode), + _("failed to get status of interface %s: %s%s%s"), + ifinfo->name, errmsg, details ? " - " : "", + details ? details : ""); goto cleanup; } @@ -581,10 +577,10 @@ static int interfaceChangeBegin(virConnectPtr conn, unsigned int flags) if (ret < 0) { const char *errmsg, *details; int errcode = ncf_error(driver->netcf, &errmsg, &details); - interfaceReportError(netcf_to_vir_err(errcode), - _("failed to begin transaction: %s%s%s"), - errmsg, details ? " - " : "", - details ? details : ""); + virReportError(netcf_to_vir_err(errcode), + _("failed to begin transaction: %s%s%s"), + errmsg, details ? " - " : "", + details ? details : ""); } interfaceDriverUnlock(driver); @@ -604,10 +600,10 @@ static int interfaceChangeCommit(virConnectPtr conn, unsigned int flags) if (ret < 0) { const char *errmsg, *details; int errcode = ncf_error(driver->netcf, &errmsg, &details); - interfaceReportError(netcf_to_vir_err(errcode), - _("failed to commit transaction: %s%s%s"), - errmsg, details ? " - " : "", - details ? details : ""); + virReportError(netcf_to_vir_err(errcode), + _("failed to commit transaction: %s%s%s"), + errmsg, details ? " - " : "", + details ? details : ""); } interfaceDriverUnlock(driver); @@ -627,10 +623,10 @@ static int interfaceChangeRollback(virConnectPtr conn, unsigned int flags) if (ret < 0) { const char *errmsg, *details; int errcode = ncf_error(driver->netcf, &errmsg, &details); - interfaceReportError(netcf_to_vir_err(errcode), - _("failed to rollback transaction: %s%s%s"), - errmsg, details ? " - " : "", - details ? details : ""); + virReportError(netcf_to_vir_err(errcode), + _("failed to rollback transaction: %s%s%s"), + errmsg, details ? " - " : "", + details ? details : ""); } interfaceDriverUnlock(driver); -- 1.7.10.4

On 07/18/2012 05:53 AM, Daniel P. Berrange wrote:
From: "Daniel P. Berrange" <berrange@redhat.com>
Update the netcf driver to use virReportError instead of the interfaceReportError custom macro --- cfg.mk | 1 - src/interface/netcf_driver.c | 150 ++++++++++++++++++++---------------------- 2 files changed, 73 insertions(+), 78 deletions(-)
ACK. -- Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

From: "Daniel P. Berrange" <berrange@redhat.com> Update the linux bridge driver to use virReportError instead of the networkReportError custom macro Signed-off-by: Daniel P. Berrange <berrange@redhat.com> --- cfg.mk | 1 - src/network/bridge_driver.c | 344 ++++++++++++++++++++++--------------------- 2 files changed, 174 insertions(+), 171 deletions(-) diff --git a/cfg.mk b/cfg.mk index ed2838c..e83c8b0 100644 --- a/cfg.mk +++ b/cfg.mk @@ -515,7 +515,6 @@ msg_gen_function += VMX_ERROR msg_gen_function += XENXS_ERROR msg_gen_function += lxcError msg_gen_function += libxlError -msg_gen_function += networkReportError msg_gen_function += nodeReportError msg_gen_function += openvzError msg_gen_function += qemuReportError diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index 9b1964b..2962580 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -70,10 +70,6 @@ #define VIR_FROM_THIS VIR_FROM_NETWORK -#define networkReportError(code, ...) \ - virReportErrorHelper(VIR_FROM_NETWORK, code, __FILE__, \ - __FUNCTION__, __LINE__, __VA_ARGS__) - /* Main driver state */ struct network_driver { virMutex lock; @@ -849,9 +845,9 @@ networkStartRadvd(virNetworkObjPtr network) prefix = virNetworkIpDefPrefix(ipdef); if (prefix < 0) { - networkReportError(VIR_ERR_INTERNAL_ERROR, - _("bridge '%s' has an invalid prefix"), - network->def->bridge); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("bridge '%s' has an invalid prefix"), + network->def->bridge); goto cleanup; } if (!(netaddr = virSocketAddrFormat(&ipdef->address))) @@ -935,9 +931,9 @@ networkAddMasqueradingIptablesRules(struct network_driver *driver, const char *forwardIf = virNetworkDefForwardIf(network->def, 0); if (prefix < 0) { - networkReportError(VIR_ERR_INTERNAL_ERROR, - _("Invalid prefix or netmask for '%s'"), - network->def->bridge); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Invalid prefix or netmask for '%s'"), + network->def->bridge); goto masqerr1; } @@ -947,9 +943,9 @@ networkAddMasqueradingIptablesRules(struct network_driver *driver, prefix, network->def->bridge, forwardIf) < 0) { - networkReportError(VIR_ERR_SYSTEM_ERROR, - _("failed to add iptables rule to allow forwarding from '%s'"), - network->def->bridge); + virReportError(VIR_ERR_SYSTEM_ERROR, + _("failed to add iptables rule to allow forwarding from '%s'"), + network->def->bridge); goto masqerr1; } @@ -961,9 +957,9 @@ networkAddMasqueradingIptablesRules(struct network_driver *driver, prefix, network->def->bridge, forwardIf) < 0) { - networkReportError(VIR_ERR_SYSTEM_ERROR, - _("failed to add iptables rule to allow forwarding to '%s'"), - network->def->bridge); + virReportError(VIR_ERR_SYSTEM_ERROR, + _("failed to add iptables rule to allow forwarding to '%s'"), + network->def->bridge); goto masqerr2; } @@ -996,11 +992,11 @@ networkAddMasqueradingIptablesRules(struct network_driver *driver, prefix, forwardIf, NULL) < 0) { - networkReportError(VIR_ERR_SYSTEM_ERROR, - forwardIf ? - _("failed to add iptables rule to enable masquerading to %s") : - _("failed to add iptables rule to enable masquerading"), - forwardIf); + virReportError(VIR_ERR_SYSTEM_ERROR, + forwardIf ? + _("failed to add iptables rule to enable masquerading to %s") : + _("failed to add iptables rule to enable masquerading"), + forwardIf); goto masqerr3; } @@ -1010,11 +1006,11 @@ networkAddMasqueradingIptablesRules(struct network_driver *driver, prefix, forwardIf, "udp") < 0) { - networkReportError(VIR_ERR_SYSTEM_ERROR, - forwardIf ? - _("failed to add iptables rule to enable UDP masquerading to %s") : - _("failed to add iptables rule to enable UDP masquerading"), - forwardIf); + virReportError(VIR_ERR_SYSTEM_ERROR, + forwardIf ? + _("failed to add iptables rule to enable UDP masquerading to %s") : + _("failed to add iptables rule to enable UDP masquerading"), + forwardIf); goto masqerr4; } @@ -1024,11 +1020,11 @@ networkAddMasqueradingIptablesRules(struct network_driver *driver, prefix, forwardIf, "tcp") < 0) { - networkReportError(VIR_ERR_SYSTEM_ERROR, - forwardIf ? - _("failed to add iptables rule to enable TCP masquerading to %s") : - _("failed to add iptables rule to enable TCP masquerading"), - forwardIf); + virReportError(VIR_ERR_SYSTEM_ERROR, + forwardIf ? + _("failed to add iptables rule to enable TCP masquerading to %s") : + _("failed to add iptables rule to enable TCP masquerading"), + forwardIf); goto masqerr5; } @@ -1109,9 +1105,9 @@ networkAddRoutingIptablesRules(struct network_driver *driver, const char *forwardIf = virNetworkDefForwardIf(network->def, 0); if (prefix < 0) { - networkReportError(VIR_ERR_INTERNAL_ERROR, - _("Invalid prefix or netmask for '%s'"), - network->def->bridge); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Invalid prefix or netmask for '%s'"), + network->def->bridge); goto routeerr1; } @@ -1121,9 +1117,9 @@ networkAddRoutingIptablesRules(struct network_driver *driver, prefix, network->def->bridge, forwardIf) < 0) { - networkReportError(VIR_ERR_SYSTEM_ERROR, - _("failed to add iptables rule to allow routing from '%s'"), - network->def->bridge); + virReportError(VIR_ERR_SYSTEM_ERROR, + _("failed to add iptables rule to allow routing from '%s'"), + network->def->bridge); goto routeerr1; } @@ -1133,9 +1129,9 @@ networkAddRoutingIptablesRules(struct network_driver *driver, prefix, network->def->bridge, forwardIf) < 0) { - networkReportError(VIR_ERR_SYSTEM_ERROR, - _("failed to add iptables rule to allow routing to '%s'"), - network->def->bridge); + virReportError(VIR_ERR_SYSTEM_ERROR, + _("failed to add iptables rule to allow routing to '%s'"), + network->def->bridge); goto routeerr2; } @@ -1187,43 +1183,43 @@ networkAddGeneralIp6tablesRules(struct network_driver *driver, if (iptablesAddForwardRejectOut(driver->iptables, AF_INET6, network->def->bridge) < 0) { - networkReportError(VIR_ERR_SYSTEM_ERROR, - _("failed to add ip6tables rule to block outbound traffic from '%s'"), - network->def->bridge); + virReportError(VIR_ERR_SYSTEM_ERROR, + _("failed to add ip6tables rule to block outbound traffic from '%s'"), + network->def->bridge); goto err1; } if (iptablesAddForwardRejectIn(driver->iptables, AF_INET6, network->def->bridge) < 0) { - networkReportError(VIR_ERR_SYSTEM_ERROR, - _("failed to add ip6tables rule to block inbound traffic to '%s'"), - network->def->bridge); + virReportError(VIR_ERR_SYSTEM_ERROR, + _("failed to add ip6tables rule to block inbound traffic to '%s'"), + network->def->bridge); goto err2; } /* Allow traffic between guests on the same bridge */ if (iptablesAddForwardAllowCross(driver->iptables, AF_INET6, network->def->bridge) < 0) { - networkReportError(VIR_ERR_SYSTEM_ERROR, - _("failed to add ip6tables rule to allow cross bridge traffic on '%s'"), - network->def->bridge); + virReportError(VIR_ERR_SYSTEM_ERROR, + _("failed to add ip6tables rule to allow cross bridge traffic on '%s'"), + network->def->bridge); goto err3; } /* allow DNS over IPv6 */ if (iptablesAddTcpInput(driver->iptables, AF_INET6, network->def->bridge, 53) < 0) { - networkReportError(VIR_ERR_SYSTEM_ERROR, - _("failed to add ip6tables rule to allow DNS requests from '%s'"), - network->def->bridge); + virReportError(VIR_ERR_SYSTEM_ERROR, + _("failed to add ip6tables rule to allow DNS requests from '%s'"), + network->def->bridge); goto err4; } if (iptablesAddUdpInput(driver->iptables, AF_INET6, network->def->bridge, 53) < 0) { - networkReportError(VIR_ERR_SYSTEM_ERROR, - _("failed to add ip6tables rule to allow DNS requests from '%s'"), - network->def->bridge); + virReportError(VIR_ERR_SYSTEM_ERROR, + _("failed to add ip6tables rule to allow DNS requests from '%s'"), + network->def->bridge); goto err5; } @@ -1274,17 +1270,17 @@ networkAddGeneralIptablesRules(struct network_driver *driver, if (iptablesAddTcpInput(driver->iptables, AF_INET, network->def->bridge, 67) < 0) { - networkReportError(VIR_ERR_SYSTEM_ERROR, - _("failed to add iptables rule to allow DHCP requests from '%s'"), - network->def->bridge); + virReportError(VIR_ERR_SYSTEM_ERROR, + _("failed to add iptables rule to allow DHCP requests from '%s'"), + network->def->bridge); goto err1; } if (iptablesAddUdpInput(driver->iptables, AF_INET, network->def->bridge, 67) < 0) { - networkReportError(VIR_ERR_SYSTEM_ERROR, - _("failed to add iptables rule to allow DHCP requests from '%s'"), - network->def->bridge); + virReportError(VIR_ERR_SYSTEM_ERROR, + _("failed to add iptables rule to allow DHCP requests from '%s'"), + network->def->bridge); goto err2; } @@ -1305,17 +1301,17 @@ networkAddGeneralIptablesRules(struct network_driver *driver, /* allow DNS requests through to dnsmasq */ if (iptablesAddTcpInput(driver->iptables, AF_INET, network->def->bridge, 53) < 0) { - networkReportError(VIR_ERR_SYSTEM_ERROR, - _("failed to add iptables rule to allow DNS requests from '%s'"), - network->def->bridge); + virReportError(VIR_ERR_SYSTEM_ERROR, + _("failed to add iptables rule to allow DNS requests from '%s'"), + network->def->bridge); goto err3; } if (iptablesAddUdpInput(driver->iptables, AF_INET, network->def->bridge, 53) < 0) { - networkReportError(VIR_ERR_SYSTEM_ERROR, - _("failed to add iptables rule to allow DNS requests from '%s'"), - network->def->bridge); + virReportError(VIR_ERR_SYSTEM_ERROR, + _("failed to add iptables rule to allow DNS requests from '%s'"), + network->def->bridge); goto err4; } @@ -1323,9 +1319,9 @@ networkAddGeneralIptablesRules(struct network_driver *driver, if (ipv4def && ipv4def->tftproot && iptablesAddUdpInput(driver->iptables, AF_INET, network->def->bridge, 69) < 0) { - networkReportError(VIR_ERR_SYSTEM_ERROR, - _("failed to add iptables rule to allow TFTP requests from '%s'"), - network->def->bridge); + virReportError(VIR_ERR_SYSTEM_ERROR, + _("failed to add iptables rule to allow TFTP requests from '%s'"), + network->def->bridge); goto err5; } @@ -1333,26 +1329,26 @@ networkAddGeneralIptablesRules(struct network_driver *driver, if (iptablesAddForwardRejectOut(driver->iptables, AF_INET, network->def->bridge) < 0) { - networkReportError(VIR_ERR_SYSTEM_ERROR, - _("failed to add iptables rule to block outbound traffic from '%s'"), - network->def->bridge); + virReportError(VIR_ERR_SYSTEM_ERROR, + _("failed to add iptables rule to block outbound traffic from '%s'"), + network->def->bridge); goto err6; } if (iptablesAddForwardRejectIn(driver->iptables, AF_INET, network->def->bridge) < 0) { - networkReportError(VIR_ERR_SYSTEM_ERROR, - _("failed to add iptables rule to block inbound traffic to '%s'"), - network->def->bridge); + virReportError(VIR_ERR_SYSTEM_ERROR, + _("failed to add iptables rule to block inbound traffic to '%s'"), + network->def->bridge); goto err7; } /* Allow traffic between guests on the same bridge */ if (iptablesAddForwardAllowCross(driver->iptables, AF_INET, network->def->bridge) < 0) { - networkReportError(VIR_ERR_SYSTEM_ERROR, - _("failed to add iptables rule to allow cross bridge traffic on '%s'"), - network->def->bridge); + virReportError(VIR_ERR_SYSTEM_ERROR, + _("failed to add iptables rule to allow cross bridge traffic on '%s'"), + network->def->bridge); goto err8; } @@ -1700,9 +1696,9 @@ networkCheckRouteCollision(virNetworkObjPtr network) if ((net_dest == addr_val) && (netmask.data.inet4.sin_addr.s_addr == mask_val)) { - networkReportError(VIR_ERR_INTERNAL_ERROR, - _("Network is already in use by interface %s"), - iface); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Network is already in use by interface %s"), + iface); ret = -1; goto out; } @@ -1721,9 +1717,9 @@ networkAddAddrToBridge(virNetworkObjPtr network, int prefix = virNetworkIpDefPrefix(ipdef); if (prefix < 0) { - networkReportError(VIR_ERR_INTERNAL_ERROR, - _("bridge '%s' has an invalid netmask or IP address"), - network->def->bridge); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("bridge '%s' has an invalid netmask or IP address"), + network->def->bridge); return -1; } @@ -1828,9 +1824,9 @@ networkStartNetworkVirtual(struct network_driver *driver, goto err4; if (virNetDevBandwidthSet(network->def->bridge, network->def->bandwidth) < 0) { - networkReportError(VIR_ERR_INTERNAL_ERROR, - _("cannot set bandwidth limits on %s"), - network->def->bridge); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("cannot set bandwidth limits on %s"), + network->def->bridge); goto err5; } @@ -1962,8 +1958,8 @@ networkStartNetwork(struct network_driver *driver, int ret = 0; if (virNetworkObjIsActive(network)) { - networkReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("network is already active")); + virReportError(VIR_ERR_OPERATION_INVALID, + "%s", _("network is already active")); return -1; } @@ -2064,8 +2060,8 @@ static virNetworkPtr networkLookupByUUID(virConnectPtr conn, network = virNetworkFindByUUID(&driver->networks, uuid); networkDriverUnlock(driver); if (!network) { - networkReportError(VIR_ERR_NO_NETWORK, - "%s", _("no network with matching uuid")); + virReportError(VIR_ERR_NO_NETWORK, + "%s", _("no network with matching uuid")); goto cleanup; } @@ -2087,8 +2083,8 @@ static virNetworkPtr networkLookupByName(virConnectPtr conn, network = virNetworkFindByName(&driver->networks, name); networkDriverUnlock(driver); if (!network) { - networkReportError(VIR_ERR_NO_NETWORK, - _("no network with matching name '%s'"), name); + virReportError(VIR_ERR_NO_NETWORK, + _("no network with matching name '%s'"), name); goto cleanup; } @@ -2216,7 +2212,7 @@ static int networkIsActive(virNetworkPtr net) obj = virNetworkFindByUUID(&driver->networks, net->uuid); networkDriverUnlock(driver); if (!obj) { - networkReportError(VIR_ERR_NO_NETWORK, NULL); + virReportError(VIR_ERR_NO_NETWORK, NULL); goto cleanup; } ret = virNetworkObjIsActive(obj); @@ -2237,7 +2233,7 @@ static int networkIsPersistent(virNetworkPtr net) obj = virNetworkFindByUUID(&driver->networks, net->uuid); networkDriverUnlock(driver); if (!obj) { - networkReportError(VIR_ERR_NO_NETWORK, NULL); + virReportError(VIR_ERR_NO_NETWORK, NULL); goto cleanup; } ret = obj->persistent; @@ -2337,8 +2333,10 @@ static virNetworkPtr networkDefine(virConnectPtr conn, const char *xml) { if (VIR_SOCKET_ADDR_IS_FAMILY(&ipdef->address, AF_INET)) { if (ipdef->nranges || ipdef->nhosts) { if (ipv4def) { - networkReportError(VIR_ERR_CONFIG_UNSUPPORTED, - "%s", _("Multiple dhcp sections found. dhcp is supported only for a single IPv4 address on each network")); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Multiple dhcp sections found. " + "dhcp is supported only for a " + "single IPv4 address on each network")); goto cleanup; } else { ipv4def = ipdef; @@ -2392,14 +2390,14 @@ static int networkUndefine(virNetworkPtr net) { network = virNetworkFindByUUID(&driver->networks, net->uuid); if (!network) { - networkReportError(VIR_ERR_NO_NETWORK, - "%s", _("no network with matching uuid")); + virReportError(VIR_ERR_NO_NETWORK, + "%s", _("no network with matching uuid")); goto cleanup; } if (virNetworkObjIsActive(network)) { - networkReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("network is still active")); + virReportError(VIR_ERR_OPERATION_INVALID, + "%s", _("network is still active")); goto cleanup; } @@ -2479,8 +2477,8 @@ static int networkStart(virNetworkPtr net) { network = virNetworkFindByUUID(&driver->networks, net->uuid); if (!network) { - networkReportError(VIR_ERR_NO_NETWORK, - "%s", _("no network with matching uuid")); + virReportError(VIR_ERR_NO_NETWORK, + "%s", _("no network with matching uuid")); goto cleanup; } @@ -2502,14 +2500,14 @@ static int networkDestroy(virNetworkPtr net) { network = virNetworkFindByUUID(&driver->networks, net->uuid); if (!network) { - networkReportError(VIR_ERR_NO_NETWORK, - "%s", _("no network with matching uuid")); + virReportError(VIR_ERR_NO_NETWORK, + "%s", _("no network with matching uuid")); goto cleanup; } if (!virNetworkObjIsActive(network)) { - networkReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("network is not active")); + virReportError(VIR_ERR_OPERATION_INVALID, + "%s", _("network is not active")); goto cleanup; } @@ -2542,8 +2540,8 @@ static char *networkGetXMLDesc(virNetworkPtr net, networkDriverUnlock(driver); if (!network) { - networkReportError(VIR_ERR_NO_NETWORK, - "%s", _("no network with matching uuid")); + virReportError(VIR_ERR_NO_NETWORK, + "%s", _("no network with matching uuid")); goto cleanup; } @@ -2570,15 +2568,15 @@ static char *networkGetBridgeName(virNetworkPtr net) { networkDriverUnlock(driver); if (!network) { - networkReportError(VIR_ERR_NO_NETWORK, - "%s", _("no network with matching id")); + virReportError(VIR_ERR_NO_NETWORK, + "%s", _("no network with matching id")); goto cleanup; } if (!(network->def->bridge)) { - networkReportError(VIR_ERR_INTERNAL_ERROR, - _("network '%s' does not have a bridge name."), - network->def->name); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("network '%s' does not have a bridge name."), + network->def->name); goto cleanup; } @@ -2602,8 +2600,8 @@ static int networkGetAutostart(virNetworkPtr net, network = virNetworkFindByUUID(&driver->networks, net->uuid); networkDriverUnlock(driver); if (!network) { - networkReportError(VIR_ERR_NO_NETWORK, - "%s", _("no network with matching uuid")); + virReportError(VIR_ERR_NO_NETWORK, + "%s", _("no network with matching uuid")); goto cleanup; } @@ -2627,14 +2625,14 @@ static int networkSetAutostart(virNetworkPtr net, network = virNetworkFindByUUID(&driver->networks, net->uuid); if (!network) { - networkReportError(VIR_ERR_NO_NETWORK, - "%s", _("no network with matching uuid")); + virReportError(VIR_ERR_NO_NETWORK, + "%s", _("no network with matching uuid")); goto cleanup; } if (!network->persistent) { - networkReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("cannot set autostart for transient network")); + virReportError(VIR_ERR_OPERATION_INVALID, + "%s", _("cannot set autostart for transient network")); goto cleanup; } @@ -2763,9 +2761,9 @@ networkAllocateActualDevice(virDomainNetDefPtr iface) network = virNetworkFindByName(&driver->networks, iface->data.network.name); networkDriverUnlock(driver); if (!network) { - networkReportError(VIR_ERR_NO_NETWORK, - _("no network with matching name '%s'"), - iface->data.network.name); + virReportError(VIR_ERR_NO_NETWORK, + _("no network with matching name '%s'"), + iface->data.network.name); goto cleanup; } @@ -2879,9 +2877,10 @@ networkAllocateActualDevice(virDomainNetDefPtr iface) * any error if exclusive use is required but could not be acquired). */ if ((netdef->nForwardIfs <= 0) && (netdef->nForwardPfs <= 0)) { - networkReportError(VIR_ERR_INTERNAL_ERROR, - _("network '%s' uses a direct mode, but has no forward dev and no interface pool"), - netdef->name); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("network '%s' uses a direct mode, but " + "has no forward dev and no interface pool"), + netdef->name); goto cleanup; } else { virNetworkForwardIfDefPtr dev = NULL; @@ -2897,16 +2896,16 @@ networkAllocateActualDevice(virDomainNetDefPtr iface) if ((netdef->nForwardPfs > 0) && (netdef->nForwardIfs <= 0)) { if ((virNetDevGetVirtualFunctions(netdef->forwardPfs->dev, &vfname, &num_virt_fns)) < 0) { - networkReportError(VIR_ERR_INTERNAL_ERROR, - _("Could not get Virtual functions on %s"), - netdef->forwardPfs->dev); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Could not get Virtual functions on %s"), + netdef->forwardPfs->dev); goto cleanup; } if (num_virt_fns == 0) { - networkReportError(VIR_ERR_INTERNAL_ERROR, - _("No Vf's present on SRIOV PF %s"), - netdef->forwardPfs->dev); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("No Vf's present on SRIOV PF %s"), + netdef->forwardPfs->dev); goto cleanup; } @@ -2957,9 +2956,10 @@ networkAllocateActualDevice(virDomainNetDefPtr iface) } /* dev points at the physical device we want to use */ if (!dev) { - networkReportError(VIR_ERR_INTERNAL_ERROR, - _("network '%s' requires exclusive access to interfaces, but none are available"), - netdef->name); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("network '%s' requires exclusive access " + "to interfaces, but none are available"), + netdef->name); goto cleanup; } iface->data.network.actual->data.direct.linkdev = strdup(dev->dev); @@ -3020,24 +3020,26 @@ networkNotifyActualDevice(virDomainNetDefPtr iface) network = virNetworkFindByName(&driver->networks, iface->data.network.name); networkDriverUnlock(driver); if (!network) { - networkReportError(VIR_ERR_NO_NETWORK, - _("no network with matching name '%s'"), - iface->data.network.name); + virReportError(VIR_ERR_NO_NETWORK, + _("no network with matching name '%s'"), + iface->data.network.name); goto cleanup; } actualDev = virDomainNetGetActualDirectDev(iface); if (!actualDev) { - networkReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("the interface uses a direct mode, but has no source dev")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("the interface uses a direct " + "mode, but has no source dev")); goto cleanup; } netdef = network->def; if (netdef->nForwardIfs == 0) { - networkReportError(VIR_ERR_INTERNAL_ERROR, - _("network '%s' uses a direct mode, but has no forward dev and no interface pool"), - netdef->name); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("network '%s' uses a direct mode, but " + "has no forward dev and no interface pool"), + netdef->name); goto cleanup; } else { int ii; @@ -3053,9 +3055,9 @@ networkNotifyActualDevice(virDomainNetDefPtr iface) } /* dev points at the physical device we want to use */ if (!dev) { - networkReportError(VIR_ERR_INTERNAL_ERROR, - _("network '%s' doesn't have dev='%s' in use by domain"), - netdef->name, actualDev); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("network '%s' doesn't have dev='%s' in use by domain"), + netdef->name, actualDev); goto cleanup; } @@ -3069,9 +3071,9 @@ networkNotifyActualDevice(virDomainNetDefPtr iface) iface->data.network.actual->data.direct.virtPortProfile && (iface->data.network.actual->data.direct.virtPortProfile->virtPortType == VIR_NETDEV_VPORT_PROFILE_8021QBH)))) { - networkReportError(VIR_ERR_INTERNAL_ERROR, - _("network '%s' claims dev='%s' is already in use by a different domain"), - netdef->name, actualDev); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("network '%s' claims dev='%s' is already in use by a different domain"), + netdef->name, actualDev); goto cleanup; } /* we are now assured of success, so mark the allocation */ @@ -3121,24 +3123,26 @@ networkReleaseActualDevice(virDomainNetDefPtr iface) network = virNetworkFindByName(&driver->networks, iface->data.network.name); networkDriverUnlock(driver); if (!network) { - networkReportError(VIR_ERR_NO_NETWORK, - _("no network with matching name '%s'"), - iface->data.network.name); + virReportError(VIR_ERR_NO_NETWORK, + _("no network with matching name '%s'"), + iface->data.network.name); goto cleanup; } actualDev = virDomainNetGetActualDirectDev(iface); if (!actualDev) { - networkReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("the interface uses a direct mode, but has no source dev")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("the interface uses a direct " + "mode, but has no source dev")); goto cleanup; } netdef = network->def; if (netdef->nForwardIfs == 0) { - networkReportError(VIR_ERR_INTERNAL_ERROR, - _("network '%s' uses a direct mode, but has no forward dev and no interface pool"), - netdef->name); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("network '%s' uses a direct mode, but " + "has no forward dev and no interface pool"), + netdef->name); goto cleanup; } else { int ii; @@ -3152,9 +3156,9 @@ networkReleaseActualDevice(virDomainNetDefPtr iface) } /* dev points at the physical device we've been using */ if (!dev) { - networkReportError(VIR_ERR_INTERNAL_ERROR, - _("network '%s' doesn't have dev='%s' in use by domain"), - netdef->name, actualDev); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("network '%s' doesn't have dev='%s' in use by domain"), + netdef->name, actualDev); goto cleanup; } @@ -3208,9 +3212,9 @@ networkGetNetworkAddress(const char *netname, char **netaddr) network = virNetworkFindByName(&driver->networks, netname); networkDriverUnlock(driver); if (!network) { - networkReportError(VIR_ERR_NO_NETWORK, - _("no network with matching name '%s'"), - netname); + virReportError(VIR_ERR_NO_NETWORK, + _("no network with matching name '%s'"), + netname); goto cleanup; } netdef = network->def; @@ -3222,9 +3226,9 @@ networkGetNetworkAddress(const char *netname, char **netaddr) /* if there's an ipv4def, get it's address */ ipdef = virNetworkDefGetIpByIndex(netdef, AF_INET, 0); if (!ipdef) { - networkReportError(VIR_ERR_INTERNAL_ERROR, - _("network '%s' doesn't have an IPv4 address"), - netdef->name); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("network '%s' doesn't have an IPv4 address"), + netdef->name); break; } addrptr = &ipdef->address; @@ -3244,9 +3248,9 @@ networkGetNetworkAddress(const char *netname, char **netaddr) dev_name = netdef->forwardIfs[0].dev; if (!dev_name) { - networkReportError(VIR_ERR_INTERNAL_ERROR, - _("network '%s' has no associated interface or bridge"), - netdef->name); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("network '%s' has no associated interface or bridge"), + netdef->name); } break; } -- 1.7.10.4

On 07/18/2012 05:53 AM, Daniel P. Berrange wrote:
From: "Daniel P. Berrange" <berrange@redhat.com>
Update the linux bridge driver to use virReportError instead of the networkReportError custom macro
Signed-off-by: Daniel P. Berrange <berrange@redhat.com> ---
ACK. -- Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

On 07/18/2012 05:52 AM, Daniel P. Berrange wrote:
This series is all about replacing custom error reporting macros with a common virReportError macro
79 files changed, 3510 insertions(+), 3705 deletions(-)
Yet another big series that nukes more than it adds, and is probably mostly mechanical but with a good chance of some blips to fix. I'll start reviewing :) -- Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

On Wed, Jul 18, 2012 at 05:58:34AM -0600, Eric Blake wrote:
On 07/18/2012 05:52 AM, Daniel P. Berrange wrote:
This series is all about replacing custom error reporting macros with a common virReportError macro
79 files changed, 3510 insertions(+), 3705 deletions(-)
Yet another big series that nukes more than it adds, and is probably mostly mechanical but with a good chance of some blips to fix. I'll start reviewing :)
It was 100% mechanical, apart from the first 4 patches. The rest were simply global search+replace, followed by re-indent, and occasional line-wrapping. I did not attempt any functional changes at the same time. Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
participants (2)
-
Daniel P. Berrange
-
Eric Blake