]> git.proxmox.com Git - pve-qemu-kvm.git/blob - debian/patches/0003-add-backup-related-monitor-commands.patch
update backup patches - removed threaded code
[pve-qemu-kvm.git] / debian / patches / 0003-add-backup-related-monitor-commands.patch
1 From b9c06929cb9e9583b002fa6de76ad3c318c89f35 Mon Sep 17 00:00:00 2001
2 From: Dietmar Maurer <dietmar@proxmox.com>
3 Date: Tue, 13 Nov 2012 11:27:56 +0100
4 Subject: [PATCH v3 3/6] add backup related monitor commands
5
6 We use a generic BackupDriver struct to encapsulate all archive format
7 related function.
8
9 Another option would be to simply dump <devid,cluster_num,cluster_data> to
10 the output fh (pipe), and an external binary saves the data. That way we
11 could move the whole archive format related code out of qemu.
12
13 Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
14 ---
15 backup.h | 12 ++
16 blockdev.c | 412 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
17 hmp-commands.hx | 31 ++++
18 hmp.c | 63 ++++++++
19 hmp.h | 3 +
20 monitor.c | 7 +
21 qapi-schema.json | 91 ++++++++++++
22 qmp-commands.hx | 27 ++++
23 8 files changed, 646 insertions(+), 0 deletions(-)
24
25 diff --git a/backup.h b/backup.h
26 index a5f85e6..c9c20c9 100644
27 --- a/backup.h
28 +++ b/backup.h
29 @@ -29,4 +29,16 @@ int backup_job_create(BlockDriverState *bs, BackupDumpFunc *backup_dump_cb,
30 BlockDriverCompletionFunc *backup_complete_cb,
31 void *opaque, int64_t speed);
32
33 +typedef struct BackupDriver {
34 + const char *format;
35 + void *(*open_cb)(const char *filename, uuid_t uuid, Error **errp);
36 + int (*close_cb)(void *opaque, Error **errp);
37 + int (*register_config_cb)(void *opaque, const char *name, gpointer data,
38 + size_t data_len);
39 + int (*register_stream_cb)(void *opaque, const char *devname, size_t size);
40 + int (*dump_cb)(void *opaque, uint8_t dev_id, int64_t cluster_num,
41 + unsigned char *buf, size_t *zero_bytes);
42 + int (*complete_cb)(void *opaque, uint8_t dev_id, int ret);
43 +} BackupDriver;
44 +
45 #endif /* QEMU_BACKUP_H */
46 diff --git a/blockdev.c b/blockdev.c
47 index e73fd6e..bd2198e 100644
48 --- a/blockdev.c
49 +++ b/blockdev.c
50 @@ -20,6 +20,7 @@
51 #include "qmp-commands.h"
52 #include "trace.h"
53 #include "arch_init.h"
54 +#include "backup.h"
55
56 static QTAILQ_HEAD(drivelist, DriveInfo) drives = QTAILQ_HEAD_INITIALIZER(drives);
57
58 @@ -1321,6 +1322,417 @@ void qmp_drive_mirror(const char *device, const char *target,
59 drive_get_ref(drive_get_by_blockdev(bs));
60 }
61
62 +/* Backup related function */
63 +
64 +static void backup_run_next_job(void);
65 +
66 +static struct GenericBackupState {
67 + Error *error;
68 + uuid_t uuid;
69 + char uuid_str[37];
70 + int64_t speed;
71 + time_t start_time;
72 + time_t end_time;
73 + char *backupfile;
74 + const BackupDriver *driver;
75 + void *writer;
76 + GList *bcb_list;
77 + size_t total;
78 + size_t transferred;
79 + size_t zero_bytes;
80 +} backup_state;
81 +
82 +typedef struct BackupCB {
83 + BlockDriverState *bs;
84 + uint8_t dev_id;
85 + bool started;
86 + bool completed;
87 + size_t size;
88 + size_t transferred;
89 + size_t zero_bytes;
90 +} BackupCB;
91 +
92 +static int backup_dump_cb(void *opaque, BlockDriverState *bs,
93 + int64_t cluster_num, unsigned char *buf)
94 +{
95 + BackupCB *bcb = opaque;
96 +
97 + assert(backup_state.driver);
98 + assert(backup_state.writer);
99 + assert(backup_state.driver->dump_cb);
100 +
101 + size_t zero_bytes = 0;
102 + int bytes = backup_state.driver->dump_cb(backup_state.writer,
103 + bcb->dev_id, cluster_num,
104 + buf, &zero_bytes);
105 +
106 + if (bytes > 0) {
107 + bcb->transferred += bytes;
108 + backup_state.transferred += bytes;
109 + if (zero_bytes) {
110 + bcb->zero_bytes += bytes;
111 + backup_state.zero_bytes += zero_bytes;
112 + }
113 + }
114 +
115 + return bytes;
116 +}
117 +
118 +static void backup_cleanup(void)
119 +{
120 + if (backup_state.writer && backup_state.driver) {
121 + backup_state.end_time = time(NULL);
122 + Error *local_err = NULL;
123 + backup_state.driver->close_cb(backup_state.writer, &local_err);
124 + error_propagate(&backup_state.error, local_err);
125 + backup_state.writer = NULL;
126 + }
127 +
128 + if (backup_state.bcb_list) {
129 + GList *l = backup_state.bcb_list;
130 + while (l) {
131 + BackupCB *bcb = l->data;
132 + l = g_list_next(l);
133 + drive_put_ref_bh_schedule(drive_get_by_blockdev(bcb->bs));
134 + g_free(bcb);
135 + }
136 + g_list_free(backup_state.bcb_list);
137 + backup_state.bcb_list = NULL;
138 + }
139 +}
140 +
141 +static void backup_complete_cb(void *opaque, int ret)
142 +{
143 + BackupCB *bcb = opaque;
144 +
145 + assert(backup_state.driver);
146 + assert(backup_state.writer);
147 + assert(backup_state.driver->complete_cb);
148 + assert(backup_state.driver->close_cb);
149 +
150 + bcb->completed = true;
151 +
152 + backup_state.driver->complete_cb(backup_state.writer, bcb->dev_id, ret);
153 +
154 + backup_run_next_job();
155 +}
156 +
157 +static void backup_cancel(void)
158 +{
159 + if (!backup_state.error) {
160 + error_setg(&backup_state.error, "backup cancelled");
161 + }
162 +
163 + /* we only need to cancel the running job - backup_run_next_job() cancels
164 + * the other jobs */
165 +
166 + GList *l = backup_state.bcb_list;
167 + while (l) {
168 + BackupCB *bcb = l->data;
169 + l = g_list_next(l);
170 + BlockJob *job = bcb->bs->job;
171 + if (!bcb->completed && job) {
172 + block_job_cancel(job);
173 + /* make sure we call the complete callback */
174 + if (!job->co) {
175 + block_job_completed(job, -1);
176 + }
177 + break;
178 + }
179 + }
180 +
181 + if (!l) { /* all jobs completed */
182 + backup_cleanup();
183 + }
184 +}
185 +
186 +void qmp_backup_cancel(Error **errp)
187 +{
188 + backup_cancel();
189 +}
190 +
191 +static void backup_run_next_job(void)
192 +{
193 + GList *l = backup_state.bcb_list;
194 + while(l) {
195 + BackupCB *bcb = l->data;
196 + l = g_list_next(l);
197 +
198 + if (bcb->bs && bcb->bs->job && !bcb->completed) {
199 + if (!bcb->started) {
200 + bcb->started = true;
201 + if (!backup_state.error) {
202 + backup_job_start(bcb->bs);
203 + } else {
204 + block_job_completed(bcb->bs->job, -1);
205 + }
206 + }
207 + return;
208 + }
209 + }
210 +
211 + backup_cleanup();
212 +}
213 +
214 +static void backup_start_jobs(void)
215 +{
216 + /* create all jobs (one for each device), start first one */
217 + GList *l = backup_state.bcb_list;
218 + while (l) {
219 + BackupCB *bcb = l->data;
220 + l = g_list_next(l);
221 +
222 + if (backup_job_create(bcb->bs, backup_dump_cb, backup_complete_cb,
223 + bcb, backup_state.speed) != 0) {
224 + error_setg(&backup_state.error, "backup_job_create failed");
225 + backup_cancel();
226 + return;
227 + }
228 + }
229 +
230 + backup_run_next_job();
231 +}
232 +
233 +char *qmp_backup(const char *backupfile, bool has_format, BackupFormat format,
234 + bool has_config_filename, const char *config_filename,
235 + bool has_devlist, const char *devlist,
236 + bool has_speed, int64_t speed, Error **errp)
237 +{
238 + BlockDriverState *bs;
239 + Error *local_err = NULL;
240 + uuid_t uuid;
241 + void *writer = NULL;
242 + gchar **devs = NULL;
243 + GList *bcblist = NULL;
244 +
245 + /* Todo: try to auto-detect format based on file name */
246 + format = has_format ? format : BACKUP_FORMAT_VMA;
247 +
248 + /* fixme: find driver for specifued format */
249 + const BackupDriver *driver = NULL;
250 +
251 + if (!driver) {
252 + error_set(errp, ERROR_CLASS_GENERIC_ERROR, "unknown backup format");
253 + return NULL;
254 + }
255 +
256 + if (has_devlist) {
257 + devs = g_strsplit_set(devlist, ",;:", -1);
258 +
259 + gchar **d = devs;
260 + while (d && *d) {
261 + bs = bdrv_find(*d);
262 + if (bs) {
263 + if (bdrv_is_read_only(bs)) {
264 + error_set(errp, QERR_DEVICE_IS_READ_ONLY, *d);
265 + goto err;
266 + }
267 + if (!bdrv_is_inserted(bs)) {
268 + error_set(errp, QERR_DEVICE_HAS_NO_MEDIUM, *d);
269 + goto err;
270 + }
271 + BackupCB *bcb = g_new0(BackupCB, 1);
272 + bcb->bs = bs;
273 + bcblist = g_list_append(bcblist, bcb);
274 + } else {
275 + error_set(errp, QERR_DEVICE_NOT_FOUND, *d);
276 + goto err;
277 + }
278 + d++;
279 + }
280 +
281 + } else {
282 +
283 + bs = NULL;
284 + while ((bs = bdrv_next(bs))) {
285 +
286 + if (!bdrv_is_inserted(bs) || bdrv_is_read_only(bs)) {
287 + continue;
288 + }
289 +
290 + BackupCB *bcb = g_new0(BackupCB, 1);
291 + bcb->bs = bs;
292 + bcblist = g_list_append(bcblist, bcb);
293 + }
294 + }
295 +
296 + if (!bcblist) {
297 + error_set(errp, ERROR_CLASS_GENERIC_ERROR, "empty device list");
298 + goto err;
299 + }
300 +
301 + GList *l = bcblist;
302 + while (l) {
303 + BackupCB *bcb = l->data;
304 + l = g_list_next(l);
305 + if (bcb->bs->job) {
306 + error_set(errp, QERR_DEVICE_IN_USE, bdrv_get_device_name(bcb->bs));
307 + goto err;
308 + }
309 + }
310 +
311 + uuid_generate(uuid);
312 +
313 + writer = driver->open_cb(backupfile, uuid, &local_err);
314 + if (!writer) {
315 + if (error_is_set(&local_err)) {
316 + error_propagate(errp, local_err);
317 + }
318 + goto err;
319 + }
320 +
321 + size_t total = 0;
322 +
323 + /* register all devices for vma writer */
324 + l = bcblist;
325 + while (l) {
326 + BackupCB *bcb = l->data;
327 + l = g_list_next(l);
328 +
329 + int64_t size = bdrv_getlength(bcb->bs);
330 + const char *devname = bdrv_get_device_name(bcb->bs);
331 + bcb->dev_id = driver->register_stream_cb(writer, devname, size);
332 + if (bcb->dev_id <= 0) {
333 + error_set(errp, ERROR_CLASS_GENERIC_ERROR,
334 + "register_stream failed");
335 + goto err;
336 + }
337 + bcb->size = size;
338 + total += size;
339 + }
340 +
341 + /* add configuration file to archive */
342 + if (has_config_filename) {
343 + char *cdata = NULL;
344 + gsize clen = 0;
345 + GError *err = NULL;
346 + if (!g_file_get_contents(config_filename, &cdata, &clen, &err)) {
347 + error_setg(errp, "unable to read file '%s'", config_filename);
348 + goto err;
349 + }
350 +
351 + const char *basename = g_path_get_basename(config_filename);
352 + if (driver->register_config_cb(writer, basename, cdata, clen) < 0) {
353 + error_setg(errp, "register_config failed");
354 + g_free(cdata);
355 + goto err;
356 + }
357 + g_free(cdata);
358 + }
359 +
360 + /* initialize global backup_state now */
361 +
362 + if (backup_state.error) {
363 + error_free(backup_state.error);
364 + backup_state.error = NULL;
365 + }
366 +
367 + backup_state.driver = driver;
368 +
369 + backup_state.speed = (has_speed && speed > 0) ? speed : 0;
370 +
371 + backup_state.start_time = time(NULL);
372 + backup_state.end_time = 0;
373 +
374 + if (backup_state.backupfile) {
375 + g_free(backup_state.backupfile);
376 + }
377 + backup_state.backupfile = g_strdup(backupfile);
378 +
379 + backup_state.writer = writer;
380 +
381 + uuid_copy(backup_state.uuid, uuid);
382 + uuid_unparse_lower(uuid, backup_state.uuid_str);
383 +
384 + backup_state.bcb_list = bcblist;
385 +
386 + backup_state.total = total;
387 + backup_state.transferred = 0;
388 + backup_state.zero_bytes = 0;
389 +
390 + /* Grab a reference so hotplug does not delete the
391 + * BlockDriverState from underneath us.
392 + */
393 + l = bcblist;
394 + while (l) {
395 + BackupCB *bcb = l->data;
396 + l = g_list_next(l);
397 + drive_get_ref(drive_get_by_blockdev(bcb->bs));
398 + }
399 +
400 + backup_start_jobs();
401 +
402 + return g_strdup(backup_state.uuid_str);
403 +
404 +err:
405 +
406 + l = bcblist;
407 + while (l) {
408 + g_free(l->data);
409 + l = g_list_next(l);
410 + }
411 + g_list_free(bcblist);
412 +
413 + if (devs) {
414 + g_strfreev(devs);
415 + }
416 +
417 + if (writer) {
418 + unlink(backupfile);
419 + if (driver) {
420 + Error *err = NULL;
421 + driver->close_cb(writer, &err);
422 + }
423 + }
424 +
425 + return NULL;
426 +}
427 +
428 +BackupStatus *qmp_query_backup(Error **errp)
429 +{
430 + BackupStatus *info = g_malloc0(sizeof(*info));
431 +
432 + if (!backup_state.start_time) {
433 + /* not started, return {} */
434 + return info;
435 + }
436 +
437 + info->has_status = true;
438 + info->has_start_time = true;
439 + info->start_time = backup_state.start_time;
440 +
441 + if (backup_state.backupfile) {
442 + info->has_backupfile = true;
443 + info->backupfile = g_strdup(backup_state.backupfile);
444 + }
445 +
446 + info->has_uuid = true;
447 + info->uuid = g_strdup(backup_state.uuid_str);
448 +
449 + if (backup_state.end_time) {
450 + if (backup_state.error) {
451 + info->status = g_strdup("error");
452 + info->has_errmsg = true;
453 + info->errmsg = g_strdup(error_get_pretty(backup_state.error));
454 + } else {
455 + info->status = g_strdup("done");
456 + }
457 + info->has_end_time = true;
458 + info->end_time = backup_state.end_time;
459 + } else {
460 + info->status = g_strdup("active");
461 + }
462 +
463 + info->has_total = true;
464 + info->total = backup_state.total;
465 + info->has_zero_bytes = true;
466 + info->zero_bytes = backup_state.zero_bytes;
467 + info->has_transferred = true;
468 + info->transferred = backup_state.transferred;
469 +
470 + return info;
471 +}
472 +
473 static BlockJob *find_block_job(const char *device)
474 {
475 BlockDriverState *bs;
476 diff --git a/hmp-commands.hx b/hmp-commands.hx
477 index 010b8c9..57be357 100644
478 --- a/hmp-commands.hx
479 +++ b/hmp-commands.hx
480 @@ -83,6 +83,35 @@ STEXI
481 Copy data from a backing file into a block device.
482 ETEXI
483
484 + {
485 + .name = "backup",
486 + .args_type = "backupfile:s,speed:o?,devlist:s?",
487 + .params = "backupfile [speed [devlist]]",
488 + .help = "create a VM Backup.",
489 + .mhandler.cmd = hmp_backup,
490 + },
491 +
492 +STEXI
493 +@item backup
494 +@findex backup
495 +Create a VM backup.
496 +ETEXI
497 +
498 + {
499 + .name = "backup_cancel",
500 + .args_type = "",
501 + .params = "",
502 + .help = "cancel the current VM backup",
503 + .mhandler.cmd = hmp_backup_cancel,
504 + },
505 +
506 +STEXI
507 +@item backup_cancel
508 +@findex backup_cancel
509 +Cancel the current VM backup.
510 +
511 +ETEXI
512 +
513 {
514 .name = "block_job_set_speed",
515 .args_type = "device:B,speed:o",
516 @@ -1558,6 +1587,8 @@ show CPU statistics
517 show user network stack connection states
518 @item info migrate
519 show migration status
520 +@item info backup
521 +show backup status
522 @item info migrate_capabilities
523 show current migration capabilities
524 @item info migrate_cache_size
525 diff --git a/hmp.c b/hmp.c
526 index 180ba2b..27fd421 100644
527 --- a/hmp.c
528 +++ b/hmp.c
529 @@ -130,6 +130,38 @@ void hmp_info_mice(Monitor *mon)
530 qapi_free_MouseInfoList(mice_list);
531 }
532
533 +void hmp_info_backup(Monitor *mon)
534 +{
535 + BackupStatus *info;
536 +
537 + info = qmp_query_backup(NULL);
538 + if (info->has_status) {
539 + if (info->has_errmsg) {
540 + monitor_printf(mon, "Backup status: %s - %s\n",
541 + info->status, info->errmsg);
542 + } else {
543 + monitor_printf(mon, "Backup status: %s\n", info->status);
544 + }
545 + }
546 + if (info->has_backupfile) {
547 + int per = (info->has_total && info->total &&
548 + info->has_transferred && info->transferred) ?
549 + (info->transferred * 100)/info->total : 0;
550 + int zero_per = (info->has_total && info->total &&
551 + info->has_zero_bytes && info->zero_bytes) ?
552 + (info->zero_bytes * 100)/info->total : 0;
553 + monitor_printf(mon, "Backup file: %s\n", info->backupfile);
554 + monitor_printf(mon, "Backup uuid: %s\n", info->uuid);
555 + monitor_printf(mon, "Total size: %zd\n", info->total);
556 + monitor_printf(mon, "Transferred bytes: %zd (%d%%)\n",
557 + info->transferred, per);
558 + monitor_printf(mon, "Zero bytes: %zd (%d%%)\n",
559 + info->zero_bytes, zero_per);
560 + }
561 +
562 + qapi_free_BackupStatus(info);
563 +}
564 +
565 void hmp_info_migrate(Monitor *mon)
566 {
567 MigrationInfo *info;
568 @@ -977,6 +1009,37 @@ void hmp_block_stream(Monitor *mon, const QDict *qdict)
569 hmp_handle_error(mon, &error);
570 }
571
572 +void hmp_backup_cancel(Monitor *mon, const QDict *qdict)
573 +{
574 + Error *errp = NULL;
575 +
576 + qmp_backup_cancel(&errp);
577 +
578 + if (error_is_set(&errp)) {
579 + monitor_printf(mon, "%s\n", error_get_pretty(errp));
580 + error_free(errp);
581 + return;
582 + }
583 +}
584 +
585 +void hmp_backup(Monitor *mon, const QDict *qdict)
586 +{
587 + const char *backupfile = qdict_get_str(qdict, "backupfile");
588 + const char *devlist = qdict_get_try_str(qdict, "devlist");
589 + int64_t speed = qdict_get_try_int(qdict, "speed", 0);
590 +
591 + Error *errp = NULL;
592 +
593 + qmp_backup(backupfile, true, BACKUP_FORMAT_VMA, false, NULL, !!devlist,
594 + devlist, qdict_haskey(qdict, "speed"), speed, &errp);
595 +
596 + if (error_is_set(&errp)) {
597 + monitor_printf(mon, "%s\n", error_get_pretty(errp));
598 + error_free(errp);
599 + return;
600 + }
601 +}
602 +
603 void hmp_block_job_set_speed(Monitor *mon, const QDict *qdict)
604 {
605 Error *error = NULL;
606 diff --git a/hmp.h b/hmp.h
607 index 0ab03be..20c9a62 100644
608 --- a/hmp.h
609 +++ b/hmp.h
610 @@ -28,6 +28,7 @@ void hmp_info_mice(Monitor *mon);
611 void hmp_info_migrate(Monitor *mon);
612 void hmp_info_migrate_capabilities(Monitor *mon);
613 void hmp_info_migrate_cache_size(Monitor *mon);
614 +void hmp_info_backup(Monitor *mon);
615 void hmp_info_cpus(Monitor *mon);
616 void hmp_info_block(Monitor *mon);
617 void hmp_info_blockstats(Monitor *mon);
618 @@ -63,6 +64,8 @@ void hmp_eject(Monitor *mon, const QDict *qdict);
619 void hmp_change(Monitor *mon, const QDict *qdict);
620 void hmp_block_set_io_throttle(Monitor *mon, const QDict *qdict);
621 void hmp_block_stream(Monitor *mon, const QDict *qdict);
622 +void hmp_backup(Monitor *mon, const QDict *qdict);
623 +void hmp_backup_cancel(Monitor *mon, const QDict *qdict);
624 void hmp_block_job_set_speed(Monitor *mon, const QDict *qdict);
625 void hmp_block_job_cancel(Monitor *mon, const QDict *qdict);
626 void hmp_block_job_pause(Monitor *mon, const QDict *qdict);
627 diff --git a/monitor.c b/monitor.c
628 index c0e32d6..85cf47e 100644
629 --- a/monitor.c
630 +++ b/monitor.c
631 @@ -2680,6 +2680,13 @@ static mon_cmd_t info_cmds[] = {
632 },
633 #endif
634 {
635 + .name = "backup",
636 + .args_type = "",
637 + .params = "",
638 + .help = "show backup status",
639 + .mhandler.info = hmp_info_backup,
640 + },
641 + {
642 .name = "migrate",
643 .args_type = "",
644 .params = "",
645 diff --git a/qapi-schema.json b/qapi-schema.json
646 index 5dfa052..2d3699b 100644
647 --- a/qapi-schema.json
648 +++ b/qapi-schema.json
649 @@ -358,6 +358,39 @@
650 { 'type': 'EventInfo', 'data': {'name': 'str'} }
651
652 ##
653 +# @BackupStatus:
654 +#
655 +# Detailed backup status.
656 +#
657 +# @status: #optional string describing the current backup status.
658 +# This can be 'active', 'done', 'error'. If this field is not
659 +# returned, no backup process has been initiated
660 +#
661 +# @errmsg: #optional error message (only returned if status is 'error')
662 +#
663 +# @total: #optional total amount of bytes involved in the backup process
664 +#
665 +# @transferred: #optional amount of bytes already backed up.
666 +#
667 +# @zero-bytes: #optional amount of 'zero' bytes detected.
668 +#
669 +# @start-time: #optional time (epoch) when backup job started.
670 +#
671 +# @end-time: #optional time (epoch) when backup job finished.
672 +#
673 +# @backupfile: #optional backup file name
674 +#
675 +# @uuid: #optional uuid for this backup job
676 +#
677 +# Since: 1.4.0
678 +##
679 +{ 'type': 'BackupStatus',
680 + 'data': {'*status': 'str', '*errmsg': 'str', '*total': 'int',
681 + '*transferred': 'int', '*zero-bytes': 'int',
682 + '*start-time': 'int', '*end-time': 'int',
683 + '*backupfile': 'str', '*uuid': 'str' } }
684 +
685 +##
686 # @query-events:
687 #
688 # Return a list of supported QMP events by this server
689 @@ -1764,6 +1797,64 @@
690 'data': { 'path': 'str' },
691 'returns': [ 'ObjectPropertyInfo' ] }
692
693 +
694 +##
695 +# @BackupFormat
696 +#
697 +# An enumeration of supported backup formats.
698 +#
699 +# @vma: Proxmox vma backup format
700 +##
701 +{ 'enum': 'BackupFormat',
702 + 'data': [ 'vma' ] }
703 +
704 +##
705 +# @backup:
706 +#
707 +# Starts a VM backup.
708 +#
709 +# @backupfile: the backup file name
710 +#
711 +# @format: format of the backup file
712 +#
713 +# @config-filename: #optional name of a configuration file to include into
714 +# the backup archive.
715 +#
716 +# @speed: #optional the maximum speed, in bytes per second
717 +#
718 +# Returns: the uuid of the backup job
719 +#
720 +# Since: 1.4.0
721 +##
722 +{ 'command': 'backup', 'data': { 'backupfile': 'str', '*format': 'BackupFormat',
723 + '*config-filename': 'str',
724 + '*devlist': 'str', '*speed': 'int' },
725 + 'returns': 'str' }
726 +
727 +##
728 +# @query-backup
729 +#
730 +# Returns information about current/last backup task.
731 +#
732 +# Returns: @BackupStatus
733 +#
734 +# Since: 1.4.0
735 +##
736 +{ 'command': 'query-backup', 'returns': 'BackupStatus' }
737 +
738 +##
739 +# @backup-cancel
740 +#
741 +# Cancel the current executing backup process.
742 +#
743 +# Returns: nothing on success
744 +#
745 +# Notes: This command succeeds even if there is no backup process running.
746 +#
747 +# Since: 1.4.0
748 +##
749 +{ 'command': 'backup-cancel' }
750 +
751 ##
752 # @qom-get:
753 #
754 diff --git a/qmp-commands.hx b/qmp-commands.hx
755 index 5c692d0..c46fdc4 100644
756 --- a/qmp-commands.hx
757 +++ b/qmp-commands.hx
758 @@ -822,6 +822,18 @@ EQMP
759 },
760
761 {
762 + .name = "backup",
763 + .args_type = "backupfile:s,format:s?,config-filename:F?,speed:o?,devlist:s?",
764 + .mhandler.cmd_new = qmp_marshal_input_backup,
765 + },
766 +
767 + {
768 + .name = "backup_cancel",
769 + .args_type = "",
770 + .mhandler.cmd_new = qmp_marshal_input_backup_cancel,
771 + },
772 +
773 + {
774 .name = "block-job-set-speed",
775 .args_type = "device:B,speed:o",
776 .mhandler.cmd_new = qmp_marshal_input_block_job_set_speed,
777 @@ -2491,6 +2503,21 @@ EQMP
778 },
779
780 SQMP
781 +
782 +query-backup
783 +-------------
784 +
785 +Backup status.
786 +
787 +EQMP
788 +
789 + {
790 + .name = "query-backup",
791 + .args_type = "",
792 + .mhandler.cmd_new = qmp_marshal_input_query_backup,
793 + },
794 +
795 +SQMP
796 migrate-set-capabilities
797 -------
798
799 --
800 1.7.2.5
801