qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Juan Quintela <quintela@redhat.com>
To: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
Cc: kwolf@redhat.com, aliguori@us.ibm.com, stefanha@gmail.com,
	qemu-devel@nongnu.org, blauwirbel@gmail.com, pbonzini@redhat.com
Subject: Re: [Qemu-devel] [PATCH 3/6] snapshot: design of common API to take snapshots
Date: Fri, 21 Dec 2012 19:49:11 +0100	[thread overview]
Message-ID: <87y5grjl5k.fsf@elfo.mitica> (raw)
In-Reply-To: <1355725509-5429-4-git-send-email-xiawenc@linux.vnet.ibm.com> (Wenchao Xia's message of "Mon, 17 Dec 2012 14:25:06 +0800")

Wenchao Xia <xiawenc@linux.vnet.ibm.com> wrote:
> +
> +typedef struct SNTime {
> +    uint32_t date_sec; /* UTC date of the snapshot */
> +    uint32_t date_nsec;

This two fields are just struct timespec, does it makes sense to use it?

> +    uint64_t vm_clock_nsec; /* VM clock relative to boot */
> +} SNTime;
> +
> +typedef enum BlkSnapshotIntStep {
> +    BLK_SNAPSHOT_INT_START = 0,
> +    BLK_SNAPSHOT_INT_CREATED,
> +    BLK_SNAPSHOT_INT_CANCELED,
> +} BlkSnapshotIntStep;
> +
> +typedef struct BlkSnapshotInternal {
> +    /* caller input */
> +    const char *sn_name; /* must be set in create/delete. */
> +    BlockDriverState *bs; /* must be set in create/delete */
> +    SNTime time; /* must be set in create. */
> +    uint64_t vm_state_size; /* optional, default is 0, only valid in create. */
> +    /* following were used internal */
> +    QEMUSnapshotInfo sn;
> +    QEMUSnapshotInfo old_sn;
> +    bool old_sn_exist;
> +    BlkSnapshotIntStep step;
> +} BlkSnapshotInternal;
> +
> +/* external snapshot */
> +
> +typedef enum BlkSnapshotExtStep {
> +    BLK_SNAPSHOT_EXT_START = 0,
> +    BLK_SNAPSHOT_EXT_CREATED,
> +    BLK_SNAPSHOT_EXT_INVALIDATED,
> +    BLK_SNAPSHOT_EXT_CANCELED,
> +} BlkSnapshotExtStep;
> +
> +typedef struct BlkSnapshotExternal {
> +    /* caller input */
> +    const char *new_image_file; /* must be set in create/delete. */
> +    BlockDriverState *old_bs; /* must be set in create/delete. */
> +    const char *format; /* must be set in create. */
> +    /* following were used internal */
> +    BlockDriverState *new_bs;
> +    BlockDriver *format_drv;
> +    BlkSnapshotExtStep step;
> +} BlkSnapshotExternal;
> +
> +typedef enum BlkSnapshotType {
> +    BLK_SNAPSHOT_INTERNAL = 0,
> +    BLK_SNAPSHOT_EXTERNAL,
> +    BLK_SNAPSHOT_NOSUPPORT,
> +} BlkSnapshotType;
> +
> +/* for simple sync type params were all put here ignoring the difference of
> +   different operation type as create/delete. */
> +typedef struct BlkTransactionStatesSync {
> +    /* caller input */
> +    BlkSnapshotType type;
> +    union {
> +        BlkSnapshotInternal internal;
> +        BlkSnapshotExternal external;
> +    };
> +    bool use_existing;
> +    BlkTransactionOperationSync op;
> +} BlkTransactionStatesSync;
> +
> +/* async snapshot, not supported now */
> +typedef struct BlkTransactionStatesAsync {
> +    int reserved;
> +} BlkTransactionStatesAsync;
> +
> +/* Core structure for group snapshots, fill in it and then call the API. */
> +typedef struct BlkTransactionStates BlkTransactionStates;
> +
> +struct BlkTransactionStates {
> +    /* caller input */
> +    bool async;

Why do we have this variable?  As far as I can see, we only test its
value, and set it to false.  Are we missing any patch?

> +    union {
> +        BlkTransactionStatesSync st_sync;
> +        BlkTransactionStatesSync st_async;
> +    };
> +    /* following were used internal */
> +    Error *err;
> +    int (*blk_trans_do)(BlkTransactionStates *states, Error **errp);
> +    int (*blk_trans_invalid)(BlkTransactionStates *states, Error **errp);
> +    int (*blk_trans_cancel)(BlkTransactionStates *states, Error **errp);
> +    QSIMPLEQ_ENTRY(BlkTransactionStates) entry;
> +};
> +
> +typedef QSIMPLEQ_HEAD(snap_bdrv_states, BlkTransactionStates) \
> +                      BlkTransactionStatesList;
> +
> +/* API */
> +BlkTransactionStates *blk_trans_st_new(void);
> +void blk_trans_st_delete(BlkTransactionStates **p_st);
> +BlkTransactionStatesList *blk_trans_st_list_new(void);
> +void blk_trans_st_list_delete(BlkTransactionStatesList **p_list);
> +
> +/* add a request to list, request would be checked to see if it is valid,
> +   return -1 when met error and states would not be queued. */
> +int add_transaction(BlkTransactionStatesList *list,
> +                    BlkTransactionStates *states,
> +                    Error **errp);
> +
> +/*    'Atomic' submit the request. In snapshot creation case, if any
> + *  fail then we do not pivot any of the devices in the group, and abandon the
> + *  snapshots
> + */
> +int submit_transaction(BlkTransactionStatesList *list, Error **errp);
> +
> +/* helper */
> +SNTime get_sn_time(void);

> +void generate_sn_name_from_time(SNTime *time, char *time_str, int size);
>  #endif

  parent reply	other threads:[~2012-12-21 18:49 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-17  6:25 [Qemu-devel] [PATCH 0/6] snapshot: take snapshots in unified way Wenchao Xia
2012-12-17  6:25 ` [Qemu-devel] [PATCH 1/6] snapshot: export function in block.c Wenchao Xia
2012-12-21 18:13   ` Juan Quintela
2012-12-25  4:31     ` Wenchao Xia
2013-01-04 14:49   ` Stefan Hajnoczi
2013-01-05  8:26     ` Wenchao Xia
2013-01-07 16:43   ` Kevin Wolf
2013-01-08  2:25     ` Wenchao Xia
2013-01-08 10:37       ` Kevin Wolf
2013-01-09  4:32         ` Wenchao Xia
2012-12-17  6:25 ` [Qemu-devel] [PATCH 2/6] snapshot: add error set function Wenchao Xia
2012-12-20 21:36   ` Eric Blake
2012-12-21  2:37     ` Wenchao Xia
2013-01-04 14:55   ` Stefan Hajnoczi
2013-01-05  8:27     ` Wenchao Xia
2012-12-17  6:25 ` [Qemu-devel] [PATCH 3/6] snapshot: design of common API to take snapshots Wenchao Xia
2012-12-21 18:48   ` Eric Blake
2012-12-25  5:25     ` Wenchao Xia
2012-12-21 18:49   ` Juan Quintela [this message]
2012-12-25  5:24     ` Wenchao Xia
2012-12-17  6:25 ` [Qemu-devel] [PATCH 4/6] snapshot: implemention " Wenchao Xia
2012-12-17  6:36   ` Dietmar Maurer
2012-12-17  7:38     ` Wenchao Xia
2012-12-17  7:52       ` Dietmar Maurer
2012-12-17  8:52         ` Wenchao Xia
2012-12-17  9:58           ` Dietmar Maurer
2012-12-20 22:19             ` Eric Blake
2012-12-21  3:01               ` Wenchao Xia
2012-12-21  6:20                 ` Dietmar Maurer
2013-01-04 16:13                   ` Stefan Hajnoczi
2012-12-17 10:32           ` Dietmar Maurer
2012-12-18 10:29             ` Wenchao Xia
2012-12-18 10:36               ` Dietmar Maurer
2012-12-19  3:34                 ` Wenchao Xia
2012-12-19  4:55                   ` Dietmar Maurer
2012-12-19  5:37                     ` Wenchao Xia
2012-12-21 18:48   ` Juan Quintela
2012-12-25  5:16     ` Wenchao Xia
2012-12-17  6:25 ` [Qemu-devel] [PATCH 5/6] snapshot: qmp interface Wenchao Xia
2013-01-02 14:52   ` Eric Blake
2013-01-04  6:02     ` Wenchao Xia
2013-01-04 13:57       ` Eric Blake
2013-01-04 16:22   ` Stefan Hajnoczi
2013-01-05  8:38     ` Wenchao Xia
2012-12-17  6:25 ` [Qemu-devel] [PATCH 6/6] snapshot: human monitor interface Wenchao Xia
2013-01-04 15:44   ` Stefan Hajnoczi
2013-01-05  8:36     ` 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=87y5grjl5k.fsf@elfo.mitica \
    --to=quintela@redhat.com \
    --cc=aliguori@us.ibm.com \
    --cc=blauwirbel@gmail.com \
    --cc=kwolf@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@gmail.com \
    --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).