Commit c47c33b098302d2c94db22e76ef5745aab05a7c8
1 parent
e70332b3
block API change
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2088 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
1 changed file
with
15 additions
and
16 deletions
block-qcow.c
... | ... | @@ -350,7 +350,7 @@ static uint64_t get_cluster_offset(BlockDriverState *bs, |
350 | 350 | (n_end - n_start) < s->cluster_sectors) { |
351 | 351 | uint64_t start_sect; |
352 | 352 | start_sect = (offset & ~(s->cluster_size - 1)) >> 9; |
353 | - memset(s->cluster_data + 512, 0xaa, 512); | |
353 | + memset(s->cluster_data + 512, 0x00, 512); | |
354 | 354 | for(i = 0; i < s->cluster_sectors; i++) { |
355 | 355 | if (i < n_start || i >= n_end) { |
356 | 356 | encrypt_sectors(s, start_sect + i, |
... | ... | @@ -813,7 +813,7 @@ static int qcow_create(const char *filename, int64_t total_size, |
813 | 813 | return 0; |
814 | 814 | } |
815 | 815 | |
816 | -int qcow_make_empty(BlockDriverState *bs) | |
816 | +static int qcow_make_empty(BlockDriverState *bs) | |
817 | 817 | { |
818 | 818 | BDRVQcowState *s = bs->opaque; |
819 | 819 | uint32_t l1_length = s->l1_size * sizeof(uint64_t); |
... | ... | @@ -833,18 +833,10 @@ int qcow_make_empty(BlockDriverState *bs) |
833 | 833 | return 0; |
834 | 834 | } |
835 | 835 | |
836 | -int qcow_get_cluster_size(BlockDriverState *bs) | |
837 | -{ | |
838 | - BDRVQcowState *s = bs->opaque; | |
839 | - if (bs->drv != &bdrv_qcow) | |
840 | - return -1; | |
841 | - return s->cluster_size; | |
842 | -} | |
843 | - | |
844 | 836 | /* XXX: put compressed sectors first, then all the cluster aligned |
845 | 837 | tables to avoid losing bytes in alignment */ |
846 | -int qcow_compress_cluster(BlockDriverState *bs, int64_t sector_num, | |
847 | - const uint8_t *buf) | |
838 | +static int qcow_write_compressed(BlockDriverState *bs, int64_t sector_num, | |
839 | + const uint8_t *buf, int nb_sectors) | |
848 | 840 | { |
849 | 841 | BDRVQcowState *s = bs->opaque; |
850 | 842 | z_stream strm; |
... | ... | @@ -852,8 +844,8 @@ int qcow_compress_cluster(BlockDriverState *bs, int64_t sector_num, |
852 | 844 | uint8_t *out_buf; |
853 | 845 | uint64_t cluster_offset; |
854 | 846 | |
855 | - if (bs->drv != &bdrv_qcow) | |
856 | - return -1; | |
847 | + if (nb_sectors != s->cluster_sectors) | |
848 | + return -EINVAL; | |
857 | 849 | |
858 | 850 | out_buf = qemu_malloc(s->cluster_size + (s->cluster_size / 1000) + 128); |
859 | 851 | if (!out_buf) |
... | ... | @@ -907,6 +899,13 @@ static void qcow_flush(BlockDriverState *bs) |
907 | 899 | bdrv_flush(s->hd); |
908 | 900 | } |
909 | 901 | |
902 | +static int qcow_get_info(BlockDriverState *bs, BlockDriverInfo *bdi) | |
903 | +{ | |
904 | + BDRVQcowState *s = bs->opaque; | |
905 | + bdi->cluster_size = s->cluster_size; | |
906 | + return 0; | |
907 | +} | |
908 | + | |
910 | 909 | BlockDriver bdrv_qcow = { |
911 | 910 | "qcow", |
912 | 911 | sizeof(BDRVQcowState), |
... | ... | @@ -926,6 +925,6 @@ BlockDriver bdrv_qcow = { |
926 | 925 | .bdrv_aio_write = qcow_aio_write, |
927 | 926 | .bdrv_aio_cancel = qcow_aio_cancel, |
928 | 927 | .bdrv_aio_delete = qcow_aio_delete, |
928 | + .bdrv_write_compressed = qcow_write_compressed, | |
929 | + .bdrv_get_info = qcow_get_info, | |
929 | 930 | }; |
930 | - | |
931 | - | ... | ... |