diff mbox

[v3,25/32] blockdev: Separate raw probe from its driver

Message ID 1467732272-23368-26-git-send-email-clord@redhat.com
State New
Headers show

Commit Message

clord@redhat.com July 5, 2016, 3:24 p.m. UTC
Completes the separation of the raw probe from the raw driver. The
raw 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/raw.c     | 8 ++++++--
 block/raw_bsd.c       | 1 -
 include/block/probe.h | 3 ++-
 4 files changed, 9 insertions(+), 4 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 raw probe from the raw driver. The
> raw 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/raw.c     | 8 ++++++--
>  block/raw_bsd.c       | 1 -
>  include/block/probe.h | 3 ++-
>  4 files changed, 9 insertions(+), 4 deletions(-)

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

Patch

diff --git a/block.c b/block.c
index fee9f8c..a3d983f 100644
--- a/block.c
+++ b/block.c
@@ -69,6 +69,7 @@  static BdrvProbeFunc *format_probes[] = {
     qcow_probe,
     qcow2_probe,
     bdrv_qed_probe,
+    raw_probe,
 };
 
 static QTAILQ_HEAD(, BlockDriverState) graph_bdrv_states =
diff --git a/block/probe/raw.c b/block/probe/raw.c
index 22c6bcb..9923bb6 100644
--- a/block/probe/raw.c
+++ b/block/probe/raw.c
@@ -1,10 +1,14 @@ 
 #include "qemu/osdep.h"
 #include "block/probe.h"
 
-int raw_probe(const uint8_t *buf, int buf_size, const char *filename)
+const char *raw_probe(const uint8_t *buf, int buf_size, const char *filename,
+                      int *score)
 {
+    const char *format = "raw";
+    assert(score);
     /* smallest possible positive score so that raw is used if and only if no
      * other block driver works
      */
-    return 1;
+    *score = 1;
+    return format;
 }
diff --git a/block/raw_bsd.c b/block/raw_bsd.c
index 8f49637..4b24a36 100644
--- a/block/raw_bsd.c
+++ b/block/raw_bsd.c
@@ -231,7 +231,6 @@  static int raw_probe_geometry(BlockDriverState *bs, HDGeometry *geo)
 
 BlockDriver bdrv_raw = {
     .format_name          = "raw",
-    .bdrv_probe           = &raw_probe,
     .bdrv_reopen_prepare  = &raw_reopen_prepare,
     .bdrv_open            = &raw_open,
     .bdrv_close           = &raw_close,
diff --git a/include/block/probe.h b/include/block/probe.h
index 63edd74..b49663d 100644
--- a/include/block/probe.h
+++ b/include/block/probe.h
@@ -1,7 +1,6 @@ 
 #ifndef PROBE_H
 #define PROBE_H
 
-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);
 int vmdk_probe(const uint8_t *buf, int buf_size, const char *filename);
@@ -22,5 +21,7 @@  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);
+const char *raw_probe(const uint8_t *buf, int buf_size, const char *filename,
+                      int *score);
 
 #endif