This patch is part of the Fast Virtual Disk (FVD) proposal.
See http://wiki.qemu.org/Features/FVD.

This patch adds FVD's implementation of the bdrv_get_info() interface.

Signed-off-by: Chunqiang Tang <ct...@us.ibm.com>
---
 block/fvd-misc.c |   98 +++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 97 insertions(+), 1 deletions(-)

diff --git a/block/fvd-misc.c b/block/fvd-misc.c
index a42bfac..c515d74 100644
--- a/block/fvd-misc.c
+++ b/block/fvd-misc.c
@@ -11,6 +11,7 @@
  *
  */
 
+static int read_fvd_header(BDRVFvdState * s, FvdHeader * header);
 static void fvd_aio_cancel_bjnl_buf_write(FvdAIOCB * acb);
 static void fvd_aio_cancel_bjnl_flush(FvdAIOCB * acb);
 static void fvd_aio_cancel_read(FvdAIOCB * acb);
@@ -95,7 +96,102 @@ static int fvd_is_allocated(BlockDriverState * bs, int64_t 
sector_num,
 
 static int fvd_get_info(BlockDriverState * bs, BlockDriverInfo * bdi)
 {
-    return -ENOTSUP;
+    BDRVFvdState *s = bs->opaque;
+    FvdHeader header;
+
+    if (read_fvd_header(s, &header) < 0) {
+        return -1;
+    }
+
+    printf("========= Begin of FVD specific information ==================\n");
+    printf("magic\t\t\t\t\t\t%0X\n", header.magic);
+    printf("header_size\t\t\t\t\t%d\n", header.header_size);
+    printf("create_version\t\t\t\t\t%d\n", header.create_version);
+    printf("last_open_version\t\t\t\t%d\n", header.last_open_version);
+    printf("virtual_disk_size (bytes)\t\t\t%" PRId64 "\n",
+           header.virtual_disk_size);
+    printf("disk_metadata_size (bytes)\t\t\t%" PRId64 "\n", 
header.data_offset);
+    if (header.data_file[0]) {
+        printf("data_file\t\t\t\t\t%s\n", header.data_file);
+    }
+    if (header.data_file_fmt[0]) {
+        printf("data_file_fmt\t\t\t\t\t%s\n", header.data_file_fmt);
+    }
+
+    if (header.table_offset > 0) {
+        printf("table_size (bytes)\t\t\t\t%" PRId64 "\n", header.table_size);
+        printf("avail_storage (bytes)\t\t\t\t%" PRId64 "\n",
+               s->avail_storage * 512);
+        printf("chunk_size (bytes)\t\t\t\t%" PRId64 "\n", header.chunk_size);
+        printf("used_chunks (bytes)\t\t\t\t%" PRId64 "\n",
+               s->used_storage * 512);
+        printf("storage_grow_unit (bytes)\t\t\t%" PRId64 "\n",
+               header.storage_grow_unit);
+        printf("table_offset (bytes)\t\t\t\t%" PRId64 "\n",
+               header.table_offset);
+        printf("table_size (bytes)\t\t\t\t%" PRId64 "\n", s->table_size);
+        printf("chunks_relocated\t\t\t\t%s\n", BOOL(s->chunks_relocated));
+
+        if (header.add_storage_cmd[0] != 0) {
+            printf("add_storage_cmd\t\t\t\t\t%s\n", header.add_storage_cmd);
+        }
+    }
+
+    printf("clean_shutdown\t\t\t\t\t%s\n", BOOL(header.clean_shutdown));
+    if (header.journal_size > 0) {
+        printf("journal_offset\t\t\t\t\t%" PRId64 "\n", header.journal_offset);
+        printf("journal_size\t\t\t\t\t%" PRId64 "\n", header.journal_size);
+        printf("stable_journal_epoch\t\t\t\t%" PRId64 "\n",
+               header.stable_journal_epoch);
+        printf("journal_buf_size (bytes)\t\t\t%" PRId64 "\n",
+               header.journal_buf_size);
+        printf("journal_clean_buf_period (ms)\t\t\t%" PRId64 "\n",
+               header.journal_clean_buf_period);
+    }
+
+    if (header.base_img[0] != 0) {
+        printf("base_img_fully_prefetched\t\t\t%s\n",
+               BOOL(header.base_img_fully_prefetched));
+        printf("base_img\t\t\t\t\t%s\n", header.base_img);
+        if (header.base_img_fmt[0]) {
+            printf("base_img_fmt\t\t\t\t\t%s\n", header.base_img_fmt);
+        }
+        printf("base_img_size (bytes)\t\t\t\t%" PRId64 "\n",
+               header.base_img_size);
+        printf("bitmap_offset (bytes)\t\t\t\t%" PRId64 "\n",
+               header.bitmap_offset);
+        printf("bitmap_size (bytes)\t\t\t\t%" PRId64 "\n", header.bitmap_size);
+        printf("block_size\t\t\t\t\t%" PRId64 "\n", header.block_size);
+        printf("copy_on_read\t\t\t\t\t%s\n", BOOL(header.copy_on_read));
+        printf("max_outstanding_copy_on_read_data (bytes)\t%" PRId64 "\n",
+               header.max_outstanding_copy_on_read_data);
+        printf("need_zero_init\t\t\t\t\t%s\n", BOOL(header.need_zero_init));
+        printf("prefetch_start_delay (sec)\t\t\t%" PRId64 "\n",
+               header.prefetch_start_delay);
+        printf("num_prefetch_slots\t\t\t\t%d\n", header.num_prefetch_slots);
+        printf("bytes_per_prefetch\t\t\t\t%" PRIu64 "\n",
+               header.bytes_per_prefetch);
+        printf("prefetch_over_threshold_throttle_time (ms)\t%" PRIu64 "\n",
+               header.prefetch_throttle_time);
+        printf("prefetch_read_throughput_measure_time (ms)\t%" PRIu64 "\n",
+               header.prefetch_read_throughput_measure_time);
+        printf("prefetch_write_throughput_measure_time (ms)\t%" PRIu64 "\n",
+               header.prefetch_write_throughput_measure_time);
+        printf("prefetch_min_read_throughput (KB/s)\t\t%" PRIu64 "\n",
+               header.prefetch_min_read_throughput);
+        printf("prefetch_min_write_throughput (KB/s)\t\t%" PRIu64 "\n",
+               header.prefetch_min_write_throughput);
+        printf("prefetch_max_read_throughput (KB/s)\t\t%" PRIu64 "\n",
+               header.prefetch_max_read_throughput);
+        printf("prefetch_max_write_throughput (KB/s)\t\t%" PRIu64 "\n",
+               header.prefetch_max_write_throughput);
+    }
+
+    printf("========= End of FVD specific information ====================\n");
+
+    bdi->cluster_size = 0;
+    bdi->vm_state_offset = 0;
+    return 0;
 }
 
 static int fvd_has_zero_init(BlockDriverState * bs)
-- 
1.7.0.4


Reply via email to