aboutsummaryrefslogtreecommitdiffstats
path: root/block/qcow2-cluster.c
diff options
context:
space:
mode:
authorOt ten Thije <ottenthije@google.com>2010-07-29 10:26:01 +0100
committerOt ten Thije <ottenthije@google.com>2010-07-29 16:16:29 +0100
commit7fd67eba0b961d94a5d6baa8e3c3de37b729f738 (patch)
tree7c73ed8c8452f90b816689b14f691297241659ba /block/qcow2-cluster.c
parent8acd2219729896fea80a363076f31e64c0b54e12 (diff)
downloadexternal_qemu-7fd67eba0b961d94a5d6baa8e3c3de37b729f738.zip
external_qemu-7fd67eba0b961d94a5d6baa8e3c3de37b729f738.tar.gz
external_qemu-7fd67eba0b961d94a5d6baa8e3c3de37b729f738.tar.bz2
Fixed rudimentary suspend/resume.
This patch replaces the failing asynchronous I/O code in the qcow2 driver with a working synchronous implementation and fixes another minor bug in iteration over QField structs. As a result, the VM can now be suspended and resumed with the savevm and loadvm commands, albeit with the following (major) caveats: 1. The ADBd and other network services do not resume correctly. 2. Normal SD card usage is blocked, since snapshots are written to a qcow2 image that must (for now) be mounted on hda. 3. Resume only works after the emulator is fully booted. It is not (yet) possible to load an image immediately after the machine started. The synchronous I/O code is ported from commit ef845c3b in mainline QEMU, which addresses a similar issue. Further upstream mainline also introduces a fix for the async I/O, but that patch is quite involved, and for now this relatively simple fix works. Change-Id: I660c19c22316aecdd7dcae357e66da20e0ab6d80
Diffstat (limited to 'block/qcow2-cluster.c')
-rw-r--r--block/qcow2-cluster.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c
index d349655..fdedf17 100644
--- a/block/qcow2-cluster.c
+++ b/block/qcow2-cluster.c
@@ -306,8 +306,8 @@ void qcow2_encrypt_sectors(BDRVQcowState *s, int64_t sector_num,
}
-static int qcow_read(BlockDriverState *bs, int64_t sector_num,
- uint8_t *buf, int nb_sectors)
+int qcow2_read(BlockDriverState *bs, int64_t sector_num, uint8_t *buf,
+ int nb_sectors)
{
BDRVQcowState *s = bs->opaque;
int ret, index_in_cluster, n, n1;
@@ -358,7 +358,7 @@ static int copy_sectors(BlockDriverState *bs, uint64_t start_sect,
n = n_end - n_start;
if (n <= 0)
return 0;
- ret = qcow_read(bs, start_sect + n_start, s->cluster_data, n);
+ ret = qcow2_read(bs, start_sect + n_start, s->cluster_data, n);
if (ret < 0)
return ret;
if (s->crypt_method) {
@@ -732,6 +732,12 @@ uint64_t qcow2_alloc_cluster_offset(BlockDriverState *bs,
}
nb_clusters = i;
+ if (!nb_clusters) {
+ abort();
+ }
+
+ QLIST_INSERT_HEAD(&s->cluster_allocs, m, next_in_flight);
+
/* allocate a new cluster */
cluster_offset = qcow2_alloc_clusters(bs, nb_clusters * s->cluster_size);