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