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