From: Jes Sorensen <jes.soren...@redhat.com> Signed-off-by: Jes Sorensen <jes.soren...@redhat.com> --- block/qcow.c | 13 ++++++------- 1 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/block/qcow.c b/block/qcow.c index 816103d..c4d8cb3 100644 --- a/block/qcow.c +++ b/block/qcow.c @@ -214,9 +214,8 @@ static int qcow_set_key(BlockDriverState *bs, const char *key) /* The crypt function is compatible with the linux cryptoloop algorithm for < 4 GB images. NOTE: out_buf == in_buf is supported */ -static void encrypt_sectors(BDRVQcowState *s, int64_t sector_num, - uint8_t *out_buf, const uint8_t *in_buf, - int nb_sectors, int enc, +static void encrypt_sectors(int64_t sector_num, uint8_t *out_buf, + const uint8_t *in_buf, int nb_sectors, int enc, const AES_KEY *key) { union { @@ -351,7 +350,7 @@ static uint64_t get_cluster_offset(BlockDriverState *bs, 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, + encrypt_sectors(start_sect + i, s->cluster_data, s->cluster_data + 512, 1, 1, &s->aes_encrypt_key); @@ -474,7 +473,7 @@ static int qcow_read(BlockDriverState *bs, int64_t sector_num, if (ret != n * 512) return -1; if (s->crypt_method) { - encrypt_sectors(s, sector_num, buf, buf, n, 0, + encrypt_sectors(sector_num, buf, buf, n, 0, &s->aes_decrypt_key); } } @@ -558,7 +557,7 @@ static void qcow_aio_read_cb(void *opaque, int ret) /* nothing to do */ } else { if (s->crypt_method) { - encrypt_sectors(s, acb->sector_num, acb->buf, acb->buf, + encrypt_sectors(acb->sector_num, acb->buf, acb->buf, acb->n, 0, &s->aes_decrypt_key); } @@ -687,7 +686,7 @@ static void qcow_aio_write_cb(void *opaque, int ret) goto done; } } - encrypt_sectors(s, acb->sector_num, acb->cluster_data, acb->buf, + encrypt_sectors(acb->sector_num, acb->cluster_data, acb->buf, acb->n, 1, &s->aes_encrypt_key); src_buf = acb->cluster_data; } else { -- 1.7.2.2