xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Chunyan Liu <cyliu@suse.com>
To: xen-devel@lists.xen.org
Cc: jfehlig@suse.com, ian.jackson@eu.citrix.com,
	Ian.Campbell@citrix.com, Chunyan Liu <cyliu@suse.com>
Subject: [RFC V6] Libxl Domain Snapshot API Design
Date: Wed, 27 Aug 2014 15:22:26 +0800	[thread overview]
Message-ID: <1409124146-18249-1-git-send-email-cyliu@suse.com> (raw)

Since Bamvor left SUSE and turns to work on ARM server, I'd like to continue
this work and make progress. Following the discussion about V5, which mainly
focused on the API design, here post the updated API design. Thanks for any
of your further suggestions!

Main changes to V5:
* libxl_disk_snapshot: reuse libxl_device_disk rather than specify path,
    format separately in the structure. Including two libxl_device_disk
    components, one is to indicate the original disk info, one is to
    indicate the external snapshot info if it is 'external snapshot'.
* define common APIs for domain snapshot creating/deleting/reverting,
  rather than a group of functions for disk snapshot operations.
* remove those APIs for loading/storing/deleting snapshot config.

V5 is here:
http://lists.xenproject.org/archives/html/xen-devel/2014-07/msg00893.html
V5 about API Design is here:
http://lists.xenproject.org/archives/html/xen-devel/2014-07/msg00897.html

===========================================================================
Libxl Domain Snapshot API

libxl_domain_snapshot = Struct("domain_snapshot",[
    ("name",          string),              /* snapshot name */
    ("description",   string),              /* snapshot description */
    ("creation_time", uint64),              /* creation time, in seconds */

    /* save memory or not. "false" means disk-only snapshot */
    ("memory",        bool),

    /* memory state file when snapshot is external */
    ("memory_file",   string),

    /* Array to store disk snapshot info. */
    ("disks", Array(libxl_disk_snapshot, "num_disks")),
    ])

libxl_disk_snapshot = Struct("disk_snapshot",[
    ("disk",           libxl_device_disk),      /* orignal disk */
    ("name",           string),                 /* snapshot name */
    ("external",       bool),                   /* external snapshot or not */

    /* external snapshot info, including file path and format, etc.
     * if "external" is false, this will be "NULL".
     */
    ("external_sn",    libxl_device_disk),
    ])

enum libxlDomainSnapshotCreateFlags {
    /* disk snapshot, not system checkpoint */
    LIBXL_DOMAIN_SNAPSHOT_CREATE_DISK_ONLY	=  1,

    /* create the snapshot while the guest is running */
    LIBXL_DOMAIN_SNAPSHOT_CREATE_LIVE	        =  2,
}

enum libxlDomainSnapshotDeleteFlags {
    LIBXL_DOMAIN_SNAPSHOT_DELETE_CHILDREN	=  1, /* delete children too */
}

enum virDomainSnapshotRevertFlags {
    LIBXL_DOMAIN_SNAPSHOT_REVERT_RUNNING        =  1, /* run after revert */
    LIBXL_DOMAIN_SNAPSHOT_REVERT_PAUSED         =  2, /* pause after revert */
    LIBXL_DOMAIN_SNAPSHOT_REVERT_FORCE          =  4, /* force revert */
}

int libxl_domain_snapshot_create(libxl_ctx *ctx, const char *domname,
                                 libxl_domain_snapshot *snapshot,
                                 unsigned int flags);

    Creates a new snapshot of a domain based on the snapshot config contained
    in @snapshot.

    If @flags includes LIBXL_DOMAIN_SNAPSHOT_CREATE_LIVE, then the domain is not
    paused while creating the snapshot, like live migration. This increases size
    of the memory dump file, but reducess downtime of the guest. Only support
    this flag during external checkpoints.

    If @flags includes LIBXL_DOMAIN_SNAPSHOT_CREATE_DISK_ONLY, then the snapshot
    will be limited to the disks described in @snapshot, and no VM state will
    be saved. For an active guest, this is not supported.

    ctx: context
    domname:  domain name
    snapshot: configuration of domain snapshot
    flags: bitwise-OR of libxlDomainSnapshotCreateFlags
    Returns: 0 on success, -1 on failure


int libxl_domain_snapshot_delete(libxl_ctx *ctx, const char *domname,
                                 const char *snapshot_name,
                                 unsigned int flags);

    Delete a snapshot.

    If @flags is 0, then just this snapshot is deleted, and changes from this
    snapshot are automatically merged into children snapshots.

    If @flags includes LIBXL_DOMAIN_SNAPSHOT_DELETE_CHILDREN, then this snapshot
    and any descendant snapshots are deleted.

    ctx: context
    domname: domain name
    snapshot_name: snapshot name
    flags: bitwise-OR of supported libxlDomainSnapshotDeleteFlags
    Returns: 0 on success, -1 on error.

int libxl_disk_snapshot_revert(libxl_ctx *ctx, const char *domname,
                               const char *snapshot_name,
                               unsigned int flags);

    Revert the domain to a given snapshot.

    Normally, the domain will revert to the same state the domain was in while
    the snapshot was taken (whether inactive, running, or paused).

    If @flags includes LIBXL_DOMAIN_SNAPSHOT_REVERT_RUNNING, then overrides the
    snapshot state to guarantee a running domain after the revert.

    If @flags includes LIBXL_DOMAIN_SNAPSHOT_REVERT_PAUSED, then guarantees a
    paused domain after the revert.

    ctx: context
    domname: domain name
    snapshot_name: snapshot name
    flags: bitwise-OR of supported libxlDomainSnapshotRevertFlags
    Returns: 0 on success, -1 on error.

             reply	other threads:[~2014-08-27  7:22 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-27  7:22 Chunyan Liu [this message]
2014-09-05  3:18 ` [RFC V6] Libxl Domain Snapshot API Design Chun Yan Liu
2014-09-05 12:44 ` Ian Campbell
2014-09-09  8:43   ` Chun Yan Liu
2014-09-09  9:28     ` Wei Liu
2014-09-09 10:13     ` Ian Campbell
2014-09-10  5:53       ` Chun Yan Liu
2014-09-10 12:17         ` Ian Campbell
2014-09-11  8:30           ` Chun Yan Liu
2014-09-24 12:21             ` Ian Campbell
2014-09-26  3:00               ` Chun Yan Liu

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=1409124146-18249-1-git-send-email-cyliu@suse.com \
    --to=cyliu@suse.com \
    --cc=Ian.Campbell@citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=jfehlig@suse.com \
    --cc=xen-devel@lists.xen.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).