mirror of
https://github.com/qemu/qemu.git
synced 2025-08-01 02:05:48 +00:00
block: Make .bdrv_load_vmstate() vectored
This brings it in line with .bdrv_save_vmstate(). Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Fam Zheng <famz@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
parent
f1e8474115
commit
5ddda0b8f0
25
block/io.c
25
block/io.c
@ -1870,14 +1870,29 @@ int bdrv_writev_vmstate(BlockDriverState *bs, QEMUIOVector *qiov, int64_t pos)
|
|||||||
|
|
||||||
int bdrv_load_vmstate(BlockDriverState *bs, uint8_t *buf,
|
int bdrv_load_vmstate(BlockDriverState *bs, uint8_t *buf,
|
||||||
int64_t pos, int size)
|
int64_t pos, int size)
|
||||||
|
{
|
||||||
|
QEMUIOVector qiov;
|
||||||
|
struct iovec iov = {
|
||||||
|
.iov_base = buf,
|
||||||
|
.iov_len = size,
|
||||||
|
};
|
||||||
|
|
||||||
|
qemu_iovec_init_external(&qiov, &iov, 1);
|
||||||
|
return bdrv_readv_vmstate(bs, &qiov, pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
int bdrv_readv_vmstate(BlockDriverState *bs, QEMUIOVector *qiov, int64_t pos)
|
||||||
{
|
{
|
||||||
BlockDriver *drv = bs->drv;
|
BlockDriver *drv = bs->drv;
|
||||||
if (!drv)
|
|
||||||
|
if (!drv) {
|
||||||
return -ENOMEDIUM;
|
return -ENOMEDIUM;
|
||||||
if (drv->bdrv_load_vmstate)
|
} else if (drv->bdrv_load_vmstate) {
|
||||||
return drv->bdrv_load_vmstate(bs, buf, pos, size);
|
return drv->bdrv_load_vmstate(bs, qiov, pos);
|
||||||
if (bs->file)
|
} else if (bs->file) {
|
||||||
return bdrv_load_vmstate(bs->file->bs, buf, pos, size);
|
return bdrv_readv_vmstate(bs->file->bs, qiov, pos);
|
||||||
|
}
|
||||||
|
|
||||||
return -ENOTSUP;
|
return -ENOTSUP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2926,8 +2926,8 @@ static int qcow2_save_vmstate(BlockDriverState *bs, QEMUIOVector *qiov,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int qcow2_load_vmstate(BlockDriverState *bs, uint8_t *buf,
|
static int qcow2_load_vmstate(BlockDriverState *bs, QEMUIOVector *qiov,
|
||||||
int64_t pos, int size)
|
int64_t pos)
|
||||||
{
|
{
|
||||||
BDRVQcow2State *s = bs->opaque;
|
BDRVQcow2State *s = bs->opaque;
|
||||||
bool zero_beyond_eof = bs->zero_beyond_eof;
|
bool zero_beyond_eof = bs->zero_beyond_eof;
|
||||||
@ -2935,7 +2935,7 @@ static int qcow2_load_vmstate(BlockDriverState *bs, uint8_t *buf,
|
|||||||
|
|
||||||
BLKDBG_EVENT(bs->file, BLKDBG_VMSTATE_LOAD);
|
BLKDBG_EVENT(bs->file, BLKDBG_VMSTATE_LOAD);
|
||||||
bs->zero_beyond_eof = false;
|
bs->zero_beyond_eof = false;
|
||||||
ret = bdrv_pread(bs, qcow2_vm_state_offset(s) + pos, buf, size);
|
ret = bdrv_preadv(bs, qcow2_vm_state_offset(s) + pos, qiov);
|
||||||
bs->zero_beyond_eof = zero_beyond_eof;
|
bs->zero_beyond_eof = zero_beyond_eof;
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -2784,12 +2784,19 @@ static int sd_save_vmstate(BlockDriverState *bs, QEMUIOVector *qiov,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int sd_load_vmstate(BlockDriverState *bs, uint8_t *data,
|
static int sd_load_vmstate(BlockDriverState *bs, QEMUIOVector *qiov,
|
||||||
int64_t pos, int size)
|
int64_t pos)
|
||||||
{
|
{
|
||||||
BDRVSheepdogState *s = bs->opaque;
|
BDRVSheepdogState *s = bs->opaque;
|
||||||
|
void *buf;
|
||||||
|
int ret;
|
||||||
|
|
||||||
return do_load_save_vmstate(s, data, pos, size, 1);
|
buf = qemu_blockalign(bs, qiov->size);
|
||||||
|
ret = do_load_save_vmstate(s, buf, pos, qiov->size, 1);
|
||||||
|
qemu_iovec_from_buf(qiov, 0, buf, qiov->size);
|
||||||
|
qemu_vfree(buf);
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -431,6 +431,7 @@ void path_combine(char *dest, int dest_size,
|
|||||||
const char *base_path,
|
const char *base_path,
|
||||||
const char *filename);
|
const char *filename);
|
||||||
|
|
||||||
|
int bdrv_readv_vmstate(BlockDriverState *bs, QEMUIOVector *qiov, int64_t pos);
|
||||||
int bdrv_writev_vmstate(BlockDriverState *bs, QEMUIOVector *qiov, int64_t pos);
|
int bdrv_writev_vmstate(BlockDriverState *bs, QEMUIOVector *qiov, int64_t pos);
|
||||||
int bdrv_save_vmstate(BlockDriverState *bs, const uint8_t *buf,
|
int bdrv_save_vmstate(BlockDriverState *bs, const uint8_t *buf,
|
||||||
int64_t pos, int size);
|
int64_t pos, int size);
|
||||||
|
@ -226,8 +226,8 @@ struct BlockDriver {
|
|||||||
|
|
||||||
int (*bdrv_save_vmstate)(BlockDriverState *bs, QEMUIOVector *qiov,
|
int (*bdrv_save_vmstate)(BlockDriverState *bs, QEMUIOVector *qiov,
|
||||||
int64_t pos);
|
int64_t pos);
|
||||||
int (*bdrv_load_vmstate)(BlockDriverState *bs, uint8_t *buf,
|
int (*bdrv_load_vmstate)(BlockDriverState *bs, QEMUIOVector *qiov,
|
||||||
int64_t pos, int size);
|
int64_t pos);
|
||||||
|
|
||||||
int (*bdrv_change_backing_file)(BlockDriverState *bs,
|
int (*bdrv_change_backing_file)(BlockDriverState *bs,
|
||||||
const char *backing_file, const char *backing_fmt);
|
const char *backing_file, const char *backing_fmt);
|
||||||
|
Loading…
Reference in New Issue
Block a user