[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 6/9] monitor: move hmp_snapshot_* to blockdev-hmp-cmds.c
From: |
Maxim Levitsky |
Subject: |
[PATCH 6/9] monitor: move hmp_snapshot_* to blockdev-hmp-cmds.c |
Date: |
Wed, 20 Nov 2019 20:58:47 +0200 |
Signed-off-by: Maxim Levitsky <address@hidden>
---
blockdev-hmp-cmds.c | 47 +++++++++++++++++++++++++++++++++++++++++++++
monitor/hmp-cmds.c | 46 --------------------------------------------
2 files changed, 47 insertions(+), 46 deletions(-)
diff --git a/blockdev-hmp-cmds.c b/blockdev-hmp-cmds.c
index e333de27b1..f3d22c7dd3 100644
--- a/blockdev-hmp-cmds.c
+++ b/blockdev-hmp-cmds.c
@@ -290,3 +290,50 @@ void hmp_block_job_complete(Monitor *mon, const QDict
*qdict)
hmp_handle_error(mon, &error);
}
+
+void hmp_snapshot_blkdev(Monitor *mon, const QDict *qdict)
+{
+ const char *device = qdict_get_str(qdict, "device");
+ const char *filename = qdict_get_try_str(qdict, "snapshot-file");
+ const char *format = qdict_get_try_str(qdict, "format");
+ bool reuse = qdict_get_try_bool(qdict, "reuse", false);
+ enum NewImageMode mode;
+ Error *err = NULL;
+
+ if (!filename) {
+ /* In the future, if 'snapshot-file' is not specified, the snapshot
+ will be taken internally. Today it's actually required. */
+ error_setg(&err, QERR_MISSING_PARAMETER, "snapshot-file");
+ hmp_handle_error(mon, &err);
+ return;
+ }
+
+ mode = reuse ? NEW_IMAGE_MODE_EXISTING : NEW_IMAGE_MODE_ABSOLUTE_PATHS;
+ qmp_blockdev_snapshot_sync(true, device, false, NULL,
+ filename, false, NULL,
+ !!format, format,
+ true, mode, &err);
+ hmp_handle_error(mon, &err);
+}
+
+void hmp_snapshot_blkdev_internal(Monitor *mon, const QDict *qdict)
+{
+ const char *device = qdict_get_str(qdict, "device");
+ const char *name = qdict_get_str(qdict, "name");
+ Error *err = NULL;
+
+ qmp_blockdev_snapshot_internal_sync(device, name, &err);
+ hmp_handle_error(mon, &err);
+}
+
+void hmp_snapshot_delete_blkdev_internal(Monitor *mon, const QDict *qdict)
+{
+ const char *device = qdict_get_str(qdict, "device");
+ const char *name = qdict_get_str(qdict, "name");
+ const char *id = qdict_get_try_str(qdict, "id");
+ Error *err = NULL;
+
+ qmp_blockdev_snapshot_delete_internal_sync(device, !!id, id,
+ true, name, &err);
+ hmp_handle_error(mon, &err);
+}
diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
index 326276cced..2acdcd6e1e 100644
--- a/monitor/hmp-cmds.c
+++ b/monitor/hmp-cmds.c
@@ -1338,52 +1338,6 @@ void hmp_block_resize(Monitor *mon, const QDict *qdict)
hmp_handle_error(mon, &err);
}
-void hmp_snapshot_blkdev(Monitor *mon, const QDict *qdict)
-{
- const char *device = qdict_get_str(qdict, "device");
- const char *filename = qdict_get_try_str(qdict, "snapshot-file");
- const char *format = qdict_get_try_str(qdict, "format");
- bool reuse = qdict_get_try_bool(qdict, "reuse", false);
- enum NewImageMode mode;
- Error *err = NULL;
-
- if (!filename) {
- /* In the future, if 'snapshot-file' is not specified, the snapshot
- will be taken internally. Today it's actually required. */
- error_setg(&err, QERR_MISSING_PARAMETER, "snapshot-file");
- hmp_handle_error(mon, &err);
- return;
- }
-
- mode = reuse ? NEW_IMAGE_MODE_EXISTING : NEW_IMAGE_MODE_ABSOLUTE_PATHS;
- qmp_blockdev_snapshot_sync(true, device, false, NULL,
- filename, false, NULL,
- !!format, format,
- true, mode, &err);
- hmp_handle_error(mon, &err);
-}
-
-void hmp_snapshot_blkdev_internal(Monitor *mon, const QDict *qdict)
-{
- const char *device = qdict_get_str(qdict, "device");
- const char *name = qdict_get_str(qdict, "name");
- Error *err = NULL;
-
- qmp_blockdev_snapshot_internal_sync(device, name, &err);
- hmp_handle_error(mon, &err);
-}
-
-void hmp_snapshot_delete_blkdev_internal(Monitor *mon, const QDict *qdict)
-{
- const char *device = qdict_get_str(qdict, "device");
- const char *name = qdict_get_str(qdict, "name");
- const char *id = qdict_get_try_str(qdict, "id");
- Error *err = NULL;
-
- qmp_blockdev_snapshot_delete_internal_sync(device, !!id, id,
- true, name, &err);
- hmp_handle_error(mon, &err);
-}
void hmp_loadvm(Monitor *mon, const QDict *qdict)
{
--
2.17.2
- [PATCH 3/9] monitor: move hmp_drive_del and hmp_commit to blockdev-hmp-cmds.c, (continued)
- [PATCH 3/9] monitor: move hmp_drive_del and hmp_commit to blockdev-hmp-cmds.c, Maxim Levitsky, 2019/11/20
- [PATCH 2/9] monitor: rename device-hotplug.c to blockdev-hmp-cmds.c, Maxim Levitsky, 2019/11/20
- [PATCH 5/9] monitor: move hmp_block_job* to blockdev-hmp-cmd.c, Maxim Levitsky, 2019/11/20
- [PATCH 4/9] monitor: move hmp_drive_mirror and hmp_drive_backup to blockdev-hmp-cmds.c, Maxim Levitsky, 2019/11/20
- [PATCH 8/9] monitor: move hmp_info_block* to blockdev-hmp-cmds.c, Maxim Levitsky, 2019/11/20
- [PATCH 6/9] monitor: move hmp_snapshot_* to blockdev-hmp-cmds.c,
Maxim Levitsky <=
- [PATCH 7/9] monitor: move remaining hmp_block* functions to blockdev-hmp-cmds.c, Maxim Levitsky, 2019/11/20
- [PATCH 9/9] monitor/hmp: Prefer to use hmp_handle_error for error reporting in block hmp commands, Maxim Levitsky, 2019/11/20
- Re: [PATCH 0/9] RFC: [for 5.0]: HMP monitor handlers cleanups, Dr. David Alan Gilbert, 2019/11/22