]> xenbits.xensource.com Git - qemu-xen.git/commitdiff
block: Make .bdrv_load_vmstate() vectored
authorKevin Wolf <kwolf@redhat.com>
Thu, 9 Jun 2016 14:50:16 +0000 (16:50 +0200)
committerKevin Wolf <kwolf@redhat.com>
Thu, 16 Jun 2016 13:19:55 +0000 (15:19 +0200)
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>
block/io.c
block/qcow2.c
block/sheepdog.c
include/block/block.h
include/block/block_int.h

index 72d72109a5c8595b9090a766b3324ec9806612e2..aac9b67d94c9ad54abe7633c482031eecee35322 100644 (file)
@@ -1870,14 +1870,29 @@ int bdrv_writev_vmstate(BlockDriverState *bs, QEMUIOVector *qiov, int64_t pos)
 
 int bdrv_load_vmstate(BlockDriverState *bs, uint8_t *buf,
                       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;
-    if (!drv)
+
+    if (!drv) {
         return -ENOMEDIUM;
-    if (drv->bdrv_load_vmstate)
-        return drv->bdrv_load_vmstate(bs, buf, pos, size);
-    if (bs->file)
-        return bdrv_load_vmstate(bs->file->bs, buf, pos, size);
+    } else if (drv->bdrv_load_vmstate) {
+        return drv->bdrv_load_vmstate(bs, qiov, pos);
+    } else if (bs->file) {
+        return bdrv_readv_vmstate(bs->file->bs, qiov, pos);
+    }
+
     return -ENOTSUP;
 }
 
index 9de716a524397314af568f21fb3ceca596c6879b..362ada24f92f9c12a1f858c0f17bdfbad81c4a94 100644 (file)
@@ -2926,8 +2926,8 @@ static int qcow2_save_vmstate(BlockDriverState *bs, QEMUIOVector *qiov,
     return ret;
 }
 
-static int qcow2_load_vmstate(BlockDriverState *bs, uint8_t *buf,
-                              int64_t pos, int size)
+static int qcow2_load_vmstate(BlockDriverState *bs, QEMUIOVector *qiov,
+                              int64_t pos)
 {
     BDRVQcow2State *s = bs->opaque;
     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);
     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;
 
     return ret;
index 23fbace1f90517705fbcae50a732a018c64fd507..ef5d044ab9502109e71f49e31dda9b1f6d34a6cc 100644 (file)
@@ -2784,12 +2784,19 @@ static int sd_save_vmstate(BlockDriverState *bs, QEMUIOVector *qiov,
     return ret;
 }
 
-static int sd_load_vmstate(BlockDriverState *bs, uint8_t *data,
-                           int64_t pos, int size)
+static int sd_load_vmstate(BlockDriverState *bs, QEMUIOVector *qiov,
+                           int64_t pos)
 {
     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;
 }
 
 
index 9c63d0776549d729ed69a86499ae87053247538b..733a8ec2ec976645b290492becb6a95a11b42281 100644 (file)
@@ -431,6 +431,7 @@ void path_combine(char *dest, int dest_size,
                   const char *base_path,
                   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_save_vmstate(BlockDriverState *bs, const uint8_t *buf,
                       int64_t pos, int size);
index 8a4963c4fe419256144872f5fa176fbec19792d5..f9a32cc5c519130756cf3dfcd9399020735c4f31 100644 (file)
@@ -226,8 +226,8 @@ struct BlockDriver {
 
     int (*bdrv_save_vmstate)(BlockDriverState *bs, QEMUIOVector *qiov,
                              int64_t pos);
-    int (*bdrv_load_vmstate)(BlockDriverState *bs, uint8_t *buf,
-                             int64_t pos, int size);
+    int (*bdrv_load_vmstate)(BlockDriverState *bs, QEMUIOVector *qiov,
+                             int64_t pos);
 
     int (*bdrv_change_backing_file)(BlockDriverState *bs,
         const char *backing_file, const char *backing_fmt);