* qemud/qemud.c (GET_CONF_STR): Use virStrerror, not strerror.
* qemud/remote.c (remoteDispatchDomainBlockPeek): Likewise.
(remoteDispatchDomainMemoryPeek, remoteDispatchAuthSaslInit): Likewise.
(remoteDispatchAuthPolkit): Likewise.
* src/lxc_container.c (lxcContainerAvailable): Likewise.
* src/network_driver.c (networkStartNetworkDaemon): Likewise.
(networkShutdownNetworkDaemon): Likewise.
* src/qemu_conf.c (qemudExtractVersion, qemudNetworkIfaceConnect):
* src/storage_conf.c (virStoragePoolLoadAllConfigs): Likewise.
* src/storage_driver.c (storagePoolUndefine): Likewise.
* src/uml_driver.c (umlStartup, umlStartVMDaemon): Likewise.
* src/util.c (virFileReadAll): Likewise.
* src/uuid.c (virUUIDGenerate): Likewise.
* src/xen_internal.c (get_cpu_flags): Likewise.
+Thu Feb 5 17:03:35 +0100 2009 Jim Meyering <meyering@redhat.com>
+
+ remove remainder of offending strerror uses
+ * qemud/qemud.c (GET_CONF_STR): Use virStrerror, not strerror.
+ * qemud/remote.c (remoteDispatchDomainBlockPeek): Likewise.
+ (remoteDispatchDomainMemoryPeek, remoteDispatchAuthSaslInit): Likewise.
+ (remoteDispatchAuthPolkit): Likewise.
+ * src/lxc_container.c (lxcContainerAvailable): Likewise.
+ * src/network_driver.c (networkStartNetworkDaemon): Likewise.
+ (networkShutdownNetworkDaemon): Likewise.
+ * src/qemu_conf.c (qemudExtractVersion, qemudNetworkIfaceConnect):
+ * src/storage_conf.c (virStoragePoolLoadAllConfigs): Likewise.
+ * src/storage_driver.c (storagePoolUndefine): Likewise.
+ * src/uml_driver.c (umlStartup, umlStartVMDaemon): Likewise.
+ * src/util.c (virFileReadAll): Likewise.
+ * src/uuid.c (virUUIDGenerate): Likewise.
+ * src/xen_internal.c (get_cpu_flags): Likewise.
+
Thu Feb 5 17:03:35 +0100 2009 Jim Meyering <meyering@redhat.com>
don't include raw errno in diagnostics
#include <netdb.h>
#include "libvirt_internal.h"
+#include "virterror_internal.h"
#include "qemud.h"
#include "util.h"
goto free_and_fail; \
(var_name) = strdup (p->str); \
if ((var_name) == NULL) { \
- VIR_ERROR(_("remoteReadConfigFile: %s\n"),strerror (errno)); \
+ char ebuf[1024]; \
+ VIR_ERROR(_("remoteReadConfigFile: %s\n"), \
+ virStrerror(errno, ebuf, sizeof ebuf)); \
goto free_and_fail; \
} \
} \
#include <string.h>
#include <errno.h>
#include <fnmatch.h>
+#include "virterror_internal.h"
#ifdef HAVE_POLKIT
#include <polkit/polkit.h>
}
ret->buffer.buffer_len = size;
- if (VIR_ALLOC_N(ret->buffer.buffer_val, size) < 0) {
+ if (VIR_ALLOC_N (ret->buffer.buffer_val, size) < 0) {
+ char ebuf[1024];
virDomainFree (dom);
- remoteDispatchFormatError (rerr, "%s", strerror (errno));
+ remoteDispatchFormatError (rerr, "%s",
+ virStrerror(errno, ebuf, sizeof ebuf));
return -1;
}
flags = args->flags;
if (size > REMOTE_DOMAIN_MEMORY_PEEK_BUFFER_MAX) {
+ virDomainFree (dom);
remoteDispatchFormatError (rerr,
"%s", _("size > maximum buffer size"));
- virDomainFree (dom);
return -1;
}
ret->buffer.buffer_len = size;
if (VIR_ALLOC_N (ret->buffer.buffer_val, size) < 0) {
- remoteDispatchFormatError (rerr, "%s", strerror (errno));
+ char ebuf[1024];
virDomainFree (dom);
+ remoteDispatchFormatError (rerr, "%s",
+ virStrerror(errno, ebuf, sizeof ebuf));
return -1;
}
/* Get local address in form IPADDR:PORT */
salen = sizeof(sa);
if (getsockname(client->fd, (struct sockaddr*)&sa, &salen) < 0) {
+ char ebuf[1024];
remoteDispatchFormatError(rerr,
_("failed to get sock address: %s"),
- strerror(errno));
+ virStrerror(errno, ebuf, sizeof ebuf));
goto error;
}
if ((localAddr = addrToString(rerr, &sa, salen)) == NULL) {
/* Get remote address in form IPADDR:PORT */
salen = sizeof(sa);
if (getpeername(client->fd, (struct sockaddr*)&sa, &salen) < 0) {
+ char ebuf[1024];
remoteDispatchFormatError(rerr, _("failed to get peer address: %s"),
- strerror(errno));
+ virStrerror(errno, ebuf, sizeof ebuf));
VIR_FREE(localAddr);
goto error;
}
}
if (!(pkaction = polkit_action_new())) {
- VIR_ERROR(_("Failed to create polkit action %s\n"), strerror(errno));
+ char ebuf[1024];
+ VIR_ERROR(_("Failed to create polkit action %s\n"),
+ virStrerror(errno, ebuf, sizeof ebuf));
polkit_caller_unref(pkcaller);
goto authfail;
}
if (!(pkcontext = polkit_context_new()) ||
!polkit_context_init(pkcontext, &pkerr)) {
+ char ebuf[1024];
VIR_ERROR(_("Failed to create polkit context %s\n"),
(pkerr ? polkit_error_get_error_message(pkerr)
- : strerror(errno)));
+ : virStrerror(errno, ebuf, sizeof ebuf)));
if (pkerr)
polkit_error_free(pkerr);
polkit_caller_unref(pkcaller);
cpid = clone(lxcContainerDummyChild, childStack, flags, NULL);
VIR_FREE(stack);
if (cpid < 0) {
+ char ebuf[1024];
DEBUG("clone call returned %s, container support is not enabled",
- strerror(errno));
+ virStrerror(errno, ebuf, sizeof ebuf));
return -1;
} else {
waitpid(cpid, &childStatus, 0);
err_delbr1:
if (network->def->ipAddress &&
(err = brSetInterfaceUp(driver->brctl, network->def->bridge, 0))) {
+ char ebuf[1024];
networkLog(NETWORK_WARN, _("Failed to bring down bridge '%s' : %s\n"),
- network->def->bridge, strerror(err));
+ network->def->bridge, virStrerror(err, ebuf, sizeof ebuf));
}
err_delbr:
if ((err = brDeleteBridge(driver->brctl, network->def->bridge))) {
+ char ebuf[1024];
networkLog(NETWORK_WARN, _("Failed to delete bridge '%s' : %s\n"),
- network->def->bridge, strerror(err));
+ network->def->bridge, virStrerror(err, ebuf, sizeof ebuf));
}
return -1;
networkRemoveIptablesRules(driver, network);
+ char ebuf[1024];
if (network->def->ipAddress &&
(err = brSetInterfaceUp(driver->brctl, network->def->bridge, 0))) {
networkLog(NETWORK_WARN, _("Failed to bring down bridge '%s' : %s\n"),
- network->def->bridge, strerror(err));
+ network->def->bridge, virStrerror(err, ebuf, sizeof ebuf));
}
if ((err = brDeleteBridge(driver->brctl, network->def->bridge))) {
networkLog(NETWORK_WARN, _("Failed to delete bridge '%s' : %s\n"),
- network->def->bridge, strerror(err));
+ network->def->bridge, virStrerror(err, ebuf, sizeof ebuf));
}
/* See if its still alive and really really kill it */
return -1;
if (stat(binary, &sb) < 0) {
+ char ebuf[1024];
qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
_("Cannot find QEMU binary %s: %s"), binary,
- strerror(errno));
+ virStrerror(errno, ebuf, sizeof ebuf));
return -1;
}
}
}
+ char ebuf[1024];
if (!driver->brctl && (err = brInit(&driver->brctl))) {
qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
_("cannot initialize bridge support: %s"),
- strerror(err));
+ virStrerror(err, ebuf, sizeof ebuf));
goto error;
}
qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
_("Failed to add tap interface '%s' "
"to bridge '%s' : %s"),
- net->ifname, brname, strerror(err));
+ net->ifname, brname, virStrerror(err, ebuf, sizeof ebuf));
}
goto error;
}
/*
* storage_conf.c: config handling for storage driver
*
- * Copyright (C) 2006-2008 Red Hat, Inc.
+ * Copyright (C) 2006-2009 Red Hat, Inc.
* Copyright (C) 2006-2008 Daniel P. Berrange
*
* This library is free software; you can redistribute it and/or
struct dirent *entry;
if (!(dir = opendir(configDir))) {
+ char ebuf[1024];
if (errno == ENOENT)
return 0;
virStorageLog("Failed to open dir '%s': %s",
- configDir, strerror(errno));
+ configDir, virStrerror(errno, ebuf, sizeof ebuf));
return -1;
}
/*
* storage_driver.c: core driver for storage APIs
*
- * Copyright (C) 2006-2008 Red Hat, Inc.
+ * Copyright (C) 2006-2009 Red Hat, Inc.
* Copyright (C) 2006-2008 Daniel P. Berrange
*
* This library is free software; you can redistribute it and/or
if (virStoragePoolObjDeleteDef(obj->conn, pool) < 0)
goto cleanup;
- if (unlink(pool->autostartLink) < 0 && errno != ENOENT && errno != ENOTDIR)
+ if (unlink(pool->autostartLink) < 0 && errno != ENOENT && errno != ENOTDIR) {
+ char ebuf[1024];
storageLog("Failed to delete autostart link '%s': %s",
- pool->autostartLink, strerror(errno));
+ pool->autostartLink, virStrerror(errno, ebuf, sizeof ebuf));
+ }
VIR_FREE(pool->configFile);
VIR_FREE(pool->autostartLink);
}
if (virFileMakePath(uml_driver->monitorDir) < 0) {
+ char ebuf[1024];
umlLog(VIR_LOG_ERROR, _("Failed to create monitor directory %s: %s"),
- uml_driver->monitorDir, strerror(errno));
+ uml_driver->monitorDir, virStrerror(errno, ebuf, sizeof ebuf));
goto error;
}
int *tapfds = NULL;
int ntapfds = 0;
fd_set keepfd;
+ char ebuf[1024];
FD_ZERO(&keepfd);
while (*tmp) {
if (safewrite(logfd, *tmp, strlen(*tmp)) < 0)
umlLog(VIR_LOG_WARN, _("Unable to write envv to logfile: %s\n"),
- strerror(errno));
+ virStrerror(errno, ebuf, sizeof ebuf));
if (safewrite(logfd, " ", 1) < 0)
umlLog(VIR_LOG_WARN, _("Unable to write envv to logfile: %s\n"),
- strerror(errno));
+ virStrerror(errno, ebuf, sizeof ebuf));
tmp++;
}
tmp = argv;
while (*tmp) {
if (safewrite(logfd, *tmp, strlen(*tmp)) < 0)
umlLog(VIR_LOG_WARN, _("Unable to write argv to logfile: %s\n"),
- strerror(errno));
+ virStrerror(errno, ebuf, sizeof ebuf));
if (safewrite(logfd, " ", 1) < 0)
umlLog(VIR_LOG_WARN, _("Unable to write argv to logfile: %s\n"),
- strerror(errno));
+ virStrerror(errno, ebuf, sizeof ebuf));
tmp++;
}
if (safewrite(logfd, "\n", 1) < 0)
umlLog(VIR_LOG_WARN, _("Unable to write argv to logfile: %s\n"),
- strerror(errno));
+ virStrerror(errno, ebuf, sizeof ebuf));
vm->monitor = -1;
/* Cleanup intermediate proces */
if (waitpid(pid, NULL, 0) != pid)
umlLog(VIR_LOG_WARN, _("failed to wait on process: %d: %s\n"),
- pid, strerror(errno));
+ pid, virStrerror(errno, ebuf, sizeof ebuf));
for (i = 0 ; argv[i] ; i++)
VIR_FREE(argv[i]);
int virFileReadAll(const char *path, int maxlen, char **buf)
{
+ char ebuf[1024];
FILE *fh = fopen(path, "r");
if (fh == NULL) {
virLog("Failed to open file '%s': %s\n",
- path, strerror(errno));
+ path, virStrerror(errno, ebuf, sizeof ebuf));
return -1;
}
int len = virFileReadLimFP (fh, maxlen, buf);
fclose(fh);
if (len < 0) {
- virLog("Failed to read '%s': %s\n", path, strerror (errno));
+ virLog("Failed to read '%s': %s\n", path,
+ virStrerror(errno, ebuf, sizeof ebuf));
return -1;
}
/*
- * Copyright (C) 2007, 2008 Red Hat, Inc.
+ * Copyright (C) 2007, 2008, 2009 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
#include "c-ctype.h"
#include "internal.h"
#include "util.h"
+#include "virterror_internal.h"
#define qemudLog(level, msg...) fprintf(stderr, msg)
if (uuid == NULL)
return(-1);
- if ((err = virUUIDGenerateRandomBytes(uuid, VIR_UUID_BUFLEN)))
+ if ((err = virUUIDGenerateRandomBytes(uuid, VIR_UUID_BUFLEN))) {
+ char ebuf[1024];
qemudLog(QEMUD_WARN,
_("Falling back to pseudorandom UUID,"
- " failed to generate random bytes: %s"), strerror(err));
+ " failed to generate random bytes: %s"),
+ virStrerror(err, ebuf, sizeof ebuf));
+ }
return virUUIDGeneratePseudoRandomBytes(uuid, VIR_UUID_BUFLEN);
}
if ((fd = open("/dev/cpu/self/cpuid", O_RDONLY)) == -1 ||
pread(fd, ®s, sizeof(regs), 0) != sizeof(regs)) {
+ char ebuf[1024];
virXenError(conn, VIR_ERR_SYSTEM_ERROR,
- "couldn't read CPU flags: %s", strerror(errno));
+ "couldn't read CPU flags: %s", virStrerror(errno, ebuf, sizeof ebuf));
goto out;
}