mirror of https://github.com/xemu-project/xemu.git
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
This commit is contained in:
parent
65cf200a51
commit
67bdabe2af
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue