[PATCH v2 0/5] btrfs support part1: subvolume commands
by Hu Tao
Hi,
This is the part1 of improving btrfs support. This series adds missing
parameters to btrfs_subvolume_snapshot and btrfs_subvolume_create, and
adds two new API btrfs_subvolume_get_default and btrfs_subvolume_show.
Other parts will follow.
Regards,
Hu
changes:
v2:
- add 'once_had_no_optargs = true' for btrfs_subvolume_snapshot and
btrfs_subvolume_create
- improved documents for btrfs_subvolume_snapshot and
btrfs_subvolume_create
- coding style change (patch 5)
- add analyze_line (patch 5)
- rebase
Hu Tao (5):
btrfs: add optional parameter `ro' to btrfs_subvolume_snapshot
btrfs: add optional parameter `qgroupid' to btrfs_subvolume_snapshot
btrfs: add optional parameter `qgroupid' to btrfs_subvolume_create
New API: btrfs_subvolume_get_default
New API: btrfs_subvolume_show
daemon/btrfs.c | 246 ++++++++++++++++++++++++++++++++++++++++++++++++++-
generator/actions.ml | 51 ++++++++---
src/MAX_PROC_NR | 2 +-
3 files changed, 284 insertions(+), 15 deletions(-)
--
1.9.3
9 years, 12 months
[PATCH] remove commented-out debug code
by Hu Tao
This makes code cleaner.
Signed-off-by: Hu Tao <hutao(a)cn.fujitsu.com>
---
daemon/journal.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/daemon/journal.c b/daemon/journal.c
index a2a1c73..f666026 100644
--- a/daemon/journal.c
+++ b/daemon/journal.c
@@ -164,7 +164,6 @@ do_internal_journal_get (void)
sd_journal_restart_data (j);
while ((r = sd_journal_enumerate_data (j, &data, &len)) > 0) {
- //fprintf (stderr, "data[%zu] = %.*s\n", len, (int) len, (char*) data);
len_be = htobe64 ((uint64_t) len);
if (send_file_write (&len_be, sizeof (len_be)) < 0)
return -1;
--
1.9.3
9 years, 12 months
[PATCH] tools: implement --short-options
by Pino Toscano
Just like --long-options, it makes it possible to know which short
options are supported by each tool; this can help improving the bash
completion, for example.
---
align/scan.c | 3 +++
builder/cmdline.ml | 1 +
cat/cat.c | 3 +++
cat/filesystems.c | 3 +++
cat/log.c | 3 +++
cat/ls.c | 3 +++
customize/customize_main.ml | 1 +
df/main.c | 3 +++
diff/diff.c | 3 +++
edit/edit.c | 3 +++
fish/fish.c | 3 +++
fish/options.c | 16 +++++++++++++++-
fish/options.h | 1 +
format/format.c | 3 +++
fuse/guestmount.c | 3 +++
inspector/inspector.c | 3 +++
make-fs/make-fs.c | 4 ++++
mllib/common_utils.ml | 9 ++++++++-
mllib/common_utils.mli | 2 ++
p2v/main.c | 17 ++++++++++++++++-
rescue/rescue.c | 3 +++
resize/resize.ml | 1 +
sparsify/cmdline.ml | 1 +
sysprep/main.ml | 1 +
v2v/cmdline.ml | 1 +
25 files changed, 91 insertions(+), 3 deletions(-)
diff --git a/align/scan.c b/align/scan.c
index e803d8e..7da468f 100644
--- a/align/scan.c
+++ b/align/scan.c
@@ -115,6 +115,7 @@ main (int argc, char *argv[])
{ "help", 0, 0, HELP_OPTION },
{ "long-options", 0, 0, 0 },
{ "quiet", 0, 0, 'q' },
+ { "short-options", 0, 0, 0 },
{ "uuid", 0, 0, 0, },
{ "verbose", 0, 0, 'v' },
{ "version", 0, 0, 'V' },
@@ -143,6 +144,8 @@ main (int argc, char *argv[])
case 0: /* options which are long only */
if (STREQ (long_options[option_index].name, "long-options"))
display_long_options (long_options);
+ else if (STREQ (long_options[option_index].name, "short-options"))
+ display_short_options (options);
else if (STREQ (long_options[option_index].name, "format")) {
OPTION_format;
} else if (STREQ (long_options[option_index].name, "uuid")) {
diff --git a/builder/cmdline.ml b/builder/cmdline.ml
index e21d5bb..bb7b1d0 100644
--- a/builder/cmdline.ml
+++ b/builder/cmdline.ml
@@ -135,6 +135,7 @@ let parse_cmdline () =
"--long", Arg.Unit list_set_long, " " ^ s_"Shortcut for --list-format short";
"--list-format", Arg.String list_set_format,
"short|long|json" ^ " " ^ s_"Set the format for --list (default: short)";
+ "--short-options", Arg.Unit display_short_options, " " ^ s_"List short options";
"--long-options", Arg.Unit display_long_options, " " ^ s_"List long options";
"--machine-readable", Arg.Set machine_readable, " " ^ s_"Make output machine readable";
"-m", Arg.Int set_memsize, "mb" ^ " " ^ s_"Set memory size";
diff --git a/cat/cat.c b/cat/cat.c
index ec9c81f..fdfa3a9 100644
--- a/cat/cat.c
+++ b/cat/cat.c
@@ -99,6 +99,7 @@ main (int argc, char *argv[])
{ "keys-from-stdin", 0, 0, 0 },
{ "long-options", 0, 0, 0 },
{ "mount", 1, 0, 'm' },
+ { "short-options", 0, 0, 0 },
{ "verbose", 0, 0, 'v' },
{ "version", 0, 0, 'V' },
{ 0, 0, 0, 0 }
@@ -128,6 +129,8 @@ main (int argc, char *argv[])
case 0: /* options which are long only */
if (STREQ (long_options[option_index].name, "long-options"))
display_long_options (long_options);
+ else if (STREQ (long_options[option_index].name, "short-options"))
+ display_short_options (options);
else if (STREQ (long_options[option_index].name, "keys-from-stdin")) {
keys_from_stdin = 1;
} else if (STREQ (long_options[option_index].name, "echo-keys")) {
diff --git a/cat/filesystems.c b/cat/filesystems.c
index f9f887a..79d12bd 100644
--- a/cat/filesystems.c
+++ b/cat/filesystems.c
@@ -164,6 +164,7 @@ main (int argc, char *argv[])
{ "physical-volumes", 0, 0, 0 },
{ "physvols", 0, 0, 0 },
{ "pvs", 0, 0, 0 },
+ { "short-options", 0, 0, 0 },
{ "uuid", 0, 0, 0 },
{ "uuids", 0, 0, 0 },
{ "verbose", 0, 0, 'v' },
@@ -197,6 +198,8 @@ main (int argc, char *argv[])
case 0: /* options which are long only */
if (STREQ (long_options[option_index].name, "long-options"))
display_long_options (long_options);
+ else if (STREQ (long_options[option_index].name, "short-options"))
+ display_short_options (options);
else if (STREQ (long_options[option_index].name, "keys-from-stdin")) {
keys_from_stdin = 1;
} else if (STREQ (long_options[option_index].name, "echo-keys")) {
diff --git a/cat/log.c b/cat/log.c
index 0d8dab0..9e8a7bf 100644
--- a/cat/log.c
+++ b/cat/log.c
@@ -105,6 +105,7 @@ main (int argc, char *argv[])
{ "help", 0, 0, HELP_OPTION },
{ "keys-from-stdin", 0, 0, 0 },
{ "long-options", 0, 0, 0 },
+ { "short-options", 0, 0, 0 },
{ "verbose", 0, 0, 'v' },
{ "version", 0, 0, 'V' },
{ 0, 0, 0, 0 }
@@ -130,6 +131,8 @@ main (int argc, char *argv[])
case 0: /* options which are long only */
if (STREQ (long_options[option_index].name, "long-options"))
display_long_options (long_options);
+ else if (STREQ (long_options[option_index].name, "short-options"))
+ display_short_options (options);
else if (STREQ (long_options[option_index].name, "keys-from-stdin")) {
keys_from_stdin = 1;
} else if (STREQ (long_options[option_index].name, "echo-keys")) {
diff --git a/cat/ls.c b/cat/ls.c
index 2cb4e74..b979928 100644
--- a/cat/ls.c
+++ b/cat/ls.c
@@ -151,6 +151,7 @@ main (int argc, char *argv[])
{ "long-options", 0, 0, 0 },
{ "mount", 1, 0, 'm' },
{ "recursive", 0, 0, 'R' },
+ { "short-options", 0, 0, 0 },
{ "time", 0, 0, 0 },
{ "times", 0, 0, 0 },
{ "time-days", 0, 0, 0 },
@@ -190,6 +191,8 @@ main (int argc, char *argv[])
case 0: /* options which are long only */
if (STREQ (long_options[option_index].name, "long-options"))
display_long_options (long_options);
+ else if (STREQ (long_options[option_index].name, "short-options"))
+ display_short_options (options);
else if (STREQ (long_options[option_index].name, "keys-from-stdin")) {
keys_from_stdin = 1;
} else if (STREQ (long_options[option_index].name, "echo-keys")) {
diff --git a/customize/customize_main.ml b/customize/customize_main.ml
index 2830e8d..5bba71a 100644
--- a/customize/customize_main.ml
+++ b/customize/customize_main.ml
@@ -93,6 +93,7 @@ let main () =
"--dry-run", Arg.Set dryrun, " " ^ s_"Perform a dry run";
"--format", Arg.String set_format, s_"format" ^ " " ^ s_"Set format (default: auto)";
"--long-options", Arg.Unit display_long_options, " " ^ s_"List long options";
+ "--short-options", Arg.Unit display_short_options, " " ^ s_"List short options";
"-m", Arg.Int set_memsize, "mb" ^ " " ^ s_"Set memory size";
"--memsize", Arg.Int set_memsize, "mb" ^ " " ^ s_"Set memory size";
"--network", Arg.Set network, " " ^ s_"Enable appliance network (default)";
diff --git a/df/main.c b/df/main.c
index bddf2a9..09a58eb 100644
--- a/df/main.c
+++ b/df/main.c
@@ -115,6 +115,7 @@ main (int argc, char *argv[])
{ "inodes", 0, 0, 'i' },
{ "long-options", 0, 0, 0 },
{ "one-per-guest", 0, 0, 0 },
+ { "short-options", 0, 0, 0 },
{ "uuid", 0, 0, 0 },
{ "verbose", 0, 0, 'v' },
{ "version", 0, 0, 'V' },
@@ -143,6 +144,8 @@ main (int argc, char *argv[])
case 0: /* options which are long only */
if (STREQ (long_options[option_index].name, "long-options"))
display_long_options (long_options);
+ else if (STREQ (long_options[option_index].name, "short-options"))
+ display_short_options (options);
else if (STREQ (long_options[option_index].name, "format")) {
OPTION_format;
} else if (STREQ (long_options[option_index].name, "csv")) {
diff --git a/diff/diff.c b/diff/diff.c
index b113f29..8b0fda0 100644
--- a/diff/diff.c
+++ b/diff/diff.c
@@ -167,6 +167,7 @@ main (int argc, char *argv[])
{ "help", 0, 0, HELP_OPTION },
{ "human-readable", 0, 0, 'h' },
{ "keys-from-stdin", 0, 0, 0 },
+ { "short-options", 0, 0, 0 },
{ "time", 0, 0, 0 },
{ "times", 0, 0, 0 },
{ "time-days", 0, 0, 0 },
@@ -208,6 +209,8 @@ main (int argc, char *argv[])
case 0: /* options which are long only */
if (STREQ (long_options[option_index].name, "long-options"))
display_long_options (long_options);
+ else if (STREQ (long_options[option_index].name, "short-options"))
+ display_short_options (options);
else if (STREQ (long_options[option_index].name, "keys-from-stdin")) {
keys_from_stdin = 1;
} else if (STREQ (long_options[option_index].name, "echo-keys")) {
diff --git a/edit/edit.c b/edit/edit.c
index 20b2963..6281a2a 100644
--- a/edit/edit.c
+++ b/edit/edit.c
@@ -117,6 +117,7 @@ main (int argc, char *argv[])
{ "keys-from-stdin", 0, 0, 0 },
{ "long-options", 0, 0, 0 },
{ "mount", 1, 0, 'm' },
+ { "short-options", 0, 0, 0 },
{ "verbose", 0, 0, 'v' },
{ "version", 0, 0, 'V' },
{ 0, 0, 0, 0 }
@@ -145,6 +146,8 @@ main (int argc, char *argv[])
case 0: /* options which are long only */
if (STREQ (long_options[option_index].name, "long-options"))
display_long_options (long_options);
+ else if (STREQ (long_options[option_index].name, "short-options"))
+ display_short_options (options);
else if (STREQ (long_options[option_index].name, "keys-from-stdin")) {
keys_from_stdin = 1;
} else if (STREQ (long_options[option_index].name, "echo-keys")) {
diff --git a/fish/fish.c b/fish/fish.c
index 981a7d4..0432774 100644
--- a/fish/fish.c
+++ b/fish/fish.c
@@ -204,6 +204,7 @@ main (int argc, char *argv[])
{ "ro", 0, 0, 'r' },
{ "rw", 0, 0, 'w' },
{ "selinux", 0, 0, 0 },
+ { "short-options", 0, 0, 0 },
{ "verbose", 0, 0, 'v' },
{ "version", 0, 0, 'V' },
{ 0, 0, 0, 0 }
@@ -245,6 +246,8 @@ main (int argc, char *argv[])
case 0: /* options which are long only */
if (STREQ (long_options[option_index].name, "long-options"))
display_long_options (long_options);
+ else if (STREQ (long_options[option_index].name, "short-options"))
+ display_short_options (options);
else if (STREQ (long_options[option_index].name, "listen"))
remote_control_listen = 1;
else if (STREQ (long_options[option_index].name, "remote")) {
diff --git a/fish/options.c b/fish/options.c
index f7870a4..9ffcc6b 100644
--- a/fish/options.c
+++ b/fish/options.c
@@ -340,6 +340,20 @@ free_mps (struct mp *mp)
free (mp);
}
+/* Implements the internal 'tool --short-options' flag, which just
+ * lists out the short options available. Used by bash completion.
+ */
+void
+display_short_options (const char *format)
+{
+ while (*format) {
+ if (*format != ':')
+ printf ("-%c\n", *format);
+ ++format;
+ }
+ exit (EXIT_SUCCESS);
+}
+
/* Implements the internal 'tool --long-options' flag, which just
* lists out the long options available. Used by bash completion.
*/
@@ -347,7 +361,7 @@ void
display_long_options (const struct option *long_options)
{
while (long_options->name) {
- if (STRNEQ (long_options->name, "long-options"))
+ if (STRNEQ (long_options->name, "long-options") && STRNEQ (long_options->name, "short-options"))
printf ("--%s\n", long_options->name);
long_options++;
}
diff --git a/fish/options.h b/fish/options.h
index 2c568e6..cf68122 100644
--- a/fish/options.h
+++ b/fish/options.h
@@ -138,6 +138,7 @@ extern char add_drives_handle (guestfs_h *g, struct drv *drv, char next_drive);
extern void mount_mps (struct mp *mp);
extern void free_drives (struct drv *drv);
extern void free_mps (struct mp *mp);
+extern void display_short_options (const char *) __attribute__((noreturn));
extern void display_long_options (const struct option *) __attribute__((noreturn));
#define OPTION_a \
diff --git a/format/format.c b/format/format.c
index 1651f31..4e6069f 100644
--- a/format/format.c
+++ b/format/format.c
@@ -113,6 +113,7 @@ main (int argc, char *argv[])
{ "long-options", 0, 0, 0 },
{ "lvm", 2, 0, 0 },
{ "partition", 2, 0, 0 },
+ { "short-options", 0, 0, 0 },
{ "verbose", 0, 0, 'v' },
{ "version", 0, 0, 'V' },
{ "wipe", 0, 0, 0 },
@@ -139,6 +140,8 @@ main (int argc, char *argv[])
case 0: /* options which are long only */
if (STREQ (long_options[option_index].name, "long-options"))
display_long_options (long_options);
+ else if (STREQ (long_options[option_index].name, "short-options"))
+ display_short_options (options);
else if (STREQ (long_options[option_index].name, "format")) {
OPTION_format;
} else if (STREQ (long_options[option_index].name, "filesystem")) {
diff --git a/fuse/guestmount.c b/fuse/guestmount.c
index 519bba3..f952c47 100644
--- a/fuse/guestmount.c
+++ b/fuse/guestmount.c
@@ -173,6 +173,7 @@ main (int argc, char *argv[])
{ "ro", 0, 0, 'r' },
{ "rw", 0, 0, 'w' },
{ "selinux", 0, 0, 0 },
+ { "short-options", 0, 0, 0 },
{ "trace", 0, 0, 'x' },
{ "verbose", 0, 0, 'v' },
{ "version", 0, 0, 'V' },
@@ -220,6 +221,8 @@ main (int argc, char *argv[])
case 0: /* options which are long only */
if (STREQ (long_options[option_index].name, "long-options"))
display_long_options (long_options);
+ else if (STREQ (long_options[option_index].name, "short-options"))
+ display_short_options (options);
else if (STREQ (long_options[option_index].name, "dir-cache-timeout"))
dir_cache_timeout = atoi (optarg);
else if (STREQ (long_options[option_index].name, "fuse-help"))
diff --git a/inspector/inspector.c b/inspector/inspector.c
index 71795ce..5b99efa 100644
--- a/inspector/inspector.c
+++ b/inspector/inspector.c
@@ -111,6 +111,7 @@ main (int argc, char *argv[])
{ "help", 0, 0, HELP_OPTION },
{ "keys-from-stdin", 0, 0, 0 },
{ "long-options", 0, 0, 0 },
+ { "short-options", 0, 0, 0 },
{ "verbose", 0, 0, 'v' },
{ "version", 0, 0, 'V' },
{ "xpath", 1, 0, 0 },
@@ -137,6 +138,8 @@ main (int argc, char *argv[])
case 0: /* options which are long only */
if (STREQ (long_options[option_index].name, "long-options"))
display_long_options (long_options);
+ else if (STREQ (long_options[option_index].name, "short-options"))
+ display_short_options (options);
else if (STREQ (long_options[option_index].name, "keys-from-stdin")) {
keys_from_stdin = 1;
} else if (STREQ (long_options[option_index].name, "echo-keys")) {
diff --git a/make-fs/make-fs.c b/make-fs/make-fs.c
index 406aa1d..841c202 100644
--- a/make-fs/make-fs.c
+++ b/make-fs/make-fs.c
@@ -59,6 +59,7 @@ static const struct option long_options[] = {
{ "label", 1, 0, 0 },
{ "long-options", 0, 0, 0 },
{ "partition", 2, 0, 0 },
+ { "short-options", 0, 0, 0 },
{ "size", 1, 0, 's' },
{ "type", 1, 0, 't' },
{ "verbose", 0, 0, 'v' },
@@ -125,6 +126,9 @@ main (int argc, char *argv[])
if (STREQ (long_options[option_index].name, "long-options")) {
display_long_options (long_options);
}
+ else if (STREQ (long_options[option_index].name, "short-options")) {
+ display_short_options (options);
+ }
else if (STREQ (long_options[option_index].name, "floppy")) {
size_str = "1440K";
partition = "mbr";
diff --git a/mllib/common_utils.ml b/mllib/common_utils.ml
index 83ebd3a..89d8412 100644
--- a/mllib/common_utils.ml
+++ b/mllib/common_utils.ml
@@ -421,8 +421,15 @@ let skip_dashes str =
let compare_command_line_args a b =
compare (String.lowercase (skip_dashes a)) (String.lowercase (skip_dashes b))
-(* Implements `--long-options'. *)
+(* Implement `--short-options' and `--long-options'. *)
let long_options = ref ([] : (Arg.key * Arg.spec * Arg.doc) list)
+let display_short_options () =
+ List.iter (
+ fun (arg, _, _) ->
+ if string_prefix arg "-" && not (string_prefix arg "--") then
+ printf "%s\n" arg
+ ) !long_options;
+ exit 0
let display_long_options () =
List.iter (
fun (arg, _, _) ->
diff --git a/mllib/common_utils.mli b/mllib/common_utils.mli
index 112648a..bcdeecf 100644
--- a/mllib/common_utils.mli
+++ b/mllib/common_utils.mli
@@ -92,6 +92,8 @@ val compare_command_line_args : string -> string -> int
(** Compare command line arguments for equality, ignoring any leading [-]s. *)
val long_options : (Arg.key * Arg.spec * Arg.doc) list ref
+val display_short_options : unit -> 'a
+(** Implements [--short-options]. *)
val display_long_options : unit -> 'a
(** Implements [--long-options]. *)
diff --git a/p2v/main.c b/p2v/main.c
index a93ca1c..226f574 100644
--- a/p2v/main.c
+++ b/p2v/main.c
@@ -53,6 +53,7 @@ static const struct option long_options[] = {
{ "help", 0, 0, HELP_OPTION },
{ "cmdline", 1, 0, 0 },
{ "long-options", 0, 0, 0 },
+ { "short-options", 0, 0, 0 },
{ "verbose", 0, 0, 'v' },
{ "version", 0, 0, 'V' },
{ 0, 0, 0, 0 }
@@ -83,10 +84,21 @@ usage (int status)
/* XXX Copied from fish/options.c. */
static void
+display_short_options (const char *format)
+{
+ while (*format) {
+ if (*format != ':')
+ printf ("-%c\n", *format);
+ ++format;
+ }
+ exit (EXIT_SUCCESS);
+}
+
+static void
display_long_options (const struct option *long_options)
{
while (long_options->name) {
- if (STRNEQ (long_options->name, "long-options"))
+ if (STRNEQ (long_options->name, "long-options") && STRNEQ (long_options->name, "short-options"))
printf ("--%s\n", long_options->name);
long_options++;
}
@@ -119,6 +131,9 @@ main (int argc, char *argv[])
if (STREQ (long_options[option_index].name, "long-options")) {
display_long_options (long_options);
}
+ else if (STREQ (long_options[option_index].name, "short-options")) {
+ display_short_options (options);
+ }
else if (STREQ (long_options[option_index].name, "cmdline")) {
cmdline = strdup (optarg);
}
diff --git a/rescue/rescue.c b/rescue/rescue.c
index 00187a4..0295634 100644
--- a/rescue/rescue.c
+++ b/rescue/rescue.c
@@ -113,6 +113,7 @@ main (int argc, char *argv[])
{ "rw", 0, 0, 'w' },
{ "scratch", 2, 0, 0 },
{ "selinux", 0, 0, 0 },
+ { "short-options", 0, 0, 0 },
{ "smp", 1, 0, 0 },
{ "suggest", 0, 0, 0 },
{ "verbose", 0, 0, 'v' },
@@ -145,6 +146,8 @@ main (int argc, char *argv[])
case 0: /* options which are long only */
if (STREQ (long_options[option_index].name, "long-options"))
display_long_options (long_options);
+ else if (STREQ (long_options[option_index].name, "short-options"))
+ display_short_options (options);
else if (STREQ (long_options[option_index].name, "selinux")) {
if (guestfs_set_selinux (g, 1) == -1)
exit (EXIT_FAILURE);
diff --git a/resize/resize.ml b/resize/resize.ml
index f54b11f..363e2b6 100644
--- a/resize/resize.ml
+++ b/resize/resize.ml
@@ -194,6 +194,7 @@ let main () =
"--no-extra-partition", Arg.Clear extra_partition, " " ^ s_"Don't create extra partition";
"--format", Arg.Set_string format, s_"format" ^ " " ^ s_"Format of input disk";
"--ignore", Arg.String (add ignores), s_"part" ^ " " ^ s_"Ignore partition";
+ "--short-options", Arg.Unit display_short_options, " " ^ s_"List short options";
"--long-options", Arg.Unit display_long_options, " " ^ s_"List long options";
"--lv-expand", Arg.String (add lv_expands), s_"lv" ^ " " ^ s_"Expand logical volume";
"--LV-expand", Arg.String (add lv_expands), s_"lv" ^ ditto;
diff --git a/sparsify/cmdline.ml b/sparsify/cmdline.ml
index ec58dc1..88bab72 100644
--- a/sparsify/cmdline.ml
+++ b/sparsify/cmdline.ml
@@ -73,6 +73,7 @@ let parse_cmdline () =
"--ignore", Arg.String (add ignores), s_"fs" ^ " " ^ s_"Ignore filesystem";
"--in-place", Arg.Set in_place, " " ^ s_"Modify the disk image in-place";
"--inplace", Arg.Set in_place, ditto;
+ "--short-options", Arg.Unit display_short_options, " " ^ s_"List short options";
"--long-options", Arg.Unit display_long_options, " " ^ s_"List long options";
"--machine-readable", Arg.Set machine_readable, " " ^ s_"Make output machine readable";
"-o", Arg.Set_string option, s_"option" ^ " " ^ s_"Add qemu-img options";
diff --git a/sysprep/main.ml b/sysprep/main.ml
index 057f4cb..1fe3725 100644
--- a/sysprep/main.ml
+++ b/sysprep/main.ml
@@ -138,6 +138,7 @@ let main () =
"--enable", Arg.String set_enable, s_"operations" ^ " " ^ s_"Enable specific operations";
"--format", Arg.String set_format, s_"format" ^ " " ^ s_"Set format (default: auto)";
"--list-operations", Arg.Unit list_operations, " " ^ s_"List supported operations";
+ "--short-options", Arg.Unit display_short_options, " " ^ s_"List short options";
"--long-options", Arg.Unit display_long_options, " " ^ s_"List long options";
"--mount-options", Arg.Set_string mount_opts, s_"opts" ^ " " ^ s_"Set mount options (eg /:noatime;/var:rw,noatime)";
"--no-selinux-relabel", Arg.Unit (fun () -> ()),
diff --git a/v2v/cmdline.ml b/v2v/cmdline.ml
index 69a627f..85757e6 100644
--- a/v2v/cmdline.ml
+++ b/v2v/cmdline.ml
@@ -154,6 +154,7 @@ let parse_cmdline () =
"-ic", Arg.Set_string input_conn, "uri " ^ s_"Libvirt URI";
"-if", Arg.Set_string input_format,
"format " ^ s_"Input format (for -i disk)";
+ "--short-options", Arg.Unit display_short_options, " " ^ s_"List short options";
"--long-options", Arg.Unit display_long_options, " " ^ s_"List long options";
"--machine-readable", Arg.Set machine_readable, " " ^ s_"Make output machine readable";
"-n", Arg.String add_network, "in:out " ^ s_"Map network 'in' to 'out'";
--
1.9.3
9 years, 12 months
[PATCH 1/2] typo fix: preceeding -> preceding
by Hu Tao
Signed-off-by: Hu Tao <hutao(a)cn.fujitsu.com>
---
daemon/available.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/daemon/available.c b/daemon/available.c
index 7a8ede0..54c6b9b 100644
--- a/daemon/available.c
+++ b/daemon/available.c
@@ -166,7 +166,7 @@ do_filesystem_available (const char *filesystem)
r = filesystem_available (filesystem);
if (r == -1) {
reply_with_error ("error testing for filesystem availability; "
- "enable verbose mode and look at preceeding output");
+ "enable verbose mode and look at preceding output");
return -1;
}
--
1.9.3
9 years, 12 months
[PATCH 0/6] btrfs support part1: subvolume commands
by Hu Tao
Hi,
This is the part1 of improving btrfs support. This series adds missing
parameters to btrfs_subvolume_snapshot and btrfs_subvolume_create, and
adds two new API btrfs_subvolume_get_default and btrfs_subvolume_show.
Other parts will follow.
Regards,
Hu
Hu Tao (6):
btrfs: correct words about subvolume and snapshot
btrfs: add optional parameter `ro' to btrfs_subvolume_snapshot
btrfs: add optional parameter `qgroupid' to btrfs_subvolume_snapshot
btrfs: add optional parameter `qgroupid' to btrfs_subvolume_create
New API: btrfs_subvolume_get_default
New API: btrfs_subvolume_show
daemon/btrfs.c | 232 ++++++++++++++++++++++++++++++++++++++++++++++++++-
generator/actions.ml | 44 +++++++---
src/MAX_PROC_NR | 2 +-
3 files changed, 263 insertions(+), 15 deletions(-)
--
1.9.3
9 years, 12 months
[PATCH] Add tests for Arch Linux
by Nikos Skalkotos
Signed-off-by: Nikos Skalkotos <skalkoto(a)gmail.com>
---
.gitignore | 1 +
inspector/Makefile.am | 1 +
inspector/expected-archlinux.img.xml | 35 +++++++++++++++++
tests/guests/Makefile.am | 7 ++++
tests/guests/guest-aux/archlinux-package | 15 +++++++
tests/guests/guest-aux/make-archlinux-img.sh | 58 ++++++++++++++++++++++++++++
tests/guests/guests.xml.in | 16 ++++++++
7 files changed, 133 insertions(+)
create mode 100644 inspector/expected-archlinux.img.xml
create mode 100644 tests/guests/guest-aux/archlinux-package
create mode 100755 tests/guests/guest-aux/make-archlinux-img.sh
diff --git a/.gitignore b/.gitignore
index fa1cee4..b4a8ed1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -527,6 +527,7 @@ Makefile.in
/tests/guests/guest-aux/windows-system
/tests/guests/stamp-fedora-md.img
/tests/guests/ubuntu.img
+/tests/guests/archlinux.img
/tests/guests/windows.img
/tests/mount-local/test-parallel-mount-local
/tests/mountable/test-internal-parse-mountable
diff --git a/inspector/Makefile.am b/inspector/Makefile.am
index e1f5acd..d3538ad 100644
--- a/inspector/Makefile.am
+++ b/inspector/Makefile.am
@@ -37,6 +37,7 @@ EXTRA_DIST = \
expected-debian.img.xml \
expected-fedora.img.xml \
expected-ubuntu.img.xml \
+ expected-archlinux.img.xml \
expected-windows.img.xml \
test-virt-inspector.sh \
test-xmllint.sh.in \
diff --git a/inspector/expected-archlinux.img.xml b/inspector/expected-archlinux.img.xml
new file mode 100644
index 0000000..665ac30
--- /dev/null
+++ b/inspector/expected-archlinux.img.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0"?>
+<operatingsystems>
+ <operatingsystem>
+ <root>/dev/sda1</root>
+ <name>linux</name>
+ <arch>x86_64</arch>
+ <distro>archlinux</distro>
+ <major_version>0</major_version>
+ <minor_version>0</minor_version>
+ <package_format>pacman</package_format>
+ <package_management>pacman</package_management>
+ <hostname>archlinux.test</hostname>
+ <format>installed</format>
+ <mountpoints>
+ <mountpoint dev="/dev/sda1">/</mountpoint>
+ </mountpoints>
+ <filesystems>
+ <filesystem dev="/dev/sda1">
+ <type>ext4</type>
+ <uuid>01234567-0123-0123-0123-012345678902</uuid>
+ </filesystem>
+ </filesystems>
+ <applications>
+ <application>
+ <name>test-package</name>
+ <epoch>1</epoch>
+ <version>0.1</version>
+ <release>1</release>
+ <arch>x86_64</arch>
+ <url>http://libguestfs.org/</url>
+ <description>Test package for libguestfs</description>
+ </application>
+ </applications>
+ </operatingsystem>
+</operatingsystems>
diff --git a/tests/guests/Makefile.am b/tests/guests/Makefile.am
index e58d563..2bb721d 100644
--- a/tests/guests/Makefile.am
+++ b/tests/guests/Makefile.am
@@ -28,6 +28,8 @@ EXTRA_DIST = \
guest-aux/fedora-packages.db.txt \
guest-aux/fedora-packages.db \
guest-aux/make-ubuntu-img.sh \
+ guest-aux/make-archlinux-img.sh \
+ guest-aux/archlinux-package \
guest-aux/make-windows-img.sh \
guest-aux/windows-software \
guest-aux/windows-software.reg \
@@ -49,6 +51,7 @@ disk_images = \
fedora-md2.img \
fedora-btrfs.img \
ubuntu.img \
+ archlinux.img \
windows.img
# This is 'check_DATA' because we don't need it until 'make check'
@@ -102,6 +105,10 @@ debian.img: guest-aux/make-debian-img.sh
ubuntu.img: guest-aux/make-ubuntu-img.sh
SRCDIR=$(srcdir) $(top_builddir)/run --test $<
+# Make a (dummy) Arch Linux image.
+archlinux.img: guest-aux/make-archlinux-img.sh
+ SRCDIR=$(srcdir) $(top_builddir)/run --test $<
+
# Make a (dummy) Windows image.
windows.img: guest-aux/make-windows-img.sh \
guest-aux/windows-software guest-aux/windows-system
diff --git a/tests/guests/guest-aux/archlinux-package b/tests/guests/guest-aux/archlinux-package
new file mode 100644
index 0000000..96459a2
--- /dev/null
+++ b/tests/guests/guest-aux/archlinux-package
@@ -0,0 +1,15 @@
+%NAME%
+test-package
+
+%VERSION%
+1:0.1-1
+
+%DESC%
+Test package for libguestfs
+
+%URL%
+http://libguestfs.org/
+
+%ARCH%
+x86_64
+
diff --git a/tests/guests/guest-aux/make-archlinux-img.sh b/tests/guests/guest-aux/make-archlinux-img.sh
new file mode 100755
index 0000000..62babd1
--- /dev/null
+++ b/tests/guests/guest-aux/make-archlinux-img.sh
@@ -0,0 +1,58 @@
+#!/bin/bash -
+# libguestfs
+# Copyright (C) 2014 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.
+
+# Make an Arch Linux image which is enough to fool the inspection heuristics.
+
+export LANG=C
+set -e
+
+# Create a disk image.
+guestfish <<EOF
+sparse archlinux.img.tmp.$$ 512M
+run
+
+# Format the disk.
+part-init /dev/sda mbr
+part-add /dev/sda p 64 -64
+
+# Phony / filesystem.
+mkfs ext4 /dev/sda1 blocksize:4096
+set-e2uuid /dev/sda1 01234567-0123-0123-0123-012345678902
+
+# Enough to fool inspection API.
+mount /dev/sda1 /
+mkdir /boot
+mkdir /bin
+mkdir /etc
+mkdir /home
+mkdir /usr
+mkdir-p /var/lib/pacman/local/test-package-1:0.1-1
+
+write /etc/fstab "/dev/sda1 / ext4 rw,relatime,data=ordered 0 1"
+touch /etc/arch-release
+write /etc/hostname "archlinux.test"
+
+upload $SRCDIR/guest-aux/archlinux-package /var/lib/pacman/local/test-package-1:0.1-1/desc
+
+upload $SRCDIR/../data/bin-x86_64-dynamic /bin/ls
+
+mkdir /boot/grub
+touch /boot/grub/grub.conf
+EOF
+
+mv archlinux.img.tmp.$$ archlinux.img
diff --git a/tests/guests/guests.xml.in b/tests/guests/guests.xml.in
index bac5d8e..451d3fa 100644
--- a/tests/guests/guests.xml.in
+++ b/tests/guests/guests.xml.in
@@ -232,6 +232,22 @@
</domain>
<domain type='test'>
+ <name>archlinux</name>
+ <memory>1048576</memory>
+ <os>
+ <type>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <devices>
+ <disk type='file' device='disk'>
+ <driver name='qemu' type='raw'/>
+ <source file='@abs_builddir(a)/archlinux.img'/>
+ <target dev='vda' bus='virtio'/>
+ </disk>
+ </devices>
+ </domain>
+
+ <domain type='test'>
<name>windows</name>
<memory>1048576</memory>
<os>
--
2.1.3
9 years, 12 months
[PATCH] mllib: use Unix.isatty
by Pino Toscano
Make use of Unix.isatty instead of our TTY.isatty_stdout, as the
supported OCaml provides the former already.
---
mllib/common_utils.ml | 10 +++++-----
mllib/progress.ml | 2 +-
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/mllib/common_utils.ml b/mllib/common_utils.ml
index 295981c..9fcd8dd 100644
--- a/mllib/common_utils.ml
+++ b/mllib/common_utils.ml
@@ -207,15 +207,15 @@ let rec combine3 xs ys zs =
(* ANSI terminal colours. *)
let ansi_green ?(chan = stdout) () =
- if TTY.isatty_stdout () then output_string chan "\x1b[0;32m"
+ if Unix.isatty Unix.stdout then output_string chan "\x1b[0;32m"
let ansi_red ?(chan = stdout) () =
- if TTY.isatty_stdout () then output_string chan "\x1b[1;31m"
+ if Unix.isatty Unix.stdout then output_string chan "\x1b[1;31m"
let ansi_blue ?(chan = stdout) () =
- if TTY.isatty_stdout () then output_string chan "\x1b[1;34m"
+ if Unix.isatty Unix.stdout then output_string chan "\x1b[1;34m"
let ansi_magenta ?(chan = stdout) () =
- if TTY.isatty_stdout () then output_string chan "\x1b[1;35m"
+ if Unix.isatty Unix.stdout then output_string chan "\x1b[1;35m"
let ansi_restore ?(chan = stdout) () =
- if TTY.isatty_stdout () then output_string chan "\x1b[0m"
+ if Unix.isatty Unix.stdout then output_string chan "\x1b[0m"
(* Timestamped progress messages, used for ordinary messages when not
* --quiet.
diff --git a/mllib/progress.ml b/mllib/progress.ml
index 194120e..8cf5875 100644
--- a/mllib/progress.ml
+++ b/mllib/progress.ml
@@ -33,7 +33,7 @@ let set_up_progress_bar ?(machine_readable = false) (g : Guestfs.guestfs) =
(* Only display progress bars if the machine_readable flag is set or
* the output is a tty.
*)
- if machine_readable || TTY.isatty_stdout () then (
+ if machine_readable || Unix.isatty Unix.stdout then (
(* Initialize the C mini library. *)
let bar = progress_bar_init ~machine_readable in
--
1.9.3
9 years, 12 months
[PATCH] generator: force longdesc to begin with uppercase
by Hu Tao
As contrast to shortdesc which is forced to begin with lowercase, this
patch forces longdesc to begin with uppercase.
Signed-off-by: Hu Tao <hutao(a)cn.fujitsu.com>
---
generator/checks.ml | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/generator/checks.ml b/generator/checks.ml
index b57134b..376de3b 100644
--- a/generator/checks.ml
+++ b/generator/checks.ml
@@ -157,7 +157,9 @@ let () =
List.iter (
fun { name = name; longdesc = longdesc } ->
if longdesc.[String.length longdesc-1] = '\n' then
- failwithf "long description of %s should not end with \\n." name
+ failwithf "long description of %s should not end with \\n." name;
+ if longdesc.[0] <> Char.uppercase longdesc.[0] then
+ failwithf "long description of %s should begin with uppercase." name
) (all_functions @ fish_commands);
(* Check proc_nrs. *)
--
1.9.3
9 years, 12 months
[PATCH] v2v: -i ova: Remove incorrect warning for disks that have no parent controller (RHBZ#1167302).
by Richard W.M. Jones
Don't assume every disk <Item> has a <Parent> field. For floppy disks
this is not the case.
Thanks: Junqin Zhou
---
v2v/input_ova.ml | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/v2v/input_ova.ml b/v2v/input_ova.ml
index 95af2e5..9a9c10a 100644
--- a/v2v/input_ova.ml
+++ b/v2v/input_ova.ml
@@ -187,14 +187,17 @@ object
for i = 0 to nr_nodes-1 do
let n = Xml.xpathobj_node doc obj i in
Xml.xpathctx_set_current_context xpathctx n;
- let parent_id = xpath_to_int "rasd:Parent/text()" 0 in
(* XXX We assume the OVF lists these in order.
let address = xpath_to_int "rasd:AddressOnParent/text()" 0 in
*)
(* Find the parent controller. *)
- let controller = parent_controller parent_id in
+ let parent_id = xpath_to_int "rasd:Parent/text()" 0 in
+ let controller =
+ match parent_id with
+ | 0 -> None
+ | id -> parent_controller id in
Xml.xpathctx_set_current_context xpathctx n;
let file_id = xpath_to_string "rasd:HostResource/text()" "" in
@@ -255,14 +258,17 @@ object
Xml.xpathctx_set_current_context xpathctx n;
let id = xpath_to_int "rasd:ResourceType/text()" 0 in
assert (id = 14 || id = 15 || id = 16);
- let parent_id = xpath_to_int "rasd:Parent/text()" 0 in
(* XXX We assume the OVF lists these in order.
let address = xpath_to_int "rasd:AddressOnParent/text()" 0 in
*)
(* Find the parent controller. *)
- let controller = parent_controller parent_id in
+ let parent_id = xpath_to_int "rasd:Parent/text()" 0 in
+ let controller =
+ match parent_id with
+ | 0 -> None
+ | id -> parent_controller id in
let typ =
match id with
--
2.1.0
9 years, 12 months
[PATCH] rpm: use librpm's rpmvercmp
by Pino Toscano
Bind and use rpmvercmp to compare versions of packages when sorting
them, instead of an own string-based comparison function.
---
src/librpm-c.c | 12 ++++++++++++
src/librpm.ml | 1 +
src/librpm.mli | 1 +
src/rpm.ml | 2 +-
4 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/src/librpm-c.c b/src/librpm-c.c
index 1ae3bad..fc847d6 100644
--- a/src/librpm-c.c
+++ b/src/librpm-c.c
@@ -122,6 +122,12 @@ supermin_rpm_version (value unit)
}
value
+supermin_rpm_vercmp (value av, value bv)
+{
+ return Val_int (rpmvercmp (String_val (av), String_val (bv)));
+}
+
+value
supermin_rpm_open (value debugv)
{
CAMLparam1 (debugv);
@@ -445,6 +451,12 @@ supermin_rpm_version (value unit)
}
value
+supermin_rpm_vercmp (value av, value bv)
+{
+ abort ();
+}
+
+value
supermin_rpm_open (value debugv)
{
abort ();
diff --git a/src/librpm.ml b/src/librpm.ml
index aa8d367..8c30248 100644
--- a/src/librpm.ml
+++ b/src/librpm.ml
@@ -19,6 +19,7 @@
external rpm_is_available : unit -> bool = "supermin_rpm_is_available"
external rpm_version : unit -> string = "supermin_rpm_version"
+external rpm_vercmp : string -> string -> int = "supermin_rpm_vercmp"
type t
diff --git a/src/librpm.mli b/src/librpm.mli
index 880a038..da73911 100644
--- a/src/librpm.mli
+++ b/src/librpm.mli
@@ -19,6 +19,7 @@
val rpm_is_available : unit -> bool
val rpm_version : unit -> string
+val rpm_vercmp : string -> string -> int
type t
diff --git a/src/rpm.ml b/src/rpm.ml
index 640a02a..ce803e1 100644
--- a/src/rpm.ml
+++ b/src/rpm.ml
@@ -144,7 +144,7 @@ let rpm_package_of_string str =
* architecture.
*)
let cmp { version = v1; arch = a1 } { version = v2; arch = a2 } =
- let i = compare_version v2 v1 in
+ let i = rpm_vercmp v2 v1 in
if i <> 0 then i
else compare_architecture a2 a1
in
--
1.9.3
9 years, 12 months