提交 28608856 编写于 作者: M Michal Privoznik

storage: Allow runtime detection of scrub

Currently, if scrub (used for wiping algorithms) is not present
at compile time, we don't support any other wiping algorithms than
zeroing, even if it was installed later. Switch to runtime detection
instead.
上级 fcdfa31f
...@@ -215,6 +215,8 @@ AC_PATH_PROG([MODPROBE], [modprobe], [], ...@@ -215,6 +215,8 @@ AC_PATH_PROG([MODPROBE], [modprobe], [],
[/sbin:/usr/sbin:/usr/local/sbin:$PATH]) [/sbin:/usr/sbin:/usr/local/sbin:$PATH])
AC_PATH_PROG([OVSVSCTL], [ovs-vsctl], [ovs-vsctl], AC_PATH_PROG([OVSVSCTL], [ovs-vsctl], [ovs-vsctl],
[/sbin:/usr/sbin:/usr/local/sbin:$PATH]) [/sbin:/usr/sbin:/usr/local/sbin:$PATH])
AC_PATH_PROG([SCRUB], [scrub], [],
[/sbin:/usr/sbin:/usr/local/sbin:$PATH])
AC_DEFINE_UNQUOTED([DNSMASQ],["$DNSMASQ"], AC_DEFINE_UNQUOTED([DNSMASQ],["$DNSMASQ"],
[Location or name of the dnsmasq program]) [Location or name of the dnsmasq program])
...@@ -237,6 +239,8 @@ if test -n "$MODPROBE"; then ...@@ -237,6 +239,8 @@ if test -n "$MODPROBE"; then
AC_DEFINE_UNQUOTED([MODPROBE],["$MODPROBE"], AC_DEFINE_UNQUOTED([MODPROBE],["$MODPROBE"],
[Location or name of the modprobe program]) [Location or name of the modprobe program])
fi fi
AC_DEFINE_UNQUOTED([SCRUB],["$SCRUB"],
[Location or name of the scrub program (for wiping algorithms)])
dnl Specific dir for HTML output ? dnl Specific dir for HTML output ?
AC_ARG_WITH([html-dir], [AC_HELP_STRING([--with-html-dir=path], AC_ARG_WITH([html-dir], [AC_HELP_STRING([--with-html-dir=path],
...@@ -2505,32 +2509,6 @@ AM_CONDITIONAL([HAVE_LIBNL], [test "$have_libnl" = "yes"]) ...@@ -2505,32 +2509,6 @@ AM_CONDITIONAL([HAVE_LIBNL], [test "$have_libnl" = "yes"])
AC_SUBST([LIBNL_CFLAGS]) AC_SUBST([LIBNL_CFLAGS])
AC_SUBST([LIBNL_LIBS]) AC_SUBST([LIBNL_LIBS])
dnl scrub program for different volume wiping algorithms
AC_ARG_WITH([scrub],
AC_HELP_STRING([--with-scrub], [enable different volume wiping algorithms
@<:@default=check@:>@]),
[with_macvtap=${withval}],
[with_scrub=check])
if test "$with_scrub" != "no"; then
AC_PATH_PROG([SCRUB], [scrub])
if test -z "$SCRUB" ; then
if test "$with_scrub" = "check"; then
with_scrub=no
else
AC_MSG_ERROR([You must install the 'scrub' binary to enable
different volume wiping algorithms])
fi
else
with_scrub=yes
fi
if test "$with_scrub" = "yes"; then
AC_DEFINE_UNQUOTED([SCRUB], ["$SCRUB"],
[Location of the scrub program])
fi
fi
# Only COPYING.LIB is under version control, yet COPYING # Only COPYING.LIB is under version control, yet COPYING
# is included as part of the distribution tarball. # is included as part of the distribution tarball.
# Copy one to the other, but only if this is a srcdir-build. # Copy one to the other, but only if this is a srcdir-build.
......
...@@ -513,6 +513,9 @@ BuildRequires: nfs-utils ...@@ -513,6 +513,9 @@ BuildRequires: nfs-utils
# Fedora build root suckage # Fedora build root suckage
BuildRequires: gawk BuildRequires: gawk
# For storage wiping with different algorithms
BuildRequires: scrub
%description %description
Libvirt is a C toolkit to interact with the virtualization capabilities Libvirt is a C toolkit to interact with the virtualization capabilities
of recent versions of Linux (and other OSes). The main package includes of recent versions of Linux (and other OSes). The main package includes
......
...@@ -1918,7 +1918,6 @@ storageVolumeWipeInternal(virStorageVolDefPtr def, ...@@ -1918,7 +1918,6 @@ storageVolumeWipeInternal(virStorageVolDefPtr def,
if (algorithm != VIR_STORAGE_VOL_WIPE_ALG_ZERO) { if (algorithm != VIR_STORAGE_VOL_WIPE_ALG_ZERO) {
const char *alg_char ATTRIBUTE_UNUSED = NULL; const char *alg_char ATTRIBUTE_UNUSED = NULL;
switch (algorithm) { switch (algorithm) {
#ifdef SCRUB
case VIR_STORAGE_VOL_WIPE_ALG_NNSA: case VIR_STORAGE_VOL_WIPE_ALG_NNSA:
alg_char = "nnsa"; alg_char = "nnsa";
break; break;
...@@ -1943,13 +1942,11 @@ storageVolumeWipeInternal(virStorageVolDefPtr def, ...@@ -1943,13 +1942,11 @@ storageVolumeWipeInternal(virStorageVolDefPtr def,
case VIR_STORAGE_VOL_WIPE_ALG_RANDOM: case VIR_STORAGE_VOL_WIPE_ALG_RANDOM:
alg_char = "random"; alg_char = "random";
break; break;
#endif
default: default:
virStorageReportError(VIR_ERR_INVALID_ARG, virStorageReportError(VIR_ERR_INVALID_ARG,
_("unsupported algorithm %d"), _("unsupported algorithm %d"),
algorithm); algorithm);
} }
#ifdef SCRUB
cmd = virCommandNew(SCRUB); cmd = virCommandNew(SCRUB);
virCommandAddArgList(cmd, "-f", "-p", alg_char, virCommandAddArgList(cmd, "-f", "-p", alg_char,
def->target.path, NULL); def->target.path, NULL);
...@@ -1958,7 +1955,6 @@ storageVolumeWipeInternal(virStorageVolDefPtr def, ...@@ -1958,7 +1955,6 @@ storageVolumeWipeInternal(virStorageVolDefPtr def,
goto out; goto out;
ret = 0; ret = 0;
#endif
goto out; goto out;
} else { } else {
if (S_ISREG(st.st_mode) && st.st_blocks < (st.st_size / DEV_BSIZE)) { if (S_ISREG(st.st_mode) && st.st_blocks < (st.st_size / DEV_BSIZE)) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册