aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel P. Berrangé <berrange@redhat.com>2022-06-20 12:01:54 +0100
committerDr. David Alan Gilbert <dgilbert@redhat.com>2022-06-22 19:33:43 +0100
commit67bdabe2af52cf5bb9420f57e0f67c9b571e1e5d (patch)
treecc2ee0ef09c5f1b0bcf645ca7d4246f499af0f10
parent65cf200a51ddc6d0a28ecceac30dc892233cddd7 (diff)
downloadqemu-67bdabe2af52cf5bb9420f57e0f67c9b571e1e5d.zip
qemu-67bdabe2af52cf5bb9420f57e0f67c9b571e1e5d.tar.gz
qemu-67bdabe2af52cf5bb9420f57e0f67c9b571e1e5d.tar.bz2
migration: convert savevm to use QIOChannelBlock for VMState
With this change, all QEMUFile usage is backed by QIOChannel at last. 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> dgilbert: Wrap long lines
-rw-r--r--migration/savevm.c44
1 files changed, 6 insertions, 38 deletions
diff --git a/migration/savevm.c b/migration/savevm.c
index 75d05f1..3e96121 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -35,6 +35,7 @@
#include "migration/misc.h"
#include "migration/register.h"
#include "migration/global_state.h"
+#include "migration/channel-block.h"
#include "ram.h"
#include "qemu-file-channel.h"
#include "qemu-file.h"
@@ -130,48 +131,15 @@ static struct mig_cmd_args {
/***********************************************************/
/* savevm/loadvm support */
-static ssize_t block_writev_buffer(void *opaque, struct iovec *iov, int iovcnt,
- int64_t pos, Error **errp)
-{
- int ret;
- QEMUIOVector qiov;
-
- qemu_iovec_init_external(&qiov, iov, iovcnt);
- ret = bdrv_writev_vmstate(opaque, &qiov, pos);
- if (ret < 0) {
- return ret;
- }
-
- return qiov.size;
-}
-
-static ssize_t block_get_buffer(void *opaque, uint8_t *buf, int64_t pos,
- size_t size, Error **errp)
-{
- return bdrv_load_vmstate(opaque, buf, pos, size);
-}
-
-static int bdrv_fclose(void *opaque, Error **errp)
-{
- return bdrv_flush(opaque);
-}
-
-static const QEMUFileOps bdrv_read_ops = {
- .get_buffer = block_get_buffer,
- .close = bdrv_fclose
-};
-
-static const QEMUFileOps bdrv_write_ops = {
- .writev_buffer = block_writev_buffer,
- .close = bdrv_fclose
-};
-
static QEMUFile *qemu_fopen_bdrv(BlockDriverState *bs, int is_writable)
{
if (is_writable) {
- return qemu_fopen_ops(bs, &bdrv_write_ops, false);
+ return qemu_fopen_channel_output(
+ QIO_CHANNEL(qio_channel_block_new(bs)));
+ } else {
+ return qemu_fopen_channel_input(
+ QIO_CHANNEL(qio_channel_block_new(bs)));
}
- return qemu_fopen_ops(bs, &bdrv_read_ops, false);
}