From 359f03dcecbd90691383c39d8a4ef7a12c66da10 Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Tue, 29 Jan 2013 15:15:57 +0100 Subject: [PATCH] update backup patches --- Makefile | 2 +- debian/changelog | 2 +- ...basic-backup-support-to-block-driver.patch | 20 ++++--- ...-add-backup-related-monitor-commands.patch | 52 ++++++++++--------- ...004-introduce-new-vma-archive-format.patch | 10 ++-- ...0005-add-regression-tests-for-backup.patch | 6 +-- .../0006-add-vm-state-to-backups.patch | 20 +++---- 7 files changed, 60 insertions(+), 52 deletions(-) diff --git a/Makefile b/Makefile index 19659b6..b912dbc 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ RELEASE=2.3 # also update debian/changelog KVMVER=1.3 -KVMPKGREL=16 +KVMPKGREL=17 KVMPACKAGE=pve-qemu-kvm KVMDIR=qemu-kvm diff --git a/debian/changelog b/debian/changelog index ee604b5..56f3f73 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -pve-qemu-kvm (1.3-16) unstable; urgency=low +pve-qemu-kvm (1.3-17) unstable; urgency=low * update backup patches - removed threaded code - we use qemu-aio instead to avoid problems in bdrv_drain_all(). diff --git a/debian/patches/0002-add-basic-backup-support-to-block-driver.patch b/debian/patches/0002-add-basic-backup-support-to-block-driver.patch index 90667b3..6224bf4 100644 --- a/debian/patches/0002-add-basic-backup-support-to-block-driver.patch +++ b/debian/patches/0002-add-basic-backup-support-to-block-driver.patch @@ -1,4 +1,4 @@ -From 26891c19f68a14927e8c52417112d80668be1b3a Mon Sep 17 00:00:00 2001 +From c51e1c591401926d7a5c3a41011736c329c6ef82 Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Tue, 13 Nov 2012 10:03:52 +0100 Subject: [PATCH v3 2/6] add basic backup support to block driver @@ -16,12 +16,12 @@ Currently backup cluster size is hardcoded to 65536 bytes. Signed-off-by: Dietmar Maurer --- Makefile.objs | 1 + - backup.c | 335 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + backup.c | 339 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ backup.h | 32 ++++++ block.c | 71 +++++++++++- block.h | 2 + blockjob.h | 10 ++ - 6 files changed, 445 insertions(+), 6 deletions(-) + 6 files changed, 449 insertions(+), 6 deletions(-) create mode 100644 backup.c create mode 100644 backup.h @@ -39,10 +39,10 @@ index 3c7abca..cb46be5 100644 block-obj-$(CONFIG_WIN32) += event_notifier-win32.o aio-win32.o diff --git a/backup.c b/backup.c new file mode 100644 -index 0000000..3ccb74c +index 0000000..5dcbd11 --- /dev/null +++ b/backup.c -@@ -0,0 +1,335 @@ +@@ -0,0 +1,339 @@ +/* + * QEMU backup + * @@ -324,12 +324,16 @@ index 0000000..3ccb74c +} + +void -+backup_job_start(BlockDriverState *bs) ++backup_job_start(BlockDriverState *bs, bool cancel) +{ + assert(bs); + assert(bs->job); + assert(bs->job->co == NULL); + ++ if (cancel) { ++ block_job_cancel(bs->job); /* set cancel flag */ ++ } ++ + bs->job->co = qemu_coroutine_create(backup_run); + qemu_coroutine_enter(bs->job->co, bs->job); +} @@ -380,7 +384,7 @@ index 0000000..3ccb74c +} diff --git a/backup.h b/backup.h new file mode 100644 -index 0000000..a5f85e6 +index 0000000..20a9016 --- /dev/null +++ b/backup.h @@ -0,0 +1,32 @@ @@ -409,7 +413,7 @@ index 0000000..a5f85e6 +typedef int BackupDumpFunc(void *opaque, BlockDriverState *bs, + int64_t cluster_num, unsigned char *buf); + -+void backup_job_start(BlockDriverState *bs); ++void backup_job_start(BlockDriverState *bs, bool cancel); + +int backup_job_create(BlockDriverState *bs, BackupDumpFunc *backup_dump_cb, + BlockDriverCompletionFunc *backup_complete_cb, diff --git a/debian/patches/0003-add-backup-related-monitor-commands.patch b/debian/patches/0003-add-backup-related-monitor-commands.patch index 0a17a01..1de493e 100644 --- a/debian/patches/0003-add-backup-related-monitor-commands.patch +++ b/debian/patches/0003-add-backup-related-monitor-commands.patch @@ -1,4 +1,4 @@ -From 2c23d119338c45005ebe37b55e54e75a71e5bafd Mon Sep 17 00:00:00 2001 +From 4c0880f2561de8dec379eb6f02b3df88c023270c Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Tue, 13 Nov 2012 11:27:56 +0100 Subject: [PATCH v3 3/6] add backup related monitor commands @@ -13,17 +13,17 @@ could move the whole archive format related code out of qemu. Signed-off-by: Dietmar Maurer --- backup.h | 12 ++ - blockdev.c | 419 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ + blockdev.c | 423 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ hmp-commands.hx | 31 ++++ hmp.c | 63 ++++++++ hmp.h | 3 + monitor.c | 7 + qapi-schema.json | 91 ++++++++++++ qmp-commands.hx | 27 ++++ - 8 files changed, 653 insertions(+), 0 deletions(-) + 8 files changed, 657 insertions(+), 0 deletions(-) diff --git a/backup.h b/backup.h -index a5f85e6..c9c20c9 100644 +index 20a9016..be52ea4 100644 --- a/backup.h +++ b/backup.h @@ -29,4 +29,16 @@ int backup_job_create(BlockDriverState *bs, BackupDumpFunc *backup_dump_cb, @@ -44,7 +44,7 @@ index a5f85e6..c9c20c9 100644 + #endif /* QEMU_BACKUP_H */ diff --git a/blockdev.c b/blockdev.c -index e73fd6e..30f63bd 100644 +index e73fd6e..c559903 100644 --- a/blockdev.c +++ b/blockdev.c @@ -20,6 +20,7 @@ @@ -55,7 +55,7 @@ index e73fd6e..30f63bd 100644 static QTAILQ_HEAD(drivelist, DriveInfo) drives = QTAILQ_HEAD_INITIALIZER(drives); -@@ -1321,6 +1322,424 @@ void qmp_drive_mirror(const char *device, const char *target, +@@ -1321,6 +1322,428 @@ void qmp_drive_mirror(const char *device, const char *target, drive_get_ref(drive_get_by_blockdev(bs)); } @@ -65,6 +65,7 @@ index e73fd6e..30f63bd 100644 + +static struct GenericBackupState { + Error *error; ++ bool cancel; + uuid_t uuid; + char uuid_str[37]; + int64_t speed; @@ -151,11 +152,15 @@ index e73fd6e..30f63bd 100644 + + backup_state.driver->complete_cb(backup_state.writer, bcb->dev_id, ret); + -+ backup_run_next_job(); ++ if (!backup_state.cancel) { ++ backup_run_next_job(); ++ } +} + +static void backup_cancel(void) +{ ++ backup_state.cancel = true; ++ + if (!backup_state.error) { + error_setg(&backup_state.error, "backup cancelled"); + } @@ -163,9 +168,6 @@ index e73fd6e..30f63bd 100644 + /* drain all i/o (awake jobs waiting for aio) */ + bdrv_drain_all(); + -+ /* we only need to cancel the running job - backup_run_next_job() cancels -+ * the other jobs */ -+ + int job_count = 0; + GList *l = backup_state.bcb_list; + while (l) { @@ -174,20 +176,17 @@ index e73fd6e..30f63bd 100644 + BlockJob *job = bcb->bs->job; + if (job) { + job_count++; ++ if (!bcb->started) { ++ bcb->started = true; ++ backup_job_start(bcb->bs, true); ++ } + if (!bcb->completed) { + block_job_cancel_sync(job); -+ /* make sure we call the complete callback */ -+ if (!job->co) { -+ block_job_completed(job, -1); -+ } -+ break; + } + } + } + -+ if (job_count == 0) { /* can happen when backup_start_jobs() fails */ -+ backup_cleanup(); -+ } ++ backup_cleanup(); +} + +void qmp_backup_cancel(Error **errp) @@ -195,7 +194,7 @@ index e73fd6e..30f63bd 100644 + backup_cancel(); +} + -+static void backup_run_next_job(void) ++static void backup_run_next_job(void) +{ + GList *l = backup_state.bcb_list; + while(l) { @@ -205,11 +204,8 @@ index e73fd6e..30f63bd 100644 + if (bcb->bs && bcb->bs->job && !bcb->completed) { + if (!bcb->started) { + bcb->started = true; -+ if (!backup_state.error) { -+ backup_job_start(bcb->bs); -+ } else { -+ block_job_completed(bcb->bs->job, -1); -+ } ++ bool cancel = backup_state.error || backup_state.cancel; ++ backup_job_start(bcb->bs,cancel); + } + return; + } @@ -249,6 +245,12 @@ index e73fd6e..30f63bd 100644 + gchar **devs = NULL; + GList *bcblist = NULL; + ++ if (backup_state.bcb_list) { ++ error_set(errp, ERROR_CLASS_GENERIC_ERROR, ++ "previous backup not finished"); ++ return NULL; ++ } ++ + /* Todo: try to auto-detect format based on file name */ + format = has_format ? format : BACKUP_FORMAT_VMA; + @@ -366,6 +368,8 @@ index e73fd6e..30f63bd 100644 + + /* initialize global backup_state now */ + ++ backup_state.cancel = false; ++ + if (backup_state.error) { + error_free(backup_state.error); + backup_state.error = NULL; diff --git a/debian/patches/0004-introduce-new-vma-archive-format.patch b/debian/patches/0004-introduce-new-vma-archive-format.patch index 4952162..d1f27b9 100644 --- a/debian/patches/0004-introduce-new-vma-archive-format.patch +++ b/debian/patches/0004-introduce-new-vma-archive-format.patch @@ -1,4 +1,4 @@ -From 7592ded4c7222255085ac7cad534a9e592931f30 Mon Sep 17 00:00:00 2001 +From 86ddce6dbd1cc88a0fad43b36300b8ffa573bd04 Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Tue, 13 Nov 2012 11:11:38 +0100 Subject: [PATCH v3 4/6] introduce new vma archive format @@ -57,7 +57,7 @@ index cb46be5..b5732e2 100644 block-obj-$(CONFIG_POSIX) += event_notifier-posix.o aio-posix.o block-obj-$(CONFIG_WIN32) += event_notifier-win32.o aio-win32.o diff --git a/blockdev.c b/blockdev.c -index 30f63bd..5ffd246 100644 +index c559903..467667e 100644 --- a/blockdev.c +++ b/blockdev.c @@ -21,6 +21,7 @@ @@ -68,7 +68,7 @@ index 30f63bd..5ffd246 100644 static QTAILQ_HEAD(drivelist, DriveInfo) drives = QTAILQ_HEAD_INITIALIZER(drives); -@@ -1515,10 +1516,11 @@ char *qmp_backup(const char *backupfile, bool has_format, BackupFormat format, +@@ -1517,10 +1518,11 @@ char *qmp_backup(const char *backupfile, bool has_format, BackupFormat format, /* Todo: try to auto-detect format based on file name */ format = has_format ? format : BACKUP_FORMAT_VMA; @@ -1862,7 +1862,7 @@ index 0000000..6ecbaf4 + diff --git a/vma.c b/vma.c new file mode 100644 -index 0000000..5d13906 +index 0000000..66de9bb --- /dev/null +++ b/vma.c @@ -0,0 +1,561 @@ @@ -2336,7 +2336,7 @@ index 0000000..5d13906 + unlink(archivename); + g_error("backup_job_start failed"); + } else { -+ backup_job_start(bs); ++ backup_job_start(bs, false); + } + } + diff --git a/debian/patches/0005-add-regression-tests-for-backup.patch b/debian/patches/0005-add-regression-tests-for-backup.patch index 9fe68f9..4571a2f 100644 --- a/debian/patches/0005-add-regression-tests-for-backup.patch +++ b/debian/patches/0005-add-regression-tests-for-backup.patch @@ -1,4 +1,4 @@ -From e550dd634d38dda15d8663a5d97883c9145b95fd Mon Sep 17 00:00:00 2001 +From 2f16d5e7a7fdcbb83f2643cbbbf872e1b4fbac2f Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Wed, 14 Nov 2012 09:57:04 +0100 Subject: [PATCH v3 5/6] add regression tests for backup @@ -54,7 +54,7 @@ index b60f0fb..cffbd22 100644 -include $(wildcard tests/*.d) diff --git a/tests/backup-test.c b/tests/backup-test.c new file mode 100644 -index 0000000..d816ffa +index 0000000..36a6389 --- /dev/null +++ b/tests/backup-test.c @@ -0,0 +1,516 @@ @@ -436,7 +436,7 @@ index 0000000..d816ffa + speed) < 0) { + g_error("backup_job_create failed"); + } else { -+ backup_job_start(bs); ++ backup_job_start(bs, false); + } + + request_term = false; diff --git a/debian/patches/0006-add-vm-state-to-backups.patch b/debian/patches/0006-add-vm-state-to-backups.patch index 94fd723..ad3affc 100644 --- a/debian/patches/0006-add-vm-state-to-backups.patch +++ b/debian/patches/0006-add-vm-state-to-backups.patch @@ -1,4 +1,4 @@ -From 66ecb72361ea3e2e1243ee87527919621c85f4ff Mon Sep 17 00:00:00 2001 +From 1f4df212ac4408eaf685cd0febf2ae86ea96e6f3 Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Thu, 29 Nov 2012 10:46:49 +0100 Subject: [PATCH v3 6/6] add vm state to backups @@ -12,7 +12,7 @@ Signed-off-by: Dietmar Maurer 3 files changed, 200 insertions(+), 5 deletions(-) diff --git a/blockdev.c b/blockdev.c -index 5ffd246..6bddbd3 100644 +index 467667e..b6d80a4 100644 --- a/blockdev.c +++ b/blockdev.c @@ -22,6 +22,8 @@ @@ -24,7 +24,7 @@ index 5ffd246..6bddbd3 100644 static QTAILQ_HEAD(drivelist, DriveInfo) drives = QTAILQ_HEAD_INITIALIZER(drives); -@@ -1341,6 +1343,10 @@ static struct GenericBackupState { +@@ -1342,6 +1344,10 @@ static struct GenericBackupState { size_t total; size_t transferred; size_t zero_bytes; @@ -35,7 +35,7 @@ index 5ffd246..6bddbd3 100644 } backup_state; typedef struct BackupCB { -@@ -1501,10 +1507,170 @@ static void backup_start_jobs(void) +@@ -1497,10 +1503,170 @@ static void backup_start_jobs(void) backup_run_next_job(); } @@ -207,16 +207,16 @@ index 5ffd246..6bddbd3 100644 { BlockDriverState *bs; Error *local_err = NULL; -@@ -1513,6 +1679,8 @@ char *qmp_backup(const char *backupfile, bool has_format, BackupFormat format, - gchar **devs = NULL; - GList *bcblist = NULL; +@@ -1515,6 +1681,8 @@ char *qmp_backup(const char *backupfile, bool has_format, BackupFormat format, + return NULL; + } + bool save_state = has_state ? state : false; + /* Todo: try to auto-detect format based on file name */ format = has_format ? format : BACKUP_FORMAT_VMA; -@@ -1593,6 +1761,22 @@ char *qmp_backup(const char *backupfile, bool has_format, BackupFormat format, +@@ -1595,6 +1763,22 @@ char *qmp_backup(const char *backupfile, bool has_format, BackupFormat format, size_t total = 0; /* register all devices for vma writer */ @@ -239,7 +239,7 @@ index 5ffd246..6bddbd3 100644 l = bcblist; while (l) { BackupCB *bcb = l->data; -@@ -1658,6 +1842,9 @@ char *qmp_backup(const char *backupfile, bool has_format, BackupFormat format, +@@ -1662,6 +1846,9 @@ char *qmp_backup(const char *backupfile, bool has_format, BackupFormat format, backup_state.total = total; backup_state.transferred = 0; backup_state.zero_bytes = 0; @@ -249,7 +249,7 @@ index 5ffd246..6bddbd3 100644 /* Grab a reference so hotplug does not delete the * BlockDriverState from underneath us. -@@ -1669,7 +1856,12 @@ char *qmp_backup(const char *backupfile, bool has_format, BackupFormat format, +@@ -1673,7 +1860,12 @@ char *qmp_backup(const char *backupfile, bool has_format, BackupFormat format, drive_get_ref(drive_get_by_blockdev(bcb->bs)); } -- 2.39.2