qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v4 00/32] Dynamic module loading for block drivers
@ 2016-07-14 19:02 Colin Lord
  2016-07-14 19:02 ` [Qemu-devel] [PATCH v4 01/32] blockdev: prepare iSCSI block driver for dynamic loading Colin Lord
                   ` (32 more replies)
  0 siblings, 33 replies; 42+ messages in thread
From: Colin Lord @ 2016-07-14 19:02 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, qemu-block, mreitz, Colin Lord

Here's v4 of the modularization series. Things that have changed since
v3 include:

- Fix indentation of the generated header file module_block.h
- Drivers and probe functions are now all located in the block/
  directory, rather than being split between block/ and block/probe/. In
  addition the header files for each probe/driver pair are in the block/
  directory, not the include/block/driver/ directory (which no longer
  exists).
- Since the probe files are in block/ now, they follow the naming
  pattern of format-probe.c
- Renamed crypto probe file to be crypto-probe.c, luks is no longer in
  the filename
- Fixed formatting of parallels_probe() function header
- Enforced consistent naming convention for the probe functions. They
  now follow the pattern bdrv_format_probe().

Colin Lord (30):
  blockdev: prepare iSCSI block driver for dynamic loading
  blockdev: Move bochs probe into separate file
  blockdev: Move cloop probe to its own file
  blockdev: Move luks probe to its own file
  blockdev: Move dmg probe to its own file
  blockdev: Move parallels probe to its own file
  blockdev: Move qcow probe to its own file
  blockdev: Move qcow2 probe to its own file
  blockdev: Move qed probe to its own file
  blockdev: Move raw probe to its own file
  blockdev: Move vdi probe to its own file
  blockdev: Move vhdx probe to its own file
  blockdev: Move vmdk probe to its own file
  blockdev: Move vpc probe to its own file
  blockdev: Separate bochs probe from its driver
  blockdev: Separate cloop probe from its driver
  blockdev: Separate luks probe from its driver
  blockdev: Separate dmg probe from its driver
  blockdev: Separate parallels probe from its driver
  blockdev: Separate qcow probe from its driver
  blockdev: Separate qcow2 probe from its driver
  blockdev: Separate qed probe from its driver
  blockdev: Separate raw probe from its driver
  blockdev: Separate vdi probe from its driver
  blockdev: Separate vhdx probe from its driver
  blockdev: Separate vmdk probe from its driver
  blockdev: Separate vpc probe from its driver
  blockdev: Remove the .bdrv_probe field from BlockDrivers
  blockdev: Separate out bdrv_probe_device functions
  blockdev: Remove bdrv_probe_device field from BlockDriver

Marc Mari (2):
  blockdev: Add dynamic generation of module_block.h
  blockdev: Add dynamic module loading for block drivers

 Makefile                        |   7 ++
 block.c                         | 181 ++++++++++++++++++++++++++++++++--------
 block/Makefile.objs             |   4 +
 block/bochs-probe.c             |  28 +++++++
 block/bochs.c                   |  56 +------------
 block/bochs.h                   |  40 +++++++++
 block/cloop-probe.c             |  22 +++++
 block/cloop.c                   |  17 +---
 block/crypto-probe.c            |  26 ++++++
 block/crypto.c                  |  22 +----
 block/dmg-probe.c               |  22 +++++
 block/dmg.c                     |  17 +---
 block/host_cdrom-probe.c        |  47 +++++++++++
 block/host_device-probe.c       |  42 ++++++++++
 block/iscsi.c                   |  36 --------
 block/parallels-probe.c         |  26 ++++++
 block/parallels.c               |  44 +---------
 block/parallels.h               |  26 ++++++
 block/qcow-probe.c              |  22 +++++
 block/qcow.c                    |  32 +------
 block/qcow.h                    |  21 +++++
 block/qcow2-probe.c             |  22 +++++
 block/qcow2.c                   |  14 +---
 block/qed-probe.c               |  24 ++++++
 block/qed.c                     |  16 +---
 block/raw-posix.c               |  55 +-----------
 block/raw-probe.c               |  14 ++++
 block/raw-win32.c               |  11 +--
 block/raw_bsd.c                 |  10 +--
 block/vdi-probe.c               |  29 +++++++
 block/vdi.c                     |  70 +---------------
 block/vdi.h                     |  49 +++++++++++
 block/vhdx-probe.c              |  27 ++++++
 block/vhdx.c                    |  21 +----
 block/vmdk-probe.c              |  67 +++++++++++++++
 block/vmdk.c                    |  61 +-------------
 block/vmdk.h                    |   7 ++
 block/vpc-probe.c               |  16 ++++
 block/vpc.c                     |   9 +-
 include/block/block_int.h       |   3 -
 include/block/probe.h           |  33 ++++++++
 include/qemu/module.h           |   3 +
 scripts/modules/module_block.py | 108 ++++++++++++++++++++++++
 util/module.c                   |  38 +++------
 vl.c                            |  38 +++++++++
 45 files changed, 948 insertions(+), 535 deletions(-)
 create mode 100644 block/bochs-probe.c
 create mode 100644 block/bochs.h
 create mode 100644 block/cloop-probe.c
 create mode 100644 block/crypto-probe.c
 create mode 100644 block/dmg-probe.c
 create mode 100644 block/host_cdrom-probe.c
 create mode 100644 block/host_device-probe.c
 create mode 100644 block/parallels-probe.c
 create mode 100644 block/parallels.h
 create mode 100644 block/qcow-probe.c
 create mode 100644 block/qcow.h
 create mode 100644 block/qcow2-probe.c
 create mode 100644 block/qed-probe.c
 create mode 100644 block/raw-probe.c
 create mode 100644 block/vdi-probe.c
 create mode 100644 block/vdi.h
 create mode 100644 block/vhdx-probe.c
 create mode 100644 block/vmdk-probe.c
 create mode 100644 block/vmdk.h
 create mode 100644 block/vpc-probe.c
 create mode 100644 include/block/probe.h
 create mode 100644 scripts/modules/module_block.py

-- 
2.5.5

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [Qemu-devel] [PATCH v4 01/32] blockdev: prepare iSCSI block driver for dynamic loading
  2016-07-14 19:02 [Qemu-devel] [PATCH v4 00/32] Dynamic module loading for block drivers Colin Lord
@ 2016-07-14 19:02 ` Colin Lord
  2016-07-14 19:02 ` [Qemu-devel] [PATCH v4 02/32] blockdev: Add dynamic generation of module_block.h Colin Lord
                   ` (31 subsequent siblings)
  32 siblings, 0 replies; 42+ messages in thread
From: Colin Lord @ 2016-07-14 19:02 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, qemu-block, mreitz, Colin Lord

This commit moves the initialization of the QemuOptsList qemu_iscsi_opts
struct out of block/iscsi.c in order to allow the iscsi module to be
dynamically loaded.

Signed-off-by: Colin Lord <clord@redhat.com>
Reviewed-by: Fam Zheng <famz@redhat.com>
---
 block/iscsi.c | 36 ------------------------------------
 vl.c          | 38 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 38 insertions(+), 36 deletions(-)

diff --git a/block/iscsi.c b/block/iscsi.c
index 434cb37..b52cd37 100644
--- a/block/iscsi.c
+++ b/block/iscsi.c
@@ -1882,45 +1882,9 @@ static BlockDriver bdrv_iscsi = {
     .bdrv_attach_aio_context = iscsi_attach_aio_context,
 };
 
-static QemuOptsList qemu_iscsi_opts = {
-    .name = "iscsi",
-    .head = QTAILQ_HEAD_INITIALIZER(qemu_iscsi_opts.head),
-    .desc = {
-        {
-            .name = "user",
-            .type = QEMU_OPT_STRING,
-            .help = "username for CHAP authentication to target",
-        },{
-            .name = "password",
-            .type = QEMU_OPT_STRING,
-            .help = "password for CHAP authentication to target",
-        },{
-            .name = "password-secret",
-            .type = QEMU_OPT_STRING,
-            .help = "ID of the secret providing password for CHAP "
-                    "authentication to target",
-        },{
-            .name = "header-digest",
-            .type = QEMU_OPT_STRING,
-            .help = "HeaderDigest setting. "
-                    "{CRC32C|CRC32C-NONE|NONE-CRC32C|NONE}",
-        },{
-            .name = "initiator-name",
-            .type = QEMU_OPT_STRING,
-            .help = "Initiator iqn name to use when connecting",
-        },{
-            .name = "timeout",
-            .type = QEMU_OPT_NUMBER,
-            .help = "Request timeout in seconds (default 0 = no timeout)",
-        },
-        { /* end of list */ }
-    },
-};
-
 static void iscsi_block_init(void)
 {
     bdrv_register(&bdrv_iscsi);
-    qemu_add_opts(&qemu_iscsi_opts);
 }
 
 block_init(iscsi_block_init);
diff --git a/vl.c b/vl.c
index 356713e..90ed255 100644
--- a/vl.c
+++ b/vl.c
@@ -506,6 +506,41 @@ static QemuOptsList qemu_fw_cfg_opts = {
     },
 };
 
+static QemuOptsList qemu_iscsi_opts = {
+    .name = "iscsi",
+    .head = QTAILQ_HEAD_INITIALIZER(qemu_iscsi_opts.head),
+    .desc = {
+        {
+            .name = "user",
+            .type = QEMU_OPT_STRING,
+            .help = "username for CHAP authentication to target",
+        },{
+            .name = "password",
+            .type = QEMU_OPT_STRING,
+            .help = "password for CHAP authentication to target",
+        },{
+            .name = "password-secret",
+            .type = QEMU_OPT_STRING,
+            .help = "ID of the secret providing password for CHAP "
+                    "authentication to target",
+        },{
+            .name = "header-digest",
+            .type = QEMU_OPT_STRING,
+            .help = "HeaderDigest setting. "
+                    "{CRC32C|CRC32C-NONE|NONE-CRC32C|NONE}",
+        },{
+            .name = "initiator-name",
+            .type = QEMU_OPT_STRING,
+            .help = "Initiator iqn name to use when connecting",
+        },{
+            .name = "timeout",
+            .type = QEMU_OPT_NUMBER,
+            .help = "Request timeout in seconds (default 0 = no timeout)",
+        },
+        { /* end of list */ }
+    },
+};
+
 /**
  * Get machine options
  *
@@ -3000,6 +3035,9 @@ int main(int argc, char **argv, char **envp)
     qemu_add_opts(&qemu_icount_opts);
     qemu_add_opts(&qemu_semihosting_config_opts);
     qemu_add_opts(&qemu_fw_cfg_opts);
+#ifdef CONFIG_LIBISCSI
+    qemu_add_opts(&qemu_iscsi_opts);
+#endif
     module_call_init(MODULE_INIT_OPTS);
 
     runstate_init();
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [Qemu-devel] [PATCH v4 02/32] blockdev: Add dynamic generation of module_block.h
  2016-07-14 19:02 [Qemu-devel] [PATCH v4 00/32] Dynamic module loading for block drivers Colin Lord
  2016-07-14 19:02 ` [Qemu-devel] [PATCH v4 01/32] blockdev: prepare iSCSI block driver for dynamic loading Colin Lord
@ 2016-07-14 19:02 ` Colin Lord
  2016-07-14 19:02 ` [Qemu-devel] [PATCH v4 03/32] blockdev: Add dynamic module loading for block drivers Colin Lord
                   ` (30 subsequent siblings)
  32 siblings, 0 replies; 42+ messages in thread
From: Colin Lord @ 2016-07-14 19:02 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, qemu-block, mreitz, Marc Mari, Colin Lord

From: Marc Mari <markmb@redhat.com>

To simplify the addition of new block modules, add a script that generates
module_block.h automatically from the modules' source code.

This script assumes that the QEMU coding style rules are followed.

Signed-off-by: Marc Marí <markmb@redhat.com>
Signed-off-by: Colin Lord <clord@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
---
 Makefile                        |   7 +++
 scripts/modules/module_block.py | 122 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 129 insertions(+)
 create mode 100644 scripts/modules/module_block.py

diff --git a/Makefile b/Makefile
index c054bc6..29035ac 100644
--- a/Makefile
+++ b/Makefile
@@ -76,6 +76,8 @@ GENERATED_HEADERS += trace/generated-ust-provider.h
 GENERATED_SOURCES += trace/generated-ust.c
 endif
 
+GENERATED_HEADERS += module_block.h
+
 # Don't try to regenerate Makefile or configure
 # We don't generate any of them
 Makefile: ;
@@ -352,6 +354,11 @@ ivshmem-client$(EXESUF): $(ivshmem-client-obj-y) libqemuutil.a libqemustub.a
 ivshmem-server$(EXESUF): $(ivshmem-server-obj-y) libqemuutil.a libqemustub.a
 	$(call LINK, $^)
 
+module_block.h: $(SRC_PATH)/scripts/modules/module_block.py config-host.mak
+	$(call quiet-command,$(PYTHON) $< $@ \
+	$(addprefix $(SRC_PATH)/,$(patsubst %.mo,%.c,$(block-obj-m))), \
+	"  GEN   $@")
+
 clean:
 # avoid old build problems by removing potentially incorrect old files
 	rm -f config.mak op-i386.h opc-i386.h gen-op-i386.h op-arm.h opc-arm.h gen-op-arm.h
diff --git a/scripts/modules/module_block.py b/scripts/modules/module_block.py
new file mode 100644
index 0000000..e5040f3
--- /dev/null
+++ b/scripts/modules/module_block.py
@@ -0,0 +1,122 @@
+#!/usr/bin/python
+#
+# Module information generator
+#
+# Copyright Red Hat, Inc. 2015 - 2016
+#
+# Authors:
+#  Marc Mari <markmb@redhat.com>
+#
+# This work is licensed under the terms of the GNU GPL, version 2.
+# See the COPYING file in the top-level directory.
+
+from __future__ import print_function
+import sys
+import os
+
+def get_string_struct(line):
+    data = line.split()
+
+    # data[0] -> struct element name
+    # data[1] -> =
+    # data[2] -> value
+
+    return data[2].replace('"', '')[:-1]
+
+def add_module(fheader, library, format_name, protocol_name,
+                probe, 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,')
+
+    text = '\n        '.join(lines)
+    fheader.write('\n    {\n        ' + text + '\n    },')
+
+def process_file(fheader, filename):
+    # This parser assumes the coding style rules are being followed
+    with open(filename, "r") as cfile:
+        found_something = False
+        found_start = False
+        library, _ = os.path.splitext(os.path.basename(filename))
+        for line in cfile:
+            if found_start:
+                line = line.replace('\n', '')
+                if line.find(".format_name") != -1:
+                    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)
+                    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:
+            print("No BlockDriver struct found in " + filename + ". \
+                    Is this really a module?", file=sys.stderr)
+            sys.exit(1)
+
+def print_top(fheader):
+    fheader.write('''/* AUTOMATICALLY GENERATED, DO NOT MODIFY */
+/*
+ * QEMU Block Module Infrastructure
+ *
+ * Authors:
+ *  Marc Mari       <markmb@redhat.com>
+ */
+
+''')
+
+    fheader.write('''#ifndef QEMU_MODULE_BLOCK_H
+#define QEMU_MODULE_BLOCK_H
+
+#include "qemu-common.h"
+
+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[] = {''')
+
+def print_bottom(fheader):
+    fheader.write('''
+};
+
+#endif
+''')
+
+# First argument: output file
+# All other arguments: modules source files (.c)
+output_file = sys.argv[1]
+with open(output_file, 'w') as fheader:
+    print_top(fheader)
+
+    for filename in sys.argv[2:]:
+        if os.path.isfile(filename):
+            process_file(fheader, filename)
+        else:
+            print("File " + filename + " does not exist.", file=sys.stderr)
+            sys.exit(1)
+
+    print_bottom(fheader)
+
+sys.exit(0)
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [Qemu-devel] [PATCH v4 03/32] blockdev: Add dynamic module loading for block drivers
  2016-07-14 19:02 [Qemu-devel] [PATCH v4 00/32] Dynamic module loading for block drivers Colin Lord
  2016-07-14 19:02 ` [Qemu-devel] [PATCH v4 01/32] blockdev: prepare iSCSI block driver for dynamic loading Colin Lord
  2016-07-14 19:02 ` [Qemu-devel] [PATCH v4 02/32] blockdev: Add dynamic generation of module_block.h Colin Lord
@ 2016-07-14 19:02 ` Colin Lord
  2016-07-14 19:03 ` [Qemu-devel] [PATCH v4 04/32] blockdev: Move bochs probe into separate file Colin Lord
                   ` (29 subsequent siblings)
  32 siblings, 0 replies; 42+ messages in thread
From: Colin Lord @ 2016-07-14 19:02 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, qemu-block, mreitz, Marc Mari, Colin Lord

From: Marc Mari <markmb@redhat.com>

Extend the current module interface to allow for block drivers to be loaded
dynamically on request.

The only block drivers that can be converted into modules are the drivers
that don't perform any init operation except for registering themselves.

All the necessary module information is located in a new structure found in
module_block.h

Signed-off-by: Marc Marí <markmb@redhat.com>
Signed-off-by: Colin Lord <clord@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
---
 block.c               | 110 ++++++++++++++++++++++++++++++++++++++++++--------
 include/qemu/module.h |   3 ++
 util/module.c         |  38 +++++------------
 3 files changed, 108 insertions(+), 43 deletions(-)

diff --git a/block.c b/block.c
index 823ff1d..3a0dc19 100644
--- a/block.c
+++ b/block.c
@@ -26,6 +26,7 @@
 #include "block/block_int.h"
 #include "block/blockjob.h"
 #include "qemu/error-report.h"
+#include "module_block.h"
 #include "qemu/module.h"
 #include "qapi/qmp/qerror.h"
 #include "qapi/qmp/qbool.h"
@@ -239,17 +240,40 @@ BlockDriverState *bdrv_new(void)
     return bs;
 }
 
-BlockDriver *bdrv_find_format(const char *format_name)
+static BlockDriver *bdrv_do_find_format(const char *format_name)
 {
     BlockDriver *drv1;
+
     QLIST_FOREACH(drv1, &bdrv_drivers, list) {
         if (!strcmp(drv1->format_name, format_name)) {
             return drv1;
         }
     }
+
     return NULL;
 }
 
+BlockDriver *bdrv_find_format(const char *format_name)
+{
+    BlockDriver *drv1;
+    size_t i;
+
+    drv1 = bdrv_do_find_format(format_name);
+    if (drv1) {
+        return drv1;
+    }
+
+    /* The driver isn't registered, maybe we need to load a module */
+    for (i = 0; i < ARRAY_SIZE(block_driver_modules); ++i) {
+        if (!strcmp(block_driver_modules[i].format_name, format_name)) {
+            block_module_load_one(block_driver_modules[i].library_name);
+            break;
+        }
+    }
+
+    return bdrv_do_find_format(format_name);
+}
+
 static int bdrv_is_whitelisted(BlockDriver *drv, bool read_only)
 {
     static const char *whitelist_rw[] = {
@@ -443,8 +467,15 @@ int get_tmp_filename(char *filename, int size)
 static BlockDriver *find_hdev_driver(const char *filename)
 {
     int score_max = 0, score;
+    size_t i;
     BlockDriver *drv = NULL, *d;
 
+    for (i = 0; i < ARRAY_SIZE(block_driver_modules); ++i) {
+        if (block_driver_modules[i].has_probe_device) {
+            block_module_load_one(block_driver_modules[i].library_name);
+        }
+    }
+
     QLIST_FOREACH(d, &bdrv_drivers, list) {
         if (d->bdrv_probe_device) {
             score = d->bdrv_probe_device(filename);
@@ -458,6 +489,19 @@ static BlockDriver *find_hdev_driver(const char *filename)
     return drv;
 }
 
+static BlockDriver *bdrv_do_find_protocol(const char *protocol)
+{
+    BlockDriver *drv1;
+
+    QLIST_FOREACH(drv1, &bdrv_drivers, list) {
+        if (drv1->protocol_name && !strcmp(drv1->protocol_name, protocol)) {
+            return drv1;
+        }
+    }
+
+    return NULL;
+}
+
 BlockDriver *bdrv_find_protocol(const char *filename,
                                 bool allow_protocol_prefix,
                                 Error **errp)
@@ -466,6 +510,7 @@ BlockDriver *bdrv_find_protocol(const char *filename,
     char protocol[128];
     int len;
     const char *p;
+    size_t i;
 
     /* TODO Drivers without bdrv_file_open must be specified explicitly */
 
@@ -492,15 +537,25 @@ BlockDriver *bdrv_find_protocol(const char *filename,
         len = sizeof(protocol) - 1;
     memcpy(protocol, filename, len);
     protocol[len] = '\0';
-    QLIST_FOREACH(drv1, &bdrv_drivers, list) {
-        if (drv1->protocol_name &&
-            !strcmp(drv1->protocol_name, protocol)) {
-            return drv1;
+
+    drv1 = bdrv_do_find_protocol(protocol);
+    if (drv1) {
+        return drv1;
+    }
+
+    for (i = 0; i < ARRAY_SIZE(block_driver_modules); ++i) {
+        if (block_driver_modules[i].protocol_name &&
+            !strcmp(block_driver_modules[i].protocol_name, protocol)) {
+            block_module_load_one(block_driver_modules[i].library_name);
+            break;
         }
     }
 
-    error_setg(errp, "Unknown protocol '%s'", protocol);
-    return NULL;
+    drv1 = bdrv_do_find_protocol(protocol);
+    if (!drv1) {
+        error_setg(errp, "Unknown protocol '%s'", protocol);
+    }
+    return drv1;
 }
 
 /*
@@ -521,8 +576,15 @@ BlockDriver *bdrv_probe_all(const uint8_t *buf, int buf_size,
                             const char *filename)
 {
     int score_max = 0, score;
+    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);
@@ -2628,26 +2690,42 @@ static int qsort_strcmp(const void *a, const void *b)
     return strcmp(a, b);
 }
 
+static const char **add_format(const char **formats, int *count,
+                               const char *format_name)
+{
+    int i;
+
+    for (i = 0; i < *count; i++) {
+        if (!strcmp(formats[i], format_name)) {
+            return formats;
+        }
+    }
+
+    formats = g_renew(const char *, formats, *count + 1);
+    formats[*count] = format_name;
+    *count += 1;
+    return formats;
+}
+
 void bdrv_iterate_format(void (*it)(void *opaque, const char *name),
                          void *opaque)
 {
     BlockDriver *drv;
     int count = 0;
     int i;
+    size_t n;
     const char **formats = NULL;
 
     QLIST_FOREACH(drv, &bdrv_drivers, list) {
         if (drv->format_name) {
-            bool found = false;
-            int i = count;
-            while (formats && i && !found) {
-                found = !strcmp(formats[--i], drv->format_name);
-            }
+            formats = add_format(formats, &count, drv->format_name);
+        }
+    }
 
-            if (!found) {
-                formats = g_renew(const char *, formats, count + 1);
-                formats[count++] = drv->format_name;
-            }
+    for (n = 0; n < ARRAY_SIZE(block_driver_modules); n++) {
+        if (block_driver_modules[n].format_name) {
+            formats = add_format(formats, &count,
+                                 block_driver_modules[n].format_name);
         }
     }
 
diff --git a/include/qemu/module.h b/include/qemu/module.h
index 2370708..dc2c9d4 100644
--- a/include/qemu/module.h
+++ b/include/qemu/module.h
@@ -52,9 +52,12 @@ typedef enum {
 #define qapi_init(function) module_init(function, MODULE_INIT_QAPI)
 #define type_init(function) module_init(function, MODULE_INIT_QOM)
 
+#define block_module_load_one(lib) module_load_one("block-", lib)
+
 void register_module_init(void (*fn)(void), module_init_type type);
 void register_dso_module_init(void (*fn)(void), module_init_type type);
 
 void module_call_init(module_init_type type);
+void module_load_one(const char *prefix, const char *lib_name);
 
 #endif
diff --git a/util/module.c b/util/module.c
index 86e3f7a..a5f7fbd 100644
--- a/util/module.c
+++ b/util/module.c
@@ -87,14 +87,11 @@ void register_dso_module_init(void (*fn)(void), module_init_type type)
     QTAILQ_INSERT_TAIL(&dso_init_list, e, node);
 }
 
-static void module_load(module_init_type type);
-
 void module_call_init(module_init_type type)
 {
     ModuleTypeList *l;
     ModuleEntry *e;
 
-    module_load(type);
     l = find_type(type);
 
     QTAILQ_FOREACH(e, l, node) {
@@ -145,6 +142,7 @@ static int module_load_file(const char *fname)
         ret = -EINVAL;
     } else {
         QTAILQ_FOREACH(e, &dso_init_list, node) {
+            e->init();
             register_module_init(e->init, e->type);
         }
         ret = 0;
@@ -159,14 +157,10 @@ out:
 }
 #endif
 
-static void module_load(module_init_type type)
+void module_load_one(const char *prefix, const char *lib_name)
 {
 #ifdef CONFIG_MODULES
     char *fname = NULL;
-    const char **mp;
-    static const char *block_modules[] = {
-        CONFIG_BLOCK_MODULES
-    };
     char *exec_dir;
     char *dirs[3];
     int i = 0;
@@ -177,15 +171,6 @@ static void module_load(module_init_type type)
         return;
     }
 
-    switch (type) {
-    case MODULE_INIT_BLOCK:
-        mp = block_modules;
-        break;
-    default:
-        /* no other types have dynamic modules for now*/
-        return;
-    }
-
     exec_dir = qemu_get_exec_dir();
     dirs[i++] = g_strdup_printf("%s", CONFIG_QEMU_MODDIR);
     dirs[i++] = g_strdup_printf("%s/..", exec_dir ? : "");
@@ -194,16 +179,15 @@ static void module_load(module_init_type type)
     g_free(exec_dir);
     exec_dir = NULL;
 
-    for ( ; *mp; mp++) {
-        for (i = 0; i < ARRAY_SIZE(dirs); i++) {
-            fname = g_strdup_printf("%s/%s%s", dirs[i], *mp, HOST_DSOSUF);
-            ret = module_load_file(fname);
-            g_free(fname);
-            fname = NULL;
-            /* Try loading until loaded a module file */
-            if (!ret) {
-                break;
-            }
+    for (i = 0; i < ARRAY_SIZE(dirs); i++) {
+        fname = g_strdup_printf("%s/%s%s%s",
+                dirs[i], prefix, lib_name, HOST_DSOSUF);
+        ret = module_load_file(fname);
+        g_free(fname);
+        fname = NULL;
+        /* Try loading until loaded a module file */
+        if (!ret) {
+            break;
         }
     }
 
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [Qemu-devel] [PATCH v4 04/32] blockdev: Move bochs probe into separate file
  2016-07-14 19:02 [Qemu-devel] [PATCH v4 00/32] Dynamic module loading for block drivers Colin Lord
                   ` (2 preceding siblings ...)
  2016-07-14 19:02 ` [Qemu-devel] [PATCH v4 03/32] blockdev: Add dynamic module loading for block drivers Colin Lord
@ 2016-07-14 19:03 ` Colin Lord
  2016-07-14 19:03 ` [Qemu-devel] [PATCH v4 05/32] blockdev: Move cloop probe to its own file Colin Lord
                   ` (28 subsequent siblings)
  32 siblings, 0 replies; 42+ messages in thread
From: Colin Lord @ 2016-07-14 19:03 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, qemu-block, mreitz, Colin Lord

This puts the bochs probe function into its own separate file as part of
the process of modularizing block drivers. Having the probe functions
separate from the rest of the driver allows us to probe without having
to potentially unnecessarily load the driver.

Signed-off-by: Colin Lord <clord@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
---
 block/Makefile.objs   |  1 +
 block/bochs-probe.c   | 21 ++++++++++++++++++++
 block/bochs.c         | 55 ++-------------------------------------------------
 block/bochs.h         | 40 +++++++++++++++++++++++++++++++++++++
 include/block/probe.h |  6 ++++++
 5 files changed, 70 insertions(+), 53 deletions(-)
 create mode 100644 block/bochs-probe.c
 create mode 100644 block/bochs.h
 create mode 100644 include/block/probe.h

diff --git a/block/Makefile.objs b/block/Makefile.objs
index 2593a2f..9d4be3b 100644
--- a/block/Makefile.objs
+++ b/block/Makefile.objs
@@ -24,6 +24,7 @@ block-obj-y += accounting.o dirty-bitmap.o
 block-obj-y += write-threshold.o
 
 block-obj-y += crypto.o
+block-obj-y += bochs-probe.o
 
 common-obj-y += stream.o
 common-obj-y += backup.o
diff --git a/block/bochs-probe.c b/block/bochs-probe.c
new file mode 100644
index 0000000..befe2cf
--- /dev/null
+++ b/block/bochs-probe.c
@@ -0,0 +1,21 @@
+#include "qemu/osdep.h"
+#include "block/block_int.h"
+#include "block/probe.h"
+#include "bochs.h"
+
+int bochs_probe(const uint8_t *buf, int buf_size, const char *filename)
+{
+    const struct bochs_header *bochs = (const void *)buf;
+
+    if (buf_size < HEADER_SIZE)
+	return 0;
+
+    if (!strcmp(bochs->magic, HEADER_MAGIC) &&
+	!strcmp(bochs->type, REDOLOG_TYPE) &&
+	!strcmp(bochs->subtype, GROWING_TYPE) &&
+	((le32_to_cpu(bochs->version) == HEADER_VERSION) ||
+	(le32_to_cpu(bochs->version) == HEADER_V1)))
+	return 100;
+
+    return 0;
+}
diff --git a/block/bochs.c b/block/bochs.c
index 8c9652e..5c9a696 100644
--- a/block/bochs.c
+++ b/block/bochs.c
@@ -28,45 +28,11 @@
 #include "block/block_int.h"
 #include "qemu/module.h"
 #include "qemu/bswap.h"
+#include "bochs.h"
+#include "block/probe.h"
 
 /**************************************************************/
 
-#define HEADER_MAGIC "Bochs Virtual HD Image"
-#define HEADER_VERSION 0x00020000
-#define HEADER_V1 0x00010000
-#define HEADER_SIZE 512
-
-#define REDOLOG_TYPE "Redolog"
-#define GROWING_TYPE "Growing"
-
-// not allocated: 0xffffffff
-
-// always little-endian
-struct bochs_header {
-    char magic[32];     /* "Bochs Virtual HD Image" */
-    char type[16];      /* "Redolog" */
-    char subtype[16];   /* "Undoable" / "Volatile" / "Growing" */
-    uint32_t version;
-    uint32_t header;    /* size of header */
-
-    uint32_t catalog;   /* num of entries */
-    uint32_t bitmap;    /* bitmap size */
-    uint32_t extent;    /* extent size */
-
-    union {
-        struct {
-            uint32_t reserved;  /* for ??? */
-            uint64_t disk;      /* disk size */
-            char padding[HEADER_SIZE - 64 - 20 - 12];
-        } QEMU_PACKED redolog;
-        struct {
-            uint64_t disk;      /* disk size */
-            char padding[HEADER_SIZE - 64 - 20 - 8];
-        } QEMU_PACKED redolog_v1;
-        char padding[HEADER_SIZE - 64 - 20];
-    } extra;
-} QEMU_PACKED;
-
 typedef struct BDRVBochsState {
     CoMutex lock;
     uint32_t *catalog_bitmap;
@@ -79,23 +45,6 @@ typedef struct BDRVBochsState {
     uint32_t extent_size;
 } BDRVBochsState;
 
-static int bochs_probe(const uint8_t *buf, int buf_size, const char *filename)
-{
-    const struct bochs_header *bochs = (const void *)buf;
-
-    if (buf_size < HEADER_SIZE)
-	return 0;
-
-    if (!strcmp(bochs->magic, HEADER_MAGIC) &&
-	!strcmp(bochs->type, REDOLOG_TYPE) &&
-	!strcmp(bochs->subtype, GROWING_TYPE) &&
-	((le32_to_cpu(bochs->version) == HEADER_VERSION) ||
-	(le32_to_cpu(bochs->version) == HEADER_V1)))
-	return 100;
-
-    return 0;
-}
-
 static int bochs_open(BlockDriverState *bs, QDict *options, int flags,
                       Error **errp)
 {
diff --git a/block/bochs.h b/block/bochs.h
new file mode 100644
index 0000000..2883f7d
--- /dev/null
+++ b/block/bochs.h
@@ -0,0 +1,40 @@
+#ifndef BLOCK_BOCHS_H
+#define BLOCK_BOCHS_H
+
+#define HEADER_MAGIC "Bochs Virtual HD Image"
+#define HEADER_VERSION 0x00020000
+#define HEADER_V1 0x00010000
+#define HEADER_SIZE 512
+
+#define REDOLOG_TYPE "Redolog"
+#define GROWING_TYPE "Growing"
+
+// not allocated: 0xffffffff
+
+// always little-endian
+struct bochs_header {
+    char magic[32];     /* "Bochs Virtual HD Image" */
+    char type[16];      /* "Redolog" */
+    char subtype[16];   /* "Undoable" / "Volatile" / "Growing" */
+    uint32_t version;
+    uint32_t header;    /* size of header */
+
+    uint32_t catalog;   /* num of entries */
+    uint32_t bitmap;    /* bitmap size */
+    uint32_t extent;    /* extent size */
+
+    union {
+        struct {
+            uint32_t reserved;  /* for ??? */
+            uint64_t disk;      /* disk size */
+            char padding[HEADER_SIZE - 64 - 20 - 12];
+        } QEMU_PACKED redolog;
+        struct {
+            uint64_t disk;      /* disk size */
+            char padding[HEADER_SIZE - 64 - 20 - 8];
+        } QEMU_PACKED redolog_v1;
+        char padding[HEADER_SIZE - 64 - 20];
+    } extra;
+} QEMU_PACKED;
+
+#endif
diff --git a/include/block/probe.h b/include/block/probe.h
new file mode 100644
index 0000000..6450ca1
--- /dev/null
+++ b/include/block/probe.h
@@ -0,0 +1,6 @@
+#ifndef PROBE_H
+#define PROBE_H
+
+int bochs_probe(const uint8_t *buf, int buf_size, const char *filename);
+
+#endif
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [Qemu-devel] [PATCH v4 05/32] blockdev: Move cloop probe to its own file
  2016-07-14 19:02 [Qemu-devel] [PATCH v4 00/32] Dynamic module loading for block drivers Colin Lord
                   ` (3 preceding siblings ...)
  2016-07-14 19:03 ` [Qemu-devel] [PATCH v4 04/32] blockdev: Move bochs probe into separate file Colin Lord
@ 2016-07-14 19:03 ` Colin Lord
  2016-07-14 19:03 ` [Qemu-devel] [PATCH v4 06/32] blockdev: Move luks " Colin Lord
                   ` (27 subsequent siblings)
  32 siblings, 0 replies; 42+ messages in thread
From: Colin Lord @ 2016-07-14 19:03 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, qemu-block, mreitz, Colin Lord

Isolates cloop probing function as part of the modularization process.

Signed-off-by: Colin Lord <clord@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
---
 block/Makefile.objs   |  2 +-
 block/cloop-probe.c   | 17 +++++++++++++++++
 block/cloop.c         | 16 +---------------
 include/block/probe.h |  1 +
 4 files changed, 20 insertions(+), 16 deletions(-)
 create mode 100644 block/cloop-probe.c

diff --git a/block/Makefile.objs b/block/Makefile.objs
index 9d4be3b..1a8d7c0 100644
--- a/block/Makefile.objs
+++ b/block/Makefile.objs
@@ -24,7 +24,7 @@ block-obj-y += accounting.o dirty-bitmap.o
 block-obj-y += write-threshold.o
 
 block-obj-y += crypto.o
-block-obj-y += bochs-probe.o
+block-obj-y += bochs-probe.o cloop-probe.o
 
 common-obj-y += stream.o
 common-obj-y += backup.o
diff --git a/block/cloop-probe.c b/block/cloop-probe.c
new file mode 100644
index 0000000..955c29c
--- /dev/null
+++ b/block/cloop-probe.c
@@ -0,0 +1,17 @@
+#include "qemu/osdep.h"
+#include "block/probe.h"
+
+int cloop_probe(const uint8_t *buf, int buf_size, const char *filename)
+{
+    const char *magic_version_2_0 = "#!/bin/sh\n"
+        "#V2.0 Format\n"
+        "modprobe cloop file=$0 && mount -r -t iso9660 /dev/cloop $1\n";
+    int length = strlen(magic_version_2_0);
+    if (length > buf_size) {
+        length = buf_size;
+    }
+    if (!memcmp(magic_version_2_0, buf, length)) {
+        return 2;
+    }
+    return 0;
+}
diff --git a/block/cloop.c b/block/cloop.c
index 7b75f7e..c897e58 100644
--- a/block/cloop.c
+++ b/block/cloop.c
@@ -25,6 +25,7 @@
 #include "qapi/error.h"
 #include "qemu-common.h"
 #include "block/block_int.h"
+#include "block/probe.h"
 #include "qemu/module.h"
 #include "qemu/bswap.h"
 #include <zlib.h>
@@ -44,21 +45,6 @@ typedef struct BDRVCloopState {
     z_stream zstream;
 } BDRVCloopState;
 
-static int cloop_probe(const uint8_t *buf, int buf_size, const char *filename)
-{
-    const char *magic_version_2_0 = "#!/bin/sh\n"
-        "#V2.0 Format\n"
-        "modprobe cloop file=$0 && mount -r -t iso9660 /dev/cloop $1\n";
-    int length = strlen(magic_version_2_0);
-    if (length > buf_size) {
-        length = buf_size;
-    }
-    if (!memcmp(magic_version_2_0, buf, length)) {
-        return 2;
-    }
-    return 0;
-}
-
 static int cloop_open(BlockDriverState *bs, QDict *options, int flags,
                       Error **errp)
 {
diff --git a/include/block/probe.h b/include/block/probe.h
index 6450ca1..ed1a60b 100644
--- a/include/block/probe.h
+++ b/include/block/probe.h
@@ -2,5 +2,6 @@
 #define PROBE_H
 
 int bochs_probe(const uint8_t *buf, int buf_size, const char *filename);
+int cloop_probe(const uint8_t *buf, int buf_size, const char *filename);
 
 #endif
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [Qemu-devel] [PATCH v4 06/32] blockdev: Move luks probe to its own file
  2016-07-14 19:02 [Qemu-devel] [PATCH v4 00/32] Dynamic module loading for block drivers Colin Lord
                   ` (4 preceding siblings ...)
  2016-07-14 19:03 ` [Qemu-devel] [PATCH v4 05/32] blockdev: Move cloop probe to its own file Colin Lord
@ 2016-07-14 19:03 ` Colin Lord
  2016-07-14 19:03 ` [Qemu-devel] [PATCH v4 07/32] blockdev: Move dmg " Colin Lord
                   ` (26 subsequent siblings)
  32 siblings, 0 replies; 42+ messages in thread
From: Colin Lord @ 2016-07-14 19:03 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, qemu-block, mreitz, Colin Lord

Isolates the luks probe function as part of the modularization process.

Signed-off-by: Colin Lord <clord@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
---
 block/Makefile.objs   |  2 +-
 block/crypto-probe.c  | 23 +++++++++++++++++++++++
 block/crypto.c        | 21 +--------------------
 include/block/probe.h |  2 ++
 4 files changed, 27 insertions(+), 21 deletions(-)
 create mode 100644 block/crypto-probe.c

diff --git a/block/Makefile.objs b/block/Makefile.objs
index 1a8d7c0..aca547f 100644
--- a/block/Makefile.objs
+++ b/block/Makefile.objs
@@ -24,7 +24,7 @@ block-obj-y += accounting.o dirty-bitmap.o
 block-obj-y += write-threshold.o
 
 block-obj-y += crypto.o
-block-obj-y += bochs-probe.o cloop-probe.o
+block-obj-y += bochs-probe.o cloop-probe.o crypto-probe.o
 
 common-obj-y += stream.o
 common-obj-y += backup.o
diff --git a/block/crypto-probe.c b/block/crypto-probe.c
new file mode 100644
index 0000000..5c6427a
--- /dev/null
+++ b/block/crypto-probe.c
@@ -0,0 +1,23 @@
+#include "qemu/osdep.h"
+#include "qapi-types.h"
+#include "block/probe.h"
+#include "crypto/block.h"
+
+static int block_crypto_probe_generic(QCryptoBlockFormat format,
+                                      const uint8_t *buf,
+                                      int buf_size,
+                                      const char *filename)
+{
+    if (qcrypto_block_has_format(format, buf, buf_size)) {
+        return 100;
+    } else {
+        return 0;
+    }
+}
+
+int block_crypto_probe_luks(const uint8_t *buf,
+                                   int buf_size,
+                                   const char *filename) {
+    return block_crypto_probe_generic(Q_CRYPTO_BLOCK_FORMAT_LUKS,
+                                      buf, buf_size, filename);
+}
diff --git a/block/crypto.c b/block/crypto.c
index 7eaa057..5706ba6 100644
--- a/block/crypto.c
+++ b/block/crypto.c
@@ -21,6 +21,7 @@
 #include "qemu/osdep.h"
 
 #include "block/block_int.h"
+#include "block/probe.h"
 #include "sysemu/block-backend.h"
 #include "crypto/block.h"
 #include "qapi/opts-visitor.h"
@@ -41,19 +42,6 @@ struct BlockCrypto {
 };
 
 
-static int block_crypto_probe_generic(QCryptoBlockFormat format,
-                                      const uint8_t *buf,
-                                      int buf_size,
-                                      const char *filename)
-{
-    if (qcrypto_block_has_format(format, buf, buf_size)) {
-        return 100;
-    } else {
-        return 0;
-    }
-}
-
-
 static ssize_t block_crypto_read_func(QCryptoBlock *block,
                                       size_t offset,
                                       uint8_t *buf,
@@ -538,13 +526,6 @@ static int64_t block_crypto_getlength(BlockDriverState *bs)
 }
 
 
-static int block_crypto_probe_luks(const uint8_t *buf,
-                                   int buf_size,
-                                   const char *filename) {
-    return block_crypto_probe_generic(Q_CRYPTO_BLOCK_FORMAT_LUKS,
-                                      buf, buf_size, filename);
-}
-
 static int block_crypto_open_luks(BlockDriverState *bs,
                                   QDict *options,
                                   int flags,
diff --git a/include/block/probe.h b/include/block/probe.h
index ed1a60b..35a8d00 100644
--- a/include/block/probe.h
+++ b/include/block/probe.h
@@ -3,5 +3,7 @@
 
 int bochs_probe(const uint8_t *buf, int buf_size, const char *filename);
 int cloop_probe(const uint8_t *buf, int buf_size, const char *filename);
+int block_crypto_probe_luks(const uint8_t *buf, int buf_size,
+                            const char *filename);
 
 #endif
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [Qemu-devel] [PATCH v4 07/32] blockdev: Move dmg probe to its own file
  2016-07-14 19:02 [Qemu-devel] [PATCH v4 00/32] Dynamic module loading for block drivers Colin Lord
                   ` (5 preceding siblings ...)
  2016-07-14 19:03 ` [Qemu-devel] [PATCH v4 06/32] blockdev: Move luks " Colin Lord
@ 2016-07-14 19:03 ` Colin Lord
  2016-07-14 19:03 ` [Qemu-devel] [PATCH v4 08/32] blockdev: Move parallels " Colin Lord
                   ` (25 subsequent siblings)
  32 siblings, 0 replies; 42+ messages in thread
From: Colin Lord @ 2016-07-14 19:03 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, qemu-block, mreitz, Colin Lord

Isolate dmg probe as part of the modularization process.

Signed-off-by: Colin Lord <clord@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
---
 block/Makefile.objs   |  2 +-
 block/dmg-probe.c     | 17 +++++++++++++++++
 block/dmg.c           | 16 +---------------
 include/block/probe.h |  1 +
 4 files changed, 20 insertions(+), 16 deletions(-)
 create mode 100644 block/dmg-probe.c

diff --git a/block/Makefile.objs b/block/Makefile.objs
index aca547f..09cc64c 100644
--- a/block/Makefile.objs
+++ b/block/Makefile.objs
@@ -24,7 +24,7 @@ block-obj-y += accounting.o dirty-bitmap.o
 block-obj-y += write-threshold.o
 
 block-obj-y += crypto.o
-block-obj-y += bochs-probe.o cloop-probe.o crypto-probe.o
+block-obj-y += bochs-probe.o cloop-probe.o crypto-probe.o dmg-probe.o
 
 common-obj-y += stream.o
 common-obj-y += backup.o
diff --git a/block/dmg-probe.c b/block/dmg-probe.c
new file mode 100644
index 0000000..a40281b
--- /dev/null
+++ b/block/dmg-probe.c
@@ -0,0 +1,17 @@
+#include "qemu/osdep.h"
+#include "block/probe.h"
+
+int dmg_probe(const uint8_t *buf, int buf_size, const char *filename)
+{
+    int len;
+
+    if (!filename) {
+        return 0;
+    }
+
+    len = strlen(filename);
+    if (len > 4 && !strcmp(filename + len - 4, ".dmg")) {
+        return 2;
+    }
+    return 0;
+}
diff --git a/block/dmg.c b/block/dmg.c
index b0ed89b..4bbb079 100644
--- a/block/dmg.c
+++ b/block/dmg.c
@@ -25,6 +25,7 @@
 #include "qapi/error.h"
 #include "qemu-common.h"
 #include "block/block_int.h"
+#include "block/probe.h"
 #include "qemu/bswap.h"
 #include "qemu/error-report.h"
 #include "qemu/module.h"
@@ -66,21 +67,6 @@ typedef struct BDRVDMGState {
 #endif
 } BDRVDMGState;
 
-static int dmg_probe(const uint8_t *buf, int buf_size, const char *filename)
-{
-    int len;
-
-    if (!filename) {
-        return 0;
-    }
-
-    len = strlen(filename);
-    if (len > 4 && !strcmp(filename + len - 4, ".dmg")) {
-        return 2;
-    }
-    return 0;
-}
-
 static int read_uint64(BlockDriverState *bs, int64_t offset, uint64_t *result)
 {
     uint64_t buffer;
diff --git a/include/block/probe.h b/include/block/probe.h
index 35a8d00..267431d 100644
--- a/include/block/probe.h
+++ b/include/block/probe.h
@@ -5,5 +5,6 @@ int bochs_probe(const uint8_t *buf, int buf_size, const char *filename);
 int cloop_probe(const uint8_t *buf, int buf_size, const char *filename);
 int block_crypto_probe_luks(const uint8_t *buf, int buf_size,
                             const char *filename);
+int dmg_probe(const uint8_t *buf, int buf_size, const char *filename);
 
 #endif
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [Qemu-devel] [PATCH v4 08/32] blockdev: Move parallels probe to its own file
  2016-07-14 19:02 [Qemu-devel] [PATCH v4 00/32] Dynamic module loading for block drivers Colin Lord
                   ` (6 preceding siblings ...)
  2016-07-14 19:03 ` [Qemu-devel] [PATCH v4 07/32] blockdev: Move dmg " Colin Lord
@ 2016-07-14 19:03 ` Colin Lord
  2016-07-14 19:03 ` [Qemu-devel] [PATCH v4 09/32] blockdev: Move qcow " Colin Lord
                   ` (24 subsequent siblings)
  32 siblings, 0 replies; 42+ messages in thread
From: Colin Lord @ 2016-07-14 19:03 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, qemu-block, mreitz, Colin Lord

Isolate parallels probe as part of the modularization process.

Signed-off-by: Colin Lord <clord@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
---
 block/Makefile.objs     |  1 +
 block/parallels-probe.c | 21 +++++++++++++++++++++
 block/parallels.c       | 43 ++-----------------------------------------
 block/parallels.h       | 26 ++++++++++++++++++++++++++
 include/block/probe.h   |  1 +
 5 files changed, 51 insertions(+), 41 deletions(-)
 create mode 100644 block/parallels-probe.c
 create mode 100644 block/parallels.h

diff --git a/block/Makefile.objs b/block/Makefile.objs
index 09cc64c..43724ec 100644
--- a/block/Makefile.objs
+++ b/block/Makefile.objs
@@ -25,6 +25,7 @@ block-obj-y += write-threshold.o
 
 block-obj-y += crypto.o
 block-obj-y += bochs-probe.o cloop-probe.o crypto-probe.o dmg-probe.o
+block-obj-y += parallels-probe.o
 
 common-obj-y += stream.o
 common-obj-y += backup.o
diff --git a/block/parallels-probe.c b/block/parallels-probe.c
new file mode 100644
index 0000000..ff2f6ba
--- /dev/null
+++ b/block/parallels-probe.c
@@ -0,0 +1,21 @@
+#include "qemu/osdep.h"
+#include "block/block_int.h"
+#include "block/probe.h"
+#include "parallels.h"
+
+int parallels_probe(const uint8_t *buf, int buf_size, const char *filename)
+{
+    const ParallelsHeader *ph = (const void *)buf;
+
+    if (buf_size < sizeof(ParallelsHeader)) {
+        return 0;
+    }
+
+    if ((!memcmp(ph->magic, HEADER_MAGIC, 16) ||
+           !memcmp(ph->magic, HEADER_MAGIC2, 16)) &&
+           (le32_to_cpu(ph->version) == HEADER_VERSION)) {
+        return 100;
+    }
+
+    return 0;
+}
diff --git a/block/parallels.c b/block/parallels.c
index 807a801..70e9439 100644
--- a/block/parallels.c
+++ b/block/parallels.c
@@ -31,6 +31,8 @@
 #include "qapi/error.h"
 #include "qemu-common.h"
 #include "block/block_int.h"
+#include "block/probe.h"
+#include "parallels.h"
 #include "sysemu/block-backend.h"
 #include "qemu/module.h"
 #include "qemu/bswap.h"
@@ -39,29 +41,6 @@
 
 /**************************************************************/
 
-#define HEADER_MAGIC "WithoutFreeSpace"
-#define HEADER_MAGIC2 "WithouFreSpacExt"
-#define HEADER_VERSION 2
-#define HEADER_INUSE_MAGIC  (0x746F6E59)
-
-#define DEFAULT_CLUSTER_SIZE 1048576        /* 1 MiB */
-
-
-// always little-endian
-typedef struct ParallelsHeader {
-    char magic[16]; // "WithoutFreeSpace"
-    uint32_t version;
-    uint32_t heads;
-    uint32_t cylinders;
-    uint32_t tracks;
-    uint32_t bat_entries;
-    uint64_t nb_sectors;
-    uint32_t inuse;
-    uint32_t data_off;
-    char padding[12];
-} QEMU_PACKED ParallelsHeader;
-
-
 typedef enum ParallelsPreallocMode {
     PRL_PREALLOC_MODE_FALLOCATE = 0,
     PRL_PREALLOC_MODE_TRUNCATE = 1,
@@ -536,24 +515,6 @@ exit:
 }
 
 
-static int parallels_probe(const uint8_t *buf, int buf_size,
-                           const char *filename)
-{
-    const ParallelsHeader *ph = (const void *)buf;
-
-    if (buf_size < sizeof(ParallelsHeader)) {
-        return 0;
-    }
-
-    if ((!memcmp(ph->magic, HEADER_MAGIC, 16) ||
-           !memcmp(ph->magic, HEADER_MAGIC2, 16)) &&
-           (le32_to_cpu(ph->version) == HEADER_VERSION)) {
-        return 100;
-    }
-
-    return 0;
-}
-
 static int parallels_update_header(BlockDriverState *bs)
 {
     BDRVParallelsState *s = bs->opaque;
diff --git a/block/parallels.h b/block/parallels.h
new file mode 100644
index 0000000..512ef5f
--- /dev/null
+++ b/block/parallels.h
@@ -0,0 +1,26 @@
+#ifndef PARALLELS_H
+#define PARALLELS_H
+
+#define HEADER_MAGIC "WithoutFreeSpace"
+#define HEADER_MAGIC2 "WithouFreSpacExt"
+#define HEADER_VERSION 2
+#define HEADER_INUSE_MAGIC  (0x746F6E59)
+
+#define DEFAULT_CLUSTER_SIZE 1048576        /* 1 MiB */
+
+
+// always little-endian
+typedef struct ParallelsHeader {
+    char magic[16]; // "WithoutFreeSpace"
+    uint32_t version;
+    uint32_t heads;
+    uint32_t cylinders;
+    uint32_t tracks;
+    uint32_t bat_entries;
+    uint64_t nb_sectors;
+    uint32_t inuse;
+    uint32_t data_off;
+    char padding[12];
+} QEMU_PACKED ParallelsHeader;
+
+#endif
diff --git a/include/block/probe.h b/include/block/probe.h
index 267431d..f8b0984 100644
--- a/include/block/probe.h
+++ b/include/block/probe.h
@@ -6,5 +6,6 @@ int cloop_probe(const uint8_t *buf, int buf_size, const char *filename);
 int block_crypto_probe_luks(const uint8_t *buf, int buf_size,
                             const char *filename);
 int dmg_probe(const uint8_t *buf, int buf_size, const char *filename);
+int parallels_probe(const uint8_t *buf, int buf_size, const char *filename);
 
 #endif
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [Qemu-devel] [PATCH v4 09/32] blockdev: Move qcow probe to its own file
  2016-07-14 19:02 [Qemu-devel] [PATCH v4 00/32] Dynamic module loading for block drivers Colin Lord
                   ` (7 preceding siblings ...)
  2016-07-14 19:03 ` [Qemu-devel] [PATCH v4 08/32] blockdev: Move parallels " Colin Lord
@ 2016-07-14 19:03 ` Colin Lord
  2016-07-14 19:03 ` [Qemu-devel] [PATCH v4 10/32] blockdev: Move qcow2 " Colin Lord
                   ` (23 subsequent siblings)
  32 siblings, 0 replies; 42+ messages in thread
From: Colin Lord @ 2016-07-14 19:03 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, qemu-block, mreitz, Colin Lord

Isolates qcow probe as part of the modularization process.

Signed-off-by: Colin Lord <clord@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
---
 block/Makefile.objs   |  2 +-
 block/qcow-probe.c    | 16 ++++++++++++++++
 block/qcow.c          | 31 ++-----------------------------
 block/qcow.h          | 21 +++++++++++++++++++++
 include/block/probe.h |  1 +
 5 files changed, 41 insertions(+), 30 deletions(-)
 create mode 100644 block/qcow-probe.c
 create mode 100644 block/qcow.h

diff --git a/block/Makefile.objs b/block/Makefile.objs
index 43724ec..01b2e4e 100644
--- a/block/Makefile.objs
+++ b/block/Makefile.objs
@@ -25,7 +25,7 @@ block-obj-y += write-threshold.o
 
 block-obj-y += crypto.o
 block-obj-y += bochs-probe.o cloop-probe.o crypto-probe.o dmg-probe.o
-block-obj-y += parallels-probe.o
+block-obj-y += parallels-probe.o qcow-probe.o
 
 common-obj-y += stream.o
 common-obj-y += backup.o
diff --git a/block/qcow-probe.c b/block/qcow-probe.c
new file mode 100644
index 0000000..c5fd214
--- /dev/null
+++ b/block/qcow-probe.c
@@ -0,0 +1,16 @@
+#include "qemu/osdep.h"
+#include "block/block_int.h"
+#include "block/probe.h"
+#include "qcow.h"
+
+int qcow_probe(const uint8_t *buf, int buf_size, const char *filename)
+{
+    const QCowHeader *cow_header = (const void *)buf;
+
+    if (buf_size >= sizeof(QCowHeader) &&
+        be32_to_cpu(cow_header->magic) == QCOW_MAGIC &&
+        be32_to_cpu(cow_header->version) == QCOW_VERSION)
+        return 100;
+    else
+        return 0;
+}
diff --git a/block/qcow.c b/block/qcow.c
index ac849bd..6ea1164 100644
--- a/block/qcow.c
+++ b/block/qcow.c
@@ -26,6 +26,8 @@
 #include "qemu-common.h"
 #include "qemu/error-report.h"
 #include "block/block_int.h"
+#include "block/probe.h"
+#include "qcow.h"
 #include "sysemu/block-backend.h"
 #include "qemu/module.h"
 #include "qemu/bswap.h"
@@ -37,28 +39,11 @@
 /**************************************************************/
 /* QEMU COW block driver with compression and encryption support */
 
-#define QCOW_MAGIC (('Q' << 24) | ('F' << 16) | ('I' << 8) | 0xfb)
-#define QCOW_VERSION 1
-
 #define QCOW_CRYPT_NONE 0
 #define QCOW_CRYPT_AES  1
 
 #define QCOW_OFLAG_COMPRESSED (1LL << 63)
 
-typedef struct QCowHeader {
-    uint32_t magic;
-    uint32_t version;
-    uint64_t backing_file_offset;
-    uint32_t backing_file_size;
-    uint32_t mtime;
-    uint64_t size; /* in bytes */
-    uint8_t cluster_bits;
-    uint8_t l2_bits;
-    uint16_t padding;
-    uint32_t crypt_method;
-    uint64_t l1_table_offset;
-} QEMU_PACKED QCowHeader;
-
 #define L2_CACHE_SIZE 16
 
 typedef struct BDRVQcowState {
@@ -85,18 +70,6 @@ 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)
-{
-    const QCowHeader *cow_header = (const void *)buf;
-
-    if (buf_size >= sizeof(QCowHeader) &&
-        be32_to_cpu(cow_header->magic) == QCOW_MAGIC &&
-        be32_to_cpu(cow_header->version) == QCOW_VERSION)
-        return 100;
-    else
-        return 0;
-}
-
 static int qcow_open(BlockDriverState *bs, QDict *options, int flags,
                      Error **errp)
 {
diff --git a/block/qcow.h b/block/qcow.h
new file mode 100644
index 0000000..c96ea24
--- /dev/null
+++ b/block/qcow.h
@@ -0,0 +1,21 @@
+#ifndef QCOW_H
+#define QCOW_H
+
+#define QCOW_MAGIC (('Q' << 24) | ('F' << 16) | ('I' << 8) | 0xfb)
+#define QCOW_VERSION 1
+
+typedef struct QCowHeader {
+    uint32_t magic;
+    uint32_t version;
+    uint64_t backing_file_offset;
+    uint32_t backing_file_size;
+    uint32_t mtime;
+    uint64_t size; /* in bytes */
+    uint8_t cluster_bits;
+    uint8_t l2_bits;
+    uint16_t padding;
+    uint32_t crypt_method;
+    uint64_t l1_table_offset;
+} QEMU_PACKED QCowHeader;
+
+#endif
diff --git a/include/block/probe.h b/include/block/probe.h
index f8b0984..5230da4 100644
--- a/include/block/probe.h
+++ b/include/block/probe.h
@@ -7,5 +7,6 @@ int block_crypto_probe_luks(const uint8_t *buf, int buf_size,
                             const char *filename);
 int dmg_probe(const uint8_t *buf, int buf_size, const char *filename);
 int parallels_probe(const uint8_t *buf, int buf_size, const char *filename);
+int qcow_probe(const uint8_t *buf, int buf_size, const char *filename);
 
 #endif
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [Qemu-devel] [PATCH v4 10/32] blockdev: Move qcow2 probe to its own file
  2016-07-14 19:02 [Qemu-devel] [PATCH v4 00/32] Dynamic module loading for block drivers Colin Lord
                   ` (8 preceding siblings ...)
  2016-07-14 19:03 ` [Qemu-devel] [PATCH v4 09/32] blockdev: Move qcow " Colin Lord
@ 2016-07-14 19:03 ` Colin Lord
  2016-07-14 19:03 ` [Qemu-devel] [PATCH v4 11/32] blockdev: Move qed " Colin Lord
                   ` (22 subsequent siblings)
  32 siblings, 0 replies; 42+ messages in thread
From: Colin Lord @ 2016-07-14 19:03 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, qemu-block, mreitz, Colin Lord

Isolates qcow2 probe as part of the modularization process.

Signed-off-by: Colin Lord <clord@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
---
 block/Makefile.objs   |  2 +-
 block/qcow2-probe.c   | 16 ++++++++++++++++
 block/qcow2.c         | 13 +------------
 include/block/probe.h |  1 +
 4 files changed, 19 insertions(+), 13 deletions(-)
 create mode 100644 block/qcow2-probe.c

diff --git a/block/Makefile.objs b/block/Makefile.objs
index 01b2e4e..4a27bde 100644
--- a/block/Makefile.objs
+++ b/block/Makefile.objs
@@ -25,7 +25,7 @@ block-obj-y += write-threshold.o
 
 block-obj-y += crypto.o
 block-obj-y += bochs-probe.o cloop-probe.o crypto-probe.o dmg-probe.o
-block-obj-y += parallels-probe.o qcow-probe.o
+block-obj-y += parallels-probe.o qcow-probe.o qcow2-probe.o
 
 common-obj-y += stream.o
 common-obj-y += backup.o
diff --git a/block/qcow2-probe.c b/block/qcow2-probe.c
new file mode 100644
index 0000000..e5cd92c
--- /dev/null
+++ b/block/qcow2-probe.c
@@ -0,0 +1,16 @@
+#include "qemu/osdep.h"
+#include "block/block_int.h"
+#include "block/probe.h"
+#include "qcow2.h"
+
+int qcow2_probe(const uint8_t *buf, int buf_size, const char *filename)
+{
+    const QCowHeader *cow_header = (const void *)buf;
+
+    if (buf_size >= sizeof(QCowHeader) &&
+        be32_to_cpu(cow_header->magic) == QCOW_MAGIC &&
+        be32_to_cpu(cow_header->version) >= 2)
+        return 100;
+    else
+        return 0;
+}
diff --git a/block/qcow2.c b/block/qcow2.c
index a5ea19b..17521f7 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -27,6 +27,7 @@
 #include "qemu/module.h"
 #include <zlib.h>
 #include "block/qcow2.h"
+#include "block/probe.h"
 #include "qemu/error-report.h"
 #include "qapi/qmp/qerror.h"
 #include "qapi/qmp/qbool.h"
@@ -64,18 +65,6 @@ 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)
-{
-    const QCowHeader *cow_header = (const void *)buf;
-
-    if (buf_size >= sizeof(QCowHeader) &&
-        be32_to_cpu(cow_header->magic) == QCOW_MAGIC &&
-        be32_to_cpu(cow_header->version) >= 2)
-        return 100;
-    else
-        return 0;
-}
-
 
 /* 
  * read qcow2 extension and fill bs
diff --git a/include/block/probe.h b/include/block/probe.h
index 5230da4..f9dd36e 100644
--- a/include/block/probe.h
+++ b/include/block/probe.h
@@ -8,5 +8,6 @@ int block_crypto_probe_luks(const uint8_t *buf, int buf_size,
 int dmg_probe(const uint8_t *buf, int buf_size, const char *filename);
 int parallels_probe(const uint8_t *buf, int buf_size, const char *filename);
 int qcow_probe(const uint8_t *buf, int buf_size, const char *filename);
+int qcow2_probe(const uint8_t *buf, int buf_size, const char *filename);
 
 #endif
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [Qemu-devel] [PATCH v4 11/32] blockdev: Move qed probe to its own file
  2016-07-14 19:02 [Qemu-devel] [PATCH v4 00/32] Dynamic module loading for block drivers Colin Lord
                   ` (9 preceding siblings ...)
  2016-07-14 19:03 ` [Qemu-devel] [PATCH v4 10/32] blockdev: Move qcow2 " Colin Lord
@ 2016-07-14 19:03 ` Colin Lord
  2016-07-14 19:03 ` [Qemu-devel] [PATCH v4 12/32] blockdev: Move raw " Colin Lord
                   ` (21 subsequent siblings)
  32 siblings, 0 replies; 42+ messages in thread
From: Colin Lord @ 2016-07-14 19:03 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, qemu-block, mreitz, Colin Lord

Isolate qed probe as part of the modularization process.

Signed-off-by: Colin Lord <clord@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
---
 block/Makefile.objs   |  2 +-
 block/qed-probe.c     | 18 ++++++++++++++++++
 block/qed.c           | 15 +--------------
 include/block/probe.h |  1 +
 4 files changed, 21 insertions(+), 15 deletions(-)
 create mode 100644 block/qed-probe.c

diff --git a/block/Makefile.objs b/block/Makefile.objs
index 4a27bde..db9faef 100644
--- a/block/Makefile.objs
+++ b/block/Makefile.objs
@@ -25,7 +25,7 @@ block-obj-y += write-threshold.o
 
 block-obj-y += crypto.o
 block-obj-y += bochs-probe.o cloop-probe.o crypto-probe.o dmg-probe.o
-block-obj-y += parallels-probe.o qcow-probe.o qcow2-probe.o
+block-obj-y += parallels-probe.o qcow-probe.o qcow2-probe.o qed-probe.o
 
 common-obj-y += stream.o
 common-obj-y += backup.o
diff --git a/block/qed-probe.c b/block/qed-probe.c
new file mode 100644
index 0000000..40261f0
--- /dev/null
+++ b/block/qed-probe.c
@@ -0,0 +1,18 @@
+#include "qemu/osdep.h"
+#include "block/block_int.h"
+#include "block/probe.h"
+#include "qed.h"
+
+int bdrv_qed_probe(const uint8_t *buf, int buf_size,
+                          const char *filename)
+{
+    const QEDHeader *header = (const QEDHeader *)buf;
+
+    if (buf_size < sizeof(*header)) {
+        return 0;
+    }
+    if (le32_to_cpu(header->magic) != QED_MAGIC) {
+        return 0;
+    }
+    return 100;
+}
diff --git a/block/qed.c b/block/qed.c
index f619d82..544ed0d 100644
--- a/block/qed.c
+++ b/block/qed.c
@@ -16,6 +16,7 @@
 #include "qapi/error.h"
 #include "qemu/timer.h"
 #include "qemu/bswap.h"
+#include "block/probe.h"
 #include "trace.h"
 #include "qed.h"
 #include "qapi/qmp/qerror.h"
@@ -26,20 +27,6 @@ static const AIOCBInfo qed_aiocb_info = {
     .aiocb_size         = sizeof(QEDAIOCB),
 };
 
-static int bdrv_qed_probe(const uint8_t *buf, int buf_size,
-                          const char *filename)
-{
-    const QEDHeader *header = (const QEDHeader *)buf;
-
-    if (buf_size < sizeof(*header)) {
-        return 0;
-    }
-    if (le32_to_cpu(header->magic) != QED_MAGIC) {
-        return 0;
-    }
-    return 100;
-}
-
 /**
  * Check whether an image format is raw
  *
diff --git a/include/block/probe.h b/include/block/probe.h
index f9dd36e..e3e9934 100644
--- a/include/block/probe.h
+++ b/include/block/probe.h
@@ -9,5 +9,6 @@ int dmg_probe(const uint8_t *buf, int buf_size, const char *filename);
 int parallels_probe(const uint8_t *buf, int buf_size, const char *filename);
 int qcow_probe(const uint8_t *buf, int buf_size, const char *filename);
 int qcow2_probe(const uint8_t *buf, int buf_size, const char *filename);
+int bdrv_qed_probe(const uint8_t *buf, int buf_size, const char *filename);
 
 #endif
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [Qemu-devel] [PATCH v4 12/32] blockdev: Move raw probe to its own file
  2016-07-14 19:02 [Qemu-devel] [PATCH v4 00/32] Dynamic module loading for block drivers Colin Lord
                   ` (10 preceding siblings ...)
  2016-07-14 19:03 ` [Qemu-devel] [PATCH v4 11/32] blockdev: Move qed " Colin Lord
@ 2016-07-14 19:03 ` Colin Lord
  2016-07-14 19:03 ` [Qemu-devel] [PATCH v4 13/32] blockdev: Move vdi " Colin Lord
                   ` (20 subsequent siblings)
  32 siblings, 0 replies; 42+ messages in thread
From: Colin Lord @ 2016-07-14 19:03 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, qemu-block, mreitz, Colin Lord

Isolate raw probe as part of the modularization process.

Signed-off-by: Colin Lord <clord@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
---
 block/Makefile.objs   |  1 +
 block/raw-probe.c     | 10 ++++++++++
 block/raw_bsd.c       |  9 +--------
 include/block/probe.h |  1 +
 4 files changed, 13 insertions(+), 8 deletions(-)
 create mode 100644 block/raw-probe.c

diff --git a/block/Makefile.objs b/block/Makefile.objs
index db9faef..07b0a2d 100644
--- a/block/Makefile.objs
+++ b/block/Makefile.objs
@@ -26,6 +26,7 @@ block-obj-y += write-threshold.o
 block-obj-y += crypto.o
 block-obj-y += bochs-probe.o cloop-probe.o crypto-probe.o dmg-probe.o
 block-obj-y += parallels-probe.o qcow-probe.o qcow2-probe.o qed-probe.o
+block-obj-y += raw-probe.o
 
 common-obj-y += stream.o
 common-obj-y += backup.o
diff --git a/block/raw-probe.c b/block/raw-probe.c
new file mode 100644
index 0000000..22c6bcb
--- /dev/null
+++ b/block/raw-probe.c
@@ -0,0 +1,10 @@
+#include "qemu/osdep.h"
+#include "block/probe.h"
+
+int raw_probe(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
+     */
+    return 1;
+}
diff --git a/block/raw_bsd.c b/block/raw_bsd.c
index 5f9dd29..25d5185 100644
--- a/block/raw_bsd.c
+++ b/block/raw_bsd.c
@@ -28,6 +28,7 @@
 
 #include "qemu/osdep.h"
 #include "block/block_int.h"
+#include "block/probe.h"
 #include "qapi/error.h"
 #include "qemu/option.h"
 
@@ -213,14 +214,6 @@ static void raw_close(BlockDriverState *bs)
 {
 }
 
-static int raw_probe(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
-     */
-    return 1;
-}
-
 static int raw_probe_blocksizes(BlockDriverState *bs, BlockSizes *bsz)
 {
     return bdrv_probe_blocksizes(bs->file->bs, bsz);
diff --git a/include/block/probe.h b/include/block/probe.h
index e3e9934..053f961 100644
--- a/include/block/probe.h
+++ b/include/block/probe.h
@@ -10,5 +10,6 @@ int parallels_probe(const uint8_t *buf, int buf_size, const char *filename);
 int qcow_probe(const uint8_t *buf, int buf_size, const char *filename);
 int qcow2_probe(const uint8_t *buf, int buf_size, const char *filename);
 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);
 
 #endif
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [Qemu-devel] [PATCH v4 13/32] blockdev: Move vdi probe to its own file
  2016-07-14 19:02 [Qemu-devel] [PATCH v4 00/32] Dynamic module loading for block drivers Colin Lord
                   ` (11 preceding siblings ...)
  2016-07-14 19:03 ` [Qemu-devel] [PATCH v4 12/32] blockdev: Move raw " Colin Lord
@ 2016-07-14 19:03 ` Colin Lord
  2016-07-14 19:03 ` [Qemu-devel] [PATCH v4 14/32] blockdev: Move vhdx " Colin Lord
                   ` (19 subsequent siblings)
  32 siblings, 0 replies; 42+ messages in thread
From: Colin Lord @ 2016-07-14 19:03 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, qemu-block, mreitz, Colin Lord

Isolates vdi probe as part of the modularization process.

Signed-off-by: Colin Lord <clord@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
---
 block/Makefile.objs   |  2 +-
 block/vdi-probe.c     | 26 +++++++++++++++++++
 block/vdi.c           | 69 ++-------------------------------------------------
 block/vdi.h           | 49 ++++++++++++++++++++++++++++++++++++
 include/block/probe.h |  1 +
 5 files changed, 79 insertions(+), 68 deletions(-)
 create mode 100644 block/vdi-probe.c
 create mode 100644 block/vdi.h

diff --git a/block/Makefile.objs b/block/Makefile.objs
index 07b0a2d..9f9e83f 100644
--- a/block/Makefile.objs
+++ b/block/Makefile.objs
@@ -26,7 +26,7 @@ block-obj-y += write-threshold.o
 block-obj-y += crypto.o
 block-obj-y += bochs-probe.o cloop-probe.o crypto-probe.o dmg-probe.o
 block-obj-y += parallels-probe.o qcow-probe.o qcow2-probe.o qed-probe.o
-block-obj-y += raw-probe.o
+block-obj-y += raw-probe.o vdi-probe.o
 
 common-obj-y += stream.o
 common-obj-y += backup.o
diff --git a/block/vdi-probe.c b/block/vdi-probe.c
new file mode 100644
index 0000000..42b2cc8
--- /dev/null
+++ b/block/vdi-probe.c
@@ -0,0 +1,26 @@
+#include "qemu/osdep.h"
+#include "block/block_int.h"
+#include "block/probe.h"
+#include "vdi.h"
+
+int vdi_probe(const uint8_t *buf, int buf_size, const char *filename)
+{
+    const VdiHeader *header = (const VdiHeader *)buf;
+    int ret = 0;
+
+    logout("\n");
+
+    if (buf_size < sizeof(*header)) {
+        /* Header too small, no VDI. */
+    } else if (le32_to_cpu(header->signature) == VDI_SIGNATURE) {
+        ret = 100;
+    }
+
+    if (ret == 0) {
+        logout("no vdi image\n");
+    } else {
+        logout("%s", header->text);
+    }
+
+    return ret;
+}
diff --git a/block/vdi.c b/block/vdi.c
index 8a1cf97..b6db1c6 100644
--- a/block/vdi.c
+++ b/block/vdi.c
@@ -52,6 +52,8 @@
 #include "qemu/osdep.h"
 #include "qapi/error.h"
 #include "block/block_int.h"
+#include "block/probe.h"
+#include "vdi.h"
 #include "sysemu/block-backend.h"
 #include "qemu/module.h"
 #include "qemu/bswap.h"
@@ -59,14 +61,6 @@
 #include "qemu/coroutine.h"
 #include "qemu/cutils.h"
 
-#if defined(CONFIG_UUID)
-#include <uuid/uuid.h>
-#else
-/* TODO: move uuid emulation to some central place in QEMU. */
-#include "sysemu/sysemu.h"     /* UUID_FMT */
-typedef unsigned char uuid_t[16];
-#endif
-
 /* Code configuration options. */
 
 /* Enable debug messages. */
@@ -92,16 +86,6 @@ typedef unsigned char uuid_t[16];
 #define SECTOR_SIZE 512
 #define DEFAULT_CLUSTER_SIZE (1 * MiB)
 
-#if defined(CONFIG_VDI_DEBUG)
-#define logout(fmt, ...) \
-                fprintf(stderr, "vdi\t%-24s" fmt, __func__, ##__VA_ARGS__)
-#else
-#define logout(fmt, ...) ((void)0)
-#endif
-
-/* Image signature. */
-#define VDI_SIGNATURE 0xbeda107f
-
 /* Image version. */
 #define VDI_VERSION_1_1 0x00010001
 
@@ -163,33 +147,6 @@ static inline void uuid_unparse(const uuid_t uu, char *out)
 #endif
 
 typedef struct {
-    char text[0x40];
-    uint32_t signature;
-    uint32_t version;
-    uint32_t header_size;
-    uint32_t image_type;
-    uint32_t image_flags;
-    char description[256];
-    uint32_t offset_bmap;
-    uint32_t offset_data;
-    uint32_t cylinders;         /* disk geometry, unused here */
-    uint32_t heads;             /* disk geometry, unused here */
-    uint32_t sectors;           /* disk geometry, unused here */
-    uint32_t sector_size;
-    uint32_t unused1;
-    uint64_t disk_size;
-    uint32_t block_size;
-    uint32_t block_extra;       /* unused here */
-    uint32_t blocks_in_image;
-    uint32_t blocks_allocated;
-    uuid_t uuid_image;
-    uuid_t uuid_last_snap;
-    uuid_t uuid_link;
-    uuid_t uuid_parent;
-    uint64_t unused2[7];
-} QEMU_PACKED VdiHeader;
-
-typedef struct {
     /* The block map entries are little endian (even in memory). */
     uint32_t *bmap;
     /* Size of block (bytes). */
@@ -371,28 +328,6 @@ static int vdi_make_empty(BlockDriverState *bs)
     return 0;
 }
 
-static int vdi_probe(const uint8_t *buf, int buf_size, const char *filename)
-{
-    const VdiHeader *header = (const VdiHeader *)buf;
-    int ret = 0;
-
-    logout("\n");
-
-    if (buf_size < sizeof(*header)) {
-        /* Header too small, no VDI. */
-    } else if (le32_to_cpu(header->signature) == VDI_SIGNATURE) {
-        ret = 100;
-    }
-
-    if (ret == 0) {
-        logout("no vdi image\n");
-    } else {
-        logout("%s", header->text);
-    }
-
-    return ret;
-}
-
 static int vdi_open(BlockDriverState *bs, QDict *options, int flags,
                     Error **errp)
 {
diff --git a/block/vdi.h b/block/vdi.h
new file mode 100644
index 0000000..4020c94
--- /dev/null
+++ b/block/vdi.h
@@ -0,0 +1,49 @@
+#ifndef VDI_H
+#define VDI_H
+
+#if defined(CONFIG_UUID)
+#include <uuid/uuid.h>
+#else
+/* TODO: move uuid emulation to some central place in QEMU. */
+#include "sysemu/sysemu.h"     /* UUID_FMT */
+typedef unsigned char uuid_t[16];
+#endif
+
+#if defined(CONFIG_VDI_DEBUG)
+#define logout(fmt, ...) \
+                fprintf(stderr, "vdi\t%-24s" fmt, __func__, ##__VA_ARGS__)
+#else
+#define logout(fmt, ...) ((void)0)
+#endif
+
+/* Image signature. */
+#define VDI_SIGNATURE 0xbeda107f
+
+typedef struct {
+    char text[0x40];
+    uint32_t signature;
+    uint32_t version;
+    uint32_t header_size;
+    uint32_t image_type;
+    uint32_t image_flags;
+    char description[256];
+    uint32_t offset_bmap;
+    uint32_t offset_data;
+    uint32_t cylinders;         /* disk geometry, unused here */
+    uint32_t heads;             /* disk geometry, unused here */
+    uint32_t sectors;           /* disk geometry, unused here */
+    uint32_t sector_size;
+    uint32_t unused1;
+    uint64_t disk_size;
+    uint32_t block_size;
+    uint32_t block_extra;       /* unused here */
+    uint32_t blocks_in_image;
+    uint32_t blocks_allocated;
+    uuid_t uuid_image;
+    uuid_t uuid_last_snap;
+    uuid_t uuid_link;
+    uuid_t uuid_parent;
+    uint64_t unused2[7];
+} QEMU_PACKED VdiHeader;
+
+#endif
diff --git a/include/block/probe.h b/include/block/probe.h
index 053f961..f85c178 100644
--- a/include/block/probe.h
+++ b/include/block/probe.h
@@ -11,5 +11,6 @@ int qcow_probe(const uint8_t *buf, int buf_size, const char *filename);
 int qcow2_probe(const uint8_t *buf, int buf_size, const char *filename);
 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);
 
 #endif
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [Qemu-devel] [PATCH v4 14/32] blockdev: Move vhdx probe to its own file
  2016-07-14 19:02 [Qemu-devel] [PATCH v4 00/32] Dynamic module loading for block drivers Colin Lord
                   ` (12 preceding siblings ...)
  2016-07-14 19:03 ` [Qemu-devel] [PATCH v4 13/32] blockdev: Move vdi " Colin Lord
@ 2016-07-14 19:03 ` Colin Lord
  2016-07-14 19:03 ` [Qemu-devel] [PATCH v4 15/32] blockdev: Move vmdk " Colin Lord
                   ` (18 subsequent siblings)
  32 siblings, 0 replies; 42+ messages in thread
From: Colin Lord @ 2016-07-14 19:03 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, qemu-block, mreitz, Colin Lord

Isolates vhdx probe as part of the modularization process.

Signed-off-by: Colin Lord <clord@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
---
 block/Makefile.objs   |  2 +-
 block/vhdx-probe.c    | 21 +++++++++++++++++++++
 block/vhdx.c          | 20 +-------------------
 include/block/probe.h |  1 +
 4 files changed, 24 insertions(+), 20 deletions(-)
 create mode 100644 block/vhdx-probe.c

diff --git a/block/Makefile.objs b/block/Makefile.objs
index 9f9e83f..4363667 100644
--- a/block/Makefile.objs
+++ b/block/Makefile.objs
@@ -26,7 +26,7 @@ block-obj-y += write-threshold.o
 block-obj-y += crypto.o
 block-obj-y += bochs-probe.o cloop-probe.o crypto-probe.o dmg-probe.o
 block-obj-y += parallels-probe.o qcow-probe.o qcow2-probe.o qed-probe.o
-block-obj-y += raw-probe.o vdi-probe.o
+block-obj-y += raw-probe.o vdi-probe.o vhdx-probe.o
 
 common-obj-y += stream.o
 common-obj-y += backup.o
diff --git a/block/vhdx-probe.c b/block/vhdx-probe.c
new file mode 100644
index 0000000..6c38aac
--- /dev/null
+++ b/block/vhdx-probe.c
@@ -0,0 +1,21 @@
+#include "qemu/osdep.h"
+#include "block/probe.h"
+
+/*
+ * Per the MS VHDX Specification, for every VHDX file:
+ *      - The header section is fixed size - 1 MB
+ *      - The header section is always the first "object"
+ *      - The first 64KB of the header is the File Identifier
+ *      - The first uint64 (8 bytes) is the VHDX Signature ("vhdxfile")
+ *      - The following 512 bytes constitute a UTF-16 string identifiying the
+ *        software that created the file, and is optional and diagnostic only.
+ *
+ *  Therefore, we probe by looking for the vhdxfile signature "vhdxfile"
+ */
+int vhdx_probe(const uint8_t *buf, int buf_size, const char *filename)
+{
+    if (buf_size >= 8 && !memcmp(buf, "vhdxfile", 8)) {
+        return 100;
+    }
+    return 0;
+}
diff --git a/block/vhdx.c b/block/vhdx.c
index 75ef2b1..2f13c61 100644
--- a/block/vhdx.c
+++ b/block/vhdx.c
@@ -19,6 +19,7 @@
 #include "qapi/error.h"
 #include "qemu-common.h"
 #include "block/block_int.h"
+#include "block/probe.h"
 #include "sysemu/block-backend.h"
 #include "qemu/module.h"
 #include "qemu/crc32c.h"
@@ -273,25 +274,6 @@ static void vhdx_set_shift_bits(BDRVVHDXState *s)
 }
 
 /*
- * Per the MS VHDX Specification, for every VHDX file:
- *      - The header section is fixed size - 1 MB
- *      - The header section is always the first "object"
- *      - The first 64KB of the header is the File Identifier
- *      - The first uint64 (8 bytes) is the VHDX Signature ("vhdxfile")
- *      - The following 512 bytes constitute a UTF-16 string identifiying the
- *        software that created the file, and is optional and diagnostic only.
- *
- *  Therefore, we probe by looking for the vhdxfile signature "vhdxfile"
- */
-static int vhdx_probe(const uint8_t *buf, int buf_size, const char *filename)
-{
-    if (buf_size >= 8 && !memcmp(buf, "vhdxfile", 8)) {
-        return 100;
-    }
-    return 0;
-}
-
-/*
  * Writes the header to the specified offset.
  *
  * This will optionally read in buffer data from disk (otherwise zero-fill),
diff --git a/include/block/probe.h b/include/block/probe.h
index f85c178..e901d8f 100644
--- a/include/block/probe.h
+++ b/include/block/probe.h
@@ -12,5 +12,6 @@ int qcow2_probe(const uint8_t *buf, int buf_size, const char *filename);
 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);
 
 #endif
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [Qemu-devel] [PATCH v4 15/32] blockdev: Move vmdk probe to its own file
  2016-07-14 19:02 [Qemu-devel] [PATCH v4 00/32] Dynamic module loading for block drivers Colin Lord
                   ` (13 preceding siblings ...)
  2016-07-14 19:03 ` [Qemu-devel] [PATCH v4 14/32] blockdev: Move vhdx " Colin Lord
@ 2016-07-14 19:03 ` Colin Lord
  2016-07-14 19:03 ` [Qemu-devel] [PATCH v4 16/32] blockdev: Move vpc " Colin Lord
                   ` (17 subsequent siblings)
  32 siblings, 0 replies; 42+ messages in thread
From: Colin Lord @ 2016-07-14 19:03 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, qemu-block, mreitz, Colin Lord

Isolates vmdk probe as part of the modularization process.

Signed-off-by: Colin Lord <clord@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
---
 block/Makefile.objs   |  2 +-
 block/vmdk-probe.c    | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++
 block/vmdk.c          | 60 ++-------------------------------------------------
 block/vmdk.h          |  7 ++++++
 include/block/probe.h |  1 +
 5 files changed, 71 insertions(+), 59 deletions(-)
 create mode 100644 block/vmdk-probe.c
 create mode 100644 block/vmdk.h

diff --git a/block/Makefile.objs b/block/Makefile.objs
index 4363667..f86ab63 100644
--- a/block/Makefile.objs
+++ b/block/Makefile.objs
@@ -26,7 +26,7 @@ block-obj-y += write-threshold.o
 block-obj-y += crypto.o
 block-obj-y += bochs-probe.o cloop-probe.o crypto-probe.o dmg-probe.o
 block-obj-y += parallels-probe.o qcow-probe.o qcow2-probe.o qed-probe.o
-block-obj-y += raw-probe.o vdi-probe.o vhdx-probe.o
+block-obj-y += raw-probe.o vdi-probe.o vhdx-probe.o vmdk-probe.o
 
 common-obj-y += stream.o
 common-obj-y += backup.o
diff --git a/block/vmdk-probe.c b/block/vmdk-probe.c
new file mode 100644
index 0000000..77b06af
--- /dev/null
+++ b/block/vmdk-probe.c
@@ -0,0 +1,60 @@
+#include "qemu/osdep.h"
+#include "block/block_int.h"
+#include "block/probe.h"
+#include "vmdk.h"
+
+int vmdk_probe(const uint8_t *buf, int buf_size, const char *filename)
+{
+    uint32_t magic;
+
+    if (buf_size < 4) {
+        return 0;
+    }
+    magic = be32_to_cpu(*(uint32_t *)buf);
+    if (magic == VMDK3_MAGIC ||
+        magic == VMDK4_MAGIC) {
+        return 100;
+    } else {
+        const char *p = (const char *)buf;
+        const char *end = p + buf_size;
+        while (p < end) {
+            if (*p == '#') {
+                /* skip comment line */
+                while (p < end && *p != '\n') {
+                    p++;
+                }
+                p++;
+                continue;
+            }
+            if (*p == ' ') {
+                while (p < end && *p == ' ') {
+                    p++;
+                }
+                /* skip '\r' if windows line endings used. */
+                if (p < end && *p == '\r') {
+                    p++;
+                }
+                /* only accept blank lines before 'version=' line */
+                if (p == end || *p != '\n') {
+                    return 0;
+                }
+                p++;
+                continue;
+            }
+            if (end - p >= strlen("version=X\n")) {
+                if (strncmp("version=1\n", p, strlen("version=1\n")) == 0 ||
+                    strncmp("version=2\n", p, strlen("version=2\n")) == 0) {
+                    return 100;
+                }
+            }
+            if (end - p >= strlen("version=X\r\n")) {
+                if (strncmp("version=1\r\n", p, strlen("version=1\r\n")) == 0 ||
+                    strncmp("version=2\r\n", p, strlen("version=2\r\n")) == 0) {
+                    return 100;
+                }
+            }
+            return 0;
+        }
+        return 0;
+    }
+}
diff --git a/block/vmdk.c b/block/vmdk.c
index d73f431..d2699b0 100644
--- a/block/vmdk.c
+++ b/block/vmdk.c
@@ -26,6 +26,8 @@
 #include "qemu/osdep.h"
 #include "qapi/error.h"
 #include "block/block_int.h"
+#include "block/probe.h"
+#include "vmdk.h"
 #include "sysemu/block-backend.h"
 #include "qapi/qmp/qerror.h"
 #include "qemu/error-report.h"
@@ -35,8 +37,6 @@
 #include "qemu/cutils.h"
 #include <zlib.h>
 
-#define VMDK3_MAGIC (('C' << 24) | ('O' << 16) | ('W' << 8) | 'D')
-#define VMDK4_MAGIC (('K' << 24) | ('D' << 16) | ('M' << 8) | 'V')
 #define VMDK4_COMPRESSION_DEFLATE 1
 #define VMDK4_FLAG_NL_DETECT (1 << 0)
 #define VMDK4_FLAG_RGD (1 << 1)
@@ -151,62 +151,6 @@ enum {
     MARKER_FOOTER           = 3,
 };
 
-static int vmdk_probe(const uint8_t *buf, int buf_size, const char *filename)
-{
-    uint32_t magic;
-
-    if (buf_size < 4) {
-        return 0;
-    }
-    magic = be32_to_cpu(*(uint32_t *)buf);
-    if (magic == VMDK3_MAGIC ||
-        magic == VMDK4_MAGIC) {
-        return 100;
-    } else {
-        const char *p = (const char *)buf;
-        const char *end = p + buf_size;
-        while (p < end) {
-            if (*p == '#') {
-                /* skip comment line */
-                while (p < end && *p != '\n') {
-                    p++;
-                }
-                p++;
-                continue;
-            }
-            if (*p == ' ') {
-                while (p < end && *p == ' ') {
-                    p++;
-                }
-                /* skip '\r' if windows line endings used. */
-                if (p < end && *p == '\r') {
-                    p++;
-                }
-                /* only accept blank lines before 'version=' line */
-                if (p == end || *p != '\n') {
-                    return 0;
-                }
-                p++;
-                continue;
-            }
-            if (end - p >= strlen("version=X\n")) {
-                if (strncmp("version=1\n", p, strlen("version=1\n")) == 0 ||
-                    strncmp("version=2\n", p, strlen("version=2\n")) == 0) {
-                    return 100;
-                }
-            }
-            if (end - p >= strlen("version=X\r\n")) {
-                if (strncmp("version=1\r\n", p, strlen("version=1\r\n")) == 0 ||
-                    strncmp("version=2\r\n", p, strlen("version=2\r\n")) == 0) {
-                    return 100;
-                }
-            }
-            return 0;
-        }
-        return 0;
-    }
-}
-
 #define SECTOR_SIZE 512
 #define DESC_SIZE (20 * SECTOR_SIZE)    /* 20 sectors of 512 bytes each */
 #define BUF_SIZE 4096
diff --git a/block/vmdk.h b/block/vmdk.h
new file mode 100644
index 0000000..d631468
--- /dev/null
+++ b/block/vmdk.h
@@ -0,0 +1,7 @@
+#ifndef VMDK_H
+#define VMDK_H
+
+#define VMDK3_MAGIC (('C' << 24) | ('O' << 16) | ('W' << 8) | 'D')
+#define VMDK4_MAGIC (('K' << 24) | ('D' << 16) | ('M' << 8) | 'V')
+
+#endif
diff --git a/include/block/probe.h b/include/block/probe.h
index e901d8f..392515d 100644
--- a/include/block/probe.h
+++ b/include/block/probe.h
@@ -13,5 +13,6 @@ 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);
+int vmdk_probe(const uint8_t *buf, int buf_size, const char *filename);
 
 #endif
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [Qemu-devel] [PATCH v4 16/32] blockdev: Move vpc probe to its own file
  2016-07-14 19:02 [Qemu-devel] [PATCH v4 00/32] Dynamic module loading for block drivers Colin Lord
                   ` (14 preceding siblings ...)
  2016-07-14 19:03 ` [Qemu-devel] [PATCH v4 15/32] blockdev: Move vmdk " Colin Lord
@ 2016-07-14 19:03 ` Colin Lord
  2016-07-14 19:03 ` [Qemu-devel] [PATCH v4 17/32] blockdev: Separate bochs probe from its driver Colin Lord
                   ` (16 subsequent siblings)
  32 siblings, 0 replies; 42+ messages in thread
From: Colin Lord @ 2016-07-14 19:03 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, qemu-block, mreitz, Colin Lord

Isolates vpc probe as part of the modularization process.

Signed-off-by: Colin Lord <clord@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
---
 block/Makefile.objs   | 2 +-
 block/vpc-probe.c     | 9 +++++++++
 block/vpc.c           | 8 +-------
 include/block/probe.h | 1 +
 4 files changed, 12 insertions(+), 8 deletions(-)
 create mode 100644 block/vpc-probe.c

diff --git a/block/Makefile.objs b/block/Makefile.objs
index f86ab63..6512073 100644
--- a/block/Makefile.objs
+++ b/block/Makefile.objs
@@ -26,7 +26,7 @@ block-obj-y += write-threshold.o
 block-obj-y += crypto.o
 block-obj-y += bochs-probe.o cloop-probe.o crypto-probe.o dmg-probe.o
 block-obj-y += parallels-probe.o qcow-probe.o qcow2-probe.o qed-probe.o
-block-obj-y += raw-probe.o vdi-probe.o vhdx-probe.o vmdk-probe.o
+block-obj-y += raw-probe.o vdi-probe.o vhdx-probe.o vmdk-probe.o vpc-probe.o
 
 common-obj-y += stream.o
 common-obj-y += backup.o
diff --git a/block/vpc-probe.c b/block/vpc-probe.c
new file mode 100644
index 0000000..afe8271
--- /dev/null
+++ b/block/vpc-probe.c
@@ -0,0 +1,9 @@
+#include "qemu/osdep.h"
+#include "block/probe.h"
+
+int vpc_probe(const uint8_t *buf, int buf_size, const char *filename)
+{
+    if (buf_size >= 8 && !strncmp((char *)buf, "conectix", 8))
+	return 100;
+    return 0;
+}
diff --git a/block/vpc.c b/block/vpc.c
index 43707ed..7ab3e7f 100644
--- a/block/vpc.c
+++ b/block/vpc.c
@@ -26,6 +26,7 @@
 #include "qapi/error.h"
 #include "qemu-common.h"
 #include "block/block_int.h"
+#include "block/probe.h"
 #include "sysemu/block-backend.h"
 #include "qemu/module.h"
 #include "migration/migration.h"
@@ -179,13 +180,6 @@ 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)
-{
-    if (buf_size >= 8 && !strncmp((char *)buf, "conectix", 8))
-	return 100;
-    return 0;
-}
-
 static void vpc_parse_options(BlockDriverState *bs, QemuOpts *opts,
                               Error **errp)
 {
diff --git a/include/block/probe.h b/include/block/probe.h
index 392515d..6cf878b 100644
--- a/include/block/probe.h
+++ b/include/block/probe.h
@@ -14,5 +14,6 @@ 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);
+int vpc_probe(const uint8_t *buf, int buf_size, const char *filename);
 
 #endif
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [Qemu-devel] [PATCH v4 17/32] blockdev: Separate bochs probe from its driver
  2016-07-14 19:02 [Qemu-devel] [PATCH v4 00/32] Dynamic module loading for block drivers Colin Lord
                   ` (15 preceding siblings ...)
  2016-07-14 19:03 ` [Qemu-devel] [PATCH v4 16/32] blockdev: Move vpc " Colin Lord
@ 2016-07-14 19:03 ` Colin Lord
  2016-07-18 16:28   ` Max Reitz
  2016-07-14 19:03 ` [Qemu-devel] [PATCH v4 18/32] blockdev: Separate cloop " Colin Lord
                   ` (15 subsequent siblings)
  32 siblings, 1 reply; 42+ messages in thread
From: Colin Lord @ 2016-07-14 19:03 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, qemu-block, mreitz, Colin Lord

Modifies the bochs probe to return the format name as well as the
score as the final step of separating the probe function from the
driver. This keeps the probe completely independent of the driver,
making future modularization easier to accomplish. Returning the format
name as well as the score allows the score to be correlated to the
driver without the probe function needing to be part of the driver.

Signed-off-by: Colin Lord <clord@redhat.com>
---
 block.c               | 20 ++++++++++++++++++++
 block/bochs-probe.c   | 25 ++++++++++++++++---------
 block/bochs.c         |  1 -
 include/block/probe.h |  3 ++-
 4 files changed, 38 insertions(+), 11 deletions(-)

diff --git a/block.c b/block.c
index 3a0dc19..b16f8cf 100644
--- a/block.c
+++ b/block.c
@@ -25,6 +25,7 @@
 #include "trace.h"
 #include "block/block_int.h"
 #include "block/blockjob.h"
+#include "block/probe.h"
 #include "qemu/error-report.h"
 #include "module_block.h"
 #include "qemu/module.h"
@@ -56,6 +57,13 @@
 
 #define NOT_DONE 0x7fffffff /* used while emulated sync operation in progress */
 
+typedef const char *BdrvProbeFunc(const uint8_t *buf, int buf_size,
+                                  const char *filename, int *score);
+
+static BdrvProbeFunc *format_probes[] = {
+    bdrv_bochs_probe,
+};
+
 static QTAILQ_HEAD(, BlockDriverState) graph_bdrv_states =
     QTAILQ_HEAD_INITIALIZER(graph_bdrv_states);
 
@@ -576,6 +584,8 @@ BlockDriver *bdrv_probe_all(const uint8_t *buf, int buf_size,
                             const char *filename)
 {
     int score_max = 0, score;
+    const char *format_max = NULL;
+    const char *format;
     size_t i;
     BlockDriver *drv = NULL, *d;
 
@@ -595,6 +605,16 @@ BlockDriver *bdrv_probe_all(const uint8_t *buf, int buf_size,
         }
     }
 
+    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;
 }
 
diff --git a/block/bochs-probe.c b/block/bochs-probe.c
index befe2cf..57161dc 100644
--- a/block/bochs-probe.c
+++ b/block/bochs-probe.c
@@ -3,19 +3,26 @@
 #include "block/probe.h"
 #include "bochs.h"
 
-int bochs_probe(const uint8_t *buf, int buf_size, const char *filename)
+const char *bdrv_bochs_probe(const uint8_t *buf, int buf_size,
+                             const char *filename, int *score)
 {
+    const char *format = "bochs";
     const struct bochs_header *bochs = (const void *)buf;
+    assert(score);
+    *score = 0;
 
-    if (buf_size < HEADER_SIZE)
-	return 0;
+    if (buf_size < HEADER_SIZE) {
+        return format;
+    }
 
     if (!strcmp(bochs->magic, HEADER_MAGIC) &&
-	!strcmp(bochs->type, REDOLOG_TYPE) &&
-	!strcmp(bochs->subtype, GROWING_TYPE) &&
-	((le32_to_cpu(bochs->version) == HEADER_VERSION) ||
-	(le32_to_cpu(bochs->version) == HEADER_V1)))
-	return 100;
+        !strcmp(bochs->type, REDOLOG_TYPE) &&
+        !strcmp(bochs->subtype, GROWING_TYPE) &&
+        ((le32_to_cpu(bochs->version) == HEADER_VERSION) ||
+        (le32_to_cpu(bochs->version) == HEADER_V1))) {
+        *score = 100;
+        return format;
+    }
 
-    return 0;
+    return format;
 }
diff --git a/block/bochs.c b/block/bochs.c
index 5c9a696..7051ffc 100644
--- a/block/bochs.c
+++ b/block/bochs.c
@@ -234,7 +234,6 @@ static void bochs_close(BlockDriverState *bs)
 static BlockDriver bdrv_bochs = {
     .format_name	= "bochs",
     .instance_size	= sizeof(BDRVBochsState),
-    .bdrv_probe		= bochs_probe,
     .bdrv_open		= bochs_open,
     .bdrv_refresh_limits = bochs_refresh_limits,
     .bdrv_co_preadv = bochs_co_preadv,
diff --git a/include/block/probe.h b/include/block/probe.h
index 6cf878b..aac1fca 100644
--- a/include/block/probe.h
+++ b/include/block/probe.h
@@ -1,7 +1,6 @@
 #ifndef PROBE_H
 #define PROBE_H
 
-int bochs_probe(const uint8_t *buf, int buf_size, const char *filename);
 int cloop_probe(const uint8_t *buf, int buf_size, const char *filename);
 int block_crypto_probe_luks(const uint8_t *buf, int buf_size,
                             const char *filename);
@@ -15,5 +14,7 @@ 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);
 int vpc_probe(const uint8_t *buf, int buf_size, const char *filename);
+const char *bdrv_bochs_probe(const uint8_t *buf, int buf_size,
+                             const char *filename, int *score);
 
 #endif
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [Qemu-devel] [PATCH v4 18/32] blockdev: Separate cloop probe from its driver
  2016-07-14 19:02 [Qemu-devel] [PATCH v4 00/32] Dynamic module loading for block drivers Colin Lord
                   ` (16 preceding siblings ...)
  2016-07-14 19:03 ` [Qemu-devel] [PATCH v4 17/32] blockdev: Separate bochs probe from its driver Colin Lord
@ 2016-07-14 19:03 ` Colin Lord
  2016-07-14 19:03 ` [Qemu-devel] [PATCH v4 19/32] blockdev: Separate luks " Colin Lord
                   ` (14 subsequent siblings)
  32 siblings, 0 replies; 42+ messages in thread
From: Colin Lord @ 2016-07-14 19:03 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, qemu-block, mreitz, Colin Lord

Completes the separation of the cloop probe from the cloop driver. The
cloop 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>
Reviewed-by: Max Reitz <mreitz@redhat.com>
---
 block.c               |  1 +
 block/cloop-probe.c   | 11 ++++++++---
 block/cloop.c         |  1 -
 include/block/probe.h |  3 ++-
 4 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/block.c b/block.c
index b16f8cf..8d21f87 100644
--- a/block.c
+++ b/block.c
@@ -62,6 +62,7 @@ typedef const char *BdrvProbeFunc(const uint8_t *buf, int buf_size,
 
 static BdrvProbeFunc *format_probes[] = {
     bdrv_bochs_probe,
+    bdrv_cloop_probe,
 };
 
 static QTAILQ_HEAD(, BlockDriverState) graph_bdrv_states =
diff --git a/block/cloop-probe.c b/block/cloop-probe.c
index 955c29c..779b377 100644
--- a/block/cloop-probe.c
+++ b/block/cloop-probe.c
@@ -1,17 +1,22 @@
 #include "qemu/osdep.h"
 #include "block/probe.h"
 
-int cloop_probe(const uint8_t *buf, int buf_size, const char *filename)
+const char *bdrv_cloop_probe(const uint8_t *buf, int buf_size,
+                             const char *filename, int *score)
 {
+    const char *format = "cloop";
     const char *magic_version_2_0 = "#!/bin/sh\n"
         "#V2.0 Format\n"
         "modprobe cloop file=$0 && mount -r -t iso9660 /dev/cloop $1\n";
     int length = strlen(magic_version_2_0);
+    assert(score);
     if (length > buf_size) {
         length = buf_size;
     }
     if (!memcmp(magic_version_2_0, buf, length)) {
-        return 2;
+        *score = 2;
+        return format;
     }
-    return 0;
+    *score = 0;
+    return format;
 }
diff --git a/block/cloop.c b/block/cloop.c
index c897e58..a2555d3 100644
--- a/block/cloop.c
+++ b/block/cloop.c
@@ -268,7 +268,6 @@ static void cloop_close(BlockDriverState *bs)
 static BlockDriver bdrv_cloop = {
     .format_name    = "cloop",
     .instance_size  = sizeof(BDRVCloopState),
-    .bdrv_probe     = cloop_probe,
     .bdrv_open      = cloop_open,
     .bdrv_refresh_limits = cloop_refresh_limits,
     .bdrv_co_preadv = cloop_co_preadv,
diff --git a/include/block/probe.h b/include/block/probe.h
index aac1fca..e434af5 100644
--- a/include/block/probe.h
+++ b/include/block/probe.h
@@ -1,7 +1,6 @@
 #ifndef PROBE_H
 #define PROBE_H
 
-int cloop_probe(const uint8_t *buf, int buf_size, const char *filename);
 int block_crypto_probe_luks(const uint8_t *buf, int buf_size,
                             const char *filename);
 int dmg_probe(const uint8_t *buf, int buf_size, const char *filename);
@@ -16,5 +15,7 @@ int vmdk_probe(const uint8_t *buf, int buf_size, const char *filename);
 int vpc_probe(const uint8_t *buf, int buf_size, const char *filename);
 const char *bdrv_bochs_probe(const uint8_t *buf, int buf_size,
                              const char *filename, int *score);
+const char *bdrv_cloop_probe(const uint8_t *buf, int buf_size,
+                             const char *filename, int *score);
 
 #endif
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [Qemu-devel] [PATCH v4 19/32] blockdev: Separate luks probe from its driver
  2016-07-14 19:02 [Qemu-devel] [PATCH v4 00/32] Dynamic module loading for block drivers Colin Lord
                   ` (17 preceding siblings ...)
  2016-07-14 19:03 ` [Qemu-devel] [PATCH v4 18/32] blockdev: Separate cloop " Colin Lord
@ 2016-07-14 19:03 ` Colin Lord
  2016-07-14 19:03 ` [Qemu-devel] [PATCH v4 20/32] blockdev: Separate dmg " Colin Lord
                   ` (13 subsequent siblings)
  32 siblings, 0 replies; 42+ messages in thread
From: Colin Lord @ 2016-07-14 19:03 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, qemu-block, mreitz, Colin Lord

Completes the separation of the luks probe from the crypto driver. The
luks 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>
Reviewed-by: Max Reitz <mreitz@redhat.com>
---
 block.c               |  1 +
 block/crypto-probe.c  | 13 ++++++++-----
 block/crypto.c        |  1 -
 include/block/probe.h |  4 ++--
 4 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/block.c b/block.c
index 8d21f87..6a144cc 100644
--- a/block.c
+++ b/block.c
@@ -63,6 +63,7 @@ typedef const char *BdrvProbeFunc(const uint8_t *buf, int buf_size,
 static BdrvProbeFunc *format_probes[] = {
     bdrv_bochs_probe,
     bdrv_cloop_probe,
+    bdrv_crypto_probe_luks,
 };
 
 static QTAILQ_HEAD(, BlockDriverState) graph_bdrv_states =
diff --git a/block/crypto-probe.c b/block/crypto-probe.c
index 5c6427a..b372613 100644
--- a/block/crypto-probe.c
+++ b/block/crypto-probe.c
@@ -15,9 +15,12 @@ static int block_crypto_probe_generic(QCryptoBlockFormat format,
     }
 }
 
-int block_crypto_probe_luks(const uint8_t *buf,
-                                   int buf_size,
-                                   const char *filename) {
-    return block_crypto_probe_generic(Q_CRYPTO_BLOCK_FORMAT_LUKS,
-                                      buf, buf_size, filename);
+const char *bdrv_crypto_probe_luks(const uint8_t *buf, int buf_size,
+                                   const char *filename, int *score)
+{
+    const char *format = "luks";
+    assert(score);
+    *score = block_crypto_probe_generic(Q_CRYPTO_BLOCK_FORMAT_LUKS,
+                                        buf, buf_size, filename);
+    return format;
 }
diff --git a/block/crypto.c b/block/crypto.c
index 5706ba6..bba350e 100644
--- a/block/crypto.c
+++ b/block/crypto.c
@@ -547,7 +547,6 @@ static int block_crypto_create_luks(const char *filename,
 BlockDriver bdrv_crypto_luks = {
     .format_name        = "luks",
     .instance_size      = sizeof(BlockCrypto),
-    .bdrv_probe         = block_crypto_probe_luks,
     .bdrv_open          = block_crypto_open_luks,
     .bdrv_close         = block_crypto_close,
     .bdrv_create        = block_crypto_create_luks,
diff --git a/include/block/probe.h b/include/block/probe.h
index e434af5..b15dd91 100644
--- a/include/block/probe.h
+++ b/include/block/probe.h
@@ -1,8 +1,6 @@
 #ifndef PROBE_H
 #define PROBE_H
 
-int block_crypto_probe_luks(const uint8_t *buf, int buf_size,
-                            const char *filename);
 int dmg_probe(const uint8_t *buf, int buf_size, const char *filename);
 int parallels_probe(const uint8_t *buf, int buf_size, const char *filename);
 int qcow_probe(const uint8_t *buf, int buf_size, const char *filename);
@@ -17,5 +15,7 @@ const char *bdrv_bochs_probe(const uint8_t *buf, int buf_size,
                              const char *filename, int *score);
 const char *bdrv_cloop_probe(const uint8_t *buf, int buf_size,
                              const char *filename, int *score);
+const char *bdrv_crypto_probe_luks(const uint8_t *buf, int buf_size,
+                                   const char *filename, int *score);
 
 #endif
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [Qemu-devel] [PATCH v4 20/32] blockdev: Separate dmg probe from its driver
  2016-07-14 19:02 [Qemu-devel] [PATCH v4 00/32] Dynamic module loading for block drivers Colin Lord
                   ` (18 preceding siblings ...)
  2016-07-14 19:03 ` [Qemu-devel] [PATCH v4 19/32] blockdev: Separate luks " Colin Lord
@ 2016-07-14 19:03 ` Colin Lord
  2016-07-14 19:03 ` [Qemu-devel] [PATCH v4 21/32] blockdev: Separate parallels " Colin Lord
                   ` (12 subsequent siblings)
  32 siblings, 0 replies; 42+ messages in thread
From: Colin Lord @ 2016-07-14 19:03 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, qemu-block, mreitz, Colin Lord

Completes the separation of the dmg probe from the dmg driver. The dmg
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>
Reviewed-by: Max Reitz <mreitz@redhat.com>
---
 block.c               |  1 +
 block/dmg-probe.c     | 13 +++++++++----
 block/dmg.c           |  1 -
 include/block/probe.h |  3 ++-
 4 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/block.c b/block.c
index 6a144cc..f7dc4a4 100644
--- a/block.c
+++ b/block.c
@@ -64,6 +64,7 @@ static BdrvProbeFunc *format_probes[] = {
     bdrv_bochs_probe,
     bdrv_cloop_probe,
     bdrv_crypto_probe_luks,
+    bdrv_dmg_probe,
 };
 
 static QTAILQ_HEAD(, BlockDriverState) graph_bdrv_states =
diff --git a/block/dmg-probe.c b/block/dmg-probe.c
index a40281b..cc6efa8 100644
--- a/block/dmg-probe.c
+++ b/block/dmg-probe.c
@@ -1,17 +1,22 @@
 #include "qemu/osdep.h"
 #include "block/probe.h"
 
-int dmg_probe(const uint8_t *buf, int buf_size, const char *filename)
+const char *bdrv_dmg_probe(const uint8_t *buf, int buf_size,
+                           const char *filename, int *score)
 {
+    const char *format = "dmg";
     int len;
+    assert(score);
+    *score = 0;
 
     if (!filename) {
-        return 0;
+        return format;
     }
 
     len = strlen(filename);
     if (len > 4 && !strcmp(filename + len - 4, ".dmg")) {
-        return 2;
+        *score = 2;
+        return format;
     }
-    return 0;
+    return format;
 }
diff --git a/block/dmg.c b/block/dmg.c
index 4bbb079..8e50a6b 100644
--- a/block/dmg.c
+++ b/block/dmg.c
@@ -709,7 +709,6 @@ static void dmg_close(BlockDriverState *bs)
 static BlockDriver bdrv_dmg = {
     .format_name    = "dmg",
     .instance_size  = sizeof(BDRVDMGState),
-    .bdrv_probe     = dmg_probe,
     .bdrv_open      = dmg_open,
     .bdrv_refresh_limits = dmg_refresh_limits,
     .bdrv_co_preadv = dmg_co_preadv,
diff --git a/include/block/probe.h b/include/block/probe.h
index b15dd91..bd5a532 100644
--- a/include/block/probe.h
+++ b/include/block/probe.h
@@ -1,7 +1,6 @@
 #ifndef PROBE_H
 #define PROBE_H
 
-int dmg_probe(const uint8_t *buf, int buf_size, const char *filename);
 int parallels_probe(const uint8_t *buf, int buf_size, const char *filename);
 int qcow_probe(const uint8_t *buf, int buf_size, const char *filename);
 int qcow2_probe(const uint8_t *buf, int buf_size, const char *filename);
@@ -17,5 +16,7 @@ const char *bdrv_cloop_probe(const uint8_t *buf, int buf_size,
                              const char *filename, int *score);
 const char *bdrv_crypto_probe_luks(const uint8_t *buf, int buf_size,
                                    const char *filename, int *score);
+const char *bdrv_dmg_probe(const uint8_t *buf, int buf_size,
+                           const char *filename, int *score);
 
 #endif
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [Qemu-devel] [PATCH v4 21/32] blockdev: Separate parallels probe from its driver
  2016-07-14 19:02 [Qemu-devel] [PATCH v4 00/32] Dynamic module loading for block drivers Colin Lord
                   ` (19 preceding siblings ...)
  2016-07-14 19:03 ` [Qemu-devel] [PATCH v4 20/32] blockdev: Separate dmg " Colin Lord
@ 2016-07-14 19:03 ` Colin Lord
  2016-07-14 19:03 ` [Qemu-devel] [PATCH v4 22/32] blockdev: Separate qcow " Colin Lord
                   ` (11 subsequent siblings)
  32 siblings, 0 replies; 42+ messages in thread
From: Colin Lord @ 2016-07-14 19:03 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, qemu-block, mreitz, Colin Lord

Completes the separation of the parallels probe from the parallels
driver. The parallels 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>
Reviewed-by: Max Reitz <mreitz@redhat.com>
---
 block.c                 |  1 +
 block/parallels-probe.c | 17 +++++++++++------
 block/parallels.c       |  1 -
 include/block/probe.h   |  3 ++-
 4 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/block.c b/block.c
index f7dc4a4..18974c6 100644
--- a/block.c
+++ b/block.c
@@ -65,6 +65,7 @@ static BdrvProbeFunc *format_probes[] = {
     bdrv_cloop_probe,
     bdrv_crypto_probe_luks,
     bdrv_dmg_probe,
+    bdrv_parallels_probe,
 };
 
 static QTAILQ_HEAD(, BlockDriverState) graph_bdrv_states =
diff --git a/block/parallels-probe.c b/block/parallels-probe.c
index ff2f6ba..659a09b 100644
--- a/block/parallels-probe.c
+++ b/block/parallels-probe.c
@@ -3,19 +3,24 @@
 #include "block/probe.h"
 #include "parallels.h"
 
-int parallels_probe(const uint8_t *buf, int buf_size, const char *filename)
+const char *bdrv_parallels_probe(const uint8_t *buf, int buf_size,
+                                 const char *filename, int *score)
 {
+    const char *format = "parallels";
     const ParallelsHeader *ph = (const void *)buf;
+    assert(score);
+    *score = 0;
 
     if (buf_size < sizeof(ParallelsHeader)) {
-        return 0;
+        return format;
     }
 
     if ((!memcmp(ph->magic, HEADER_MAGIC, 16) ||
-           !memcmp(ph->magic, HEADER_MAGIC2, 16)) &&
-           (le32_to_cpu(ph->version) == HEADER_VERSION)) {
-        return 100;
+        !memcmp(ph->magic, HEADER_MAGIC2, 16)) &&
+        (le32_to_cpu(ph->version) == HEADER_VERSION)) {
+        *score = 100;
+        return format;
     }
 
-    return 0;
+    return format;
 }
diff --git a/block/parallels.c b/block/parallels.c
index 70e9439..88294f7 100644
--- a/block/parallels.c
+++ b/block/parallels.c
@@ -709,7 +709,6 @@ static QemuOptsList parallels_create_opts = {
 static BlockDriver bdrv_parallels = {
     .format_name	= "parallels",
     .instance_size	= sizeof(BDRVParallelsState),
-    .bdrv_probe		= parallels_probe,
     .bdrv_open		= parallels_open,
     .bdrv_close		= parallels_close,
     .bdrv_co_get_block_status = parallels_co_get_block_status,
diff --git a/include/block/probe.h b/include/block/probe.h
index bd5a532..090e0ae 100644
--- a/include/block/probe.h
+++ b/include/block/probe.h
@@ -1,7 +1,6 @@
 #ifndef PROBE_H
 #define PROBE_H
 
-int parallels_probe(const uint8_t *buf, int buf_size, const char *filename);
 int qcow_probe(const uint8_t *buf, int buf_size, const char *filename);
 int qcow2_probe(const uint8_t *buf, int buf_size, const char *filename);
 int bdrv_qed_probe(const uint8_t *buf, int buf_size, const char *filename);
@@ -18,5 +17,7 @@ const char *bdrv_crypto_probe_luks(const uint8_t *buf, int buf_size,
                                    const char *filename, int *score);
 const char *bdrv_dmg_probe(const uint8_t *buf, int buf_size,
                            const char *filename, int *score);
+const char *bdrv_parallels_probe(const uint8_t *buf, int buf_size,
+                                 const char *filename, int *score);
 
 #endif
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [Qemu-devel] [PATCH v4 22/32] blockdev: Separate qcow probe from its driver
  2016-07-14 19:02 [Qemu-devel] [PATCH v4 00/32] Dynamic module loading for block drivers Colin Lord
                   ` (20 preceding siblings ...)
  2016-07-14 19:03 ` [Qemu-devel] [PATCH v4 21/32] blockdev: Separate parallels " Colin Lord
@ 2016-07-14 19:03 ` Colin Lord
  2016-07-14 19:03 ` [Qemu-devel] [PATCH v4 23/32] blockdev: Separate qcow2 " Colin Lord
                   ` (10 subsequent siblings)
  32 siblings, 0 replies; 42+ messages in thread
From: Colin Lord @ 2016-07-14 19:03 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, qemu-block, mreitz, Colin Lord

Completes the separation of the qcow probe from the qcow driver. The
qcow 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>
Reviewed-by: Max Reitz <mreitz@redhat.com>
---
 block.c               |  1 +
 block/qcow-probe.c    | 16 +++++++++++-----
 block/qcow.c          |  1 -
 include/block/probe.h |  3 ++-
 4 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/block.c b/block.c
index 18974c6..f531ad0 100644
--- a/block.c
+++ b/block.c
@@ -66,6 +66,7 @@ static BdrvProbeFunc *format_probes[] = {
     bdrv_crypto_probe_luks,
     bdrv_dmg_probe,
     bdrv_parallels_probe,
+    bdrv_qcow_probe,
 };
 
 static QTAILQ_HEAD(, BlockDriverState) graph_bdrv_states =
diff --git a/block/qcow-probe.c b/block/qcow-probe.c
index c5fd214..36bbd05 100644
--- a/block/qcow-probe.c
+++ b/block/qcow-probe.c
@@ -3,14 +3,20 @@
 #include "block/probe.h"
 #include "qcow.h"
 
-int qcow_probe(const uint8_t *buf, int buf_size, const char *filename)
+const char *bdrv_qcow_probe(const uint8_t *buf, int buf_size,
+                            const char *filename, int *score)
 {
+    const char *format = "qcow";
     const QCowHeader *cow_header = (const void *)buf;
+    assert(score);
 
     if (buf_size >= sizeof(QCowHeader) &&
         be32_to_cpu(cow_header->magic) == QCOW_MAGIC &&
-        be32_to_cpu(cow_header->version) == QCOW_VERSION)
-        return 100;
-    else
-        return 0;
+        be32_to_cpu(cow_header->version) == QCOW_VERSION) {
+        *score = 100;
+        return format;
+    }
+
+    *score = 0;
+    return format;
 }
diff --git a/block/qcow.c b/block/qcow.c
index 6ea1164..5144c8d 100644
--- a/block/qcow.c
+++ b/block/qcow.c
@@ -1044,7 +1044,6 @@ static QemuOptsList qcow_create_opts = {
 static BlockDriver bdrv_qcow = {
     .format_name	= "qcow",
     .instance_size	= sizeof(BDRVQcowState),
-    .bdrv_probe		= qcow_probe,
     .bdrv_open		= qcow_open,
     .bdrv_close		= qcow_close,
     .bdrv_reopen_prepare    = qcow_reopen_prepare,
diff --git a/include/block/probe.h b/include/block/probe.h
index 090e0ae..e670341 100644
--- a/include/block/probe.h
+++ b/include/block/probe.h
@@ -1,7 +1,6 @@
 #ifndef PROBE_H
 #define PROBE_H
 
-int qcow_probe(const uint8_t *buf, int buf_size, const char *filename);
 int qcow2_probe(const uint8_t *buf, int buf_size, const char *filename);
 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);
@@ -19,5 +18,7 @@ const char *bdrv_dmg_probe(const uint8_t *buf, int buf_size,
                            const char *filename, int *score);
 const char *bdrv_parallels_probe(const uint8_t *buf, int buf_size,
                                  const char *filename, int *score);
+const char *bdrv_qcow_probe(const uint8_t *buf, int buf_size,
+                            const char *filename, int *score);
 
 #endif
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [Qemu-devel] [PATCH v4 23/32] blockdev: Separate qcow2 probe from its driver
  2016-07-14 19:02 [Qemu-devel] [PATCH v4 00/32] Dynamic module loading for block drivers Colin Lord
                   ` (21 preceding siblings ...)
  2016-07-14 19:03 ` [Qemu-devel] [PATCH v4 22/32] blockdev: Separate qcow " Colin Lord
@ 2016-07-14 19:03 ` Colin Lord
  2016-07-14 19:03 ` [Qemu-devel] [PATCH v4 24/32] blockdev: Separate qed " Colin Lord
                   ` (9 subsequent siblings)
  32 siblings, 0 replies; 42+ messages in thread
From: Colin Lord @ 2016-07-14 19:03 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, qemu-block, mreitz, Colin Lord

Completes the separation of the qcow2 probe from the qcow2 driver. The
qcow2 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>
Reviewed-by: Max Reitz <mreitz@redhat.com>
---
 block.c               |  1 +
 block/qcow2-probe.c   | 16 +++++++++++-----
 block/qcow2.c         |  1 -
 include/block/probe.h |  3 ++-
 4 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/block.c b/block.c
index f531ad0..145be9b 100644
--- a/block.c
+++ b/block.c
@@ -67,6 +67,7 @@ static BdrvProbeFunc *format_probes[] = {
     bdrv_dmg_probe,
     bdrv_parallels_probe,
     bdrv_qcow_probe,
+    bdrv_qcow2_probe,
 };
 
 static QTAILQ_HEAD(, BlockDriverState) graph_bdrv_states =
diff --git a/block/qcow2-probe.c b/block/qcow2-probe.c
index e5cd92c..b7a73c5 100644
--- a/block/qcow2-probe.c
+++ b/block/qcow2-probe.c
@@ -3,14 +3,20 @@
 #include "block/probe.h"
 #include "qcow2.h"
 
-int qcow2_probe(const uint8_t *buf, int buf_size, const char *filename)
+const char *bdrv_qcow2_probe(const uint8_t *buf, int buf_size,
+                             const char *filename, int *score)
 {
+    const char *format = "qcow2";
     const QCowHeader *cow_header = (const void *)buf;
+    assert(score);
 
     if (buf_size >= sizeof(QCowHeader) &&
         be32_to_cpu(cow_header->magic) == QCOW_MAGIC &&
-        be32_to_cpu(cow_header->version) >= 2)
-        return 100;
-    else
-        return 0;
+        be32_to_cpu(cow_header->version) >= 2) {
+        *score = 100;
+        return format;
+    }
+
+    *score = 0;
+    return format;
 }
diff --git a/block/qcow2.c b/block/qcow2.c
index 17521f7..2f575d1 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -3382,7 +3382,6 @@ static QemuOptsList qcow2_create_opts = {
 BlockDriver bdrv_qcow2 = {
     .format_name        = "qcow2",
     .instance_size      = sizeof(BDRVQcow2State),
-    .bdrv_probe         = qcow2_probe,
     .bdrv_open          = qcow2_open,
     .bdrv_close         = qcow2_close,
     .bdrv_reopen_prepare  = qcow2_reopen_prepare,
diff --git a/include/block/probe.h b/include/block/probe.h
index e670341..1a68cef 100644
--- a/include/block/probe.h
+++ b/include/block/probe.h
@@ -1,7 +1,6 @@
 #ifndef PROBE_H
 #define PROBE_H
 
-int qcow2_probe(const uint8_t *buf, int buf_size, const char *filename);
 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);
@@ -20,5 +19,7 @@ const char *bdrv_parallels_probe(const uint8_t *buf, int buf_size,
                                  const char *filename, int *score);
 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);
 
 #endif
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [Qemu-devel] [PATCH v4 24/32] blockdev: Separate qed probe from its driver
  2016-07-14 19:02 [Qemu-devel] [PATCH v4 00/32] Dynamic module loading for block drivers Colin Lord
                   ` (22 preceding siblings ...)
  2016-07-14 19:03 ` [Qemu-devel] [PATCH v4 23/32] blockdev: Separate qcow2 " Colin Lord
@ 2016-07-14 19:03 ` Colin Lord
  2016-07-14 19:03 ` [Qemu-devel] [PATCH v4 25/32] blockdev: Separate raw " Colin Lord
                   ` (8 subsequent siblings)
  32 siblings, 0 replies; 42+ messages in thread
From: Colin Lord @ 2016-07-14 19:03 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, qemu-block, mreitz, Colin Lord

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>
Reviewed-by: Max Reitz <mreitz@redhat.com>
---
 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

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [Qemu-devel] [PATCH v4 25/32] blockdev: Separate raw probe from its driver
  2016-07-14 19:02 [Qemu-devel] [PATCH v4 00/32] Dynamic module loading for block drivers Colin Lord
                   ` (23 preceding siblings ...)
  2016-07-14 19:03 ` [Qemu-devel] [PATCH v4 24/32] blockdev: Separate qed " Colin Lord
@ 2016-07-14 19:03 ` Colin Lord
  2016-07-14 19:03 ` [Qemu-devel] [PATCH v4 26/32] blockdev: Separate vdi " Colin Lord
                   ` (7 subsequent siblings)
  32 siblings, 0 replies; 42+ messages in thread
From: Colin Lord @ 2016-07-14 19:03 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, qemu-block, mreitz, Colin Lord

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>
Reviewed-by: Max Reitz <mreitz@redhat.com>
---
 block.c               | 1 +
 block/raw-probe.c     | 8 ++++++--
 block/raw_bsd.c       | 1 -
 include/block/probe.h | 3 ++-
 4 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/block.c b/block.c
index 3dc7644..f37161d 100644
--- a/block.c
+++ b/block.c
@@ -69,6 +69,7 @@ static BdrvProbeFunc *format_probes[] = {
     bdrv_qcow_probe,
     bdrv_qcow2_probe,
     bdrv_qed_probe,
+    bdrv_raw_probe,
 };
 
 static QTAILQ_HEAD(, BlockDriverState) graph_bdrv_states =
diff --git a/block/raw-probe.c b/block/raw-probe.c
index 22c6bcb..ac45e13 100644
--- a/block/raw-probe.c
+++ b/block/raw-probe.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 *bdrv_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 25d5185..908cb59 100644
--- a/block/raw_bsd.c
+++ b/block/raw_bsd.c
@@ -226,7 +226,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 cbb9c12..662d5d7 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 *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);
+const char *bdrv_raw_probe(const uint8_t *buf, int buf_size,
+                           const char *filename, int *score);
 
 #endif
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [Qemu-devel] [PATCH v4 26/32] blockdev: Separate vdi probe from its driver
  2016-07-14 19:02 [Qemu-devel] [PATCH v4 00/32] Dynamic module loading for block drivers Colin Lord
                   ` (24 preceding siblings ...)
  2016-07-14 19:03 ` [Qemu-devel] [PATCH v4 25/32] blockdev: Separate raw " Colin Lord
@ 2016-07-14 19:03 ` Colin Lord
  2016-07-14 19:03 ` [Qemu-devel] [PATCH v4 27/32] blockdev: Separate vhdx " Colin Lord
                   ` (6 subsequent siblings)
  32 siblings, 0 replies; 42+ messages in thread
From: Colin Lord @ 2016-07-14 19:03 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, qemu-block, mreitz, Colin Lord

Completes the separation of the vdi probe from the vdi driver. The
vdi 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>
Reviewed-by: Max Reitz <mreitz@redhat.com>
---
 block.c               |  1 +
 block/vdi-probe.c     | 13 ++++++++-----
 block/vdi.c           |  1 -
 include/block/probe.h |  3 ++-
 4 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/block.c b/block.c
index f37161d..a1a0b50 100644
--- a/block.c
+++ b/block.c
@@ -70,6 +70,7 @@ static BdrvProbeFunc *format_probes[] = {
     bdrv_qcow2_probe,
     bdrv_qed_probe,
     bdrv_raw_probe,
+    bdrv_vdi_probe,
 };
 
 static QTAILQ_HEAD(, BlockDriverState) graph_bdrv_states =
diff --git a/block/vdi-probe.c b/block/vdi-probe.c
index 42b2cc8..9c57194 100644
--- a/block/vdi-probe.c
+++ b/block/vdi-probe.c
@@ -3,24 +3,27 @@
 #include "block/probe.h"
 #include "vdi.h"
 
-int vdi_probe(const uint8_t *buf, int buf_size, const char *filename)
+const char *bdrv_vdi_probe(const uint8_t *buf, int buf_size,
+                           const char *filename, int *score)
 {
+    const char *format = "vdi";
     const VdiHeader *header = (const VdiHeader *)buf;
-    int ret = 0;
+    assert(score);
+    *score = 0;
 
     logout("\n");
 
     if (buf_size < sizeof(*header)) {
         /* Header too small, no VDI. */
     } else if (le32_to_cpu(header->signature) == VDI_SIGNATURE) {
-        ret = 100;
+        *score = 100;
     }
 
-    if (ret == 0) {
+    if (*score == 0) {
         logout("no vdi image\n");
     } else {
         logout("%s", header->text);
     }
 
-    return ret;
+    return format;
 }
diff --git a/block/vdi.c b/block/vdi.c
index b6db1c6..27cc5c3 100644
--- a/block/vdi.c
+++ b/block/vdi.c
@@ -849,7 +849,6 @@ static QemuOptsList vdi_create_opts = {
 static BlockDriver bdrv_vdi = {
     .format_name = "vdi",
     .instance_size = sizeof(BDRVVdiState),
-    .bdrv_probe = vdi_probe,
     .bdrv_open = vdi_open,
     .bdrv_close = vdi_close,
     .bdrv_reopen_prepare = vdi_reopen_prepare,
diff --git a/include/block/probe.h b/include/block/probe.h
index 662d5d7..86d48e2 100644
--- a/include/block/probe.h
+++ b/include/block/probe.h
@@ -1,7 +1,6 @@
 #ifndef PROBE_H
 #define PROBE_H
 
-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);
 int vpc_probe(const uint8_t *buf, int buf_size, const char *filename);
@@ -23,5 +22,7 @@ const char *bdrv_qed_probe(const uint8_t *buf, int buf_size,
                            const char *filename, int *score);
 const char *bdrv_raw_probe(const uint8_t *buf, int buf_size,
                            const char *filename, int *score);
+const char *bdrv_vdi_probe(const uint8_t *buf, int buf_size,
+                           const char *filename, int *score);
 
 #endif
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [Qemu-devel] [PATCH v4 27/32] blockdev: Separate vhdx probe from its driver
  2016-07-14 19:02 [Qemu-devel] [PATCH v4 00/32] Dynamic module loading for block drivers Colin Lord
                   ` (25 preceding siblings ...)
  2016-07-14 19:03 ` [Qemu-devel] [PATCH v4 26/32] blockdev: Separate vdi " Colin Lord
@ 2016-07-14 19:03 ` Colin Lord
  2016-07-14 19:03 ` [Qemu-devel] [PATCH v4 28/32] blockdev: Separate vmdk " Colin Lord
                   ` (5 subsequent siblings)
  32 siblings, 0 replies; 42+ messages in thread
From: Colin Lord @ 2016-07-14 19:03 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, qemu-block, mreitz, Colin Lord

Completes the separation of the vhdx probe from the vhdx driver. The
vhdx 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>
Reviewed-by: Max Reitz <mreitz@redhat.com>
---
 block.c               |  1 +
 block/vhdx-probe.c    | 12 +++++++++---
 block/vhdx.c          |  1 -
 include/block/probe.h |  3 ++-
 4 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/block.c b/block.c
index a1a0b50..941e208 100644
--- a/block.c
+++ b/block.c
@@ -71,6 +71,7 @@ static BdrvProbeFunc *format_probes[] = {
     bdrv_qed_probe,
     bdrv_raw_probe,
     bdrv_vdi_probe,
+    bdrv_vhdx_probe,
 };
 
 static QTAILQ_HEAD(, BlockDriverState) graph_bdrv_states =
diff --git a/block/vhdx-probe.c b/block/vhdx-probe.c
index 6c38aac..d907d6b 100644
--- a/block/vhdx-probe.c
+++ b/block/vhdx-probe.c
@@ -12,10 +12,16 @@
  *
  *  Therefore, we probe by looking for the vhdxfile signature "vhdxfile"
  */
-int vhdx_probe(const uint8_t *buf, int buf_size, const char *filename)
+const char *bdrv_vhdx_probe(const uint8_t *buf, int buf_size,
+                            const char *filename, int *score)
 {
+    const char *format = "vhdx";
+    assert(score);
+
     if (buf_size >= 8 && !memcmp(buf, "vhdxfile", 8)) {
-        return 100;
+        *score = 100;
+        return format;
     }
-    return 0;
+    *score = 0;
+    return format;
 }
diff --git a/block/vhdx.c b/block/vhdx.c
index 2f13c61..852ef5c 100644
--- a/block/vhdx.c
+++ b/block/vhdx.c
@@ -1951,7 +1951,6 @@ static QemuOptsList vhdx_create_opts = {
 static BlockDriver bdrv_vhdx = {
     .format_name            = "vhdx",
     .instance_size          = sizeof(BDRVVHDXState),
-    .bdrv_probe             = vhdx_probe,
     .bdrv_open              = vhdx_open,
     .bdrv_close             = vhdx_close,
     .bdrv_reopen_prepare    = vhdx_reopen_prepare,
diff --git a/include/block/probe.h b/include/block/probe.h
index 86d48e2..b7eb00e 100644
--- a/include/block/probe.h
+++ b/include/block/probe.h
@@ -1,7 +1,6 @@
 #ifndef PROBE_H
 #define PROBE_H
 
-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);
 int vpc_probe(const uint8_t *buf, int buf_size, const char *filename);
 const char *bdrv_bochs_probe(const uint8_t *buf, int buf_size,
@@ -24,5 +23,7 @@ const char *bdrv_raw_probe(const uint8_t *buf, int buf_size,
                            const char *filename, int *score);
 const char *bdrv_vdi_probe(const uint8_t *buf, int buf_size,
                            const char *filename, int *score);
+const char *bdrv_vhdx_probe(const uint8_t *buf, int buf_size,
+                            const char *filename, int *score);
 
 #endif
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [Qemu-devel] [PATCH v4 28/32] blockdev: Separate vmdk probe from its driver
  2016-07-14 19:02 [Qemu-devel] [PATCH v4 00/32] Dynamic module loading for block drivers Colin Lord
                   ` (26 preceding siblings ...)
  2016-07-14 19:03 ` [Qemu-devel] [PATCH v4 27/32] blockdev: Separate vhdx " Colin Lord
@ 2016-07-14 19:03 ` Colin Lord
  2016-07-14 19:03 ` [Qemu-devel] [PATCH v4 29/32] blockdev: Separate vpc " Colin Lord
                   ` (4 subsequent siblings)
  32 siblings, 0 replies; 42+ messages in thread
From: Colin Lord @ 2016-07-14 19:03 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, qemu-block, mreitz, Colin Lord

Completes the separation of the vmdk probe from the vmdk driver. The
vmdk 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>
Reviewed-by: Max Reitz <mreitz@redhat.com>
---
 block.c               |  1 +
 block/vmdk-probe.c    | 23 +++++++++++++++--------
 block/vmdk.c          |  1 -
 include/block/probe.h |  3 ++-
 4 files changed, 18 insertions(+), 10 deletions(-)

diff --git a/block.c b/block.c
index 941e208..bb2faf8 100644
--- a/block.c
+++ b/block.c
@@ -72,6 +72,7 @@ static BdrvProbeFunc *format_probes[] = {
     bdrv_raw_probe,
     bdrv_vdi_probe,
     bdrv_vhdx_probe,
+    bdrv_vmdk_probe,
 };
 
 static QTAILQ_HEAD(, BlockDriverState) graph_bdrv_states =
diff --git a/block/vmdk-probe.c b/block/vmdk-probe.c
index 77b06af..86d6f46 100644
--- a/block/vmdk-probe.c
+++ b/block/vmdk-probe.c
@@ -3,17 +3,22 @@
 #include "block/probe.h"
 #include "vmdk.h"
 
-int vmdk_probe(const uint8_t *buf, int buf_size, const char *filename)
+const char *bdrv_vmdk_probe(const uint8_t *buf, int buf_size,
+                            const char *filename, int *score)
 {
+    const char *format = "vmdk";
     uint32_t magic;
+    assert(score);
+    *score = 0;
 
     if (buf_size < 4) {
-        return 0;
+        return format;
     }
     magic = be32_to_cpu(*(uint32_t *)buf);
     if (magic == VMDK3_MAGIC ||
         magic == VMDK4_MAGIC) {
-        return 100;
+        *score = 100;
+        return format;
     } else {
         const char *p = (const char *)buf;
         const char *end = p + buf_size;
@@ -36,7 +41,7 @@ int vmdk_probe(const uint8_t *buf, int buf_size, const char *filename)
                 }
                 /* only accept blank lines before 'version=' line */
                 if (p == end || *p != '\n') {
-                    return 0;
+                    return format;
                 }
                 p++;
                 continue;
@@ -44,17 +49,19 @@ int vmdk_probe(const uint8_t *buf, int buf_size, const char *filename)
             if (end - p >= strlen("version=X\n")) {
                 if (strncmp("version=1\n", p, strlen("version=1\n")) == 0 ||
                     strncmp("version=2\n", p, strlen("version=2\n")) == 0) {
-                    return 100;
+                    *score = 100;
+                    return format;
                 }
             }
             if (end - p >= strlen("version=X\r\n")) {
                 if (strncmp("version=1\r\n", p, strlen("version=1\r\n")) == 0 ||
                     strncmp("version=2\r\n", p, strlen("version=2\r\n")) == 0) {
-                    return 100;
+                    *score = 100;
+                    return format;
                 }
             }
-            return 0;
+            return format;
         }
-        return 0;
+        return format;
     }
 }
diff --git a/block/vmdk.c b/block/vmdk.c
index d2699b0..fb33362 100644
--- a/block/vmdk.c
+++ b/block/vmdk.c
@@ -2331,7 +2331,6 @@ static QemuOptsList vmdk_create_opts = {
 static BlockDriver bdrv_vmdk = {
     .format_name                  = "vmdk",
     .instance_size                = sizeof(BDRVVmdkState),
-    .bdrv_probe                   = vmdk_probe,
     .bdrv_open                    = vmdk_open,
     .bdrv_check                   = vmdk_check,
     .bdrv_reopen_prepare          = vmdk_reopen_prepare,
diff --git a/include/block/probe.h b/include/block/probe.h
index b7eb00e..8f2c26c 100644
--- a/include/block/probe.h
+++ b/include/block/probe.h
@@ -1,7 +1,6 @@
 #ifndef PROBE_H
 #define PROBE_H
 
-int vmdk_probe(const uint8_t *buf, int buf_size, const char *filename);
 int vpc_probe(const uint8_t *buf, int buf_size, const char *filename);
 const char *bdrv_bochs_probe(const uint8_t *buf, int buf_size,
                              const char *filename, int *score);
@@ -25,5 +24,7 @@ const char *bdrv_vdi_probe(const uint8_t *buf, int buf_size,
                            const char *filename, int *score);
 const char *bdrv_vhdx_probe(const uint8_t *buf, int buf_size,
                             const char *filename, int *score);
+const char *bdrv_vmdk_probe(const uint8_t *buf, int buf_size,
+                            const char *filename, int *score);
 
 #endif
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [Qemu-devel] [PATCH v4 29/32] blockdev: Separate vpc probe from its driver
  2016-07-14 19:02 [Qemu-devel] [PATCH v4 00/32] Dynamic module loading for block drivers Colin Lord
                   ` (27 preceding siblings ...)
  2016-07-14 19:03 ` [Qemu-devel] [PATCH v4 28/32] blockdev: Separate vmdk " Colin Lord
@ 2016-07-14 19:03 ` Colin Lord
  2016-07-14 19:03 ` [Qemu-devel] [PATCH v4 30/32] blockdev: Remove the .bdrv_probe field from BlockDrivers Colin Lord
                   ` (3 subsequent siblings)
  32 siblings, 0 replies; 42+ messages in thread
From: Colin Lord @ 2016-07-14 19:03 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, qemu-block, mreitz, Colin Lord

Completes the separation of the vpc probe from the vpc driver. The
vpc 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>
Reviewed-by: Max Reitz <mreitz@redhat.com>
---
 block.c               |  1 +
 block/vpc-probe.c     | 15 +++++++++++----
 block/vpc.c           |  1 -
 include/block/probe.h |  3 ++-
 4 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/block.c b/block.c
index bb2faf8..bc550e4 100644
--- a/block.c
+++ b/block.c
@@ -73,6 +73,7 @@ static BdrvProbeFunc *format_probes[] = {
     bdrv_vdi_probe,
     bdrv_vhdx_probe,
     bdrv_vmdk_probe,
+    bdrv_vpc_probe
 };
 
 static QTAILQ_HEAD(, BlockDriverState) graph_bdrv_states =
diff --git a/block/vpc-probe.c b/block/vpc-probe.c
index afe8271..77cc4e7 100644
--- a/block/vpc-probe.c
+++ b/block/vpc-probe.c
@@ -1,9 +1,16 @@
 #include "qemu/osdep.h"
 #include "block/probe.h"
 
-int vpc_probe(const uint8_t *buf, int buf_size, const char *filename)
+const char *bdrv_vpc_probe(const uint8_t *buf, int buf_size,
+                           const char *filename, int *score)
 {
-    if (buf_size >= 8 && !strncmp((char *)buf, "conectix", 8))
-	return 100;
-    return 0;
+    const char *format = "vpc";
+    assert(score);
+    if (buf_size >= 8 && !strncmp((char *)buf, "conectix", 8)) {
+        *score = 100;
+        return format;
+    }
+
+    *score = 0;
+    return format;
 }
diff --git a/block/vpc.c b/block/vpc.c
index 7ab3e7f..78ed40a 100644
--- a/block/vpc.c
+++ b/block/vpc.c
@@ -1050,7 +1050,6 @@ static BlockDriver bdrv_vpc = {
     .format_name    = "vpc",
     .instance_size  = sizeof(BDRVVPCState),
 
-    .bdrv_probe             = vpc_probe,
     .bdrv_open              = vpc_open,
     .bdrv_close             = vpc_close,
     .bdrv_reopen_prepare    = vpc_reopen_prepare,
diff --git a/include/block/probe.h b/include/block/probe.h
index 8f2c26c..b320b20 100644
--- a/include/block/probe.h
+++ b/include/block/probe.h
@@ -1,7 +1,6 @@
 #ifndef PROBE_H
 #define PROBE_H
 
-int vpc_probe(const uint8_t *buf, int buf_size, const char *filename);
 const char *bdrv_bochs_probe(const uint8_t *buf, int buf_size,
                              const char *filename, int *score);
 const char *bdrv_cloop_probe(const uint8_t *buf, int buf_size,
@@ -26,5 +25,7 @@ const char *bdrv_vhdx_probe(const uint8_t *buf, int buf_size,
                             const char *filename, int *score);
 const char *bdrv_vmdk_probe(const uint8_t *buf, int buf_size,
                             const char *filename, int *score);
+const char *bdrv_vpc_probe(const uint8_t *buf, int buf_size,
+                           const char *filename, int *score);
 
 #endif
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [Qemu-devel] [PATCH v4 30/32] blockdev: Remove the .bdrv_probe field from BlockDrivers
  2016-07-14 19:02 [Qemu-devel] [PATCH v4 00/32] Dynamic module loading for block drivers Colin Lord
                   ` (28 preceding siblings ...)
  2016-07-14 19:03 ` [Qemu-devel] [PATCH v4 29/32] blockdev: Separate vpc " Colin Lord
@ 2016-07-14 19:03 ` Colin Lord
  2016-07-14 19:03 ` [Qemu-devel] [PATCH v4 31/32] blockdev: Separate out bdrv_probe_device functions Colin Lord
                   ` (2 subsequent siblings)
  32 siblings, 0 replies; 42+ messages in thread
From: Colin Lord @ 2016-07-14 19:03 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, qemu-block, mreitz, Colin Lord

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 <clord@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
---
 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

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [Qemu-devel] [PATCH v4 31/32] blockdev: Separate out bdrv_probe_device functions
  2016-07-14 19:02 [Qemu-devel] [PATCH v4 00/32] Dynamic module loading for block drivers Colin Lord
                   ` (29 preceding siblings ...)
  2016-07-14 19:03 ` [Qemu-devel] [PATCH v4 30/32] blockdev: Remove the .bdrv_probe field from BlockDrivers Colin Lord
@ 2016-07-14 19:03 ` Colin Lord
  2016-07-14 19:03 ` [Qemu-devel] [PATCH v4 32/32] blockdev: Remove bdrv_probe_device field from BlockDriver Colin Lord
  2016-07-19 10:54 ` [Qemu-devel] [PATCH v4 00/32] Dynamic module loading for block drivers Paolo Bonzini
  32 siblings, 0 replies; 42+ messages in thread
From: Colin Lord @ 2016-07-14 19:03 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, qemu-block, mreitz, Colin Lord

This puts the bdrv_probe_device functions into their own files to
facilitate the modularization of the block drivers.

Signed-off-by: Colin Lord <clord@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
---
 block/Makefile.objs       |  1 +
 block/host_cdrom-probe.c  | 40 +++++++++++++++++++++++++++++++++++++
 block/host_device-probe.c | 30 ++++++++++++++++++++++++++++
 block/raw-posix.c         | 51 +----------------------------------------------
 block/raw-win32.c         | 10 +---------
 include/block/probe.h     |  2 ++
 6 files changed, 75 insertions(+), 59 deletions(-)
 create mode 100644 block/host_cdrom-probe.c
 create mode 100644 block/host_device-probe.c

diff --git a/block/Makefile.objs b/block/Makefile.objs
index 6512073..fbc57f9 100644
--- a/block/Makefile.objs
+++ b/block/Makefile.objs
@@ -27,6 +27,7 @@ block-obj-y += crypto.o
 block-obj-y += bochs-probe.o cloop-probe.o crypto-probe.o dmg-probe.o
 block-obj-y += parallels-probe.o qcow-probe.o qcow2-probe.o qed-probe.o
 block-obj-y += raw-probe.o vdi-probe.o vhdx-probe.o vmdk-probe.o vpc-probe.o
+block-obj-y += host_device-probe.o host_cdrom-probe.o
 
 common-obj-y += stream.o
 common-obj-y += backup.o
diff --git a/block/host_cdrom-probe.c b/block/host_cdrom-probe.c
new file mode 100644
index 0000000..1886cad
--- /dev/null
+++ b/block/host_cdrom-probe.c
@@ -0,0 +1,40 @@
+#include "qemu/osdep.h"
+#include "block/probe.h"
+
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+int cdrom_probe_device(const char *filename)
+{
+    if (strstart(filename, "/dev/cd", NULL) ||
+            strstart(filename, "/dev/acd", NULL))
+        return 100;
+    return 0;
+}
+#elif defined(__linux__)
+#include <sys/ioctl.h>
+#include <linux/cdrom.h>
+int cdrom_probe_device(const char *filename)
+{
+    int fd, ret;
+    int prio = 0;
+    struct stat st;
+
+    fd = qemu_open(filename, O_RDONLY | O_NONBLOCK);
+    if (fd < 0) {
+        goto out;
+    }
+    ret = fstat(fd, &st);
+    if (ret == -1 || !S_ISBLK(st.st_mode)) {
+        goto outc;
+    }
+
+    /* Attempt to detect via a CDROM specific ioctl */
+    ret = ioctl(fd, CDROM_DRIVE_STATUS, CDSL_CURRENT);
+    if (ret >= 0)
+        prio = 100;
+
+outc:
+    qemu_close(fd);
+out:
+    return prio;
+}
+#endif
diff --git a/block/host_device-probe.c b/block/host_device-probe.c
new file mode 100644
index 0000000..ebd969b
--- /dev/null
+++ b/block/host_device-probe.c
@@ -0,0 +1,30 @@
+#include "qemu/osdep.h"
+#include "block/probe.h"
+#include "qemu/cutils.h"
+
+#ifdef _WIN32
+int hdev_probe_device(const char *filename)
+{
+    if (strstart(filename, "/dev/cdrom", NULL))
+        return 100;
+    if (is_windows_drive(filename))
+        return 100;
+    return 0;
+}
+#else
+int hdev_probe_device(const char *filename)
+{
+    struct stat st;
+
+    /* allow a dedicated CD-ROM driver to match with a higher priority */
+    if (strstart(filename, "/dev/cdrom", NULL))
+        return 50;
+
+    if (stat(filename, &st) >= 0 &&
+            (S_ISCHR(st.st_mode) || S_ISBLK(st.st_mode))) {
+        return 100;
+    }
+
+    return 0;
+}
+#endif
diff --git a/block/raw-posix.c b/block/raw-posix.c
index e321bcd..f42b74a 100644
--- a/block/raw-posix.c
+++ b/block/raw-posix.c
@@ -28,6 +28,7 @@
 #include "qemu/timer.h"
 #include "qemu/log.h"
 #include "block/block_int.h"
+#include "block/probe.h"
 #include "qemu/module.h"
 #include "trace.h"
 #include "block/thread-pool.h"
@@ -2084,22 +2085,6 @@ static void print_unmounting_directions(const char *file_name)
 
 #endif /* defined(__APPLE__) && defined(__MACH__) */
 
-static int hdev_probe_device(const char *filename)
-{
-    struct stat st;
-
-    /* allow a dedicated CD-ROM driver to match with a higher priority */
-    if (strstart(filename, "/dev/cdrom", NULL))
-        return 50;
-
-    if (stat(filename, &st) >= 0 &&
-            (S_ISCHR(st.st_mode) || S_ISBLK(st.st_mode))) {
-        return 100;
-    }
-
-    return 0;
-}
-
 static int check_hdev_writable(BDRVRawState *s)
 {
 #if defined(BLKROGET)
@@ -2441,32 +2426,6 @@ static int cdrom_open(BlockDriverState *bs, QDict *options, int flags,
     return raw_open_common(bs, options, flags, O_NONBLOCK, errp);
 }
 
-static int cdrom_probe_device(const char *filename)
-{
-    int fd, ret;
-    int prio = 0;
-    struct stat st;
-
-    fd = qemu_open(filename, O_RDONLY | O_NONBLOCK);
-    if (fd < 0) {
-        goto out;
-    }
-    ret = fstat(fd, &st);
-    if (ret == -1 || !S_ISBLK(st.st_mode)) {
-        goto outc;
-    }
-
-    /* Attempt to detect via a CDROM specific ioctl */
-    ret = ioctl(fd, CDROM_DRIVE_STATUS, CDSL_CURRENT);
-    if (ret >= 0)
-        prio = 100;
-
-outc:
-    qemu_close(fd);
-out:
-    return prio;
-}
-
 static bool cdrom_is_inserted(BlockDriverState *bs)
 {
     BDRVRawState *s = bs->opaque;
@@ -2565,14 +2524,6 @@ static int cdrom_open(BlockDriverState *bs, QDict *options, int flags,
     return 0;
 }
 
-static int cdrom_probe_device(const char *filename)
-{
-    if (strstart(filename, "/dev/cd", NULL) ||
-            strstart(filename, "/dev/acd", NULL))
-        return 100;
-    return 0;
-}
-
 static int cdrom_reopen(BlockDriverState *bs)
 {
     BDRVRawState *s = bs->opaque;
diff --git a/block/raw-win32.c b/block/raw-win32.c
index 62edb1a..5afab2a 100644
--- a/block/raw-win32.c
+++ b/block/raw-win32.c
@@ -26,6 +26,7 @@
 #include "qemu/cutils.h"
 #include "qemu/timer.h"
 #include "block/block_int.h"
+#include "block/probe.h"
 #include "qemu/module.h"
 #include "raw-aio.h"
 #include "trace.h"
@@ -615,15 +616,6 @@ static int find_device_type(BlockDriverState *bs, const char *filename)
     }
 }
 
-static int hdev_probe_device(const char *filename)
-{
-    if (strstart(filename, "/dev/cdrom", NULL))
-        return 100;
-    if (is_windows_drive(filename))
-        return 100;
-    return 0;
-}
-
 static void hdev_parse_filename(const char *filename, QDict *options,
                                 Error **errp)
 {
diff --git a/include/block/probe.h b/include/block/probe.h
index b320b20..4d5feb4 100644
--- a/include/block/probe.h
+++ b/include/block/probe.h
@@ -27,5 +27,7 @@ const char *bdrv_vmdk_probe(const uint8_t *buf, int buf_size,
                             const char *filename, int *score);
 const char *bdrv_vpc_probe(const uint8_t *buf, int buf_size,
                            const char *filename, int *score);
+int hdev_probe_device(const char *filename);
+int cdrom_probe_device(const char *filename);
 
 #endif
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [Qemu-devel] [PATCH v4 32/32] blockdev: Remove bdrv_probe_device field from BlockDriver
  2016-07-14 19:02 [Qemu-devel] [PATCH v4 00/32] Dynamic module loading for block drivers Colin Lord
                   ` (30 preceding siblings ...)
  2016-07-14 19:03 ` [Qemu-devel] [PATCH v4 31/32] blockdev: Separate out bdrv_probe_device functions Colin Lord
@ 2016-07-14 19:03 ` Colin Lord
  2016-07-19 10:54 ` [Qemu-devel] [PATCH v4 00/32] Dynamic module loading for block drivers Paolo Bonzini
  32 siblings, 0 replies; 42+ messages in thread
From: Colin Lord @ 2016-07-14 19:03 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, qemu-block, mreitz, Colin Lord

This commit finalizes the separation of the BlockDriver from its
device probing function. Now the accesses to these functions in block.c
occur through the protocol_probes array, and each function returns a
score and protocol name with which to find the corresponding driver.

Signed-off-by: Colin Lord <clord@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
---
 block.c                         | 46 ++++++++++++++++++++++++++++++-----------
 block/host_cdrom-probe.c        | 23 ++++++++++++++-------
 block/host_device-probe.c       | 34 ++++++++++++++++++++----------
 block/raw-posix.c               |  3 ---
 block/raw-win32.c               |  1 -
 include/block/block_int.h       |  2 --
 include/block/probe.h           |  4 ++--
 scripts/modules/module_block.py | 12 ++---------
 8 files changed, 76 insertions(+), 49 deletions(-)

diff --git a/block.c b/block.c
index 20b93cf..a129376 100644
--- a/block.c
+++ b/block.c
@@ -59,6 +59,7 @@
 
 typedef const char *BdrvProbeFunc(const uint8_t *buf, int buf_size,
                                   const char *filename, int *score);
+typedef const char *BdrvProbeDevFunc(const char *filename, int *score);
 
 static BdrvProbeFunc *format_probes[] = {
     bdrv_bochs_probe,
@@ -76,6 +77,13 @@ static BdrvProbeFunc *format_probes[] = {
     bdrv_vpc_probe
 };
 
+static BdrvProbeDevFunc *protocol_probes[] = {
+    hdev_probe_device,
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__linux__)
+    cdrom_probe_device
+#endif
+};
+
 static QTAILQ_HEAD(, BlockDriverState) graph_bdrv_states =
     QTAILQ_HEAD_INITIALIZER(graph_bdrv_states);
 
@@ -95,6 +103,8 @@ static BlockDriverState *bdrv_open_inherit(const char *filename,
 /* If non-zero, use only whitelisted block drivers */
 static int use_bdrv_whitelist;
 
+static BlockDriver *bdrv_do_find_protocol(const char *protocol);
+
 #ifdef _WIN32
 static int is_windows_drive_prefix(const char *filename)
 {
@@ -487,25 +497,37 @@ int get_tmp_filename(char *filename, int size)
 static BlockDriver *find_hdev_driver(const char *filename)
 {
     int score_max = 0, score;
+    const char *protocol_max = NULL;
+    const char *protocol;
+    BlockDriver *drv;
     size_t i;
-    BlockDriver *drv = NULL, *d;
+
+    for (i = 0; i < ARRAY_SIZE(protocol_probes); i++) {
+        protocol = protocol_probes[i](filename, &score);
+        if (score > score_max) {
+            protocol_max = protocol;
+            score_max = score;
+        }
+    }
+
+    if (!protocol_max) {
+        return NULL;
+    }
+
+    drv = bdrv_do_find_protocol(protocol_max);
+    if (drv) {
+        return drv;
+    }
 
     for (i = 0; i < ARRAY_SIZE(block_driver_modules); ++i) {
-        if (block_driver_modules[i].has_probe_device) {
+        if (block_driver_modules[i].protocol_name &&
+            !strcmp(block_driver_modules[i].protocol_name, protocol_max)) {
             block_module_load_one(block_driver_modules[i].library_name);
+            break;
         }
     }
 
-    QLIST_FOREACH(d, &bdrv_drivers, list) {
-        if (d->bdrv_probe_device) {
-            score = d->bdrv_probe_device(filename);
-            if (score > score_max) {
-                score_max = score;
-                drv = d;
-            }
-        }
-    }
-
+    drv = bdrv_do_find_protocol(protocol);
     return drv;
 }
 
diff --git a/block/host_cdrom-probe.c b/block/host_cdrom-probe.c
index 1886cad..3f7d863 100644
--- a/block/host_cdrom-probe.c
+++ b/block/host_cdrom-probe.c
@@ -1,22 +1,28 @@
 #include "qemu/osdep.h"
 #include "block/probe.h"
 
+static const char *protocol = "host_cdrom";
+
 #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
-int cdrom_probe_device(const char *filename)
+const char *cdrom_probe_device(const char *filename, int *score)
 {
+    assert(score);
     if (strstart(filename, "/dev/cd", NULL) ||
-            strstart(filename, "/dev/acd", NULL))
-        return 100;
+        strstart(filename, "/dev/acd", NULL)) {
+        *score = 100;
+        return protocol;
+    }
     return 0;
 }
 #elif defined(__linux__)
 #include <sys/ioctl.h>
 #include <linux/cdrom.h>
-int cdrom_probe_device(const char *filename)
+const char *cdrom_probe_device(const char *filename, int *score)
 {
     int fd, ret;
-    int prio = 0;
     struct stat st;
+    assert(score);
+    *score = 0;
 
     fd = qemu_open(filename, O_RDONLY | O_NONBLOCK);
     if (fd < 0) {
@@ -29,12 +35,13 @@ int cdrom_probe_device(const char *filename)
 
     /* Attempt to detect via a CDROM specific ioctl */
     ret = ioctl(fd, CDROM_DRIVE_STATUS, CDSL_CURRENT);
-    if (ret >= 0)
-        prio = 100;
+    if (ret >= 0) {
+        *score = 100;
+    }
 
 outc:
     qemu_close(fd);
 out:
-    return prio;
+    return protocol;
 }
 #endif
diff --git a/block/host_device-probe.c b/block/host_device-probe.c
index ebd969b..b4e4d20 100644
--- a/block/host_device-probe.c
+++ b/block/host_device-probe.c
@@ -2,29 +2,41 @@
 #include "block/probe.h"
 #include "qemu/cutils.h"
 
+static const char *protocol = "host_device";
+
 #ifdef _WIN32
-int hdev_probe_device(const char *filename)
+const char *hdev_probe_device(const char *filename, int *score)
 {
-    if (strstart(filename, "/dev/cdrom", NULL))
-        return 100;
-    if (is_windows_drive(filename))
-        return 100;
-    return 0;
+    assert(score);
+    *score = 100;
+    if (strstart(filename, "/dev/cdrom", NULL)) {
+        return protocol;
+    }
+    if (is_windows_drive(filename)) {
+        return protocol
+    }
+    *score = 0;
+    return protocol;
 }
 #else
-int hdev_probe_device(const char *filename)
+const char *hdev_probe_device(const char *filename, int *score)
 {
     struct stat st;
+    assert(score);
 
     /* allow a dedicated CD-ROM driver to match with a higher priority */
-    if (strstart(filename, "/dev/cdrom", NULL))
-        return 50;
+    if (strstart(filename, "/dev/cdrom", NULL)) {
+        *score = 50;
+        return protocol;
+    }
 
     if (stat(filename, &st) >= 0 &&
             (S_ISCHR(st.st_mode) || S_ISBLK(st.st_mode))) {
-        return 100;
+        *score = 100;
+        return protocol;
     }
 
-    return 0;
+    *score = 0;
+    return protocol;
 }
 #endif
diff --git a/block/raw-posix.c b/block/raw-posix.c
index f42b74a..90c65f9 100644
--- a/block/raw-posix.c
+++ b/block/raw-posix.c
@@ -2367,7 +2367,6 @@ static BlockDriver bdrv_host_device = {
     .protocol_name        = "host_device",
     .instance_size      = sizeof(BDRVRawState),
     .bdrv_needs_filename = true,
-    .bdrv_probe_device  = hdev_probe_device,
     .bdrv_parse_filename = hdev_parse_filename,
     .bdrv_file_open     = hdev_open,
     .bdrv_close         = raw_close,
@@ -2466,7 +2465,6 @@ static BlockDriver bdrv_host_cdrom = {
     .protocol_name      = "host_cdrom",
     .instance_size      = sizeof(BDRVRawState),
     .bdrv_needs_filename = true,
-    .bdrv_probe_device	= cdrom_probe_device,
     .bdrv_parse_filename = cdrom_parse_filename,
     .bdrv_file_open     = cdrom_open,
     .bdrv_close         = raw_close,
@@ -2592,7 +2590,6 @@ static BlockDriver bdrv_host_cdrom = {
     .protocol_name      = "host_cdrom",
     .instance_size      = sizeof(BDRVRawState),
     .bdrv_needs_filename = true,
-    .bdrv_probe_device	= cdrom_probe_device,
     .bdrv_parse_filename = cdrom_parse_filename,
     .bdrv_file_open     = cdrom_open,
     .bdrv_close         = raw_close,
diff --git a/block/raw-win32.c b/block/raw-win32.c
index 5afab2a..b4f64e7 100644
--- a/block/raw-win32.c
+++ b/block/raw-win32.c
@@ -696,7 +696,6 @@ static BlockDriver bdrv_host_device = {
     .instance_size	= sizeof(BDRVRawState),
     .bdrv_needs_filename = true,
     .bdrv_parse_filename = hdev_parse_filename,
-    .bdrv_probe_device	= hdev_probe_device,
     .bdrv_file_open	= hdev_open,
     .bdrv_close		= raw_close,
 
diff --git a/include/block/block_int.h b/include/block/block_int.h
index 23f229d..87bb487 100644
--- a/include/block/block_int.h
+++ b/include/block/block_int.h
@@ -99,8 +99,6 @@ struct BlockDriver {
     bool (*bdrv_recurse_is_first_non_filter)(BlockDriverState *bs,
                                              BlockDriverState *candidate);
 
-    int (*bdrv_probe_device)(const char *filename);
-
     /* Any driver implementing this callback is expected to be able to handle
      * NULL file names in its .bdrv_open() implementation */
     void (*bdrv_parse_filename)(const char *filename, QDict *options, Error **errp);
diff --git a/include/block/probe.h b/include/block/probe.h
index 4d5feb4..e96cd2f 100644
--- a/include/block/probe.h
+++ b/include/block/probe.h
@@ -27,7 +27,7 @@ const char *bdrv_vmdk_probe(const uint8_t *buf, int buf_size,
                             const char *filename, int *score);
 const char *bdrv_vpc_probe(const uint8_t *buf, int buf_size,
                            const char *filename, int *score);
-int hdev_probe_device(const char *filename);
-int cdrom_probe_device(const char *filename);
+const char *hdev_probe_device(const char *filename, int *score);
+const char *cdrom_probe_device(const char *filename, int *score);
 
 #endif
diff --git a/scripts/modules/module_block.py b/scripts/modules/module_block.py
index dba1717..db4fb54 100644
--- a/scripts/modules/module_block.py
+++ b/scripts/modules/module_block.py
@@ -23,16 +23,13 @@ def get_string_struct(line):
 
     return data[2].replace('"', '')[:-1]
 
-def add_module(fheader, library, format_name, protocol_name,
-               probe_device):
+def add_module(fheader, library, format_name, protocol_name):
     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_device:
-        lines.append('.has_probe_device = true,')
 
     text = '\n        '.join(lines)
     fheader.write('\n    {\n        ' + text + '\n    },')
@@ -50,18 +47,14 @@ 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_device") != -1:
-                    probe_device = True
                 elif line == "};":
-                    add_module(fheader, library, format_name, protocol_name,
-                               probe_device)
+                    add_module(fheader, library, format_name, protocol_name)
                     found_start = False
             elif line.find("static BlockDriver") != -1:
                 found_something = True
                 found_start = True
                 format_name = ""
                 protocol_name = ""
-                probe_device = False
 
         if not found_something:
             print("No BlockDriver struct found in " + filename + ". \
@@ -88,7 +81,6 @@ static const struct {
     const char *format_name;
     const char *protocol_name;
     const char *library_name;
-    bool has_probe_device;
 } block_driver_modules[] = {''')
 
 def print_bottom(fheader):
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* Re: [Qemu-devel] [PATCH v4 17/32] blockdev: Separate bochs probe from its driver
  2016-07-14 19:03 ` [Qemu-devel] [PATCH v4 17/32] blockdev: Separate bochs probe from its driver Colin Lord
@ 2016-07-18 16:28   ` Max Reitz
  2016-07-18 19:44     ` Colin Lord
  0 siblings, 1 reply; 42+ messages in thread
From: Max Reitz @ 2016-07-18 16:28 UTC (permalink / raw)
  To: Colin Lord, qemu-devel; +Cc: kwolf, qemu-block

[-- Attachment #1: Type: text/plain, Size: 1580 bytes --]

On 14.07.2016 21:03, Colin Lord wrote:
> Modifies the bochs probe to return the format name as well as the
> score as the final step of separating the probe function from the
> driver. This keeps the probe completely independent of the driver,
> making future modularization easier to accomplish. Returning the format
> name as well as the score allows the score to be correlated to the
> driver without the probe function needing to be part of the driver.
> 
> Signed-off-by: Colin Lord <clord@redhat.com>
> ---
>  block.c               | 20 ++++++++++++++++++++
>  block/bochs-probe.c   | 25 ++++++++++++++++---------
>  block/bochs.c         |  1 -
>  include/block/probe.h |  3 ++-
>  4 files changed, 38 insertions(+), 11 deletions(-)
> 
> diff --git a/block.c b/block.c
> index 3a0dc19..b16f8cf 100644
> --- a/block.c
> +++ b/block.c
> @@ -25,6 +25,7 @@
>  #include "trace.h"
>  #include "block/block_int.h"
>  #include "block/blockjob.h"
> +#include "block/probe.h"
>  #include "qemu/error-report.h"
>  #include "module_block.h"
>  #include "qemu/module.h"
> @@ -56,6 +57,13 @@
>  
>  #define NOT_DONE 0x7fffffff /* used while emulated sync operation in progress */
>  
> +typedef const char *BdrvProbeFunc(const uint8_t *buf, int buf_size,
> +                                  const char *filename, int *score);
> +
> +static BdrvProbeFunc *format_probes[] = {
> +    bdrv_bochs_probe,
> +};
> +

I really can't convince you of my "struct concept", can I? :-)

Unless maybe I can:

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


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 498 bytes --]

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [Qemu-devel] [PATCH v4 17/32] blockdev: Separate bochs probe from its driver
  2016-07-18 16:28   ` Max Reitz
@ 2016-07-18 19:44     ` Colin Lord
  0 siblings, 0 replies; 42+ messages in thread
From: Colin Lord @ 2016-07-18 19:44 UTC (permalink / raw)
  To: Max Reitz, qemu-devel; +Cc: kwolf, qemu-block

On 07/18/2016 12:28 PM, Max Reitz wrote:
> On 14.07.2016 21:03, Colin Lord wrote:
>> Modifies the bochs probe to return the format name as well as the
>> score as the final step of separating the probe function from the
>> driver. This keeps the probe completely independent of the driver,
>> making future modularization easier to accomplish. Returning the format
>> name as well as the score allows the score to be correlated to the
>> driver without the probe function needing to be part of the driver.
>>
>> Signed-off-by: Colin Lord <clord@redhat.com>
>> ---
>>  block.c               | 20 ++++++++++++++++++++
>>  block/bochs-probe.c   | 25 ++++++++++++++++---------
>>  block/bochs.c         |  1 -
>>  include/block/probe.h |  3 ++-
>>  4 files changed, 38 insertions(+), 11 deletions(-)
>>
>> diff --git a/block.c b/block.c
>> index 3a0dc19..b16f8cf 100644
>> --- a/block.c
>> +++ b/block.c
>> @@ -25,6 +25,7 @@
>>  #include "trace.h"
>>  #include "block/block_int.h"
>>  #include "block/blockjob.h"
>> +#include "block/probe.h"
>>  #include "qemu/error-report.h"
>>  #include "module_block.h"
>>  #include "qemu/module.h"
>> @@ -56,6 +57,13 @@
>>  
>>  #define NOT_DONE 0x7fffffff /* used while emulated sync operation in progress */
>>  
>> +typedef const char *BdrvProbeFunc(const uint8_t *buf, int buf_size,
>> +                                  const char *filename, int *score);
>> +
>> +static BdrvProbeFunc *format_probes[] = {
>> +    bdrv_bochs_probe,
>> +};
>> +
> 
> I really can't convince you of my "struct concept", can I? :-)
> 
> Unless maybe I can:
> 
> Reviewed-by: Max Reitz <mreitz@redhat.com>
> 
If you really want me to I could go back and change it. I do have to
agree that it's a little odd to be returning the same string every time,
but it also strikes me as pretty weird if the probing functions
themselves can't even be associated with their drivers without the help
of another struct. It doesn't seem quite right to me if the functions
can't be used independently of the struct containing the mappings.
Technically of course they could still be used, but without the mappings
they are practically indistinguishable from each other so they're
basically useless.

Since both options seem to have their own quirks, I'm not too excited to
go back and edit all the patches only to end up with something I see as
equally weird. But again, if you (or others) really want me to change
it, or show me why having a bunch of indistinguishable probing functions
isn't as weird as I think, I could certainly do so.

Colin

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [Qemu-devel] [PATCH v4 00/32] Dynamic module loading for block drivers
  2016-07-14 19:02 [Qemu-devel] [PATCH v4 00/32] Dynamic module loading for block drivers Colin Lord
                   ` (31 preceding siblings ...)
  2016-07-14 19:03 ` [Qemu-devel] [PATCH v4 32/32] blockdev: Remove bdrv_probe_device field from BlockDriver Colin Lord
@ 2016-07-19 10:54 ` Paolo Bonzini
  2016-07-19 13:47   ` Colin Lord
  2016-07-22 16:27   ` Max Reitz
  32 siblings, 2 replies; 42+ messages in thread
From: Paolo Bonzini @ 2016-07-19 10:54 UTC (permalink / raw)
  To: Colin Lord, qemu-devel; +Cc: kwolf, qemu-block, mreitz



On 14/07/2016 21:02, Colin Lord wrote:
> Here's v4 of the modularization series. Things that have changed since
> v3 include:
> 
> - Fix indentation of the generated header file module_block.h
> - Drivers and probe functions are now all located in the block/
>   directory, rather than being split between block/ and block/probe/. In
>   addition the header files for each probe/driver pair are in the block/
>   directory, not the include/block/driver/ directory (which no longer
>   exists).
> - Since the probe files are in block/ now, they follow the naming
>   pattern of format-probe.c
> - Renamed crypto probe file to be crypto-probe.c, luks is no longer in
>   the filename
> - Fixed formatting of parallels_probe() function header
> - Enforced consistent naming convention for the probe functions. They
>   now follow the pattern bdrv_format_probe().

It's still not clear to me why probes need to be separate for drivers
that (presumably) will never be modularized.

Paolo

> Colin Lord (30):
>   blockdev: prepare iSCSI block driver for dynamic loading
>   blockdev: Move bochs probe into separate file
>   blockdev: Move cloop probe to its own file
>   blockdev: Move luks probe to its own file
>   blockdev: Move dmg probe to its own file
>   blockdev: Move parallels probe to its own file
>   blockdev: Move qcow probe to its own file
>   blockdev: Move qcow2 probe to its own file
>   blockdev: Move qed probe to its own file
>   blockdev: Move raw probe to its own file
>   blockdev: Move vdi probe to its own file
>   blockdev: Move vhdx probe to its own file
>   blockdev: Move vmdk probe to its own file
>   blockdev: Move vpc probe to its own file
>   blockdev: Separate bochs probe from its driver
>   blockdev: Separate cloop probe from its driver
>   blockdev: Separate luks probe from its driver
>   blockdev: Separate dmg probe from its driver
>   blockdev: Separate parallels probe from its driver
>   blockdev: Separate qcow probe from its driver
>   blockdev: Separate qcow2 probe from its driver
>   blockdev: Separate qed probe from its driver
>   blockdev: Separate raw probe from its driver
>   blockdev: Separate vdi probe from its driver
>   blockdev: Separate vhdx probe from its driver
>   blockdev: Separate vmdk probe from its driver
>   blockdev: Separate vpc probe from its driver
>   blockdev: Remove the .bdrv_probe field from BlockDrivers
>   blockdev: Separate out bdrv_probe_device functions
>   blockdev: Remove bdrv_probe_device field from BlockDriver
> 
> Marc Mari (2):
>   blockdev: Add dynamic generation of module_block.h
>   blockdev: Add dynamic module loading for block drivers
> 
>  Makefile                        |   7 ++
>  block.c                         | 181 ++++++++++++++++++++++++++++++++--------
>  block/Makefile.objs             |   4 +
>  block/bochs-probe.c             |  28 +++++++
>  block/bochs.c                   |  56 +------------
>  block/bochs.h                   |  40 +++++++++
>  block/cloop-probe.c             |  22 +++++
>  block/cloop.c                   |  17 +---
>  block/crypto-probe.c            |  26 ++++++
>  block/crypto.c                  |  22 +----
>  block/dmg-probe.c               |  22 +++++
>  block/dmg.c                     |  17 +---
>  block/host_cdrom-probe.c        |  47 +++++++++++
>  block/host_device-probe.c       |  42 ++++++++++
>  block/iscsi.c                   |  36 --------
>  block/parallels-probe.c         |  26 ++++++
>  block/parallels.c               |  44 +---------
>  block/parallels.h               |  26 ++++++
>  block/qcow-probe.c              |  22 +++++
>  block/qcow.c                    |  32 +------
>  block/qcow.h                    |  21 +++++
>  block/qcow2-probe.c             |  22 +++++
>  block/qcow2.c                   |  14 +---
>  block/qed-probe.c               |  24 ++++++
>  block/qed.c                     |  16 +---
>  block/raw-posix.c               |  55 +-----------
>  block/raw-probe.c               |  14 ++++
>  block/raw-win32.c               |  11 +--
>  block/raw_bsd.c                 |  10 +--
>  block/vdi-probe.c               |  29 +++++++
>  block/vdi.c                     |  70 +---------------
>  block/vdi.h                     |  49 +++++++++++
>  block/vhdx-probe.c              |  27 ++++++
>  block/vhdx.c                    |  21 +----
>  block/vmdk-probe.c              |  67 +++++++++++++++
>  block/vmdk.c                    |  61 +-------------
>  block/vmdk.h                    |   7 ++
>  block/vpc-probe.c               |  16 ++++
>  block/vpc.c                     |   9 +-
>  include/block/block_int.h       |   3 -
>  include/block/probe.h           |  33 ++++++++
>  include/qemu/module.h           |   3 +
>  scripts/modules/module_block.py | 108 ++++++++++++++++++++++++
>  util/module.c                   |  38 +++------
>  vl.c                            |  38 +++++++++
>  45 files changed, 948 insertions(+), 535 deletions(-)
>  create mode 100644 block/bochs-probe.c
>  create mode 100644 block/bochs.h
>  create mode 100644 block/cloop-probe.c
>  create mode 100644 block/crypto-probe.c
>  create mode 100644 block/dmg-probe.c
>  create mode 100644 block/host_cdrom-probe.c
>  create mode 100644 block/host_device-probe.c
>  create mode 100644 block/parallels-probe.c
>  create mode 100644 block/parallels.h
>  create mode 100644 block/qcow-probe.c
>  create mode 100644 block/qcow.h
>  create mode 100644 block/qcow2-probe.c
>  create mode 100644 block/qed-probe.c
>  create mode 100644 block/raw-probe.c
>  create mode 100644 block/vdi-probe.c
>  create mode 100644 block/vdi.h
>  create mode 100644 block/vhdx-probe.c
>  create mode 100644 block/vmdk-probe.c
>  create mode 100644 block/vmdk.h
>  create mode 100644 block/vpc-probe.c
>  create mode 100644 include/block/probe.h
>  create mode 100644 scripts/modules/module_block.py
> 

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [Qemu-devel] [PATCH v4 00/32] Dynamic module loading for block drivers
  2016-07-19 10:54 ` [Qemu-devel] [PATCH v4 00/32] Dynamic module loading for block drivers Paolo Bonzini
@ 2016-07-19 13:47   ` Colin Lord
  2016-07-19 14:42     ` Paolo Bonzini
  2016-07-22 16:27   ` Max Reitz
  1 sibling, 1 reply; 42+ messages in thread
From: Colin Lord @ 2016-07-19 13:47 UTC (permalink / raw)
  To: Paolo Bonzini, qemu-devel; +Cc: kwolf, qemu-block, mreitz

On 07/19/2016 06:54 AM, Paolo Bonzini wrote:
> 
> 
> On 14/07/2016 21:02, Colin Lord wrote:
>> Here's v4 of the modularization series. Things that have changed since
>> v3 include:
>>
>> - Fix indentation of the generated header file module_block.h
>> - Drivers and probe functions are now all located in the block/
>>   directory, rather than being split between block/ and block/probe/. In
>>   addition the header files for each probe/driver pair are in the block/
>>   directory, not the include/block/driver/ directory (which no longer
>>   exists).
>> - Since the probe files are in block/ now, they follow the naming
>>   pattern of format-probe.c
>> - Renamed crypto probe file to be crypto-probe.c, luks is no longer in
>>   the filename
>> - Fixed formatting of parallels_probe() function header
>> - Enforced consistent naming convention for the probe functions. They
>>   now follow the pattern bdrv_format_probe().
> 
> It's still not clear to me why probes need to be separate for drivers
> that (presumably) will never be modularized.
> 
I was hoping someone more experienced with this project would respond to
you the last time you asked this, so apologies if it felt like I was
ignoring it. I'll tell you what I'm seeing from my perspective though
and hopefully that can get some discussion going.

As far as performance benefits go, you are correct that modularizing the
drivers that these probes are being separated from will have essentially
no effect. At this point it's more of a question of how the project
should be organized. I can see why having modules seems like a nice
organization of things, but on the other hand it does move code around
without accomplishing anything other than a different project structure.

However, the protocol drivers do tend to see noticeable performance
benefits. Most of them get modularized in the first three patches of
this series. This includes the iscsi, glusterfs, ssh, curl, and rbd
drivers. A minimal configuration excluding all of these drivers takes
around 3 ms to reach main(), and each of these drivers respectively add
times of approximately 0.2, 0.9, 1.2, 2.5, and a massive time of 41.6 ms
to the time to main. So some of these aren't even a huge benefit by
themselves but they do add up, and also it makes sense to modularize all
of the protocol drivers if we're already modularizing one.

As for the format drivers, as I said that's a question of project
structure. The dmg driver is in this patch series simply because it was
there in Marc's patches and I didn't remove it, and only recently did I
realize that it wouldn't actually affect performance. I think the whole
deal of probes being separated just fell out from having the dmg driver
modularized. There is maybe an argument to be made that if the protocol
drivers are getting modularized, the format drivers should as well just
for consistency, but at the end of the day it's mostly just personal
preferences I think, and I will add to that that although this series
only modularizes dmg, if this series goes through I'll be working on
modularizing the rest of them as well. Most of them should be trivial to
modularize, although there may be a tricky one or two that I'm not aware
of yet.

Hopefully this has helped make the situation more clear.

Colin

> Paolo
> 
>> Colin Lord (30):
>>   blockdev: prepare iSCSI block driver for dynamic loading
>>   blockdev: Move bochs probe into separate file
>>   blockdev: Move cloop probe to its own file
>>   blockdev: Move luks probe to its own file
>>   blockdev: Move dmg probe to its own file
>>   blockdev: Move parallels probe to its own file
>>   blockdev: Move qcow probe to its own file
>>   blockdev: Move qcow2 probe to its own file
>>   blockdev: Move qed probe to its own file
>>   blockdev: Move raw probe to its own file
>>   blockdev: Move vdi probe to its own file
>>   blockdev: Move vhdx probe to its own file
>>   blockdev: Move vmdk probe to its own file
>>   blockdev: Move vpc probe to its own file
>>   blockdev: Separate bochs probe from its driver
>>   blockdev: Separate cloop probe from its driver
>>   blockdev: Separate luks probe from its driver
>>   blockdev: Separate dmg probe from its driver
>>   blockdev: Separate parallels probe from its driver
>>   blockdev: Separate qcow probe from its driver
>>   blockdev: Separate qcow2 probe from its driver
>>   blockdev: Separate qed probe from its driver
>>   blockdev: Separate raw probe from its driver
>>   blockdev: Separate vdi probe from its driver
>>   blockdev: Separate vhdx probe from its driver
>>   blockdev: Separate vmdk probe from its driver
>>   blockdev: Separate vpc probe from its driver
>>   blockdev: Remove the .bdrv_probe field from BlockDrivers
>>   blockdev: Separate out bdrv_probe_device functions
>>   blockdev: Remove bdrv_probe_device field from BlockDriver
>>
>> Marc Mari (2):
>>   blockdev: Add dynamic generation of module_block.h
>>   blockdev: Add dynamic module loading for block drivers
>>
>>  Makefile                        |   7 ++
>>  block.c                         | 181 ++++++++++++++++++++++++++++++++--------
>>  block/Makefile.objs             |   4 +
>>  block/bochs-probe.c             |  28 +++++++
>>  block/bochs.c                   |  56 +------------
>>  block/bochs.h                   |  40 +++++++++
>>  block/cloop-probe.c             |  22 +++++
>>  block/cloop.c                   |  17 +---
>>  block/crypto-probe.c            |  26 ++++++
>>  block/crypto.c                  |  22 +----
>>  block/dmg-probe.c               |  22 +++++
>>  block/dmg.c                     |  17 +---
>>  block/host_cdrom-probe.c        |  47 +++++++++++
>>  block/host_device-probe.c       |  42 ++++++++++
>>  block/iscsi.c                   |  36 --------
>>  block/parallels-probe.c         |  26 ++++++
>>  block/parallels.c               |  44 +---------
>>  block/parallels.h               |  26 ++++++
>>  block/qcow-probe.c              |  22 +++++
>>  block/qcow.c                    |  32 +------
>>  block/qcow.h                    |  21 +++++
>>  block/qcow2-probe.c             |  22 +++++
>>  block/qcow2.c                   |  14 +---
>>  block/qed-probe.c               |  24 ++++++
>>  block/qed.c                     |  16 +---
>>  block/raw-posix.c               |  55 +-----------
>>  block/raw-probe.c               |  14 ++++
>>  block/raw-win32.c               |  11 +--
>>  block/raw_bsd.c                 |  10 +--
>>  block/vdi-probe.c               |  29 +++++++
>>  block/vdi.c                     |  70 +---------------
>>  block/vdi.h                     |  49 +++++++++++
>>  block/vhdx-probe.c              |  27 ++++++
>>  block/vhdx.c                    |  21 +----
>>  block/vmdk-probe.c              |  67 +++++++++++++++
>>  block/vmdk.c                    |  61 +-------------
>>  block/vmdk.h                    |   7 ++
>>  block/vpc-probe.c               |  16 ++++
>>  block/vpc.c                     |   9 +-
>>  include/block/block_int.h       |   3 -
>>  include/block/probe.h           |  33 ++++++++
>>  include/qemu/module.h           |   3 +
>>  scripts/modules/module_block.py | 108 ++++++++++++++++++++++++
>>  util/module.c                   |  38 +++------
>>  vl.c                            |  38 +++++++++
>>  45 files changed, 948 insertions(+), 535 deletions(-)
>>  create mode 100644 block/bochs-probe.c
>>  create mode 100644 block/bochs.h
>>  create mode 100644 block/cloop-probe.c
>>  create mode 100644 block/crypto-probe.c
>>  create mode 100644 block/dmg-probe.c
>>  create mode 100644 block/host_cdrom-probe.c
>>  create mode 100644 block/host_device-probe.c
>>  create mode 100644 block/parallels-probe.c
>>  create mode 100644 block/parallels.h
>>  create mode 100644 block/qcow-probe.c
>>  create mode 100644 block/qcow.h
>>  create mode 100644 block/qcow2-probe.c
>>  create mode 100644 block/qed-probe.c
>>  create mode 100644 block/raw-probe.c
>>  create mode 100644 block/vdi-probe.c
>>  create mode 100644 block/vdi.h
>>  create mode 100644 block/vhdx-probe.c
>>  create mode 100644 block/vmdk-probe.c
>>  create mode 100644 block/vmdk.h
>>  create mode 100644 block/vpc-probe.c
>>  create mode 100644 include/block/probe.h
>>  create mode 100644 scripts/modules/module_block.py
>>

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [Qemu-devel] [PATCH v4 00/32] Dynamic module loading for block drivers
  2016-07-19 13:47   ` Colin Lord
@ 2016-07-19 14:42     ` Paolo Bonzini
  2016-07-19 15:06       ` Daniel P. Berrange
  0 siblings, 1 reply; 42+ messages in thread
From: Paolo Bonzini @ 2016-07-19 14:42 UTC (permalink / raw)
  To: Colin Lord, qemu-devel; +Cc: kwolf, qemu-block, mreitz



On 19/07/2016 15:47, Colin Lord wrote:
> However, the protocol drivers do tend to see noticeable performance
> benefits. Most of them get modularized in the first three patches of
> this series. This includes the iscsi, glusterfs, ssh, curl, and rbd
> drivers.

Indeed, but... protocol drivers don't have probes, do they?  There is a
distinction between "formats" and "protocols", and only formats need to
be probed for.

> A minimal configuration excluding all of these drivers takes
> around 3 ms to reach main(), and each of these drivers respectively add
> times of approximately 0.2, 0.9, 1.2, 2.5, and a massive time of 41.6 ms
> to the time to main. So some of these aren't even a huge benefit by
> themselves but they do add up, and also it makes sense to modularize all
> of the protocol drivers if we're already modularizing one.

All this I entirely agree with.

Paolo

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [Qemu-devel] [PATCH v4 00/32] Dynamic module loading for block drivers
  2016-07-19 14:42     ` Paolo Bonzini
@ 2016-07-19 15:06       ` Daniel P. Berrange
  0 siblings, 0 replies; 42+ messages in thread
From: Daniel P. Berrange @ 2016-07-19 15:06 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: Colin Lord, qemu-devel, kwolf, qemu-block, mreitz

On Tue, Jul 19, 2016 at 04:42:38PM +0200, Paolo Bonzini wrote:
> 
> 
> On 19/07/2016 15:47, Colin Lord wrote:
> > However, the protocol drivers do tend to see noticeable performance
> > benefits. Most of them get modularized in the first three patches of
> > this series. This includes the iscsi, glusterfs, ssh, curl, and rbd
> > drivers.
> 
> Indeed, but... protocol drivers don't have probes, do they?  There is a
> distinction between "formats" and "protocols", and only formats need to
> be probed for.

IOW, if we only modularized the protocol drivers, then there's no
reason to split out the probe code to separate files, so we avoid
a whole lot of code churn, and keep all the format drivers largely
self contained as today which would be nice.


Regards,
Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [Qemu-devel] [PATCH v4 00/32] Dynamic module loading for block drivers
  2016-07-19 10:54 ` [Qemu-devel] [PATCH v4 00/32] Dynamic module loading for block drivers Paolo Bonzini
  2016-07-19 13:47   ` Colin Lord
@ 2016-07-22 16:27   ` Max Reitz
  2016-07-22 16:40     ` Paolo Bonzini
  1 sibling, 1 reply; 42+ messages in thread
From: Max Reitz @ 2016-07-22 16:27 UTC (permalink / raw)
  To: Paolo Bonzini, Colin Lord, qemu-devel; +Cc: kwolf, qemu-block

[-- Attachment #1: Type: text/plain, Size: 2831 bytes --]

On 19.07.2016 12:54, Paolo Bonzini wrote:
> 
> 
> On 14/07/2016 21:02, Colin Lord wrote:
>> Here's v4 of the modularization series. Things that have changed since
>> v3 include:
>>
>> - Fix indentation of the generated header file module_block.h
>> - Drivers and probe functions are now all located in the block/
>>   directory, rather than being split between block/ and block/probe/. In
>>   addition the header files for each probe/driver pair are in the block/
>>   directory, not the include/block/driver/ directory (which no longer
>>   exists).
>> - Since the probe files are in block/ now, they follow the naming
>>   pattern of format-probe.c
>> - Renamed crypto probe file to be crypto-probe.c, luks is no longer in
>>   the filename
>> - Fixed formatting of parallels_probe() function header
>> - Enforced consistent naming convention for the probe functions. They
>>   now follow the pattern bdrv_format_probe().
> 
> It's still not clear to me why probes need to be separate for drivers
> that (presumably) will never be modularized.

For completeness' sake, my stance on the issue can be summarized as "Why
not?".

The patches exist, so "Someone would need to do it" is not an argument
anymore.

Daniel said the separation of the probing functions introduced by this
series would break the block drivers' "self-containedness", but I'm not
sure all block drivers are contained in a single file, if that is what
he meant by it. qcow2 and vhdx aren't, and I never had any problem with
that.

Maybe he was referring to the file placement discussion we had some
weeks ago. Obviously we didn't end up with a unanimous consensus, so
intuitively I'd say sidestepping this issue would be worth something.
But it really isn't. In my very personal opinion, letting dissent over
coding style get in the way of a functional issue is not really
something we should do.

Also, I think it's actually debatable whether the probing function
belongs to a block driver. One could argue that all the probing
functions in theory belong to a virtual block driver that we haven't
given a name to yet, but that is selected by not specifying any driver.
That virtual driver then does nothing but replace itself by the probed one.

As far as I'm aware, we've always planned to give that virtual block
driver a name (such as "probe-format") in the future.

From that point of view, one could argue that pulling out the probe
functions from the block drivers is actually the right thing to do,
independently of modularization, because the probing functions are
actually not part of the drivers themselves.

So I can't see a strong argument for not modularizing the format block
drivers, but in turn I don't have a strong argument for doing so either.

Therefore: Why not? :-)

Max


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 498 bytes --]

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [Qemu-devel] [PATCH v4 00/32] Dynamic module loading for block drivers
  2016-07-22 16:27   ` Max Reitz
@ 2016-07-22 16:40     ` Paolo Bonzini
  2016-07-22 16:43       ` Max Reitz
  0 siblings, 1 reply; 42+ messages in thread
From: Paolo Bonzini @ 2016-07-22 16:40 UTC (permalink / raw)
  To: Max Reitz, Colin Lord, qemu-devel; +Cc: kwolf, qemu-block



On 22/07/2016 18:27, Max Reitz wrote:
> 
> So I can't see a strong argument for not modularizing the format block
> drivers, but in turn I don't have a strong argument for doing so either.
> 
> Therefore: Why not? :-)

The usual argument is that there is an additional cost in
maintainability.  This applies particularly in this case where you
wouldn't have to care at all about dynamically loading a driver based on
the outcome of a probe---only based on the driver name or a
colon-separated prefix in the filename.

Thanks,

Paolo

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [Qemu-devel] [PATCH v4 00/32] Dynamic module loading for block drivers
  2016-07-22 16:40     ` Paolo Bonzini
@ 2016-07-22 16:43       ` Max Reitz
  0 siblings, 0 replies; 42+ messages in thread
From: Max Reitz @ 2016-07-22 16:43 UTC (permalink / raw)
  To: Paolo Bonzini, Colin Lord, qemu-devel; +Cc: kwolf, qemu-block

[-- Attachment #1: Type: text/plain, Size: 758 bytes --]

On 22.07.2016 18:40, Paolo Bonzini wrote:
> 
> 
> On 22/07/2016 18:27, Max Reitz wrote:
>>
>> So I can't see a strong argument for not modularizing the format block
>> drivers, but in turn I don't have a strong argument for doing so either.
>>
>> Therefore: Why not? :-)
> 
> The usual argument is that there is an additional cost in
> maintainability.  This applies particularly in this case where you
> wouldn't have to care at all about dynamically loading a driver based on
> the outcome of a probe---only based on the driver name or a
> colon-separated prefix in the filename.

That's a good point, especially since it's likely only a few people will
use modularized format block drivers, so we may break it without noticing.

Max


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 498 bytes --]

^ permalink raw reply	[flat|nested] 42+ messages in thread

end of thread, other threads:[~2016-07-22 16:43 UTC | newest]

Thread overview: 42+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-07-14 19:02 [Qemu-devel] [PATCH v4 00/32] Dynamic module loading for block drivers Colin Lord
2016-07-14 19:02 ` [Qemu-devel] [PATCH v4 01/32] blockdev: prepare iSCSI block driver for dynamic loading Colin Lord
2016-07-14 19:02 ` [Qemu-devel] [PATCH v4 02/32] blockdev: Add dynamic generation of module_block.h Colin Lord
2016-07-14 19:02 ` [Qemu-devel] [PATCH v4 03/32] blockdev: Add dynamic module loading for block drivers Colin Lord
2016-07-14 19:03 ` [Qemu-devel] [PATCH v4 04/32] blockdev: Move bochs probe into separate file Colin Lord
2016-07-14 19:03 ` [Qemu-devel] [PATCH v4 05/32] blockdev: Move cloop probe to its own file Colin Lord
2016-07-14 19:03 ` [Qemu-devel] [PATCH v4 06/32] blockdev: Move luks " Colin Lord
2016-07-14 19:03 ` [Qemu-devel] [PATCH v4 07/32] blockdev: Move dmg " Colin Lord
2016-07-14 19:03 ` [Qemu-devel] [PATCH v4 08/32] blockdev: Move parallels " Colin Lord
2016-07-14 19:03 ` [Qemu-devel] [PATCH v4 09/32] blockdev: Move qcow " Colin Lord
2016-07-14 19:03 ` [Qemu-devel] [PATCH v4 10/32] blockdev: Move qcow2 " Colin Lord
2016-07-14 19:03 ` [Qemu-devel] [PATCH v4 11/32] blockdev: Move qed " Colin Lord
2016-07-14 19:03 ` [Qemu-devel] [PATCH v4 12/32] blockdev: Move raw " Colin Lord
2016-07-14 19:03 ` [Qemu-devel] [PATCH v4 13/32] blockdev: Move vdi " Colin Lord
2016-07-14 19:03 ` [Qemu-devel] [PATCH v4 14/32] blockdev: Move vhdx " Colin Lord
2016-07-14 19:03 ` [Qemu-devel] [PATCH v4 15/32] blockdev: Move vmdk " Colin Lord
2016-07-14 19:03 ` [Qemu-devel] [PATCH v4 16/32] blockdev: Move vpc " Colin Lord
2016-07-14 19:03 ` [Qemu-devel] [PATCH v4 17/32] blockdev: Separate bochs probe from its driver Colin Lord
2016-07-18 16:28   ` Max Reitz
2016-07-18 19:44     ` Colin Lord
2016-07-14 19:03 ` [Qemu-devel] [PATCH v4 18/32] blockdev: Separate cloop " Colin Lord
2016-07-14 19:03 ` [Qemu-devel] [PATCH v4 19/32] blockdev: Separate luks " Colin Lord
2016-07-14 19:03 ` [Qemu-devel] [PATCH v4 20/32] blockdev: Separate dmg " Colin Lord
2016-07-14 19:03 ` [Qemu-devel] [PATCH v4 21/32] blockdev: Separate parallels " Colin Lord
2016-07-14 19:03 ` [Qemu-devel] [PATCH v4 22/32] blockdev: Separate qcow " Colin Lord
2016-07-14 19:03 ` [Qemu-devel] [PATCH v4 23/32] blockdev: Separate qcow2 " Colin Lord
2016-07-14 19:03 ` [Qemu-devel] [PATCH v4 24/32] blockdev: Separate qed " Colin Lord
2016-07-14 19:03 ` [Qemu-devel] [PATCH v4 25/32] blockdev: Separate raw " Colin Lord
2016-07-14 19:03 ` [Qemu-devel] [PATCH v4 26/32] blockdev: Separate vdi " Colin Lord
2016-07-14 19:03 ` [Qemu-devel] [PATCH v4 27/32] blockdev: Separate vhdx " Colin Lord
2016-07-14 19:03 ` [Qemu-devel] [PATCH v4 28/32] blockdev: Separate vmdk " Colin Lord
2016-07-14 19:03 ` [Qemu-devel] [PATCH v4 29/32] blockdev: Separate vpc " Colin Lord
2016-07-14 19:03 ` [Qemu-devel] [PATCH v4 30/32] blockdev: Remove the .bdrv_probe field from BlockDrivers Colin Lord
2016-07-14 19:03 ` [Qemu-devel] [PATCH v4 31/32] blockdev: Separate out bdrv_probe_device functions Colin Lord
2016-07-14 19:03 ` [Qemu-devel] [PATCH v4 32/32] blockdev: Remove bdrv_probe_device field from BlockDriver Colin Lord
2016-07-19 10:54 ` [Qemu-devel] [PATCH v4 00/32] Dynamic module loading for block drivers Paolo Bonzini
2016-07-19 13:47   ` Colin Lord
2016-07-19 14:42     ` Paolo Bonzini
2016-07-19 15:06       ` Daniel P. Berrange
2016-07-22 16:27   ` Max Reitz
2016-07-22 16:40     ` Paolo Bonzini
2016-07-22 16:43       ` Max Reitz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).