Hi
On Wed, Jun 15, 2022 at 6:57 PM Steve Sistare <steven.sistare@oracle.com>
wrote:
> 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>
>
(ok, I get why you keep the mode_t in fopen)
Reviewed-by: Marc-André Lureau <marcandre.lureau@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
>
>
>
--
Marc-André Lureau