mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 05:35:25 +00:00
Use g_strerror instead of virStrerror
Remove lots of stack-allocated buffers. Signed-off-by: Ján Tomko <jtomko@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
cc7868a8b3
commit
b0eea635b3
@ -1740,14 +1740,13 @@ libxlDriverConfigNew(void)
|
||||
int
|
||||
libxlDriverConfigInit(libxlDriverConfigPtr cfg)
|
||||
{
|
||||
char ebuf[1024];
|
||||
unsigned int free_mem;
|
||||
|
||||
if (virFileMakePath(cfg->logDir) < 0) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("failed to create log dir '%s': %s"),
|
||||
cfg->logDir,
|
||||
virStrerror(errno, ebuf, sizeof(ebuf)));
|
||||
g_strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -654,7 +654,6 @@ libxlStateInitialize(bool privileged,
|
||||
{
|
||||
libxlDriverConfigPtr cfg;
|
||||
g_autofree char *driverConf = NULL;
|
||||
char ebuf[1024];
|
||||
bool autostart = true;
|
||||
|
||||
if (root != NULL) {
|
||||
@ -725,35 +724,35 @@ libxlStateInitialize(bool privileged,
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("failed to create state dir '%s': %s"),
|
||||
cfg->stateDir,
|
||||
virStrerror(errno, ebuf, sizeof(ebuf)));
|
||||
g_strerror(errno));
|
||||
goto error;
|
||||
}
|
||||
if (virFileMakePath(cfg->libDir) < 0) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("failed to create lib dir '%s': %s"),
|
||||
cfg->libDir,
|
||||
virStrerror(errno, ebuf, sizeof(ebuf)));
|
||||
g_strerror(errno));
|
||||
goto error;
|
||||
}
|
||||
if (virFileMakePath(cfg->saveDir) < 0) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("failed to create save dir '%s': %s"),
|
||||
cfg->saveDir,
|
||||
virStrerror(errno, ebuf, sizeof(ebuf)));
|
||||
g_strerror(errno));
|
||||
goto error;
|
||||
}
|
||||
if (virFileMakePath(cfg->autoDumpDir) < 0) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("failed to create dump dir '%s': %s"),
|
||||
cfg->autoDumpDir,
|
||||
virStrerror(errno, ebuf, sizeof(ebuf)));
|
||||
g_strerror(errno));
|
||||
goto error;
|
||||
}
|
||||
if (virFileMakePath(cfg->channelDir) < 0) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("failed to create channel dir '%s': %s"),
|
||||
cfg->channelDir,
|
||||
virStrerror(errno, ebuf, sizeof(ebuf)));
|
||||
g_strerror(errno));
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
@ -67,7 +67,6 @@ libvirt_vmessage(xentoollog_logger *logger_in,
|
||||
char timestamp[VIR_TIME_STRING_BUFLEN];
|
||||
char *message = NULL;
|
||||
char *start, *end;
|
||||
char ebuf[1024];
|
||||
|
||||
VIR_DEBUG("libvirt_vmessage: context='%s' format='%s'", context, format);
|
||||
|
||||
@ -104,7 +103,7 @@ libvirt_vmessage(xentoollog_logger *logger_in,
|
||||
fprintf(logFile, "%s", message);
|
||||
|
||||
if (errnoval >= 0)
|
||||
fprintf(logFile, ": %s", virStrerror(errnoval, ebuf, sizeof(ebuf)));
|
||||
fprintf(logFile, ": %s", g_strerror(errnoval));
|
||||
|
||||
fputc('\n', logFile);
|
||||
fflush(logFile);
|
||||
@ -192,14 +191,13 @@ libxlLoggerOpenFile(libxlLoggerPtr logger,
|
||||
char *path = NULL;
|
||||
FILE *logFile = NULL;
|
||||
char *domidstr = NULL;
|
||||
char ebuf[1024];
|
||||
|
||||
path = g_strdup_printf("%s/%s.log", logger->logDir, name);
|
||||
domidstr = g_strdup_printf("%d", id);
|
||||
|
||||
if (!(logFile = fopen(path, "a"))) {
|
||||
VIR_WARN("Failed to open log file %s: %s",
|
||||
path, virStrerror(errno, ebuf, sizeof(ebuf)));
|
||||
path, g_strerror(errno));
|
||||
goto cleanup;
|
||||
}
|
||||
ignore_value(virHashAddEntry(logger->files, domidstr, logFile));
|
||||
|
@ -1225,9 +1225,8 @@ int main(int argc, char **argv) {
|
||||
old_umask = umask(077);
|
||||
VIR_DEBUG("Ensuring run dir '%s' exists", run_dir);
|
||||
if (virFileMakePath(run_dir) < 0) {
|
||||
char ebuf[1024];
|
||||
VIR_ERROR(_("unable to create rundir %s: %s"), run_dir,
|
||||
virStrerror(errno, ebuf, sizeof(ebuf)));
|
||||
g_strerror(errno));
|
||||
ret = VIR_LOCK_DAEMON_ERR_RUNDIR;
|
||||
umask(old_umask);
|
||||
goto cleanup;
|
||||
@ -1253,17 +1252,15 @@ int main(int argc, char **argv) {
|
||||
};
|
||||
|
||||
if (godaemon) {
|
||||
char ebuf[1024];
|
||||
|
||||
if (chdir("/") < 0) {
|
||||
VIR_ERROR(_("cannot change to root directory: %s"),
|
||||
virStrerror(errno, ebuf, sizeof(ebuf)));
|
||||
g_strerror(errno));
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if ((statuswrite = virLockDaemonForkIntoBackground(argv[0])) < 0) {
|
||||
VIR_ERROR(_("Failed to fork as daemon: %s"),
|
||||
virStrerror(errno, ebuf, sizeof(ebuf)));
|
||||
g_strerror(errno));
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
|
@ -993,9 +993,8 @@ int main(int argc, char **argv) {
|
||||
old_umask = umask(077);
|
||||
VIR_DEBUG("Ensuring run dir '%s' exists", run_dir);
|
||||
if (virFileMakePath(run_dir) < 0) {
|
||||
char ebuf[1024];
|
||||
VIR_ERROR(_("unable to create rundir %s: %s"), run_dir,
|
||||
virStrerror(errno, ebuf, sizeof(ebuf)));
|
||||
g_strerror(errno));
|
||||
ret = VIR_LOG_DAEMON_ERR_RUNDIR;
|
||||
umask(old_umask);
|
||||
goto cleanup;
|
||||
@ -1023,17 +1022,15 @@ int main(int argc, char **argv) {
|
||||
};
|
||||
|
||||
if (godaemon) {
|
||||
char ebuf[1024];
|
||||
|
||||
if (chdir("/") < 0) {
|
||||
VIR_ERROR(_("cannot change to root directory: %s"),
|
||||
virStrerror(errno, ebuf, sizeof(ebuf)));
|
||||
g_strerror(errno));
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if ((statuswrite = virLogDaemonForkIntoBackground(argv[0])) < 0) {
|
||||
VIR_ERROR(_("Failed to fork as daemon: %s"),
|
||||
virStrerror(errno, ebuf, sizeof(ebuf)));
|
||||
g_strerror(errno));
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
|
@ -566,12 +566,11 @@ static int lxcContainerUnmountSubtree(const char *prefix,
|
||||
for (i = 0; i < nmounts; i++) {
|
||||
VIR_DEBUG("Umount %s", mounts[i]);
|
||||
if (umount(mounts[i]) < 0) {
|
||||
char ebuf[1024];
|
||||
failedUmount = mounts[i];
|
||||
saveErrno = errno;
|
||||
VIR_WARN("Failed to unmount '%s', trying to detach subtree '%s': %s",
|
||||
failedUmount, mounts[nmounts-1],
|
||||
virStrerror(errno, ebuf, sizeof(ebuf)));
|
||||
g_strerror(errno));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -135,14 +135,13 @@ static void
|
||||
lxcProcessRemoveDomainStatus(virLXCDriverConfigPtr cfg,
|
||||
virDomainObjPtr vm)
|
||||
{
|
||||
char ebuf[1024];
|
||||
char *file = NULL;
|
||||
|
||||
file = g_strdup_printf("%s/%s.xml", cfg->stateDir, vm->def->name);
|
||||
|
||||
if (unlink(file) < 0 && errno != ENOENT && errno != ENOTDIR)
|
||||
VIR_WARN("Failed to remove domain XML for %s: %s",
|
||||
vm->def->name, virStrerror(errno, ebuf, sizeof(ebuf)));
|
||||
vm->def->name, g_strerror(errno));
|
||||
VIR_FREE(file);
|
||||
}
|
||||
|
||||
@ -1410,7 +1409,7 @@ int virLXCProcessStart(virConnectPtr conn,
|
||||
if (safewrite(logfd, timestamp, strlen(timestamp)) < 0 ||
|
||||
safewrite(logfd, START_POSTFIX, strlen(START_POSTFIX)) < 0) {
|
||||
VIR_WARN("Unable to write timestamp to logfile: %s",
|
||||
virStrerror(errno, ebuf, sizeof(ebuf)));
|
||||
g_strerror(errno));
|
||||
}
|
||||
VIR_FREE(timestamp);
|
||||
|
||||
@ -1418,7 +1417,7 @@ int virLXCProcessStart(virConnectPtr conn,
|
||||
virCommandWriteArgLog(cmd, logfd);
|
||||
if ((pos = lseek(logfd, 0, SEEK_END)) < 0)
|
||||
VIR_WARN("Unable to seek to end of logfile: %s",
|
||||
virStrerror(errno, ebuf, sizeof(ebuf)));
|
||||
g_strerror(errno));
|
||||
|
||||
VIR_DEBUG("Launching container");
|
||||
virCommandRawStatus(cmd);
|
||||
|
@ -996,11 +996,10 @@ networkKillDaemon(pid_t pid,
|
||||
if (errno == ESRCH) {
|
||||
ret = 0;
|
||||
} else {
|
||||
char ebuf[1024];
|
||||
VIR_WARN("Failed to terminate %s process %d "
|
||||
"for network '%s' with SIG%s: %s",
|
||||
daemonName, pid, networkName, signame,
|
||||
virStrerror(errno, ebuf, sizeof(ebuf)));
|
||||
g_strerror(errno));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
@ -4646,10 +4646,9 @@ virQEMUCapsIsValid(void *data,
|
||||
}
|
||||
|
||||
if (stat(qemuCaps->binary, &sb) < 0) {
|
||||
char ebuf[1024];
|
||||
VIR_DEBUG("Failed to stat QEMU binary '%s': %s",
|
||||
qemuCaps->binary,
|
||||
virStrerror(errno, ebuf, sizeof(ebuf)));
|
||||
g_strerror(errno));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -351,7 +351,6 @@ qemuCreateInBridgePortWithHelper(virQEMUDriverConfigPtr cfg,
|
||||
} while (*tapfd < 0 && errno == EINTR);
|
||||
|
||||
if (*tapfd < 0) {
|
||||
char ebuf[1024];
|
||||
char *errstr = NULL;
|
||||
|
||||
if (!(cmdstr = virCommandToString(cmd, false)))
|
||||
@ -363,7 +362,7 @@ qemuCreateInBridgePortWithHelper(virQEMUDriverConfigPtr cfg,
|
||||
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("%s: failed to communicate with bridge helper: %s%s"),
|
||||
cmdstr, virStrerror(errno, ebuf, sizeof(ebuf)),
|
||||
cmdstr, g_strerror(errno),
|
||||
NULLSTR_EMPTY(errstr));
|
||||
VIR_FREE(errstr);
|
||||
goto cleanup;
|
||||
|
@ -105,7 +105,6 @@ static void
|
||||
qemuProcessRemoveDomainStatus(virQEMUDriverPtr driver,
|
||||
virDomainObjPtr vm)
|
||||
{
|
||||
char ebuf[1024];
|
||||
g_autofree char *file = NULL;
|
||||
qemuDomainObjPrivatePtr priv = vm->privateData;
|
||||
g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver);
|
||||
@ -114,13 +113,13 @@ qemuProcessRemoveDomainStatus(virQEMUDriverPtr driver,
|
||||
|
||||
if (unlink(file) < 0 && errno != ENOENT && errno != ENOTDIR)
|
||||
VIR_WARN("Failed to remove domain XML for %s: %s",
|
||||
vm->def->name, virStrerror(errno, ebuf, sizeof(ebuf)));
|
||||
vm->def->name, g_strerror(errno));
|
||||
|
||||
if (priv->pidfile &&
|
||||
unlink(priv->pidfile) < 0 &&
|
||||
errno != ENOENT)
|
||||
VIR_WARN("Failed to remove PID file for %s: %s",
|
||||
vm->def->name, virStrerror(errno, ebuf, sizeof(ebuf)));
|
||||
vm->def->name, g_strerror(errno));
|
||||
}
|
||||
|
||||
|
||||
@ -8344,13 +8343,11 @@ qemuProcessQMPStop(qemuProcessQMPPtr proc)
|
||||
virDomainObjEndAPI(&proc->vm);
|
||||
|
||||
if (proc->pid != 0) {
|
||||
char ebuf[1024];
|
||||
|
||||
VIR_DEBUG("Killing QMP caps process %lld", (long long)proc->pid);
|
||||
if (virProcessKill(proc->pid, SIGKILL) < 0 && errno != ESRCH)
|
||||
VIR_ERROR(_("Failed to kill process %lld: %s"),
|
||||
(long long)proc->pid,
|
||||
virStrerror(errno, ebuf, sizeof(ebuf)));
|
||||
g_strerror(errno));
|
||||
|
||||
proc->pid = 0;
|
||||
}
|
||||
|
@ -189,12 +189,10 @@ static int daemonForkIntoBackground(const char *argv0)
|
||||
VIR_FORCE_CLOSE(statuspipe[0]);
|
||||
|
||||
if (ret != 1) {
|
||||
char ebuf[1024];
|
||||
|
||||
fprintf(stderr,
|
||||
_("%s: error: unable to determine if daemon is "
|
||||
"running: %s\n"), argv0,
|
||||
virStrerror(errno, ebuf, sizeof(ebuf)));
|
||||
g_strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
} else if (status != 0) {
|
||||
fprintf(stderr,
|
||||
@ -1194,17 +1192,15 @@ int main(int argc, char **argv) {
|
||||
NULLSTR(sock_file_adm));
|
||||
|
||||
if (godaemon) {
|
||||
char ebuf[1024];
|
||||
|
||||
if (chdir("/") < 0) {
|
||||
VIR_ERROR(_("cannot change to root directory: %s"),
|
||||
virStrerror(errno, ebuf, sizeof(ebuf)));
|
||||
g_strerror(errno));
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if ((statuswrite = daemonForkIntoBackground(argv[0])) < 0) {
|
||||
VIR_ERROR(_("Failed to fork as daemon: %s"),
|
||||
virStrerror(errno, ebuf, sizeof(ebuf)));
|
||||
g_strerror(errno));
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
@ -1227,9 +1223,8 @@ int main(int argc, char **argv) {
|
||||
old_umask = umask(077);
|
||||
VIR_DEBUG("Ensuring run dir '%s' exists", run_dir);
|
||||
if (virFileMakePath(run_dir) < 0) {
|
||||
char ebuf[1024];
|
||||
VIR_ERROR(_("unable to create rundir %s: %s"), run_dir,
|
||||
virStrerror(errno, ebuf, sizeof(ebuf)));
|
||||
g_strerror(errno));
|
||||
ret = VIR_DAEMON_ERR_RUNDIR;
|
||||
goto cleanup;
|
||||
}
|
||||
|
@ -1407,7 +1407,6 @@ virSecurityManagerMetadataUnlock(virSecurityManagerPtr mgr G_GNUC_UNUSED,
|
||||
return;
|
||||
|
||||
for (i = 0; i < (*state)->nfds; i++) {
|
||||
char ebuf[1024];
|
||||
const char *path = (*state)->paths[i];
|
||||
int fd = (*state)->fds[i];
|
||||
|
||||
@ -1415,12 +1414,12 @@ virSecurityManagerMetadataUnlock(virSecurityManagerPtr mgr G_GNUC_UNUSED,
|
||||
* happen on VIR_CLOSE() anyway. But let's play it nice. */
|
||||
if (virFileUnlock(fd, METADATA_OFFSET, METADATA_LEN) < 0) {
|
||||
VIR_WARN("Unable to unlock fd %d path %s: %s",
|
||||
fd, path, virStrerror(errno, ebuf, sizeof(ebuf)));
|
||||
fd, path, g_strerror(errno));
|
||||
}
|
||||
|
||||
if (VIR_CLOSE(fd) < 0) {
|
||||
VIR_WARN("Unable to close fd %d path %s: %s",
|
||||
fd, path, virStrerror(errno, ebuf, sizeof(ebuf)));
|
||||
fd, path, g_strerror(errno));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1451,7 +1451,6 @@ virSecuritySELinuxRestoreFileLabel(virSecurityManagerPtr mgr,
|
||||
struct stat buf;
|
||||
security_context_t fcon = NULL;
|
||||
char *newpath = NULL;
|
||||
char ebuf[1024];
|
||||
int rc;
|
||||
int ret = -1;
|
||||
|
||||
@ -1465,7 +1464,7 @@ virSecuritySELinuxRestoreFileLabel(virSecurityManagerPtr mgr,
|
||||
|
||||
if (virFileResolveLink(path, &newpath) < 0) {
|
||||
VIR_WARN("cannot resolve symlink %s: %s", path,
|
||||
virStrerror(errno, ebuf, sizeof(ebuf)));
|
||||
g_strerror(errno));
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
@ -1492,7 +1491,7 @@ virSecuritySELinuxRestoreFileLabel(virSecurityManagerPtr mgr,
|
||||
if (!recall || rc == -2) {
|
||||
if (stat(newpath, &buf) != 0) {
|
||||
VIR_WARN("cannot stat %s: %s", newpath,
|
||||
virStrerror(errno, ebuf, sizeof(ebuf)));
|
||||
g_strerror(errno));
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
|
@ -900,9 +900,8 @@ storagePoolUndefine(virStoragePoolPtr pool)
|
||||
|
||||
if (autostartLink && unlink(autostartLink) < 0 &&
|
||||
errno != ENOENT && errno != ENOTDIR) {
|
||||
char ebuf[1024];
|
||||
VIR_ERROR(_("Failed to delete autostart link '%s': %s"),
|
||||
autostartLink, virStrerror(errno, ebuf, sizeof(ebuf)));
|
||||
autostartLink, g_strerror(errno));
|
||||
}
|
||||
|
||||
event = virStoragePoolEventLifecycleNew(def->name,
|
||||
|
@ -121,9 +121,8 @@ void virAuditSend(virLogSourcePtr source,
|
||||
VIR_WARN("Unknown audit record type %d", type);
|
||||
else if (audit_log_user_message(auditfd, record_types[type], str, NULL,
|
||||
clientaddr, clienttty, success) < 0) {
|
||||
char ebuf[1024];
|
||||
VIR_WARN("Failed to send audit message %s: %s",
|
||||
NULLSTR(str), virStrerror(errno, ebuf, sizeof(ebuf)));
|
||||
NULLSTR(str), g_strerror(errno));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -2061,9 +2061,8 @@ virCommandWriteArgLog(virCommandPtr cmd, int logfd)
|
||||
}
|
||||
|
||||
if (ioError) {
|
||||
char ebuf[1024];
|
||||
VIR_WARN("Unable to write command %s args to logfile: %s",
|
||||
cmd->args[0], virStrerror(ioError, ebuf, sizeof(ebuf)));
|
||||
cmd->args[0], g_strerror(ioError));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -127,9 +127,8 @@ int virFileClose(int *fdptr, virFileCloseFlags flags)
|
||||
if (!(flags & VIR_FILE_CLOSE_IGNORE_EBADF))
|
||||
VIR_WARN("Tried to close invalid fd %d", *fdptr);
|
||||
} else {
|
||||
char ebuf[1024] G_GNUC_UNUSED;
|
||||
VIR_DEBUG("Failed to close fd %d: %s",
|
||||
*fdptr, virStrerror(errno, ebuf, sizeof(ebuf)));
|
||||
*fdptr, g_strerror(errno));
|
||||
}
|
||||
} else {
|
||||
VIR_DEBUG("Closed fd %d", *fdptr);
|
||||
|
@ -1228,9 +1228,8 @@ virHostCPUGetMicrocodeVersion(void)
|
||||
unsigned int version = 0;
|
||||
|
||||
if (virFileReadHeaderQuiet(CPUINFO_PATH, 4096, &outbuf) < 0) {
|
||||
char ebuf[1024];
|
||||
VIR_DEBUG("Failed to read microcode version from %s: %s",
|
||||
CPUINFO_PATH, virStrerror(errno, ebuf, sizeof(ebuf)));
|
||||
CPUINFO_PATH, g_strerror(errno));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1301,13 +1300,12 @@ virHostCPUGetMSR(unsigned long index,
|
||||
uint64_t *msr)
|
||||
{
|
||||
VIR_AUTOCLOSE fd = -1;
|
||||
char ebuf[1024];
|
||||
|
||||
*msr = 0;
|
||||
|
||||
if ((fd = open(MSR_DEVICE, O_RDONLY)) < 0) {
|
||||
VIR_DEBUG("Unable to open %s: %s",
|
||||
MSR_DEVICE, virStrerror(errno, ebuf, sizeof(ebuf)));
|
||||
MSR_DEVICE, g_strerror(errno));
|
||||
} else {
|
||||
int rc = pread(fd, msr, sizeof(*msr), index);
|
||||
|
||||
@ -1320,7 +1318,7 @@ virHostCPUGetMSR(unsigned long index,
|
||||
}
|
||||
|
||||
VIR_DEBUG("Cannot read MSR 0x%lx from %s: %s",
|
||||
index, MSR_DEVICE, virStrerror(errno, ebuf, sizeof(ebuf)));
|
||||
index, MSR_DEVICE, g_strerror(errno));
|
||||
}
|
||||
|
||||
VIR_DEBUG("Falling back to KVM ioctl");
|
||||
|
@ -89,17 +89,15 @@ static void virLockSpaceResourceFree(virLockSpaceResourcePtr res)
|
||||
} else {
|
||||
if (unlink(res->path) < 0 &&
|
||||
errno != ENOENT) {
|
||||
char ebuf[1024];
|
||||
VIR_WARN("Failed to unlink resource %s: %s",
|
||||
res->path, virStrerror(errno, ebuf, sizeof(ebuf)));
|
||||
res->path, g_strerror(errno));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (unlink(res->path) < 0 &&
|
||||
errno != ENOENT) {
|
||||
char ebuf[1024];
|
||||
VIR_WARN("Failed to unlink resource %s: %s",
|
||||
res->path, virStrerror(errno, ebuf, sizeof(ebuf)));
|
||||
res->path, g_strerror(errno));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -173,9 +171,8 @@ virLockSpaceResourceNew(virLockSpacePtr lockspace,
|
||||
* one that now exists on the filesystem
|
||||
*/
|
||||
if (stat(res->path, &a) < 0) {
|
||||
char ebuf[1024] G_GNUC_UNUSED;
|
||||
VIR_DEBUG("Resource '%s' disappeared: %s",
|
||||
res->path, virStrerror(errno, ebuf, sizeof(ebuf)));
|
||||
res->path, g_strerror(errno));
|
||||
VIR_FORCE_CLOSE(res->fd);
|
||||
/* Someone else must be racing with us, so try again */
|
||||
continue;
|
||||
|
@ -289,9 +289,8 @@ virPCIDeviceConfigOpenInternal(virPCIDevicePtr dev, bool readonly, bool fatal)
|
||||
_("Failed to open config space file '%s'"),
|
||||
dev->path);
|
||||
} else {
|
||||
char ebuf[1024];
|
||||
VIR_WARN("Failed to open config space file '%s': %s",
|
||||
dev->path, virStrerror(errno, ebuf, sizeof(ebuf)));
|
||||
dev->path, g_strerror(errno));
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
@ -322,9 +321,8 @@ static void
|
||||
virPCIDeviceConfigClose(virPCIDevicePtr dev, int cfgfd)
|
||||
{
|
||||
if (VIR_CLOSE(cfgfd) < 0) {
|
||||
char ebuf[1024];
|
||||
VIR_WARN("Failed to close config space file '%s': %s",
|
||||
dev->path, virStrerror(errno, ebuf, sizeof(ebuf)));
|
||||
dev->path, g_strerror(errno));
|
||||
}
|
||||
}
|
||||
|
||||
@ -340,9 +338,8 @@ virPCIDeviceRead(virPCIDevicePtr dev,
|
||||
|
||||
if (lseek(cfgfd, pos, SEEK_SET) != pos ||
|
||||
saferead(cfgfd, buf, buflen) != buflen) {
|
||||
char ebuf[1024];
|
||||
VIR_WARN("Failed to read from '%s' : %s", dev->path,
|
||||
virStrerror(errno, ebuf, sizeof(ebuf)));
|
||||
g_strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@ -407,9 +404,8 @@ virPCIDeviceWrite(virPCIDevicePtr dev,
|
||||
{
|
||||
if (lseek(cfgfd, pos, SEEK_SET) != pos ||
|
||||
safewrite(cfgfd, buf, buflen) != buflen) {
|
||||
char ebuf[1024];
|
||||
VIR_WARN("Failed to write to '%s' : %s", dev->path,
|
||||
virStrerror(errno, ebuf, sizeof(ebuf)));
|
||||
g_strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
|
@ -374,9 +374,8 @@ int virPidFileAcquirePath(const char *path,
|
||||
* one that now exists on the filesystem
|
||||
*/
|
||||
if (stat(path, &a) < 0) {
|
||||
char ebuf[1024] G_GNUC_UNUSED;
|
||||
VIR_DEBUG("Pid file '%s' disappeared: %s",
|
||||
path, virStrerror(errno, ebuf, sizeof(ebuf)));
|
||||
path, g_strerror(errno));
|
||||
VIR_FORCE_CLOSE(fd);
|
||||
/* Someone else must be racing with us, so try again */
|
||||
continue;
|
||||
|
@ -1292,9 +1292,8 @@ virProcessNamespaceAvailable(unsigned int ns)
|
||||
cpid = clone(virProcessDummyChild, childStack, flags, NULL);
|
||||
|
||||
if (cpid < 0) {
|
||||
char ebuf[1024] G_GNUC_UNUSED;
|
||||
VIR_DEBUG("clone call returned %s, container support is not enabled",
|
||||
virStrerror(errno, ebuf, sizeof(ebuf)));
|
||||
g_strerror(errno));
|
||||
return -1;
|
||||
} else if (virProcessWait(cpid, NULL, false) < 0) {
|
||||
return -1;
|
||||
|
@ -793,12 +793,11 @@ virGetUserIDByName(const char *name, uid_t *uid, bool missing_ok)
|
||||
|
||||
if (!pw) {
|
||||
if (rc != 0 && !missing_ok) {
|
||||
char buf[1024];
|
||||
/* log the possible error from getpwnam_r. Unfortunately error
|
||||
* reporting from this function is bad and we can't really
|
||||
* rely on it, so we just report that the user wasn't found */
|
||||
VIR_WARN("User record for user '%s' was not found: %s",
|
||||
name, virStrerror(rc, buf, sizeof(buf)));
|
||||
name, g_strerror(rc));
|
||||
}
|
||||
|
||||
ret = 1;
|
||||
@ -876,12 +875,11 @@ virGetGroupIDByName(const char *name, gid_t *gid, bool missing_ok)
|
||||
|
||||
if (!gr) {
|
||||
if (rc != 0 && !missing_ok) {
|
||||
char buf[1024];
|
||||
/* log the possible error from getgrnam_r. Unfortunately error
|
||||
* reporting from this function is bad and we can't really
|
||||
* rely on it, so we just report that the user wasn't found */
|
||||
VIR_WARN("Group record for user '%s' was not found: %s",
|
||||
name, virStrerror(rc, buf, sizeof(buf)));
|
||||
name, g_strerror(rc));
|
||||
}
|
||||
|
||||
ret = 1;
|
||||
|
28
tools/vsh.c
28
tools/vsh.c
@ -1930,7 +1930,7 @@ vshTTYMakeRaw(vshControl *ctl G_GNUC_UNUSED,
|
||||
{
|
||||
#ifndef WIN32
|
||||
struct termios rawattr = ctl->termattr;
|
||||
char ebuf[1024];
|
||||
|
||||
|
||||
if (!ctl->istty) {
|
||||
if (report_errors) {
|
||||
@ -1946,7 +1946,7 @@ vshTTYMakeRaw(vshControl *ctl G_GNUC_UNUSED,
|
||||
if (tcsetattr(STDIN_FILENO, TCSAFLUSH, &rawattr) < 0) {
|
||||
if (report_errors)
|
||||
vshError(ctl, _("unable to set tty attributes: %s"),
|
||||
virStrerror(errno, ebuf, sizeof(ebuf)));
|
||||
g_strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
@ -2120,12 +2120,10 @@ vshEventWait(vshControl *ctl)
|
||||
assert(ctl->eventPipe[0] >= 0);
|
||||
while ((rv = read(ctl->eventPipe[0], &buf, 1)) < 0 && errno == EINTR);
|
||||
if (rv != 1) {
|
||||
char ebuf[1024];
|
||||
|
||||
if (!rv)
|
||||
errno = EPIPE;
|
||||
vshError(ctl, _("failed to determine loop exit status: %s"),
|
||||
virStrerror(errno, ebuf, sizeof(ebuf)));
|
||||
g_strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
return buf;
|
||||
@ -2256,13 +2254,11 @@ vshOutputLogFile(vshControl *ctl, int log_level, const char *msg_format,
|
||||
void
|
||||
vshCloseLogFile(vshControl *ctl)
|
||||
{
|
||||
char ebuf[1024];
|
||||
|
||||
/* log file close */
|
||||
if (VIR_CLOSE(ctl->log_fd) < 0) {
|
||||
vshError(ctl, _("%s: failed to write log file: %s"),
|
||||
ctl->logfile ? ctl->logfile : "?",
|
||||
virStrerror(errno, ebuf, sizeof(ebuf)));
|
||||
g_strerror(errno));
|
||||
}
|
||||
|
||||
if (ctl->logfile) {
|
||||
@ -2366,7 +2362,6 @@ vshEditWriteToTempFile(vshControl *ctl, const char *doc)
|
||||
char *ret;
|
||||
const char *tmpdir;
|
||||
int fd;
|
||||
char ebuf[1024];
|
||||
|
||||
tmpdir = getenv("TMPDIR");
|
||||
if (!tmpdir) tmpdir = "/tmp";
|
||||
@ -2374,14 +2369,14 @@ vshEditWriteToTempFile(vshControl *ctl, const char *doc)
|
||||
fd = g_mkstemp_full(ret, O_RDWR | O_CLOEXEC, S_IRUSR | S_IWUSR);
|
||||
if (fd == -1) {
|
||||
vshError(ctl, _("g_mkstemp_full: failed to create temporary file: %s"),
|
||||
virStrerror(errno, ebuf, sizeof(ebuf)));
|
||||
g_strerror(errno));
|
||||
VIR_FREE(ret);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (safewrite(fd, doc, strlen(doc)) == -1) {
|
||||
vshError(ctl, _("write: %s: failed to write to temporary file: %s"),
|
||||
ret, virStrerror(errno, ebuf, sizeof(ebuf)));
|
||||
ret, g_strerror(errno));
|
||||
VIR_FORCE_CLOSE(fd);
|
||||
unlink(ret);
|
||||
VIR_FREE(ret);
|
||||
@ -2389,7 +2384,7 @@ vshEditWriteToTempFile(vshControl *ctl, const char *doc)
|
||||
}
|
||||
if (VIR_CLOSE(fd) < 0) {
|
||||
vshError(ctl, _("close: %s: failed to write or close temporary file: %s"),
|
||||
ret, virStrerror(errno, ebuf, sizeof(ebuf)));
|
||||
ret, g_strerror(errno));
|
||||
unlink(ret);
|
||||
VIR_FREE(ret);
|
||||
return NULL;
|
||||
@ -2459,12 +2454,11 @@ char *
|
||||
vshEditReadBackFile(vshControl *ctl, const char *filename)
|
||||
{
|
||||
char *ret;
|
||||
char ebuf[1024];
|
||||
|
||||
if (virFileReadAll(filename, VSH_MAX_XML_FILE, &ret) == -1) {
|
||||
vshError(ctl,
|
||||
_("%s: failed to read temporary file: %s"),
|
||||
filename, virStrerror(errno, ebuf, sizeof(ebuf)));
|
||||
filename, g_strerror(errno));
|
||||
return NULL;
|
||||
}
|
||||
return ret;
|
||||
@ -2916,9 +2910,8 @@ vshReadlineDeinit(vshControl *ctl)
|
||||
if (ctl->historyfile != NULL) {
|
||||
if (virFileMakePathWithMode(ctl->historydir, 0755) < 0 &&
|
||||
errno != EEXIST) {
|
||||
char ebuf[1024];
|
||||
vshError(ctl, _("Failed to create '%s': %s"),
|
||||
ctl->historydir, virStrerror(errno, ebuf, sizeof(ebuf)));
|
||||
ctl->historydir, g_strerror(errno));
|
||||
} else {
|
||||
write_history(ctl->historyfile);
|
||||
}
|
||||
@ -3155,7 +3148,6 @@ cmdCd(vshControl *ctl, const vshCmd *cmd)
|
||||
{
|
||||
const char *dir = NULL;
|
||||
g_autofree char *dir_malloced = NULL;
|
||||
char ebuf[1024];
|
||||
|
||||
if (!ctl->imode) {
|
||||
vshError(ctl, "%s", _("cd: command valid only in interactive mode"));
|
||||
@ -3169,7 +3161,7 @@ cmdCd(vshControl *ctl, const vshCmd *cmd)
|
||||
|
||||
if (chdir(dir) == -1) {
|
||||
vshError(ctl, _("cd: %s: %s"),
|
||||
virStrerror(errno, ebuf, sizeof(ebuf)), dir);
|
||||
g_strerror(errno), dir);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user