]> git.proxmox.com Git - pve-qemu-kvm.git/blame - debian/patches/backup-add-pve-monitor-commands.patch
create backup stats with dump_cb and remove pvebackup_update_status
[pve-qemu-kvm.git] / debian / patches / backup-add-pve-monitor-commands.patch
CommitLineData
cbf9030a
DM
1Index: new/blockdev.c
2===================================================================
e72ed697
DM
3--- new.orig/blockdev.c 2013-12-05 13:39:59.000000000 +0100
4+++ new/blockdev.c 2013-12-06 06:28:41.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
DM
490--- new.orig/hmp.c 2013-12-05 13:39:59.000000000 +0100
491+++ new/hmp.c 2013-12-05 13:40:07.000000000 +0100
cbf9030a
DM
492@@ -133,6 +133,38 @@
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+ }
509+ if (info->has_backup_file) {
510+ int per = (info->has_total && info->total &&
511+ info->has_transferred && info->transferred) ?
512+ (info->transferred * 100)/info->total : 0;
513+ int zero_per = (info->has_total && info->total &&
514+ info->has_zero_bytes && info->zero_bytes) ?
515+ (info->zero_bytes * 100)/info->total : 0;
516+ monitor_printf(mon, "Backup file: %s\n", info->backup_file);
517+ monitor_printf(mon, "Backup uuid: %s\n", info->uuid);
518+ monitor_printf(mon, "Total size: %zd\n", info->total);
519+ monitor_printf(mon, "Transferred bytes: %zd (%d%%)\n",
520+ info->transferred, per);
521+ monitor_printf(mon, "Zero bytes: %zd (%d%%)\n",
522+ info->zero_bytes, zero_per);
523+ }
524+
525+ qapi_free_BackupStatus(info);
526+}
527+
528 void hmp_info_migrate(Monitor *mon, const QDict *qdict)
529 {
530 MigrationInfo *info;
531@@ -1194,6 +1226,37 @@
532 hmp_handle_error(mon, &error);
533 }
534
535+void hmp_backup_cancel(Monitor *mon, const QDict *qdict)
536+{
537+ Error *errp = NULL;
538+
539+ qmp_backup_cancel(&errp);
540+
541+ if (error_is_set(&errp)) {
542+ monitor_printf(mon, "%s\n", error_get_pretty(errp));
543+ error_free(errp);
544+ return;
545+ }
546+}
547+
548+void hmp_backup(Monitor *mon, const QDict *qdict)
549+{
550+ const char *backup_file = qdict_get_str(qdict, "backup-file");
551+ const char *devlist = qdict_get_try_str(qdict, "devlist");
552+ int64_t speed = qdict_get_try_int(qdict, "speed", 0);
553+
554+ Error *errp = NULL;
555+
556+ qmp_backup(backup_file, true, BACKUP_FORMAT_VMA, false, NULL, !!devlist,
557+ devlist, qdict_haskey(qdict, "speed"), speed, &errp);
558+
559+ if (error_is_set(&errp)) {
560+ monitor_printf(mon, "%s\n", error_get_pretty(errp));
561+ error_free(errp);
562+ return;
563+ }
564+}
565+
566 void hmp_block_job_set_speed(Monitor *mon, const QDict *qdict)
567 {
568 Error *error = NULL;
569Index: new/hmp.h
570===================================================================
e72ed697
DM
571--- new.orig/hmp.h 2013-12-05 13:39:59.000000000 +0100
572+++ new/hmp.h 2013-12-05 13:40:07.000000000 +0100
cbf9030a
DM
573@@ -28,6 +28,7 @@
574 void hmp_info_migrate(Monitor *mon, const QDict *qdict);
575 void hmp_info_migrate_capabilities(Monitor *mon, const QDict *qdict);
576 void hmp_info_migrate_cache_size(Monitor *mon, const QDict *qdict);
577+void hmp_info_backup(Monitor *mon, const QDict *qdict);
578 void hmp_info_cpus(Monitor *mon, const QDict *qdict);
579 void hmp_info_block(Monitor *mon, const QDict *qdict);
580 void hmp_info_blockstats(Monitor *mon, const QDict *qdict);
581@@ -69,6 +70,8 @@
582 void hmp_change(Monitor *mon, const QDict *qdict);
583 void hmp_block_set_io_throttle(Monitor *mon, const QDict *qdict);
584 void hmp_block_stream(Monitor *mon, const QDict *qdict);
585+void hmp_backup(Monitor *mon, const QDict *qdict);
586+void hmp_backup_cancel(Monitor *mon, const QDict *qdict);
587 void hmp_block_job_set_speed(Monitor *mon, const QDict *qdict);
588 void hmp_block_job_cancel(Monitor *mon, const QDict *qdict);
589 void hmp_block_job_pause(Monitor *mon, const QDict *qdict);
590Index: new/monitor.c
591===================================================================
e72ed697
DM
592--- new.orig/monitor.c 2013-12-05 13:39:59.000000000 +0100
593+++ new/monitor.c 2013-12-05 13:40:07.000000000 +0100
cbf9030a
DM
594@@ -2880,6 +2880,13 @@
595 },
596 #endif
597 {
598+ .name = "backup",
599+ .args_type = "",
600+ .params = "",
601+ .help = "show backup status",
602+ .mhandler.cmd = hmp_info_backup,
603+ },
604+ {
605 .name = "migrate",
606 .args_type = "",
607 .params = "",
608Index: new/qapi-schema.json
609===================================================================
e72ed697
DM
610--- new.orig/qapi-schema.json 2013-12-05 13:39:59.000000000 +0100
611+++ new/qapi-schema.json 2013-12-06 06:27:50.000000000 +0100
cbf9030a
DM
612@@ -547,6 +547,95 @@
613 ##
614 { 'command': 'query-events', 'returns': ['EventInfo'] }
615
616+# @BackupStatus:
617+#
618+# Detailed backup status.
619+#
620+# @status: #optional string describing the current backup status.
621+# This can be 'active', 'done', 'error'. If this field is not
622+# returned, no backup process has been initiated
623+#
624+# @errmsg: #optional error message (only returned if status is 'error')
625+#
626+# @total: #optional total amount of bytes involved in the backup process
627+#
628+# @transferred: #optional amount of bytes already backed up.
629+#
630+# @zero-bytes: #optional amount of 'zero' bytes detected.
631+#
632+# @start-time: #optional time (epoch) when backup job started.
633+#
634+# @end-time: #optional time (epoch) when backup job finished.
635+#
636+# @backupfile: #optional backup file name
637+#
638+# @uuid: #optional uuid for this backup job
639+#
640+##
641+{ 'type': 'BackupStatus',
642+ 'data': {'*status': 'str', '*errmsg': 'str', '*total': 'int',
643+ '*transferred': 'int', '*zero-bytes': 'int',
644+ '*start-time': 'int', '*end-time': 'int',
645+ '*backup-file': 'str', '*uuid': 'str' } }
646+
647+##
648+# @BackupFormat
649+#
650+# An enumeration of supported backup formats.
651+#
652+# @vma: Proxmox vma backup format
653+##
654+{ 'enum': 'BackupFormat',
655+ 'data': [ 'vma' ] }
656+
657+##
658+# @backup:
659+#
660+# Starts a VM backup.
661+#
662+# @backup-file: the backup file name
663+#
664+# @format: format of the backup file
665+#
666+# @config-filename: #optional name of a configuration file to include into
667+# the backup archive.
668+#
669+# @speed: #optional the maximum speed, in bytes per second
670+#
671+# @devlist: #optional list of block device names (separated by ',', ';'
672+# or ':'). By default the backup includes all writable block devices.
673+#
674+# Returns: the uuid of the backup job
675+#
676+##
677+{ 'command': 'backup', 'data': { 'backup-file': 'str',
678+ '*format': 'BackupFormat',
679+ '*config-file': 'str',
680+ '*devlist': 'str', '*speed': 'int' },
681+ 'returns': 'str' }
682+
683+##
684+# @query-backup
685+#
686+# Returns information about current/last backup task.
687+#
688+# Returns: @BackupStatus
689+#
690+##
691+{ 'command': 'query-backup', 'returns': 'BackupStatus' }
692+
693+##
694+# @backup-cancel
695+#
696+# Cancel the current executing backup process.
697+#
698+# Returns: nothing on success
699+#
700+# Notes: This command succeeds even if there is no backup process running.
701+#
702+##
703+{ 'command': 'backup-cancel' }
704+
705 ##
706 # @MigrationStats
707 #
708Index: new/qmp-commands.hx
709===================================================================
e72ed697
DM
710--- new.orig/qmp-commands.hx 2013-12-05 13:39:59.000000000 +0100
711+++ new/qmp-commands.hx 2013-12-05 13:40:07.000000000 +0100
cbf9030a
DM
712@@ -966,6 +966,24 @@
713 EQMP
714
715 {
716+ .name = "backup",
717+ .args_type = "backup-file:s,format:s?,config-file:F?,speed:o?,devlist:s?",
718+ .mhandler.cmd_new = qmp_marshal_input_backup,
719+ },
720+
721+ {
722+ .name = "backup-cancel",
723+ .args_type = "",
724+ .mhandler.cmd_new = qmp_marshal_input_backup_cancel,
725+ },
726+
727+ {
728+ .name = "query-backup",
729+ .args_type = "",
730+ .mhandler.cmd_new = qmp_marshal_input_query_backup,
731+ },
732+
733+ {
734 .name = "block-job-set-speed",
735 .args_type = "device:B,speed:o",
736 .mhandler.cmd_new = qmp_marshal_input_block_job_set_speed,