Skip to contentSkip to conversation

migration/xen: Check return value of qemu_fclose

PATCH In review Ross Lagerwall 2 participants 3 messages Feb 6, 2018 – Feb 14, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 migration/xen: Check return value of qemu_fclose

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().

---
 migration/savevm.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
migration/savevm.c +1 -2
index b7908f6..4b9d5be 100644
@@ -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
Signature · 1 line
2.9.5
Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · * Ross Lagerwall ([email protected]) 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().

Quoted 21 lines
---
 migration/savevm.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
migration/savevm.c +1 -2
index b7908f6..4b9d5be 100644
@@ -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
Signature · 1 line
2.9.5

--
Dr. David Alan Gilbert / [email protected] / Manchester, UK

#2 lore raw
In reply to Ross Lagerwall
Quoted 7 lines · * Ross Lagerwall ([email protected]) 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().

Queued.

Quoted 22 lines
---
 migration/savevm.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
migration/savevm.c +1 -2
index b7908f6..4b9d5be 100644
@@ -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
Signature · 1 line
2.9.5

--
Dr. David Alan Gilbert / [email protected] / Manchester, UK