qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 1/3] block: format: pass down the current state to t


From: Levente Kurusa
Subject: [Qemu-devel] [PATCH 1/3] block: format: pass down the current state to the format's probe function
Date: Fri, 1 Aug 2014 15:39:59 +0200

While most ->probe functions are content with reading the first 2048
bytes of their disk, there are some (namely VPC) which might need to
know more about the disk. Pass down the BlockDriverState to the probe
functions, so that the drivers can read more data should they need it.

Reviewed-by: Andrew Jones <address@hidden>
Signed-off-by: Levente Kurusa <address@hidden>
---
 block.c                   | 2 +-
 block/bochs.c             | 3 ++-
 block/cloop.c             | 3 ++-
 block/cow.c               | 3 ++-
 block/dmg.c               | 3 ++-
 block/parallels.c         | 3 ++-
 block/qcow.c              | 3 ++-
 block/qcow2.c             | 3 ++-
 block/qed.c               | 4 ++--
 block/raw_bsd.c           | 3 ++-
 block/vdi.c               | 3 ++-
 block/vmdk.c              | 3 ++-
 block/vpc.c               | 3 ++-
 include/block/block_int.h | 3 ++-
 14 files changed, 27 insertions(+), 15 deletions(-)

diff --git a/block.c b/block.c
index 8cf519b..90dd8f0 100644
--- a/block.c
+++ b/block.c
@@ -683,7 +683,7 @@ static int find_image_format(BlockDriverState *bs, const 
char *filename,
     drv = NULL;
     QLIST_FOREACH(drv1, &bdrv_drivers, list) {
         if (drv1->bdrv_probe) {
-            score = drv1->bdrv_probe(buf, ret, filename);
+            score = drv1->bdrv_probe(bs, buf, ret, filename);
             if (score > score_max) {
                 score_max = score;
                 drv = drv1;
diff --git a/block/bochs.c b/block/bochs.c
index eba23df..9e445f4 100644
--- a/block/bochs.c
+++ b/block/bochs.c
@@ -76,7 +76,8 @@ typedef struct BDRVBochsState {
     uint32_t extent_size;
 } BDRVBochsState;
 
-static int bochs_probe(const uint8_t *buf, int buf_size, const char *filename)
+static int bochs_probe(BlockDriverState *bs, const uint8_t *buf, int buf_size,
+                       const char *filename)
 {
     const struct bochs_header *bochs = (const void *)buf;
 
diff --git a/block/cloop.c b/block/cloop.c
index 8457737..f707699 100644
--- a/block/cloop.c
+++ b/block/cloop.c
@@ -41,7 +41,8 @@ typedef struct BDRVCloopState {
     z_stream zstream;
 } BDRVCloopState;
 
-static int cloop_probe(const uint8_t *buf, int buf_size, const char *filename)
+static int cloop_probe(BlockDriverState *bs, const uint8_t *buf, int buf_size,
+                       const char *filename)
 {
     const char *magic_version_2_0 = "#!/bin/sh\n"
         "#V2.0 Format\n"
diff --git a/block/cow.c b/block/cow.c
index 6ee4833..6002c62 100644
--- a/block/cow.c
+++ b/block/cow.c
@@ -46,7 +46,8 @@ typedef struct BDRVCowState {
     int64_t cow_sectors_offset;
 } BDRVCowState;
 
-static int cow_probe(const uint8_t *buf, int buf_size, const char *filename)
+static int cow_probe(BlockDriverState *bs, const uint8_t *buf, int buf_size,
+                     const char *filename)
 {
     const struct cow_header_v2 *cow_header = (const void *)buf;
 
diff --git a/block/dmg.c b/block/dmg.c
index 1e153cd..962c4fc 100644
--- a/block/dmg.c
+++ b/block/dmg.c
@@ -57,7 +57,8 @@ typedef struct BDRVDMGState {
     z_stream zstream;
 } BDRVDMGState;
 
-static int dmg_probe(const uint8_t *buf, int buf_size, const char *filename)
+static int dmg_probe(BlockDriverState *bs, const uint8_t *buf, int buf_size,
+                     const char *filename)
 {
     int len;
 
diff --git a/block/parallels.c b/block/parallels.c
index 1a5bd35..157d0a0 100644
--- a/block/parallels.c
+++ b/block/parallels.c
@@ -54,7 +54,8 @@ typedef struct BDRVParallelsState {
     unsigned int tracks;
 } BDRVParallelsState;
 
-static int parallels_probe(const uint8_t *buf, int buf_size, const char 
*filename)
+static int parallels_probe(BlockDriverState *bs, const uint8_t *buf,
+                           int buf_size, const char *filename)
 {
     const struct parallels_header *ph = (const void *)buf;
 
diff --git a/block/qcow.c b/block/qcow.c
index a874056..acd126a 100644
--- a/block/qcow.c
+++ b/block/qcow.c
@@ -81,7 +81,8 @@ typedef struct BDRVQcowState {
 
 static int decompress_cluster(BlockDriverState *bs, uint64_t cluster_offset);
 
-static int qcow_probe(const uint8_t *buf, int buf_size, const char *filename)
+static int qcow_probe(BlockDriverState *bs, const uint8_t *buf, int buf_size,
+                      const char *filename)
 {
     const QCowHeader *cow_header = (const void *)buf;
 
diff --git a/block/qcow2.c b/block/qcow2.c
index 1e3ab6b..14593db 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -59,7 +59,8 @@ typedef struct {
 #define  QCOW2_EXT_MAGIC_BACKING_FORMAT 0xE2792ACA
 #define  QCOW2_EXT_MAGIC_FEATURE_TABLE 0x6803f857
 
-static int qcow2_probe(const uint8_t *buf, int buf_size, const char *filename)
+static int qcow2_probe(BlockDriverState *bs, const uint8_t *buf, int buf_size,
+                       const char *filename)
 {
     const QCowHeader *cow_header = (const void *)buf;
 
diff --git a/block/qed.c b/block/qed.c
index 7944832..7b492e9 100644
--- a/block/qed.c
+++ b/block/qed.c
@@ -36,8 +36,8 @@ static const AIOCBInfo qed_aiocb_info = {
     .cancel             = qed_aio_cancel,
 };
 
-static int bdrv_qed_probe(const uint8_t *buf, int buf_size,
-                          const char *filename)
+static int bdrv_qed_probe(BlockDriverState *bs, const uint8_t *buf,
+                          int buf_size, const char *filename)
 {
     const QEDHeader *header = (const QEDHeader *)buf;
 
diff --git a/block/raw_bsd.c b/block/raw_bsd.c
index f82f4c2..0a2b45f 100644
--- a/block/raw_bsd.c
+++ b/block/raw_bsd.c
@@ -165,7 +165,8 @@ static void raw_close(BlockDriverState *bs)
 {
 }
 
-static int raw_probe(const uint8_t *buf, int buf_size, const char *filename)
+static int raw_probe(BlockDriverState *bs, const uint8_t *buf, int buf_size,
+                     const char *filename)
 {
     /* smallest possible positive score so that raw is used if and only if no
      * other block driver works
diff --git a/block/vdi.c b/block/vdi.c
index 197bd77..a30ccb1 100644
--- a/block/vdi.c
+++ b/block/vdi.c
@@ -354,7 +354,8 @@ static int vdi_make_empty(BlockDriverState *bs)
     return 0;
 }
 
-static int vdi_probe(const uint8_t *buf, int buf_size, const char *filename)
+static int vdi_probe(BlockDriverState *bs, const uint8_t *buf, int buf_size,
+                     const char *filename)
 {
     const VdiHeader *header = (const VdiHeader *)buf;
     int result = 0;
diff --git a/block/vmdk.c b/block/vmdk.c
index 0517bba..8302876 100644
--- a/block/vmdk.c
+++ b/block/vmdk.c
@@ -145,7 +145,8 @@ enum {
     MARKER_FOOTER           = 3,
 };
 
-static int vmdk_probe(const uint8_t *buf, int buf_size, const char *filename)
+static int vmdk_probe(BlockDriverState *bs, const uint8_t *buf, int buf_size,
+                      const char *filename)
 {
     uint32_t magic;
 
diff --git a/block/vpc.c b/block/vpc.c
index 8b376a4..2ba8fc2 100644
--- a/block/vpc.c
+++ b/block/vpc.c
@@ -157,7 +157,8 @@ static uint32_t vpc_checksum(uint8_t* buf, size_t size)
 }
 
 
-static int vpc_probe(const uint8_t *buf, int buf_size, const char *filename)
+static int vpc_probe(BlockDriverState *bs, const uint8_t *buf, int buf_size,
+                     const char *filename)
 {
     if (buf_size >= 8 && !strncmp((char *)buf, "conectix", 8))
        return 100;
diff --git a/include/block/block_int.h b/include/block/block_int.h
index 7b541a0..2825cef 100644
--- a/include/block/block_int.h
+++ b/include/block/block_int.h
@@ -88,7 +88,8 @@ struct BlockDriver {
     bool (*bdrv_recurse_is_first_non_filter)(BlockDriverState *bs,
                                              BlockDriverState *candidate);
 
-    int (*bdrv_probe)(const uint8_t *buf, int buf_size, const char *filename);
+    int (*bdrv_probe)(BlockDriverState *bs, const uint8_t *buf,
+                      int buf_size, const char *filename);
     int (*bdrv_probe_device)(const char *filename);
 
     /* Any driver implementing this callback is expected to be able to handle
-- 
1.9.3




reply via email to

[Prev in Thread] Current Thread [Next in Thread]