mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-03 11:35:19 +00:00
qemu: work around dash 0.5.5 bug in managed save
Older dash mistakenly truncates regular files when using <> redirection; this kills our use of double dd to reduce storage overhead when saving qemu images. But qemu insists on running a command through /bin/sh, so we work around it by having qemu run $sh -c 'real command' when we have a replacement $sh in mind. * configure.ac (VIR_WRAPPER_SHELL): Define to a replacement shell, if /bin/sh is broken on <> redirection. * src/qemu/qemu_monitor.h (VIR_WRAPPER_SHELL_PREFIX) (VIR_WRAPPER_SHELL_SUFFIX): New macros. * src/qemu/qemu_monitor_text.c (qemuMonitorTextMigrateToFile): Use them. * src/qemu/qemu_monitor_json.c (qemuMonitorJSONMigrateToFile): Likewise.
This commit is contained in:
parent
ff9bbffcd9
commit
f22e670b4a
50
configure.ac
50
configure.ac
@ -592,6 +592,56 @@ if test "$with_lxc" = "yes" ; then
|
|||||||
fi
|
fi
|
||||||
AM_CONDITIONAL([WITH_LXC], [test "$with_lxc" = "yes"])
|
AM_CONDITIONAL([WITH_LXC], [test "$with_lxc" = "yes"])
|
||||||
|
|
||||||
|
dnl
|
||||||
|
dnl check for shell that understands <> redirection without truncation,
|
||||||
|
dnl needed by src/qemu/qemu_monitor_{text,json}.c.
|
||||||
|
dnl
|
||||||
|
if test "$with_qemu" = yes; then
|
||||||
|
lv_wrapper_shell=
|
||||||
|
AC_CACHE_CHECK([for shell that supports <> redirection],
|
||||||
|
[lv_cv_wrapper_shell],
|
||||||
|
[
|
||||||
|
# If cross-compiling, guess that /bin/sh is good enough except for
|
||||||
|
# Linux, where it might be dash 0.5.5 which is known broken; and on
|
||||||
|
# Linux, we have a good chance that /bin/bash will exist.
|
||||||
|
# If we guess wrong, a user can override the cache variable.
|
||||||
|
# Going through /bin/bash is a slight slowdown if /bin/sh works.
|
||||||
|
if test "$cross_compiling" = yes; then
|
||||||
|
case $host_os in
|
||||||
|
linux*) lv_cv_wrapper_shell=/bin/bash ;;
|
||||||
|
*) lv_cv_wrapper_shell=/bin/sh ;;
|
||||||
|
esac
|
||||||
|
else
|
||||||
|
for lv_cv_wrapper_shell in /bin/sh bash ksh zsh none; do
|
||||||
|
test $lv_cv_wrapper_shell = none &&
|
||||||
|
AC_MSG_ERROR([could not find decent shell])
|
||||||
|
echo a > conftest.a
|
||||||
|
$lv_cv_wrapper_shell -c ': 1<>conftest.a'
|
||||||
|
case `cat conftest.a`.$lv_cv_wrapper_shell in
|
||||||
|
a./*) break;; dnl /bin/sh is good enough
|
||||||
|
a.*) dnl bash, ksh, and zsh all understand 'command', use that
|
||||||
|
dnl to determine the absolute path of the shell
|
||||||
|
lv_cv_wrapper_shell=`$lv_cv_wrapper_shell -c \
|
||||||
|
'command -v $lv_cv_wrapper_shell'`
|
||||||
|
case $lv_cv_wrapper_shell in
|
||||||
|
/*) break;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
rm -f conftest.a
|
||||||
|
fi
|
||||||
|
])
|
||||||
|
if test "x$lv_cv_wrapper_shell" != x/bin/sh; then
|
||||||
|
lv_wrapper_shell=$lv_cv_wrapper_shell
|
||||||
|
fi
|
||||||
|
if test "x$lv_wrapper_shell" != x; then
|
||||||
|
AC_DEFINE_UNQUOTED([VIR_WRAPPER_SHELL], [$lv_wrapper_shell],
|
||||||
|
[Define to the absolute path of a shell that does not truncate on
|
||||||
|
<> redirection, if /bin/sh does not fit the bill])
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
dnl
|
dnl
|
||||||
dnl check for kernel headers required by src/bridge.c
|
dnl check for kernel headers required by src/bridge.c
|
||||||
|
@ -391,4 +391,17 @@ int qemuMonitorDeleteSnapshot(qemuMonitorPtr mon, const char *name);
|
|||||||
|
|
||||||
int qemuMonitorArbitraryCommand(qemuMonitorPtr mon, const char *cmd, char **reply);
|
int qemuMonitorArbitraryCommand(qemuMonitorPtr mon, const char *cmd, char **reply);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* When running two dd process and using <> redirection, we need a
|
||||||
|
* shell that will not truncate files. These two strings serve that
|
||||||
|
* purpose.
|
||||||
|
*/
|
||||||
|
# ifdef VIR_WRAPPER_SHELL
|
||||||
|
# define VIR_WRAPPER_SHELL_PREFIX VIR_WRAPPER_SHELL " -c '"
|
||||||
|
# define VIR_WRAPPER_SHELL_SUFFIX "'"
|
||||||
|
# else
|
||||||
|
# define VIR_WRAPPER_SHELL_PREFIX /* nothing */
|
||||||
|
# define VIR_WRAPPER_SHELL_SUFFIX /* nothing */
|
||||||
|
# endif
|
||||||
|
|
||||||
#endif /* QEMU_MONITOR_H */
|
#endif /* QEMU_MONITOR_H */
|
||||||
|
@ -1698,8 +1698,9 @@ int qemuMonitorJSONMigrateToFile(qemuMonitorPtr mon,
|
|||||||
* allow starting at an alignment of 512, but without wasting
|
* allow starting at an alignment of 512, but without wasting
|
||||||
* padding to get to the larger alignment useful for speed. Use
|
* padding to get to the larger alignment useful for speed. Use
|
||||||
* <> redirection to avoid truncating a regular file. */
|
* <> redirection to avoid truncating a regular file. */
|
||||||
if (virAsprintf(&dest, "exec:%s | { dd bs=%llu seek=%llu if=/dev/null && "
|
if (virAsprintf(&dest, "exec:" VIR_WRAPPER_SHELL_PREFIX "%s | "
|
||||||
"dd bs=%llu; } 1<>%s",
|
"{ dd bs=%llu seek=%llu if=/dev/null && "
|
||||||
|
"dd bs=%llu; } 1<>%s" VIR_WRAPPER_SHELL_SUFFIX,
|
||||||
argstr, QEMU_MONITOR_MIGRATE_TO_FILE_BS,
|
argstr, QEMU_MONITOR_MIGRATE_TO_FILE_BS,
|
||||||
offset / QEMU_MONITOR_MIGRATE_TO_FILE_BS,
|
offset / QEMU_MONITOR_MIGRATE_TO_FILE_BS,
|
||||||
QEMU_MONITOR_MIGRATE_TO_FILE_TRANSFER_SIZE,
|
QEMU_MONITOR_MIGRATE_TO_FILE_TRANSFER_SIZE,
|
||||||
|
@ -1277,8 +1277,9 @@ int qemuMonitorTextMigrateToFile(qemuMonitorPtr mon,
|
|||||||
* allow starting at an alignment of 512, but without wasting
|
* allow starting at an alignment of 512, but without wasting
|
||||||
* padding to get to the larger alignment useful for speed. Use
|
* padding to get to the larger alignment useful for speed. Use
|
||||||
* <> redirection to avoid truncating a regular file. */
|
* <> redirection to avoid truncating a regular file. */
|
||||||
if (virAsprintf(&dest, "exec:%s | { dd bs=%llu seek=%llu if=/dev/null && "
|
if (virAsprintf(&dest, "exec:" VIR_WRAPPER_SHELL_PREFIX "%s | "
|
||||||
"dd bs=%llu; } 1<>%s",
|
"{ dd bs=%llu seek=%llu if=/dev/null && "
|
||||||
|
"dd bs=%llu; } 1<>%s" VIR_WRAPPER_SHELL_SUFFIX,
|
||||||
argstr, QEMU_MONITOR_MIGRATE_TO_FILE_BS,
|
argstr, QEMU_MONITOR_MIGRATE_TO_FILE_BS,
|
||||||
offset / QEMU_MONITOR_MIGRATE_TO_FILE_BS,
|
offset / QEMU_MONITOR_MIGRATE_TO_FILE_BS,
|
||||||
QEMU_MONITOR_MIGRATE_TO_FILE_TRANSFER_SIZE,
|
QEMU_MONITOR_MIGRATE_TO_FILE_TRANSFER_SIZE,
|
||||||
|
Loading…
Reference in New Issue
Block a user