@@ -550,6 +550,9 @@ retry:
size,
(s->free_cluster_index - nb_clusters) << s->cluster_bits);
#endif
+ if (s->highest_alloc < s->free_cluster_index) {
+ s->highest_alloc = s->free_cluster_index;
+ }
return (s->free_cluster_index - nb_clusters) << s->cluster_bits;
}
@@ -230,6 +230,8 @@ static int qcow_open(BlockDriverState *bs, const char *filename, int flags)
if (qcow_read_extensions(bs, sizeof(header), ext_end))
goto fail;
+ s->highest_alloc = 0;
+
/* read the backing file name */
if (header.backing_file_offset != 0) {
len = header.backing_file_size;
@@ -112,6 +112,9 @@ typedef struct BDRVQcowState {
uint32_t crypt_method_header;
AES_KEY aes_encrypt_key;
AES_KEY aes_decrypt_key;
+
+ int64_t highest_alloc; /* highest cluester allocated (in clusters) */
+
uint64_t snapshots_offset;
int snapshots_size;
int nb_snapshots;