[Qemu-devel] [PATCH] migration/xen: Check return value of qemu_fclose

Ross Lagerwall posted 1 patch 6 years, 2 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20180206163039.23661-1-ross.lagerwall@citrix.com
Test checkpatch passed
Test docker-build@min-glib passed
Test docker-mingw@fedora passed
Test docker-quick@centos6 passed
Test ppc passed
Test s390x passed
migration/savevm.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
[Qemu-devel] [PATCH] migration/xen: Check return value of qemu_fclose
Posted by Ross Lagerwall 6 years, 2 months ago
QEMUFile uses buffered IO so when writing small amounts (such as the Xen
device state file), the actual write call and any errors that may occur
only happen as part of qemu_fclose(). Therefore, report IO errors when
saving the device state under Xen by checking the return value of
qemu_fclose().

Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
---
 migration/savevm.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/migration/savevm.c b/migration/savevm.c
index b7908f6..4b9d5be 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -2267,8 +2267,7 @@ void qmp_xen_save_devices_state(const char *filename, bool has_live, bool live,
     qio_channel_set_name(QIO_CHANNEL(ioc), "migration-xen-save-state");
     f = qemu_fopen_channel_output(QIO_CHANNEL(ioc));
     ret = qemu_save_device_state(f);
-    qemu_fclose(f);
-    if (ret < 0) {
+    if (ret < 0 || qemu_fclose(f) < 0) {
         error_setg(errp, QERR_IO_ERROR);
     } else {
         /* libxl calls the QMP command "stop" before calling
-- 
2.9.5


Re: [Qemu-devel] [PATCH] migration/xen: Check return value of qemu_fclose
Posted by Dr. David Alan Gilbert 6 years, 2 months ago
* Ross Lagerwall (ross.lagerwall@citrix.com) wrote:
> QEMUFile uses buffered IO so when writing small amounts (such as the Xen
> device state file), the actual write call and any errors that may occur
> only happen as part of qemu_fclose(). Therefore, report IO errors when
> saving the device state under Xen by checking the return value of
> qemu_fclose().
> 
> Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>

Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>

> ---
>  migration/savevm.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/migration/savevm.c b/migration/savevm.c
> index b7908f6..4b9d5be 100644
> --- a/migration/savevm.c
> +++ b/migration/savevm.c
> @@ -2267,8 +2267,7 @@ void qmp_xen_save_devices_state(const char *filename, bool has_live, bool live,
>      qio_channel_set_name(QIO_CHANNEL(ioc), "migration-xen-save-state");
>      f = qemu_fopen_channel_output(QIO_CHANNEL(ioc));
>      ret = qemu_save_device_state(f);
> -    qemu_fclose(f);
> -    if (ret < 0) {
> +    if (ret < 0 || qemu_fclose(f) < 0) {
>          error_setg(errp, QERR_IO_ERROR);
>      } else {
>          /* libxl calls the QMP command "stop" before calling
> -- 
> 2.9.5
> 
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK

Re: [Qemu-devel] [PATCH] migration/xen: Check return value of qemu_fclose
Posted by Dr. David Alan Gilbert 6 years, 2 months ago
* Ross Lagerwall (ross.lagerwall@citrix.com) wrote:
> QEMUFile uses buffered IO so when writing small amounts (such as the Xen
> device state file), the actual write call and any errors that may occur
> only happen as part of qemu_fclose(). Therefore, report IO errors when
> saving the device state under Xen by checking the return value of
> qemu_fclose().
> 
> Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>

Queued.

> ---
>  migration/savevm.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/migration/savevm.c b/migration/savevm.c
> index b7908f6..4b9d5be 100644
> --- a/migration/savevm.c
> +++ b/migration/savevm.c
> @@ -2267,8 +2267,7 @@ void qmp_xen_save_devices_state(const char *filename, bool has_live, bool live,
>      qio_channel_set_name(QIO_CHANNEL(ioc), "migration-xen-save-state");
>      f = qemu_fopen_channel_output(QIO_CHANNEL(ioc));
>      ret = qemu_save_device_state(f);
> -    qemu_fclose(f);
> -    if (ret < 0) {
> +    if (ret < 0 || qemu_fclose(f) < 0) {
>          error_setg(errp, QERR_IO_ERROR);
>      } else {
>          /* libxl calls the QMP command "stop" before calling
> -- 
> 2.9.5
> 
> 
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK