domain snapshot implementation
cover domain snapshot implementation
Add vm snapshot implementation. Support snapshot-create and snapshot-revert.
Current Limitations:
About disk snapshot create, there are many cases:
- qdisk, internal, should calls qmp command to do the work.
- qdisk, external, should calls qmp command to do the work, qemu will replace disk backend file after creating external snapshot.
- nonqdisk, internal, should call 'qemu-img snapshot' to do the work.
- nonqdisk, external, should call 'qemu-img create' to create a new file with the original disk file as backing file. And libxl should replace domain disk from original disk to the new file.
To the last case, during domain snapshot, between domain suspend and resume, how to replace the disk backend file from libxl? Especially if disk file format is changed (original disk backend file is 'raw', new file is 'qcow2')?
Considering this, currently I exclude the non-qdisk cases, let the API support qdisk only. About the non-qdisk and external case, any suggestion?
About disk snapshot revert:
Reverting from external disk snapshot is actually starting domain from a specified backing file, since backing file should be kept read-only, that will involve block copy operation. Currently this case is not supported.
Only support reverting from internal disk snapshot.
Design document:
Latest design document is just posted.
Chunyan Liu (7):
libxl_types.idl: add definitions for vm snapshot
qmp: add qmp handlers to create disk snapshots
libxl: save disk format to xenstore
libxl: add snapshot APIs
xl: add domain snapshot commands
qmp: add qmp handlers to delete internal/external disk snapshot
libxl: add APIs to delete internal/external disk snapshots
Config.mk | 2 +- config/Paths.mk.in | 1 + configure | 3 + docs/man/xl.snapshot.conf.pod.5 | 59 +++ m4/paths.m4 | 3 + tools/configure | 3 + tools/examples/snapshot.cfg.external | 4 + tools/examples/snapshot.cfg.internal | 4 + tools/libxl/Makefile | 2 + tools/libxl/libxl.c | 10 +- tools/libxl/libxl.h | 51 +++ tools/libxl/libxl_internal.h | 38 ++ tools/libxl/libxl_qmp.c | 224 ++++++++++++ tools/libxl/libxl_snapshot.c | 321 +++++++++++++++++ tools/libxl/libxl_types.idl | 31 ++ tools/libxl/libxl_types_internal.idl | 8 + tools/libxl/libxl_utils.c | 16 + tools/libxl/libxl_utils.h | 1 + tools/libxl/xl.h | 2 + tools/libxl/xl_cmdimpl.c | 677 +++++++++++++++++++++++++++++++++++ tools/libxl/xl_cmdtable.c | 16 + 21 files changed, 1474 insertions(+), 2 deletions(-) create mode 100644 docs/man/xl.snapshot.conf.pod.5 create mode 100644 tools/examples/snapshot.cfg.external create mode 100644 tools/examples/snapshot.cfg.internal create mode 100644 tools/libxl/libxl_snapshot.c
Signature · 1 line
2.1.4
RFC PATCH 1/7 add definitions for vm snapshot
Define libxl_disk_snapshot_type and libxl_disk_snapshot for VM snapshot usage.
--- tools/libxl/libxl_types.idl | 31 +++++++++++++++++++++++++++++++ tools/libxl/libxl_types_internal.idl | 8 ++++++++ 2 files changed, 39 insertions(+)
tools/libxl/libxl_types.idl +31 -0
@@ -793,3 +793,34 @@ libxl_psr_cat_info = Struct("psr_cat_info", [ ("cos_max", uint32), ("cbm_len", uint32), ]) + +libxl_disk_snapshot_type = Enumeration("disk_snapshot_type", [ + (0, "INVALID"), + (1, "INTERNAL"), + (2, "EXTERNAL"), + ]) + +libxl_disk_snapshot = Struct("disk_snapshot",[ + # target disk + ("disk", libxl_device_disk), + + # disk snapshot name + ("name", string), + + ("u", KeyedUnion(None, libxl_disk_snapshot_type, "type", + [("external", Struct(None, [ + + # disk format for external files. Since external disk snapshot is + # implemented with backing file mechanism, the external file disk + # format must support backing file. This field can be NULL, then + # a proper disk format will be used by default according to the + # orignal disk format. + ("external_format", libxl_disk_format), + + # external file path. This field should be non-NULL and a new path. + ("external_path", string), + ])), + ("internal", None), + ("invalid", None), + ])), + ])
tools/libxl/libxl_types_internal.idl +8 -0
@@ -45,3 +45,11 @@ libxl__device_action = Enumeration("device_action", [ (1, "ADD"), (2, "REMOVE"), ]) + +libxl_disk_snapshot_op = Enumeration("disk_snapshot_op", [ + (1, "CREATE"), + (2, "DELETE"), + (3, "REVERT"), + (4, "LIST"), + ]) +
Signature · 1 line
2.1.4
RFC PATCH 2/7 qmp: add qmp handlers to create disk snapshots
In reply to Chunyan LiuAdd qmp handlers to take disk snapshots. This will be used when creating a domain snapshots.
--- tools/libxl/libxl_internal.h | 4 +++ tools/libxl/libxl_qmp.c | 66 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+)
tools/libxl/libxl_internal.h +4 -0
@@ -1735,6 +1735,10 @@ _hidden int libxl__qmp_set_global_dirty_log(libxl__gc *gc, int domid, bool enabl _hidden int libxl__qmp_insert_cdrom(libxl__gc *gc, int domid, const libxl_device_disk *disk);/* Add a virtual CPU */ _hidden int libxl__qmp_cpu_add(libxl__gc *gc, int domid, int index); +/* Create disk snapshots for a group of disks in a transaction */ +_hidden int libxl__qmp_disk_snapshot_transaction(libxl__gc *gc, int domid, +libxl_disk_snapshot *snapshot, +int nb);/* close and free the QMP handler */ _hidden void libxl__qmp_close(libxl__qmp_handler *qmp);/* remove the socket file, if the file has already been removed,
tools/libxl/libxl_qmp.c +66 -0
72 lines not on this page · raw message
Signature · 1 line
2.1.4
RFC PATCH 3/7 libxl: save disk format to xenstore
In reply to Chunyan LiuDisk snapshot handling depends on disk format. Currently since disk format is not saved into xenstore, when getting device disk list, disk->format is LIBXL_DISK_FORMAT_UNKNOWN. Disk snapshot cannot continue without correct disk format information, so adding code to save disk format to xenstore so that when getting device disk list, disk->format contains correct information.
--- tools/libxl/libxl.c | 10 +++++++++- tools/libxl/libxl_utils.c | 16 ++++++++++++++++ tools/libxl/libxl_utils.h | 1 + 3 files changed, 26 insertions(+), 1 deletion(-)
tools/libxl/libxl.c +9 -1
@@ -2524,6 +2524,8 @@ static void device_disk_add(libxl__egc *egc, uint32_t domid, goto out; } +flexarray_append (back,"format" ); +flexarray_append (back,libxl__device_disk_string_of_format (disk->format));flexarray_append (back,"frontend-id" );flexarray_append (back,libxl__sprintf (gc,"%d" , domid));flexarray_append (back,"online" );
@@ -2682,7 +2684,13 @@ static int libxl__device_disk_from_xs_be(libxl__gc *gc, } disk->is_cdrom = !strcmp (tmp,"cdrom" ); - disk->format =LIBXL_DISK_FORMAT_UNKNOWN ; + tmp =libxl__xs_read (gc,XBT_NULL , +libxl__sprintf (gc,"%s/format" , be_path)); +if (!tmp) { +LOG (ERROR ,"Missing xenstore node %s/format" , be_path); + goto cleanup; + } +libxl_string_to_format (ctx, tmp, &(disk->format));return 0 ; cleanup:
tools/libxl/libxl_utils.c +16 -0
@@ -322,6 +322,22 @@ out:return rc; } +int libxl_string_to_format (libxl_ctx *ctx,char *s,libxl_disk_format *format) +{ +int rc =0 ; + +if (!strcmp (s,"aio" )) { + *format =LIBXL_DISK_FORMAT_RAW ; + }else if (!strcmp (s,"vhd" )) { + *format =LIBXL_DISK_FORMAT_VHD ; + }else if (!strcmp (s,"qcow" )) { + *format =LIBXL_DISK_FORMAT_QCOW ; + }else if (!strcmp (s,"qcow2" )) { + *format =LIBXL_DISK_FORMAT_QCOW2 ; + } +return rc; +} +int libxl_read_file_contents (libxl_ctx *ctx,const char *filename,void **data_r,int *datalen_r) {GC_INIT (ctx);
tools/libxl/libxl_utils.h +1 -0
@@ -37,6 +37,7 @@ int libxl_get_stubdom_id(libxl_ctx *ctx, int guest_domid);int libxl_is_stubdom (libxl_ctx *ctx,uint32_t domid,uint32_t *target_domid);int libxl_create_logfile (libxl_ctx *ctx,const char *name,char **full_name);int libxl_string_to_backend (libxl_ctx *ctx,char *s,libxl_disk_backend *backend); +int libxl_string_to_format (libxl_ctx *ctx,char *s,libxl_disk_format *format);int libxl_read_file_contents (libxl_ctx *ctx,const char *filename,void **data_r,int *datalen_r);
Signature · 1 line
2.1.4
RFC PATCH 4/7 libxl: add snapshot APIs
In reply to Chunyan LiuAdd snapshot related APIs for xl, including:
create disk snapshots, revert disk snapshots.
Together with existing memory save/restore APIs, xl can create domain snapshot and revert from a domain snapshot.
Limitations:
About disk snapshot create, there are many cases:
- qdisk, internal, should calls qmp command to do the work.
- qdisk, external, should calls qmp command to do the work, qemu will replace disk backend file after creating external snapshot.
- nonqdisk, internal, should call 'qemu-img snapshot' to do the work.
- nonqdisk, external, should call 'qemu-img create' to create a new file with the original disk file as backing file. And libxl should replace domain disk from original disk to the new file.
Problem is: to the last case, during domain snapshot, between domain suspend and resume, how to replace the disk backend file from libxl? Especially if disk file format is changed (original disk backend file is 'raw', new file is 'qcow2') ?
Considering this, currently the API only support qdisk, non-qdisk cases are not included.
About disk snapshot revert:
Reverting from external disk snapshot is actually starting domain from a specified backing file, since backing file should be kept read-only, that will involve block copy operation. Currently this case is not supported.
Only support reverting from internal disk snapshot.
--- tools/libxl/Makefile | 1 + tools/libxl/libxl.h | 6 ++ tools/libxl/libxl_internal.h | 6 ++ tools/libxl/libxl_snapshot.c | 219 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 232 insertions(+) create mode 100644 tools/libxl/libxl_snapshot.c
tools/libxl/Makefile +1 -0
@@ -105,6 +105,7 @@ LIBXL_OBJS = flexarray.o libxl.o libxl_create.o libxl_dm.o libxl_pci.o \ libxl_qmp.o libxl_event.o libxl_fork.o \ libxl_dom_suspend.o $(LIBXL_OBJS-y) LIBXL_OBJS += libxl_genid.o +LIBXL_OBJS += libxl_snapshot.o LIBXL_OBJS += _libxl_types.o libxl_flask.o _libxl_types_internal.o LIBXL_TESTS += timedereg
tools/libxl/libxl.h +6 -0
@@ -1729,6 +1729,12 @@ int libxl_psr_cat_get_l3_info(libxl_ctx *ctx, libxl_psr_cat_info **info,void libxl_psr_cat_info_list_free (libxl_psr_cat_info *list,int nr);#endif +/* Domain snapshot related APIs */ +int libxl_disk_snapshot_create (libxl_ctx *ctx,uint32_t domid, +libxl_disk_snapshot *snapshot,int nb); +int libxl_disk_snapshot_revert (libxl_ctx *ctx,uint32_t domid, +libxl_disk_snapshot *snapshot,int nb); +/* misc */ /* Each of these sets or clears the flag according to whether the
tools/libxl/libxl_internal.h +6 -0
@@ -1749,6 +1749,12 @@ _hidden void libxl__qmp_cleanup(libxl__gc *gc, uint32_t domid); _hidden int libxl__qmp_initializations(libxl__gc *gc, uint32_t domid,const libxl_domain_config *guest_config); +typedef struct libxl__ao_snapshot libxl__ao_snapshot ; +struct libxl__ao_snapshot { +libxl__ao *ao; +libxl__ev_child child; +}; +/* on failure, logs */ int libxl__sendmsg_fds(libxl__gc *gc, int carrier, const void *data, size_t datalen,
tools/libxl/libxl_snapshot.c new file +219 -0
219 lines not on this page · raw message
Signature · 1 line
2.1.4
RFC PATCH 5/7 xl: add domain snapshot commands
In reply to Chunyan LiuAdd domain snapshot create/revert commands implementation.
Since xl is expected to not maintain domain snapshot info itself, it has no idea about how many snapshots and snapshot related files and info, xl won't supply snapshot delete command. It'll depend on users to delete things.
--- Config.mk | 2 +- config/Paths.mk.in | 1 + configure | 3 + docs/man/xl.snapshot.conf.pod.5 | 59 +++ m4/paths.m4 | 3 + tools/configure | 3 + tools/examples/snapshot.cfg.external | 4 + tools/examples/snapshot.cfg.internal | 4 + tools/libxl/Makefile | 1 + tools/libxl/xl.h | 2 + tools/libxl/xl_cmdimpl.c | 677 +++++++++++++++++++++++++++++++++++ tools/libxl/xl_cmdtable.c | 16 + 12 files changed, 774 insertions(+), 1 deletion(-) create mode 100644 docs/man/xl.snapshot.conf.pod.5 create mode 100644 tools/examples/snapshot.cfg.external create mode 100644 tools/examples/snapshot.cfg.internal
Config.mk +1 -1
@@ -159,7 +159,7 @@ endef BUILD_MAKE_VARS := sbindir bindir LIBEXEC LIBEXEC_BIN libdir SHAREDIR \ XENFIRMWAREDIR XEN_CONFIG_DIR XEN_SCRIPT_DIR XEN_LOCK_DIR \ - XEN_RUN_DIR XEN_PAGING_DIR XEN_DUMP_DIR + XEN_RUN_DIR XEN_PAGING_DIR XEN_DUMP_DIR XEN_SNAPSHOT_DIR buildmakevars2file = $(eval $(call buildmakevars2file-closure,$(1))) define buildmakevars2file-closure
config/Paths.mk.in +1 -0
@@ -49,6 +49,7 @@ BASH_COMPLETION_DIR := $(CONFIG_DIR)/bash_completion.d XEN_LOCK_DIR := @XEN_LOCK_DIR@ XEN_PAGING_DIR := @XEN_PAGING_DIR@ XEN_DUMP_DIR := @XEN_DUMP_DIR@ +XEN_SNAPSHOT_DIR := @XEN_SNAPSHOT_DIR@ XENFIRMWAREDIR := @XENFIRMWAREDIR@
configure +3 -0
@@ -595,6 +595,7 @@ tools xen subdirs XEN_DUMP_DIR +XEN_SNAPSHOT_DIR XEN_PAGING_DIR XEN_LOCK_DIR XEN_SCRIPT_DIR
@@ -1984,6 +1985,8 @@ XEN_PAGING_DIR=$localstatedir/lib/xen/xenpaging XEN_DUMP_DIR=$xen_dumpdir_path +XEN_SNAPSHOT_DIR=$localstatedir/lib/xen/snapshot + case "$host_cpu" in i[3456]86|x86_64)
docs/man/xl.snapshot.conf.pod.5 new file +59 -0
59 lines not on this page · raw message
m4/paths.m4 +3 -0
@@ -122,4 +122,7 @@ AC_SUBST(XEN_PAGING_DIR) XEN_DUMP_DIR=$xen_dumpdir_path AC_SUBST(XEN_DUMP_DIR) + +XEN_SNAPSHOT_DIR=$localstatedir/lib/xen/snapshot +AC_SUBST(XEN_SNAPSHOT_DIR) ])
tools/configure +3 -0
@@ -716,6 +716,7 @@ monitors githttp rpath XEN_DUMP_DIR +XEN_SNAPSHOT_DIR XEN_PAGING_DIR XEN_LOCK_DIR XEN_SCRIPT_DIR
@@ -3950,6 +3951,8 @@ XEN_PAGING_DIR=$localstatedir/lib/xen/xenpaging XEN_DUMP_DIR=$xen_dumpdir_path +XEN_SNAPSHOT_DIR=$localstatedir/lib/xen/snapshot + # Enable/disable options
tools/examples/snapshot.cfg.external new file +4 -0
@@ -0,0 +1,4 @@ +name="1439280121" +memory=1 +memory_path="/var/lib/xen/snapshot/646d7709-7974-3e8b-03c0-e415ae619b97/1439280121/1439280121.save" +disks=['/var/lib/xen/snapshot/646d7709-7974-3e8b-03c0-e415ae619b97/1439280121/xvda_1439280121.qcow2,qcow2,xvda',]
tools/examples/snapshot.cfg.internal new file +4 -0
@@ -0,0 +1,4 @@ +name="1439280559" +memory=1 +memory_path="/var/lib/xen/snapshot/646d7709-7974-3e8b-03c0-e415ae619b97/1439280559/1439280559.save" +disks=[',,xvda']
tools/libxl/Makefile +1 -0
@@ -280,6 +280,7 @@ install: all $(INSTALL_DIR) $(DESTDIR)$(BASH_COMPLETION_DIR) $(INSTALL_DIR) $(DESTDIR)$(LIBEXEC_BIN) $(INSTALL_DIR) $(DESTDIR)$(SHAREDIR)/pkgconfig + $(INSTALL_DIR) -m 0700 $(DESTDIR)$(XEN_SNAPSHOT_DIR) $(INSTALL_PROG) xl $(DESTDIR)$(sbindir) $(INSTALL_PROG) xen-init-dom0 $(DESTDIR)$(LIBEXEC_BIN) $(INSTALL_PROG) libxl-save-helper $(DESTDIR)$(LIBEXEC_BIN)
tools/libxl/xl.h +2 -0
@@ -121,6 +121,8 @@ int main_psr_cmt_show(int argc, char **argv);int main_psr_cat_cbm_set (int argc,char **argv);int main_psr_cat_show (int argc,char **argv);#endif +int main_snapshot_create (int argc,char **argv); +int main_snapshot_revert (int argc,char **argv);void help (const char *command);
tools/libxl/xl_cmdimpl.c +677 -0
689 lines not on this page · raw message
tools/libxl/xl_cmdtable.c +16 -0
@@ -551,6 +551,22 @@ struct cmd_spec cmd_table[] = { },#endif + {"snapshot-create" , + &main_snapshot_create,1 ,1 , +"create a snapshot (disk and RAM) of a domain." , +"[--live] [--internal|--external] [--path=path] <Domain> [<ConfigFile>]" , +"-l,--live take a live snapshot\n" +"-i,--internal take internal disk snapshots to all disks\n" +"-e,--external take external disk snapshots to all disks\n" +"-p,--path path to store snapshot data" + }, + { "snapshot-revert", + &main_snapshot_revert,1 ,1 , +"revert domain to status of a snapshot." , +"[--pause] [--force] <Domain> <ConfigFile>" , +"-p,--pause keep domain paused after the revert\n" +"-f,--force try harder on risky revert" + }, };int cmdtable_len =sizeof (cmd_table)/sizeof (struct cmd_spec );
Signature · 1 line
2.1.4
RFC PATCH 6/7 qmp: add qmp handlers to delete internal/external disk snapshot
In reply to Chunyan LiuXl doesn't maintain domain snapshot info and has no idea of snapshot info and related files after creation, so it doesn't supply domain snapshot delete command. These qmp handlers won't be used by xl.
But for libvirt, it maintains domain snapshot info itself and supplies snapshot delete commands, and so needs APIs from libxl to delete internal/external disk snapshots. To libvirt, these qmp handlers are userful.
--- tools/libxl/libxl.h | 17 +++++ tools/libxl/libxl_internal.h | 28 ++++++++ tools/libxl/libxl_qmp.c | 158 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 203 insertions(+)
tools/libxl/libxl.h +17 -0
@@ -1730,6 +1730,23 @@ void libxl_psr_cat_info_list_free(libxl_psr_cat_info *list, int nr);#endif /* Domain snapshot related APIs */ + +/* structure to retrieve qmp block job status */ +typedef struct libxl_block_job_info +{ +char *disk_vdev; +const char *type; +unsigned long speed; +/* The following fields provide an indication of block job progress. +* @current indicates the current position and will be between 0 and @end. +* @end is the final cursor position for this operation and represents +* completion. +* To approximate progress, divide @cur by @end. +*/ +unsigned long long current; +unsigned long long end; +}libxl_block_job_info ; +int libxl_disk_snapshot_create (libxl_ctx *ctx,uint32_t domid,libxl_disk_snapshot *snapshot,int nb); int libxl_disk_snapshot_revert(libxl_ctx *ctx, uint32_t domid,
tools/libxl/libxl_internal.h +28 -0
@@ -1739,6 +1739,34 @@ _hidden int libxl__qmp_cpu_add(libxl__gc *gc, int domid, int index); _hidden int libxl__qmp_disk_snapshot_transaction(libxl__gc *gc, int domid,libxl_disk_snapshot *snapshot,int nb); +/* Delete a disk snapshot */ +_hidden int libxl__qmp_disk_snapshot_delete(libxl__gc *gc, int domid, +libxl_disk_snapshot *snapshot); +/* shorten backing file chain. Merge base to top */ +_hidden int libxl__qmp_block_commit(libxl__gc *gc, uint32_t domid, +libxl_device_disk *disk, +const char *base,const char *top, +const char *backing_file, +unsigned long bandwidth); +/* shorten backing file chain. Merge top to base */ +_hidden int libxl__qmp_block_stream(libxl__gc *gc, uint32_t domid, +libxl_device_disk *disk, +const char *base, +const char *backing_file, +unsigned long long bandwidth, +const char *error); +/* query qmp block job status */ +_hidden int libxl__qmp_query_block_job(libxl__gc *gc, uint32_t domid, +libxl_device_disk *disk, +libxl_block_job_info *info); +/* cancel a qmp block job */ +_hidden int libxl__qmp_block_job_cancel(libxl__gc *gc, uint32_t domid, +libxl_device_disk *disk, +bool force); + +/* complete a qmp block job */ +_hidden int libxl__qmp_block_job_complete(libxl__gc *gc, uint32_t domid, +libxl_device_disk *disk);/* close and free the QMP handler */ _hidden void libxl__qmp_close(libxl__qmp_handler *qmp);/* remove the socket file, if the file has already been removed,
tools/libxl/libxl_qmp.c +158 -0
164 lines not on this page · raw message
Signature · 1 line
2.1.4
RFC PATCH 7/7 libxl: add APIs to delete internal/external disk snapshots
In reply to Chunyan LiuCurrently this group of APIs are not used by xl toolstack since xl doesn't maintain domain snapshot info and so depends on user to delete things.
But for libvirt, they are very useful since libvirt maintains domain snapshot info itself and needs these APIs to delete internal/external disk snapshots.
--- tools/libxl/libxl.h | 28 ++++++++++++ tools/libxl/libxl_snapshot.c | 102 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 130 insertions(+)
tools/libxl/libxl.h +28 -0
@@ -1752,6 +1752,34 @@ int libxl_disk_snapshot_create(libxl_ctx *ctx, uint32_t domid,int libxl_disk_snapshot_revert (libxl_ctx *ctx,uint32_t domid,libxl_disk_snapshot *snapshot,int nb); +/* delete internal disk snapshot */ +int libxl_disk_snapshot_delete (libxl_ctx *ctx,uint32_t domid, +libxl_disk_snapshot *snapshot,int nb); +/* next 4 functions deal with external disk snapshot */ +/* shorten backing file chain. Merge from top to base */ +int libxl_domain_block_rebase (libxl_ctx *ctx,uint32_t domid, +libxl_device_disk *disk, +const char *base, +const char *backing_file, +unsigned long long bandwidth); +/* shorten backing file chain. Merge from base to top */ +int libxl_domain_block_commit (libxl_ctx *ctx,uint32_t domid, +libxl_device_disk *disk, +const char *top, +const char *base, +const char *backing_file, +unsigned long long bandwidth); +/* query a block job status, can get job type, speed, progress status */ +int libxl_domain_block_job_query (libxl_ctx *ctx,uint32_t domid, +libxl_device_disk *disk, +libxl_block_job_info *info); +/* abort a block job. If the job is finished, complete it. +* otherwise, cancel it. +*/ +int libxl_domain_block_job_abort (libxl_ctx *ctx,uint32_t domid, +libxl_device_disk *disk, +bool force); +/* misc */ /* Each of these sets or clears the flag according to whether the
tools/libxl/libxl_snapshot.c +102 -0
105 lines not on this page · raw message
Signature · 1 line
2.1.4
ping?
Quoted 1 line
Quoted 1 line
Quoted 1 line
On 8/11/2015 at 06:44 PM, in message
<[email protected]>, Chunyan Liu
Quoted 71 lines · <[email protected]> wrote:
Add vm snapshot implementation. Support snapshot-create and snapshot-revert.
Current Limitations:
About disk snapshot create, there are many cases:
- qdisk, internal, should calls qmp command to do the work.
- qdisk, external, should calls qmp command to do the work, qemu will replace disk backend file after creating external snapshot.
- nonqdisk, internal, should call 'qemu-img snapshot' to do the work.
- nonqdisk, external, should call 'qemu-img create' to create a new file with the original disk file as backing file. And libxl should replace domain disk from original disk to the new file.To the last case, during domain snapshot, between domain suspend and resume, how to replace the disk backend file from libxl? Especially if disk file format is changed (original disk backend file is 'raw', new file is 'qcow2')?
Considering this, currently I exclude the non-qdisk cases, let the API support qdisk only. About the non-qdisk and external case, any suggestion?
About disk snapshot revert:
Reverting from external disk snapshot is actually starting domain from a specified backing file, since backing file should be kept read-only, that will involve block copy operation. Currently this case is not supported.
Only support reverting from internal disk snapshot.
Design document:
Latest design document is just posted.
Chunyan Liu (7):
libxl_types.idl: add definitions for vm snapshot
qmp: add qmp handlers to create disk snapshots
libxl: save disk format to xenstore
libxl: add snapshot APIs
xl: add domain snapshot commands
qmp: add qmp handlers to delete internal/external disk snapshot
libxl: add APIs to delete internal/external disk snapshotsConfig.mk | 2 +- config/Paths.mk.in | 1 + configure | 3 + docs/man/xl.snapshot.conf.pod.5 | 59 +++ m4/paths.m4 | 3 + tools/configure | 3 + tools/examples/snapshot.cfg.external | 4 + tools/examples/snapshot.cfg.internal | 4 + tools/libxl/Makefile | 2 + tools/libxl/libxl.c | 10 +- tools/libxl/libxl.h | 51 +++ tools/libxl/libxl_internal.h | 38 ++ tools/libxl/libxl_qmp.c | 224 ++++++++++++ tools/libxl/libxl_snapshot.c | 321 +++++++++++++++++ tools/libxl/libxl_types.idl | 31 ++ tools/libxl/libxl_types_internal.idl | 8 + tools/libxl/libxl_utils.c | 16 + tools/libxl/libxl_utils.h | 1 + tools/libxl/xl.h | 2 + tools/libxl/xl_cmdimpl.c | 677 +++++++++++++++++++++++++++++++++++ tools/libxl/xl_cmdtable.c | 16 + 21 files changed, 1474 insertions(+), 2 deletions(-) create mode 100644 docs/man/xl.snapshot.conf.pod.5 create mode 100644 tools/examples/snapshot.cfg.external create mode 100644 tools/examples/snapshot.cfg.internal create mode 100644 tools/libxl/libxl_snapshot.c