qemu: monitor: Add support for blockdev-backup via 'transaction'

Implement the transaction actions generator for blockdev-backup.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Peter Krempa 2019-09-27 17:28:48 +02:00
parent 08b810053a
commit e87120307a
5 changed files with 72 additions and 1 deletions

View File

@ -4615,3 +4615,16 @@ qemuMonitorTransactionSnapshotBlockdev(virJSONValuePtr actions,
{
return qemuMonitorJSONTransactionSnapshotBlockdev(actions, node, overlay);
}
int
qemuMonitorTransactionBackup(virJSONValuePtr actions,
const char *device,
const char *jobname,
const char *target,
const char *bitmap,
qemuMonitorTransactionBackupSyncMode syncmode)
{
return qemuMonitorJSONTransactionBackup(actions, device, jobname, target,
bitmap, syncmode);
}

View File

@ -1392,3 +1392,18 @@ int
qemuMonitorTransactionSnapshotBlockdev(virJSONValuePtr actions,
const char *node,
const char *overlay);
typedef enum {
QEMU_MONITOR_TRANSACTION_BACKUP_SYNC_MODE_NONE = 0,
QEMU_MONITOR_TRANSACTION_BACKUP_SYNC_MODE_INCREMENTAL,
QEMU_MONITOR_TRANSACTION_BACKUP_SYNC_MODE_FULL,
QEMU_MONITOR_TRANSACTION_BACKUP_SYNC_MODE_LAST,
} qemuMonitorTransactionBackupSyncMode;
int
qemuMonitorTransactionBackup(virJSONValuePtr actions,
const char *device,
const char *jobname,
const char *target,
const char *bitmap,
qemuMonitorTransactionBackupSyncMode syncmode);

View File

@ -9198,6 +9198,35 @@ qemuMonitorJSONTransactionSnapshotBlockdev(virJSONValuePtr actions,
NULL);
}
VIR_ENUM_DECL(qemuMonitorTransactionBackupSyncMode);
VIR_ENUM_IMPL(qemuMonitorTransactionBackupSyncMode,
QEMU_MONITOR_TRANSACTION_BACKUP_SYNC_MODE_LAST,
"none",
"incremental",
"full");
int
qemuMonitorJSONTransactionBackup(virJSONValuePtr actions,
const char *device,
const char *jobname,
const char *target,
const char *bitmap,
qemuMonitorTransactionBackupSyncMode syncmode)
{
const char *syncmodestr = qemuMonitorTransactionBackupSyncModeTypeToString(syncmode);
return qemuMonitorJSONTransactionAdd(actions,
"blockdev-backup",
"s:device", device,
"s:job-id", jobname,
"s:target", target,
"s:sync", syncmodestr,
"S:bitmap", bitmap,
"T:auto-finalize", VIR_TRISTATE_BOOL_YES,
"T:auto-dismiss", VIR_TRISTATE_BOOL_NO,
NULL);
}
static qemuMonitorJobInfoPtr
qemuMonitorJSONGetJobInfoOne(virJSONValuePtr data)

View File

@ -667,3 +667,11 @@ int
qemuMonitorJSONTransactionSnapshotBlockdev(virJSONValuePtr actions,
const char *node,
const char *overlay);
int
qemuMonitorJSONTransactionBackup(virJSONValuePtr actions,
const char *device,
const char *jobname,
const char *target,
const char *bitmap,
qemuMonitorTransactionBackupSyncMode syncmode);

View File

@ -2962,7 +2962,13 @@ testQemuMonitorJSONTransaction(const void *opaque)
qemuMonitorTransactionBitmapDisable(actions, "node4", "bitmap4") < 0 ||
qemuMonitorTransactionBitmapMerge(actions, "node5", "bitmap5", &mergebitmaps) < 0 ||
qemuMonitorTransactionSnapshotLegacy(actions, "dev6", "path", "qcow2", true) < 0 ||
qemuMonitorTransactionSnapshotBlockdev(actions, "node7", "overlay7") < 0)
qemuMonitorTransactionSnapshotBlockdev(actions, "node7", "overlay7") < 0 ||
qemuMonitorTransactionBackup(actions, "dev8", "job8", "target8", "bitmap8",
QEMU_MONITOR_TRANSACTION_BACKUP_SYNC_MODE_NONE) < 0 ||
qemuMonitorTransactionBackup(actions, "dev9", "job9", "target9", "bitmap9",
QEMU_MONITOR_TRANSACTION_BACKUP_SYNC_MODE_INCREMENTAL) < 0 ||
qemuMonitorTransactionBackup(actions, "devA", "jobA", "targetA", "bitmapA",
QEMU_MONITOR_TRANSACTION_BACKUP_SYNC_MODE_FULL) < 0)
return -1;
if (qemuMonitorTestAddItem(test, "transaction", "{\"return\":{}}") < 0)