[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [RFC V9 4/4] domain snapshot design: libxl/libxlu



Changes to V8:
  * remove libxl_domain_snapshot_create/delete/revert API
  * export disk snapshot functionality for both xl and libvirt usage

===========================================================================
Libxl/libxlu Design

1. New Structures

libxl_disk_snapshot = Struct("disk_snapshot",[
    # target disk
    ("disk",            libxl_device_disk),

    # disk snapshot name
    ("name",            string),

    # internal/external disk snapshot?
    ("external",        bool),

    # for external disk snapshot, specify following two field
    ("external_format", string),
    ("external_path",   string),
    ])


2. New Functions

Since there're already APIs for saving memory (libxl_domain_suspend)
and restoring domain from saved memory (libxl_domain_create_restore), to
xl domain snapshot tasks, the missing part is disk snapshot functionality.
And the disk snapshot functionality would be used by libvirt too.

Considering there is qmp handling in creating/deleting disk snapshot,
will add following new functions to libxl (?):

int libxl_disk_snapshot_create(libxl_ctx *ctx, uint32_t domid,
                               libxl_disk_snapshot *snapshot, int nb);

    Taking disk snapshots to a group of domain disks according to
    configuration. For qcow2 disk backend type, it will call qmp
    "transaction" command to do the work. For other disk backend types,
    might call other external commands.

    Parameters:
       ctx (INPUT):
           context
       domid (INPUT):
           domain id
       snapshot (INPUT):
           array of disk snapshot configuration. Has "nb" members.

           libxl_device_disk:
               structure to represent which disk.
           name:
               snapshot name.
           external:
               internal snapshot or external snapshot.
               'false' means internal disk snapshot. external_format and
               external_path will be ignored.
               'true' means external disk snapshot, then external_format
               and external_path should be provided.
           external_format:
               Should be provided when 'external' is true. If not provided,
               will use default format proper to the backend file.
               Ignored when 'external' is false.
           external_path:
               Must be provided when 'external' is true.
               Ignored when 'external' is false.
       nb (INPUT):
           number of disks that need to take disk snapshot.

    Return:
       0 on success, -1 on error.


/*  This API might not be used by xl, since xl won't take care of deleting
 *  snapshots. But for libvirt, since libvirt manages snapshots and will
 *  delete snapshot, this API will be used.
 */
int libxl_disk_snapshot_delete(libxl_ctx *ctx, uint32_t domid,
                               libxl_disk_snapshot *snapshot, int nb);

    Delete disk snapshot of a group of domain disks according to
    configuration. For qcow2 disk backend type, it will call qmp command
    to delete internal disk snapshot. For other disk backend types, might
    call other external commands.

    Parameters:
       ctx (INPUT):
           context
       domid (INPUT):
           domain id
       snapshot (INPUT):
           array of disk snapshot configuration. Has "nb" members.
       nb (INPUT):
           number of disks that need to take disk snapshot.

    Return:
       0 on success, -1 on error.


int libxl_disk_to_snapshot(libxl_ctx *ctx, uint32_t domid,
                           libxl_disk_snapshot **snapshot, int *num);

    This is for domain snapshot create. If user doesn't specify disks,
    then by default it will take internal disk snapshot to each domain
    disk. This function will fill libxl_disk_snapshot according to domain
    disks info.

    Parameters:
       ctx (INPUT):
           context
       domid (INPUT):
           domain id
       snapshot (OUTPUT):
           array of disk snapshot configuration.
       num (OUTPUT):
           number of disks.

    Return:
       0 on success, -1 on error.



For disk snapshot revert, no qmp command for that, it always calls
external commands to finish the work, so put in libxlu (?):

int xlu_disk_snapshot_revert(libxl_disk_snapshot *snapshot, int nb);

    Apply disk snapshot for a group of disks according to configuration. To
    different disk backend types, call different external commands to do
    the work.

    Parameters:
       snapshot (INPUT):
           array of disk snapshot configuration. Has "nb" members.
       nb (INPUT):
           number of disks that need to take disk snapshot.

    Return:
       0 on success, -1 on error.



3. Simple Architecture View

Creating domain snapshot:
(* means new functions we will need in libxl/libxlu)

  "xl snapshot-create"
         |
  parse configuration ----> libxl_disk_to_snapshot (*)
         |
  saving memory ----> libxl_domain_suspend
         |
 taking disk snapshot ----> libxl_disk_snapshot_create (*)
         |                     |
         |                     --> libxl_qmp_disk_snapshot_transaction (*)
         |
    unpause domain ---->libxl_domain_unpause
         |
        End


Reverting to a snapshot:
(* means new functions we will need in libxl/libxlu)

  "xl snapshot-revert"
         |
   parse configuration
         |
   destroy domain ---->libxl_domain_destroy
         |
 reverting disk snapshot ----> xlu_disk_snapshot_revert (*)
         |                       |
         |                       --> call 'qemu-img' to apply disk snapshot
         |
 restore domain from saved memory ----> libxl_domain_create_restore
         |
        End

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.