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

[Xen-devel] [RFC v2] vm snapshot documents



Hi,

here is the second version about vm snapshot documents, the first version is
here[1]

thanks Ian Jackson suggestion, i write this doc about vm snapshot including new
command, struct and api. currently, the disk snapshot(create, delete, list)
worked(patch is already sent[2]), and vm snapshot(create, delete, list) work.
but i have some questions about snapshot apply(see the last section).

feel free to comment it. thanks.

1, new command
=head1 SNAPSHOT

there are two types of snapshots supported by libxl: disk snapshot and vm
snapshot. The following subcommands management the snapshot of a domain,
including create, delete, list and apply.
a domain snapshot(or a vm snapshot) means save the domain config, memory and
disk snapshot. currently, only support qcow2 and internal disk snapshot.

the vm snapshot information will store in the follow path:
/var/lib/xen/snapshots/<domain_uuid>/snapshotdata-<snapshot_name>.xl

here is an example for snapshot information file:
snapshot_name="1397207577"
snapshot_creationtime="1397207577"
snapshot_save="/var/lib/xen/snapshots/5c84adcc-bd59-788a-96d2-195f9b599cfe/1397207577.save"

the user could give a snapshot name when vm snapshot created. if not, the epoch
seconds will set as name as the above examples.

=over 4

=item B<vm-snapshot-create> [I<OPTIONS>] I<domain-id>

create vm snapshot.
it will call the qmp transaction for creating the disk snapshot in order to
ensure the disk snapshot is coherence.
vm is paused during snapshot create, and is unpause after take snapshot
finished.

B<OPTIONS>

=over 4

=item B<-n>

vm snapshot name

=back

=item B<vm-snapshot-delete> [I<OPTIONS>] I<domain-id>

delete vm snapshot.
delete the saved memory file and snapshot information file created by
vm-snapshot-create.

B<OPTIONS>

=over 4

=item B<-n>

vm snapshot name

=back

=item B<vm-snapshot-list> I<domain-id>

list vm snapshot for the dedicated domain including snapshot name and creation
time which stored in the vm snapshot information file.

=item B<vm-snapshot-apply> [I<OPTIONS>] I<domain-id>

apply vm snapshot for the dedicated domain.

B<OPTIONS>

=over 4

=item B<-n>

vm snapshot name

=back

=item B<disk-snapshot-create> [I<OPTIONS>] I<domain-id>

create disk snapshot.

B<OPTIONS>

=over 4

=item B<-n>

disk snapshot name

=back

=item B<disk-snapshot-delete> [I<OPTIONS>] I<domain-id>

delete disk snapshot by snapshot name or snapshot id.

B<OPTIONS>

=over 4

=item B<-i>

disk snapshot id

=item B<-n>

disk snapshot name

=back

=item B<disk-snapshot-list> I<domain-id>

list disk snapshot including snapshot id, tag, vm size, date, vm clock.

=back

2, new struct and new api
1), new struct
(1), libxl_snapshot struct store a disk snapshot information, which get from
qcow2 image through "query-block" qmp command.

libxl_snapshot = Struct("snapshot",[
    ("device",        string),
    ("name",          string),
    ("id",            string),
    ("vm_state_size", uint64),
    ("date_sec",      uint64),
    ("date_nsec",     uint64),
    ("vm_clock_sec",  uint64),
    ("vm_clock_nsec", uint64),

(2), libxl_vm_snapshot store vm snapshot information which store in the path
shown above. i add some api for create, delete and list these information.
at first, i want to add these information to xenstore, but it will lose when
xenstore reboot or dom0 reboot.

libxl_vm_snapshot = Struct("vm_snapshot",[
    ("name",          string),
    ("creation_time", uint64),
    ("save",          string),
    ])

2), new api
(1), in libxl/libxl.h
/* disk snapshot api
 * support create, delete and list for internal snapshot of a single disk
 * only support internal snapshot rigt now.
 */
/* create disk snapshot according to the device name in snapshot array. nb is
 * the number of snapshot array.
 * use the qmp transaction to ensure all snapshot of disk is coherence.
 */
int libxl_disk_snapshot_create(libxl_ctx *ctx, int domid,
                               libxl_snapshot *snapshot, int nb);
/* delete number of nb disk snapshot describe in snapshot array
 */
int libxl_disk_snapshot_delete(libxl_ctx *ctx, int domid,
                               libxl_snapshot *snapshot, int nb);
int libxl__disk_snapshot_delete(libxl_ctx *ctx, int domid,
                                libxl_snapshot *snapshot);
/* apply the disk snapshot by qemu-img command
 */
int libxl_disk_snapshot_apply(libxl_ctx *ctx, int domid,
                              libxl_snapshot *snapshot, int nb);
/* list disk snapshot by qmp query-block command
 */
int libxl__disk_snapshot_list(libxl_ctx *ctx, int domid,
                              libxl_snapshot **snapshotp);

/* vm snapshot api
 */
/* write vm snapshot information to file
 */
int libxl_vm_snapshot_add(libxl_ctx *ctx, uint32_t domid,
                          libxl_vm_snapshot *snapshot,
                          const libxl_asyncop_how *ao_how)
                          LIBXL_EXTERNAL_CALLERS_ONLY;
/* delete vm snapshot information file
 */
int libxl_vm_snapshot_remove(libxl_ctx *ctx, uint32_t domid,
                             libxl_vm_snapshot *snapshot,
                             const libxl_asyncop_how *ao_how)
                             LIBXL_EXTERNAL_CALLERS_ONLY;
/* list vm snapshot from file
 */
libxl_vm_snapshot *libxl_vm_snapshot_list(libxl_ctx *ctx, uint32_t domid,
                                          int *num)
                                          LIBXL_EXTERNAL_CALLERS_ONLY;
/* read vm snapshot information from dedicated file
 */
int libxl_vm_snapshot_getinfo(libxl_ctx *ctx, uint32_t domid,
                              libxl_vm_snapshot *snapshot);
/* delete vm save image */
int libxl_vm_snapshot_delete_save_image(libxl_ctx *ctx,
                                        libxl_vm_snapshot *snapshot);

(2), libxl/xl_cmdimpl.c
/* get disk device name (hda, hdc..) and image path through
 * libxl_device_disk_list and libxl_device_disk_getinfo
 */
static int get_disk(uint32_t domid, libxl_snapshot **snapshotp, char *name);

3, question
1), how to do disk snapshot apply?
when i apply the vm snapshot, i need to revert the disk snapshot. in qemu, it is
done by bdrv_snapshot_goto api. this api is only called by loadvm hmp or
qemu-img commands.
there is no hmp api in libxl. so the only choice is using qemu-img command.
i know usually i should call qmp for qemu operation. but there is not qmp at
the moment, could i call qemu-img in libxl for disk snapshot apply?

[1] http://lists.xen.org/archives/html/xen-devel/2014-04/msg00414.html
[2] http://lists.xen.org/archives/html/xen-devel/2014-04/msg00244.html



_______________________________________________
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®.