[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v4 14/32] blockdev: Move vhdx probe to its own file
From: |
Colin Lord |
Subject: |
[Qemu-devel] [PATCH v4 14/32] blockdev: Move vhdx probe to its own file |
Date: |
Thu, 14 Jul 2016 15:03:10 -0400 |
Isolates vhdx probe as part of the modularization process.
Signed-off-by: Colin Lord <address@hidden>
Reviewed-by: Max Reitz <address@hidden>
---
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
- [Qemu-devel] [PATCH v4 10/32] blockdev: Move qcow2 probe to its own file, (continued)
- [Qemu-devel] [PATCH v4 10/32] blockdev: Move qcow2 probe to its own file, Colin Lord, 2016/07/14
- [Qemu-devel] [PATCH v4 09/32] blockdev: Move qcow probe to its own file, Colin Lord, 2016/07/14
- [Qemu-devel] [PATCH v4 12/32] blockdev: Move raw probe to its own file, Colin Lord, 2016/07/14
- [Qemu-devel] [PATCH v4 13/32] blockdev: Move vdi probe to its own file, Colin Lord, 2016/07/14
- [Qemu-devel] [PATCH v4 24/32] blockdev: Separate qed probe from its driver, Colin Lord, 2016/07/14
- [Qemu-devel] [PATCH v4 25/32] blockdev: Separate raw probe from its driver, Colin Lord, 2016/07/14
- [Qemu-devel] [PATCH v4 17/32] blockdev: Separate bochs probe from its driver, Colin Lord, 2016/07/14
- [Qemu-devel] [PATCH v4 19/32] blockdev: Separate luks probe from its driver, Colin Lord, 2016/07/14
- [Qemu-devel] [PATCH v4 26/32] blockdev: Separate vdi probe from its driver, Colin Lord, 2016/07/14
- [Qemu-devel] [PATCH v4 21/32] blockdev: Separate parallels probe from its driver, Colin Lord, 2016/07/14
- [Qemu-devel] [PATCH v4 14/32] blockdev: Move vhdx probe to its own file,
Colin Lord <=
- [Qemu-devel] [PATCH v4 16/32] blockdev: Move vpc probe to its own file, Colin Lord, 2016/07/14
- [Qemu-devel] [PATCH v4 27/32] blockdev: Separate vhdx probe from its driver, Colin Lord, 2016/07/14
- [Qemu-devel] [PATCH v4 31/32] blockdev: Separate out bdrv_probe_device functions, Colin Lord, 2016/07/14
- [Qemu-devel] [PATCH v4 15/32] blockdev: Move vmdk probe to its own file, Colin Lord, 2016/07/14
- [Qemu-devel] [PATCH v4 20/32] blockdev: Separate dmg probe from its driver, Colin Lord, 2016/07/14
- [Qemu-devel] [PATCH v4 30/32] blockdev: Remove the .bdrv_probe field from BlockDrivers, Colin Lord, 2016/07/14
- [Qemu-devel] [PATCH v4 23/32] blockdev: Separate qcow2 probe from its driver, Colin Lord, 2016/07/14
- [Qemu-devel] [PATCH v4 18/32] blockdev: Separate cloop probe from its driver, Colin Lord, 2016/07/14
- [Qemu-devel] [PATCH v4 22/32] blockdev: Separate qcow probe from its driver, Colin Lord, 2016/07/14
- [Qemu-devel] [PATCH v4 32/32] blockdev: Remove bdrv_probe_device field from BlockDriver, Colin Lord, 2016/07/14