#include "block_int.h"
#include "block/qcow2.h"
-int grow_l1_table(BlockDriverState *bs, int min_size)
+int qcow2_grow_l1_table(BlockDriverState *bs, int min_size)
{
BDRVQcowState *s = bs->opaque;
int new_l1_size, new_l1_size2, ret, i;
memcpy(new_l1_table, s->l1_table, s->l1_size * sizeof(uint64_t));
/* write new table (align to cluster) */
- new_l1_table_offset = alloc_clusters(bs, new_l1_size2);
+ new_l1_table_offset = qcow2_alloc_clusters(bs, new_l1_size2);
for(i = 0; i < s->l1_size; i++)
new_l1_table[i] = cpu_to_be64(new_l1_table[i]);
sizeof(data)) != sizeof(data))
goto fail;
qemu_free(s->l1_table);
- free_clusters(bs, s->l1_table_offset, s->l1_size * sizeof(uint64_t));
+ qcow2_free_clusters(bs, s->l1_table_offset, s->l1_size * sizeof(uint64_t));
s->l1_table_offset = new_l1_table_offset;
s->l1_table = new_l1_table;
s->l1_size = new_l1_size;
return -EIO;
}
-void l2_cache_reset(BlockDriverState *bs)
+void qcow2_l2_cache_reset(BlockDriverState *bs)
{
BDRVQcowState *s = bs->opaque;
/* allocate a new l2 entry */
- l2_offset = alloc_clusters(bs, s->l2_size * sizeof(uint64_t));
+ l2_offset = qcow2_alloc_clusters(bs, s->l2_size * sizeof(uint64_t));
/* update the L1 entry */
/* The crypt function is compatible with the linux cryptoloop
algorithm for < 4 GB images. NOTE: out_buf == in_buf is
supported */
-void encrypt_sectors(BDRVQcowState *s, int64_t sector_num,
- uint8_t *out_buf, const uint8_t *in_buf,
- int nb_sectors, int enc,
- const AES_KEY *key)
+void qcow2_encrypt_sectors(BDRVQcowState *s, int64_t sector_num,
+ uint8_t *out_buf, const uint8_t *in_buf,
+ int nb_sectors, int enc,
+ const AES_KEY *key)
{
union {
uint64_t ll[2];
while (nb_sectors > 0) {
n = nb_sectors;
- cluster_offset = get_cluster_offset(bs, sector_num << 9, &n);
+ cluster_offset = qcow2_get_cluster_offset(bs, sector_num << 9, &n);
index_in_cluster = sector_num & (s->cluster_sectors - 1);
if (!cluster_offset) {
if (bs->backing_hd) {
/* read from the base image */
- n1 = backing_read1(bs->backing_hd, sector_num, buf, n);
+ n1 = qcow2_backing_read1(bs->backing_hd, sector_num, buf, n);
if (n1 > 0) {
ret = bdrv_read(bs->backing_hd, sector_num, buf, n1);
if (ret < 0)
memset(buf, 0, 512 * n);
}
} else if (cluster_offset & QCOW_OFLAG_COMPRESSED) {
- if (decompress_cluster(s, cluster_offset) < 0)
+ if (qcow2_decompress_cluster(s, cluster_offset) < 0)
return -1;
memcpy(buf, s->cluster_cache + index_in_cluster * 512, 512 * n);
} else {
if (ret != n * 512)
return -1;
if (s->crypt_method) {
- encrypt_sectors(s, sector_num, buf, buf, n, 0,
+ qcow2_encrypt_sectors(s, sector_num, buf, buf, n, 0,
&s->aes_decrypt_key);
}
}
if (ret < 0)
return ret;
if (s->crypt_method) {
- encrypt_sectors(s, start_sect + n_start,
+ qcow2_encrypt_sectors(s, start_sect + n_start,
s->cluster_data,
s->cluster_data, n, 1,
&s->aes_encrypt_key);
*
*/
-uint64_t get_cluster_offset(BlockDriverState *bs, uint64_t offset, int *num)
+uint64_t qcow2_get_cluster_offset(BlockDriverState *bs, uint64_t offset,
+ int *num)
{
BDRVQcowState *s = bs->opaque;
int l1_index, l2_index;
l1_index = offset >> (s->l2_bits + s->cluster_bits);
if (l1_index >= s->l1_size) {
- ret = grow_l1_table(bs, l1_index + 1);
+ ret = qcow2_grow_l1_table(bs, l1_index + 1);
if (ret < 0)
return 0;
}
return 0;
} else {
if (l2_offset)
- free_clusters(bs, l2_offset, s->l2_size * sizeof(uint64_t));
+ qcow2_free_clusters(bs, l2_offset, s->l2_size * sizeof(uint64_t));
l2_table = l2_allocate(bs, l1_index);
if (l2_table == NULL)
return 0;
*
*/
-uint64_t alloc_compressed_cluster_offset(BlockDriverState *bs,
- uint64_t offset,
- int compressed_size)
+uint64_t qcow2_alloc_compressed_cluster_offset(BlockDriverState *bs,
+ uint64_t offset,
+ int compressed_size)
{
BDRVQcowState *s = bs->opaque;
int l2_index, ret;
return cluster_offset & ~QCOW_OFLAG_COPIED;
if (cluster_offset)
- free_any_clusters(bs, cluster_offset, 1);
+ qcow2_free_any_clusters(bs, cluster_offset, 1);
- cluster_offset = alloc_bytes(bs, compressed_size);
+ cluster_offset = qcow2_alloc_bytes(bs, compressed_size);
nb_csectors = ((cluster_offset + compressed_size - 1) >> 9) -
(cluster_offset >> 9);
return cluster_offset;
}
-int alloc_cluster_link_l2(BlockDriverState *bs, uint64_t cluster_offset,
+int qcow2_alloc_cluster_link_l2(BlockDriverState *bs, uint64_t cluster_offset,
QCowL2Meta *m)
{
BDRVQcowState *s = bs->opaque;
goto err;
for (i = 0; i < j; i++)
- free_any_clusters(bs, be64_to_cpu(old_cluster[i]) & ~QCOW_OFLAG_COPIED,
- 1);
+ qcow2_free_any_clusters(bs,
+ be64_to_cpu(old_cluster[i]) & ~QCOW_OFLAG_COPIED, 1);
ret = 0;
err:
*
*/
-uint64_t alloc_cluster_offset(BlockDriverState *bs,
- uint64_t offset,
- int n_start, int n_end,
- int *num, QCowL2Meta *m)
+uint64_t qcow2_alloc_cluster_offset(BlockDriverState *bs,
+ uint64_t offset,
+ int n_start, int n_end,
+ int *num, QCowL2Meta *m)
{
BDRVQcowState *s = bs->opaque;
int l2_index, ret;
/* allocate a new cluster */
- cluster_offset = alloc_clusters(bs, nb_clusters * s->cluster_size);
+ cluster_offset = qcow2_alloc_clusters(bs, nb_clusters * s->cluster_size);
/* save info needed for meta data update */
m->offset = offset;
return 0;
}
-int decompress_cluster(BDRVQcowState *s, uint64_t cluster_offset)
+int qcow2_decompress_cluster(BDRVQcowState *s, uint64_t cluster_offset)
{
int ret, csize, nb_csectors, sector_offset;
uint64_t coffset;
/*********************************************************/
/* refcount handling */
-int refcount_init(BlockDriverState *bs)
+int qcow2_refcount_init(BlockDriverState *bs)
{
BDRVQcowState *s = bs->opaque;
int ret, refcount_table_size2, i;
return -ENOMEM;
}
-void refcount_close(BlockDriverState *bs)
+void qcow2_refcount_close(BlockDriverState *bs)
{
BDRVQcowState *s = bs->opaque;
qemu_free(s->refcount_block_cache);
s->refcount_table_offset = table_offset;
update_refcount(bs, table_offset, new_table_size2, 1);
- free_clusters(bs, old_table_offset, old_table_size * sizeof(uint64_t));
+ qcow2_free_clusters(bs, old_table_offset, old_table_size * sizeof(uint64_t));
return 0;
fail:
- free_clusters(bs, table_offset, new_table_size2);
+ qcow2_free_clusters(bs, table_offset, new_table_size2);
qemu_free(new_table);
return -EIO;
}
return (s->free_cluster_index - nb_clusters) << s->cluster_bits;
}
-int64_t alloc_clusters(BlockDriverState *bs, int64_t size)
+int64_t qcow2_alloc_clusters(BlockDriverState *bs, int64_t size)
{
int64_t offset;
/* only used to allocate compressed sectors. We try to allocate
contiguous sectors. size must be <= cluster_size */
-int64_t alloc_bytes(BlockDriverState *bs, int size)
+int64_t qcow2_alloc_bytes(BlockDriverState *bs, int size)
{
BDRVQcowState *s = bs->opaque;
int64_t offset, cluster_offset;
assert(size > 0 && size <= s->cluster_size);
if (s->free_byte_offset == 0) {
- s->free_byte_offset = alloc_clusters(bs, s->cluster_size);
+ s->free_byte_offset = qcow2_alloc_clusters(bs, s->cluster_size);
}
redo:
free_in_cluster = s->cluster_size -
if ((offset & (s->cluster_size - 1)) != 0)
update_cluster_refcount(bs, offset >> s->cluster_bits, 1);
} else {
- offset = alloc_clusters(bs, s->cluster_size);
+ offset = qcow2_alloc_clusters(bs, s->cluster_size);
cluster_offset = s->free_byte_offset & ~(s->cluster_size - 1);
if ((cluster_offset + s->cluster_size) == offset) {
/* we are lucky: contiguous data */
return offset;
}
-void free_clusters(BlockDriverState *bs,
+void qcow2_free_clusters(BlockDriverState *bs,
int64_t offset, int64_t size)
{
update_refcount(bs, offset, size, -1);
*
*/
-void free_any_clusters(BlockDriverState *bs,
+void qcow2_free_any_clusters(BlockDriverState *bs,
uint64_t cluster_offset, int nb_clusters)
{
BDRVQcowState *s = bs->opaque;
int nb_csectors;
nb_csectors = ((cluster_offset >> s->csize_shift) &
s->csize_mask) + 1;
- free_clusters(bs, (cluster_offset & s->cluster_offset_mask) & ~511,
- nb_csectors * 512);
+ qcow2_free_clusters(bs,
+ (cluster_offset & s->cluster_offset_mask) & ~511,
+ nb_csectors * 512);
return;
}
- free_clusters(bs, cluster_offset, nb_clusters << s->cluster_bits);
+ qcow2_free_clusters(bs, cluster_offset, nb_clusters << s->cluster_bits);
return;
}
-void create_refcount_update(QCowCreateState *s, int64_t offset, int64_t size)
+void qcow2_create_refcount_update(QCowCreateState *s, int64_t offset,
+ int64_t size)
{
int refcount;
int64_t start, last, cluster_offset;
}
/* update the refcounts of snapshots and the copied flag */
-int update_snapshot_refcount(BlockDriverState *bs,
- int64_t l1_table_offset,
- int l1_size,
- int addend)
+int qcow2_update_snapshot_refcount(BlockDriverState *bs,
+ int64_t l1_table_offset, int l1_size, int addend)
{
BDRVQcowState *s = bs->opaque;
uint64_t *l1_table, *l2_table, l2_offset, offset, l1_size2, l1_allocated;
int64_t old_offset, old_l2_offset;
int l2_size, i, j, l1_modified, l2_modified, nb_csectors, refcount;
- l2_cache_reset(bs);
+ qcow2_l2_cache_reset(bs);
l2_table = NULL;
l1_table = NULL;
* Returns 0 if no errors are found, the number of errors in case the image is
* detected as corrupted, and -errno when an internal error occured.
*/
-int check_refcounts(BlockDriverState *bs)
+int qcow2_check_refcounts(BlockDriverState *bs)
{
BDRVQcowState *s = bs->opaque;
int64_t size;
/* name follows */
} QCowSnapshotHeader;
-void qcow_free_snapshots(BlockDriverState *bs)
+void qcow2_free_snapshots(BlockDriverState *bs)
{
BDRVQcowState *s = bs->opaque;
int i;
s->nb_snapshots = 0;
}
-int qcow_read_snapshots(BlockDriverState *bs)
+int qcow2_read_snapshots(BlockDriverState *bs)
{
BDRVQcowState *s = bs->opaque;
QCowSnapshotHeader h;
s->snapshots_size = offset - s->snapshots_offset;
return 0;
fail:
- qcow_free_snapshots(bs);
+ qcow2_free_snapshots(bs);
return -1;
}
}
snapshots_size = offset;
- snapshots_offset = alloc_clusters(bs, snapshots_size);
+ snapshots_offset = qcow2_alloc_clusters(bs, snapshots_size);
offset = snapshots_offset;
for(i = 0; i < s->nb_snapshots; i++) {
goto fail;
/* free the old snapshot table */
- free_clusters(bs, s->snapshots_offset, s->snapshots_size);
+ qcow2_free_clusters(bs, s->snapshots_offset, s->snapshots_size);
s->snapshots_offset = snapshots_offset;
s->snapshots_size = snapshots_size;
return 0;
}
/* if no id is provided, a new one is constructed */
-int qcow_snapshot_create(BlockDriverState *bs, QEMUSnapshotInfo *sn_info)
+int qcow2_snapshot_create(BlockDriverState *bs, QEMUSnapshotInfo *sn_info)
{
BDRVQcowState *s = bs->opaque;
QCowSnapshot *snapshots1, sn1, *sn = &sn1;
sn->date_nsec = sn_info->date_nsec;
sn->vm_clock_nsec = sn_info->vm_clock_nsec;
- ret = update_snapshot_refcount(bs, s->l1_table_offset, s->l1_size, 1);
+ ret = qcow2_update_snapshot_refcount(bs, s->l1_table_offset, s->l1_size, 1);
if (ret < 0)
goto fail;
/* create the L1 table of the snapshot */
- sn->l1_table_offset = alloc_clusters(bs, s->l1_size * sizeof(uint64_t));
+ sn->l1_table_offset = qcow2_alloc_clusters(bs, s->l1_size * sizeof(uint64_t));
sn->l1_size = s->l1_size;
l1_table = qemu_malloc(s->l1_size * sizeof(uint64_t));
}
/* copy the snapshot 'snapshot_name' into the current disk image */
-int qcow_snapshot_goto(BlockDriverState *bs, const char *snapshot_id)
+int qcow2_snapshot_goto(BlockDriverState *bs, const char *snapshot_id)
{
BDRVQcowState *s = bs->opaque;
QCowSnapshot *sn;
return -ENOENT;
sn = &s->snapshots[snapshot_index];
- if (update_snapshot_refcount(bs, s->l1_table_offset, s->l1_size, -1) < 0)
+ if (qcow2_update_snapshot_refcount(bs, s->l1_table_offset, s->l1_size, -1) < 0)
goto fail;
- if (grow_l1_table(bs, sn->l1_size) < 0)
+ if (qcow2_grow_l1_table(bs, sn->l1_size) < 0)
goto fail;
s->l1_size = sn->l1_size;
be64_to_cpus(&s->l1_table[i]);
}
- if (update_snapshot_refcount(bs, s->l1_table_offset, s->l1_size, 1) < 0)
+ if (qcow2_update_snapshot_refcount(bs, s->l1_table_offset, s->l1_size, 1) < 0)
goto fail;
#ifdef DEBUG_ALLOC
return -EIO;
}
-int qcow_snapshot_delete(BlockDriverState *bs, const char *snapshot_id)
+int qcow2_snapshot_delete(BlockDriverState *bs, const char *snapshot_id)
{
BDRVQcowState *s = bs->opaque;
QCowSnapshot *sn;
return -ENOENT;
sn = &s->snapshots[snapshot_index];
- ret = update_snapshot_refcount(bs, sn->l1_table_offset, sn->l1_size, -1);
+ ret = qcow2_update_snapshot_refcount(bs, sn->l1_table_offset, sn->l1_size, -1);
if (ret < 0)
return ret;
/* must update the copied flag on the current cluster offsets */
- ret = update_snapshot_refcount(bs, s->l1_table_offset, s->l1_size, 0);
+ ret = qcow2_update_snapshot_refcount(bs, s->l1_table_offset, s->l1_size, 0);
if (ret < 0)
return ret;
- free_clusters(bs, sn->l1_table_offset, sn->l1_size * sizeof(uint64_t));
+ qcow2_free_clusters(bs, sn->l1_table_offset, sn->l1_size * sizeof(uint64_t));
qemu_free(sn->id_str);
qemu_free(sn->name);
return 0;
}
-int qcow_snapshot_list(BlockDriverState *bs, QEMUSnapshotInfo **psn_tab)
+int qcow2_snapshot_list(BlockDriverState *bs, QEMUSnapshotInfo **psn_tab)
{
BDRVQcowState *s = bs->opaque;
QEMUSnapshotInfo *sn_tab, *sn_info;
+ 512);
s->cluster_cache_offset = -1;
- if (refcount_init(bs) < 0)
+ if (qcow2_refcount_init(bs) < 0)
goto fail;
/* read qcow2 extensions */
goto fail;
bs->backing_file[len] = '\0';
}
- if (qcow_read_snapshots(bs) < 0)
+ if (qcow2_read_snapshots(bs) < 0)
goto fail;
#ifdef DEBUG_ALLOC
return 0;
fail:
- qcow_free_snapshots(bs);
- refcount_close(bs);
+ qcow2_free_snapshots(bs);
+ qcow2_refcount_close(bs);
qemu_free(s->l1_table);
qemu_free(s->l2_cache);
qemu_free(s->cluster_cache);
uint64_t cluster_offset;
*pnum = nb_sectors;
- cluster_offset = get_cluster_offset(bs, sector_num << 9, pnum);
+ cluster_offset = qcow2_get_cluster_offset(bs, sector_num << 9, pnum);
return (cluster_offset != 0);
}
/* handle reading after the end of the backing file */
-int backing_read1(BlockDriverState *bs,
+int qcow2_backing_read1(BlockDriverState *bs,
int64_t sector_num, uint8_t *buf, int nb_sectors)
{
int n1;
/* nothing to do */
} else {
if (s->crypt_method) {
- encrypt_sectors(s, acb->sector_num, acb->buf, acb->buf,
+ qcow2_encrypt_sectors(s, acb->sector_num, acb->buf, acb->buf,
acb->n, 0,
&s->aes_decrypt_key);
}
/* prepare next AIO request */
acb->n = acb->nb_sectors;
- acb->cluster_offset = get_cluster_offset(bs, acb->sector_num << 9, &acb->n);
+ acb->cluster_offset =
+ qcow2_get_cluster_offset(bs, acb->sector_num << 9, &acb->n);
index_in_cluster = acb->sector_num & (s->cluster_sectors - 1);
if (!acb->cluster_offset) {
if (bs->backing_hd) {
/* read from the base image */
- n1 = backing_read1(bs->backing_hd, acb->sector_num,
+ n1 = qcow2_backing_read1(bs->backing_hd, acb->sector_num,
acb->buf, acb->n);
if (n1 > 0) {
acb->hd_iov.iov_base = (void *)acb->buf;
}
} else if (acb->cluster_offset & QCOW_OFLAG_COMPRESSED) {
/* add AIO support for compressed blocks ? */
- if (decompress_cluster(s, acb->cluster_offset) < 0)
+ if (qcow2_decompress_cluster(s, acb->cluster_offset) < 0)
goto done;
memcpy(acb->buf,
s->cluster_cache + index_in_cluster * 512, 512 * acb->n);
if (ret < 0)
goto done;
- if (alloc_cluster_link_l2(bs, acb->cluster_offset, &acb->l2meta) < 0) {
- free_any_clusters(bs, acb->cluster_offset, acb->l2meta.nb_clusters);
+ if (qcow2_alloc_cluster_link_l2(bs, acb->cluster_offset, &acb->l2meta) < 0) {
+ qcow2_free_any_clusters(bs, acb->cluster_offset, acb->l2meta.nb_clusters);
goto done;
}
n_end > QCOW_MAX_CRYPT_CLUSTERS * s->cluster_sectors)
n_end = QCOW_MAX_CRYPT_CLUSTERS * s->cluster_sectors;
- acb->cluster_offset = alloc_cluster_offset(bs, acb->sector_num << 9,
+ acb->cluster_offset = qcow2_alloc_cluster_offset(bs, acb->sector_num << 9,
index_in_cluster,
n_end, &acb->n, &acb->l2meta);
if (!acb->cluster_offset || (acb->cluster_offset & 511) != 0) {
acb->cluster_data = qemu_mallocz(QCOW_MAX_CRYPT_CLUSTERS *
s->cluster_size);
}
- encrypt_sectors(s, acb->sector_num, acb->cluster_data, acb->buf,
+ qcow2_encrypt_sectors(s, acb->sector_num, acb->cluster_data, acb->buf,
acb->n, 1, &s->aes_encrypt_key);
src_buf = acb->cluster_data;
} else {
qemu_free(s->l2_cache);
qemu_free(s->cluster_cache);
qemu_free(s->cluster_data);
- refcount_close(bs);
+ qcow2_refcount_close(bs);
bdrv_delete(s->hd);
}
s->refcount_block = qemu_mallocz(ref_clusters * s->cluster_size);
/* update refcounts */
- create_refcount_update(s, 0, header_size);
- create_refcount_update(s, s->l1_table_offset, l1_size * sizeof(uint64_t));
- create_refcount_update(s, s->refcount_table_offset, s->cluster_size);
- create_refcount_update(s, s->refcount_block_offset, ref_clusters * s->cluster_size);
+ qcow2_create_refcount_update(s, 0, header_size);
+ qcow2_create_refcount_update(s, s->l1_table_offset,
+ l1_size * sizeof(uint64_t));
+ qcow2_create_refcount_update(s, s->refcount_table_offset, s->cluster_size);
+ qcow2_create_refcount_update(s, s->refcount_block_offset,
+ ref_clusters * s->cluster_size);
/* write all the data */
write(fd, &header, sizeof(header));
/* could not compress: write normal cluster */
bdrv_write(bs, sector_num, buf, s->cluster_sectors);
} else {
- cluster_offset = alloc_compressed_cluster_offset(bs, sector_num << 9,
- out_len);
+ cluster_offset = qcow2_alloc_compressed_cluster_offset(bs,
+ sector_num << 9, out_len);
if (!cluster_offset)
return -1;
cluster_offset &= s->cluster_offset_mask;
static int qcow_check(BlockDriverState *bs)
{
- return check_refcounts(bs);
+ return qcow2_check_refcounts(bs);
}
#if 0
.bdrv_aio_writev = qcow_aio_writev,
.bdrv_write_compressed = qcow_write_compressed,
- .bdrv_snapshot_create = qcow_snapshot_create,
- .bdrv_snapshot_goto = qcow_snapshot_goto,
- .bdrv_snapshot_delete = qcow_snapshot_delete,
- .bdrv_snapshot_list = qcow_snapshot_list,
+ .bdrv_snapshot_create = qcow2_snapshot_create,
+ .bdrv_snapshot_goto = qcow2_snapshot_goto,
+ .bdrv_snapshot_delete = qcow2_snapshot_delete,
+ .bdrv_snapshot_list = qcow2_snapshot_list,
.bdrv_get_info = qcow_get_info,
.bdrv_put_buffer = qcow_put_buffer,
// FIXME Need qcow2_ prefix to global functions
/* qcow2.c functions */
-void l2_cache_reset(BlockDriverState *bs);
-int backing_read1(BlockDriverState *bs,
+int qcow2_backing_read1(BlockDriverState *bs,
int64_t sector_num, uint8_t *buf, int nb_sectors);
/* qcow2-refcount.c functions */
-int refcount_init(BlockDriverState *bs);
-void refcount_close(BlockDriverState *bs);
+int qcow2_refcount_init(BlockDriverState *bs);
+void qcow2_refcount_close(BlockDriverState *bs);
-int64_t alloc_clusters(BlockDriverState *bs, int64_t size);
-int64_t alloc_bytes(BlockDriverState *bs, int size);
-void free_clusters(BlockDriverState *bs,
+int64_t qcow2_alloc_clusters(BlockDriverState *bs, int64_t size);
+int64_t qcow2_alloc_bytes(BlockDriverState *bs, int size);
+void qcow2_free_clusters(BlockDriverState *bs,
int64_t offset, int64_t size);
-void free_any_clusters(BlockDriverState *bs,
+void qcow2_free_any_clusters(BlockDriverState *bs,
uint64_t cluster_offset, int nb_clusters);
-void create_refcount_update(QCowCreateState *s, int64_t offset, int64_t size);
-int update_snapshot_refcount(BlockDriverState *bs,
- int64_t l1_table_offset,
- int l1_size,
- int addend);
+void qcow2_create_refcount_update(QCowCreateState *s, int64_t offset,
+ int64_t size);
+int qcow2_update_snapshot_refcount(BlockDriverState *bs,
+ int64_t l1_table_offset, int l1_size, int addend);
-int check_refcounts(BlockDriverState *bs);
+int qcow2_check_refcounts(BlockDriverState *bs);
/* qcow2-cluster.c functions */
-int grow_l1_table(BlockDriverState *bs, int min_size);
-int decompress_cluster(BDRVQcowState *s, uint64_t cluster_offset);
-void encrypt_sectors(BDRVQcowState *s, int64_t sector_num,
+int qcow2_grow_l1_table(BlockDriverState *bs, int min_size);
+void qcow2_l2_cache_reset(BlockDriverState *bs);
+int qcow2_decompress_cluster(BDRVQcowState *s, uint64_t cluster_offset);
+void qcow2_encrypt_sectors(BDRVQcowState *s, int64_t sector_num,
uint8_t *out_buf, const uint8_t *in_buf,
int nb_sectors, int enc,
const AES_KEY *key);
-uint64_t get_cluster_offset(BlockDriverState *bs, uint64_t offset, int *num);
-uint64_t alloc_cluster_offset(BlockDriverState *bs,
+uint64_t qcow2_get_cluster_offset(BlockDriverState *bs, uint64_t offset,
+ int *num);
+uint64_t qcow2_alloc_cluster_offset(BlockDriverState *bs,
uint64_t offset,
int n_start, int n_end,
int *num, QCowL2Meta *m);
-uint64_t alloc_compressed_cluster_offset(BlockDriverState *bs,
+uint64_t qcow2_alloc_compressed_cluster_offset(BlockDriverState *bs,
uint64_t offset,
int compressed_size);
-int alloc_cluster_link_l2(BlockDriverState *bs, uint64_t cluster_offset,
+int qcow2_alloc_cluster_link_l2(BlockDriverState *bs, uint64_t cluster_offset,
QCowL2Meta *m);
/* qcow2-snapshot.c functions */
-int qcow_snapshot_create(BlockDriverState *bs, QEMUSnapshotInfo *sn_info);
-int qcow_snapshot_goto(BlockDriverState *bs, const char *snapshot_id);
-int qcow_snapshot_delete(BlockDriverState *bs, const char *snapshot_id);
-int qcow_snapshot_list(BlockDriverState *bs, QEMUSnapshotInfo **psn_tab);
+int qcow2_snapshot_create(BlockDriverState *bs, QEMUSnapshotInfo *sn_info);
+int qcow2_snapshot_goto(BlockDriverState *bs, const char *snapshot_id);
+int qcow2_snapshot_delete(BlockDriverState *bs, const char *snapshot_id);
+int qcow2_snapshot_list(BlockDriverState *bs, QEMUSnapshotInfo **psn_tab);
-void qcow_free_snapshots(BlockDriverState *bs);
-int qcow_read_snapshots(BlockDriverState *bs);
+void qcow2_free_snapshots(BlockDriverState *bs);
+int qcow2_read_snapshots(BlockDriverState *bs);
#endif