[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH V2 22/22] simplify savevm
From: |
Steve Sistare |
Subject: |
[PATCH V2 22/22] simplify savevm |
Date: |
Tue, 5 Jan 2021 07:42:10 -0800 |
Use qf_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 | 19 ++++++-------------
1 file changed, 6 insertions(+), 13 deletions(-)
diff --git a/migration/savevm.c b/migration/savevm.c
index a843d20..994ad1a 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -2788,8 +2788,8 @@ int save_snapshot(const char *name, Error **errp)
void qmp_xen_save_devices_state(const char *filename, bool has_live, bool live,
Error **errp)
{
+ const char *ioc_name = "migration-xen-save-state";
QEMUFile *f;
- QIOChannelFile *ioc;
int saved_vm_running;
int ret;
@@ -2803,13 +2803,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, 0660, errp);
- if (!ioc) {
+ f = qf_file_open(filename, O_WRONLY | O_CREAT, 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);
@@ -2837,8 +2834,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
@@ -2850,14 +2847,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 = qf_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
- Re: [PATCH V2 05/22] vl: memfd-alloc option, (continued)
[PATCH V2 12/22] vfio-pci: cpr, Steve Sistare, 2021/01/05
[PATCH V2 16/22] chardev: cpr for pty, Steve Sistare, 2021/01/05
[PATCH V2 18/22] chardev: cpr for sockets, Steve Sistare, 2021/01/05
[PATCH V2 19/22] monitor: cpr support, Steve Sistare, 2021/01/05
[PATCH V2 17/22] chardev: socket accept subroutine, Steve Sistare, 2021/01/05
[PATCH V2 20/22] cpr: only-cpr-capable option, Steve Sistare, 2021/01/05
[PATCH V2 22/22] simplify savevm,
Steve Sistare <=
[PATCH V2 14/22] chardev: cpr framework, Steve Sistare, 2021/01/05
[PATCH V2 21/22] cpr: maintainers, Steve Sistare, 2021/01/05
[PATCH V2 02/22] qemu_ram_volatile, Steve Sistare, 2021/01/05
[PATCH V2 13/22] vhost: reset vhost devices upon cprsave, Steve Sistare, 2021/01/05
[PATCH V2 01/22] as_flat_walk, Steve Sistare, 2021/01/05
[PATCH V2 11/22] vfio-pci: refactor for cpr, Steve Sistare, 2021/01/05
[PATCH V2 15/22] chardev: cpr for simple devices, Steve Sistare, 2021/01/05