[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH V8 03/39] migration: simplify savevm
From: |
Steve Sistare |
Subject: |
[PATCH V8 03/39] migration: simplify savevm |
Date: |
Wed, 15 Jun 2022 07:51:50 -0700 |
Use qemu_file_open to simplify a few functions in savevm.c.
No functional change.
Signed-off-by: Steve Sistare <steven.sistare@oracle.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
---
migration/savevm.c | 20 ++++++--------------
1 file changed, 6 insertions(+), 14 deletions(-)
diff --git a/migration/savevm.c b/migration/savevm.c
index d907689..0b2c5cd 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -2931,7 +2931,6 @@ void qmp_xen_save_devices_state(const char *filename,
bool has_live, bool live,
Error **errp)
{
QEMUFile *f;
- QIOChannelFile *ioc;
int saved_vm_running;
int ret;
@@ -2945,14 +2944,11 @@ void qmp_xen_save_devices_state(const char *filename,
bool has_live, bool live,
vm_stop(RUN_STATE_SAVE_VM);
global_state_store_running();
- ioc = qio_channel_file_new_path(filename, O_WRONLY | O_CREAT | O_TRUNC,
- 0660, errp);
- if (!ioc) {
+ f = qemu_fopen_file(filename, O_WRONLY | O_CREAT | O_TRUNC, 0660,
+ "migration-xen-save-state", errp);
+ if (!f) {
goto the_end;
}
- qio_channel_set_name(QIO_CHANNEL(ioc), "migration-xen-save-state");
- f = qemu_fopen_channel_output(QIO_CHANNEL(ioc));
- object_unref(OBJECT(ioc));
ret = qemu_save_device_state(f);
if (ret < 0 || qemu_fclose(f) < 0) {
error_setg(errp, QERR_IO_ERROR);
@@ -2981,7 +2977,6 @@ void qmp_xen_save_devices_state(const char *filename,
bool has_live, bool live,
void qmp_xen_load_devices_state(const char *filename, Error **errp)
{
QEMUFile *f;
- QIOChannelFile *ioc;
int ret;
/* Guest must be paused before loading the device state; the RAM state
@@ -2993,14 +2988,11 @@ void qmp_xen_load_devices_state(const char *filename,
Error **errp)
}
vm_stop(RUN_STATE_RESTORE_VM);
- ioc = qio_channel_file_new_path(filename, O_RDONLY | O_BINARY, 0, errp);
- if (!ioc) {
+ f = qemu_fopen_file(filename, O_RDONLY | O_BINARY, 0,
+ "migration-xen-load-state", errp);
+ if (!f) {
return;
}
- qio_channel_set_name(QIO_CHANNEL(ioc), "migration-xen-load-state");
- f = qemu_fopen_channel_input(QIO_CHANNEL(ioc));
- object_unref(OBJECT(ioc));
-
ret = qemu_loadvm_state(f);
qemu_fclose(f);
if (ret < 0) {
--
1.8.3.1
- [PATCH V8 00/39] Live Update, Steve Sistare, 2022/06/15
- [PATCH V8 03/39] migration: simplify savevm,
Steve Sistare <=
- [PATCH V8 06/39] cpr: reboot mode, Steve Sistare, 2022/06/15
- [PATCH V8 02/39] migration: qemu file wrappers, Steve Sistare, 2022/06/15
- [PATCH V8 08/39] cpr: blockers, Steve Sistare, 2022/06/15
- [PATCH V8 10/39] cpr: cpr-enable option, Steve Sistare, 2022/06/15
- [PATCH V8 12/39] memory: flat section iterator, Steve Sistare, 2022/06/15