mirror of https://github.com/xemu-project/xemu.git
migration: remove the QEMUFileOps 'shut_down' callback
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> Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
This commit is contained in:
parent
0f58c3fcc7
commit
d3c581b750
|
@ -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,
|
static int channel_set_blocking(void *opaque,
|
||||||
bool enabled,
|
bool enabled,
|
||||||
Error **errp)
|
Error **errp)
|
||||||
|
@ -166,7 +141,6 @@ static QEMUFile *channel_get_output_return_path(void *opaque)
|
||||||
static const QEMUFileOps channel_input_ops = {
|
static const QEMUFileOps channel_input_ops = {
|
||||||
.get_buffer = channel_get_buffer,
|
.get_buffer = channel_get_buffer,
|
||||||
.close = channel_close,
|
.close = channel_close,
|
||||||
.shut_down = channel_shutdown,
|
|
||||||
.set_blocking = channel_set_blocking,
|
.set_blocking = channel_set_blocking,
|
||||||
.get_return_path = channel_get_input_return_path,
|
.get_return_path = channel_get_input_return_path,
|
||||||
};
|
};
|
||||||
|
@ -175,7 +149,6 @@ static const QEMUFileOps channel_input_ops = {
|
||||||
static const QEMUFileOps channel_output_ops = {
|
static const QEMUFileOps channel_output_ops = {
|
||||||
.writev_buffer = channel_writev_buffer,
|
.writev_buffer = channel_writev_buffer,
|
||||||
.close = channel_close,
|
.close = channel_close,
|
||||||
.shut_down = channel_shutdown,
|
|
||||||
.set_blocking = channel_set_blocking,
|
.set_blocking = channel_set_blocking,
|
||||||
.get_return_path = channel_get_output_return_path,
|
.get_return_path = channel_get_output_return_path,
|
||||||
};
|
};
|
||||||
|
|
|
@ -71,16 +71,23 @@ struct QEMUFile {
|
||||||
/*
|
/*
|
||||||
* Stop a file from being read/written - not all backing files can do this
|
* Stop a file from being read/written - not all backing files can do this
|
||||||
* typically only sockets can.
|
* 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 qemu_file_shutdown(QEMUFile *f)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret = 0;
|
||||||
|
|
||||||
f->shutdown = true;
|
f->shutdown = true;
|
||||||
if (!f->ops->shut_down) {
|
if (!qio_channel_has_feature(f->ioc,
|
||||||
|
QIO_CHANNEL_FEATURE_SHUTDOWN)) {
|
||||||
return -ENOSYS;
|
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) {
|
if (!f->last_error) {
|
||||||
qemu_file_set_error(f, -EIO);
|
qemu_file_set_error(f, -EIO);
|
||||||
|
|
|
@ -89,22 +89,12 @@ typedef size_t (QEMURamSaveFunc)(QEMUFile *f,
|
||||||
*/
|
*/
|
||||||
typedef QEMUFile *(QEMURetPathFunc)(void *opaque);
|
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 {
|
typedef struct QEMUFileOps {
|
||||||
QEMUFileGetBufferFunc *get_buffer;
|
QEMUFileGetBufferFunc *get_buffer;
|
||||||
QEMUFileCloseFunc *close;
|
QEMUFileCloseFunc *close;
|
||||||
QEMUFileSetBlocking *set_blocking;
|
QEMUFileSetBlocking *set_blocking;
|
||||||
QEMUFileWritevBufferFunc *writev_buffer;
|
QEMUFileWritevBufferFunc *writev_buffer;
|
||||||
QEMURetPathFunc *get_return_path;
|
QEMURetPathFunc *get_return_path;
|
||||||
QEMUFileShutdownFunc *shut_down;
|
|
||||||
} QEMUFileOps;
|
} QEMUFileOps;
|
||||||
|
|
||||||
typedef struct QEMUFileHooks {
|
typedef struct QEMUFileHooks {
|
||||||
|
|
Loading…
Reference in New Issue