[PATCH 00/11] Getting it work with SLES / openSUSE
by Cédric Bosdonnat
Hi there!
I know it's been a while since I posted my first version of some patches.
But here I have rebased them on top of Roman's work and added a few other ones.
Cédric Bosdonnat (11):
v2v: also search for windows virtio drivers in symlinks
Update packagelist for SLES
customize: fix windows firstboot script
customize: change windows firstboot path
customize: add support for pvvxsvc
v2v: document SUSE's Xen as a working input hypervisor
v2v: add support for SUSE VMDP drivers
v2v: don't set spice display if QXL isn't supported
appliance: fix errors in init for SLE / openSUSE
v2v: rename RHEL 5 Xen input section into Xen in man
v2v: improve initrd search
appliance/init | 5 ++-
appliance/packagelist.in | 4 +--
builder/virt-builder.pod | 13 ++++++--
customize/firstboot.ml | 53 ++++++++++++++++++--------------
customize/virt-customize.pod | 6 ++++
sysprep/virt-sysprep.pod | 6 ++++
v2v/convert_linux.ml | 11 +++----
v2v/convert_windows.ml | 73 ++++++++++++++++++++++++++++++++++++--------
v2v/output_libvirt.ml | 4 ++-
v2v/virt-v2v.pod | 15 +++++++--
v2v/windows_virtio.ml | 27 +++++++++++-----
11 files changed, 157 insertions(+), 60 deletions(-)
--
2.6.6
8 years, 6 months
[PATCH] launch: Use tsc=reliable.
by Richard W.M. Jones
I've pushed this change already actually.
No one seems to know if this option is safe. If you see strange
timing-related things happening in libguestfs, let us know!
Rich.
8 years, 6 months
[PATCH 1/2] Revert "appliance: init: run ldconfig"
by Richard W.M. Jones
Running ldconfig adds about 100ms to the boot time. I would prefer
that we understood which libraries need ldconfig to be run, and fix
that. We could also consider running ldconfig in parallel, but since
it might be required by just about any binary that the init script
runs it's not clear what benefit that gives.
This reverts commit 66aa98265dd215dcd4c717e7ef6845fbac859e54.
---
appliance/init | 4 ----
1 file changed, 4 deletions(-)
diff --git a/appliance/init b/appliance/init
index 413a95f..419434a 100755
--- a/appliance/init
+++ b/appliance/init
@@ -17,10 +17,6 @@ if [ ! -d /tmp ] || [ ! -d /var/tmp ]; then
chmod 1777 /tmp /var/tmp
fi
-# Make sure to find all the libraries, also those in non-standard place
-# but with a proper ld.so configuration pointing at them
-ldconfig
-
# Try to print a stack trace for segfaults inside the appliance.
for d in /lib64 /lib; do
f=$d/libSegFault.so
--
2.7.4
8 years, 6 months
[PATCH] New API: btrfs-filesystem-show (RHBZ#1164765)
by Pino Toscano
Add a new API to list all the devices where a btrfs filesystem is
spanned.
---
daemon/btrfs.c | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++++
generator/actions.ml | 27 ++++++++++++++++++
src/MAX_PROC_NR | 2 +-
3 files changed, 106 insertions(+), 1 deletion(-)
diff --git a/daemon/btrfs.c b/daemon/btrfs.c
index 2a20cb0..62bdac7 100644
--- a/daemon/btrfs.c
+++ b/daemon/btrfs.c
@@ -2203,6 +2203,84 @@ do_btrfs_replace (const char *srcdev, const char *targetdev,
return 0;
}
+char **
+do_btrfs_filesystem_show (const char *device)
+{
+ CLEANUP_FREE_STRINGSBUF DECLARE_STRINGSBUF (ret);
+ const size_t MAX_ARGS = 16;
+ const char *argv[MAX_ARGS];
+ size_t i = 0;
+ CLEANUP_FREE char *out = NULL;
+ CLEANUP_FREE char *err = NULL;
+ CLEANUP_FREE_STRING_LIST char **lines = NULL;
+ int r;
+
+ ADD_ARG (argv, i, str_btrfs);
+ ADD_ARG (argv, i, "filesystem");
+ ADD_ARG (argv, i, "show");
+ ADD_ARG (argv, i, device);
+ ADD_ARG (argv, i, NULL);
+
+ r = commandv (&out, &err, argv);
+ if (r == -1) {
+ reply_with_error ("%s: %s", device, err);
+ return NULL;
+ }
+
+ lines = split_lines (out);
+ if (!lines)
+ return NULL;
+
+ if (count_strings (lines) < 3) {
+ reply_with_error ("truncated output from 'btrfs filesystem show' command");
+ return NULL;
+ }
+
+ /* Output of `btrfs filesystem show' is like:
+ *
+ * Label: none uuid: 99a1b6ba-de46-4a93-8f91-7d7685970a6c
+ * Total devices 3 FS bytes used 1.12MiB
+ * devid 1 size 10.00GiB used 2.00GiB path /dev/sda
+ * [...]
+ *
+ * or:
+ *
+ * Label: none uuid: 99a1b6ba-de46-4a93-8f91-7d7685970a6c
+ * Total devices 3 FS bytes used 1.12MiB
+ * devid 1 size 10.00GiB used 2.00GiB path /dev/sda
+ * [...]
+ * *** Some devices missing
+ */
+ for (i = 1; lines[i] != NULL; ++i) {
+ if (lines[i][0] == 0)
+ continue;
+ if (STRPREFIX (lines[i], "Label: "))
+ continue;
+ else if (STRPREFIX (lines[i], "\tTotal devices "))
+ continue;
+ else if (STRPREFIX (lines[i], "\tdevid ")) {
+ const char *p = strstr (lines[i], " path ");
+ const char *end;
+ if (!p)
+ continue;
+
+ p += strlen (" path ");
+ end = strchrnul (p, ' ');
+ add_sprintf (&ret, "%.*s", (int) (end - p), p);
+ } else if (STRPREFIX (lines[i], "\t*** Some devices missing")) {
+ reply_with_error_errno (ENODEV, "%s: missing devices", device);
+ return NULL;
+ } else {
+ reply_with_error ("unrecognized line in output from 'btrfs filesystem show': %s", lines[i]);
+ return NULL;
+ }
+ }
+
+ end_stringsbuf (&ret);
+
+ return take_stringsbuf (&ret);
+}
+
/* btrfs command add a new command
* inspect-internal min-dev-size <path>
* since v4.2
diff --git a/generator/actions.ml b/generator/actions.ml
index e5cb939..3566371 100644
--- a/generator/actions.ml
+++ b/generator/actions.ml
@@ -12958,6 +12958,33 @@ and save it as F<filename> on the local machine.
This allows to download deleted or inaccessible files." };
+ { defaults with
+ name = "btrfs_filesystem_show"; added = (1, 33, 29);
+ style = RStringList "devices", [Device "device"], [];
+ proc_nr = Some 465;
+ optional = Some "btrfs"; camel_name = "BTRFSFilesystemsShow";
+ tests = [
+ InitScratchFS, Always, TestLastFail (
+ [["btrfs_filesystem_show"; "/dev/sdb"]]), [];
+ InitPartition, Always, TestResult (
+ [["mkfs_btrfs"; "/dev/sda1"; ""; ""; "NOARG"; ""; "NOARG"; "NOARG"; ""; ""];
+ ["btrfs_filesystem_show"; "/dev/sda1"]],
+ "is_string_list (ret, 1, \"/dev/sda1\")"), [];
+ InitEmpty, Always, TestResult (
+ [["part_init"; "/dev/sda"; "mbr"];
+ ["part_add"; "/dev/sda"; "p"; "64"; "2047999"];
+ ["part_add"; "/dev/sda"; "p"; "2048000"; "4095999"];
+ ["mkfs_btrfs"; "/dev/sda1 /dev/sda2"; ""; ""; "NOARG"; ""; "NOARG"; "NOARG"; ""; ""];
+ ["btrfs_filesystem_show"; "/dev/sda1"]],
+ "is_string_list (ret, 2, \"/dev/sda1\", \"/dev/sda2\")"), [];
+ ];
+ shortdesc = "list devices for btrfs filesystem";
+ longdesc = "\
+Show all the devices where the filesystems in C<device> is spanned over.
+
+If not all the devices for the filesystems are present, then this function
+fails and the C<errno> is set to C<ENODEV>." };
+
]
(* Non-API meta-commands available only in guestfish.
diff --git a/src/MAX_PROC_NR b/src/MAX_PROC_NR
index 3bb8a49..073c57b 100644
--- a/src/MAX_PROC_NR
+++ b/src/MAX_PROC_NR
@@ -1 +1 @@
-464
+465
--
2.5.5
8 years, 6 months
virt-v2v : Import Ubuntu VM
by Kevin COUSIN
Hi list,
Is it possible to import Ubuntu (or Debian) VM with virt-p2v or virt-v2v
to oVirt ?
Thanks
Kevin C
8 years, 6 months
[PATCH] builder: run/schedule a SELinux relabel if needed
by Pino Toscano
If the guest uses SELinux, then make sure to run a relabel (or at least
schedule one) after the image build: this way the template is
relabelled, or at least it will do that at the next boot, without the
need for the user to ask for a relabel.
This just covers the case of building a new image with no additional
operations on it though.
---
builder/website/centos.sh | 2 ++
builder/website/compress.sh | 18 +++++++++++++++++-
builder/website/fedora-aarch64.sh | 2 ++
builder/website/fedora-armv7l.sh | 2 ++
builder/website/fedora-i686.sh | 2 ++
builder/website/fedora-ppc64.sh | 2 ++
builder/website/fedora-ppc64le.sh | 2 ++
builder/website/fedora.sh | 2 ++
builder/website/rhel-aarch64.sh | 2 ++
builder/website/rhel-ppc64.sh | 2 ++
builder/website/rhel-ppc64le.sh | 2 ++
builder/website/rhel.sh | 2 ++
builder/website/scientificlinux.sh | 2 ++
13 files changed, 41 insertions(+), 1 deletion(-)
diff --git a/builder/website/centos.sh b/builder/website/centos.sh
index 5217aef..69670fe 100755
--- a/builder/website/centos.sh
+++ b/builder/website/centos.sh
@@ -96,4 +96,6 @@ virt-install \
--nographics \
--noreboot
+DO_RELABEL=1
+
source $(dirname "$0")/compress.sh $output
diff --git a/builder/website/compress.sh b/builder/website/compress.sh
index 2148804..4e09bf3 100644
--- a/builder/website/compress.sh
+++ b/builder/website/compress.sh
@@ -20,10 +20,26 @@
output=$1
+relabel_args=()
+
+if [ -n "$DO_RELABEL" ]; then
+ os_arch=$(uname -m)
+ guest_arch=$(virt-inspector -a "$output" | virt-inspector --xpath "string(/operatingsystems/operatingsystem/arch)")
+
+ if [ "$os_arch" = "$guest_arch" ] || [ "$os_arch" = "x86_64" -a "$guest_arch" = "i386" ]; then
+ # this is what --selinux-relabel should really do, but do it ourselves
+ # in the meanwhile -- see RHBZ#1089100.
+ relabel_args+=(--run-command "setfiles /etc/selinux/targeted/contexts/files/file_contexts /")
+ else
+ relabel_args+=(--selinux-relabel)
+ fi
+
+fi
+
# Sysprep (removes logfiles and so on).
# Note this also touches /.autorelabel so the further installation
# changes that we make will be labelled properly at first boot.
-virt-sysprep -a $output
+virt-sysprep -a $output "${relabel_args[@]}"
# Sparsify.
mv $output $output.old
diff --git a/builder/website/fedora-aarch64.sh b/builder/website/fedora-aarch64.sh
index 8c7c1b9..1de834d 100755
--- a/builder/website/fedora-aarch64.sh
+++ b/builder/website/fedora-aarch64.sh
@@ -103,4 +103,6 @@ virt-install \
cp $vars $output-nvram
xz --best $output-nvram
+DO_RELABEL=1
+
source $(dirname "$0")/compress.sh $output
diff --git a/builder/website/fedora-armv7l.sh b/builder/website/fedora-armv7l.sh
index 1de9b93..ece95c3 100755
--- a/builder/website/fedora-armv7l.sh
+++ b/builder/website/fedora-armv7l.sh
@@ -92,4 +92,6 @@ virt-install \
--nographics \
--noreboot
+DO_RELABEL=1
+
source $(dirname "$0")/compress.sh $output
diff --git a/builder/website/fedora-i686.sh b/builder/website/fedora-i686.sh
index ccae8ab..92d3f21 100755
--- a/builder/website/fedora-i686.sh
+++ b/builder/website/fedora-i686.sh
@@ -100,4 +100,6 @@ virt-install \
--nographics \
--noreboot
+DO_RELABEL=1
+
source $(dirname "$0")/compress.sh $output
diff --git a/builder/website/fedora-ppc64.sh b/builder/website/fedora-ppc64.sh
index b664e04..c8eafe2 100755
--- a/builder/website/fedora-ppc64.sh
+++ b/builder/website/fedora-ppc64.sh
@@ -92,4 +92,6 @@ virt-install \
--nographics \
--noreboot
+DO_RELABEL=1
+
source $(dirname "$0")/compress.sh $output
diff --git a/builder/website/fedora-ppc64le.sh b/builder/website/fedora-ppc64le.sh
index 351b569..8645ab4 100755
--- a/builder/website/fedora-ppc64le.sh
+++ b/builder/website/fedora-ppc64le.sh
@@ -92,4 +92,6 @@ virt-install \
--nographics \
--noreboot
+DO_RELABEL=1
+
source $(dirname "$0")/compress.sh $output
diff --git a/builder/website/fedora.sh b/builder/website/fedora.sh
index 8e48ce1..8911d14 100755
--- a/builder/website/fedora.sh
+++ b/builder/website/fedora.sh
@@ -100,4 +100,6 @@ virt-install \
--nographics \
--noreboot
+DO_RELABEL=1
+
source $(dirname "$0")/compress.sh $output
diff --git a/builder/website/rhel-aarch64.sh b/builder/website/rhel-aarch64.sh
index a8d1019..467d43b 100755
--- a/builder/website/rhel-aarch64.sh
+++ b/builder/website/rhel-aarch64.sh
@@ -159,4 +159,6 @@ cp $vars $output-nvram
guestfish --rw -a $output -m $guestroot \
upload $yum /etc/yum.repos.d/download.devel.redhat.com.repo
+DO_RELABEL=1
+
source $(dirname "$0")/compress.sh $output
diff --git a/builder/website/rhel-ppc64.sh b/builder/website/rhel-ppc64.sh
index 48d6280..32148ae 100755
--- a/builder/website/rhel-ppc64.sh
+++ b/builder/website/rhel-ppc64.sh
@@ -140,4 +140,6 @@ virt-install \
guestfish --rw -a $output -m $guestroot \
upload $yum /etc/yum.repos.d/download.devel.redhat.com.repo
+DO_RELABEL=1
+
source $(dirname "$0")/compress.sh $output
diff --git a/builder/website/rhel-ppc64le.sh b/builder/website/rhel-ppc64le.sh
index a6dcc5b..9169b12 100755
--- a/builder/website/rhel-ppc64le.sh
+++ b/builder/website/rhel-ppc64le.sh
@@ -140,4 +140,6 @@ virt-install \
guestfish --rw -a $output -m $guestroot \
upload $yum /etc/yum.repos.d/download.devel.redhat.com.repo
+DO_RELABEL=1
+
source $(dirname "$0")/compress.sh $output
diff --git a/builder/website/rhel.sh b/builder/website/rhel.sh
index 0c64563..fcb7315 100755
--- a/builder/website/rhel.sh
+++ b/builder/website/rhel.sh
@@ -225,4 +225,6 @@ guestfish --rw -a $output -m $guestroot \
upload $yum /etc/yum.repos.d/download.devel.redhat.com.repo
fi
+DO_RELABEL=1
+
source $(dirname "$0")/compress.sh $output
diff --git a/builder/website/scientificlinux.sh b/builder/website/scientificlinux.sh
index f3f8948..2cd2c8f 100755
--- a/builder/website/scientificlinux.sh
+++ b/builder/website/scientificlinux.sh
@@ -86,4 +86,6 @@ virt-install \
--nographics \
--noreboot
+DO_RELABEL=1
+
source $(dirname "$0")/compress.sh $output
--
2.5.5
8 years, 6 months
[PATCH] perl: use INT2PTR macro for casting back to guestfs_h * (RHBZ#1150298)
by Pino Toscano
Use the right macro, which should avoid the warnings seen with Perl
headers on some architecture.
---
generator/perl.ml | 2 +-
perl/typemap | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/generator/perl.ml b/generator/perl.ml
index 19cabb6..a665051 100644
--- a/generator/perl.ml
+++ b/generator/perl.ml
@@ -242,7 +242,7 @@ DESTROY (sv)
HV *hv = (HV *) SvRV (sv);
SV **svp = hv_fetch (hv, \"_g\", 2, 0);
if (svp != NULL) {
- guestfs_h *g = (guestfs_h *) SvIV (*svp);
+ guestfs_h *g = INT2PTR (guestfs_h *, SvIV (*svp));
_close_handle (g);
}
diff --git a/perl/typemap b/perl/typemap
index 508e378..0a92e53 100644
--- a/perl/typemap
+++ b/perl/typemap
@@ -14,7 +14,7 @@ O_OBJECT_guestfs_h
SV **svp = hv_fetch (hv, \"_g\", 2, 0);
if (svp == NULL)
croak (\"${Package}::$func_name(): called on a closed handle\");
- $var = ($type) SvIV (*svp);
+ $var = INT2PTR ($type, SvIV (*svp));
} else {
croak (\"${Package}::$func_name(): $var is not a blessed HV reference\");
}
--
2.5.5
8 years, 6 months
[PATCH] python: use constants instead of raw values
by Pino Toscano
Extend the internal libguestfsmod module with the CREATE values, so
there is no need to hardcode values in GuestFS.__init__.
---
generator/python.ml | 7 +++++--
python/guestfs-py-byhand.c | 7 +++++++
python/guestfs-py.h | 2 ++
3 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/generator/python.ml b/generator/python.ml
index 9744b8f..470abe7 100644
--- a/generator/python.ml
+++ b/generator/python.ml
@@ -597,6 +597,9 @@ moduleinit (void)
m = Py_InitModule ((char *) \"libguestfsmod\", methods);
#endif
+ if (m != NULL)
+ guestfs_int_py_extend_module (m);
+
return m; /* m might be NULL if module init failed */
}
@@ -719,9 +722,9 @@ class GuestFS(object):
\"\"\"
flags = 0
if not environment:
- flags |= 1
+ flags |= libguestfsmod.GUESTFS_CREATE_NO_ENVIRONMENT
if not close_on_exit:
- flags |= 2
+ flags |= libguestfsmod.GUESTFS_CREATE_NO_CLOSE_ON_EXIT
self._o = libguestfsmod.create(flags)
self._python_return_dict = python_return_dict
diff --git a/python/guestfs-py-byhand.c b/python/guestfs-py-byhand.c
index cf8576f..9e2debf 100644
--- a/python/guestfs-py-byhand.c
+++ b/python/guestfs-py-byhand.c
@@ -37,6 +37,13 @@
static PyObject **get_all_event_callbacks (guestfs_h *g, size_t *len_rtn);
+void
+guestfs_int_py_extend_module (PyObject *module)
+{
+ PyModule_AddIntMacro(module, GUESTFS_CREATE_NO_ENVIRONMENT);
+ PyModule_AddIntMacro(module, GUESTFS_CREATE_NO_CLOSE_ON_EXIT);
+}
+
PyObject *
guestfs_int_py_create (PyObject *self, PyObject *args)
{
diff --git a/python/guestfs-py.h b/python/guestfs-py.h
index da5f483..f2246a6 100644
--- a/python/guestfs-py.h
+++ b/python/guestfs-py.h
@@ -59,6 +59,8 @@ put_handle (guestfs_h *g)
#endif
}
+extern void guestfs_int_py_extend_module (PyObject *module);
+
extern PyObject *guestfs_int_py_create (PyObject *self, PyObject *args);
extern PyObject *guestfs_int_py_close (PyObject *self, PyObject *args);
extern PyObject *guestfs_int_py_set_event_callback (PyObject *self, PyObject *args);
--
2.5.5
8 years, 6 months
[PATCH v2] inspect: check also /etc/hosts for detecting Linux root (RHBZ#1203898)
by Pino Toscano
Use /etc/hosts as alternative of /etc/fstab to detect whether a partition
represents the root of a Linux installation; the latter might not exist
in smaller/special installations like Docker images.
---
Repost (refreshed) of
https://www.redhat.com/archives/libguestfs/2016-February/msg00207.html
src/inspect-fs.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/inspect-fs.c b/src/inspect-fs.c
index 7f7d5d1..e9976cf 100644
--- a/src/inspect-fs.c
+++ b/src/inspect-fs.c
@@ -217,7 +217,8 @@ check_filesystem (guestfs_h *g, const char *mountable,
else if (is_dir_etc &&
(is_dir_bin ||
is_symlink_to (g, "/bin", "usr/bin") > 0) &&
- guestfs_is_file (g, "/etc/fstab") > 0) {
+ (guestfs_is_file (g, "/etc/fstab") > 0 ||
+ guestfs_is_file (g, "/etc/hosts") > 0)) {
fs->is_root = 1;
fs->format = OS_FORMAT_INSTALLED;
if (guestfs_int_check_linux_root (g, fs) == -1)
--
2.5.5
8 years, 6 months
[PATCH] tools: improve reporting for option errors (RHBZ#1316041)
by Pino Toscano
Improve the error messages produced by C-based tools in case of issues
with the command line options:
- explicitly mention to use -a/-d (and -A/-D in virt-diff)
- when extra arguments are found, mention the correct way to pass
options to certain command line switches (like --format)
- in virt-inspector, give a cleaner error message when neither -i nor
any -m is specified
In all the cases, keep the extra notice to use 'TOOL --help' to get more
help with it.
---
cat/cat.c | 5 ++++-
cat/filesystems.c | 12 ++++++++++--
cat/log.c | 12 ++++++++++--
cat/ls.c | 5 ++++-
diff/diff.c | 21 +++++++++++++++------
edit/edit.c | 5 ++++-
format/format.c | 12 ++++++++++--
fuse/guestmount.c | 13 ++++++++++---
inspector/inspector.c | 12 ++++++++++--
rescue/rescue.c | 12 ++++++++++--
10 files changed, 87 insertions(+), 22 deletions(-)
diff --git a/cat/cat.c b/cat/cat.c
index 0370fbd..4d671ca 100644
--- a/cat/cat.c
+++ b/cat/cat.c
@@ -224,8 +224,11 @@ main (int argc, char *argv[])
CHECK_OPTION_format_consumed;
/* User must have specified some drives. */
- if (drvs == NULL)
+ if (drvs == NULL) {
+ fprintf (stderr, _("%s: error: you must specify at least one -a or -d option.\n"),
+ guestfs_int_program_name);
usage (EXIT_FAILURE);
+ }
/* Add drives, inspect and mount. */
add_drives (drvs, 'a');
diff --git a/cat/filesystems.c b/cat/filesystems.c
index 3f9d931..f1c2852 100644
--- a/cat/filesystems.c
+++ b/cat/filesystems.c
@@ -291,8 +291,13 @@ main (int argc, char *argv[])
assert (live == 0);
/* Must be no extra arguments on the command line. */
- if (optind != argc)
+ if (optind != argc) {
+ fprintf (stderr, _("%s: error: extra argument '%s' on command line.\n"
+ "Make sure to specify the argument for --format "
+ "like '--format=%s'.\n"),
+ guestfs_int_program_name, argv[optind], argv[optind]);
usage (EXIT_FAILURE);
+ }
CHECK_OPTION_format_consumed;
@@ -329,8 +334,11 @@ main (int argc, char *argv[])
title = 0;
/* User must have specified some drives. */
- if (drvs == NULL)
+ if (drvs == NULL) {
+ fprintf (stderr, _("%s: error: you must specify at least one -a or -d option.\n"),
+ guestfs_int_program_name);
usage (EXIT_FAILURE);
+ }
/* Add drives. */
add_drives (drvs, 'a');
diff --git a/cat/log.c b/cat/log.c
index daefda7..6632f5a 100644
--- a/cat/log.c
+++ b/cat/log.c
@@ -184,14 +184,22 @@ main (int argc, char *argv[])
assert (live == 0);
/* User must not specify more arguments on the command line. */
- if (optind != argc)
+ if (optind != argc) {
+ fprintf (stderr, _("%s: error: extra argument '%s' on command line.\n"
+ "Make sure to specify the argument for --format "
+ "like '--format=%s'.\n"),
+ guestfs_int_program_name, argv[optind], argv[optind]);
usage (EXIT_FAILURE);
+ }
CHECK_OPTION_format_consumed;
/* User must have specified some drives. */
- if (drvs == NULL)
+ if (drvs == NULL) {
+ fprintf (stderr, _("%s: error: you must specify at least one -a or -d option.\n"),
+ guestfs_int_program_name);
usage (EXIT_FAILURE);
+ }
/* Add drives, inspect and mount. Note that inspector is always true,
* and there is no -m option.
diff --git a/cat/ls.c b/cat/ls.c
index 91f2125..f990737 100644
--- a/cat/ls.c
+++ b/cat/ls.c
@@ -340,8 +340,11 @@ main (int argc, char *argv[])
usage (EXIT_FAILURE);
/* User must have specified some drives. */
- if (drvs == NULL)
+ if (drvs == NULL) {
+ fprintf (stderr, _("%s: error: you must specify at least one -a or -d option.\n"),
+ guestfs_int_program_name);
usage (EXIT_FAILURE);
+ }
/* Add drives, inspect and mount. */
add_drives (drvs, 'a');
diff --git a/diff/diff.c b/diff/diff.c
index d7542fc..210abc2 100644
--- a/diff/diff.c
+++ b/diff/diff.c
@@ -311,10 +311,14 @@ main (int argc, char *argv[])
}
}
- if (drvs == NULL || drvs2 == NULL) {
- fprintf (stderr,
- _("%s: you must specify some -a|-A|-d|-D options, see %s(1)\n"),
- guestfs_int_program_name, guestfs_int_program_name);
+ if (drvs == NULL) {
+ fprintf (stderr, _("%s: error: you must specify at least one -a or -d option.\n"),
+ guestfs_int_program_name);
+ usage (EXIT_FAILURE);
+ }
+ if (drvs2 == NULL) {
+ fprintf (stderr, _("%s: error: you must specify at least one -A or -D option.\n"),
+ guestfs_int_program_name);
usage (EXIT_FAILURE);
}
@@ -324,8 +328,13 @@ main (int argc, char *argv[])
if (human && csv)
error (EXIT_FAILURE, 0, _("you cannot use -h and --csv options together."));
- if (optind != argc)
- error (EXIT_FAILURE, 0, _("extra arguments on the command line"));
+ if (optind != argc) {
+ fprintf (stderr, _("%s: error: extra argument '%s' on command line.\n"
+ "Make sure to specify the argument for --checksum or --format "
+ "like '--format=%s'.\n"),
+ guestfs_int_program_name, argv[optind], argv[optind]);
+ usage (EXIT_FAILURE);
+ }
/* These are really constants, but they have to be variables for the
* options parsing code. Assert here that they have known-good
diff --git a/edit/edit.c b/edit/edit.c
index 6e7aee4..2d3ccc6 100644
--- a/edit/edit.c
+++ b/edit/edit.c
@@ -253,8 +253,11 @@ main (int argc, char *argv[])
CHECK_OPTION_format_consumed;
/* User must have specified some drives. */
- if (drvs == NULL)
+ if (drvs == NULL) {
+ fprintf (stderr, _("%s: error: you must specify at least one -a or -d option.\n"),
+ guestfs_int_program_name);
usage (EXIT_FAILURE);
+ }
/* Add drives. */
add_drives (drvs, 'a');
diff --git a/format/format.c b/format/format.c
index 4aa31de..5026aff 100644
--- a/format/format.c
+++ b/format/format.c
@@ -219,14 +219,22 @@ main (int argc, char *argv[])
assert (live == 0);
/* Must be no extra arguments on the command line. */
- if (optind != argc)
+ if (optind != argc) {
+ fprintf (stderr, _("%s: error: extra argument '%s' on command line.\n"
+ "Make sure to specify the argument for --format, --lvm "
+ "or --partition like '--format=%s'.\n"),
+ guestfs_int_program_name, argv[optind], argv[optind]);
usage (EXIT_FAILURE);
+ }
CHECK_OPTION_format_consumed;
/* The user didn't specify any drives to format. */
- if (drvs == NULL)
+ if (drvs == NULL) {
+ fprintf (stderr, _("%s: error: you must specify at least one -a option.\n"),
+ guestfs_int_program_name);
usage (EXIT_FAILURE);
+ }
/* Because the libguestfs kernel can get stuck rereading the
* partition table after things have been erased, we sometimes need
diff --git a/fuse/guestmount.c b/fuse/guestmount.c
index fc03a9c..f72ecb8 100644
--- a/fuse/guestmount.c
+++ b/fuse/guestmount.c
@@ -311,9 +311,16 @@ main (int argc, char *argv[])
/* Check we have the right options. */
if (!live) {
- if (!drvs || !(mps || inspector))
- error (EXIT_FAILURE, 0,
- _("must have at least one -a/-d and at least one -m/-i option"));
+ if (drvs == NULL) {
+ fprintf (stderr, _("%s: error: you must specify at least one -a or -d option.\n"),
+ guestfs_int_program_name);
+ usage (EXIT_FAILURE);
+ }
+ if (!(mps || inspector)) {
+ fprintf (stderr, _("%s: error: you must specify either -i at least one -m option.\n"),
+ guestfs_int_program_name);
+ usage (EXIT_FAILURE);
+ }
} else {
size_t count_d = 0, count_other = 0;
struct drv *drv;
diff --git a/inspector/inspector.c b/inspector/inspector.c
index 6d4694d..d8e455e 100644
--- a/inspector/inspector.c
+++ b/inspector/inspector.c
@@ -233,8 +233,13 @@ main (int argc, char *argv[])
assert (live == 0);
/* Must be no extra arguments on the command line. */
- if (optind != argc)
+ if (optind != argc) {
+ fprintf (stderr, _("%s: error: extra argument '%s' on command line.\n"
+ "Make sure to specify the argument for --format "
+ "like '--format=%s'.\n"),
+ guestfs_int_program_name, argv[optind], argv[optind]);
usage (EXIT_FAILURE);
+ }
CHECK_OPTION_format_consumed;
@@ -252,8 +257,11 @@ main (int argc, char *argv[])
}
/* User must have specified some drives. */
- if (drvs == NULL)
+ if (drvs == NULL) {
+ fprintf (stderr, _("%s: error: you must specify at least one -a or -d option.\n"),
+ guestfs_int_program_name);
usage (EXIT_FAILURE);
+ }
/* Add drives, inspect and mount. Note that inspector is always true,
* and there is no -m option.
diff --git a/rescue/rescue.c b/rescue/rescue.c
index c46c775..135c9e6 100644
--- a/rescue/rescue.c
+++ b/rescue/rescue.c
@@ -275,14 +275,22 @@ main (int argc, char *argv[])
assert (live == 0);
/* Must be no extra arguments on the command line. */
- if (optind != argc)
+ if (optind != argc) {
+ fprintf (stderr, _("%s: error: extra argument '%s' on command line.\n"
+ "Make sure to specify the argument for --format or --scratch "
+ "like '--format=%s'.\n"),
+ guestfs_int_program_name, argv[optind], argv[optind]);
usage (EXIT_FAILURE);
+ }
CHECK_OPTION_format_consumed;
/* User must have specified some drives. */
- if (drvs == NULL)
+ if (drvs == NULL) {
+ fprintf (stderr, _("%s: error: you must specify at least one -a or -d option.\n"),
+ guestfs_int_program_name);
usage (EXIT_FAILURE);
+ }
/* Setting "direct mode" is required for the rescue appliance. */
if (guestfs_set_direct (g, 1) == -1)
--
2.5.5
8 years, 6 months