@@ -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
+block-obj-y += probe/parallels.o probe/qcow.o
common-obj-y += stream.o
common-obj-y += commit.o
new file mode 100644
@@ -0,0 +1,16 @@
+#include "qemu/osdep.h"
+#include "block/block_int.h"
+#include "block/probe.h"
+#include "block/driver/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;
+}
@@ -26,6 +26,8 @@
#include "qemu-common.h"
#include "qemu/error-report.h"
#include "block/block_int.h"
+#include "block/probe.h"
+#include "block/driver/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)
{
new file mode 100644
@@ -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
@@ -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
Isolates qcow probe as part of the modularization process. Signed-off-by: Colin Lord <clord@redhat.com> --- block/Makefile.objs | 2 +- block/probe/qcow.c | 16 ++++++++++++++++ block/qcow.c | 31 ++----------------------------- include/block/driver/qcow.h | 21 +++++++++++++++++++++ include/block/probe.h | 1 + 5 files changed, 41 insertions(+), 30 deletions(-) create mode 100644 block/probe/qcow.c create mode 100644 include/block/driver/qcow.h