[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH V7 04/29] migration: simplify savevm
From: |
Steve Sistare |
Subject: |
[PATCH V7 04/29] migration: simplify savevm |
Date: |
Wed, 22 Dec 2021 11:05:09 -0800 |
Use qemu_file_open to simplify a few functions in savevm.c.
No functional change.
Signed-off-by: Steve Sistare <steven.sistare@oracle.com>
---
migration/savevm.c | 21 +++++++--------------
1 file changed, 7 insertions(+), 14 deletions(-)
diff --git a/migration/savevm.c b/migration/savevm.c
index 0bef031..c71d525 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -2910,8 +2910,9 @@ bool save_snapshot(const char *name, bool overwrite,
const char *vmstate,
void qmp_xen_save_devices_state(const char *filename, bool has_live, bool live,
Error **errp)
{
+ const char *ioc_name = "migration-xen-save-state";
+ int flags = O_WRONLY | O_CREAT | O_TRUNC;
QEMUFile *f;
- QIOChannelFile *ioc;
int saved_vm_running;
int ret;
@@ -2925,14 +2926,10 @@ 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_file_open(filename, flags, 0660, ioc_name, 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);
@@ -2960,8 +2957,8 @@ 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)
{
+ const char *ioc_name = "migration-xen-load-state";
QEMUFile *f;
- QIOChannelFile *ioc;
int ret;
/* Guest must be paused before loading the device state; the RAM state
@@ -2973,14 +2970,10 @@ 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_file_open(filename, O_RDONLY | O_BINARY, 0, ioc_name, 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 V7 00/29] Live Update, Steve Sistare, 2021/12/22
- [PATCH V7 02/29] migration: fix populate_vfio_info, Steve Sistare, 2021/12/22
- [PATCH V7 06/29] cpr: reboot mode, Steve Sistare, 2021/12/22
- [PATCH V7 11/29] qapi: list utility functions, Steve Sistare, 2021/12/22
- [PATCH V7 09/29] oslib: qemu_clear_cloexec, Steve Sistare, 2021/12/22
- [PATCH V7 12/29] vl: helper to request re-exec, Steve Sistare, 2021/12/22
- [PATCH V7 03/29] migration: qemu file wrappers, Steve Sistare, 2021/12/22
- [PATCH V7 07/29] cpr: reboot HMP interfaces, Steve Sistare, 2021/12/22
- [PATCH V7 05/29] vl: start on wakeup request, Steve Sistare, 2021/12/22
- [PATCH V7 01/29] memory: qemu_check_ram_volatile, Steve Sistare, 2021/12/22
- [PATCH V7 04/29] migration: simplify savevm,
Steve Sistare <=
- [PATCH V7 13/29] cpr: preserve extra state, Steve Sistare, 2021/12/22
- [PATCH V7 15/29] cpr: restart HMP interfaces, Steve Sistare, 2021/12/22
- [PATCH V7 17/29] pci: export functions for cpr, Steve Sistare, 2021/12/22
- [PATCH V7 20/29] vfio-pci: cpr part 2 (msi), Steve Sistare, 2021/12/22
- [PATCH V7 19/29] vfio-pci: cpr part 1 (fd and dma), Steve Sistare, 2021/12/22
- [PATCH V7 16/29] hostmem-memfd: cpr for memory-backend-memfd, Steve Sistare, 2021/12/22
- [PATCH V7 14/29] cpr: restart mode, Steve Sistare, 2021/12/22
- [PATCH V7 18/29] vfio-pci: refactor for cpr, Steve Sistare, 2021/12/22