Patchwork [v3,05/16] block: export dirty bitmap information in query-block

login
register
mail settings
Submitter Paolo Bonzini
Date Oct. 18, 2012, 2:49 p.m.
Message ID <1350571770-9836-6-git-send-email-pbonzini@redhat.com>
Download mbox | patch
Permalink /patch/192353/
State New
Headers show

Comments

Paolo Bonzini - Oct. 18, 2012, 2:49 p.m.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
        v2->v3: unit of measure is now bytes

 block.c          |  7 +++++++
 qapi-schema.json | 20 ++++++++++++++++++--
 2 file modificati, 25 inserzioni(+), 2 rimozioni(-)
Eric Blake - Oct. 18, 2012, 4:51 p.m.
On 10/18/2012 08:49 AM, Paolo Bonzini wrote:
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>         v2->v3: unit of measure is now bytes
> 
>  block.c          |  7 +++++++
>  qapi-schema.json | 20 ++++++++++++++++++--
>  2 file modificati, 25 inserzioni(+), 2 rimozioni(-)
> 
> +++ b/qapi-schema.json
> @@ -629,7 +629,7 @@
>              '*backing_file': 'str', 'backing_file_depth': 'int',
>              'encrypted': 'bool', 'encryption_key_missing': 'bool',
>              'bps': 'int', 'bps_rd': 'int', 'bps_wr': 'int',
> -            'iops': 'int', 'iops_rd': 'int', 'iops_wr': 'int'} }
> +            'iops': 'int', 'iops_rd': 'int', 'iops_wr': 'int' } }
>  

This whitespace change hunk looks out of place...

>  ##
>  # @BlockDeviceIoStatus:
> @@ -647,6 +647,18 @@
>  { 'enum': 'BlockDeviceIoStatus', 'data': [ 'ok', 'failed', 'nospace' ] }
>  
>  ##
> +# @BlockDirtyInfo:
> +#
> +# Block dirty bitmap information.
> +#
> +# @count: number of dirty bytes according to the dirty bitmap
> +#
> +# Since: 1.3
> +##
> +{ 'type': 'BlockDirtyInfo',
> +  'data': {'count': 'int'} }

...especially since you aren't consistent on using space before }

However, I can live with it, rather than needing a v4.

Patch

diff --git a/block.c b/block.c
index 057b2b2..b167f61 100644
--- a/block.c
+++ b/block.c
@@ -2835,6 +2835,13 @@  BlockInfo *bdrv_query_info(BlockDriverState *bs)
         info->io_status = bs->iostatus;
     }
 
+    if (bs->dirty_bitmap) {
+        info->has_dirty = true;
+        info->dirty = g_malloc0(sizeof(*info->dirty));
+        info->dirty->count = bdrv_get_dirty_count(bs) *
+            BDRV_SECTORS_PER_DIRTY_CHUNK * BDRV_SECTOR_SIZE;
+    }
+
     if (bs->drv) {
         info->has_inserted = true;
         info->inserted = g_malloc0(sizeof(*info->inserted));
diff --git a/qapi-schema.json b/qapi-schema.json
index f9dbdae..2aac6b8 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -629,7 +629,7 @@ 
             '*backing_file': 'str', 'backing_file_depth': 'int',
             'encrypted': 'bool', 'encryption_key_missing': 'bool',
             'bps': 'int', 'bps_rd': 'int', 'bps_wr': 'int',
-            'iops': 'int', 'iops_rd': 'int', 'iops_wr': 'int'} }
+            'iops': 'int', 'iops_rd': 'int', 'iops_wr': 'int' } }
 
 ##
 # @BlockDeviceIoStatus:
@@ -647,6 +647,18 @@ 
 { 'enum': 'BlockDeviceIoStatus', 'data': [ 'ok', 'failed', 'nospace' ] }
 
 ##
+# @BlockDirtyInfo:
+#
+# Block dirty bitmap information.
+#
+# @count: number of dirty bytes according to the dirty bitmap
+#
+# Since: 1.3
+##
+{ 'type': 'BlockDirtyInfo',
+  'data': {'count': 'int'} }
+
+##
 # @BlockInfo:
 #
 # Block device information.  This structure describes a virtual device and
@@ -665,6 +677,9 @@ 
 # @tray_open: #optional True if the device has a tray and it is open
 #             (only present if removable is true)
 #
+# @dirty: #optional dirty bitmap information (only present if the dirty
+#         bitmap is enabled)
+#
 # @io-status: #optional @BlockDeviceIoStatus. Only present if the device
 #             supports it and the VM is configured to stop on errors
 #
@@ -676,7 +691,8 @@ 
 { 'type': 'BlockInfo',
   'data': {'device': 'str', 'type': 'str', 'removable': 'bool',
            'locked': 'bool', '*inserted': 'BlockDeviceInfo',
-           '*tray_open': 'bool', '*io-status': 'BlockDeviceIoStatus'} }
+           '*tray_open': 'bool', '*io-status': 'BlockDeviceIoStatus',
+           '*dirty': 'BlockDirtyInfo' } }
 
 ##
 # @query-block: