diff mbox

[v4,10/32] blockdev: Move qcow2 probe to its own file

Message ID 1468523008-30013-11-git-send-email-clord@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

clord@redhat.com July 14, 2016, 7:03 p.m. UTC
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 mbox

Patch

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