Blame SOURCES/kvm-qapi-new-qmp-command-nbd-server-add-bitmap.patch

1bdc94
From 9949f65ad44a273fabbf98591ef98b4742e6882f Mon Sep 17 00:00:00 2001
1bdc94
From: John Snow <jsnow@redhat.com>
1bdc94
Date: Wed, 18 Jul 2018 22:55:04 +0200
1bdc94
Subject: [PATCH 79/89] qapi: new qmp command nbd-server-add-bitmap
1bdc94
1bdc94
RH-Author: John Snow <jsnow@redhat.com>
1bdc94
Message-id: <20180718225511.14878-29-jsnow@redhat.com>
1bdc94
Patchwork-id: 81408
1bdc94
O-Subject: [RHEL-7.6 qemu-kvm-rhev PATCH 28/35] qapi: new qmp command nbd-server-add-bitmap
1bdc94
Bugzilla: 1207657
1bdc94
RH-Acked-by: Eric Blake <eblake@redhat.com>
1bdc94
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
1bdc94
RH-Acked-by: Fam Zheng <famz@redhat.com>
1bdc94
1bdc94
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
1bdc94
1bdc94
For now, the actual command ix x-nbd-server-add-bitmap, reflecting
1bdc94
the fact that we are still working on libvirt code that proves the
1bdc94
command works as needed, and also the fact that we may remove
1bdc94
bitmap-export-name (and just require that the exported name be the
1bdc94
bitmap name).
1bdc94
1bdc94
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
1bdc94
Message-Id: <20180609151758.17343-6-vsementsov@virtuozzo.com>
1bdc94
Reviewed-by: Eric Blake <eblake@redhat.com>
1bdc94
[eblake: make the command experimental by adding x- prefix]
1bdc94
Signed-off-by: Eric Blake <eblake@redhat.com>
1bdc94
(cherry picked from commit 767f0c7d6cddedbc97ad700bd1e0229cc2ce5eb5)
1bdc94
Signed-off-by: John Snow <jsnow@redhat.com>
1bdc94
1bdc94
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
1bdc94
---
1bdc94
 blockdev-nbd.c  | 23 +++++++++++++++++++++++
1bdc94
 qapi/block.json | 23 +++++++++++++++++++++++
1bdc94
 2 files changed, 46 insertions(+)
1bdc94
1bdc94
diff --git a/blockdev-nbd.c b/blockdev-nbd.c
1bdc94
index 65a8473..1ef1104 100644
1bdc94
--- a/blockdev-nbd.c
1bdc94
+++ b/blockdev-nbd.c
1bdc94
@@ -220,3 +220,26 @@ void qmp_nbd_server_stop(Error **errp)
1bdc94
     nbd_server_free(nbd_server);
1bdc94
     nbd_server = NULL;
1bdc94
 }
1bdc94
+
1bdc94
+void qmp_x_nbd_server_add_bitmap(const char *name, const char *bitmap,
1bdc94
+                                 bool has_bitmap_export_name,
1bdc94
+                                 const char *bitmap_export_name,
1bdc94
+                                 Error **errp)
1bdc94
+{
1bdc94
+    NBDExport *exp;
1bdc94
+
1bdc94
+    if (!nbd_server) {
1bdc94
+        error_setg(errp, "NBD server not running");
1bdc94
+        return;
1bdc94
+    }
1bdc94
+
1bdc94
+    exp = nbd_export_find(name);
1bdc94
+    if (exp == NULL) {
1bdc94
+        error_setg(errp, "Export '%s' is not found", name);
1bdc94
+        return;
1bdc94
+    }
1bdc94
+
1bdc94
+    nbd_export_bitmap(exp, bitmap,
1bdc94
+                      has_bitmap_export_name ? bitmap_export_name : bitmap,
1bdc94
+                      errp);
1bdc94
+}
1bdc94
diff --git a/qapi/block.json b/qapi/block.json
1bdc94
index f05b91a..ba85ceb 100644
1bdc94
--- a/qapi/block.json
1bdc94
+++ b/qapi/block.json
1bdc94
@@ -364,6 +364,29 @@
1bdc94
   'data': {'name': 'str', '*mode': 'NbdServerRemoveMode'} }
1bdc94
 
1bdc94
 ##
1bdc94
+# @x-nbd-server-add-bitmap:
1bdc94
+#
1bdc94
+# Expose a dirty bitmap associated with the selected export. The bitmap search
1bdc94
+# starts at the device attached to the export, and includes all backing files.
1bdc94
+# The exported bitmap is then locked until the NBD export is removed.
1bdc94
+#
1bdc94
+# @name: Export name.
1bdc94
+#
1bdc94
+# @bitmap: Bitmap name to search for.
1bdc94
+#
1bdc94
+# @bitmap-export-name: How the bitmap will be seen by nbd clients
1bdc94
+#                      (default @bitmap)
1bdc94
+#
1bdc94
+# Note: the client must use NBD_OPT_SET_META_CONTEXT with a query of
1bdc94
+# "qemu:dirty-bitmap:NAME" (where NAME matches @bitmap-export-name) to access
1bdc94
+# the exposed bitmap.
1bdc94
+#
1bdc94
+# Since: 3.0
1bdc94
+##
1bdc94
+  { 'command': 'x-nbd-server-add-bitmap',
1bdc94
+    'data': {'name': 'str', 'bitmap': 'str', '*bitmap-export-name': 'str'} }
1bdc94
+
1bdc94
+##
1bdc94
 # @nbd-server-stop:
1bdc94
 #
1bdc94
 # Stop QEMU's embedded NBD server, and unregister all devices previously
1bdc94
-- 
1bdc94
1.8.3.1
1bdc94