Received: from eggs.gnu.org ([2001:4830:134:3::10]:32962) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bKSDS-0005zR-4l for qemu-devel@nongnu.org; Tue, 05 Jul 2016 11:24:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bKSDP-0008T1-7N for qemu-devel@nongnu.org; Tue, 05 Jul 2016 11:24:48 -0400 From: Colin Lord Date: Tue, 5 Jul 2016 11:24:10 -0400 Message-Id: <1467732272-23368-11-git-send-email-clord@redhat.com> In-Reply-To: <1467732272-23368-1-git-send-email-clord@redhat.com> References: <1467732272-23368-1-git-send-email-clord@redhat.com> Subject: [Qemu-devel] [PATCH v3 10/32] blockdev: Move qcow2 probe to its own file List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, qemu-block@nongnu.org, mreitz@redhat.com, Colin Lord Isolates qcow2 probe as part of the modularization process. Signed-off-by: Colin Lord --- block/Makefile.objs | 2 +- block/probe/qcow2.c | 16 ++++++++++++++++ block/qcow2.c | 13 +------------ include/block/probe.h | 1 + 4 files changed, 19 insertions(+), 13 deletions(-) create mode 100644 block/probe/qcow2.c diff --git a/block/Makefile.objs b/block/Makefile.objs index 9458da8..23240d9 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 += probe/bochs.o probe/cloop.o probe/luks.o probe/dmg.o -block-obj-y += probe/parallels.o probe/qcow.o +block-obj-y += probe/parallels.o probe/qcow.o probe/qcow2.o common-obj-y += stream.o common-obj-y += commit.o diff --git a/block/probe/qcow2.c b/block/probe/qcow2.c new file mode 100644 index 0000000..56f4e82 --- /dev/null +++ b/block/probe/qcow2.c @@ -0,0 +1,16 @@ +#include "qemu/osdep.h" +#include "block/block_int.h" +#include "block/probe.h" +#include "block/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 23f666d..55639eb 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -27,6 +27,7 @@ #include "qemu/module.h" #include #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