* [Qemu-devel] [PATCH] qcow1: Fix compressed images
@ 2009-01-08 10:22 Kevin Wolf
2009-01-08 19:29 ` Anthony Liguori
0 siblings, 1 reply; 2+ messages in thread
From: Kevin Wolf @ 2009-01-08 10:22 UTC (permalink / raw)
To: qemu-devel
[-- Attachment #1: Type: text/plain, Size: 236 bytes --]
Revert r4673, the removed dead code wasn't dead in fact.
Additionally, change the misleading else which tricks the reader into
believing that allocate is a boolean to else if (allocate == 2).
Signed-off-by: Kevin Wolf <kwolf@suse.de>
[-- Attachment #2: fix-compressed-qcow1.patch --]
[-- Type: text/x-patch, Size: 3018 bytes --]
Index: qemu-svn/block-qcow.c
===================================================================
--- qemu-svn.orig/block-qcow.c
+++ qemu-svn/block-qcow.c
@@ -339,28 +339,33 @@ static uint64_t get_cluster_offset(Block
return -1;
} else {
cluster_offset = bdrv_getlength(s->hd);
- /* round to cluster size */
- cluster_offset = (cluster_offset + s->cluster_size - 1) &
- ~(s->cluster_size - 1);
- bdrv_truncate(s->hd, cluster_offset + s->cluster_size);
- /* if encrypted, we must initialize the cluster
- content which won't be written */
- if (s->crypt_method &&
- (n_end - n_start) < s->cluster_sectors) {
- uint64_t start_sect;
- start_sect = (offset & ~(s->cluster_size - 1)) >> 9;
- memset(s->cluster_data + 512, 0x00, 512);
- for(i = 0; i < s->cluster_sectors; i++) {
- if (i < n_start || i >= n_end) {
- encrypt_sectors(s, start_sect + i,
- s->cluster_data,
- s->cluster_data + 512, 1, 1,
- &s->aes_encrypt_key);
- if (bdrv_pwrite(s->hd, cluster_offset + i * 512,
- s->cluster_data, 512) != 512)
- return -1;
+ if (allocate == 1) {
+ /* round to cluster size */
+ cluster_offset = (cluster_offset + s->cluster_size - 1) &
+ ~(s->cluster_size - 1);
+ bdrv_truncate(s->hd, cluster_offset + s->cluster_size);
+ /* if encrypted, we must initialize the cluster
+ content which won't be written */
+ if (s->crypt_method &&
+ (n_end - n_start) < s->cluster_sectors) {
+ uint64_t start_sect;
+ start_sect = (offset & ~(s->cluster_size - 1)) >> 9;
+ memset(s->cluster_data + 512, 0x00, 512);
+ for(i = 0; i < s->cluster_sectors; i++) {
+ if (i < n_start || i >= n_end) {
+ encrypt_sectors(s, start_sect + i,
+ s->cluster_data,
+ s->cluster_data + 512, 1, 1,
+ &s->aes_encrypt_key);
+ if (bdrv_pwrite(s->hd, cluster_offset + i * 512,
+ s->cluster_data, 512) != 512)
+ return -1;
+ }
}
}
+ } else if (allocate == 2) {
+ cluster_offset |= QCOW_OFLAG_COMPRESSED |
+ (uint64_t)compressed_size << (63 - s->cluster_bits);
}
}
/* update L2 table */
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [Qemu-devel] [PATCH] qcow1: Fix compressed images
2009-01-08 10:22 [Qemu-devel] [PATCH] qcow1: Fix compressed images Kevin Wolf
@ 2009-01-08 19:29 ` Anthony Liguori
0 siblings, 0 replies; 2+ messages in thread
From: Anthony Liguori @ 2009-01-08 19:29 UTC (permalink / raw)
To: qemu-devel
Kevin Wolf wrote:
> Revert r4673, the removed dead code wasn't dead in fact.
>
> Additionally, change the misleading else which tricks the reader into
> believing that allocate is a boolean to else if (allocate == 2).
>
> Signed-off-by: Kevin Wolf <kwolf@suse.de>
>
Applied. Thanks.
Regards,
Anthony Liguori
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-01-08 19:29 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-08 10:22 [Qemu-devel] [PATCH] qcow1: Fix compressed images Kevin Wolf
2009-01-08 19:29 ` Anthony Liguori
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).