yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
9ae3a8
From c6de1e3f478b5449d1283c66164c5ede351db600 Mon Sep 17 00:00:00 2001
9ae3a8
From: Max Reitz <mreitz@redhat.com>
9ae3a8
Date: Wed, 6 Nov 2013 16:53:35 +0100
9ae3a8
Subject: [PATCH 78/87] block: Add bdrv_get_specific_info
9ae3a8
9ae3a8
RH-Author: Max Reitz <mreitz@redhat.com>
9ae3a8
Message-id: <1383756824-6921-13-git-send-email-mreitz@redhat.com>
9ae3a8
Patchwork-id: 55567
9ae3a8
O-Subject: [RHEL-7.0 qemu-kvm PATCH v2 12/21] block: Add bdrv_get_specific_info
9ae3a8
Bugzilla: 980771
9ae3a8
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
9ae3a8
RH-Acked-by: Fam Zheng <famz@redhat.com>
9ae3a8
RH-Acked-by: Jeffrey Cody <jcody@redhat.com>
9ae3a8
9ae3a8
BZ: 980771
9ae3a8
9ae3a8
Add a function for retrieving an ImageInfoSpecific object from a block
9ae3a8
driver.
9ae3a8
9ae3a8
Signed-off-by: Max Reitz <mreitz@redhat.com>
9ae3a8
Reviewed-by: Eric Blake <eblake@redhat.com>
9ae3a8
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
9ae3a8
(cherry picked from commit eae041fe6f4314962e873615134eefb32cf8ba61)
9ae3a8
9ae3a8
Signed-off-by: Max Reitz <mreitz@redhat.com>
9ae3a8
---
9ae3a8
 block.c                   | 9 +++++++++
9ae3a8
 block/qapi.c              | 3 +++
9ae3a8
 include/block/block.h     | 1 +
9ae3a8
 include/block/block_int.h | 1 +
9ae3a8
 4 files changed, 14 insertions(+)
9ae3a8
9ae3a8
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
9ae3a8
---
9ae3a8
 block.c                   |    9 +++++++++
9ae3a8
 block/qapi.c              |    3 +++
9ae3a8
 include/block/block.h     |    1 +
9ae3a8
 include/block/block_int.h |    1 +
9ae3a8
 4 files changed, 14 insertions(+), 0 deletions(-)
9ae3a8
9ae3a8
diff --git a/block.c b/block.c
9ae3a8
index e4885da..6913799 100644
9ae3a8
--- a/block.c
9ae3a8
+++ b/block.c
9ae3a8
@@ -3309,6 +3309,15 @@ int bdrv_get_info(BlockDriverState *bs, BlockDriverInfo *bdi)
9ae3a8
     return drv->bdrv_get_info(bs, bdi);
9ae3a8
 }
9ae3a8
 
9ae3a8
+ImageInfoSpecific *bdrv_get_specific_info(BlockDriverState *bs)
9ae3a8
+{
9ae3a8
+    BlockDriver *drv = bs->drv;
9ae3a8
+    if (drv && drv->bdrv_get_specific_info) {
9ae3a8
+        return drv->bdrv_get_specific_info(bs);
9ae3a8
+    }
9ae3a8
+    return NULL;
9ae3a8
+}
9ae3a8
+
9ae3a8
 int bdrv_save_vmstate(BlockDriverState *bs, const uint8_t *buf,
9ae3a8
                       int64_t pos, int size)
9ae3a8
 {
9ae3a8
diff --git a/block/qapi.c b/block/qapi.c
9ae3a8
index a4bc411..896cd37 100644
9ae3a8
--- a/block/qapi.c
9ae3a8
+++ b/block/qapi.c
9ae3a8
@@ -134,6 +134,9 @@ void bdrv_query_image_info(BlockDriverState *bs,
9ae3a8
         info->dirty_flag = bdi.is_dirty;
9ae3a8
         info->has_dirty_flag = true;
9ae3a8
     }
9ae3a8
+    info->format_specific     = bdrv_get_specific_info(bs);
9ae3a8
+    info->has_format_specific = info->format_specific != NULL;
9ae3a8
+
9ae3a8
     backing_filename = bs->backing_file;
9ae3a8
     if (backing_filename[0] != '\0') {
9ae3a8
         info->backing_filename = g_strdup(backing_filename);
9ae3a8
diff --git a/include/block/block.h b/include/block/block.h
9ae3a8
index 7695cae..656570e 100644
9ae3a8
--- a/include/block/block.h
9ae3a8
+++ b/include/block/block.h
9ae3a8
@@ -338,6 +338,7 @@ int bdrv_get_flags(BlockDriverState *bs);
9ae3a8
 int bdrv_write_compressed(BlockDriverState *bs, int64_t sector_num,
9ae3a8
                           const uint8_t *buf, int nb_sectors);
9ae3a8
 int bdrv_get_info(BlockDriverState *bs, BlockDriverInfo *bdi);
9ae3a8
+ImageInfoSpecific *bdrv_get_specific_info(BlockDriverState *bs);
9ae3a8
 void bdrv_round_to_clusters(BlockDriverState *bs,
9ae3a8
                             int64_t sector_num, int nb_sectors,
9ae3a8
                             int64_t *cluster_sector_num,
9ae3a8
diff --git a/include/block/block_int.h b/include/block/block_int.h
9ae3a8
index 9348238..0dbc34f 100644
9ae3a8
--- a/include/block/block_int.h
9ae3a8
+++ b/include/block/block_int.h
9ae3a8
@@ -166,6 +166,7 @@ struct BlockDriver {
9ae3a8
     int (*bdrv_snapshot_load_tmp)(BlockDriverState *bs,
9ae3a8
                                   const char *snapshot_name);
9ae3a8
     int (*bdrv_get_info)(BlockDriverState *bs, BlockDriverInfo *bdi);
9ae3a8
+    ImageInfoSpecific *(*bdrv_get_specific_info)(BlockDriverState *bs);
9ae3a8
 
9ae3a8
     int (*bdrv_save_vmstate)(BlockDriverState *bs, QEMUIOVector *qiov,
9ae3a8
                              int64_t pos);
9ae3a8
-- 
9ae3a8
1.7.1
9ae3a8