]> git.proxmox.com Git - pve-qemu-kvm.git/blame - debian/patches/backup-add-pve-monitor-commands.patch
backup: call block_job_cb()
[pve-qemu-kvm.git] / debian / patches / backup-add-pve-monitor-commands.patch
CommitLineData
cbf9030a
DM
1Index: new/blockdev.c
2===================================================================
81300c8b
DM
3--- new.orig/blockdev.c 2013-12-06 07:46:29.000000000 +0100
4+++ new/blockdev.c 2013-12-06 08:53:36.000000000 +0100
cbf9030a
DM
5@@ -45,6 +45,7 @@
6 #include "qmp-commands.h"
7 #include "trace.h"
8 #include "sysemu/arch_init.h"
9+#include "vma.h"
10
11 static QTAILQ_HEAD(drivelist, DriveInfo) drives = QTAILQ_HEAD_INITIALIZER(drives);
12
81300c8b 13@@ -1438,7 +1439,6 @@
cbf9030a
DM
14 }
15 }
16
81300c8b
DM
17-
18 static void eject_device(BlockDriverState *bs, int force, Error **errp)
19 {
20 if (bdrv_in_use(bs)) {
21@@ -1736,6 +1736,431 @@
22 bdrv_put_ref_bh_schedule(bs);
23 }
24
cbf9030a
DM
25+/* PVE backup related function */
26+
27+static struct PVEBackupState {
28+ Error *error;
29+ bool cancel;
30+ uuid_t uuid;
31+ char uuid_str[37];
32+ int64_t speed;
33+ time_t start_time;
34+ time_t end_time;
35+ char *backup_file;
36+ VmaWriter *vmaw;
37+ GList *di_list;
38+ size_t total;
39+ size_t transferred;
40+ size_t zero_bytes;
41+} backup_state;
42+
43+typedef struct PVEBackupDevInfo {
44+ BlockDriverState *bs;
e72ed697 45+ size_t size;
cbf9030a
DM
46+ uint8_t dev_id;
47+ //bool started;
48+ bool completed;
49+} PVEBackupDevInfo;
50+
51+static void pvebackup_run_next_job(void);
52+
e72ed697
DM
53+static int pvebackup_dump_cb(void *opaque, BlockDriverState *target,
54+ int64_t sector_num, int n_sectors,
55+ unsigned char *buf)
cbf9030a
DM
56+{
57+ PVEBackupDevInfo *di = opaque;
58+
e72ed697
DM
59+ if (sector_num & 0x7f) {
60+ if (!backup_state.error) {
61+ error_setg(&backup_state.error,
62+ "got unaligned write inside backup dump "
63+ "callback (sector %ld)", sector_num);
64+ }
65+ return -1; // not aligned to cluster size
66+ }
cbf9030a 67+
e72ed697
DM
68+ int64_t cluster_num = sector_num >> 7;
69+ int size = n_sectors * BDRV_SECTOR_SIZE;
cbf9030a 70+
e72ed697 71+ int ret = -1;
cbf9030a 72+
e72ed697
DM
73+ if (backup_state.vmaw) {
74+ size_t zero_bytes = 0;
75+ ret = vma_writer_write(backup_state.vmaw, di->dev_id, cluster_num,
76+ buf, &zero_bytes);
77+ backup_state.zero_bytes += zero_bytes;
78+ } else {
79+ ret = size;
80+ if (!buf) {
81+ backup_state.zero_bytes += size;
cbf9030a
DM
82+ }
83+ }
84+
e72ed697
DM
85+ backup_state.transferred += size;
86+
87+ return ret;
cbf9030a
DM
88+}
89+
90+static void pvebackup_cleanup(void)
91+{
92+ if (backup_state.vmaw) {
93+ backup_state.end_time = time(NULL);
94+ Error *local_err = NULL;
cbf9030a
DM
95+ vma_writer_close(backup_state.vmaw, &local_err);
96+ error_propagate(&backup_state.error, local_err);
97+ backup_state.vmaw = NULL;
98+ }
99+
100+ if (backup_state.di_list) {
101+ GList *l = backup_state.di_list;
102+ while (l) {
103+ PVEBackupDevInfo *di = (PVEBackupDevInfo *)l->data;
104+ l = g_list_next(l);
105+ g_free(di);
106+ }
107+ g_list_free(backup_state.di_list);
108+ backup_state.di_list = NULL;
109+ }
110+}
111+
112+static void pvebackup_complete_cb(void *opaque, int ret)
113+{
114+ PVEBackupDevInfo *di = opaque;
115+
116+ assert(backup_state.vmaw);
117+
118+ di->completed = true;
81300c8b
DM
119+
120+ BlockDriverState *bs = di->bs;
121+
b07588bd 122+ di->bs = NULL;
cbf9030a
DM
123+
124+ vma_writer_close_stream(backup_state.vmaw, di->dev_id);
125+
81300c8b
DM
126+ block_job_cb(bs, ret);
127+
cbf9030a
DM
128+ if (!backup_state.cancel) {
129+ pvebackup_run_next_job();
130+ }
131+}
132+
0c5f6a91 133+static void pvebackup_cancel(void *opaque)
cbf9030a
DM
134+{
135+ backup_state.cancel = true;
136+
137+ if (!backup_state.error) {
138+ error_setg(&backup_state.error, "backup cancelled");
139+ }
140+
141+ /* drain all i/o (awake jobs waiting for aio) */
142+ bdrv_drain_all();
143+
cbf9030a
DM
144+ GList *l = backup_state.di_list;
145+ while (l) {
146+ PVEBackupDevInfo *di = (PVEBackupDevInfo *)l->data;
147+ l = g_list_next(l);
e72ed697 148+ if (!di->completed && di->bs) {
b07588bd
DM
149+ BlockJob *job = di->bs->job;
150+ if (job) {
151+ if (!di->completed) {
152+ block_job_cancel_sync(job);
153+ }
cbf9030a
DM
154+ }
155+ }
156+ }
157+
158+ pvebackup_cleanup();
159+}
160+
161+void qmp_backup_cancel(Error **errp)
162+{
0c5f6a91
DM
163+ Coroutine *co = qemu_coroutine_create(pvebackup_cancel);
164+ qemu_coroutine_enter(co, NULL);
165+
166+ while (backup_state.vmaw) {
167+ qemu_aio_wait();
168+ }
cbf9030a
DM
169+}
170+
171+static void pvebackup_run_next_job(void)
172+{
173+ GList *l = backup_state.di_list;
174+ while (l) {
175+ PVEBackupDevInfo *di = (PVEBackupDevInfo *)l->data;
176+ l = g_list_next(l);
b07588bd
DM
177+ if (!di->completed && di->bs && di->bs->job) {
178+ BlockJob *job = di->bs->job;
bd240f3b 179+ if (block_job_is_paused(job)) {
cbf9030a
DM
180+ bool cancel = backup_state.error || backup_state.cancel;
181+ if (cancel) {
bd240f3b 182+ block_job_cancel(job);
cbf9030a 183+ } else {
bd240f3b 184+ block_job_resume(job);
cbf9030a
DM
185+ }
186+ }
187+ return;
188+ }
189+ }
190+
191+ pvebackup_cleanup();
192+}
193+
194+char *qmp_backup(const char *backup_file, bool has_format,
195+ BackupFormat format,
196+ bool has_config_file, const char *config_file,
197+ bool has_devlist, const char *devlist,
198+ bool has_speed, int64_t speed, Error **errp)
199+{
200+ BlockDriverState *bs;
201+ Error *local_err = NULL;
202+ uuid_t uuid;
203+ VmaWriter *vmaw = NULL;
204+ gchar **devs = NULL;
205+ GList *di_list = NULL;
206+ GList *l;
207+
208+ if (backup_state.di_list) {
209+ error_set(errp, ERROR_CLASS_GENERIC_ERROR,
210+ "previous backup not finished");
211+ return NULL;
212+ }
213+
214+ /* Todo: try to auto-detect format based on file name */
215+ format = has_format ? format : BACKUP_FORMAT_VMA;
216+
217+ if (format != BACKUP_FORMAT_VMA) {
218+ error_set(errp, ERROR_CLASS_GENERIC_ERROR, "unknown backup format");
219+ return NULL;
220+ }
221+
222+ if (has_devlist) {
223+ devs = g_strsplit_set(devlist, ",;:", -1);
224+
225+ gchar **d = devs;
226+ while (d && *d) {
227+ bs = bdrv_find(*d);
228+ if (bs) {
229+ if (bdrv_is_read_only(bs)) {
230+ error_set(errp, QERR_DEVICE_IS_READ_ONLY, *d);
231+ goto err;
232+ }
233+ if (!bdrv_is_inserted(bs)) {
234+ error_set(errp, QERR_DEVICE_HAS_NO_MEDIUM, *d);
235+ goto err;
236+ }
237+ PVEBackupDevInfo *di = g_new0(PVEBackupDevInfo, 1);
238+ di->bs = bs;
239+ di_list = g_list_append(di_list, di);
240+ } else {
241+ error_set(errp, QERR_DEVICE_NOT_FOUND, *d);
242+ goto err;
243+ }
244+ d++;
245+ }
246+
247+ } else {
248+
249+ bs = NULL;
250+ while ((bs = bdrv_next(bs))) {
251+
252+ if (!bdrv_is_inserted(bs) || bdrv_is_read_only(bs)) {
253+ continue;
254+ }
255+
256+ PVEBackupDevInfo *di = g_new0(PVEBackupDevInfo, 1);
257+ di->bs = bs;
258+ di_list = g_list_append(di_list, di);
259+ }
260+ }
261+
262+ if (!di_list) {
263+ error_set(errp, ERROR_CLASS_GENERIC_ERROR, "empty device list");
264+ goto err;
265+ }
266+
e72ed697
DM
267+ size_t total = 0;
268+
cbf9030a
DM
269+ l = di_list;
270+ while (l) {
271+ PVEBackupDevInfo *di = (PVEBackupDevInfo *)l->data;
272+ l = g_list_next(l);
d5764756 273+ if (bdrv_in_use(di->bs)) {
cbf9030a
DM
274+ error_set(errp, QERR_DEVICE_IN_USE, bdrv_get_device_name(di->bs));
275+ goto err;
276+ }
e72ed697
DM
277+
278+ ssize_t size = bdrv_getlength(di->bs);
279+ if (size < 0) {
280+ error_setg_errno(errp, -di->size, "bdrv_getlength failed");
281+ goto err;
282+ }
283+ di->size = size;
284+ total += size;
cbf9030a
DM
285+ }
286+
287+ uuid_generate(uuid);
288+
289+ vmaw = vma_writer_create(backup_file, uuid, &local_err);
290+ if (!vmaw) {
291+ if (error_is_set(&local_err)) {
292+ error_propagate(errp, local_err);
293+ }
294+ goto err;
295+ }
296+
297+ /* register all devices for vma writer */
298+ l = di_list;
299+ while (l) {
300+ PVEBackupDevInfo *di = (PVEBackupDevInfo *)l->data;
301+ l = g_list_next(l);
302+
cbf9030a 303+ const char *devname = bdrv_get_device_name(di->bs);
e72ed697 304+ di->dev_id = vma_writer_register_stream(vmaw, devname, di->size);
cbf9030a
DM
305+ if (di->dev_id <= 0) {
306+ error_set(errp, ERROR_CLASS_GENERIC_ERROR,
307+ "register_stream failed");
308+ goto err;
309+ }
310+ }
311+
312+ /* add configuration file to archive */
313+ if (has_config_file) {
314+ char *cdata = NULL;
315+ gsize clen = 0;
316+ GError *err = NULL;
317+ if (!g_file_get_contents(config_file, &cdata, &clen, &err)) {
318+ error_setg(errp, "unable to read file '%s'", config_file);
319+ goto err;
320+ }
321+
322+ const char *basename = g_path_get_basename(config_file);
323+ if (vma_writer_add_config(vmaw, basename, cdata, clen) != 0) {
324+ error_setg(errp, "unable to add config data to vma archive");
325+ g_free(cdata);
326+ goto err;
327+ }
328+ g_free(cdata);
329+ }
330+
331+ /* initialize global backup_state now */
332+
333+ backup_state.cancel = false;
334+
335+ if (backup_state.error) {
336+ error_free(backup_state.error);
337+ backup_state.error = NULL;
338+ }
339+
340+ backup_state.speed = (has_speed && speed > 0) ? speed : 0;
341+
342+ backup_state.start_time = time(NULL);
343+ backup_state.end_time = 0;
344+
345+ if (backup_state.backup_file) {
346+ g_free(backup_state.backup_file);
347+ }
348+ backup_state.backup_file = g_strdup(backup_file);
349+
350+ backup_state.vmaw = vmaw;
351+
352+ uuid_copy(backup_state.uuid, uuid);
353+ uuid_unparse_lower(uuid, backup_state.uuid_str);
354+
355+ backup_state.di_list = di_list;
356+
e72ed697
DM
357+ backup_state.total = total;
358+ backup_state.transferred = 0;
359+ backup_state.zero_bytes = 0;
cbf9030a
DM
360+
361+ /* start all jobs (paused state) */
362+ l = di_list;
363+ while (l) {
364+ PVEBackupDevInfo *di = (PVEBackupDevInfo *)l->data;
365+ l = g_list_next(l);
366+
367+ backup_start(di->bs, NULL, speed, MIRROR_SYNC_MODE_FULL,
368+ BLOCKDEV_ON_ERROR_REPORT, BLOCKDEV_ON_ERROR_REPORT,
bd240f3b
DM
369+ pvebackup_dump_cb, pvebackup_complete_cb, di,
370+ true, &local_err);
cbf9030a
DM
371+ if (local_err != NULL) {
372+ error_setg(&backup_state.error, "backup_job_create failed");
0c5f6a91 373+ pvebackup_cancel(NULL);
cbf9030a
DM
374+ }
375+ }
376+
377+ if (!backup_state.error) {
378+ pvebackup_run_next_job(); // run one job
379+ }
380+
381+ return g_strdup(backup_state.uuid_str);
382+
383+err:
384+
385+ l = di_list;
386+ while (l) {
387+ g_free(l->data);
388+ l = g_list_next(l);
389+ }
390+ g_list_free(di_list);
391+
392+ if (devs) {
393+ g_strfreev(devs);
394+ }
395+
396+ if (vmaw) {
397+ Error *err = NULL;
398+ vma_writer_close(vmaw, &err);
399+ unlink(backup_file);
400+ }
401+
402+ return NULL;
403+}
404+
405+BackupStatus *qmp_query_backup(Error **errp)
406+{
407+ BackupStatus *info = g_malloc0(sizeof(*info));
408+
409+ if (!backup_state.start_time) {
410+ /* not started, return {} */
411+ return info;
412+ }
413+
414+ info->has_status = true;
415+ info->has_start_time = true;
416+ info->start_time = backup_state.start_time;
417+
418+ if (backup_state.backup_file) {
419+ info->has_backup_file = true;
420+ info->backup_file = g_strdup(backup_state.backup_file);
421+ }
422+
423+ info->has_uuid = true;
424+ info->uuid = g_strdup(backup_state.uuid_str);
425+
426+ if (backup_state.end_time) {
427+ if (backup_state.error) {
428+ info->status = g_strdup("error");
429+ info->has_errmsg = true;
430+ info->errmsg = g_strdup(error_get_pretty(backup_state.error));
431+ } else {
432+ info->status = g_strdup("done");
433+ }
434+ info->has_end_time = true;
435+ info->end_time = backup_state.end_time;
436+ } else {
437+ info->status = g_strdup("active");
438+ }
439+
cbf9030a
DM
440+ info->has_total = true;
441+ info->total = backup_state.total;
442+ info->has_zero_bytes = true;
443+ info->zero_bytes = backup_state.zero_bytes;
444+ info->has_transferred = true;
445+ info->transferred = backup_state.transferred;
446+
447+ return info;
448+}
81300c8b
DM
449+
450 void qmp_block_stream(const char *device, bool has_base,
451 const char *base, bool has_speed, int64_t speed,
452 bool has_on_error, BlockdevOnError on_error,
cbf9030a
DM
453Index: new/hmp-commands.hx
454===================================================================
81300c8b
DM
455--- new.orig/hmp-commands.hx 2013-12-03 06:36:18.000000000 +0100
456+++ new/hmp-commands.hx 2013-12-06 08:42:27.000000000 +0100
cbf9030a
DM
457@@ -83,6 +83,35 @@
458 Copy data from a backing file into a block device.
459 ETEXI
460
461+ {
462+ .name = "backup",
463+ .args_type = "backupfile:s,speed:o?,devlist:s?",
464+ .params = "backupfile [speed [devlist]]",
465+ .help = "create a VM Backup.",
466+ .mhandler.cmd = hmp_backup,
467+ },
468+
469+STEXI
470+@item backup
471+@findex backup
472+Create a VM backup.
473+ETEXI
474+
475+ {
476+ .name = "backup_cancel",
477+ .args_type = "",
478+ .params = "",
479+ .help = "cancel the current VM backup",
480+ .mhandler.cmd = hmp_backup_cancel,
481+ },
482+
483+STEXI
484+@item backup_cancel
485+@findex backup_cancel
486+Cancel the current VM backup.
487+
488+ETEXI
489+
490 {
491 .name = "block_job_set_speed",
492 .args_type = "device:B,speed:o",
493@@ -1692,6 +1721,8 @@
494 show CPU statistics
495 @item info usernet
496 show user network stack connection states
497+@item info backup
498+show backup status
499 @item info migrate
500 show migration status
501 @item info migrate_capabilities
502Index: new/hmp.c
503===================================================================
81300c8b
DM
504--- new.orig/hmp.c 2013-12-06 07:46:29.000000000 +0100
505+++ new/hmp.c 2013-12-06 08:42:27.000000000 +0100
219f966c 506@@ -133,6 +133,44 @@
cbf9030a
DM
507 qapi_free_MouseInfoList(mice_list);
508 }
509
510+void hmp_info_backup(Monitor *mon, const QDict *qdict)
511+{
512+ BackupStatus *info;
513+
514+ info = qmp_query_backup(NULL);
515+ if (info->has_status) {
516+ if (info->has_errmsg) {
517+ monitor_printf(mon, "Backup status: %s - %s\n",
518+ info->status, info->errmsg);
519+ } else {
520+ monitor_printf(mon, "Backup status: %s\n", info->status);
521+ }
522+ }
219f966c 523+
cbf9030a 524+ if (info->has_backup_file) {
219f966c
DM
525+ monitor_printf(mon, "Start time: %s", ctime(&info->start_time));
526+ if (info->end_time) {
527+ monitor_printf(mon, "End time: %s", ctime(&info->end_time));
528+ }
529+
cbf9030a
DM
530+ int per = (info->has_total && info->total &&
531+ info->has_transferred && info->transferred) ?
532+ (info->transferred * 100)/info->total : 0;
533+ int zero_per = (info->has_total && info->total &&
534+ info->has_zero_bytes && info->zero_bytes) ?
535+ (info->zero_bytes * 100)/info->total : 0;
536+ monitor_printf(mon, "Backup file: %s\n", info->backup_file);
537+ monitor_printf(mon, "Backup uuid: %s\n", info->uuid);
538+ monitor_printf(mon, "Total size: %zd\n", info->total);
539+ monitor_printf(mon, "Transferred bytes: %zd (%d%%)\n",
540+ info->transferred, per);
541+ monitor_printf(mon, "Zero bytes: %zd (%d%%)\n",
542+ info->zero_bytes, zero_per);
543+ }
544+
545+ qapi_free_BackupStatus(info);
546+}
547+
548 void hmp_info_migrate(Monitor *mon, const QDict *qdict)
549 {
550 MigrationInfo *info;
219f966c
DM
551@@ -1193,6 +1231,29 @@
552
cbf9030a
DM
553 hmp_handle_error(mon, &error);
554 }
219f966c 555+
cbf9030a
DM
556+void hmp_backup_cancel(Monitor *mon, const QDict *qdict)
557+{
219f966c 558+ Error *error = NULL;
cbf9030a 559+
219f966c 560+ qmp_backup_cancel(&error);
cbf9030a 561+
219f966c 562+ hmp_handle_error(mon, &error);
cbf9030a
DM
563+}
564+
565+void hmp_backup(Monitor *mon, const QDict *qdict)
566+{
219f966c
DM
567+ Error *error = NULL;
568+
569+ const char *backup_file = qdict_get_str(qdict, "backupfile");
cbf9030a
DM
570+ const char *devlist = qdict_get_try_str(qdict, "devlist");
571+ int64_t speed = qdict_get_try_int(qdict, "speed", 0);
572+
cbf9030a 573+ qmp_backup(backup_file, true, BACKUP_FORMAT_VMA, false, NULL, !!devlist,
219f966c 574+ devlist, qdict_haskey(qdict, "speed"), speed, &error);
cbf9030a 575+
219f966c 576+ hmp_handle_error(mon, &error);
cbf9030a 577+}
219f966c 578
cbf9030a
DM
579 void hmp_block_job_set_speed(Monitor *mon, const QDict *qdict)
580 {
cbf9030a
DM
581Index: new/hmp.h
582===================================================================
81300c8b
DM
583--- new.orig/hmp.h 2013-12-03 06:36:18.000000000 +0100
584+++ new/hmp.h 2013-12-06 07:46:38.000000000 +0100
cbf9030a
DM
585@@ -28,6 +28,7 @@
586 void hmp_info_migrate(Monitor *mon, const QDict *qdict);
587 void hmp_info_migrate_capabilities(Monitor *mon, const QDict *qdict);
588 void hmp_info_migrate_cache_size(Monitor *mon, const QDict *qdict);
589+void hmp_info_backup(Monitor *mon, const QDict *qdict);
590 void hmp_info_cpus(Monitor *mon, const QDict *qdict);
591 void hmp_info_block(Monitor *mon, const QDict *qdict);
592 void hmp_info_blockstats(Monitor *mon, const QDict *qdict);
593@@ -69,6 +70,8 @@
594 void hmp_change(Monitor *mon, const QDict *qdict);
595 void hmp_block_set_io_throttle(Monitor *mon, const QDict *qdict);
596 void hmp_block_stream(Monitor *mon, const QDict *qdict);
597+void hmp_backup(Monitor *mon, const QDict *qdict);
598+void hmp_backup_cancel(Monitor *mon, const QDict *qdict);
599 void hmp_block_job_set_speed(Monitor *mon, const QDict *qdict);
600 void hmp_block_job_cancel(Monitor *mon, const QDict *qdict);
601 void hmp_block_job_pause(Monitor *mon, const QDict *qdict);
602Index: new/monitor.c
603===================================================================
81300c8b
DM
604--- new.orig/monitor.c 2013-12-03 06:36:18.000000000 +0100
605+++ new/monitor.c 2013-12-06 07:46:38.000000000 +0100
cbf9030a
DM
606@@ -2880,6 +2880,13 @@
607 },
608 #endif
609 {
610+ .name = "backup",
611+ .args_type = "",
612+ .params = "",
613+ .help = "show backup status",
614+ .mhandler.cmd = hmp_info_backup,
615+ },
616+ {
617 .name = "migrate",
618 .args_type = "",
619 .params = "",
620Index: new/qapi-schema.json
621===================================================================
81300c8b
DM
622--- new.orig/qapi-schema.json 2013-12-06 07:46:29.000000000 +0100
623+++ new/qapi-schema.json 2013-12-06 08:42:27.000000000 +0100
cbf9030a
DM
624@@ -547,6 +547,95 @@
625 ##
626 { 'command': 'query-events', 'returns': ['EventInfo'] }
627
628+# @BackupStatus:
629+#
630+# Detailed backup status.
631+#
632+# @status: #optional string describing the current backup status.
633+# This can be 'active', 'done', 'error'. If this field is not
634+# returned, no backup process has been initiated
635+#
636+# @errmsg: #optional error message (only returned if status is 'error')
637+#
638+# @total: #optional total amount of bytes involved in the backup process
639+#
640+# @transferred: #optional amount of bytes already backed up.
641+#
642+# @zero-bytes: #optional amount of 'zero' bytes detected.
643+#
644+# @start-time: #optional time (epoch) when backup job started.
645+#
646+# @end-time: #optional time (epoch) when backup job finished.
647+#
648+# @backupfile: #optional backup file name
649+#
650+# @uuid: #optional uuid for this backup job
651+#
652+##
653+{ 'type': 'BackupStatus',
654+ 'data': {'*status': 'str', '*errmsg': 'str', '*total': 'int',
655+ '*transferred': 'int', '*zero-bytes': 'int',
656+ '*start-time': 'int', '*end-time': 'int',
657+ '*backup-file': 'str', '*uuid': 'str' } }
658+
659+##
660+# @BackupFormat
661+#
662+# An enumeration of supported backup formats.
663+#
664+# @vma: Proxmox vma backup format
665+##
666+{ 'enum': 'BackupFormat',
667+ 'data': [ 'vma' ] }
668+
669+##
670+# @backup:
671+#
672+# Starts a VM backup.
673+#
674+# @backup-file: the backup file name
675+#
676+# @format: format of the backup file
677+#
678+# @config-filename: #optional name of a configuration file to include into
679+# the backup archive.
680+#
681+# @speed: #optional the maximum speed, in bytes per second
682+#
683+# @devlist: #optional list of block device names (separated by ',', ';'
684+# or ':'). By default the backup includes all writable block devices.
685+#
686+# Returns: the uuid of the backup job
687+#
688+##
689+{ 'command': 'backup', 'data': { 'backup-file': 'str',
690+ '*format': 'BackupFormat',
691+ '*config-file': 'str',
692+ '*devlist': 'str', '*speed': 'int' },
693+ 'returns': 'str' }
694+
695+##
696+# @query-backup
697+#
698+# Returns information about current/last backup task.
699+#
700+# Returns: @BackupStatus
701+#
702+##
703+{ 'command': 'query-backup', 'returns': 'BackupStatus' }
704+
705+##
706+# @backup-cancel
707+#
708+# Cancel the current executing backup process.
709+#
710+# Returns: nothing on success
711+#
712+# Notes: This command succeeds even if there is no backup process running.
713+#
714+##
715+{ 'command': 'backup-cancel' }
716+
717 ##
718 # @MigrationStats
719 #
720Index: new/qmp-commands.hx
721===================================================================
81300c8b
DM
722--- new.orig/qmp-commands.hx 2013-12-06 07:46:29.000000000 +0100
723+++ new/qmp-commands.hx 2013-12-06 07:46:38.000000000 +0100
cbf9030a
DM
724@@ -966,6 +966,24 @@
725 EQMP
726
727 {
728+ .name = "backup",
729+ .args_type = "backup-file:s,format:s?,config-file:F?,speed:o?,devlist:s?",
730+ .mhandler.cmd_new = qmp_marshal_input_backup,
731+ },
732+
733+ {
734+ .name = "backup-cancel",
735+ .args_type = "",
736+ .mhandler.cmd_new = qmp_marshal_input_backup_cancel,
737+ },
738+
739+ {
740+ .name = "query-backup",
741+ .args_type = "",
742+ .mhandler.cmd_new = qmp_marshal_input_query_backup,
743+ },
744+
745+ {
746 .name = "block-job-set-speed",
747 .args_type = "device:B,speed:o",
748 .mhandler.cmd_new = qmp_marshal_input_block_job_set_speed,