diff --git a/ChangeLog b/ChangeLog index 0a73557abf..2fe7d18650 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,21 @@ +Thu Feb 5 17:03:35 +0100 2009 Jim Meyering + + 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 don't include raw errno in diagnostics diff --git a/qemud/qemud.c b/qemud/qemud.c index 48083df9b5..effb3368e2 100644 --- a/qemud/qemud.c +++ b/qemud/qemud.c @@ -49,6 +49,7 @@ #include #include "libvirt_internal.h" +#include "virterror_internal.h" #include "qemud.h" #include "util.h" @@ -2316,7 +2317,9 @@ checkType (virConfValuePtr p, const char *filename, 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; \ } \ } \ diff --git a/qemud/remote.c b/qemud/remote.c index 2e0c48e9ad..78dda4260b 100644 --- a/qemud/remote.c +++ b/qemud/remote.c @@ -41,6 +41,7 @@ #include #include #include +#include "virterror_internal.h" #ifdef HAVE_POLKIT #include @@ -990,9 +991,11 @@ remoteDispatchDomainBlockPeek (struct qemud_server *server ATTRIBUTE_UNUSED, } 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; } @@ -1031,16 +1034,18 @@ remoteDispatchDomainMemoryPeek (struct qemud_server *server ATTRIBUTE_UNUSED, 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; } @@ -2571,9 +2576,10 @@ remoteDispatchAuthSaslInit (struct qemud_server *server, /* 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) { @@ -2583,8 +2589,9 @@ remoteDispatchAuthSaslInit (struct qemud_server *server, /* 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; } @@ -3062,7 +3069,9 @@ remoteDispatchAuthPolkit (struct qemud_server *server, } 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; } @@ -3070,9 +3079,10 @@ remoteDispatchAuthPolkit (struct qemud_server *server, 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); diff --git a/src/lxc_container.c b/src/lxc_container.c index 90c70d5367..3f17b8dfe8 100644 --- a/src/lxc_container.c +++ b/src/lxc_container.c @@ -668,8 +668,9 @@ int lxcContainerAvailable(int features) 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); diff --git a/src/network_driver.c b/src/network_driver.c index dcc6ad9a83..4138939112 100644 --- a/src/network_driver.c +++ b/src/network_driver.c @@ -907,14 +907,16 @@ static int networkStartNetworkDaemon(virConnectPtr conn, 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; @@ -944,15 +946,16 @@ static int networkShutdownNetworkDaemon(virConnectPtr conn, 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 */ diff --git a/src/qemu_conf.c b/src/qemu_conf.c index ef45b12dfa..6f58ee8123 100644 --- a/src/qemu_conf.c +++ b/src/qemu_conf.c @@ -517,9 +517,10 @@ int qemudExtractVersion(virConnectPtr conn, 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; } @@ -580,10 +581,11 @@ qemudNetworkIfaceConnect(virConnectPtr conn, } } + 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; } @@ -598,7 +600,7 @@ qemudNetworkIfaceConnect(virConnectPtr conn, 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; } diff --git a/src/storage_conf.c b/src/storage_conf.c index 7eb89e7be4..70107a287a 100644 --- a/src/storage_conf.c +++ b/src/storage_conf.c @@ -1,7 +1,7 @@ /* * 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 @@ -1384,10 +1384,11 @@ virStoragePoolLoadAllConfigs(virConnectPtr conn, 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; } diff --git a/src/storage_driver.c b/src/storage_driver.c index a4560611a9..f1320c5be7 100644 --- a/src/storage_driver.c +++ b/src/storage_driver.c @@ -1,7 +1,7 @@ /* * 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 @@ -567,9 +567,11 @@ storagePoolUndefine(virStoragePoolPtr obj) { 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); diff --git a/src/uml_driver.c b/src/uml_driver.c index 0fe2fac4f5..c5a06a2100 100644 --- a/src/uml_driver.c +++ b/src/uml_driver.c @@ -376,8 +376,9 @@ umlStartup(void) { } 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; } @@ -726,6 +727,7 @@ static int umlStartVMDaemon(virConnectPtr conn, int *tapfds = NULL; int ntapfds = 0; fd_set keepfd; + char ebuf[1024]; FD_ZERO(&keepfd); @@ -792,25 +794,25 @@ static int umlStartVMDaemon(virConnectPtr conn, 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; @@ -825,7 +827,7 @@ static int umlStartVMDaemon(virConnectPtr conn, /* 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]); diff --git a/src/util.c b/src/util.c index 96c1b00aef..01fe37a6c0 100644 --- a/src/util.c +++ b/src/util.c @@ -755,17 +755,19 @@ int virFileReadLimFD(int fd_arg, int maxlen, char **buf) 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; } diff --git a/src/uuid.c b/src/uuid.c index 9d263de426..6f7d85f421 100644 --- a/src/uuid.c +++ b/src/uuid.c @@ -1,5 +1,5 @@ /* - * 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 @@ -36,6 +36,7 @@ #include "c-ctype.h" #include "internal.h" #include "util.h" +#include "virterror_internal.h" #define qemudLog(level, msg...) fprintf(stderr, msg) @@ -99,10 +100,13 @@ virUUIDGenerate(unsigned char *uuid) 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); } diff --git a/src/xen_internal.c b/src/xen_internal.c index 0a01f5e073..a866af16f1 100644 --- a/src/xen_internal.c +++ b/src/xen_internal.c @@ -2265,8 +2265,9 @@ get_cpu_flags(virConnectPtr conn, const char **hvm, int *pae, int *longmode) 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; }