From: Stefan Hajnoczi <stefanha@gmail.com>
To: Changlong Xie <xiecl.fnst@cn.fujitsu.com>
Cc: qemu devel <qemu-devel@nongnu.org>,
Stefan Hajnoczi <stefanha@redhat.com>,
Fam Zheng <famz@redhat.com>, Max Reitz <mreitz@redhat.com>,
Kevin Wolf <kwolf@redhat.com>, Jeff Cody <jcody@redhat.com>,
Wen Congyang <wency@cn.fujitsu.com>,
zhanghailiang <zhang.zhanghailiang@huawei.com>,
qemu block <qemu-block@nongnu.org>,
Jiang Yunhong <yunhong.jiang@intel.com>,
Dong Eddie <eddie.dong@intel.com>,
"Dr. David Alan Gilbert" <dgilbert@redhat.com>,
Markus Armbruster <armbru@redhat.com>,
Gonglei <arei.gonglei@huawei.com>,
Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [Qemu-devel] [Qemu-block] [PATCH v19 09/10] tests: add unit test case for replication
Date: Mon, 30 May 2016 10:34:29 -0700 [thread overview]
Message-ID: <20160530173429.GA1366@stefanha-x1.localdomain> (raw)
In-Reply-To: <1463729780-31982-10-git-send-email-xiecl.fnst@cn.fujitsu.com>
[-- Attachment #1: Type: text/plain, Size: 2388 bytes --]
On Fri, May 20, 2016 at 03:36:19PM +0800, Changlong Xie wrote:
> +/* primary */
> +#define P_LOCAL_DISK "/tmp/p_local_disk.XXXXXX"
> +#define P_COMMAND "driver=replication,mode=primary,node-name=xxx,"\
> + "file.driver=qcow2,file.file.filename="P_LOCAL_DISK
> +
> +/* secondary */
> +#define S_LOCAL_DISK "/tmp/s_local_disk.XXXXXX"
> +#define S_ACTIVE_DISK "/tmp/s_active_disk.XXXXXX"
> +#define S_HIDDEN_DISK "/tmp/s_hidden_disk.XXXXXX"
Please use unique filenames so that multiple instances of the test can
run in parallel on a single machine. mkstemp(3) can be used to do this.
> +static void io_read(BlockDriverState *bs, long pattern, int64_t pattern_offset,
> + int64_t pattern_count, int64_t offset, int64_t count,
> + bool expect_failed)
> +{
> + char *buf;
> + void *cmp_buf;
> + int ret;
> +
> + /* 1. alloc pattern buffer */
> + if (pattern) {
> + cmp_buf = g_malloc(pattern_count);
> + memset(cmp_buf, pattern, pattern_count);
> + }
> +
> + /* 2. alloc read buffer */
> + buf = qemu_blockalign(bs, count);
> + memset(buf, 0xab, count);
> +
> + /* 3. do read */
> + ret = bdrv_read(bs, offset >> 9, (uint8_t *)buf, count >> 9);
> +
> + /* 4. assert and compare buf */
> + if (expect_failed) {
> + g_assert(ret < 0);
> + } else {
> + g_assert(ret >= 0);
> + if (pattern) {
> + g_assert(memcmp(buf + pattern_offset, cmp_buf, pattern_count) <= 0);
> + g_free(cmp_buf);
if pattern && expect_failed then cmp_buf is leaked. Probably best to
initialize cmp_buf = NULL and have an unconditional g_free(cmp_buf) at
the end of the function to avoid leaks.
> + }
> + }
> + g_free(buf);
qemu_blockalign() memory is freed with qemu_vfree(), not g_free().
> +static void test_primary_do_checkpoint(void)
> +{
> + BlockDriverState *bs;
> + Error *local_err = NULL;
> +
> + bs = start_primary();
> +
> + replication_do_checkpoint_all(&local_err);
> + g_assert(!local_err);
> +
> + teardown_primary(bs);
> +}
Shouldn't replication_start_all() be called before
replication_do_checkpoint_all()?
> +int main(int argc, char **argv)
> +{
> + int ret;
> + qemu_init_main_loop(&error_fatal);
> + bdrv_init();
> +
> + do {} while (g_main_context_iteration(NULL, false));
Why is this necessary?
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 473 bytes --]
next prev parent reply other threads:[~2016-05-30 17:34 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-20 7:36 [Qemu-devel] [PATCH v19 00/10] Block replication for continuous checkpoints Changlong Xie
2016-05-20 7:36 ` [Qemu-devel] [PATCH v19 01/10] unblock backup operations in backing file Changlong Xie
2016-05-20 7:36 ` [Qemu-devel] [PATCH v19 02/10] Backup: clear all bitmap when doing block checkpoint Changlong Xie
2016-05-20 7:36 ` [Qemu-devel] [PATCH v19 03/10] Backup: export interfaces for extra serialization Changlong Xie
2016-05-20 7:36 ` [Qemu-devel] [PATCH v19 04/10] Link backup into block core Changlong Xie
2016-05-20 7:36 ` [Qemu-devel] [PATCH v19 05/10] docs: block replication's description Changlong Xie
2016-05-20 7:36 ` [Qemu-devel] [PATCH v19 06/10] auto complete active commit Changlong Xie
2016-05-20 7:36 ` [Qemu-devel] [PATCH v19 07/10] Introduce new APIs to do replication operation Changlong Xie
2016-05-20 7:36 ` [Qemu-devel] [PATCH v19 08/10] Implement new driver for block replication Changlong Xie
2016-05-30 18:14 ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
2016-05-31 1:20 ` Changlong Xie
2016-06-07 4:59 ` [Qemu-devel] " Changlong Xie
2016-06-07 5:36 ` Changlong Xie
2016-05-20 7:36 ` [Qemu-devel] [PATCH v19 09/10] tests: add unit test case for replication Changlong Xie
2016-05-27 1:46 ` Changlong Xie
2016-05-30 17:34 ` Stefan Hajnoczi [this message]
2016-05-31 10:21 ` [Qemu-devel] [Qemu-block] " Changlong Xie
2016-05-20 7:36 ` [Qemu-devel] [PATCH v19 10/10] support replication driver in blockdev-add Changlong Xie
2016-05-27 1:59 ` [Qemu-devel] [PATCH v19 00/10] Block replication for continuous checkpoints Changlong Xie
2016-05-27 7:23 ` Fam Zheng
2016-05-30 18:20 ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
2016-05-31 10:25 ` Changlong Xie
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=20160530173429.GA1366@stefanha-x1.localdomain \
--to=stefanha@gmail.com \
--cc=arei.gonglei@huawei.com \
--cc=armbru@redhat.com \
--cc=dgilbert@redhat.com \
--cc=eddie.dong@intel.com \
--cc=famz@redhat.com \
--cc=jcody@redhat.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
--cc=wency@cn.fujitsu.com \
--cc=xiecl.fnst@cn.fujitsu.com \
--cc=yunhong.jiang@intel.com \
--cc=zhang.zhanghailiang@huawei.com \
/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).