diff mbox

[v3,24/32] blockdev: Separate qed probe from its driver

Message ID 1467732272-23368-25-git-send-email-clord@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

clord@redhat.com July 5, 2016, 3:24 p.m. UTC
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 <clord@redhat.com>
---
 block.c               |  1 +
 block/probe/qed.c     | 16 +++++++++++-----
 block/qed.c           |  1 -
 include/block/probe.h |  3 ++-
 4 files changed, 14 insertions(+), 7 deletions(-)

Comments

Max Reitz July 6, 2016, 4:11 p.m. UTC | #1
On 05.07.2016 17:24, Colin Lord wrote:
> 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 <clord@redhat.com>
> ---
>  block.c               |  1 +
>  block/probe/qed.c     | 16 +++++++++++-----
>  block/qed.c           |  1 -
>  include/block/probe.h |  3 ++-
>  4 files changed, 14 insertions(+), 7 deletions(-)

Reviewed-by: Max Reitz <mreitz@redhat.com>
diff mbox

Patch

diff --git a/block.c b/block.c
index b4e347a..fee9f8c 100644
--- a/block.c
+++ b/block.c
@@ -68,6 +68,7 @@  static BdrvProbeFunc *format_probes[] = {
     parallels_probe,
     qcow_probe,
     qcow2_probe,
+    bdrv_qed_probe,
 };
 
 static QTAILQ_HEAD(, BlockDriverState) graph_bdrv_states =
diff --git a/block/probe/qed.c b/block/probe/qed.c
index c902489..3fdb5d7 100644
--- a/block/probe/qed.c
+++ b/block/probe/qed.c
@@ -3,16 +3,22 @@ 
 #include "block/probe.h"
 #include "block/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 21d8982..cf78ff0 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 222185b..63edd74 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 *qcow_probe(const uint8_t *buf, int buf_size, const char *filename,
                        int *score);
 const char *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