mirror of
https://github.com/xemu-project/xemu.git
synced 2024-11-27 05:20:50 +00:00
block: add drive_backup HMP command
Make "drive_backup" available on the HMP monitor: drive_backup [-n] [-f] device target [format] The -n flag requests QEMU to reuse the image found in new-image-file, instead of recreating it from scratch. The -f flag requests QEMU to copy the whole disk, so that the result does not need a backing file. Note that this flag *must* currently be passed since the other sync modes ('none' and 'top') have not been implemented yet. Requiring it ensures that "drive_backup" behaves like "drive_mirror". Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
parent
b53169eae0
commit
de90930a0c
@ -1056,6 +1056,26 @@ STEXI
|
||||
@findex drive_mirror
|
||||
Start mirroring a block device's writes to a new destination,
|
||||
using the specified target.
|
||||
ETEXI
|
||||
|
||||
{
|
||||
.name = "drive_backup",
|
||||
.args_type = "reuse:-n,full:-f,device:B,target:s,format:s?",
|
||||
.params = "[-n] [-f] device target [format]",
|
||||
.help = "initiates a point-in-time\n\t\t\t"
|
||||
"copy for a device. The device's contents are\n\t\t\t"
|
||||
"copied to the new image file, excluding data that\n\t\t\t"
|
||||
"is written after the command is started.\n\t\t\t"
|
||||
"The -n flag requests QEMU to reuse the image found\n\t\t\t"
|
||||
"in new-image-file, instead of recreating it from scratch.\n\t\t\t"
|
||||
"The -f flag requests QEMU to copy the whole disk,\n\t\t\t"
|
||||
"so that the result does not need a backing file.\n\t\t\t",
|
||||
.mhandler.cmd = hmp_drive_backup,
|
||||
},
|
||||
STEXI
|
||||
@item drive_backup
|
||||
@findex drive_backup
|
||||
Start a point-in-time copy of a block device to a specificed target.
|
||||
ETEXI
|
||||
|
||||
{
|
||||
|
28
hmp.c
28
hmp.c
@ -907,6 +907,34 @@ void hmp_drive_mirror(Monitor *mon, const QDict *qdict)
|
||||
hmp_handle_error(mon, &errp);
|
||||
}
|
||||
|
||||
void hmp_drive_backup(Monitor *mon, const QDict *qdict)
|
||||
{
|
||||
const char *device = qdict_get_str(qdict, "device");
|
||||
const char *filename = qdict_get_str(qdict, "target");
|
||||
const char *format = qdict_get_try_str(qdict, "format");
|
||||
int reuse = qdict_get_try_bool(qdict, "reuse", 0);
|
||||
int full = qdict_get_try_bool(qdict, "full", 0);
|
||||
enum NewImageMode mode;
|
||||
Error *errp = NULL;
|
||||
|
||||
if (!filename) {
|
||||
error_set(&errp, QERR_MISSING_PARAMETER, "target");
|
||||
hmp_handle_error(mon, &errp);
|
||||
return;
|
||||
}
|
||||
|
||||
if (reuse) {
|
||||
mode = NEW_IMAGE_MODE_EXISTING;
|
||||
} else {
|
||||
mode = NEW_IMAGE_MODE_ABSOLUTE_PATHS;
|
||||
}
|
||||
|
||||
qmp_drive_backup(device, filename, !!format, format,
|
||||
full ? MIRROR_SYNC_MODE_FULL : MIRROR_SYNC_MODE_TOP,
|
||||
true, mode, false, 0, false, 0, false, 0, &errp);
|
||||
hmp_handle_error(mon, &errp);
|
||||
}
|
||||
|
||||
void hmp_snapshot_blkdev(Monitor *mon, const QDict *qdict)
|
||||
{
|
||||
const char *device = qdict_get_str(qdict, "device");
|
||||
|
1
hmp.h
1
hmp.h
@ -55,6 +55,7 @@ void hmp_balloon(Monitor *mon, const QDict *qdict);
|
||||
void hmp_block_resize(Monitor *mon, const QDict *qdict);
|
||||
void hmp_snapshot_blkdev(Monitor *mon, const QDict *qdict);
|
||||
void hmp_drive_mirror(Monitor *mon, const QDict *qdict);
|
||||
void hmp_drive_backup(Monitor *mon, const QDict *qdict);
|
||||
void hmp_migrate_cancel(Monitor *mon, const QDict *qdict);
|
||||
void hmp_migrate_set_downtime(Monitor *mon, const QDict *qdict);
|
||||
void hmp_migrate_set_speed(Monitor *mon, const QDict *qdict);
|
||||
|
Loading…
Reference in New Issue
Block a user