[PATCH v2] copy-out: new optional arguments
by Pino Toscano
Add new optional argument to copy-out: 'numericowner', 'excludes',
'xattrs', 'selinux', and 'acls'. Pass them straight to tar-out, so
it is possible to tweak how the files are extracted from the guest,
and locally saved.
---
generator/actions.ml | 37 +++++++++++++++++++++++++++++++++++--
gobject/Makefile.inc | 2 ++
lib/copy-in-out.c | 29 ++++++++++++++++++++++++++---
3 files changed, 63 insertions(+), 5 deletions(-)
diff --git a/generator/actions.ml b/generator/actions.ml
index 990eacb..9015a1a 100644
--- a/generator/actions.ml
+++ b/generator/actions.ml
@@ -3437,8 +3437,9 @@ Wildcards cannot be used." };
{ defaults with
name = "copy_out"; added = (1, 29, 24);
- style = RErr, [Pathname "remotepath"; String "localdir"], [];
+ style = RErr, [Pathname "remotepath"; String "localdir"], [OBool "numericowner"; OStringList "excludes"; OBool "xattrs"; OBool "selinux"; OBool "acls"];
visibility = VPublicNoFish;
+ once_had_no_optargs = true;
shortdesc = "copy remote files or directories out of an image";
longdesc = "\
C<guestfs_copy_out> copies remote files or directories recursively
@@ -3449,7 +3450,39 @@ To download to the current directory, use C<.> as in:
C<guestfs_copy_out> /home .
-Wildcards cannot be used." };
+Wildcards cannot be used.
+
+The other optional arguments are:
+
+=over 4
+
+=item C<numericowner>
+
+If set to true, the destination file will contain UID/GID numbers
+matching these in the sources, instead of using user/group names.
+Note this applies only if C<remotepath> is a directory.
+
+=item C<excludes>
+
+A list of wildcards. Files are excluded if they match any of the
+wildcards. Note they are used only if C<remotepath> is a directory.
+
+=item C<xattrs>
+
+If set to true, extended attributes are restored.
+Note this applies only if C<remotepath> is a directory.
+
+=item C<selinux>
+
+If set to true, SELinux contexts are restored.
+Note this applies only if C<remotepath> is a directory.
+
+=item C<acls>
+
+If set to true, POSIX ACLs are restored.
+Note this applies only if C<remotepath> is a directory.
+
+=back" };
{ defaults with
name = "set_identifier"; added = (1, 31, 14);
diff --git a/gobject/Makefile.inc b/gobject/Makefile.inc
index 55a137e..76482f7 100644
--- a/gobject/Makefile.inc
+++ b/gobject/Makefile.inc
@@ -67,6 +67,7 @@ guestfs_gobject_headers= \
include/guestfs-gobject/optargs-copy_device_to_file.h \
include/guestfs-gobject/optargs-copy_file_to_device.h \
include/guestfs-gobject/optargs-copy_file_to_file.h \
+ include/guestfs-gobject/optargs-copy_out.h \
include/guestfs-gobject/optargs-cpio_out.h \
include/guestfs-gobject/optargs-disk_create.h \
include/guestfs-gobject/optargs-download_blocks.h \
@@ -158,6 +159,7 @@ guestfs_gobject_sources= \
src/optargs-copy_device_to_file.c \
src/optargs-copy_file_to_device.c \
src/optargs-copy_file_to_file.c \
+ src/optargs-copy_out.c \
src/optargs-cpio_out.c \
src/optargs-disk_create.c \
src/optargs-download_blocks.c \
diff --git a/lib/copy-in-out.c b/lib/copy-in-out.c
index a4e39f8..cf2a9d6 100644
--- a/lib/copy-in-out.c
+++ b/lib/copy-in-out.c
@@ -131,8 +131,9 @@ child_setup (guestfs_h *g, void *data)
}
int
-guestfs_impl_copy_out (guestfs_h *g,
- const char *remotepath, const char *localdir)
+guestfs_impl_copy_out_opts (guestfs_h *g,
+ const char *remotepath, const char *localdir,
+ const struct guestfs_copy_out_opts_argv *optargs)
{
struct stat statbuf;
int r;
@@ -170,6 +171,7 @@ guestfs_impl_copy_out (guestfs_h *g,
struct copy_out_child_data data;
char fdbuf[64];
int fd;
+ struct guestfs_tar_out_opts_argv tar_optargs = { .bitmask = 0 };
r = guestfs_is_dir (g, remotepath);
if (r == -1)
@@ -210,7 +212,28 @@ guestfs_impl_copy_out (guestfs_h *g,
snprintf (fdbuf, sizeof fdbuf, "/dev/fd/%d", fd);
- r = guestfs_tar_out (g, remotepath, fdbuf);
+ if (optargs->bitmask & GUESTFS_COPY_OUT_OPTS_NUMERICOWNER_BITMASK) {
+ tar_optargs.numericowner = optargs->numericowner;
+ tar_optargs.bitmask |= GUESTFS_TAR_OUT_OPTS_NUMERICOWNER_BITMASK;
+ }
+ if (optargs->bitmask & GUESTFS_COPY_OUT_OPTS_EXCLUDES_BITMASK) {
+ tar_optargs.excludes = optargs->excludes;
+ tar_optargs.bitmask |= GUESTFS_TAR_OUT_OPTS_EXCLUDES_BITMASK;
+ }
+ if (optargs->bitmask & GUESTFS_COPY_OUT_OPTS_XATTRS_BITMASK) {
+ tar_optargs.xattrs = optargs->xattrs;
+ tar_optargs.bitmask |= GUESTFS_TAR_OUT_OPTS_XATTRS_BITMASK;
+ }
+ if (optargs->bitmask & GUESTFS_COPY_OUT_OPTS_SELINUX_BITMASK) {
+ tar_optargs.selinux = optargs->selinux;
+ tar_optargs.bitmask |= GUESTFS_TAR_OUT_OPTS_SELINUX_BITMASK;
+ }
+ if (optargs->bitmask & GUESTFS_COPY_OUT_OPTS_ACLS_BITMASK) {
+ tar_optargs.acls = optargs->acls;
+ tar_optargs.bitmask |= GUESTFS_TAR_OUT_OPTS_ACLS_BITMASK;
+ }
+
+ r = guestfs_tar_out_opts_argv (g, remotepath, fdbuf, &tar_optargs);
if (close (fd) == -1) {
perrorf (g, "close (tar-output subprocess)");
--
2.9.3
7 years, 10 months
[PATCH 00/10] dib/API: improvements and fixes
by Pino Toscano
Hi,
this patch series does changes mostly in virt-dib, few bug fixes and
a couple of new features (mostly implemented upstream already).
In addition, one new API is added, and a new optional argument for an
existing API is added (the latter is not needed, but could be useful
anyway).
Thanks,
Pino Toscano (10):
dib: fix listing envvars in fake-sudo
dib: source dib "die" script in some phases
dib: change hooks path when running extra-data.d scripts
dib: re-read list of scripts when running in-chroot hooks
dib: cleanup logs at end of build
copy-out: new 'excludes' optional argument
dib: add appliance check hook in Output_format
daemon: move make_exclude_from_file as common helper
New API: mksquashfs
dib: add squashfs output format
appliance/packagelist.in | 2 +
daemon/Makefile.am | 1 +
daemon/daemon.h | 2 +
daemon/guestfsd.c | 62 +++++++++++++++++
daemon/squashfs.c | 150 ++++++++++++++++++++++++++++++++++++++++++
daemon/tar.c | 58 +---------------
dib/Makefile.am | 1 +
dib/dib.ml | 49 +++++++++++---
dib/elements.ml | 15 +++++
dib/output_format.ml | 15 +++++
dib/output_format.mli | 9 +++
dib/output_format_squashfs.ml | 39 +++++++++++
dib/utils.ml | 1 +
dib/virt-dib.pod | 6 ++
generator/actions.ml | 42 +++++++++++-
gobject/Makefile.inc | 4 ++
lib/MAX_PROC_NR | 2 +-
lib/copy-in-out.c | 13 +++-
18 files changed, 398 insertions(+), 73 deletions(-)
create mode 100644 daemon/squashfs.c
create mode 100644 dib/output_format_squashfs.ml
--
2.9.3
7 years, 10 months
[PATCH 0/2] hivex: handle corrupted hives better
by Dawid Zamirski
Hello,
The following patches address issues when dealing with hives that have
corrupted data in them but are otherwise readable/writable. Those were
found on some rather rare Windows installations that seem to work fine
but current hivex fails to even open.
Those patches change hivex to simply log and ignore such "corrupted"
regions instead of aborting because the caller might be looking at keys
that are perfectly readable/writable (e.g. to identify Windows version
from HKLM/Software/Microsoft/Windows NT/CurrentVersion) and other
"corrupted" and irrelevant keys might prevent one from doing so.
Regards,
Dawid
Dawid Zamirski (2):
lib: change how hbin sections are read.
lib: allow to walk registry with corrupted blocks
lib/handle.c | 52 +++++++++++++++++++++++++++++++++++++++++++---------
lib/node.c | 11 +++++------
2 files changed, 48 insertions(+), 15 deletions(-)
--
2.9.3
7 years, 10 months
[PATCH 1/2] GCC 7: Add __attribute__((noreturn)) to some usage functions which call exit.
by Richard W.M. Jones
This happens with GCC 7.0.1. The errors were all of the form:
qemu-speed-test.c: In function 'main':
qemu-speed-test.c:153:7: error: this statement may fall through [-Werror=implicit-fallthrough=]
usage (EXIT_SUCCESS);
^~~~~~~~~~~~~~~~~~~~
qemu-speed-test.c:155:5: note: here
default:
^~~~~~~
---
builder/index-validate.c | 2 +-
utils/boot-analysis/boot-analysis.c | 2 +-
utils/boot-benchmark/boot-benchmark.c | 2 +-
utils/qemu-boot/qemu-boot.c | 2 +-
utils/qemu-speed-test/qemu-speed-test.c | 2 +-
5 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/builder/index-validate.c b/builder/index-validate.c
index d3912f3..33086b2 100644
--- a/builder/index-validate.c
+++ b/builder/index-validate.c
@@ -38,7 +38,7 @@
extern int do_parse (struct parse_context *context, FILE *in);
-static void
+static void __attribute__((noreturn))
usage (int exit_status)
{
printf ("%s index\n", getprogname ());
diff --git a/utils/boot-analysis/boot-analysis.c b/utils/boot-analysis/boot-analysis.c
index 04b3bdd..1bec9a5 100644
--- a/utils/boot-analysis/boot-analysis.c
+++ b/utils/boot-analysis/boot-analysis.c
@@ -88,7 +88,7 @@ static void print_longest_to_shortest (void);
static void free_pass_data (void);
static void free_final_timeline (void);
-static void
+static void __attribute__((noreturn))
usage (int exitcode)
{
guestfs_h *g;
diff --git a/utils/boot-benchmark/boot-benchmark.c b/utils/boot-benchmark/boot-benchmark.c
index 73da722..4af3943 100644
--- a/utils/boot-benchmark/boot-benchmark.c
+++ b/utils/boot-benchmark/boot-benchmark.c
@@ -51,7 +51,7 @@ static void run_test (void);
static guestfs_h *create_handle (void);
static void add_drive (guestfs_h *g);
-static void
+static void __attribute__((noreturn))
usage (int exitcode)
{
guestfs_h *g;
diff --git a/utils/qemu-boot/qemu-boot.c b/utils/qemu-boot/qemu-boot.c
index 1551a1a..6881835 100644
--- a/utils/qemu-boot/qemu-boot.c
+++ b/utils/qemu-boot/qemu-boot.c
@@ -74,7 +74,7 @@ static void run_test (size_t P);
static void *start_thread (void *thread_data_vp);
static void message_callback (guestfs_h *g, void *opaque, uint64_t event, int event_handle, int flags, const char *buf, size_t buf_len, const uint64_t *array, size_t array_len);
-static void
+static void __attribute__((noreturn))
usage (int exitcode)
{
fprintf (stderr,
diff --git a/utils/qemu-speed-test/qemu-speed-test.c b/utils/qemu-speed-test/qemu-speed-test.c
index 54875fa..5aa663c 100644
--- a/utils/qemu-speed-test/qemu-speed-test.c
+++ b/utils/qemu-speed-test/qemu-speed-test.c
@@ -66,7 +66,7 @@ reset_default_tests (int *flag)
}
}
-static void
+static void __attribute__((noreturn))
usage (int exitcode)
{
fprintf (stderr,
--
2.10.2
7 years, 10 months
Extract VHD using guestfs
by MUHAMMAD MOHSIN
Hi,
I have tried to extract *.vhd* file using guestfs library. I am able to
list all files inside my archive using *guestfs_ls* also
* guestfs_list_filesystems()* retruns right File system information. I am
trying to extract files from inside archive using
*guestfs_copy_device_to_file()
* but it returns following error (error: copy_device_to_file: unknown
option 689330304 (this can happen if a program is compiled against a newer
version of libguestfs, then dynamically linked to an older version)).
Please see attached main.c for my sample code.
Regards
MUHAMMAD MOSHIN
7 years, 10 months
ntfs-3g data deduplication support in guestmount for creating file based back-ups on visualization platform
by Jelle de Jong
Hello everybody,
I am using libguestfs-tools version 1.28.1 in a bunch of bash scripts to
make back-ups of the files on a visualisation platform.
I been trying to get read access to ntfs volumes with data deduplication
working.
The ntfs-3g guys developed some support and I have this working when
using the commands our back-up servers.
However when using the guestmount tool the read suport foor dedub is gone.
See this email for all the commands I use (working mount -t ntfs and
non-working guestmount commands).
https://sourceforge.net/p/ntfs-3g/mailman/message/35595392/
How can I see what version of ntfs-3g is used in guestmount and if it is
using the /usr/lib/x86_64-linux-gnu/ntfs-3g/ntfs-plugin-80000013.so
plugin that is on my back-up server?
Thank you in advance!
Kind regards,
Jelle de Jong
7 years, 10 months
[PATCH v8 0/4] Import directly from OVA tar archive if possible
by Tomáš Golembiovský
v8:
- split the big patch into several commits
v7:
- rebased because patch 1/3 has been pushed
- changes to nsplit have been dropped (2/3)
- addressed Richard's comments, notably the subfolder function was moved to
mllib and renamed to subdirectory
v6:
- just rebase
v5:
- rebase, patches 1,3,5 were merged
- 1/3: we still need to discuss whether to detect compressed discs
- 2/3:
- renamed argument noempty to keep_empty
- tests were not run
- 3/3:
- using JSON module to generate JSON (as suggested by Pino)
- all the other comments raised by Pino
v4:
- rebase to more recent master
- 1/6: using just "quote" instead of "Filename.quote"
- 2/6: reformated block of code according to Richards suggestion
- 4/6: added tests for nsplit
v3: Addressed Pino's comments, namely:
- input_ova.ml
- untar takes list of paths
- renamed untar_partial to untar_metadata
- replaced uggly regex with nsplit
- tests
- test changes are part of the main commit
- renamed test-data/guestfs-hashsums.sh to test-data/test-utils.sh
- renamed qemu_version to qemu_is_version and moved it to
test-data/test-utils.sh
- normalize paths in expect files
v2:
- rewritten the tar invocations, the output processing is now done in
OcaML rather than with a shell code; it turned out to be easier and
more readable than I have feared.
- added QEMU version check
- addressed Pino's comments
- changed tests; the expected result is now based on the QEMU used
during testing
This series is related to the problem of inefficient import of OVA
files. The needed enhancements of QEMU were merged into the codebase and
are available in QEMU 2.8. From there we can use 'size' and
'offset' options in raw driver to tell QEMU to use only subset of a file
as an image.
The patch set is more or less complete. The only outstanding issue is
the missing detection of sparse files inside tar. But this can be done
in a separate patch. As pointed out before I didn't find a way how to
detect that by using the tar tool only and would probably require use of
some external library.
Tomáš Golembiovský (4):
mllib: add subdirectory function to common_utils
v2v: add function qemu_img_version to utils
v2v: add function find_file_in_tar to utils
v2v: ova: don't extract files from OVA if it's not needed
mllib/common_utils.ml | 9 +++
mllib/common_utils.mli | 10 +++
mllib/common_utils_tests.ml | 7 ++
test-data/test-utils.sh | 19 +++++
v2v/Makefile.am | 2 +
v2v/input_ova.ml | 109 +++++++++++++++++++++----
v2v/test-v2v-i-ova-formats.sh | 5 +-
v2v/test-v2v-i-ova-subfolders.expected2 | 18 +++++
v2v/test-v2v-i-ova-subfolders.sh | 13 ++-
v2v/test-v2v-i-ova-tar.expected | 18 +++++
v2v/test-v2v-i-ova-tar.expected2 | 18 +++++
v2v/test-v2v-i-ova-tar.ovf | 138 ++++++++++++++++++++++++++++++++
v2v/test-v2v-i-ova-tar.sh | 72 +++++++++++++++++
v2v/test-v2v-i-ova-two-disks.expected2 | 19 +++++
v2v/test-v2v-i-ova-two-disks.sh | 13 ++-
v2v/utils.ml | 72 +++++++++++++++++
v2v/utils.mli | 12 +++
17 files changed, 530 insertions(+), 24 deletions(-)
create mode 100644 v2v/test-v2v-i-ova-subfolders.expected2
create mode 100644 v2v/test-v2v-i-ova-tar.expected
create mode 100644 v2v/test-v2v-i-ova-tar.expected2
create mode 100644 v2v/test-v2v-i-ova-tar.ovf
create mode 100755 v2v/test-v2v-i-ova-tar.sh
create mode 100644 v2v/test-v2v-i-ova-two-disks.expected2
--
2.11.0
7 years, 10 months
[PATCH v2 0/7] Introducing virt-builder-repository
by Cédric Bosdonnat
Hi all,
Here is a new version of the virt-builder-repository series taking
care of Pino's comments. It has also been rebased on recent master.
Cédric Bosdonnat (7):
mllib: factorize code to add Checksum.get_checksum function
Move xml and xpath_helpers OCAML code to mllib
mllib: expose libosinfo DB reading functions in mllib
builder: rename docs test script
builder: add Index.write_entry function
builder: add a template parameter to get_index
Add a virt-builder-repository tool
.gitignore | 3 +
builder/Makefile.am | 86 +++-
builder/builder.ml | 2 +-
builder/index.mli | 3 +
builder/index_parser.ml | 72 ++-
builder/index_parser.mli | 8 +-
builder/repository_main.ml | 487 +++++++++++++++++++++
.../{test-virt-builder-docs.sh => test-docs.sh} | 3 +
builder/virt-builder-repository.pod | 183 ++++++++
docs/C_SOURCE_FILES | 2 +-
lib/Makefile.am | 2 +
lib/osinfo-iso.c | 464 ++++++++++++++++++++
lib/osinfo.c | 477 ++------------------
lib/osinfo.h | 27 ++
mllib/Makefile.am | 18 +-
mllib/checksums.ml | 25 +-
mllib/checksums.mli | 9 +
mllib/osinfo-c.c | 100 +++++
mllib/osinfo.ml | 26 ++
mllib/osinfo.mli | 31 ++
{v2v => mllib}/xml-c.c | 47 +-
{v2v => mllib}/xml.ml | 49 ++-
{v2v => mllib}/xml.mli | 3 +
{v2v => mllib}/xpath_helpers.ml | 0
{v2v => mllib}/xpath_helpers.mli | 0
v2v/Makefile.am | 17 +-
26 files changed, 1629 insertions(+), 515 deletions(-)
create mode 100644 builder/repository_main.ml
rename builder/{test-virt-builder-docs.sh => test-docs.sh} (89%)
create mode 100644 builder/virt-builder-repository.pod
create mode 100644 lib/osinfo-iso.c
create mode 100644 lib/osinfo.h
create mode 100644 mllib/osinfo-c.c
create mode 100644 mllib/osinfo.ml
create mode 100644 mllib/osinfo.mli
rename {v2v => mllib}/xml-c.c (90%)
rename {v2v => mllib}/xml.ml (79%)
rename {v2v => mllib}/xml.mli (97%)
rename {v2v => mllib}/xpath_helpers.ml (100%)
rename {v2v => mllib}/xpath_helpers.mli (100%)
--
2.11.0
7 years, 10 months