diff mbox

[25/26] FVD: add impl of interface bdrv_probe()

Message ID 1298673486-3573-25-git-send-email-ctang@us.ibm.com
State New
Headers show

Commit Message

Chunqiang Tang Feb. 25, 2011, 10:38 p.m. UTC
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_probe() interface.

Signed-off-by: Chunqiang Tang <ctang@us.ibm.com>
---
 block/fvd-misc.c |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)
diff mbox

Patch

diff --git a/block/fvd-misc.c b/block/fvd-misc.c
index 61e39bb..6315218 100644
--- a/block/fvd-misc.c
+++ b/block/fvd-misc.c
@@ -163,7 +163,14 @@  static void fvd_close(BlockDriverState * bs)
 
 static int fvd_probe(const uint8_t * buf, int buf_size, const char *filename)
 {
-    return 0;
+    const FvdHeader *header = (const void *)buf;
+
+    if (buf_size >= sizeof(uint32_t) &&
+        le32_to_cpu(header->magic) == FVD_MAGIC) {
+        return 100;
+    } else {
+        return 0;
+    }
 }
 
 static int fvd_is_allocated(BlockDriverState * bs, int64_t sector_num,