Dietmar Maurer <diet...@proxmox.com> writes: > This is a very simple archive format, see docs/specs/vma_spec.txt > > Signed-off-by: Dietmar Maurer <diet...@proxmox.com> > --- > Makefile | 3 +- > Makefile.objs | 2 +- > blockdev.c | 6 +- > docs/specs/vma_spec.txt | 24 ++ > vma-reader.c | 799 ++++++++++++++++++++++++++++++++++++++++ > vma-writer.c | 940 > +++++++++++++++++++++++++++++++++++++++++++++++ > vma.c | 561 ++++++++++++++++++++++++++++ > vma.h | 145 ++++++++ > 8 files changed, 2476 insertions(+), 4 deletions(-) > create mode 100644 docs/specs/vma_spec.txt > create mode 100644 vma-reader.c > create mode 100644 vma-writer.c > create mode 100644 vma.c > create mode 100644 vma.h > > diff --git a/Makefile b/Makefile > index 0d9099a..16f1c25 100644 > --- a/Makefile > +++ b/Makefile > @@ -115,7 +115,7 @@ ifeq ($(CONFIG_SMARTCARD_NSS),y) > include $(SRC_PATH)/libcacard/Makefile > endif > > -all: $(DOCS) $(TOOLS) $(HELPERS-y) recurse-all > +all: $(DOCS) $(TOOLS) vma$(EXESUF) $(HELPERS-y) recurse-all > > config-host.h: config-host.h-timestamp > config-host.h-timestamp: config-host.mak > @@ -167,6 +167,7 @@ qemu-img.o: qemu-img-cmds.h > qemu-img$(EXESUF): qemu-img.o $(block-obj-y) libqemuutil.a libqemustub.a > qemu-nbd$(EXESUF): qemu-nbd.o $(block-obj-y) libqemuutil.a libqemustub.a > qemu-io$(EXESUF): qemu-io.o cmd.o $(block-obj-y) libqemuutil.a libqemustub.a > +vma$(EXESUF): vma.o vma-writer.o vma-reader.o $(block-obj-y) libqemuutil.a > libqemustub.a > > qemu-bridge-helper$(EXESUF): qemu-bridge-helper.o > > diff --git a/Makefile.objs b/Makefile.objs > index df64f70..91f133b 100644 > --- a/Makefile.objs > +++ b/Makefile.objs > @@ -13,7 +13,7 @@ block-obj-$(CONFIG_POSIX) += aio-posix.o > block-obj-$(CONFIG_WIN32) += aio-win32.o > block-obj-y += block/ > block-obj-y += qapi-types.o qapi-visit.o > -block-obj-y += backup.o > +block-obj-y += vma-writer.o backup.o > > block-obj-y += qemu-coroutine.o qemu-coroutine-lock.o qemu-coroutine-io.o > block-obj-y += qemu-coroutine-sleep.o > diff --git a/blockdev.c b/blockdev.c > index 84f598d..683f7da 100644 > --- a/blockdev.c > +++ b/blockdev.c > @@ -21,6 +21,7 @@ > #include "trace.h" > #include "sysemu/arch_init.h" > #include "backup.h" > +#include "vma.h" > > static QTAILQ_HEAD(drivelist, DriveInfo) drives = > QTAILQ_HEAD_INITIALIZER(drives); > > @@ -1530,10 +1531,11 @@ char *qmp_backup(const char *backup_file, bool > has_format, BackupFormat format, > /* Todo: try to auto-detect format based on file name */ > format = has_format ? format : BACKUP_FORMAT_VMA; > > - /* fixme: find driver for specifued format */ > const BackupDriver *driver = NULL; > > - if (!driver) { > + if (format == BACKUP_FORMAT_VMA) { > + driver = &backup_vma_driver; > + } else { > error_set(errp, ERROR_CLASS_GENERIC_ERROR, "unknown backup format"); > return NULL; > } > diff --git a/docs/specs/vma_spec.txt b/docs/specs/vma_spec.txt > new file mode 100644 > index 0000000..9b715f2 > --- /dev/null > +++ b/docs/specs/vma_spec.txt > @@ -0,0 +1,24 @@ > +=Virtual Machine Archive format (VMA)= > + > +This format contains a header which includes the VM configuration as > +binary blobs, and a list of devices (dev_id, name). > + > +The actual VM image data is stored inside extents. An extent contains > +up to 64 clusters, and start with a 512 byte header containing > +additional information for those clusters. > + > +We use a cluster size of 65536, and use 8 bytes for each > +cluster in the header to store the following information: > + > +* 1 byte dev_id (to identity the drive) > +* 1 byte not used (reserved) > +* 2 bytes zero indicator (mark zero regions (16x4096)) > +* 4 bytes cluster number > + > +We only store non-zero blocks (such block is 4096 bytes). > + > +Each archive is marked with a uuid. The archive header and all > +extent headers includes that uuid and a MD5 checksum (over header > +data). > + > +
Trailing blank lines. This isn't a specification, yet. I'm very much opposed to underspecified *external* interfaces, because that makes changing anything without breaking interoperability a crap shot. We'll review the implementation against the specification as soon as we got one. [...]