]> git.proxmox.com Git - pve-qemu-kvm.git/blobdiff - debian/patches/backup-add-vma-binary.patch
update to v2.1.0-rc2
[pve-qemu-kvm.git] / debian / patches / backup-add-vma-binary.patch
index 57eda450bed71e5de075fdac02234ec5522504f5..304e202a4cfa5215ab4a31f345a4f40047bf7de3 100644 (file)
@@ -24,58 +24,29 @@ Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
 
 Index: new/Makefile
 ===================================================================
---- new.orig/Makefile  2013-11-29 08:45:24.000000000 +0100
-+++ new/Makefile       2013-11-29 10:08:41.000000000 +0100
-@@ -128,7 +128,7 @@
+--- new.orig/Makefile  2014-07-16 10:40:17.000000000 +0200
++++ new/Makefile       2014-07-16 10:51:34.000000000 +0200
+@@ -146,7 +146,7 @@
  include $(SRC_PATH)/libcacard/Makefile
  endif
  
--all: $(DOCS) $(TOOLS) $(HELPERS-y) recurse-all
-+all: $(DOCS) $(TOOLS) vma$(EXESUF) $(HELPERS-y) recurse-all
+-all: $(DOCS) $(TOOLS) $(HELPERS-y) recurse-all modules
++all: $(DOCS) $(TOOLS) vma$(EXESUF) $(HELPERS-y) recurse-all modules
  
  config-host.h: config-host.h-timestamp
  config-host.h-timestamp: config-host.mak
-@@ -194,6 +194,7 @@
+@@ -214,6 +214,7 @@
  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 $(block-obj-y) libqemuutil.a libqemustub.a
-+vma$(EXESUF): vma.o vma-writer.o vma-reader.o $(block-obj-y)  libqemuutil.a libqemustub.a
++vma$(EXESUF): vma.o vma-reader.o $(block-obj-y)  libqemuutil.a libqemustub.a
  
  qemu-bridge-helper$(EXESUF): qemu-bridge-helper.o
  
-Index: new/docs/specs/vma_spec.txt
-===================================================================
---- /dev/null  1970-01-01 00:00:00.000000000 +0000
-+++ new/docs/specs/vma_spec.txt        2013-11-29 10:08:41.000000000 +0100
-@@ -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).
-+
-+
 Index: new/vma-reader.c
 ===================================================================
 --- /dev/null  1970-01-01 00:00:00.000000000 +0000
-+++ new/vma-reader.c   2013-11-29 10:18:49.000000000 +0100
++++ new/vma-reader.c   2014-07-16 10:51:34.000000000 +0200
 @@ -0,0 +1,799 @@
 +/*
 + * VMA: Virtual Machine Archive
@@ -879,8 +850,8 @@ Index: new/vma-reader.c
 Index: new/vma-writer.c
 ===================================================================
 --- /dev/null  1970-01-01 00:00:00.000000000 +0000
-+++ new/vma-writer.c   2013-11-29 10:19:59.000000000 +0100
-@@ -0,0 +1,872 @@
++++ new/vma-writer.c   2014-07-16 11:03:00.000000000 +0200
+@@ -0,0 +1,876 @@
 +/*
 + * VMA: Virtual Machine Archive
 + *
@@ -909,6 +880,7 @@ Index: new/vma-writer.c
 +#include "vma.h"
 +#include "block/block.h"
 +#include "monitor/monitor.h"
++#include "qemu/main-loop.h"
 +
 +#define DEBUG_VMA 0
 +
@@ -1119,7 +1091,7 @@ Index: new/vma-writer.c
 +
 +    vmaw->co_writer = qemu_coroutine_self();
 +
-+    qemu_aio_set_fd_handler(vmaw->fd, NULL, vma_co_continue_write, vmaw);
++    aio_set_fd_handler(qemu_get_aio_context(), vmaw->fd, NULL, vma_co_continue_write, vmaw);
 +
 +    DPRINTF("vma_co_write wait until writable\n");
 +    qemu_coroutine_yield();
@@ -1146,7 +1118,7 @@ Index: new/vma-writer.c
 +        }
 +    }
 +
-+    qemu_aio_set_fd_handler(vmaw->fd, NULL, NULL, NULL);
++    aio_set_fd_handler(qemu_get_aio_context(), vmaw->fd, NULL, NULL, NULL);
 +
 +    vmaw->co_writer = NULL;
 +
@@ -1249,6 +1221,9 @@ Index: new/vma-writer.c
 +    const char *p;
 +
 +    assert(sizeof(VmaHeader) == (4096 + 8192));
++    assert(G_STRUCT_OFFSET(VmaHeader, config_names) == 2044);
++    assert(G_STRUCT_OFFSET(VmaHeader, config_data) == 3068);
++    assert(G_STRUCT_OFFSET(VmaHeader, dev_info) == 4096);
 +    assert(sizeof(VmaExtentHeader) == 512);
 +
 +    VmaWriter *vmaw = g_new0(VmaWriter, 1);
@@ -1756,8 +1731,8 @@ Index: new/vma-writer.c
 Index: new/vma.c
 ===================================================================
 --- /dev/null  1970-01-01 00:00:00.000000000 +0000
-+++ new/vma.c  2013-11-29 10:18:49.000000000 +0100
-@@ -0,0 +1,623 @@
++++ new/vma.c  2014-07-16 10:51:34.000000000 +0200
+@@ -0,0 +1,583 @@
 +/*
 + * VMA: Virtual Machine Archive
 + *
@@ -2045,7 +2020,7 @@ Index: new/vma.c
 +
 +                bdrv_img_create(devfn, "raw", NULL, NULL, NULL, di->size,
 +                                flags, &errp, 0);
-+                if (error_is_set(&errp)) {
++                if (errp) {
 +                    g_error("can't create file %s: %s", devfn,
 +                            error_get_pretty(errp));
 +                }
@@ -2056,8 +2031,8 @@ Index: new/vma.c
 +                write_zero = false;
 +            }
 +
-+            BlockDriverState *bs = bdrv_new(di->devname);
-+            if (bdrv_open(bs, devfn, NULL, flags, NULL, &errp)) {
++            BlockDriverState *bs = bdrv_new(di->devname, &errp);
++            if (errp || bdrv_open(&bs, devfn, NULL, NULL, flags, NULL, &errp)) {
 +                g_error("can't open file %s - %s", devfn,
 +                        error_get_pretty(errp));
 +            }
@@ -2105,37 +2080,6 @@ Index: new/vma.c
 +    uint8_t dev_id;
 +} BackupJob;
 +
-+/*
-+static int backup_dump_cb(void *opaque, BlockDriverState *bs,
-+                          int64_t cluster_num, unsigned char *buf)
-+{
-+    BackupCB *bcb = opaque;
-+    size_t zb = 0;
-+    if (vma_writer_write(bcb->vmaw, bcb->dev_id, cluster_num, buf, &zb) < 0) {
-+        g_warning("backup_dump_cb vma_writer_write failed");
-+        return -1;
-+    }
-+
-+    return 0;
-+}
-+
-+static void backup_complete_cb(void *opaque, int ret)
-+{
-+    BackupCB *bcb = opaque;
-+
-+    if (ret < 0) {
-+        vma_writer_set_error(bcb->vmaw, "backup_complete_cb %d", ret);
-+    }
-+
-+    if (vma_writer_close_stream(bcb->vmaw, bcb->dev_id) <= 0) {
-+        Error *err = NULL;
-+        if (vma_writer_close(bcb->vmaw, &err) != 0) {
-+            g_warning("vma_writer_close failed %s", error_get_pretty(err));
-+        }
-+    }
-+}
-+*/
-+
 +#define BACKUP_SECTORS_PER_CLUSTER (VMA_CLUSTER_SIZE / BDRV_SECTOR_SIZE)
 +
 +static void coroutine_fn backup_run(void *opaque)
@@ -2254,10 +2198,14 @@ Index: new/vma.c
 +        path = extract_devname(path, &devname, ind++);
 +
 +        BlockDriver *drv = NULL;
-+        BlockDriverState *bs = bdrv_new(devname);
 +        Error *errp = NULL;
-+
-+        res = bdrv_open(bs, path, NULL, BDRV_O_CACHE_WB , drv, &errp);
++        BlockDriverState *bs = bdrv_new(devname, &errp);
++        
++        if (errp) {
++            g_error("bdrv_new '%s' failed - %s", devname, error_get_pretty(errp));
++        }
++ 
++        res = bdrv_open(&bs, path, NULL, NULL, BDRV_O_CACHE_WB , drv, &errp);
 +        if (res < 0) {
 +            unlink(archivename);
 +            g_error("bdrv_open '%s' failed - %s", path, error_get_pretty(errp));
@@ -2277,19 +2225,6 @@ Index: new/vma.c
 +
 +        Coroutine *co = qemu_coroutine_create(backup_run);
 +        qemu_coroutine_enter(co, job);
-+
-+       //BlockDriverState *target = NULL;
-+        //backup_start(bs, target, 0, MIRROR_SYNC_MODE_FULL,
-+        //             BLOCKDEV_ON_ERROR_STOP, BLOCKDEV_ON_ERROR_STOP,
-+        //             NULL, bcb, &errp);
-+
-+        //if (backup_job_create(bs, backup_dump_cb, backup_complete_cb,
-+        //                     bcb, 0) < 0) {
-+        //    unlink(archivename);
-+        //    g_error("backup_job_start failed");
-+        //} else {
-+        //    backup_job_start(bs, false);
-+        // }
 +    }
 +
 +    VmaStatus vmastat;
@@ -2384,8 +2319,8 @@ Index: new/vma.c
 Index: new/vma.h
 ===================================================================
 --- /dev/null  1970-01-01 00:00:00.000000000 +0000
-+++ new/vma.h  2013-11-29 10:18:49.000000000 +0100
-@@ -0,0 +1,144 @@
++++ new/vma.h  2014-07-16 10:51:34.000000000 +0200
+@@ -0,0 +1,146 @@
 +/*
 + * VMA: Virtual Machine Archive
 + *
@@ -2454,6 +2389,8 @@ Index: new/vma.h
 +    uint32_t config_names[VMA_MAX_CONFIGS]; /* offset into blob_buffer table */
 +    uint32_t config_data[VMA_MAX_CONFIGS];  /* offset into blob_buffer table */
 +
++    uint32_t reserved1;
++
 +    VmaDeviceInfoHeader dev_info[256];
 +} VmaHeader;
 +
@@ -2530,3 +2467,15 @@ Index: new/vma.h
 +                       Error **errp);
 +
 +#endif /* BACKUP_VMA_H */
+Index: new/Makefile.objs
+===================================================================
+--- new.orig/Makefile.objs     2014-07-16 10:40:17.000000000 +0200
++++ new/Makefile.objs  2014-07-16 10:51:34.000000000 +0200
+@@ -14,6 +14,7 @@
+ block-obj-y += block/
+ block-obj-y += qapi-types.o qapi-visit.o qapi-event.o
+ block-obj-y += qemu-io-cmds.o
++block-obj-y += vma-writer.o
+ block-obj-y += qemu-coroutine.o qemu-coroutine-lock.o qemu-coroutine-io.o
+ block-obj-y += qemu-coroutine-sleep.o