mirror of https://github.com/proxmox/mirror_qemu
block: Introduce bdrv_writev_vmstate
Signed-off-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>master
parent
e2ec3f9768
commit
cf8074b382
25
block.c
25
block.c
|
@ -3183,14 +3183,29 @@ int bdrv_get_info(BlockDriverState *bs, BlockDriverInfo *bdi)
|
||||||
|
|
||||||
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)
|
||||||
|
{
|
||||||
|
QEMUIOVector qiov;
|
||||||
|
struct iovec iov = {
|
||||||
|
.iov_base = (void *) buf,
|
||||||
|
.iov_len = size,
|
||||||
|
};
|
||||||
|
|
||||||
|
qemu_iovec_init_external(&qiov, &iov, 1);
|
||||||
|
return bdrv_writev_vmstate(bs, &qiov, pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
int bdrv_writev_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_save_vmstate)
|
} else if (drv->bdrv_save_vmstate) {
|
||||||
return drv->bdrv_save_vmstate(bs, buf, pos, size);
|
return drv->bdrv_save_vmstate(bs, qiov, pos);
|
||||||
if (bs->file)
|
} else if (bs->file) {
|
||||||
return bdrv_save_vmstate(bs->file, buf, pos, size);
|
return bdrv_writev_vmstate(bs->file, qiov, pos);
|
||||||
|
}
|
||||||
|
|
||||||
return -ENOTSUP;
|
return -ENOTSUP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1652,18 +1652,24 @@ static void dump_refcounts(BlockDriverState *bs)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int qcow2_save_vmstate(BlockDriverState *bs, const uint8_t *buf,
|
static int qcow2_save_vmstate(BlockDriverState *bs, QEMUIOVector *qiov,
|
||||||
int64_t pos, int size)
|
int64_t pos)
|
||||||
{
|
{
|
||||||
BDRVQcowState *s = bs->opaque;
|
BDRVQcowState *s = bs->opaque;
|
||||||
int growable = bs->growable;
|
int growable = bs->growable;
|
||||||
int ret;
|
int ret;
|
||||||
|
void *buf;
|
||||||
|
|
||||||
|
buf = qemu_blockalign(bs, qiov->size);
|
||||||
|
qemu_iovec_to_buf(qiov, 0, buf, qiov->size);
|
||||||
|
|
||||||
BLKDBG_EVENT(bs->file, BLKDBG_VMSTATE_SAVE);
|
BLKDBG_EVENT(bs->file, BLKDBG_VMSTATE_SAVE);
|
||||||
bs->growable = 1;
|
bs->growable = 1;
|
||||||
ret = bdrv_pwrite(bs, qcow2_vm_state_offset(s) + pos, buf, size);
|
ret = bdrv_pwrite(bs, qcow2_vm_state_offset(s) + pos, buf, qiov->size);
|
||||||
bs->growable = growable;
|
bs->growable = growable;
|
||||||
|
|
||||||
|
qemu_vfree(buf);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2054,12 +2054,19 @@ cleanup:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int sd_save_vmstate(BlockDriverState *bs, const uint8_t *data,
|
static int sd_save_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, (uint8_t *)data, pos, size, 0);
|
buf = qemu_blockalign(bs, qiov->size);
|
||||||
|
qemu_iovec_to_buf(qiov, 0, buf, qiov->size);
|
||||||
|
ret = do_load_save_vmstate(s, (uint8_t *) buf, pos, qiov->size, 0);
|
||||||
|
qemu_vfree(buf);
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int sd_load_vmstate(BlockDriverState *bs, uint8_t *data,
|
static int sd_load_vmstate(BlockDriverState *bs, uint8_t *data,
|
||||||
|
|
|
@ -348,6 +348,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_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);
|
||||||
|
|
||||||
|
|
|
@ -164,8 +164,8 @@ struct BlockDriver {
|
||||||
const char *snapshot_name);
|
const char *snapshot_name);
|
||||||
int (*bdrv_get_info)(BlockDriverState *bs, BlockDriverInfo *bdi);
|
int (*bdrv_get_info)(BlockDriverState *bs, BlockDriverInfo *bdi);
|
||||||
|
|
||||||
int (*bdrv_save_vmstate)(BlockDriverState *bs, const uint8_t *buf,
|
int (*bdrv_save_vmstate)(BlockDriverState *bs, QEMUIOVector *qiov,
|
||||||
int64_t pos, int size);
|
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);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue