[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 19/25] migration: remove the QEMUFileOps 'shut_down' callback
From: |
Juan Quintela |
Subject: |
[PULL 19/25] migration: remove the QEMUFileOps 'shut_down' callback |
Date: |
Wed, 22 Jun 2022 02:25:41 +0200 |
From: Daniel P. Berrangé <berrange@redhat.com>
This directly implements the shutdown logic using QIOChannel APIs.
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
migration/qemu-file.h | 10 ----------
migration/qemu-file-channel.c | 27 ---------------------------
migration/qemu-file.c | 13 ++++++++++---
3 files changed, 10 insertions(+), 40 deletions(-)
diff --git a/migration/qemu-file.h b/migration/qemu-file.h
index fe1b2d1c00..9fa92c1998 100644
--- a/migration/qemu-file.h
+++ b/migration/qemu-file.h
@@ -89,22 +89,12 @@ typedef size_t (QEMURamSaveFunc)(QEMUFile *f,
*/
typedef QEMUFile *(QEMURetPathFunc)(void *opaque);
-/*
- * Stop any read or write (depending on flags) on the underlying
- * transport on the QEMUFile.
- * Existing blocking reads/writes must be woken
- * Returns 0 on success, -err on error
- */
-typedef int (QEMUFileShutdownFunc)(void *opaque, bool rd, bool wr,
- Error **errp);
-
typedef struct QEMUFileOps {
QEMUFileGetBufferFunc *get_buffer;
QEMUFileCloseFunc *close;
QEMUFileSetBlocking *set_blocking;
QEMUFileWritevBufferFunc *writev_buffer;
QEMURetPathFunc *get_return_path;
- QEMUFileShutdownFunc *shut_down;
} QEMUFileOps;
typedef struct QEMUFileHooks {
diff --git a/migration/qemu-file-channel.c b/migration/qemu-file-channel.c
index 5cb8ac93c0..80f05dc371 100644
--- a/migration/qemu-file-channel.c
+++ b/migration/qemu-file-channel.c
@@ -112,31 +112,6 @@ static int channel_close(void *opaque, Error **errp)
}
-static int channel_shutdown(void *opaque,
- bool rd,
- bool wr,
- Error **errp)
-{
- QIOChannel *ioc = QIO_CHANNEL(opaque);
-
- if (qio_channel_has_feature(ioc,
- QIO_CHANNEL_FEATURE_SHUTDOWN)) {
- QIOChannelShutdown mode;
- if (rd && wr) {
- mode = QIO_CHANNEL_SHUTDOWN_BOTH;
- } else if (rd) {
- mode = QIO_CHANNEL_SHUTDOWN_READ;
- } else {
- mode = QIO_CHANNEL_SHUTDOWN_WRITE;
- }
- if (qio_channel_shutdown(ioc, mode, errp) < 0) {
- return -EIO;
- }
- }
- return 0;
-}
-
-
static int channel_set_blocking(void *opaque,
bool enabled,
Error **errp)
@@ -166,7 +141,6 @@ static QEMUFile *channel_get_output_return_path(void
*opaque)
static const QEMUFileOps channel_input_ops = {
.get_buffer = channel_get_buffer,
.close = channel_close,
- .shut_down = channel_shutdown,
.set_blocking = channel_set_blocking,
.get_return_path = channel_get_input_return_path,
};
@@ -175,7 +149,6 @@ static const QEMUFileOps channel_input_ops = {
static const QEMUFileOps channel_output_ops = {
.writev_buffer = channel_writev_buffer,
.close = channel_close,
- .shut_down = channel_shutdown,
.set_blocking = channel_set_blocking,
.get_return_path = channel_get_output_return_path,
};
diff --git a/migration/qemu-file.c b/migration/qemu-file.c
index c181686e41..6e79de1404 100644
--- a/migration/qemu-file.c
+++ b/migration/qemu-file.c
@@ -71,16 +71,23 @@ struct QEMUFile {
/*
* Stop a file from being read/written - not all backing files can do this
* typically only sockets can.
+ *
+ * TODO: convert to propagate Error objects instead of squashing
+ * to a fixed errno value
*/
int qemu_file_shutdown(QEMUFile *f)
{
- int ret;
+ int ret = 0;
f->shutdown = true;
- if (!f->ops->shut_down) {
+ if (!qio_channel_has_feature(f->ioc,
+ QIO_CHANNEL_FEATURE_SHUTDOWN)) {
return -ENOSYS;
}
- ret = f->ops->shut_down(f->ioc, true, true, NULL);
+
+ if (qio_channel_shutdown(f->ioc, QIO_CHANNEL_SHUTDOWN_BOTH, NULL) < 0) {
+ ret = -EIO;
+ }
if (!f->last_error) {
qemu_file_set_error(f, -EIO);
--
2.35.3
- [PULL 11/25] migration: rename qemu_update_position to qemu_file_credit_transfer, (continued)
- [PULL 11/25] migration: rename qemu_update_position to qemu_file_credit_transfer, Juan Quintela, 2022/06/21
- [PULL 12/25] migration: rename qemu_file_update_transfer to qemu_file_acct_rate_limit, Juan Quintela, 2022/06/21
- [PULL 14/25] migration: convert savevm to use QIOChannelBlock for VMState, Juan Quintela, 2022/06/21
- [PULL 08/25] migration: rename rate limiting fields in QEMUFile, Juan Quintela, 2022/06/21
- [PULL 10/25] migration: rename qemu_ftell to qemu_file_total_transferred, Juan Quintela, 2022/06/21
- [PULL 09/25] migration: rename 'pos' field in QEMUFile to 'bytes_processed', Juan Quintela, 2022/06/21
- [PULL 13/25] migration: introduce a QIOChannel impl for BlockDriverState VMState, Juan Quintela, 2022/06/21
- [PULL 15/25] migration: stop passing 'opaque' parameter to QEMUFile hooks, Juan Quintela, 2022/06/21
- [PULL 16/25] migration: hardcode assumption that QEMUFile is backed with QIOChannel, Juan Quintela, 2022/06/21
- [PULL 18/25] migration: remove unused QEMUFileGetFD typedef / qemu_get_fd method, Juan Quintela, 2022/06/21
- [PULL 19/25] migration: remove the QEMUFileOps 'shut_down' callback,
Juan Quintela <=
- [PULL 17/25] migration: introduce new constructors for QEMUFile, Juan Quintela, 2022/06/21
- [PULL 20/25] migration: remove the QEMUFileOps 'set_blocking' callback, Juan Quintela, 2022/06/21
- [PULL 21/25] migration: remove the QEMUFileOps 'close' callback, Juan Quintela, 2022/06/21
- [PULL 22/25] migration: remove the QEMUFileOps 'get_buffer' callback, Juan Quintela, 2022/06/21
- [PULL 23/25] migration: remove the QEMUFileOps 'writev_buffer' callback, Juan Quintela, 2022/06/21
- [PULL 24/25] migration: remove the QEMUFileOps 'get_return_path' callback, Juan Quintela, 2022/06/21
- [PULL 25/25] migration: remove the QEMUFileOps abstraction, Juan Quintela, 2022/06/21
- Re: [PULL 00/25] Migration 20220621 patches, Richard Henderson, 2022/06/21