[libvirt] [RFC]: Snapshot API

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

 



Hello,
     As some of you know, I've been working on a new snapshot API.
This API is heavily based on DanB's earlier API proposed here:

https://www.redhat.com/archives/libvir-list/2010-January/msg00626.html

I've made some modifications to make it more libvirt-ish, and to add a
couple of features I think it lacked.  The full documentation is below.
Any comments are appreciated.

/* NOTE: struct _virDomainSnapshot is a private structure, ala
 * struct _virDomain.
 */
typedef struct _virDomainSnapshot virDomainSnapshot;

/* Take a snapshot of the current VM state */
virDomainSnapshotPtr virDomainSnapshotCreateXML(virDomainPtr domain,
                                                const char *xmlDesc,
                                                unsigned int flags);

/* Dump the XML of a snapshot */
/* NOTE: see below for proposed XML */
char *virDomainSnapshotGetXMLDesc(virDomainSnapshotPtr snapshot,
                                  unsigned int flags);

/* Return the number of snapshots for this domain */
int virDomainSnapshotNum(virDomainPtr domain, unsigned int flags);

/* Get the names of all snapshots for this domain */
int virDomainListSnapshotNames(virDomainPtr domain, char **names, int nameslen,
                               unsigned int flags);

/* Get a handle to a named snapshot */
virDomainSnapshotPtr virDomainSnapshotLookupByName(virDomainPtr domain,
                                                   const char *name,
                                                   unsigned int flags);

/* Set this snapshot as the current one for a domain, to be
 * used next time domain is started */
int virDomainSnapshotActivate(virDomainSnapshotPtr snapshot,
                              unsigned int flags);

/* Deactivate a snapshot - with no flags, the snapshot is not used anymore,
 * but also not removed.  With a MERGE flag, it merges the snapshot into
 * the base image.  With a DISCARD flag, it deletes the snapshot.  MERGE
 * and DISCARD are mutually-exclusive.  Note that this operation can
 * generally only happen when the domain is shut down, though this is
 * hypervisor-specific */
typedef enum {
    VIR_DOMAIN_SNAPSHOT_DEACTIVATE_MERGE,
    VIR_DOMAIN_SNAPSHOT_DEACTIVATE_DISCARD,
} virDomainSnapshotDeactivate;
int virDomainSnapshotDeactivate(virDomainSnapshotPtr snapshot,
                                unsigned int flags);

int virDomainSnapshotFree(virDomainSnapshotPtr snapshot);

NOTE: During snapshot creation, *none* of the fields are required.  That is,
you can call virDomainSnapshotCreateXML() with an XML of "<domainsnapshot/>".
In this case, the individual driver will make up a <name> for you, the
<creationdate> will be set to the current time+date, <description> will be
empty, <state> will be "off", <compression> will be empty, and <parent> will
be empty.  If you do want to specify some fields during
virDomainSnapshotCreateXML(), note that the only ones that are settable are
<name>, <description>, <compression>, and <parent>; the rest are ignored,
and filled in by the driver when the snapshot is actually created.
NOTE: <parent> is used to create "trees" of snapshots, and may or may not be
supported by individual hypervisor implementations.  If <parent> is specified
and the underlying hypervisor does not support it, an error will be thrown.
NOTE: <compression> is used to compress snapshots, and may or may not be
supported by individual hypervisor implementations.  If <compression> is
specified and the underlying hypervisor does not support it, an error will
be thrown.

<domainsnapshot>
   <name>XYZ</name>
   <creationdate>...</creationdate>
   <description>
      ....blah....
   </description>
   <state>RUNNING</state>
   <domain>
      <uuid>XXXXX-XXXX-XXXX-XXXX-XXXXXXXXX</uuid>
   </domain>
   <compression>gzip</compression>
   <parent>
     <name>ABC</name>
   </parent>
</domainsnapshot>

The virsh commands will be:
virsh snapshot-create [--compress] <dom> <xmlfile>
virsh snapshot-list <dom>
virsh snapshot-dumpxml <dom> <name>
virsh snapshot-activate <dom> <snapshotname>
virsh snapshot-deactivate <dom> <snapshotname> [--merge|--delete]


-- 
Chris Lalancette

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]