|
|
ddf19c |
From d84814e298e3b05fb5bc61cc8e641a5e104d32d5 Mon Sep 17 00:00:00 2001
|
|
|
ddf19c |
From: Juan Quintela <quintela@redhat.com>
|
|
|
ddf19c |
Date: Tue, 3 Mar 2020 14:51:39 +0000
|
|
|
ddf19c |
Subject: [PATCH 07/18] qemu-file: Don't do IO after shutdown
|
|
|
ddf19c |
|
|
|
ddf19c |
RH-Author: Juan Quintela <quintela@redhat.com>
|
|
|
ddf19c |
Message-id: <20200303145143.149290-7-quintela@redhat.com>
|
|
|
ddf19c |
Patchwork-id: 94116
|
|
|
ddf19c |
O-Subject: [RHEL-AV-8.2.0 qemu-kvm PATCH v2 06/10] qemu-file: Don't do IO after shutdown
|
|
|
ddf19c |
Bugzilla: 1738451
|
|
|
ddf19c |
RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
|
|
|
ddf19c |
RH-Acked-by: Peter Xu <peterx@redhat.com>
|
|
|
ddf19c |
RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
|
|
|
ddf19c |
|
|
|
ddf19c |
Be sure that we are not doing neither read/write after shutdown of the
|
|
|
ddf19c |
QEMUFile.
|
|
|
ddf19c |
|
|
|
ddf19c |
Signed-off-by: Juan Quintela <quintela@redhat.com>
|
|
|
ddf19c |
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
|
|
|
ddf19c |
(cherry picked from commit a555b8092abc6f1bbe4b64c516679cbd68fcfbd8)
|
|
|
ddf19c |
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
|
|
|
ddf19c |
---
|
|
|
ddf19c |
migration/qemu-file.c | 22 +++++++++++++++++++++-
|
|
|
ddf19c |
1 file changed, 21 insertions(+), 1 deletion(-)
|
|
|
ddf19c |
|
|
|
ddf19c |
diff --git a/migration/qemu-file.c b/migration/qemu-file.c
|
|
|
ddf19c |
index 26fb25d..bbb2b63 100644
|
|
|
ddf19c |
--- a/migration/qemu-file.c
|
|
|
ddf19c |
+++ b/migration/qemu-file.c
|
|
|
ddf19c |
@@ -53,6 +53,8 @@ struct QEMUFile {
|
|
|
ddf19c |
|
|
|
ddf19c |
int last_error;
|
|
|
ddf19c |
Error *last_error_obj;
|
|
|
ddf19c |
+ /* has the file has been shutdown */
|
|
|
ddf19c |
+ bool shutdown;
|
|
|
ddf19c |
};
|
|
|
ddf19c |
|
|
|
ddf19c |
/*
|
|
|
ddf19c |
@@ -61,10 +63,18 @@ struct QEMUFile {
|
|
|
ddf19c |
*/
|
|
|
ddf19c |
int qemu_file_shutdown(QEMUFile *f)
|
|
|
ddf19c |
{
|
|
|
ddf19c |
+ int ret;
|
|
|
ddf19c |
+
|
|
|
ddf19c |
+ f->shutdown = true;
|
|
|
ddf19c |
if (!f->ops->shut_down) {
|
|
|
ddf19c |
return -ENOSYS;
|
|
|
ddf19c |
}
|
|
|
ddf19c |
- return f->ops->shut_down(f->opaque, true, true, NULL);
|
|
|
ddf19c |
+ ret = f->ops->shut_down(f->opaque, true, true, NULL);
|
|
|
ddf19c |
+
|
|
|
ddf19c |
+ if (!f->last_error) {
|
|
|
ddf19c |
+ qemu_file_set_error(f, -EIO);
|
|
|
ddf19c |
+ }
|
|
|
ddf19c |
+ return ret;
|
|
|
ddf19c |
}
|
|
|
ddf19c |
|
|
|
ddf19c |
/*
|
|
|
ddf19c |
@@ -214,6 +224,9 @@ void qemu_fflush(QEMUFile *f)
|
|
|
ddf19c |
return;
|
|
|
ddf19c |
}
|
|
|
ddf19c |
|
|
|
ddf19c |
+ if (f->shutdown) {
|
|
|
ddf19c |
+ return;
|
|
|
ddf19c |
+ }
|
|
|
ddf19c |
if (f->iovcnt > 0) {
|
|
|
ddf19c |
expect = iov_size(f->iov, f->iovcnt);
|
|
|
ddf19c |
ret = f->ops->writev_buffer(f->opaque, f->iov, f->iovcnt, f->pos,
|
|
|
ddf19c |
@@ -328,6 +341,10 @@ static ssize_t qemu_fill_buffer(QEMUFile *f)
|
|
|
ddf19c |
f->buf_index = 0;
|
|
|
ddf19c |
f->buf_size = pending;
|
|
|
ddf19c |
|
|
|
ddf19c |
+ if (f->shutdown) {
|
|
|
ddf19c |
+ return 0;
|
|
|
ddf19c |
+ }
|
|
|
ddf19c |
+
|
|
|
ddf19c |
len = f->ops->get_buffer(f->opaque, f->buf + pending, f->pos,
|
|
|
ddf19c |
IO_BUF_SIZE - pending, &local_error);
|
|
|
ddf19c |
if (len > 0) {
|
|
|
ddf19c |
@@ -642,6 +659,9 @@ int64_t qemu_ftell(QEMUFile *f)
|
|
|
ddf19c |
|
|
|
ddf19c |
int qemu_file_rate_limit(QEMUFile *f)
|
|
|
ddf19c |
{
|
|
|
ddf19c |
+ if (f->shutdown) {
|
|
|
ddf19c |
+ return 1;
|
|
|
ddf19c |
+ }
|
|
|
ddf19c |
if (qemu_file_get_error(f)) {
|
|
|
ddf19c |
return 1;
|
|
|
ddf19c |
}
|
|
|
ddf19c |
--
|
|
|
ddf19c |
1.8.3.1
|
|
|
ddf19c |
|