Signed-off-by: Nikolay Shirokovskiy <nikolay.shirokovskiy(a)openvz.org>
---
src/qemu/qemu_monitor.c | 53 ++++++++++++++++++
src/qemu/qemu_monitor.h | 23 ++++++++
src/qemu/qemu_monitor_json.c | 106 +++++++++++++++++++++++++++++++++++
src/qemu/qemu_monitor_json.h | 23 ++++++++
4 files changed, 205 insertions(+)
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index 316cff5b9b..4b33407e50 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -4566,3 +4566,56 @@ qemuMonitorChangeMemoryRequestedSize(qemuMonitor *mon,
return qemuMonitorJSONChangeMemoryRequestedSize(mon, alias, requestedsize);
}
+
+
+int
+qemuMonitorSnapshotSave(qemuMonitor *mon,
+ const char *jobname,
+ const char *snapid,
+ const char *vmstateDevice,
+ const char **devices,
+ size_t ndevices)
+{
+ VIR_DEBUG("jobname=%s, snapid=%s, vmstateDevice=%s, devices=%p,
ndevices=%zd",
+ jobname, snapid, vmstateDevice, devices, ndevices);
+
+ QEMU_CHECK_MONITOR(mon);
+
+ return qemuMonitorJSONSnapshotSave(mon, jobname, snapid, vmstateDevice,
+ devices, ndevices);
+}
+
+
+int
+qemuMonitorSnapshotLoad(qemuMonitor *mon,
+ const char *jobname,
+ const char *snapid,
+ const char *vmstateDevice,
+ const char **devices,
+ size_t ndevices)
+{
+ VIR_DEBUG("jobname=%s, snapid=%s, vmstateDevice=%s, devices=%p,
ndevices=%zd",
+ jobname, snapid, vmstateDevice, devices, ndevices);
+
+ QEMU_CHECK_MONITOR(mon);
+
+ return qemuMonitorJSONSnapshotLoad(mon, jobname, snapid, vmstateDevice,
+ devices, ndevices);
+}
+
+
+int
+qemuMonitorSnapshotDelete(qemuMonitor *mon,
+ const char *jobname,
+ const char *snapid,
+ const char **devices,
+ size_t ndevices)
+{
+ VIR_DEBUG("jobname=%s, snapid=%s, devices=%p, ndevices=%zd",
+ jobname, snapid, devices, ndevices);
+
+ QEMU_CHECK_MONITOR(mon);
+
+ return qemuMonitorJSONSnapshotDelete(mon, jobname, snapid,
+ devices, ndevices);
+}
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index 5c2a749282..8067236693 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -1588,3 +1588,26 @@ int
qemuMonitorChangeMemoryRequestedSize(qemuMonitor *mon,
const char *alias,
unsigned long long requestedsize);
+
+int
+qemuMonitorSnapshotSave(qemuMonitor *mon,
+ const char *jobname,
+ const char *snapid,
+ const char *vmstateDevice,
+ const char **devices,
+ size_t ndevices);
+
+int
+qemuMonitorSnapshotLoad(qemuMonitor *mon,
+ const char *jobname,
+ const char *snapid,
+ const char *vmstateDevice,
+ const char **devices,
+ size_t ndevices);
+
+int
+qemuMonitorSnapshotDelete(qemuMonitor *mon,
+ const char *jobname,
+ const char *snapid,
+ const char **devices,
+ size_t ndevices);
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index d5622bd6d9..864be427c3 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -8966,3 +8966,109 @@ qemuMonitorJSONChangeMemoryRequestedSize(qemuMonitor *mon,
return qemuMonitorJSONSetObjectProperty(mon, path, "requested-size",
&prop);
}
+
+
+int
+qemuMonitorJSONSnapshotSave(qemuMonitor *mon,
+ const char *jobname,
+ const char *snapid,
+ const char *vmstateDevice,
+ const char **devices,
+ size_t ndevices)
+{
+ g_autoptr(virJSONValue) devicesJSON = virJSONValueNewArray();
+ g_autoptr(virJSONValue) cmd = NULL;
+ g_autoptr(virJSONValue) reply = NULL;
+ size_t i;
+
+ for (i = 0; i < ndevices; i++)
+ if (virJSONValueArrayAppendString(devicesJSON, devices[i]) < 0)
+ return -1;
+
+ cmd = qemuMonitorJSONMakeCommand("snapshot-save",
+ "s:job-id", jobname,
+ "s:tag", snapid,
+ "s:vmstate", vmstateDevice,
+ "a:devices", &devicesJSON,
+ NULL);
+ if (!cmd)
+ return -1;
+
+ if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
+ return -1;
+
+ if (qemuMonitorJSONCheckError(cmd, reply) < 0)
+ return -1;
+
+ return 0;
+}
+
+
+int
+qemuMonitorJSONSnapshotLoad(qemuMonitor *mon,
+ const char *jobname,
+ const char *snapid,
+ const char *vmstateDevice,
+ const char **devices,
+ size_t ndevices)
+{
+ g_autoptr(virJSONValue) devicesJSON = virJSONValueNewArray();
+ g_autoptr(virJSONValue) cmd = NULL;
+ g_autoptr(virJSONValue) reply = NULL;
+ size_t i;
+
+ for (i = 0; i < ndevices; i++)
+ if (virJSONValueArrayAppendString(devicesJSON, devices[i]) < 0)
+ return -1;
+
+ cmd = qemuMonitorJSONMakeCommand("snapshot-load",
+ "s:job-id", jobname,
+ "s:tag", snapid,
+ "s:vmstate", vmstateDevice,
+ "a:devices", &devicesJSON,
+ NULL);
+ if (!cmd)
+ return -1;
+
+ if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
+ return -1;
+
+ if (qemuMonitorJSONCheckError(cmd, reply) < 0)
+ return -1;
+
+ return 0;
+}
+
+
+int
+qemuMonitorJSONSnapshotDelete(qemuMonitor *mon,
+ const char *jobname,
+ const char *snapid,
+ const char **devices,
+ size_t ndevices)
+{
+ g_autoptr(virJSONValue) devicesJSON = virJSONValueNewArray();
+ g_autoptr(virJSONValue) cmd = NULL;
+ g_autoptr(virJSONValue) reply = NULL;
+ size_t i;
+
+ for (i = 0; i < ndevices; i++)
+ if (virJSONValueArrayAppendString(devicesJSON, devices[i]) < 0)
+ return -1;
+
+ cmd = qemuMonitorJSONMakeCommand("snapshot-delete",
+ "s:job-id", jobname,
+ "s:tag", snapid,
+ "a:devices", &devicesJSON,
+ NULL);
+ if (!cmd)
+ return -1;
+
+ if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
+ return -1;
+
+ if (qemuMonitorJSONCheckError(cmd, reply) < 0)
+ return -1;
+
+ return 0;
+}
diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h
index 982fbad44e..73849c4a4b 100644
--- a/src/qemu/qemu_monitor_json.h
+++ b/src/qemu/qemu_monitor_json.h
@@ -873,3 +873,26 @@ int
qemuMonitorJSONChangeMemoryRequestedSize(qemuMonitor *mon,
const char *alias,
unsigned long long requestedsize);
+
+int
+qemuMonitorJSONSnapshotSave(qemuMonitor *mon,
+ const char *jobname,
+ const char *snapid,
+ const char *vmstateDevice,
+ const char **devices,
+ size_t ndevices);
+
+int
+qemuMonitorJSONSnapshotLoad(qemuMonitor *mon,
+ const char *jobname,
+ const char *snapid,
+ const char *vmstateDevice,
+ const char **devices,
+ size_t ndevices);
+
+int
+qemuMonitorJSONSnapshotDelete(qemuMonitor *mon,
+ const char *jobname,
+ const char *snapid,
+ const char **devices,
+ size_t ndevices);
--
2.35.1