qemu-block
[Top][All Lists]
Advanced

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

[Qemu-block] [PATCH v4 30/32] blockdev: Remove the .bdrv_probe field fro


From: Colin Lord
Subject: [Qemu-block] [PATCH v4 30/32] blockdev: Remove the .bdrv_probe field from BlockDrivers
Date: Thu, 14 Jul 2016 15:03:26 -0400

This commit finalizes the separation of the block driver and probe
function by removing the .bdrv_probe field from all BlockDrivers.
Probing is now accomplished solely by iterating over the array of probe
function pointers in the format_probes array.

Signed-off-by: Colin Lord <address@hidden>
Reviewed-by: Max Reitz <address@hidden>
---
 block.c                         | 21 +--------------------
 block/raw-posix.c               |  1 -
 include/block/block_int.h       |  1 -
 scripts/modules/module_block.py | 10 ++--------
 4 files changed, 3 insertions(+), 30 deletions(-)

diff --git a/block.c b/block.c
index bc550e4..20b93cf 100644
--- a/block.c
+++ b/block.c
@@ -599,35 +599,16 @@ BlockDriver *bdrv_probe_all(const uint8_t *buf, int 
buf_size,
     const char *format_max = NULL;
     const char *format;
     size_t i;
-    BlockDriver *drv = NULL, *d;
-
-    for (i = 0; i < ARRAY_SIZE(block_driver_modules); ++i) {
-        if (block_driver_modules[i].has_probe) {
-            block_module_load_one(block_driver_modules[i].library_name);
-        }
-    }
-
-    QLIST_FOREACH(d, &bdrv_drivers, list) {
-        if (d->bdrv_probe) {
-            score = d->bdrv_probe(buf, buf_size, filename);
-            if (score > score_max) {
-                score_max = score;
-                drv = d;
-            }
-        }
-    }
 
     for (i = 0; i < ARRAY_SIZE(format_probes); i++) {
         format = format_probes[i](buf, buf_size, filename, &score);
         if (score > score_max) {
             score_max = score;
             format_max = format;
-            /* TODO: move call to find_format outside this loop */
-            drv = bdrv_find_format(format_max);
         }
     }
 
-    return drv;
+    return bdrv_find_format(format_max);
 }
 
 static int find_image_format(BdrvChild *file, const char *filename,
diff --git a/block/raw-posix.c b/block/raw-posix.c
index c979ac3..e321bcd 100644
--- a/block/raw-posix.c
+++ b/block/raw-posix.c
@@ -1936,7 +1936,6 @@ BlockDriver bdrv_file = {
     .protocol_name = "file",
     .instance_size = sizeof(BDRVRawState),
     .bdrv_needs_filename = true,
-    .bdrv_probe = NULL, /* no probe for protocols */
     .bdrv_parse_filename = raw_parse_filename,
     .bdrv_file_open = raw_open,
     .bdrv_reopen_prepare = raw_reopen_prepare,
diff --git a/include/block/block_int.h b/include/block/block_int.h
index 47b9aac..23f229d 100644
--- a/include/block/block_int.h
+++ b/include/block/block_int.h
@@ -99,7 +99,6 @@ 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_device)(const char *filename);
 
     /* Any driver implementing this callback is expected to be able to handle
diff --git a/scripts/modules/module_block.py b/scripts/modules/module_block.py
index e5040f3..dba1717 100644
--- a/scripts/modules/module_block.py
+++ b/scripts/modules/module_block.py
@@ -24,15 +24,13 @@ def get_string_struct(line):
     return data[2].replace('"', '')[:-1]
 
 def add_module(fheader, library, format_name, protocol_name,
-                probe, probe_device):
+               probe_device):
     lines = []
     lines.append('.library_name = "' + library + '",')
     if format_name != "":
         lines.append('.format_name = "' + format_name + '",')
     if protocol_name != "":
         lines.append('.protocol_name = "' + protocol_name + '",')
-    if probe:
-        lines.append('.has_probe = true,')
     if probe_device:
         lines.append('.has_probe_device = true,')
 
@@ -52,20 +50,17 @@ def process_file(fheader, filename):
                     format_name = get_string_struct(line)
                 elif line.find(".protocol_name") != -1:
                     protocol_name = get_string_struct(line)
-                elif line.find(".bdrv_probe") != -1:
-                    probe = True
                 elif line.find(".bdrv_probe_device") != -1:
                     probe_device = True
                 elif line == "};":
                     add_module(fheader, library, format_name, protocol_name,
-                                probe, probe_device)
+                               probe_device)
                     found_start = False
             elif line.find("static BlockDriver") != -1:
                 found_something = True
                 found_start = True
                 format_name = ""
                 protocol_name = ""
-                probe = False
                 probe_device = False
 
         if not found_something:
@@ -93,7 +88,6 @@ static const struct {
     const char *format_name;
     const char *protocol_name;
     const char *library_name;
-    bool has_probe;
     bool has_probe_device;
 } block_driver_modules[] = {''')
 
-- 
2.5.5




reply via email to

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