[Libguestfs] [PATCH nbdkit 6/6] xz: Make the file= parameter into a magic config key.

Richard W.M. Jones rjones at redhat.com
Fri Sep 7 11:51:09 UTC 2018


---
 docs/nbdkit.pod                   | 8 ++++----
 filters/cow/nbdkit-cow-filter.pod | 2 +-
 plugins/xz/nbdkit-xz-plugin.pod   | 3 +++
 plugins/xz/xz.c                   | 3 ++-
 tests/test-xz.c                   | 2 +-
 5 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/docs/nbdkit.pod b/docs/nbdkit.pod
index 4f72502..da9d749 100644
--- a/docs/nbdkit.pod
+++ b/docs/nbdkit.pod
@@ -75,7 +75,7 @@ Serve only the first partition from compressed disk image
 F<disk.img.xz>, combining L<nbdkit-xz-plugin(1)> and
 L<nbdkit-partition-filter(1)>:
 
- nbdkit --filter=partition  xz file=disk.img.xz  partition=1
+ nbdkit --filter=partition  xz disk.img.xz  partition=1
 
 To understand this command line:
 
@@ -83,9 +83,9 @@ To understand this command line:
                                   │
                             ┌─────┴────┐
                             │          │
- nbdkit --filter=partition  xz file=disk.img.xz  partition=1
-                │                                   │
-                └───────────────┬───────────────────┘
+ nbdkit --filter=partition  xz disk.img.xz  partition=1
+                  │                               │
+                  └─────────────┬─────────────────┘
                                 │
                 filter name and filter parameter
 
diff --git a/filters/cow/nbdkit-cow-filter.pod b/filters/cow/nbdkit-cow-filter.pod
index 80100e7..d5cd735 100644
--- a/filters/cow/nbdkit-cow-filter.pod
+++ b/filters/cow/nbdkit-cow-filter.pod
@@ -65,7 +65,7 @@ L<nbdkit-xz-plugin(1)> only supports read access, but you can provide
 temporary write access by doing (although this does B<not> save
 changes to the file):
 
- nbdkit --filter=cow xz file=disk.xz
+ nbdkit --filter=cow xz disk.xz
 
 =head1 CREATING A DIFF WITH QEMU-IMG
 
diff --git a/plugins/xz/nbdkit-xz-plugin.pod b/plugins/xz/nbdkit-xz-plugin.pod
index 2c9ab6e..42ba426 100644
--- a/plugins/xz/nbdkit-xz-plugin.pod
+++ b/plugins/xz/nbdkit-xz-plugin.pod
@@ -59,6 +59,9 @@ Serve the file named C<FILENAME.xz>.
 
 This parameter is required.
 
+In nbdkit E<ge> 1.7, C<file=> may be omitted if the filename does not
+start with a C<-> or contain an C<=> character.
+
 =item B<maxblock=>SIZE
 
 The maximum block size that the plugin will read.  The plugin will
diff --git a/plugins/xz/xz.c b/plugins/xz/xz.c
index f45e489..a88d713 100644
--- a/plugins/xz/xz.c
+++ b/plugins/xz/xz.c
@@ -1,5 +1,5 @@
 /* nbdkit
- * Copyright (C) 2013 Red Hat Inc.
+ * Copyright (C) 2013-2018 Red Hat Inc.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -250,6 +250,7 @@ static struct nbdkit_plugin plugin = {
   .config            = xz_config,
   .config_complete   = xz_config_complete,
   .config_help       = xz_config_help,
+  .magic_config_key  = "file",
   .open              = xz_open,
   .close             = xz_close,
   .get_size          = xz_get_size,
diff --git a/tests/test-xz.c b/tests/test-xz.c
index ef58d59..46b1d04 100644
--- a/tests/test-xz.c
+++ b/tests/test-xz.c
@@ -51,7 +51,7 @@ main (int argc, char *argv[])
   int r;
   char *data;
 
-  if (test_start_nbdkit ("xz", "-r", "file=disk.xz", NULL) == -1)
+  if (test_start_nbdkit ("xz", "-r", "disk.xz", NULL) == -1)
     exit (EXIT_FAILURE);
 
   g = guestfs_create ();
-- 
2.18.0




More information about the Libguestfs mailing list