@@ -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
new file mode 100644
@@ -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;
+}
@@ -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;
new file mode 100644
@@ -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
@@ -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