From: Stefan Hajnoczi <stefanha@gmail.com>
To: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
Cc: kwolf@redhat.com, pbonzini@redhat.com, qemu-devel@nongnu.org,
dietmar@proxmox.com
Subject: Re: [Qemu-devel] [PATCH 2/3] block: adjust qmp_transaction to be extendable
Date: Wed, 17 Apr 2013 16:42:38 +0200 [thread overview]
Message-ID: <20130417144238.GA9390@stefanha-thinkpad.muc.redhat.com> (raw)
In-Reply-To: <1364810491-21404-3-git-send-email-xiawenc@linux.vnet.ibm.com>
On Mon, Apr 01, 2013 at 06:01:30PM +0800, Wenchao Xia wrote:
> /* New and old BlockDriverState structs for group snapshots */
> -typedef struct BlkTransactionStates {
> +typedef struct BdrvActionOps {
> + int (*commit)(BlockdevAction *action, void **p_opaque, Error **errp);
> + void (*rollback)(BlockdevAction *action, void *opaque);
> + void (*clean)(BlockdevAction *action, void *opaque);
Please document these functions.
> +const BdrvActionOps external_snapshot_ops = {
> + .commit = external_snapshot_commit,
> + .rollback = external_snapshot_rollback,
> + .clean = external_snapshot_clean,
> +};
> +
> +typedef struct BlkTransactionStates {
> + BlockdevAction *action;
> + void *opaque;
> + const BdrvActionOps *ops;
> QSIMPLEQ_ENTRY(BlkTransactionStates) entry;
> } BlkTransactionStates;
The relationship between BlkTransactionStates and ExternalSnapshotState
can be simplified:
typedef struct {
int (*commit)(BlkTransactionState *state, Error **errp);
void (*rollback)(BlkTransactionState *state);
void (*clean)(BlkTransactionState *state);
size_t instance_size;
} BdrvActionOps;
typedef struct BlkTransactionState {
BlockDevAction *action;
const BdrvActionOps *ops;
QSIMPLEQ_ENTRY(BlkTransactionState) entry;
} BlkTransactionState;
typedef struct {
BlkTransactionState common;
BlockDriverState *old_bs;
BlockDriverState *new_bs;
} ExternalSnapshotState;
const BdrvActionOps external_snapshot_ops = {
.commit = external_snapshot_commit,
.rollback = external_snapshot_rollback,
.clean = external_snapshot_clean,
.instance_size = sizeof(ExternalSnapshotState);
};
This eliminates the opaque pointer and g_free(state) can be handled by
qmp_transaction(). This way action types no longer need to free opaque.
next prev parent reply other threads:[~2013-04-17 14:42 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-01 10:01 [Qemu-devel] [PATCH 0/3] block: make qmp_transaction extendable Wenchao Xia
2013-04-01 10:01 ` [Qemu-devel] [PATCH 1/3] block: add function deappend() Wenchao Xia
2013-04-01 10:01 ` [Qemu-devel] [PATCH 2/3] block: adjust qmp_transaction to be extendable Wenchao Xia
2013-04-02 13:55 ` Kevin Wolf
2013-04-03 5:51 ` Wenchao Xia
2013-04-03 7:21 ` Paolo Bonzini
2013-04-03 9:02 ` Wenchao Xia
2013-04-03 9:17 ` Paolo Bonzini
2013-04-03 9:22 ` Kevin Wolf
2013-04-03 10:33 ` Wenchao Xia
2013-04-17 14:42 ` Stefan Hajnoczi [this message]
2013-04-18 3:00 ` Wenchao Xia
2013-04-18 6:35 ` Stefan Hajnoczi
2013-04-01 10:01 ` [Qemu-devel] [PATCH 3/3] block: change rollback sequence in qmp_transaction Wenchao Xia
2013-04-01 15:52 ` Eric Blake
2013-04-02 2:34 ` Wenchao Xia
2013-04-02 13:59 ` Kevin Wolf
2013-04-03 5:35 ` Wenchao Xia
2013-04-03 9:03 ` Kevin Wolf
2013-04-03 10:35 ` Wenchao Xia
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=20130417144238.GA9390@stefanha-thinkpad.muc.redhat.com \
--to=stefanha@gmail.com \
--cc=dietmar@proxmox.com \
--cc=kwolf@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=xiawenc@linux.vnet.ibm.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).