qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] [PATCH v4 24/32] blockdev: Separate qed probe from its driv


From: Colin Lord
Subject: [Qemu-devel] [PATCH v4 24/32] blockdev: Separate qed probe from its driver
Date: Thu, 14 Jul 2016 15:03:20 -0400

Completes the separation of the qed probe from the qed driver. The
qed probe now returns the format in addition to the score, allowing
correlation of the score and driver without the probe function being
part of the driver itself.

Signed-off-by: Colin Lord <address@hidden>
Reviewed-by: Max Reitz <address@hidden>
---
 block.c               |  1 +
 block/qed-probe.c     | 16 +++++++++++-----
 block/qed.c           |  1 -
 include/block/probe.h |  3 ++-
 4 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/block.c b/block.c
index 145be9b..3dc7644 100644
--- a/block.c
+++ b/block.c
@@ -68,6 +68,7 @@ static BdrvProbeFunc *format_probes[] = {
     bdrv_parallels_probe,
     bdrv_qcow_probe,
     bdrv_qcow2_probe,
+    bdrv_qed_probe,
 };
 
 static QTAILQ_HEAD(, BlockDriverState) graph_bdrv_states =
diff --git a/block/qed-probe.c b/block/qed-probe.c
index 40261f0..5ad8359 100644
--- a/block/qed-probe.c
+++ b/block/qed-probe.c
@@ -3,16 +3,22 @@
 #include "block/probe.h"
 #include "qed.h"
 
-int bdrv_qed_probe(const uint8_t *buf, int buf_size,
-                          const char *filename)
+const char *bdrv_qed_probe(const uint8_t *buf, int buf_size,
+                           const char *filename, int *score)
 {
+    const char *format = "qed";
     const QEDHeader *header = (const QEDHeader *)buf;
+    assert(score);
+    *score = 0;
 
     if (buf_size < sizeof(*header)) {
-        return 0;
+        return format;
     }
+
     if (le32_to_cpu(header->magic) != QED_MAGIC) {
-        return 0;
+        return format;
     }
-    return 100;
+
+    *score = 100;
+    return format;
 }
diff --git a/block/qed.c b/block/qed.c
index 544ed0d..a8d790a 100644
--- a/block/qed.c
+++ b/block/qed.c
@@ -1638,7 +1638,6 @@ static BlockDriver bdrv_qed = {
     .create_opts              = &qed_create_opts,
     .supports_backing         = true,
 
-    .bdrv_probe               = bdrv_qed_probe,
     .bdrv_open                = bdrv_qed_open,
     .bdrv_close               = bdrv_qed_close,
     .bdrv_reopen_prepare      = bdrv_qed_reopen_prepare,
diff --git a/include/block/probe.h b/include/block/probe.h
index 1a68cef..cbb9c12 100644
--- a/include/block/probe.h
+++ b/include/block/probe.h
@@ -1,7 +1,6 @@
 #ifndef PROBE_H
 #define PROBE_H
 
-int bdrv_qed_probe(const uint8_t *buf, int buf_size, const char *filename);
 int raw_probe(const uint8_t *buf, int buf_size, const char *filename);
 int vdi_probe(const uint8_t *buf, int buf_size, const char *filename);
 int vhdx_probe(const uint8_t *buf, int buf_size, const char *filename);
@@ -21,5 +20,7 @@ const char *bdrv_qcow_probe(const uint8_t *buf, int buf_size,
                             const char *filename, int *score);
 const char *bdrv_qcow2_probe(const uint8_t *buf, int buf_size,
                              const char *filename, int *score);
+const char *bdrv_qed_probe(const uint8_t *buf, int buf_size,
+                           const char *filename, int *score);
 
 #endif
-- 
2.5.5




reply via email to

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