From: Devin Nakamura <devin122@gmail.com>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com, Devin Nakamura <devin122@gmail.com>
Subject: [Qemu-devel] [RFC 11/24] qed: add open_conversion_target()
Date: Fri, 29 Jul 2011 00:49:41 -0400 [thread overview]
Message-ID: <1311914994-20482-12-git-send-email-devin122@gmail.com> (raw)
In-Reply-To: <1311914994-20482-1-git-send-email-devin122@gmail.com>
Signed-off-by: Devin Nakamura <devin122@gmail.com>
---
block/qed.c | 86 +++++++++++++++++++++++++++++++++++++++++++++++-----------
1 files changed, 69 insertions(+), 17 deletions(-)
diff --git a/block/qed.c b/block/qed.c
index daf82fd..b05224a 100644
--- a/block/qed.c
+++ b/block/qed.c
@@ -1451,6 +1451,57 @@ static int bdrv_qed_check(BlockDriverState *bs, BdrvCheckResult *result)
return qed_check(s, result, false);
}
+static int bdrv_qed_open_conversion_target(BlockDriverState *bs,
+ BlockConversionOptions *drv_options,
+ QEMUOptionParameter *usr_options)
+{
+ BDRVQEDState *s = bs->opaque;
+ s->bs = bs;
+ if (drv_options->encryption_type != BLOCK_CRYPT_NONE) {
+ return -1; //TODO: FIXME
+ }
+ if (drv_options->cluster_size != drv_options->allocation_size) {
+ return -1; //TODO: FIXME
+ }
+ s->header.magic = QED_MAGIC;
+ s->header.table_size = QED_DEFAULT_TABLE_SIZE;
+ if(qed_is_cluster_size_valid(drv_options->cluster_size)) {
+ s->header.cluster_size = drv_options->cluster_size;
+ } else {
+ return -EINVAL;
+ }
+ if(qed_is_image_size_valid(drv_options->image_size, s->header.cluster_size,
+ s->header.table_size)) {
+ /*TODO: check if qed_is_image_size_valid
+ * checks image_size % cluster_size =0 */
+ s->header.image_size = drv_options->image_size;
+ } else {
+ return -EINVAL;
+ }
+ s->file_size = bs->file->total_sectors << BDRV_SECTOR_BITS;
+ s->l1_table = qed_alloc_table(s);
+ s->header.l1_table_offset = qed_alloc_clusters(s, s->header.table_size);
+ QSIMPLEQ_INIT(&s->allocating_write_reqs);
+
+
+ if (!qed_check_table_offset(s, s->header.l1_table_offset)) {
+ return -EINVAL;
+ }
+
+ s->table_nelems = (s->header.cluster_size * s->header.table_size) /
+ sizeof(uint64_t);
+ s->l2_shift = ffs(s->header.cluster_size) - 1;
+ s->l2_mask = s->table_nelems - 1;
+ s->l1_shift = s->l2_shift + ffs(s->table_nelems) - 1;
+
+ qed_init_l2_cache(&s->l2_cache);
+
+ s->need_check_timer = qemu_new_timer_ns(vm_clock,
+ qed_need_check_timer_cb, s);
+ qed_write_l1_table_sync(s, 0, s->table_nelems);
+ return 0;
+}
+
static int bdrv_qed_get_mapping(BlockDriverState *bs, uint64_t *guest_offset,
uint64_t *host_offset,
uint64_t *contiguous_bytes)
@@ -1559,23 +1610,24 @@ static BlockDriver bdrv_qed = {
.instance_size = sizeof(BDRVQEDState),
.create_options = qed_create_options,
- .bdrv_probe = bdrv_qed_probe,
- .bdrv_open = bdrv_qed_open,
- .bdrv_close = bdrv_qed_close,
- .bdrv_create = bdrv_qed_create,
- .bdrv_flush = bdrv_qed_flush,
- .bdrv_is_allocated = bdrv_qed_is_allocated,
- .bdrv_make_empty = bdrv_qed_make_empty,
- .bdrv_aio_readv = bdrv_qed_aio_readv,
- .bdrv_aio_writev = bdrv_qed_aio_writev,
- .bdrv_aio_flush = bdrv_qed_aio_flush,
- .bdrv_truncate = bdrv_qed_truncate,
- .bdrv_getlength = bdrv_qed_getlength,
- .bdrv_get_info = bdrv_qed_get_info,
- .bdrv_change_backing_file = bdrv_qed_change_backing_file,
- .bdrv_check = bdrv_qed_check,
- .bdrv_get_mapping = bdrv_qed_get_mapping,
- .bdrv_map = bdrv_qed_map,
+ .bdrv_probe = bdrv_qed_probe,
+ .bdrv_open = bdrv_qed_open,
+ .bdrv_close = bdrv_qed_close,
+ .bdrv_create = bdrv_qed_create,
+ .bdrv_flush = bdrv_qed_flush,
+ .bdrv_is_allocated = bdrv_qed_is_allocated,
+ .bdrv_make_empty = bdrv_qed_make_empty,
+ .bdrv_aio_readv = bdrv_qed_aio_readv,
+ .bdrv_aio_writev = bdrv_qed_aio_writev,
+ .bdrv_aio_flush = bdrv_qed_aio_flush,
+ .bdrv_truncate = bdrv_qed_truncate,
+ .bdrv_getlength = bdrv_qed_getlength,
+ .bdrv_get_info = bdrv_qed_get_info,
+ .bdrv_change_backing_file = bdrv_qed_change_backing_file,
+ .bdrv_check = bdrv_qed_check,
+ .bdrv_open_conversion_target = bdrv_qed_open_conversion_target,
+ .bdrv_get_mapping = bdrv_qed_get_mapping,
+ .bdrv_map = bdrv_qed_map,
};
static void bdrv_qed_init(void)
--
1.7.6.rc1
next prev parent reply other threads:[~2011-07-29 4:50 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-29 4:49 [Qemu-devel] [RFC 00/24] inplace image conversion Devin Nakamura
2011-07-29 4:49 ` [Qemu-devel] [RFC 01/24] block: add block conversion api Devin Nakamura
2011-08-01 13:34 ` Kevin Wolf
2011-08-02 4:43 ` Devin Nakamura
2011-08-02 8:56 ` Stefan Hajnoczi
2011-08-02 9:24 ` Kevin Wolf
2011-07-29 4:49 ` [Qemu-devel] [RFC 02/24] block: add bdrv_get_conversion_options() Devin Nakamura
2011-07-29 4:49 ` [Qemu-devel] [RFC 03/24] block: add bdrv_open_conversion_target() Devin Nakamura
2011-08-01 13:42 ` Kevin Wolf
2011-08-02 8:57 ` Stefan Hajnoczi
2011-07-29 4:49 ` [Qemu-devel] [RFC 04/24] block: add bdrv_get_mapping() Devin Nakamura
2011-08-02 8:58 ` Stefan Hajnoczi
2011-07-29 4:49 ` [Qemu-devel] [RFC 05/24] block: add bdrv_map() Devin Nakamura
2011-07-29 4:49 ` [Qemu-devel] [RFC 06/24] block: add bdrv_copy_header() Devin Nakamura
2011-07-29 4:49 ` [Qemu-devel] [RFC 07/24] qed: make qed_alloc_clusters round up offset to nearest cluster Devin Nakamura
2011-08-01 13:51 ` Kevin Wolf
2011-07-29 4:49 ` [Qemu-devel] [RFC 08/24] qed: add qed_find_cluster_sync() Devin Nakamura
2011-07-29 4:49 ` [Qemu-devel] [RFC 09/24] qed: add qed_bdrv_get_mapping() Devin Nakamura
2011-08-02 8:59 ` Stefan Hajnoczi
2011-07-29 4:49 ` [Qemu-devel] [RFC 10/24] qed: add qed_bdrv_map() Devin Nakamura
2011-07-29 4:49 ` Devin Nakamura [this message]
2011-07-29 4:49 ` [Qemu-devel] [RFC 12/24] qed: add bdrv_qed_copy_header() Devin Nakamura
2011-07-29 4:49 ` [Qemu-devel] [RFC 13/24] qed: add bdrv_qed_get_conversion_options() Devin Nakamura
2011-07-29 4:49 ` [Qemu-devel] [RFC 14/24] qcow2: fix typo in documentation for qcow2_get_cluster_offset() Devin Nakamura
2011-07-29 4:49 ` [Qemu-devel] [RFC 15/24] qcow2: split up the creation of new refcount table from the act of checking it Devin Nakamura
2011-07-29 4:49 ` [Qemu-devel] [RFC 16/24] qcow2: add qcow2_drop_leaked_clusters() Devin Nakamura
2011-08-01 14:18 ` Kevin Wolf
2011-07-29 4:49 ` [Qemu-devel] [RFC 17/24] qcow2: add qcow2_get_mapping Devin Nakamura
2011-07-29 4:49 ` [Qemu-devel] [RFC 18/24] qcow2: add qcow2_map Devin Nakamura
2011-08-01 14:32 ` Kevin Wolf
[not found] ` <CAJ1AwB5ohCMOeSgcUKpKHbqGuK8Eioq5dr-z+a6+vGzdMrJJ6w@mail.gmail.com>
2011-08-02 8:05 ` Kevin Wolf
2011-07-29 4:49 ` [Qemu-devel] [RFC 19/24] qcow2: add qcow2_copy_header() Devin Nakamura
2011-08-01 14:57 ` Kevin Wolf
2011-07-29 4:49 ` [Qemu-devel] [RFC 20/24] qcow2: add get_conversion_options() Devin Nakamura
2011-07-29 4:49 ` [Qemu-devel] [RFC 21/24] qcow2: add qcow2_open_conversion_target() Devin Nakamura
2011-08-01 15:26 ` Kevin Wolf
2011-08-02 4:37 ` Devin Nakamura
2011-07-29 4:49 ` [Qemu-devel] [RFC 22/24] qemu-io: make map command use new block mapping function Devin Nakamura
2011-08-01 15:38 ` Kevin Wolf
2011-08-02 4:02 ` Devin Nakamura
2011-07-29 4:49 ` [Qemu-devel] [RFC 23/24] qemu-io: add setmap command Devin Nakamura
2011-07-29 4:49 ` [Qemu-devel] [RFC 24/24] qemu-img: add inplace conversion to qemu-img Devin Nakamura
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1311914994-20482-12-git-send-email-devin122@gmail.com \
--to=devin122@gmail.com \
--cc=kwolf@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).