[PATCH libnbd] python: Add AIO buffer is_zero method.
by Richard W.M. Jones
Fast testing whether the AIO buffer (or regions within it) contain all
zeroes, which allows Python code to quickly do sparsification when
copying.
This includes the iszero.h header from nbdkit which is distributed
under a compatible license.
---
common/include/Makefile.am | 5 +--
common/include/iszero.h | 63 +++++++++++++++++++++++++++++++++++++
generator/generator | 17 ++++++++--
python/Makefile.am | 3 +-
python/handle.c | 47 +++++++++++++++++++++++++++
python/t/580-aio-is-zero.py | 53 +++++++++++++++++++++++++++++++
6 files changed, 183 insertions(+), 5 deletions(-)
diff --git a/common/include/Makefile.am b/common/include/Makefile.am
index 89cc61e..79f0351 100644
--- a/common/include/Makefile.am
+++ b/common/include/Makefile.am
@@ -1,5 +1,5 @@
# nbd client library in userspace
-# Copyright (C) 2013-2019 Red Hat Inc.
+# Copyright (C) 2013-2020 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
@@ -18,4 +18,5 @@
include $(top_srcdir)/subdir-rules.mk
EXTRA_DIST = \
- byte-swapping.h
+ byte-swapping.h \
+ iszero.h
diff --git a/common/include/iszero.h b/common/include/iszero.h
new file mode 100644
index 0000000..7fdbb52
--- /dev/null
+++ b/common/include/iszero.h
@@ -0,0 +1,63 @@
+/* nbdkit
+ * Copyright (C) 2018 Red Hat Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * * Neither the name of Red Hat nor the names of its contributors may be
+ * used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef NBDKIT_ISZERO_H
+#define NBDKIT_ISZERO_H
+
+#include <string.h>
+#include <stdbool.h>
+
+/* Return true iff the buffer is all zero bytes.
+ *
+ * The clever approach here was suggested by Eric Blake. See:
+ * https://www.redhat.com/archives/libguestfs/2017-April/msg00171.html
+ * https://rusty.ozlabs.org/?p=560
+ *
+ * See also:
+ * https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69908
+ */
+static inline bool __attribute__((__nonnull__ (1)))
+is_zero (const char *buffer, size_t size)
+{
+ size_t i;
+ const size_t limit = size < 16 ? size : 16;
+
+ for (i = 0; i < limit; ++i)
+ if (buffer[i])
+ return false;
+ if (size != limit)
+ return ! memcmp (buffer, buffer + 16, size - 16);
+
+ return true;
+}
+
+#endif /* NBDKIT_ISZERO_H */
diff --git a/generator/generator b/generator/generator
index 31fe9dd..20fd872 100755
--- a/generator/generator
+++ b/generator/generator
@@ -5014,7 +5014,8 @@ raise_exception ()
"alloc_aio_buffer";
"aio_buffer_from_bytearray";
"aio_buffer_to_bytearray";
- "aio_buffer_size" ] @ List.map fst handle_calls);
+ "aio_buffer_size";
+ "aio_buffer_is_zero" ] @ List.map fst handle_calls);
pr "\n";
pr "#endif /* LIBNBD_METHODS_H */\n"
@@ -5044,7 +5045,8 @@ let generate_python_libnbdmod_c () =
"alloc_aio_buffer";
"aio_buffer_from_bytearray";
"aio_buffer_to_bytearray";
- "aio_buffer_size" ] @ List.map fst handle_calls);
+ "aio_buffer_size";
+ "aio_buffer_is_zero" ] @ List.map fst handle_calls);
pr " { NULL, NULL, 0, NULL }\n";
pr "};\n";
pr "\n";
@@ -5667,6 +5669,17 @@ class Buffer (object):
'''return the size of an AIO buffer'''
return libnbdmod.aio_buffer_size (self._o)
+ def is_zero (self, offset=0, size=-1):
+ '''
+ Returns true if and only if the buffer contains zero bytes.
+ Note that a freshly allocated buffer is uninitialized, not zero.
+
+ By default this tests the whole buffer, but you can restrict
+ the test to a sub-range of the buffer using the optional
+ offset and size parameters.
+ '''
+ return libnbdmod.aio_buffer_is_zero (self._o, offset, size)
+
class NBD (object):
'''NBD handle'''
diff --git a/python/Makefile.am b/python/Makefile.am
index 48aabea..c621eb7 100644
--- a/python/Makefile.am
+++ b/python/Makefile.am
@@ -50,7 +50,8 @@ libnbdmod_la_SOURCES = \
utils.c
libnbdmod_la_CPPFLAGS = \
$(PYTHON_CFLAGS) \
- -I$(top_srcdir)/include
+ -I$(top_srcdir)/include \
+ -I$(top_srcdir)/common/include
libnbdmod_la_CFLAGS = \
$(WARNINGS_CFLAGS)
libnbdmod_la_LIBADD = \
diff --git a/python/handle.c b/python/handle.c
index ef81ab8..da0c417 100644
--- a/python/handle.c
+++ b/python/handle.c
@@ -35,6 +35,8 @@
#include <libnbd.h>
+#include "iszero.h"
+
#include "methods.h"
static inline PyObject *
@@ -213,3 +215,48 @@ nbd_internal_py_aio_buffer_size (PyObject *self, PyObject *args)
return PyLong_FromSsize_t (buf->len);
}
+
+PyObject *
+nbd_internal_py_aio_buffer_is_zero (PyObject *self, PyObject *args)
+{
+ PyObject *obj;
+ struct py_aio_buffer *buf;
+ Py_ssize_t offset, size;
+
+ if (!PyArg_ParseTuple (args,
+ (char *) "Onn:nbd_internal_py_aio_buffer_size",
+ &obj, &offset, &size))
+ return NULL;
+
+ if (size == 0)
+ Py_RETURN_TRUE;
+
+ buf = nbd_internal_py_get_aio_buffer (obj);
+ if (buf == NULL)
+ return NULL;
+
+ /* Check the bounds of the offset. */
+ if (offset < 0 || offset > buf->len) {
+ PyErr_SetString (PyExc_IndexError, "offset out of range");
+ return NULL;
+ }
+
+ /* Compute or check the length. */
+ if (size == -1)
+ size = buf->len - offset;
+ else if (size < 0) {
+ PyErr_SetString (PyExc_IndexError,
+ "size cannot be negative, "
+ "except -1 to mean to the end of the buffer");
+ return NULL;
+ }
+ else if ((size_t) offset + size > buf->len) {
+ PyErr_SetString (PyExc_IndexError, "size out of range");
+ return NULL;
+ }
+
+ if (is_zero (buf->data + offset, size))
+ Py_RETURN_TRUE;
+ else
+ Py_RETURN_FALSE;
+}
diff --git a/python/t/580-aio-is-zero.py b/python/t/580-aio-is-zero.py
new file mode 100644
index 0000000..5bda9ff
--- /dev/null
+++ b/python/t/580-aio-is-zero.py
@@ -0,0 +1,53 @@
+# libnbd Python bindings
+# Copyright (C) 2010-2020 Red Hat Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+# This tests the nbd.Buffer is_zero method. We can do this entirely
+# without using the NBD protocol.
+
+import os
+import nbd
+
+# Simplest case: A Buffer initialized with zeros should be zero.
+ba = bytearray (2**20)
+buf = nbd.Buffer.from_bytearray (ba)
+assert buf.is_zero ()
+
+# The above buffer is 2**20 (= 1MB), slices of it should also be zero.
+for i in range (0, 7):
+ assert buf.is_zero (i * 2**17, 2**17)
+
+# A Buffer initialized with non-zeroes should not be zero.
+ba = bytearray (b'\xff') * 2**20
+buf = nbd.Buffer.from_bytearray (ba)
+assert not buf.is_zero ()
+
+# Slices should not be zero.
+for i in range (0, 15):
+ assert not buf.is_zero (i * 2**16, 2**16)
+
+# Buffer with a block of non-zeroes and block of zeroes.
+ba = bytearray (b'\xff') * 2**20 + bytearray (2**20)
+buf = nbd.Buffer.from_bytearray (ba)
+assert not buf.is_zero ()
+assert not buf.is_zero (0, 2**20)
+assert buf.is_zero (2**20)
+assert not buf.is_zero (2**19)
+assert buf.is_zero (2**20, 2**19)
+assert not buf.is_zero (2**20-1, 1)
+assert buf.is_zero (2**20, 1)
+assert not buf.is_zero (0, 1)
+assert buf.is_zero (2**21-1, 1)
--
2.24.1
4 years, 10 months
[PATCH v2] mlcustomize: Trim whitespaces from commands read from file (RHBZ#1351000)
by Martin Kletzander
The first split does not care about the whole string, it is just trying to get
the command name in front, so triml is just right.
Signed-off-by: Martin Kletzander <mkletzan(a)redhat.com>
---
mlcustomize/customize_cmdline.ml | 1 +
1 file changed, 1 insertion(+)
diff --git a/mlcustomize/customize_cmdline.ml b/mlcustomize/customize_cmdline.ml
index c062379879e2..abd21a4cbca5 100644
--- a/mlcustomize/customize_cmdline.ml
+++ b/mlcustomize/customize_cmdline.ml
@@ -481,6 +481,7 @@ let rec argspec () =
] in
let lines = read_whole_file filename in
let lines = String.lines_split lines in
+ let lines = List.map String.triml lines in
let lines = List.filter (
fun line ->
String.length line > 0 && line.[0] <> '#'
--
2.25.0
4 years, 10 months
[common PATCH] Trim whitespaces from commands read from file
by Martin Kletzander
Signed-off-by: Martin Kletzander <mkletzan(a)redhat.com>
---
mlcustomize/customize_cmdline.ml | 1 +
1 file changed, 1 insertion(+)
diff --git a/mlcustomize/customize_cmdline.ml b/mlcustomize/customize_cmdline.ml
index c062379879e2..67e85af2ad93 100644
--- a/mlcustomize/customize_cmdline.ml
+++ b/mlcustomize/customize_cmdline.ml
@@ -481,6 +481,7 @@ let rec argspec () =
] in
let lines = read_whole_file filename in
let lines = String.lines_split lines in
+ let lines = List.map String.trim lines in
let lines = List.filter (
fun line ->
String.length line > 0 && line.[0] <> '#'
--
2.25.0
4 years, 10 months
[PATCH v2 1/2] mltools, options: support --allow-discards when decrypting LUKS devices
by Jan Synacek
---
mltools/tools_utils-c.c | 8 ++++----
mltools/tools_utils.ml | 6 +++---
mltools/tools_utils.mli | 8 ++++++--
options/decrypt.c | 5 +++--
options/inspect.c | 2 +-
options/options.h | 2 +-
6 files changed, 18 insertions(+), 13 deletions(-)
diff --git a/mltools/tools_utils-c.c b/mltools/tools_utils-c.c
index 6c43b8d..1dcebc4 100644
--- a/mltools/tools_utils-c.c
+++ b/mltools/tools_utils-c.c
@@ -36,7 +36,7 @@
#include "options.h"
-extern value guestfs_int_mllib_inspect_decrypt (value gv, value gpv, value keysv);
+extern value guestfs_int_mllib_inspect_decrypt (value gv, value gpv, value keysv, value allowdiscards);
extern value guestfs_int_mllib_set_echo_keys (value unitv);
extern value guestfs_int_mllib_set_keys_from_stdin (value unitv);
extern value guestfs_int_mllib_rfc3339_date_time_string (value unitv);
@@ -46,9 +46,9 @@ int echo_keys = 0;
int keys_from_stdin = 0;
value
-guestfs_int_mllib_inspect_decrypt (value gv, value gpv, value keysv)
+guestfs_int_mllib_inspect_decrypt (value gv, value gpv, value keysv, value allowdiscards)
{
- CAMLparam3 (gv, gpv, keysv);
+ CAMLparam4 (gv, gpv, keysv, allowdiscards);
CAMLlocal2 (elemv, v);
guestfs_h *g = (guestfs_h *) (intptr_t) Int64_val (gpv);
struct key_store *ks = NULL;
@@ -86,7 +86,7 @@ guestfs_int_mllib_inspect_decrypt (value gv, value gpv, value keysv)
keysv = Field (keysv, 1);
}
- inspect_do_decrypt (g, ks);
+ inspect_do_decrypt (g, ks, Int_val (allowdiscards));
CAMLreturn (Val_unit);
}
diff --git a/mltools/tools_utils.ml b/mltools/tools_utils.ml
index 1271802..cb94125 100644
--- a/mltools/tools_utils.ml
+++ b/mltools/tools_utils.ml
@@ -29,7 +29,7 @@ and key_store_key =
| KeyString of string
| KeyFileName of string
-external c_inspect_decrypt : Guestfs.t -> int64 -> (string * key_store_key) list -> unit = "guestfs_int_mllib_inspect_decrypt"
+external c_inspect_decrypt : Guestfs.t -> int64 -> (string * key_store_key) list -> bool -> unit = "guestfs_int_mllib_inspect_decrypt"
external c_set_echo_keys : unit -> unit = "guestfs_int_mllib_set_echo_keys" "noalloc"
external c_set_keys_from_stdin : unit -> unit = "guestfs_int_mllib_set_keys_from_stdin" "noalloc"
external c_rfc3339_date_time_string : unit -> string = "guestfs_int_mllib_rfc3339_date_time_string"
@@ -650,7 +650,7 @@ let is_btrfs_subvolume g fs =
if g#last_errno () = Guestfs.Errno.errno_EINVAL then false
else raise exn
-let inspect_decrypt g ks =
+let inspect_decrypt g ?(allow_discards = false) ks =
(* Turn the keys in the key_store into a simpler struct, so it is possible
* to read it using the C API.
*)
@@ -664,7 +664,7 @@ let inspect_decrypt g ks =
* function.
*)
c_inspect_decrypt g#ocaml_handle (Guestfs.c_pointer g#ocaml_handle)
- keys_as_list
+ keys_as_list allow_discards
let with_timeout op timeout ?(sleep = 2) fn =
let start_t = Unix.gettimeofday () in
diff --git a/mltools/tools_utils.mli b/mltools/tools_utils.mli
index ab70f58..ac11a58 100644
--- a/mltools/tools_utils.mli
+++ b/mltools/tools_utils.mli
@@ -194,10 +194,14 @@ val inspect_mount_root_ro : Guestfs.guestfs -> string -> unit
val is_btrfs_subvolume : Guestfs.guestfs -> string -> bool
(** Checks if a filesystem is a btrfs subvolume. *)
-val inspect_decrypt : Guestfs.guestfs -> key_store -> unit
+val inspect_decrypt : Guestfs.guestfs -> ?allow_discards:bool -> key_store -> unit
(** Simple implementation of decryption: look for any [crypto_LUKS]
partitions and decrypt them, then rescan for VGs. This only works
- for Fedora whole-disk encryption. *)
+ for Fedora whole-disk encryption.
+
+ If [?allow_discards] is set, the underlying [crypto_LUKS] partitions
+ will be decrypted with the discard operation allowed, which allows
+ the partitions to be trimmed (and sparsified). Default is [false]. *)
val with_timeout : string -> int -> ?sleep:int -> (unit -> 'a option) -> 'a
(** [with_timeout op timeout ?sleep fn] implements a timeout loop.
diff --git a/options/decrypt.c b/options/decrypt.c
index 683cf5e..7e24254 100644
--- a/options/decrypt.c
+++ b/options/decrypt.c
@@ -71,7 +71,7 @@ make_mapname (const char *device, char *mapname, size_t len)
* encryption schemes.
*/
void
-inspect_do_decrypt (guestfs_h *g, struct key_store *ks)
+inspect_do_decrypt (guestfs_h *g, struct key_store *ks, bool allowdiscards)
{
CLEANUP_FREE_STRING_LIST char **partitions = guestfs_list_partitions (g);
if (partitions == NULL)
@@ -101,7 +101,8 @@ inspect_do_decrypt (guestfs_h *g, struct key_store *ks)
* is set? This might break 'mount_ro'.
*/
guestfs_push_error_handler (g, NULL, NULL);
- r = guestfs_luks_open (g, partitions[i], keys[j], mapname);
+ r = guestfs_luks_open_opts (g, partitions[i], keys[j], mapname,
+ GUESTFS_LUKS_OPEN_OPTS_ALLOWDISCARDS, allowdiscards, -1);
guestfs_pop_error_handler (g);
if (r == 0)
goto opened;
diff --git a/options/inspect.c b/options/inspect.c
index 3de6d70..be69419 100644
--- a/options/inspect.c
+++ b/options/inspect.c
@@ -70,7 +70,7 @@ inspect_mount_handle (guestfs_h *g, struct key_store *ks)
if (live)
error (EXIT_FAILURE, 0, _("don���t use --live and -i options together"));
- inspect_do_decrypt (g, ks);
+ inspect_do_decrypt (g, ks, false);
char **roots = guestfs_inspect_os (g);
if (roots == NULL)
diff --git a/options/options.h b/options/options.h
index 9b78302..2467804 100644
--- a/options/options.h
+++ b/options/options.h
@@ -137,7 +137,7 @@ struct key_store {
extern void parse_config (void);
/* in decrypt.c */
-extern void inspect_do_decrypt (guestfs_h *g, struct key_store *ks);
+extern void inspect_do_decrypt (guestfs_h *g, struct key_store *ks, bool allowdiscards);
/* in domain.c */
extern int add_libvirt_drives (guestfs_h *g, const char *guest);
--
2.24.1
4 years, 10 months
[PATCH 0/3] Fixing out-of-tree builds
by Tomáš Golembiovský
Building virt-v2v out-of-tree does not work and requires several small fixes
here and there.
Tomáš Golembiovský (3):
build: perform gnulib check from source directory
build: run ocaml-link.sh from build directory
docs: don't perform lookup on absolute paths
cfg.mk | 1 +
podwrapper.pl.in | 2 ++
v2v/Makefile.am | 16 ++++++++--------
3 files changed, 11 insertions(+), 8 deletions(-)
--
2.25.0
4 years, 11 months
[PATCH libnbd] PROPOSAL Add nbdcp (NBD copying) tool.
by Richard W.M. Jones
This is a proposal for an NBD to/from file copying tool (not actually
written). Obviously this would duplicate functionality which is
already available in qemu-img convert.
The reasons for writing this tool would be:
- to produce a tool which is very focused on the specific needs of
virt-v2v and similar migration scenarios
- to have a small tool with minimal dependencies
- fix some of the obvious problems with qemu-img convert like how it
handles devices which are already zeroed, and preallocation
- enable optimizations which make sense for NBD but which might not
be applicable to qemu (eg. multi-conn, freely writing out of order
from multiple threads).
Alternative is of course to not write a new tool and instead try to
fix all this stuff in qemu-img itself.
Anyway let me know your thoughts.
Rich.
nbdcp(1) LIBNBD nbdcp(1)
NAME
nbdcp - copy between NBD servers and local files
SYNOPSIS
nbdcp [-a|--target-allocation allocated|sparse]
[-m|--multi-conn <n>] [-M|--multi-conn-target <n>]
[-p|--progress-bar] [-S|--sparse-detect <n>]
[-T|--threads <n>] [-z|--target-is-zero]
'nbd://...'|DISK.IMG 'nbd://...'|DISK.IMG
DESCRIPTION
nbdcp is a utility that can copy quickly between NBD servers and local
raw format files (or block devices). It can copy:
from NBD server to file (or block device)
For example, this command copies from the NBD server listening on
port 10809 on "example.com" to a local file called disk.img:
nbdcp nbd://example.com disk.img
from file (or block device) to NBD server
For example, this command copies from a local block device /dev/sda
to the NBD server listening on Unix domain socket /tmp/socket:
nbdcp /dev/sda 'nbd+unix:///?socket=/tmp/socket'
from NBD server to NBD server
For example this copies between two different exports on the same
NBD server:
nbdcp nbd://example.com/export1 nbd://example.com/export2
This program cannot: copy from file to file (use cp(1) or dd(1)), copy
to or from formats other than raw (use qemu-img(1) convert), or access
servers other than NBD servers (also use qemu-img(1)).
NBD servers are specified by their URI, following the NBD URI standard
at https://github.com/NetworkBlockDevice/nbd/blob/master/doc/uri.md
Controlling sparseness or preallocation in the target
The options -a (--target-allocation), -S (--sparse-detect) and -z
(--target-is-zero) together control sparseness in the target file.
By default nbdcp tries to both preserve sparseness from the source and
will detect runs of allocated zeroes and turn them into sparseness. To
turn off detection of sparseness use "-S 0".
The -z option should be used if and only if you know that the target
block device is zeroed already. This allows an important optimization
where nbdcp can skip zeroing or trimming parts of the disk that are
already zero.
The -a option is used to control the desired final preallocation state
of the target. The default is "-a sparse" which makes the target as
sparse as possible. "-a allocated" makes the target fully allocated.
OPTIONS
--help
Display brief command line help and exit.
-a allocated
--target-allocation=allocated
Make the target fully allocated.
-a sparse
--target-allocation=sparse
Make the target as sparse as possible. This is the default. See
also "Controlling sparseness or preallocation in the target".
-m N
--multi-conn=N
Enable NBD multi-conn with up to "N" connections. Only some NBD
servers support this but it can greatly improve performance.
The default is to enable multi-conn if we detect that the server
supports it, with up to 4 connections.
-M N
--multi-conn-target=N
If you are copying between NBD servers, use -m to control the
multi-conn setting for the source server, and this option (-M) to
control the multi-conn setting for the target server.
-p
--progress-bar
Display a progress bar during copying.
-p machine:FD
--progress-bar=machine:FD
Write a machine-readable progress bar to file descriptor "FD".
This progress bar prints lines with the format "COPIED/TOTAL"
(where "COPIED" and "TOTAL" are 64 bit unsigned integers).
-S 0
--sparse-detect=0
Turn off sparseness detection.
-S N
--sparse-detect=N
Detect runs of zero bytes of at least size "N" bytes and turn them
into sparse blocks on the target (if "-a sparse" is used). This is
the default, with a 512 byte block size.
-T N
--threads N
Use at most "N" threads when copying. Usually more threads leads
to better performance, up to the limit of the number of cores on
your machine and the parallelism of the underlying disk or network.
The default is to use the number of online processors.
-z
--target-is-zero
Declare that the target block device contains only zero bytes (or
sparseness that reads back as zeroes). You must only use this
option if you are sure that this is true, since it means that nbdcp
will enable an optimization where it skips zeroing parts of the
disk that are zero on the source.
-V
--version
Display the package name and version and exit.
SEE ALSO
qemu-img(1), libnbd(3), nbdsh(1).
AUTHORS
Richard W.M. Jones
COPYRIGHT
Copyright (C) 2020 Red Hat Inc.
LICENSE
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This library is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
libnbd-1.3.1 2020-01-22 nbdcp(1)
4 years, 11 months
[v2v PATCH 0/3] Use libosinfo for query device drivers
by Pino Toscano
This patch series integrates libosinfo in virt-v2v to get the list of
files for Windows from libosinfo, if possible. The actual data is still
from virtio-win, just unpacked.
Pino Toscano (3):
build: require libosinfo
v2v: add a minimal libosinfo interface
v2v: try to get windows driver files from libosinfo
m4/guestfs-v2v.m4 | 3 +
v2v/Makefile.am | 9 +-
v2v/libosinfo-c.c | 221 ++++++++++++++++++++++++++++++++++++++++
v2v/libosinfo.ml | 52 ++++++++++
v2v/libosinfo.mli | 47 +++++++++
v2v/libosinfo_utils.ml | 34 +++++++
v2v/libosinfo_utils.mli | 26 +++++
v2v/windows_virtio.ml | 63 +++++++++++-
8 files changed, 450 insertions(+), 5 deletions(-)
create mode 100644 v2v/libosinfo-c.c
create mode 100644 v2v/libosinfo.ml
create mode 100644 v2v/libosinfo.mli
create mode 100644 v2v/libosinfo_utils.ml
create mode 100644 v2v/libosinfo_utils.mli
--
2.24.1
4 years, 11 months
[PATCH 0/1] WIP: Support LUKS-encrypted partitions
by Jan Synacek
The following patch attempts to implement sparsification of
LUKS-encrypted partitions. It uses lsblk to pair the underlying LUKS
block device with its mapped name. Also, --allow-discards was added
by default to luks_open().
There are several potential issues that I can think of:
1) If and entire device is encrypted (not just one of more partitions),
the lsblk trick might not work.
2) The --allow-discards is needed to be able to run fstrim on a
decrypted partition. I *think* that it's safe to be added
unconditionally, but I'm not sure. It might be better to just add
another luks_open() variant that uses the option.
3) As it is right now, lsblk is called for every crypto_LUKS device to
see if a corresponding mapping had been created. I *think* it's good
enough, but keeping a list of (blkdev, mapname) in the daemon memory
and adding an API call to retrieve it might be better.
Comments and pointers on how to proceed further are appreciated.
Jan Synacek (1):
WIP: sparsify: Support LUKS-encrypted partitions
daemon/listfs.ml | 18 +++++++++++++++---
daemon/luks.c | 1 +
2 files changed, 16 insertions(+), 3 deletions(-)
--
2.24.1
4 years, 11 months
[PATCH] nbdkit: fix condition in probe_filter
by Tomáš Golembiovský
The tests assume probe_filter returns true if the filter is available
(and not the other way around).
Signed-off-by: Tomáš Golembiovský <tgolembi(a)redhat.com>
---
v2v/nbdkit.ml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/v2v/nbdkit.ml b/v2v/nbdkit.ml
index 77d2a506..00122bec 100644
--- a/v2v/nbdkit.ml
+++ b/v2v/nbdkit.ml
@@ -142,7 +142,7 @@ let common_create ?bandwidth plugin_name plugin_args plugin_env =
let cmd =
sprintf "%s nbdkit --dump-plugin --filter=%s null >/dev/null"
env_as_string filter_name in
- Sys.command cmd <> 0
+ Sys.command cmd == 0
in
(* Adding the readahead filter is always a win for our access
--
2.24.1
4 years, 11 months