Blame SOURCES/kvm-block-dirty-bitmap-add-recording-and-busy-properties.patch

7711c0
From baab9fd178c51f5712acef9a54cd2848903f90e9 Mon Sep 17 00:00:00 2001
7711c0
From: John Snow <jsnow@redhat.com>
7711c0
Date: Wed, 3 Apr 2019 18:18:39 +0200
7711c0
Subject: [PATCH 134/163] block/dirty-bitmap: add recording and busy properties
7711c0
7711c0
RH-Author: John Snow <jsnow@redhat.com>
7711c0
Message-id: <20190403181857.9693-4-jsnow@redhat.com>
7711c0
Patchwork-id: 85412
7711c0
O-Subject: [RHEL-7.7 qemu-kvm-rhev PATCH 03/21] block/dirty-bitmap: add recording and busy properties
7711c0
Bugzilla: 1677073
7711c0
RH-Acked-by: Max Reitz <mreitz@redhat.com>
7711c0
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
7711c0
RH-Acked-by: Sergio Lopez Pascual <slp@redhat.com>
7711c0
7711c0
The current API allows us to report a single status, which we've defined as:
7711c0
7711c0
Frozen: has a successor, treated as qmp_locked, may or may not be enabled.
7711c0
Locked: no successor, qmp_locked. may or may not be enabled.
7711c0
Disabled: Not frozen or locked, disabled.
7711c0
Active: Not frozen, locked, or disabled.
7711c0
7711c0
The problem is that both "Frozen" and "Locked" mean nearly the same thing,
7711c0
and that both of them do not intuit whether they are recording guest writes
7711c0
or not.
7711c0
7711c0
This patch deprecates that status field and introduces two orthogonal
7711c0
properties instead to replace it.
7711c0
7711c0
Signed-off-by: John Snow <jsnow@redhat.com>
7711c0
Reviewed-by: Eric Blake <eblake@redhat.com>
7711c0
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
7711c0
Message-id: 20190223000614.13894-2-jsnow@redhat.com
7711c0
Signed-off-by: John Snow <jsnow@redhat.com>
7711c0
(cherry picked from commit 4db6ceb0b594e179fcbd46a351b8cebaa840bf0d)
7711c0
Signed-off-by: John Snow <jsnow@redhat.com>
7711c0
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
7711c0
---
7711c0
 block/dirty-bitmap.c       |  9 +++++++++
7711c0
 qapi/block-core.json       | 10 +++++++++-
7711c0
 qemu-doc.texi              |  6 ++++++
7711c0
 tests/qemu-iotests/236.out | 28 ++++++++++++++++++++++++++++
7711c0
 4 files changed, 52 insertions(+), 1 deletion(-)
7711c0
7711c0
diff --git a/block/dirty-bitmap.c b/block/dirty-bitmap.c
7711c0
index c6d4ace..101383b 100644
7711c0
--- a/block/dirty-bitmap.c
7711c0
+++ b/block/dirty-bitmap.c
7711c0
@@ -226,6 +226,13 @@ DirtyBitmapStatus bdrv_dirty_bitmap_status(BdrvDirtyBitmap *bitmap)
7711c0
     }
7711c0
 }
7711c0
 
7711c0
+/* Called with BQL taken.  */
7711c0
+static bool bdrv_dirty_bitmap_recording(BdrvDirtyBitmap *bitmap)
7711c0
+{
7711c0
+    return !bitmap->disabled || (bitmap->successor &&
7711c0
+                                 !bitmap->successor->disabled);
7711c0
+}
7711c0
+
7711c0
 /**
7711c0
  * Create a successor bitmap destined to replace this bitmap after an operation.
7711c0
  * Requires that the bitmap is not frozen and has no successor.
7711c0
@@ -448,6 +455,8 @@ BlockDirtyInfoList *bdrv_query_dirty_bitmaps(BlockDriverState *bs)
7711c0
         info->has_name = !!bm->name;
7711c0
         info->name = g_strdup(bm->name);
7711c0
         info->status = bdrv_dirty_bitmap_status(bm);
7711c0
+        info->recording = bdrv_dirty_bitmap_recording(bm);
7711c0
+        info->busy = bdrv_dirty_bitmap_user_locked(bm);
7711c0
         info->persistent = bm->persistent;
7711c0
         entry->value = info;
7711c0
         *plist = entry;
7711c0
diff --git a/qapi/block-core.json b/qapi/block-core.json
7711c0
index 5fe7897..98bd3a8 100644
7711c0
--- a/qapi/block-core.json
7711c0
+++ b/qapi/block-core.json
7711c0
@@ -459,7 +459,14 @@
7711c0
 #
7711c0
 # @granularity: granularity of the dirty bitmap in bytes (since 1.4)
7711c0
 #
7711c0
-# @status: current status of the dirty bitmap (since 2.4)
7711c0
+# @status: Deprecated in favor of @recording and @locked. (since 2.4)
7711c0
+#
7711c0
+# @recording: true if the bitmap is recording new writes from the guest.
7711c0
+#             Replaces `active` and `disabled` statuses. (since 4.0)
7711c0
+#
7711c0
+# @busy: true if the bitmap is in-use by some operation (NBD or jobs)
7711c0
+#        and cannot be modified via QMP or used by another operation.
7711c0
+#        Replaces `locked` and `frozen` statuses. (since 4.0)
7711c0
 #
7711c0
 # @persistent: true if the bitmap will eventually be flushed to persistent
7711c0
 #              storage (since 4.0)
7711c0
@@ -468,6 +475,7 @@
7711c0
 ##
7711c0
 { 'struct': 'BlockDirtyInfo',
7711c0
   'data': {'*name': 'str', 'count': 'int', 'granularity': 'uint32',
7711c0
+           'recording': 'bool', 'busy': 'bool',
7711c0
            'status': 'DirtyBitmapStatus', 'persistent': 'bool' } }
7711c0
 
7711c0
 ##
7711c0
diff --git a/qemu-doc.texi b/qemu-doc.texi
7711c0
index 2acbec5..d5060dd 100644
7711c0
--- a/qemu-doc.texi
7711c0
+++ b/qemu-doc.texi
7711c0
@@ -2951,6 +2951,12 @@ for these file types is 'host_cdrom' or 'host_device' as appropriate.
7711c0
 "autoload" parameter is now ignored. All bitmaps are automatically loaded
7711c0
 from qcow2 images.
7711c0
 
7711c0
+@subsection query-block result field dirty-bitmaps[i].status (since 4.0)
7711c0
+
7711c0
+The ``status'' field of the ``BlockDirtyInfo'' structure, returned by
7711c0
+the query-block command is deprecated. Two new boolean fields,
7711c0
+``recording'' and ``busy'' effectively replace it.
7711c0
+
7711c0
 @subsection query-cpus (since 2.12.0)
7711c0
 
7711c0
 The ``query-cpus'' command is replaced by the ``query-cpus-fast'' command.
7711c0
diff --git a/tests/qemu-iotests/236.out b/tests/qemu-iotests/236.out
7711c0
index 5006f7b..815cd05 100644
7711c0
--- a/tests/qemu-iotests/236.out
7711c0
+++ b/tests/qemu-iotests/236.out
7711c0
@@ -22,17 +22,21 @@ write -P0xcd 0x3ff0000 64k
7711c0
   "bitmaps": {
7711c0
     "drive0": [
7711c0
       {
7711c0
+        "busy": false,
7711c0
         "count": 262144,
7711c0
         "granularity": 65536,
7711c0
         "name": "bitmapB",
7711c0
         "persistent": false,
7711c0
+        "recording": true,
7711c0
         "status": "active"
7711c0
       },
7711c0
       {
7711c0
+        "busy": false,
7711c0
         "count": 262144,
7711c0
         "granularity": 65536,
7711c0
         "name": "bitmapA",
7711c0
         "persistent": false,
7711c0
+        "recording": true,
7711c0
         "status": "active"
7711c0
       }
7711c0
     ]
7711c0
@@ -84,17 +88,21 @@ write -P0xcd 0x3ff0000 64k
7711c0
   "bitmaps": {
7711c0
     "drive0": [
7711c0
       {
7711c0
+        "busy": false,
7711c0
         "count": 262144,
7711c0
         "granularity": 65536,
7711c0
         "name": "bitmapB",
7711c0
         "persistent": false,
7711c0
+        "recording": true,
7711c0
         "status": "active"
7711c0
       },
7711c0
       {
7711c0
+        "busy": false,
7711c0
         "count": 262144,
7711c0
         "granularity": 65536,
7711c0
         "name": "bitmapA",
7711c0
         "persistent": false,
7711c0
+        "recording": true,
7711c0
         "status": "active"
7711c0
       }
7711c0
     ]
7711c0
@@ -184,24 +192,30 @@ write -P0xea 0x3fe0000 64k
7711c0
   "bitmaps": {
7711c0
     "drive0": [
7711c0
       {
7711c0
+        "busy": false,
7711c0
         "count": 393216,
7711c0
         "granularity": 65536,
7711c0
         "name": "bitmapC",
7711c0
         "persistent": false,
7711c0
+        "recording": false,
7711c0
         "status": "disabled"
7711c0
       },
7711c0
       {
7711c0
+        "busy": false,
7711c0
         "count": 262144,
7711c0
         "granularity": 65536,
7711c0
         "name": "bitmapB",
7711c0
         "persistent": false,
7711c0
+        "recording": false,
7711c0
         "status": "disabled"
7711c0
       },
7711c0
       {
7711c0
+        "busy": false,
7711c0
         "count": 458752,
7711c0
         "granularity": 65536,
7711c0
         "name": "bitmapA",
7711c0
         "persistent": false,
7711c0
+        "recording": false,
7711c0
         "status": "disabled"
7711c0
       }
7711c0
     ]
7711c0
@@ -251,24 +265,30 @@ write -P0xea 0x3fe0000 64k
7711c0
   "bitmaps": {
7711c0
     "drive0": [
7711c0
       {
7711c0
+        "busy": false,
7711c0
         "count": 393216,
7711c0
         "granularity": 65536,
7711c0
         "name": "bitmapC",
7711c0
         "persistent": false,
7711c0
+        "recording": false,
7711c0
         "status": "disabled"
7711c0
       },
7711c0
       {
7711c0
+        "busy": false,
7711c0
         "count": 262144,
7711c0
         "granularity": 65536,
7711c0
         "name": "bitmapB",
7711c0
         "persistent": false,
7711c0
+        "recording": false,
7711c0
         "status": "disabled"
7711c0
       },
7711c0
       {
7711c0
+        "busy": false,
7711c0
         "count": 458752,
7711c0
         "granularity": 65536,
7711c0
         "name": "bitmapA",
7711c0
         "persistent": false,
7711c0
+        "recording": false,
7711c0
         "status": "disabled"
7711c0
       }
7711c0
     ]
7711c0
@@ -311,31 +331,39 @@ write -P0xea 0x3fe0000 64k
7711c0
   "bitmaps": {
7711c0
     "drive0": [
7711c0
       {
7711c0
+        "busy": false,
7711c0
         "count": 458752,
7711c0
         "granularity": 65536,
7711c0
         "name": "bitmapD",
7711c0
         "persistent": false,
7711c0
+        "recording": false,
7711c0
         "status": "disabled"
7711c0
       },
7711c0
       {
7711c0
+        "busy": false,
7711c0
         "count": 393216,
7711c0
         "granularity": 65536,
7711c0
         "name": "bitmapC",
7711c0
         "persistent": false,
7711c0
+        "recording": false,
7711c0
         "status": "disabled"
7711c0
       },
7711c0
       {
7711c0
+        "busy": false,
7711c0
         "count": 262144,
7711c0
         "granularity": 65536,
7711c0
         "name": "bitmapB",
7711c0
         "persistent": false,
7711c0
+        "recording": false,
7711c0
         "status": "disabled"
7711c0
       },
7711c0
       {
7711c0
+        "busy": false,
7711c0
         "count": 458752,
7711c0
         "granularity": 65536,
7711c0
         "name": "bitmapA",
7711c0
         "persistent": false,
7711c0
+        "recording": false,
7711c0
         "status": "disabled"
7711c0
       }
7711c0
     ]
7711c0
-- 
7711c0
1.8.3.1
7711c0