[Libguestfs] [nbdkit PATCH] gzip/xz: Advertise multi-conn

Eric Blake eblake at redhat.com
Fri Feb 19 22:06:02 UTC 2021


Since we aren't modifying the data when decompressing, we are
inherently consistent between connections.
---
 filters/gzip/gzip.c | 11 ++++++++++-
 filters/xz/xz.c     | 11 ++++++++++-
 2 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/filters/gzip/gzip.c b/filters/gzip/gzip.c
index 20b533b9..03e023e5 100644
--- a/filters/gzip/gzip.c
+++ b/filters/gzip/gzip.c
@@ -1,5 +1,5 @@
 /* nbdkit
- * Copyright (C) 2018-2020 Red Hat Inc.
+ * Copyright (C) 2018-2021 Red Hat Inc.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
@@ -266,6 +266,14 @@ gzip_can_write (struct nbdkit_next_ops *next_ops, void *nxdata,
   return 0;
 }

+/* Whatever the plugin says, this filter is consistent across connections. */
+static int
+gzip_can_multi_conn (struct nbdkit_next_ops *next_ops, void *nxdata,
+                     void *handle)
+{
+  return 1;
+}
+
 /* Similar to above, whatever the plugin says, extents are not
  * supported.
  */
@@ -360,6 +368,7 @@ static struct nbdkit_filter filter = {
   .can_write          = gzip_can_write,
   .can_extents        = gzip_can_extents,
   .can_cache          = gzip_can_cache,
+  .can_multi_conn     = gzip_can_multi_conn,
   .prepare            = gzip_prepare,
   .export_description = gzip_export_description,
   .get_size           = gzip_get_size,
diff --git a/filters/xz/xz.c b/filters/xz/xz.c
index 72801536..63adb37e 100644
--- a/filters/xz/xz.c
+++ b/filters/xz/xz.c
@@ -1,5 +1,5 @@
 /* nbdkit
- * Copyright (C) 2013-2020 Red Hat Inc.
+ * Copyright (C) 2013-2021 Red Hat Inc.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
@@ -190,6 +190,14 @@ xz_can_write (struct nbdkit_next_ops *next_ops, void *nxdata,
   return 0;
 }

+/* Whatever the plugin says, this filter is consistent across connections. */
+static int
+xz_can_multi_conn (struct nbdkit_next_ops *next_ops, void *nxdata,
+                   void *handle)
+{
+  return 1;
+}
+
 /* Similar to above.  However xz files themselves do support
  * sparseness so in future we should generate extents information. XXX
  */
@@ -271,6 +279,7 @@ static struct nbdkit_filter filter = {
   .can_write          = xz_can_write,
   .can_extents        = xz_can_extents,
   .can_cache          = xz_can_cache,
+  .can_multi_conn     = xz_can_multi_conn,
   .pread              = xz_pread,
 };

-- 
2.30.1




More information about the Libguestfs mailing list