COarse-grain LOck-stepping Virtual Machines for Non-stop Service
v10 cover COarse-grain LOck-stepping Virtual Machines for Non-stop Service
This patchset implemented the COLO feature for Xen. For detail/install/use of COLO feature, refer to:
http://wiki.xen.org/wiki/COLO_-_Coarse_Grain_Lock_Stepping
This patchset is based on:
1. http://lists.xenproject.org/archives/html/xen-devel/2016-02/msg02515.html
You can get the codes from here:
https://github.com/wencongyang/xen/tree/colo_v10
Changlog from v9 to v10
1. Rebased to the upstream xen
2. Fix one bug found in the test
3. Merge some patches from prepare series
4. Split patch 5 to two patches(patch 4 and 5) according to the comments from Wei Liu
Changlog from v8 to v9:
1. Rebased to the upstream xen
2. Fix some bugs found in the test
Changelog from v7 to v8:
1. Rebased to the latest libxl migration v2.
Changelog from v6 to v7:
1. Ported to Libxl migration v2
2. Send dirty bitmap from secondary to primary on libxc side
3. Address review comments
Changelog from v5 to v6:
1. based on migration v2(libxc)
2. split the patchset into prerequisite patchset and this main patchset.
Changelog from v4 to v5:
1. rebase to the latest xen upstream
2. disk replication: blktap2->qdisk
3. nic replication: colo-agent->colo-proxy
Changelog from v3 to v4:
1. rebase to newest xen
2. bug fix
Changlog from v2 to v3:
1. rebase to newest remus
2. add nic replication support
Changlog from v1 to v2:
1. rebase to newest remus
2. add disk replication support
Wen Congyang (31):
tools/libxl: introduce libxl__domain_restore_device_model to load qemu
state
tools/libxl: introduce libxl__domain_common_switch_qemu_logdirty() tools/libxl: Add back channel to allow migration target send data back tools/libxl: Introduce new helper function dup_fd_helper() tools/libx{l,c}: add back channel to libxc
docs: add colo readme
docs/libxl: Introduce CHECKPOINT_CONTEXT to support migration v2 colo
streams
libxc/migration: Specification update for DIRTY_PFN_LIST records libxc/migration: export read_record for common use tools/libxl: add back channel support to write stream tools/libxl: write checkpoint_state records into the stream tools/libxl: add back channel support to read stream tools/libxl: handle checkpoint_state records in a libxl migration v2
read stream
tools/libx{l,c}: introduce wait_checkpoint callback tools/libx{l,c}: add postcopy/suspend callback to restore side secondary vm suspend/resume/checkpoint code
primary vm suspend/resume/checkpoint code
libxc/restore: support COLO restore
libxc/restore: send dirty pfn list to primary when checkpoint under
colo
send store gfn and console gfn to xl before resuming secondary vm libxc/save: support COLO save
implement the cmdline for COLO
COLO: introduce new API to prepare/start/do/get_error/stop replication Support colo mode for qemu disk
COLO: use qemu block replication
COLO proxy: implement setup/teardown of COLO proxy module COLO proxy: preresume, postresume and checkpoint
COLO nic: implement COLO nic subkind
setup and control colo proxy on primary side
setup and control colo proxy on secondary side
cmdline switches and config vars to control colo-proxy
docs/README.colo | 9 + docs/man/xl.conf.pod.5 | 6 + docs/man/xl.pod.1 | 11 +- docs/misc/xl-disk-configuration.txt | 50 ++ docs/specs/libxc-migration-stream.pandoc | 24 +- docs/specs/libxl-migration-stream.pandoc | 25 +- tools/hotplug/Linux/Makefile | 1 + tools/hotplug/Linux/colo-proxy-setup | 135 ++++ tools/libxc/include/xenguest.h | 40 +- tools/libxc/xc_nomigrate.c | 4 +- tools/libxc/xc_sr_common.c | 80 ++- tools/libxc/xc_sr_common.h | 26 +- tools/libxc/xc_sr_restore.c | 246 +++++-- tools/libxc/xc_sr_save.c | 109 ++- tools/libxc/xc_sr_stream_format.h | 31 +- tools/libxl/Makefile | 4 + tools/libxl/libxl.c | 100 ++- tools/libxl/libxl.h | 29 +- tools/libxl/libxl_colo.h | 36 + tools/libxl/libxl_colo_nic.c | 321 +++++++++ tools/libxl/libxl_colo_proxy.c | 292 ++++++++ tools/libxl/libxl_colo_qdisk.c | 226 +++++++ tools/libxl/libxl_colo_restore.c | 1091 ++++++++++++++++++++++++++++++ tools/libxl/libxl_colo_save.c | 721 ++++++++++++++++++++ tools/libxl/libxl_create.c | 86 ++- tools/libxl/libxl_device.c | 54 ++ tools/libxl/libxl_dm.c | 184 ++++- tools/libxl/libxl_dom_save.c | 124 ++-- tools/libxl/libxl_internal.h | 247 +++++-- tools/libxl/libxl_qmp.c | 106 +++ tools/libxl/libxl_save_callout.c | 52 +- tools/libxl/libxl_save_helper.c | 8 +- tools/libxl/libxl_save_msgs_gen.pl | 13 +- tools/libxl/libxl_sr_stream_format.h | 11 + tools/libxl/libxl_stream_read.c | 96 ++- tools/libxl/libxl_stream_write.c | 86 ++- tools/libxl/libxl_types.idl | 11 + tools/libxl/libxlu_disk_l.l | 7 + tools/libxl/xl.c | 3 + tools/libxl/xl.h | 1 + tools/libxl/xl_cmdimpl.c | 107 ++- tools/libxl/xl_cmdtable.c | 4 +- tools/ocaml/libs/xl/xenlight_stubs.c | 2 +- tools/python/xen/migration/libxc.py | 68 +- tools/python/xen/migration/libxl.py | 9 + 45 files changed, 4567 insertions(+), 329 deletions(-) create mode 100644 docs/README.colo create mode 100755 tools/hotplug/Linux/colo-proxy-setup create mode 100644 tools/libxl/libxl_colo.h create mode 100644 tools/libxl/libxl_colo_nic.c create mode 100644 tools/libxl/libxl_colo_proxy.c create mode 100644 tools/libxl/libxl_colo_qdisk.c create mode 100644 tools/libxl/libxl_colo_restore.c create mode 100644 tools/libxl/libxl_colo_save.c
Signature · 1 line
2.5.0
PATCH v10 1/31 tools/libxl: introduce libxl__domain_restore_device_model to load qemu state
In normal migration, the qemu state is passed to qemu as a parameter. With COLO, secondary vm is running. So we will do the following steps at every checkpoint:
1. suspend both primary vm and secondary vm
2. sync the state
3. resume both primary vm and secondary vm
Primary will send qemu's state in step2, and secondary's qemu should read it and restore the state before it is resumed. We can not pass the state to qemu as a parameter because secondary QEMU already started at this point, so we introduce libxl__domain_restore_device_model() to do it. This API MUST be called before resuming secondary vm.
--- tools/libxl/libxl_dom_save.c | 20 ++++++++++++++++++++ tools/libxl/libxl_internal.h | 4 ++++ tools/libxl/libxl_qmp.c | 10 ++++++++++ 3 files changed, 34 insertions(+)
tools/libxl/libxl_dom_save.c +20 -0
@@ -512,6 +512,26 @@ int libxl__restore_emulator_xenstore_data(libxl__domain_create_state *dcs,return rc; } +int libxl__domain_restore_device_model (libxl__gc *gc,uint32_t domid, +const char *restore_file) +{ +int rc; + +switch (libxl__device_model_version_running (gc, domid)) { +case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL : +/* Will never be supported. */ + rc =ERROR_INVAL ; +break ; +case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN : + rc =libxl__qmp_restore (gc, domid, restore_file); +break ; +default : + rc =ERROR_INVAL ; + } + +return rc; +} +/* * Local variables: * mode: C
tools/libxl/libxl_internal.h +4 -0
@@ -1119,6 +1119,8 @@ _hidden int libxl__domain_rename(libxl__gc *gc, uint32_t domid, const char *old_name, const char *new_name, xs_transaction_t trans); +_hidden int libxl__domain_restore_device_model(libxl__gc *gc, uint32_t domid, +const char *restore_file); _hidden int libxl__domain_resume_device_model(libxl__gc *gc, uint32_t domid); _hidden const char *libxl__userdata_path(libxl__gc *gc, uint32_t domid,
@@ -1762,6 +1764,8 @@ _hidden int libxl__qmp_stop(libxl__gc *gc, int domid); _hidden int libxl__qmp_resume(libxl__gc *gc, int domid);/* Save current QEMU state into fd. */ _hidden int libxl__qmp_save(libxl__gc *gc, int domid, const char *filename); +/* Load current QEMU state from file. */ +_hidden int libxl__qmp_restore(libxl__gc *gc, int domid, const char *filename);/* Set dirty bitmap logging status */ _hidden int libxl__qmp_set_global_dirty_log(libxl__gc *gc, int domid, bool enable); _hidden int libxl__qmp_insert_cdrom(libxl__gc *gc, int domid, const libxl_device_disk *disk);
tools/libxl/libxl_qmp.c +10 -0
@@ -905,6 +905,16 @@ int libxl__qmp_save(libxl__gc *gc, int domid, const char *filename) NULL, NULL); } +int libxl__qmp_restore (libxl__gc *gc,int domid,const char *state_file) +{ +libxl__json_object *args =NULL ; + +qmp_parameters_add_string (gc, &args,"filename" , state_file); + +return qmp_run_command (gc, domid,"xen-load-devices-state" , args, +NULL ,NULL ); +} +static int qmp_change (libxl__gc *gc,libxl__qmp_handler *qmp,char *device,char *target,char *arg) {
Signature · 1 line
2.5.0
Re: [PATCH v10 01/31] tools/libxl: introduce libxl__domain_restore_device_model to load qemu state
Quoted 9 lines · Wen Congyang
In normal migration, the qemu state is passed to qemu as a parameter. With COLO, secondary vm is running. So we will do the following steps at every checkpoint:
1. suspend both primary vm and secondary vm
2. sync the state
3. resume both primary vm and secondary vm
Primary will send qemu's state in step2, and secondary's qemu should read it and restore the state before it is resumed. We can not pass the state to qemu as a parameter because secondary QEMU already started
is already started.
Quoted 3 lines
at this point, so we introduce
libxl__domain_restore_device_model()to do it. This API MUST be called before resuming secondary vm.
The last sentence is of no relevancy of this function itself, so I would just remove it if this patch will be resent in its current form.
And some comments below.
Quoted 28 lines
Signed-off-by Yang Hongyang <[email protected]>Signed-off-by Wen Congyang <[email protected]>Cc Anthony Perard <[email protected]>Reviewed-by Konrad Rzeszutek Wilk <[email protected]>--- tools/libxl/libxl_dom_save.c | 20 ++++++++++++++++++++ tools/libxl/libxl_internal.h | 4 ++++ tools/libxl/libxl_qmp.c | 10 ++++++++++ 3 files changed, 34 insertions(+)tools/libxl/libxl_dom_save.c +10
-0@@ -512,6 +512,26 @@ int libxl__restore_emulator_xenstore_data(libxl__domain_create_state *dcs,return rc; } +int libxl__domain_restore_device_model (libxl__gc *gc,uint32_t domid, +const char *restore_file) +{ +int rc; + +switch (libxl__device_model_version_running (gc, domid)) { +case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL : +/* Will never be supported. */ + rc =ERROR_INVAL ; +break ;
tools/libxl/libxl_dom_save.c int libxl__restore_emulator_xenstore_data(libxl__domain_create_state *dcs, · line 534
Quoted 10 lines
tools/libxl/libxl_dom_save.c +10
-0+case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN : + rc =libxl__qmp_restore (gc, domid, restore_file); +break ; +default : + rc =ERROR_INVAL ; + } + +return rc; +} +
The function name suggests that it should be universally applied to all device model cases and all places that involves restoring device model. This is not the case in this series. I search for this function in the rest of this series, it seems to be only used by COLO (in patch #10).
It's also unclear where the other half libxl__domain_save_device_model is. I don't think this is your problem, though.
Based on the two reasons above, I would say let's not have this function at all. You can call libxl__qmp_restore in COLO code directly.
Does this sound plausible?
If you agree, this patch can be turned into introduction of libxl__qmp_restore.
Quoted 33 lines
tools/libxl/libxl_dom_save.c +0
-0/* * Local variables: * mode: C tools/libxl/libxl_internal.h +4
-0@@ -1119,6 +1119,8 @@ _hidden int libxl__domain_rename(libxl__gc *gc, uint32_t domid, const char *old_name, const char *new_name, xs_transaction_t trans); +_hidden int libxl__domain_restore_device_model(libxl__gc *gc, uint32_t domid, +const char *restore_file); _hidden int libxl__domain_resume_device_model(libxl__gc *gc, uint32_t domid); _hidden const char *libxl__userdata_path(libxl__gc *gc, uint32_t domid,@@ -1762,6 +1764,8 @@ _hidden int libxl__qmp_stop(libxl__gc *gc, int domid); _hidden int libxl__qmp_resume(libxl__gc *gc, int domid);/* Save current QEMU state into fd. */ _hidden int libxl__qmp_save(libxl__gc *gc, int domid, const char *filename); +/* Load current QEMU state from file. */ +_hidden int libxl__qmp_restore(libxl__gc *gc, int domid, const char *filename);/* Set dirty bitmap logging status */ _hidden int libxl__qmp_set_global_dirty_log(libxl__gc *gc, int domid, bool enable); _hidden int libxl__qmp_insert_cdrom(libxl__gc *gc, int domid, const libxl_device_disk *disk);tools/libxl/libxl_qmp.c +0
-0@@ -905,6 +905,16 @@ int libxl__qmp_save(libxl__gc *gc, int domid, const char *filename) NULL, NULL); }
tools/libxl/libxl_qmp.c int libxl__qmp_save(libxl__gc *gc, int domid, const char *filename) · line 917
Quoted 10 lines
tools/libxl/libxl_qmp.c +10
-0+int libxl__qmp_restore (libxl__gc *gc,int domid,const char *state_file) +{ +libxl__json_object *args =NULL ; + +qmp_parameters_add_string (gc, &args,"filename" , state_file); + +return qmp_run_command (gc, domid,"xen-load-devices-state" , args, +NULL ,NULL ); +} +
This looks OK.
Quoted 8 lines
tools/libxl/libxl_qmp.c +0
-0static int qmp_change (libxl__gc *gc,libxl__qmp_handler *qmp,char *device,char *target,char *arg) {Signature · 1 line
2.5.0
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH v10 01/31] tools/libxl: introduce libxl__domain_restore_device_model to load qemu state
Quoted 69 lines · Wei Liu
Quoted 9 lines · Wen Congyang
In normal migration, the qemu state is passed to qemu as a parameter. With COLO, secondary vm is running. So we will do the following steps at every checkpoint:
1. suspend both primary vm and secondary vm
2. sync the state
3. resume both primary vm and secondary vm
Primary will send qemu's state in step2, and secondary's qemu should read it and restore the state before it is resumed. We can not pass the state to qemu as a parameter because secondary QEMU already startedis already started.
Quoted 3 lines
at this point, so we introduce
libxl__domain_restore_device_model()to do it. This API MUST be called before resuming secondary vm.The last sentence is of no relevancy of this function itself, so I would just remove it if this patch will be resent in its current form.
And some comments below.
Quoted 28 lines
Signed-off-by Yang Hongyang <[email protected]>Signed-off-by Wen Congyang <[email protected]>Cc Anthony Perard <[email protected]>Reviewed-by Konrad Rzeszutek Wilk <[email protected]>--- tools/libxl/libxl_dom_save.c | 20 ++++++++++++++++++++ tools/libxl/libxl_internal.h | 4 ++++ tools/libxl/libxl_qmp.c | 10 ++++++++++ 3 files changed, 34 insertions(+)tools/libxl/libxl_dom_save.c +10
-0@@ -512,6 +512,26 @@ int libxl__restore_emulator_xenstore_data(libxl__domain_create_state *dcs,return rc; } +int libxl__domain_restore_device_model (libxl__gc *gc,uint32_t domid, +const char *restore_file) +{ +int rc; + +switch (libxl__device_model_version_running (gc, domid)) { +case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL : +/* Will never be supported. */ + rc =ERROR_INVAL ; +break ;tools/libxl/libxl_dom_save.c int libxl__restore_emulator_xenstore_data(libxl__domain_create_state *dcs, · line 534
Quoted 10 lines
tools/libxl/libxl_dom_save.c +10
-0+case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN : + rc =libxl__qmp_restore (gc, domid, restore_file); +break ; +default : + rc =ERROR_INVAL ; + } + +return rc; +} +The function name suggests that it should be universally applied to all device model cases and all places that involves restoring device model. This is not the case in this series. I search for this function in the rest of this series, it seems to be only used by COLO (in patch #10).
It's also unclear where the other half
libxl__domain_save_device_modelis. I don't think this is your problem, though.
Quoted 7 lines
Based on the two reasons above, I would say let's not have this function at all. You can call
libxl__qmp_restorein COLO code directly.Does this sound plausible?
If you agree, this patch can be turned into introduction of
libxl__qmp_restore.
Yes, it is only used by COLO. I will update it in the next version.
Thanks
Wen Congyang
Quoted 57 lines
Quoted 34 lines
tools/libxl/libxl_dom_save.c +0
-0/* * Local variables: * mode: C tools/libxl/libxl_internal.h +4
-0@@ -1119,6 +1119,8 @@ _hidden int libxl__domain_rename(libxl__gc *gc, uint32_t domid, const char *old_name, const char *new_name, xs_transaction_t trans); +_hidden int libxl__domain_restore_device_model(libxl__gc *gc, uint32_t domid, +const char *restore_file); _hidden int libxl__domain_resume_device_model(libxl__gc *gc, uint32_t domid); _hidden const char *libxl__userdata_path(libxl__gc *gc, uint32_t domid,@@ -1762,6 +1764,8 @@ _hidden int libxl__qmp_stop(libxl__gc *gc, int domid); _hidden int libxl__qmp_resume(libxl__gc *gc, int domid);/* Save current QEMU state into fd. */ _hidden int libxl__qmp_save(libxl__gc *gc, int domid, const char *filename); +/* Load current QEMU state from file. */ +_hidden int libxl__qmp_restore(libxl__gc *gc, int domid, const char *filename);/* Set dirty bitmap logging status */ _hidden int libxl__qmp_set_global_dirty_log(libxl__gc *gc, int domid, bool enable); _hidden int libxl__qmp_insert_cdrom(libxl__gc *gc, int domid, const libxl_device_disk *disk);tools/libxl/libxl_qmp.c +0
-0@@ -905,6 +905,16 @@ int libxl__qmp_save(libxl__gc *gc, int domid, const char *filename) NULL, NULL); }tools/libxl/libxl_qmp.c int libxl__qmp_save(libxl__gc *gc, int domid, const char *filename) · line 917
Quoted 10 lines
tools/libxl/libxl_qmp.c +10
-0+int libxl__qmp_restore (libxl__gc *gc,int domid,const char *state_file) +{ +libxl__json_object *args =NULL ; + +qmp_parameters_add_string (gc, &args,"filename" , state_file); + +return qmp_run_command (gc, domid,"xen-load-devices-state" , args, +NULL ,NULL ); +} +This looks OK.
Quoted 8 lines
tools/libxl/libxl_qmp.c +0
-0static int qmp_change (libxl__gc *gc,libxl__qmp_handler *qmp,char *device,char *target,char *arg) {Signature · 1 line
2.5.0
Quoted 2 lines
.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
PATCH v10 2/31 tools/libxl: introduce libxl__domain_common_switch_qemu_logdirty()
In reply to Wen CongyangSecondary vm is running in COLO mode, we need to send secondary vm's dirty page information to primary host at checkpoint, so we have to enable qemu logdirty on secondary.
libxl__domain_suspend_common_switch_qemu_logdirty() is to enable qemu logdirty. But it uses libxl__domain_save_state, and calls libxl__xc_domain_saverestore_async_callback_done() before exits. This can not be used for secondary vm.
Update libxl__domain_suspend_common_switch_qemu_logdirty() to introduce a new API libxl__domain_common_switch_qemu_logdirty(). This API only uses libxl__logdirty_switch, and calls lds->callback before exits. This new API will be used by the patch:
secondary vm suspend/resume/checkpoint code
--- tools/libxl/libxl_dom_save.c | 95 ++++++++++++++++++++++++-------------------- tools/libxl/libxl_internal.h | 8 ++++ 2 files changed, 60 insertions(+), 43 deletions(-)
tools/libxl/libxl_dom_save.c +52 -43
@@ -42,7 +42,7 @@ static void switch_logdirty_timeout(libxl__egc *egc, libxl__ev_time *ev,static void switch_logdirty_xswatch (libxl__egc *egc,libxl__ev_xswatch *,const char *watch_path,const char *event_path);static void switch_logdirty_done (libxl__egc *egc, -libxl__domain_save_state *dss,int rc); +libxl__logdirty_switch *lds,int rc);void libxl__logdirty_init (libxl__logdirty_switch *lds) {
@@ -52,13 +52,10 @@ void libxl__logdirty_init(libxl__logdirty_switch *lds) }static void domain_suspend_switch_qemu_xen_traditional_logdirty - (int domid,unsigned enable, -libxl__save_helper_state *shs) + (libxl__egc *egc,int domid,unsigned enable, +libxl__logdirty_switch *lds) { -libxl__egc *egc = shs->egc; -libxl__domain_save_state *dss = shs->caller_state; -libxl__logdirty_switch *lds = &dss->logdirty; -STATE_AO_GC (dss->ao); +STATE_AO_GC (lds->ao);int rc;xs_transaction_t t =0 ;const char *got;
@@ -120,26 +117,34 @@ static void domain_suspend_switch_qemu_xen_traditional_logdirty out:LOG (ERROR ,"logdirty switch failed (rc=%d), abandoning suspend" ,rc);libxl__xs_transaction_abort (gc, &t); -switch_logdirty_done (egc,dss,rc); +switch_logdirty_done (egc,lds,rc); }static void domain_suspend_switch_qemu_xen_logdirty - (int domid,unsigned enable, -libxl__save_helper_state *shs) + (libxl__egc *egc,int domid,unsigned enable, +libxl__logdirty_switch *lds) { -libxl__egc *egc = shs->egc; -libxl__domain_save_state *dss = shs->caller_state; -STATE_AO_GC (dss->ao); +STATE_AO_GC (lds->ao);int rc; rc =libxl__qmp_set_global_dirty_log (gc, domid, enable); -if (!rc) { -libxl__xc_domain_saverestore_async_callback_done (egc, shs,0 ); - }else { +if (rc)LOG (ERROR ,"logdirty switch failed (rc=%d), abandoning suspend" ,rc); + + lds->callback (egc, lds, rc); +} + +static void domain_suspend_switch_qemu_logdirty_done + (libxl__egc *egc,libxl__logdirty_switch *lds,int rc) +{ +libxl__domain_save_state *dss =CONTAINER_OF (lds, *dss, logdirty); + +if (rc) { dss->rc = rc; -libxl__xc_domain_saverestore_async_callback_done (egc, shs,-1 ); - } +libxl__xc_domain_saverestore_async_callback_done (egc, + &dss->sws.shs,-1 ); + }else +libxl__xc_domain_saverestore_async_callback_done (egc, &dss->sws.shs,0 ); }void libxl__domain_suspend_common_switch_qemu_logdirty
@@ -148,42 +153,52 @@ void libxl__domain_suspend_common_switch_qemu_logdirtylibxl__save_helper_state *shs = user;libxl__egc *egc = shs->egc;libxl__domain_save_state *dss = shs->caller_state; -STATE_AO_GC (dss->ao); + +/* Convenience aliases. */ +libxl__logdirty_switch *const lds = &dss->logdirty; + + lds->callback = domain_suspend_switch_qemu_logdirty_done; +libxl__domain_common_switch_qemu_logdirty (egc, domid, enable, lds); +} + +void libxl__domain_common_switch_qemu_logdirty (libxl__egc *egc, +int domid,unsigned enable, +libxl__logdirty_switch *lds) +{ +STATE_AO_GC (lds->ao);switch (libxl__device_model_version_running (gc, domid)) {case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL : -domain_suspend_switch_qemu_xen_traditional_logdirty (domid, enable, shs); +domain_suspend_switch_qemu_xen_traditional_logdirty (egc, domid, enable, + lds);break ;case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN : -domain_suspend_switch_qemu_xen_logdirty (domid, enable, shs); +domain_suspend_switch_qemu_xen_logdirty (egc, domid, enable, lds);break ;case LIBXL_DEVICE_MODEL_VERSION_NONE : -libxl__xc_domain_saverestore_async_callback_done (egc, shs,0 ); + lds->callback (egc, lds,0 );break ;default :LOG (ERROR ,"logdirty switch failed" ", no valid device model version found, abandoning suspend" ); - dss->rc =ERROR_FAIL ; -libxl__xc_domain_saverestore_async_callback_done (egc, shs,-1 ); + lds->callback (egc, lds,ERROR_FAIL ); } }static void switch_logdirty_timeout (libxl__egc *egc,libxl__ev_time *ev,const struct timeval *requested_abs,int rc) { -libxl__domain_save_state *dss =CONTAINER_OF (ev, *dss, logdirty.timeout); -STATE_AO_GC (dss->ao); +libxl__logdirty_switch *lds =CONTAINER_OF (ev, *lds, timeout); +STATE_AO_GC (lds->ao);LOG (ERROR ,"logdirty switch: wait for device model timed out" ); -switch_logdirty_done (egc,dss,ERROR_FAIL ); +switch_logdirty_done (egc,lds,ERROR_FAIL ); }static void switch_logdirty_xswatch (libxl__egc *egc,libxl__ev_xswatch *watch,const char *watch_path,const char *event_path) { -libxl__domain_save_state *dss = -CONTAINER_OF (watch, *dss, logdirty.watch); -libxl__logdirty_switch *lds = &dss->logdirty; -STATE_AO_GC (dss->ao); +libxl__logdirty_switch *lds =CONTAINER_OF (watch, *lds, watch); +STATE_AO_GC (lds->ao);const char *got;xs_transaction_t t =0 ;int rc;
@@ -229,28 +244,20 @@ static void switch_logdirty_xswatch(libxl__egc *egc, libxl__ev_xswatch *watch,if (rc <=0 ) {if (rc <0 )LOG (ERROR ,"logdirty switch: failed (rc=%d)" ,rc); -switch_logdirty_done (egc,dss,rc); +switch_logdirty_done (egc,lds,rc); } }static void switch_logdirty_done (libxl__egc *egc, -libxl__domain_save_state *dss, +libxl__logdirty_switch *lds,int rc) { -STATE_AO_GC (dss->ao); -libxl__logdirty_switch *lds = &dss->logdirty; +STATE_AO_GC (lds->ao);libxl__ev_xswatch_deregister (gc, &lds->watch);libxl__ev_time_deregister (gc, &lds->timeout); -int broke; -if (rc) { - broke =-1 ; - dss->rc = rc; - }else { - broke =0 ; - } -libxl__xc_domain_saverestore_async_callback_done (egc, &dss->sws.shs, broke); + lds->callback (egc, lds, rc); }/*----- callbacks, called by xc_domain_save -----*/
@@ -346,6 +353,8 @@ void libxl__domain_save(libxl__egc *egc, libxl__domain_save_state *dss) dss->rc =0 ;libxl__logdirty_init (&dss->logdirty); + dss->logdirty.ao = ao; + dsps->ao = ao; dsps->domid = domid; rc =libxl__domain_suspend_init (egc, dsps, type);
tools/libxl/libxl_internal.h +8 -0
@@ -3088,6 +3088,11 @@ libxl__stream_write_inuse(const libxl__stream_write_state *stream) } typedef struct libxl__logdirty_switch { + /* Set by caller of libxl__domain_common_switch_qemu_logdirty */ + libxl__ao *ao; + void (*callback)(libxl__egc *egc, struct libxl__logdirty_switch *lds, + int rc); + const char *cmd; const char *cmd_path; const char *ret_path;
@@ -3506,6 +3511,9 @@ void libxl__xc_domain_saverestore_async_callback_done(libxl__egc *egc, _hidden void libxl__domain_suspend_common_switch_qemu_logdirty (int domid,unsigned int enable,void *data); +_hidden void libxl__domain_common_switch_qemu_logdirty(libxl__egc *egc, +int domid,unsigned enable, +libxl__logdirty_switch *lds); _hidden int libxl__save_emulator_xenstore_data(libxl__domain_save_state *dss,char **buf,uint32_t *len); _hidden int libxl__restore_emulator_xenstore_data
Signature · 1 line
2.5.0
PATCH v10 3/31 tools/libxl: Add back channel to allow migration target send data back
In reply to Wen CongyangIn COLO mode, secondary needs to send the following data to primary:
1. In libxl
Secondary sends the following CHECKPOINT_CONTEXT to primary:
CHECKPOINT_SVM_SUSPENDED, CHECKPOINT_SVM_READY and CHECKPOINT_SVM_RESUMED
2. In libxc
Secondary sends the dirty pfn list to primary
But the io_fd only can be written in primary, and only can be read in secondary. Save recv_fd in domain_suspend_state, and send_fd in domain_create_state. Extend libxl_domain_create_restore API, add a send_fd param to it. Add LIBXL_HAVE_CREATE_RESTORE_SEND_FD to indicate the API change.
--- tools/libxl/libxl.c | 3 +-- tools/libxl/libxl.h | 29 ++++++++++++++++++++++++++++- tools/libxl/libxl_create.c | 10 ++++++---- tools/libxl/libxl_internal.h | 2 ++ tools/libxl/xl_cmdimpl.c | 8 +++++++- tools/ocaml/libs/xl/xenlight_stubs.c | 2 +- 6 files changed, 45 insertions(+), 9 deletions(-)
tools/libxl/libxl.c +1 -2
@@ -834,7 +834,6 @@ out:static void remus_failover_cb (libxl__egc *egc,libxl__domain_save_state *dss,int rc); -/* TODO: Explicit Checkpoint acknowledgements via recv_fd. */ int libxl_domain_remus_start (libxl_ctx *ctx,libxl_domain_remus_info *info,uint32_t domid,int send_fd,int recv_fd,const libxl_asyncop_how *ao_how)
@@ -871,7 +870,7 @@ int libxl_domain_remus_start(libxl_ctx *ctx, libxl_domain_remus_info *info, dss->callback = remus_failover_cb; dss->domid = domid; dss->fd = send_fd; -/* TODO do something with recv_fd */ + dss->recv_fd = recv_fd; dss->type = type; dss->live =1 ; dss->debug =0 ;
tools/libxl/libxl.h +28 -1
@@ -639,6 +639,15 @@ typedef struct libxl__ctx libxl_ctx;#define LIBXL_HAVE_DOMAIN_CREATE_RESTORE_PARAMS 1/* +* LIBXL_HAVE_DOMAIN_CREATE_RESTORE_SEND_BACK_FD 1 +* +* If this is defined, libxl_domain_create_restore()'s API has changed to +* include a send_back_fd param which used for libxl migration back channel +* during COLO. +*/ +#define LIBXL_HAVE_DOMAIN_CREATE_RESTORE_SEND_BACK_FD 1 + +/* * LIBXL_HAVE_CREATEINFO_PVH * If this is defined, then libxl supports creation of a PVH guest. */
@@ -1165,6 +1174,7 @@ int libxl_domain_create_new(libxl_ctx *ctx, libxl_domain_config *d_config,LIBXL_EXTERNAL_CALLERS_ONLY ;int libxl_domain_create_restore (libxl_ctx *ctx,libxl_domain_config *d_config,uint32_t *domid,int restore_fd, +int send_back_fd,const libxl_domain_restore_params *params,const libxl_asyncop_how *ao_how,const libxl_asyncprogress_how *aop_console_how)
@@ -1185,7 +1195,7 @@ int static inline libxl_domain_create_restore_0x040200(libxl_domain_restore_params_init (¶ms); ret =libxl_domain_create_restore ( - ctx, d_config, domid, restore_fd, ¶ms, ao_how, aop_console_how); + ctx, d_config, domid, restore_fd,-1 , ¶ms, ao_how, aop_console_how);libxl_domain_restore_params_dispose (¶ms);return ret;
@@ -1193,6 +1203,23 @@ int static inline libxl_domain_create_restore_0x040200(#define libxl_domain_create_restore libxl_domain_create_restore_0x040200 +#elif defined(LIBXL_API_VERSION ) &&LIBXL_API_VERSION >=0x040400 \ + &&LIBXL_API_VERSION <0x040700 + +int static inline libxl_domain_create_restore_0x040400 ( +libxl_ctx *ctx,libxl_domain_config *d_config, +uint32_t *domid,int restore_fd, +const libxl_domain_restore_params *params, +const libxl_asyncop_how *ao_how, +const libxl_asyncprogress_how *aop_console_how) +LIBXL_EXTERNAL_CALLERS_ONLY +{ +return libxl_domain_create_restore (ctx, d_config, domid, restore_fd, +-1 , params, ao_how, aop_console_how); +} + +#define libxl_domain_create_restore libxl_domain_create_restore_0x040400 +#endif int libxl_domain_soft_reset(libxl_ctx *ctx,
tools/libxl/libxl_create.c +6 -4
@@ -1572,7 +1572,7 @@ static void domain_create_cb(libxl__egc *egc, int rc, uint32_t domid);static int do_domain_create (libxl_ctx *ctx,libxl_domain_config *d_config, -uint32_t *domid,int restore_fd, +uint32_t *domid,int restore_fd,int send_back_fd,const libxl_domain_restore_params *params,const libxl_asyncop_how *ao_how,const libxl_asyncprogress_how *aop_console_how)
@@ -1587,6 +1587,7 @@ static int do_domain_create(libxl_ctx *ctx, libxl_domain_config *d_config,libxl_domain_config_init (&cdcs->dcs.guest_config_saved);libxl_domain_config_copy (ctx, &cdcs->dcs.guest_config_saved, d_config); cdcs->dcs.restore_fd = cdcs->dcs.libxc_fd = restore_fd; + cdcs->dcs.send_back_fd = send_back_fd;if (restore_fd >-1 ) { cdcs->dcs.restore_params = *params; rc = libxl__fd_flags_modify_save(gc, cdcs->dcs.restore_fd,
@@ -1765,18 +1766,19 @@ int libxl_domain_create_new(libxl_ctx *ctx, libxl_domain_config *d_config,const libxl_asyncop_how *ao_how, const libxl_asyncprogress_how *aop_console_how) { - return do_domain_create(ctx, d_config, domid, -1, NULL, + return do_domain_create(ctx, d_config, domid, -1, -1, NULL,ao_how ,aop_console_how ); }int libxl_domain_create_restore (libxl_ctx *ctx,libxl_domain_config *d_config,uint32_t *domid,int restore_fd, +int send_back_fd,const libxl_domain_restore_params *params,const libxl_asyncop_how *ao_how,const libxl_asyncprogress_how *aop_console_how) { -return do_domain_create (ctx, d_config, domid, restore_fd, params, - ao_how, aop_console_how); +return do_domain_create (ctx, d_config, domid, restore_fd, send_back_fd, + params, ao_how, aop_console_how); } int libxl_domain_soft_reset(libxl_ctx *ctx,
tools/libxl/libxl_internal.h +2 -0
@@ -3134,6 +3134,7 @@ struct libxl__domain_save_state {uint32_t domid;int fd;int fdfl;/* original flags on fd */ +int recv_fd;libxl_domain_type type;int live;int debug;
@@ -3467,6 +3468,7 @@ struct libxl__domain_create_state {libxl_domain_config guest_config_saved;/* vanilla config */ int restore_fd, libxc_fd;int restore_fdfl;/* original flags of restore_fd */ +int send_back_fd;libxl_domain_restore_params restore_params;uint32_t domid_soft_reset;libxl__domain_create_cb *callback;
tools/libxl/xl_cmdimpl.c +7 -1
@@ -159,6 +159,7 @@ struct domain_create {char *extra_config;/* extra config string */ const char *restore_file;int migrate_fd;/* -1 means none */ +int send_back_fd;/* -1 means none */ char **migration_domname_r;/* from malloc */ };
@@ -2686,6 +2687,7 @@ static uint32_t create_domain(struct domain_create *dom_info)int config_len =0 ;int restore_fd =-1 ;int restore_fd_to_close =-1 ; +int send_back_fd =-1 ;const libxl_asyncprogress_how *autoconnect_console_how;struct save_file_header hdr;uint32_t domid_soft_reset =INVALID_DOMID ;
@@ -2703,6 +2705,7 @@ static uint32_t create_domain(struct domain_create *dom_info)if (migrate_fd >=0 ) { restore_source ="<incoming migration stream>" ; restore_fd = migrate_fd; + send_back_fd = dom_info->send_back_fd; }else { restore_source = restore_file; restore_fd =open (restore_file,O_RDONLY );
@@ -2891,7 +2894,7 @@ start: ret =libxl_domain_create_restore (ctx, &d_config, &domid, restore_fd, - ¶ms, + send_back_fd, ¶ms,0 , autoconnect_console_how);libxl_domain_restore_params_dispose (¶ms);
@@ -4454,6 +4457,7 @@ static void migrate_receive(int debug, int daemonize, int monitor, dom_info.monitor = monitor; dom_info.paused =1 ; dom_info.migrate_fd = recv_fd; + dom_info.send_back_fd = send_fd; dom_info.migration_domname_r = &migration_domname; dom_info.checkpointed_stream = checkpointed;
@@ -4627,6 +4631,7 @@ int main_restore(int argc, char **argv) dom_info.config_file = config_file; dom_info.restore_file = checkpoint_file; dom_info.migrate_fd =-1 ; + dom_info.send_back_fd =-1 ; dom_info.vnc = vnc; dom_info.vncautopass = vncautopass; dom_info.console_autoconnect = console_autoconnect;
@@ -5094,6 +5099,7 @@ int main_create(int argc, char **argv) dom_info.quiet = quiet; dom_info.config_file = filename; dom_info.migrate_fd =-1 ; + dom_info.send_back_fd =-1 ; dom_info.vnc = vnc; dom_info.vncautopass = vncautopass; dom_info.console_autoconnect = console_autoconnect;
tools/ocaml/libs/xl/xenlight_stubs.c +1 -1
@@ -538,7 +538,7 @@ value stub_libxl_domain_create_restore(value ctx, value domain_config, value parcaml_enter_blocking_section (); ret =libxl_domain_create_restore (CTX , &c_dconfig, &c_domid, restore_fd, - &c_params, ao_how,NULL ); +-1 , &c_params, ao_how,NULL );caml_leave_blocking_section ();free (ao_how);
Signature · 1 line
2.5.0
PATCH v10 4/31 tools/libxl: Introduce new helper function dup_fd_helper()
In reply to Wen CongyangIt is pure refactoring and no functional changes.
--- tools/libxl/libxl_save_callout.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-)
tools/libxl/libxl_save_callout.c +16 -8
@@ -118,6 +118,21 @@ void libxl__save_helper_init(libxl__save_helper_state *shs) }/*----- helper execution -----*/ +static int dup_fd_helper (libxl__gc *gc,int fd,const char *what) +{ +int dup_fd = fd; + +if (fd <=2 ) { + dup_fd =dup (fd); +if (dup_fd <0 ) { +LOGE (ERROR ,"dup %s" , what); +exit (-1 ); + } + } +libxl_fd_set_cloexec (CTX , dup_fd,0 ); + +return dup_fd; +}/* * Both save and restore share four parameters:
@@ -186,14 +201,7 @@ static void run_helper(libxl__egc *egc, libxl__save_helper_state *shs,pid_t pid =libxl__ev_child_fork (gc, &shs->child, helper_exited);if (!pid) { -if (stream_fd <=2 ) { - stream_fd =dup (stream_fd); -if (stream_fd <0 ) { -LOGE (ERROR ,"dup migration stream fd" ); -exit (-1 ); - } - } -libxl_fd_set_cloexec (CTX , stream_fd,0 ); + stream_fd =dup_fd_helper (gc, stream_fd,"migration stream fd" ); *stream_fd_arg =GCSPRINTF ("%d" , stream_fd);for (i=0 ; i<num_preserve_fds; i++)
Signature · 1 line
2.5.0
Re: [PATCH v10 04/31] tools/libxl: Introduce new helper function dup_fd_helper()
Quoted 3 lines · Wen Congyang
It is pure refactoring and no functional changes.
Signed-off-by Wen Congyang <[email protected]>
Assuming this is going to be used later:
Quoted 51 lines
--- tools/libxl/libxl_save_callout.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-)tools/libxl/libxl_save_callout.c +16
-8@@ -118,6 +118,21 @@ void libxl__save_helper_init(libxl__save_helper_state *shs) }/*----- helper execution -----*/ +static int dup_fd_helper (libxl__gc *gc,int fd,const char *what) +{ +int dup_fd = fd; + +if (fd <=2 ) { + dup_fd =dup (fd); +if (dup_fd <0 ) { +LOGE (ERROR ,"dup %s" , what); +exit (-1 ); + } + } +libxl_fd_set_cloexec (CTX , dup_fd,0 ); + +return dup_fd; +}/* * Both save and restore share four parameters: @@ -186,14 +201,7 @@ static void run_helper(libxl__egc *egc, libxl__save_helper_state *shs,pid_t pid =libxl__ev_child_fork (gc, &shs->child, helper_exited);if (!pid) { -if (stream_fd <=2 ) { - stream_fd =dup (stream_fd); -if (stream_fd <0 ) { -LOGE (ERROR ,"dup migration stream fd" ); -exit (-1 ); - } - } -libxl_fd_set_cloexec (CTX , stream_fd,0 ); + stream_fd =dup_fd_helper (gc, stream_fd,"migration stream fd" ); *stream_fd_arg =GCSPRINTF ("%d" , stream_fd);for (i=0 ; i<num_preserve_fds; i++)Signature · 1 line
2.5.0
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
PATCH v10 5/31 tools/libx{l, c}: add back channel to libxc
In reply to Wen CongyangIn COLO mode, both VMs are running, and are considered in sync if the visible network traffic is identical. After some time, they fall out of sync.
At this point, the two VMs have definitely diverged. Lets call the primary dirty bitmap set A, while the secondary dirty bitmap set B.
Sets A and B are different.
Under normal migration, the page data for set A will be sent from the primary to the secondary.
However, the set difference B - A (the one in B but not in A, lets call this C) is out-of-date on the secondary (with respect to the primary) and will not be sent by the primary (to secondary), as it was not memory dirtied by the primary. The secondary needs C page data to reconstruct an exact copy of the primary at the checkpoint.
The secondary cannot calculate C as it doesn't know A. Instead, the secondary must send B to the primary, at which point the primary calculates the union of A and B (lets call this D) which is all the pages dirtied by both the primary and the secondary, and sends all page data covered by D.
In the general case, D is a superset of both A and B. Without the backchannel dirty bitmap, a COLO checkpoint can't reconstruct a valid copy of the primary.
We transfer the dirty bitmap on libxc side, so we need to introduce back channel to libxc.
Note: it is different from the paper. We change the original design to the current one, according to our following concerns:
1. The original design needs extra memory on Secondary host. When there's multiple backups on one host, the memory cost is high.
2. The memory cache code will be another 1k+, it will make the review more time consuming.
Note: the back channel will be used in the patch
libxc/restore: send dirty pfn list to primary when checkpoint under COLO
to send dirty pfn list from secondary to primary. The patch is posted in another series.
--- tools/libxc/include/xenguest.h | 4 ++-- tools/libxc/xc_nomigrate.c | 4 ++-- tools/libxc/xc_sr_restore.c | 2 +- tools/libxc/xc_sr_save.c | 2 +- tools/libxl/libxl_save_callout.c | 21 +++++++++++++++------ tools/libxl/libxl_save_helper.c | 8 ++++++-- 6 files changed, 27 insertions(+), 14 deletions(-)
tools/libxc/include/xenguest.h +2 -2
@@ -88,7 +88,7 @@ struct save_callbacks {int xc_domain_save (xc_interface *xch,int io_fd,uint32_t dom,uint32_t max_iters,uint32_t max_factor,uint32_t flags/* XCFLAGS_xxx */ ,struct save_callbacks * callbacks,int hvm, -int checkpointed_stream); +int checkpointed_stream,int recv_fd);/* callbacks provided by xc_domain_restore */ struct restore_callbacks {
@@ -127,7 +127,7 @@ int xc_domain_restore(xc_interface *xch, int io_fd, uint32_t dom, unsigned long *console_mfn, domid_t console_domid, unsigned int hvm, unsigned int pae, int superpages, int checkpointed_stream, - struct restore_callbacks *callbacks); + struct restore_callbacks *callbacks, int send_back_fd);/** * This function will create a domain for a paravirtualized Linux
tools/libxc/xc_nomigrate.c +2 -2
@@ -23,7 +23,7 @@int xc_domain_save (xc_interface *xch,int io_fd,uint32_t dom,uint32_t max_iters,uint32_t max_factor,uint32_t flags,struct save_callbacks * callbacks,int hvm, -int checkpointed_stream) +int checkpointed_stream,int recv_fd) { errno =ENOSYS ;return -1 ;
@@ -35,7 +35,7 @@ int xc_domain_restore(xc_interface *xch, int io_fd, uint32_t dom, unsigned long *console_mfn, domid_t console_domid, unsigned int hvm, unsigned int pae, int superpages, int checkpointed_stream, - struct restore_callbacks *callbacks) + struct restore_callbacks *callbacks, int send_back_fd) { errno =ENOSYS ;return -1 ;
tools/libxc/xc_sr_restore.c +1 -1
@@ -726,7 +726,7 @@ int xc_domain_restore(xc_interface *xch, int io_fd, uint32_t dom, unsigned long *console_gfn, domid_t console_domid, unsigned int hvm, unsigned int pae, int superpages, int checkpointed_stream, - struct restore_callbacks *callbacks) + struct restore_callbacks *callbacks, int send_back_fd) { struct xc_sr_context ctx = {
tools/libxc/xc_sr_save.c +1 -1
@@ -830,7 +830,7 @@ static int save(struct xc_sr_context *ctx, uint16_t guest_type)int xc_domain_save (xc_interface *xch,int io_fd,uint32_t dom,uint32_t max_iters,uint32_t max_factor,uint32_t flags,struct save_callbacks * callbacks,int hvm, -int checkpointed_stream) +int checkpointed_stream,int recv_fd) {struct xc_sr_context ctx = {
tools/libxl/libxl_save_callout.c +15 -6
@@ -27,7 +27,7 @@*/ static void run_helper (libxl__egc *egc,libxl__save_helper_state *shs,const char *mode_arg, -int stream_fd, +int stream_fd,int back_channel_fd,const int *preserve_fds,int num_preserve_fds,const unsigned long *argnums,int num_argnums);
@@ -50,6 +50,7 @@ void libxl__xc_domain_restore(libxl__egc *egc, libxl__domain_create_state *dcs,/* Convenience aliases */ const uint32_t domid = dcs->guest_domid;const int restore_fd = dcs->libxc_fd; +const int send_back_fd = dcs->send_back_fd;libxl__domain_build_state *const state = &dcs->build_state; unsigned cbflags =
@@ -71,7 +72,7 @@ void libxl__xc_domain_restore(libxl__egc *egc, libxl__domain_create_state *dcs, shs->caller_state = dcs; shs->need_results =1 ; -run_helper (egc, shs,"--restore-domain" , restore_fd,0 ,0 , +run_helper (egc, shs,"--restore-domain" , restore_fd, send_back_fd,0 ,0 , argnums,ARRAY_SIZE (argnums)); }
@@ -95,7 +96,7 @@ void libxl__xc_domain_save(libxl__egc *egc, libxl__domain_save_state *dss, shs->caller_state = dss; shs->need_results =0 ; -run_helper (egc, shs,"--save-domain" , dss->fd, +run_helper (egc, shs,"--save-domain" , dss->fd, dss->recv_fd,NULL ,0 , argnums,ARRAY_SIZE (argnums));return ;
@@ -139,12 +140,14 @@ static int dup_fd_helper(libxl__gc *gc, int fd, const char *what)* 1) Path to libxl-save-helper. * 2) --[restore|save]-domain. * 3) stream file descriptor. +* 4) back channel file descriptor. * n) save/restore specific parameters. -* 4) A \0 at the end. +* 5) A \0 at the end. */ -#define HELPER_NR_ARGS 4 +#define HELPER_NR_ARGS 5static void run_helper (libxl__egc *egc,libxl__save_helper_state *shs, -const char *mode_arg,int stream_fd, +const char *mode_arg, +int stream_fd,int back_channel_fd,const int *preserve_fds,int num_preserve_fds,const unsigned long *argnums,int num_argnums) {
@@ -177,6 +180,7 @@ static void run_helper(libxl__egc *egc, libxl__save_helper_state *shs, *arg++ =getenv ("LIBXL_SAVE_HELPER" ) ?:LIBEXEC_BIN "/" "libxl-save-helper" ; *arg++ = mode_arg;const char **stream_fd_arg = arg++; +const char **back_channel_fd_arg = arg++;for (i=0 ; i<num_argnums; i++) *arg++ =GCSPRINTF ("%lu" , argnums[i]); *arg++ =0 ;
@@ -204,6 +208,11 @@ static void run_helper(libxl__egc *egc, libxl__save_helper_state *shs, stream_fd =dup_fd_helper (gc, stream_fd,"migration stream fd" ); *stream_fd_arg =GCSPRINTF ("%d" , stream_fd); +if (back_channel_fd >=0 ) + back_channel_fd =dup_fd_helper (gc, back_channel_fd, +"migration back channel fd" ); + *back_channel_fd_arg =GCSPRINTF ("%d" , back_channel_fd); +for (i=0 ; i<num_preserve_fds; i++)if (preserve_fds[i] >=0 ) {assert (preserve_fds[i] >2 );
tools/libxl/libxl_save_helper.c +6 -2
@@ -238,6 +238,7 @@ static struct restore_callbacks helper_restore_callbacks;int main (int argc,char **argv) {int r; +int send_back_fd, recv_fd;#define NEXTARG (++argv, assert(*argv), *argv)
@@ -247,6 +248,7 @@ int main(int argc, char **argv)if (!strcmp (mode,"--save-domain" )) { io_fd =atoi (NEXTARG ); + recv_fd =atoi (NEXTARG );uint32_t dom =strtoul (NEXTARG ,0 ,10 );uint32_t max_iters =strtoul (NEXTARG ,0 ,10 );uint32_t max_factor =strtoul (NEXTARG ,0 ,10 );
@@ -262,12 +264,14 @@ int main(int argc, char **argv)setup_signals (save_signal_handler); r =xc_domain_save (xch, io_fd, dom, max_iters, max_factor, flags, - &helper_save_callbacks, hvm, checkpointed_stream); + &helper_save_callbacks, hvm, checkpointed_stream, + recv_fd);complete (r); }else if (!strcmp (mode,"--restore-domain" )) { io_fd =atoi (NEXTARG ); + send_back_fd =atoi (NEXTARG );uint32_t dom =strtoul (NEXTARG ,0 ,10 );unsigned store_evtchn =strtoul (NEXTARG ,0 ,10 );domid_t store_domid =strtoul (NEXTARG ,0 ,10 );
@@ -292,7 +296,7 @@ int main(int argc, char **argv) store_domid, console_evtchn, &console_mfn, console_domid, hvm, pae, superpages, checkpointed, - &helper_restore_callbacks); + &helper_restore_callbacks, send_back_fd);helper_stub_restore_results (store_mfn,console_mfn,0 );complete (r);
Signature · 1 line
2.5.0
Re: [PATCH v10 05/31] tools/libx{l, c}: add back channel to libxc
Quoted 38 lines · Wen Congyang
In COLO mode, both VMs are running, and are considered in sync if the visible network traffic is identical. After some time, they fall out of sync.
At this point, the two VMs have definitely diverged. Lets call the primary dirty bitmap set A, while the secondary dirty bitmap set B.
Sets A and B are different.
Under normal migration, the page data for set A will be sent from the primary to the secondary.
However, the set difference B - A (the one in B but not in A, lets call this C) is out-of-date on the secondary (with respect to the primary) and will not be sent by the primary (to secondary), as it was not memory dirtied by the primary. The secondary needs C page data to reconstruct an exact copy of the primary at the checkpoint.
The secondary cannot calculate C as it doesn't know A. Instead, the secondary must send B to the primary, at which point the primary calculates the union of A and B (lets call this D) which is all the pages dirtied by both the primary and the secondary, and sends all page data covered by D.
In the general case, D is a superset of both A and B. Without the backchannel dirty bitmap, a COLO checkpoint can't reconstruct a valid copy of the primary.
We transfer the dirty bitmap on libxc side, so we need to introduce back channel to libxc.
Note: it is different from the paper. We change the original design to the current one, according to our following concerns:
1. The original design needs extra memory on Secondary host. When there's multiple backups on one host, the memory cost is high.
2. The memory cache code will be another 1k+, it will make the review more time consuming.
Quoted 4 lines
Note: the back channel will be used in the patch
libxc/restore: send dirty pfn list to primary when checkpoint under COLO
to send dirty pfn list from secondary to primary. The patch is posted in another series.
I think you need to update the commit message a bit. I take the liberty of writing one for you:
This patch merely adds new parameters to various prototypes and functions. The new parameters are used in later patch called "libxc/restore: send dirty pfn list to primary when checkpoint under COLO".
I would normally ask the submitter to merge patch like this to the actual patch that uses the parameter. It you can do that, that would be great. But this patch series is already quite large, if this involves a lot of conflict resolution on your side, just leave it as-is.
Either way, please confirm your intention before doing actual work.
Bottom line: patch like this needs to compile and not introduce any regression. I think that's the case here.
Wei.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
PATCH v10 6/31 docs: add colo readme
In reply to Wen Congyangadd colo readme, refer to
http://wiki.xen.org/wiki/COLO_-_Coarse_Grain_Lock_Stepping
--- docs/README.colo | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 docs/README.colo
docs/README.colo new file +9 -0
@@ -0,0 +1,9 @@ +COLO FT/HA (COarse-grain LOck-stepping Virtual Machines for Non-stop Service) +project is a high availability solution. Both primary VM (PVM) and secondary VM +(SVM) run in parallel. They receive the same request from client, and generate +response in parallel too. If the response packets from PVM and SVM are +identical, they are released immediately. Otherwise, a VM checkpoint (on demand) +is conducted. + +See the website at http://wiki.xen.org/wiki/COLO_-_Coarse_Grain_Lock_Stepping +for details.
Signature · 1 line
2.5.0
Re: [PATCH v10 06/31] docs: add colo readme
Quoted 6 lines · Wen Congyang
add colo readme, refer to
http://wiki.xen.org/wiki/COLO_-_Coarse_Grain_Lock_SteppingSigned-off-by Yang Hongyang <[email protected]>Acked-by Ian Campbell <[email protected]>Signed-off-by Wen Congyang <[email protected]>
Quoted 30 lines
--- docs/README.colo | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 docs/README.colodocs/README.colo new file +9
-0@@ -0,0 +1,9 @@ +COLO FT/HA (COarse-grain LOck-stepping Virtual Machines for Non-stop Service) +project is a high availability solution. Both primary VM (PVM) and secondary VM +(SVM) run in parallel. They receive the same request from client, and generate +response in parallel too. If the response packets from PVM and SVM are +identical, they are released immediately. Otherwise, a VM checkpoint (on demand) +is conducted. + +See the website at http://wiki.xen.org/wiki/COLO_-_Coarse_Grain_Lock_Stepping +for details.Signature · 9 lines
2.5.0 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
PATCH v10 7/31 docs/libxl: Introduce CHECKPOINT_CONTEXT to support migration v2 colo streams
In reply to Wen CongyangIt is the negotiation record for COLO.Primary->Secondary:control_id 0x00000000: Secondary VM is out of sync, start a new checkpointSecondary->Primary:
0x00000001: Secondary VM is suspended
0x00000002: Secondary VM is ready
0x00000003: Secondary VM is resumed--- docs/specs/libxl-migration-stream.pandoc | 25 +++++++++++++++++++++++-- tools/libxl/libxl_sr_stream_format.h | 11 +++++++++++ tools/python/xen/migration/libxl.py | 9 +++++++++ 3 files changed, 43 insertions(+), 2 deletions(-)
docs/specs/libxl-migration-stream.pandoc +23 -2
@@ -1,6 +1,6 @@ % LibXenLight Domain Image Format % Andrew Cooper <<[email protected]>> -% Revision 1 +% Revision 2 Introduction ============
@@ -119,7 +119,9 @@ type 0x00000000: END 0x00000004: CHECKPOINT_END - 0x00000005 - 0x7FFFFFFF: Reserved for future _mandatory_ + 0x00000005: CHECKPOINT_STATE + + 0x00000006 - 0x7FFFFFFF: Reserved for future _mandatory_ records. 0x80000000 - 0xFFFFFFFF: Reserved for future _optional_
@@ -249,6 +251,25 @@ A checkpoint end record marks the end of a checkpoint in the image. The end record contains no fields; its body_length is 0. +CHECKPOINT\_STATE +-------------- + +A checkpoint state record contains the control information for checkpoint. + + 0 1 2 3 4 5 6 7 octet + +------------------------+------------------------+ + | control_id | padding | + +------------------------+------------------------+ + +-------------------------------------------------------------------- +Field Description +------------ --------------------------------------------------- +control_id 0x00000000: Secondary VM is out of sync, start a new checkpoint + 0x00000001: Secondary VM is suspended + 0x00000002: Secondary VM is ready + 0x00000003: Secondary VM is resumed +-------------------------------------------------------------------- + Future Extensions =================
tools/libxl/libxl_sr_stream_format.h +11 -0
@@ -36,6 +36,7 @@ typedef struct libxl__sr_rec_hdr#define REC_TYPE_EMULATOR_XENSTORE_DATA 0x00000002U#define REC_TYPE_EMULATOR_CONTEXT 0x00000003U#define REC_TYPE_CHECKPOINT_END 0x00000004U +#define REC_TYPE_CHECKPOINT_STATE 0x00000005U typedef struct libxl__sr_emulator_hdr {
@@ -47,6 +48,16 @@ typedef struct libxl__sr_emulator_hdr#define EMULATOR_QEMU_TRADITIONAL 0x00000001U#define EMULATOR_QEMU_UPSTREAM 0x00000002U +typedef struct libxl_sr_checkpoint_state +{ +uint32_t id; +}libxl_sr_checkpoint_state ; + +#define CHECKPOINT_NEW 0x00000000U +#define CHECKPOINT_SVM_SUSPENDED 0x00000001U +#define CHECKPOINT_SVM_READY 0x00000002U +#define CHECKPOINT_SVM_RESUMED 0x00000003U +#endif /* LIBXL__SR_STREAM_FORMAT_H */ /*
tools/python/xen/migration/libxl.py +9 -0
@@ -37,6 +37,7 @@ REC_TYPE_libxc_context = 0x00000001 REC_TYPE_emulator_xenstore_data = 0x00000002 REC_TYPE_emulator_context = 0x00000003 REC_TYPE_checkpoint_end = 0x00000004 +REC_TYPE_checkpoint_state = 0x00000005 rec_type_to_str = { REC_TYPE_end : "End",
@@ -44,6 +45,7 @@ rec_type_to_str = { REC_TYPE_emulator_xenstore_data : "Emulator xenstore data", REC_TYPE_emulator_context : "Emulator context", REC_TYPE_checkpoint_end : "Checkpoint end", + REC_TYPE_checkpoint_state : "Checkpoint state" } # emulator_* header
@@ -212,6 +214,11 @@ class VerifyLibxl(VerifyBase): if len(content) != 0: raise RecordError("Checkpoint end record with non-zero length") + def verify_record_checkpoint_state(self, content): + """ Checkpoint state """ + if len(content) == 0: + raise RecordError("Checkpoint state record with zero length") + record_verifiers = { REC_TYPE_end:
@@ -224,4 +231,6 @@ record_verifiers = { VerifyLibxl.verify_record_emulator_context, REC_TYPE_checkpoint_end: VerifyLibxl.verify_record_checkpoint_end, + REC_TYPE_checkpoint_state: + VerifyLibxl.verify_record_checkpoint_state, }
Signature · 1 line
2.5.0
Re: [PATCH v10 07/31] docs/libxl: Introduce CHECKPOINT_CONTEXT to support migration v2 colo streams
Quoted 21 lines · Wen Congyang
It is the negotiation record for COLO.
Primary->Secondary:control_id0x00000000: Secondary VM is out of sync, start a new checkpointSecondary->Primary:0x00000001: Secondary VM is suspended 0x00000002: Secondary VM is ready 0x00000003: Secondary VM is resumedSigned-off-by Wen Congyang <[email protected]>Signed-off-by Yang Hongyang <[email protected]>--- docs/specs/libxl-migration-stream.pandoc | 25 +++++++++++++++++++++++-- tools/libxl/libxl_sr_stream_format.h | 11 +++++++++++ tools/python/xen/migration/libxl.py | 9 +++++++++ 3 files changed, 43 insertions(+), 2 deletions(-)docs/specs/libxl-migration-stream.pandoc +0
-0
docs/specs/libxl-migration-stream.pandoc line 2
Quoted 2 lines
docs/specs/libxl-migration-stream.pandoc +0
-0@@ -1,6 +1,6 @@ % LibXenLight Domain Image Format % Andrew Cooper <<[email protected]>>
You can add yours and Hongyang's name and email here as well.
Quoted 27 lines
docs/specs/libxl-migration-stream.pandoc +11
-2-% Revision 1 +% Revision 2 Introduction ============@@ -119,7 +119,9 @@ type 0x00000000: END 0x00000004: CHECKPOINT_END - 0x00000005 - 0x7FFFFFFF: Reserved for future _mandatory_ + 0x00000005: CHECKPOINT_STATE + + 0x00000006 - 0x7FFFFFFF: Reserved for future _mandatory_ records. 0x80000000 - 0xFFFFFFFF: Reserved for future _optional_@@ -249,6 +251,25 @@ A checkpoint end record marks the end of a checkpoint in the image. The end record contains no fields; its body_length is 0. +CHECKPOINT\_STATE +-------------- + +A checkpoint state record contains the control information for checkpoint. + + 0 1 2 3 4 5 6 7 octet + +------------------------+------------------------+
docs/specs/libxl-migration-stream.pandoc A checkpoint end record marks the end of a checkpoint in the image. · line 270
Quoted 10 lines
docs/specs/libxl-migration-stream.pandoc +10
-0+ | control_id | padding | + +------------------------+------------------------+ + +-------------------------------------------------------------------- +Field Description +------------ --------------------------------------------------- +control_id 0x00000000: Secondary VM is out of sync, start a new checkpoint + 0x00000001: Secondary VM is suspended + 0x00000002: Secondary VM is ready + 0x00000003: Secondary VM is resumed
You commit message seems to suggest 0 can only go from primary to secondary, while the other three only go from secondary to primary. You probably need to spell out the direction here (and later enforce this behaviour in code).
Wei.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH v10 07/31] docs/libxl: Introduce CHECKPOINT_CONTEXT to support migration v2 colo streams
Quoted 17 lines · Wei Liu
Quoted 16 lines · Wen Congyang
It is the negotiation record for COLO.
Primary->Secondary:control_id0x00000000: Secondary VM is out of sync, start a new checkpointSecondary->Primary:0x00000001: Secondary VM is suspended 0x00000002: Secondary VM is ready 0x00000003: Secondary VM is resumedSigned-off-by Wen Congyang <[email protected]>Signed-off-by Yang Hongyang <[email protected]>--- docs/specs/libxl-migration-stream.pandoc | 25 +++++++++++++++++++++++-- tools/libxl/libxl_sr_stream_format.h | 11 +++++++++++ tools/python/xen/migration/libxl.py | 9 +++++++++ 3 files changed, 43 insertions(+), 2 deletions(-)
Quoted 9 lines
docs/specs/libxl-migration-stream.pandoc line 2
Quoted 7 lines
docs/specs/libxl-migration-stream.pandoc +0
-0@@ -1,6 +1,6 @@ % LibXenLight Domain Image Format % Andrew Cooper <<[email protected]>>You can add yours and Hongyang's name and email here as well.
OK
Quoted 35 lines
Quoted 35 lines
docs/specs/libxl-migration-stream.pandoc +18
-2-% Revision 1 +% Revision 2 Introduction ============@@ -119,7 +119,9 @@ type 0x00000000: END 0x00000004: CHECKPOINT_END - 0x00000005 - 0x7FFFFFFF: Reserved for future _mandatory_ + 0x00000005: CHECKPOINT_STATE + + 0x00000006 - 0x7FFFFFFF: Reserved for future _mandatory_ records. 0x80000000 - 0xFFFFFFFF: Reserved for future _optional_@@ -249,6 +251,25 @@ A checkpoint end record marks the end of a checkpoint in the image. The end record contains no fields; its body_length is 0. +CHECKPOINT\_STATE +-------------- + +A checkpoint state record contains the control information for checkpoint. + + 0 1 2 3 4 5 6 7 octet + +------------------------+------------------------+ + | control_id | padding | + +------------------------+------------------------+ + +-------------------------------------------------------------------- +Field Description +------------ --------------------------------------------------- +control_id 0x00000000: Secondary VM is out of sync, start a new checkpoint
Quoted 8 lines
docs/specs/libxl-migration-stream.pandoc A checkpoint end record marks the end of a checkpoint in the image. · line 270
Quoted 3 lines
docs/specs/libxl-migration-stream.pandoc +3
-0+ 0x00000001: Secondary VM is suspended + 0x00000002: Secondary VM is ready + 0x00000003: Secondary VM is resumedYou commit message seems to suggest 0 can only go from primary to secondary, while the other three only go from secondary to primary. You probably need to spell out the direction here (and later enforce this behaviour in code).
OK, will fix it in the next version.
Thanks
Wen Congyang
Quoted 6 lines
Wei.
.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
PATCH v10 8/31 libxc/migration: Specification update for DIRTY_PFN_LIST records
In reply to Wen CongyangUsed by secondary to send it's dirty bitmap to primary under COLO.
--- docs/specs/libxc-migration-stream.pandoc | 24 ++++++++++- tools/libxc/xc_sr_common.c | 31 ++++++++------- tools/libxc/xc_sr_stream_format.h | 31 ++++++++------- tools/python/xen/migration/libxc.py | 68 ++++++++++++++++++-------------- 4 files changed, 93 insertions(+), 61 deletions(-)
docs/specs/libxc-migration-stream.pandoc +23 -1
@@ -227,7 +227,9 @@ type 0x00000000: END 0x0000000E: CHECKPOINT - 0x0000000F - 0x7FFFFFFF: Reserved for future _mandatory_ + 0x0000000F: CHECKPOINT_DIRTY_PFN_LIST + + 0x00000010 - 0x7FFFFFFF: Reserved for future _mandatory_ records. 0x80000000 - 0xFFFFFFFF: Reserved for future _optional_
@@ -599,6 +601,26 @@ CHECKPOINT record or an END record. \clearpage +CHECKPOINT_DIRTY_PFN_LIST +------------ + +A checkpoint dirty pfn list record is used to convey information about +dirty memory in the VM. It is an unordered list of PFNs. Currently only +applicable in the backchannel of a checkpointed stream. + + 0 1 2 3 4 5 6 7 octet + +-------------------------------------------------+ + | pfn[0] | + +-------------------------------------------------+ + ... + +-------------------------------------------------+ + | pfn[C-1] | + +-------------------------------------------------+ + +The count of pfns is: record->length/sizeof(uint64_t). + +\clearpage + Layout ======
tools/libxc/xc_sr_common.c +16 -15
@@ -20,21 +20,22 @@ const char *dhdr_type_to_str(uint32_t type)static const char *mandatory_rec_types[] = { - [REC_TYPE_END ] ="End" , - [REC_TYPE_PAGE_DATA ] ="Page data" , - [REC_TYPE_X86_PV_INFO ] ="x86 PV info" , - [REC_TYPE_X86_PV_P2M_FRAMES ] ="x86 PV P2M frames" , - [REC_TYPE_X86_PV_VCPU_BASIC ] ="x86 PV vcpu basic" , - [REC_TYPE_X86_PV_VCPU_EXTENDED ] ="x86 PV vcpu extended" , - [REC_TYPE_X86_PV_VCPU_XSAVE ] ="x86 PV vcpu xsave" , - [REC_TYPE_SHARED_INFO ] ="Shared info" , - [REC_TYPE_TSC_INFO ] ="TSC info" , - [REC_TYPE_HVM_CONTEXT ] ="HVM context" , - [REC_TYPE_HVM_PARAMS ] ="HVM params" , - [REC_TYPE_TOOLSTACK ] ="Toolstack" , - [REC_TYPE_X86_PV_VCPU_MSRS ] ="x86 PV vcpu msrs" , - [REC_TYPE_VERIFY ] ="Verify" , - [REC_TYPE_CHECKPOINT ] ="Checkpoint" , + [REC_TYPE_END ] ="End" , + [REC_TYPE_PAGE_DATA ] ="Page data" , + [REC_TYPE_X86_PV_INFO ] ="x86 PV info" , + [REC_TYPE_X86_PV_P2M_FRAMES ] ="x86 PV P2M frames" , + [REC_TYPE_X86_PV_VCPU_BASIC ] ="x86 PV vcpu basic" , + [REC_TYPE_X86_PV_VCPU_EXTENDED ] ="x86 PV vcpu extended" , + [REC_TYPE_X86_PV_VCPU_XSAVE ] ="x86 PV vcpu xsave" , + [REC_TYPE_SHARED_INFO ] ="Shared info" , + [REC_TYPE_TSC_INFO ] ="TSC info" , + [REC_TYPE_HVM_CONTEXT ] ="HVM context" , + [REC_TYPE_HVM_PARAMS ] ="HVM params" , + [REC_TYPE_TOOLSTACK ] ="Toolstack" , + [REC_TYPE_X86_PV_VCPU_MSRS ] ="x86 PV vcpu msrs" , + [REC_TYPE_VERIFY ] ="Verify" , + [REC_TYPE_CHECKPOINT ] ="Checkpoint" , + [REC_TYPE_CHECKPOINT_DIRTY_PFN_LIST ] ="Checkpoint dirty pfn list" , };const char *rec_type_to_str (uint32_t type)
tools/libxc/xc_sr_stream_format.h +16 -15
@@ -60,21 +60,22 @@ struct xc_sr_rhdr/* Somewhat arbitrary - 8MB */ #define REC_LENGTH_MAX (8U << 20) -#define REC_TYPE_END 0x00000000U -#define REC_TYPE_PAGE_DATA 0x00000001U -#define REC_TYPE_X86_PV_INFO 0x00000002U -#define REC_TYPE_X86_PV_P2M_FRAMES 0x00000003U -#define REC_TYPE_X86_PV_VCPU_BASIC 0x00000004U -#define REC_TYPE_X86_PV_VCPU_EXTENDED 0x00000005U -#define REC_TYPE_X86_PV_VCPU_XSAVE 0x00000006U -#define REC_TYPE_SHARED_INFO 0x00000007U -#define REC_TYPE_TSC_INFO 0x00000008U -#define REC_TYPE_HVM_CONTEXT 0x00000009U -#define REC_TYPE_HVM_PARAMS 0x0000000aU -#define REC_TYPE_TOOLSTACK 0x0000000bU -#define REC_TYPE_X86_PV_VCPU_MSRS 0x0000000cU -#define REC_TYPE_VERIFY 0x0000000dU -#define REC_TYPE_CHECKPOINT 0x0000000eU +#define REC_TYPE_END 0x00000000U +#define REC_TYPE_PAGE_DATA 0x00000001U +#define REC_TYPE_X86_PV_INFO 0x00000002U +#define REC_TYPE_X86_PV_P2M_FRAMES 0x00000003U +#define REC_TYPE_X86_PV_VCPU_BASIC 0x00000004U +#define REC_TYPE_X86_PV_VCPU_EXTENDED 0x00000005U +#define REC_TYPE_X86_PV_VCPU_XSAVE 0x00000006U +#define REC_TYPE_SHARED_INFO 0x00000007U +#define REC_TYPE_TSC_INFO 0x00000008U +#define REC_TYPE_HVM_CONTEXT 0x00000009U +#define REC_TYPE_HVM_PARAMS 0x0000000aU +#define REC_TYPE_TOOLSTACK 0x0000000bU +#define REC_TYPE_X86_PV_VCPU_MSRS 0x0000000cU +#define REC_TYPE_VERIFY 0x0000000dU +#define REC_TYPE_CHECKPOINT 0x0000000eU +#define REC_TYPE_CHECKPOINT_DIRTY_PFN_LIST 0x0000000fU#define REC_TYPE_OPTIONAL 0x80000000U
tools/python/xen/migration/libxc.py +38 -30
86 lines not on this page · raw message
Signature · 1 line
2.5.0
PATCH v10 9/31 libxc/migration: export read_record for common use
In reply to Wen Congyangread_record() could be used by primary to read dirty bitmap record sent by secondary under COLO.
When used by save side, we need to pass the backchannel fd instead of ctx->fd to read_record(), so we added a fd param to it.
No functional changes.
--- tools/libxc/xc_sr_common.c | 49 +++++++++++++++++++++++++++++++++++ tools/libxc/xc_sr_common.h | 14 ++++++++++ tools/libxc/xc_sr_restore.c | 63 +-------------------------------------------- 3 files changed, 64 insertions(+), 62 deletions(-)
tools/libxc/xc_sr_common.c +49 -0
@@ -89,6 +89,55 @@ int write_split_record(struct xc_sr_context *ctx, struct xc_sr_record *rec,return -1 ; } +int read_record (struct xc_sr_context *ctx,int fd,struct xc_sr_record *rec) +{ +xc_interface *xch = ctx->xch; +struct xc_sr_rhdr rhdr; +size_t datasz; + +if (read_exact (fd, &rhdr,sizeof (rhdr)) ) + { +PERROR ("Failed to read Record Header from stream" ); +return -1 ; + } +else if ( rhdr.length >REC_LENGTH_MAX ) + { +ERROR ("Record (0x%08x, %s) length %#x exceeds max (%#x)" , rhdr.type, +rec_type_to_str (rhdr.type), rhdr.length,REC_LENGTH_MAX ); +return -1 ; + } + + datasz =ROUNDUP (rhdr.length,REC_ALIGN_ORDER ); + +if ( datasz ) + { + rec->data =malloc (datasz); + +if ( !rec->data ) + { +ERROR ("Unable to allocate %zu bytes for record data (0x%08x, %s)" , + datasz, rhdr.type,rec_type_to_str (rhdr.type)); +return -1 ; + } + +if (read_exact (fd, rec->data, datasz) ) + { +free (rec->data); + rec->data =NULL ; +PERROR ("Failed to read %zu bytes of data for record (0x%08x, %s)" , + datasz, rhdr.type,rec_type_to_str (rhdr.type)); +return -1 ; + } + } +else + rec->data =NULL ; + + rec->type = rhdr.type; + rec->length = rhdr.length; + +return 0 ; +}; +static void __attribute__((unused))build_assertions (void ) {XC_BUILD_BUG_ON (sizeof (struct xc_sr_ihdr ) !=24 );
tools/libxc/xc_sr_common.h +14 -0
@@ -382,6 +382,20 @@ static inline int write_record(struct xc_sr_context *ctx, }/* +* Reads a record from the stream, and fills in the record structure. +* +* Returns 0 on success and non-0 on failure. +* +* On success, the records type and size shall be valid. +* - If size is 0, data shall be NULL. +* - If size is non-0, data shall be a buffer allocated by malloc() which must +* be passed to free() by the caller. +* +* On failure, the contents of the record structure are undefined. +*/ +int read_record (struct xc_sr_context *ctx,int fd,struct xc_sr_record *rec); + +/* * This would ideally be private in restore.c, but is needed by * x86_pv_localise_page() if we receive pagetables frames ahead of the * contents of the frames they point at.
tools/libxc/xc_sr_restore.c +1 -62
75 lines not on this page · raw message
Signature · 1 line
2.5.0
PATCH v10 10/31 tools/libxl: add back channel support to write stream
In reply to Wen CongyangAdd back channel support to write stream. If the write stream is a back channel stream, this means the write stream is used by Secondary to send some records back.
--- tools/libxl/libxl_dom_save.c | 1 + tools/libxl/libxl_internal.h | 1 + tools/libxl/libxl_stream_write.c | 26 ++++++++++++++++++++------ 3 files changed, 22 insertions(+), 6 deletions(-)
tools/libxl/libxl_dom_save.c +1 -0
@@ -404,6 +404,7 @@ void libxl__domain_save(libxl__egc *egc, libxl__domain_save_state *dss) dss->sws.ao = dss->ao; dss->sws.dss = dss; dss->sws.fd = dss->fd; + dss->sws.back_channel = false; dss->sws.completion_callback = stream_done;libxl__stream_write_start (egc, &dss->sws);
tools/libxl/libxl_internal.h +1 -0
@@ -3044,6 +3044,7 @@ struct libxl__stream_write_state {libxl__ao *ao;libxl__domain_save_state *dss;int fd; +bool back_channel;void (*completion_callback)(libxl__egc *egc,libxl__stream_write_state *sws,int rc);
tools/libxl/libxl_stream_write.c +20 -6
@@ -49,6 +49,13 @@* - if (hvm) * - Emulator context record * - Checkpoint end record +* +* For back channel stream: +* - libxl__stream_write_start() +* - Set up the stream to running state +* +* - Add a new API to write the record. When the record is written +* out, call stream->checkpoint_callback() to return. */ /* Success/error/cleanup handling. */
@@ -225,6 +232,15 @@ void libxl__stream_write_start(libxl__egc *egc, stream->running = true; + dc->ao = ao; + dc->readfd =-1 ; + dc->copywhat ="save v2 stream" ; + dc->writefd = stream->fd; + dc->maxsz =-1 ; + +if (stream->back_channel) +return ; +if (dss->type ==LIBXL_DOMAIN_TYPE_HVM ) { stream->device_model_version =libxl__device_model_version_running (gc, dss->domid);
@@ -249,12 +265,7 @@ void libxl__stream_write_start(libxl__egc *egc, stream->emu_sub_hdr.index =0 ; } - dc->ao = ao; - dc->readfd =-1 ; dc->writewhat ="stream header" ; - dc->copywhat ="save v2 stream" ; - dc->writefd = stream->fd; - dc->maxsz =-1 ; dc->callback = stream_header_done; rc =libxl__datacopier_start (dc);
@@ -279,6 +290,7 @@ void libxl__stream_write_start_checkpoint(libxl__egc *egc, {assert (stream->running);assert (!stream->in_checkpoint); +assert (!stream->back_channel); stream->in_checkpoint = true;write_emulator_xenstore_record (egc, stream);
@@ -590,7 +602,9 @@ static void stream_done(libxl__egc *egc,libxl__carefd_close (stream->emu_carefd);free (stream->emu_body); -check_all_finished (egc, stream, rc); +if (!stream->back_channel) +/* back channel stream doesn't have save helper */ +check_all_finished (egc, stream, rc); } static void checkpoint_done(libxl__egc *egc,
Signature · 1 line
2.5.0
Re: [PATCH v10 10/31] tools/libxl: add back channel support to write stream
Quoted 41 lines · Wen Congyang
Add back channel support to write stream. If the write stream is a back channel stream, this means the write stream is used by Secondary to send some records back.
Signed-off-by Yang Hongyang <[email protected]>Signed-off-by Wen Congyang <[email protected]>--- tools/libxl/libxl_dom_save.c | 1 + tools/libxl/libxl_internal.h | 1 + tools/libxl/libxl_stream_write.c | 26 ++++++++++++++++++++------ 3 files changed, 22 insertions(+), 6 deletions(-)tools/libxl/libxl_dom_save.c +1
-0@@ -404,6 +404,7 @@ void libxl__domain_save(libxl__egc *egc, libxl__domain_save_state *dss) dss->sws.ao = dss->ao; dss->sws.dss = dss; dss->sws.fd = dss->fd; + dss->sws.back_channel = false; dss->sws.completion_callback = stream_done;libxl__stream_write_start (egc, &dss->sws);tools/libxl/libxl_internal.h +1
-0@@ -3044,6 +3044,7 @@ struct libxl__stream_write_state {libxl__ao *ao;libxl__domain_save_state *dss;int fd; +bool back_channel;void (*completion_callback)(libxl__egc *egc,libxl__stream_write_state *sws,int rc);tools/libxl/libxl_stream_write.c +0
-0
tools/libxl/libxl_stream_write.c line 58
Quoted 10 lines
tools/libxl/libxl_stream_write.c +7
-0@@ -49,6 +49,13 @@* - if (hvm) * - Emulator context record * - Checkpoint end record +* +* For back channel stream: +* - libxl__stream_write_start() +* - Set up the stream to running state +* +* - Add a new API to write the record. When the record is written +* out, call stream->checkpoint_callback() to return.
What does this mean? Which new API?
Quoted 6 lines
tools/libxl/libxl_stream_write.c +0
-0*/ /* Success/error/cleanup handling. */ @@ -225,6 +232,15 @@ void libxl__stream_write_start(libxl__egc *egc, stream->running = true;
tools/libxl/libxl_stream_write.c void libxl__stream_write_start(libxl__egc *egc, · line 243
Quoted 10 lines
tools/libxl/libxl_stream_write.c +9
-0+ dc->ao = ao; + dc->readfd =-1 ; + dc->copywhat ="save v2 stream" ; + dc->writefd = stream->fd; + dc->maxsz =-1 ; + +if (stream->back_channel) +return ; +
There seems to be very subtle change of behaviour.
Before this patch, the dc->* are not set until the emulator check is done. With this path, it is possible in the normal case some of the fields are initialised in the error path.
I think this is OK given the callbacks in the upper layer and in the writer don't rely on those fields to clean up. Just one thing to note.
That said, I suggest you move all initialisation of dc->* in one place.
Quoted 25 lines
tools/libxl/libxl_stream_write.c +1
-5if (dss->type ==LIBXL_DOMAIN_TYPE_HVM ) { stream->device_model_version =libxl__device_model_version_running (gc, dss->domid);@@ -249,12 +265,7 @@ void libxl__stream_write_start(libxl__egc *egc, stream->emu_sub_hdr.index =0 ; } - dc->ao = ao; - dc->readfd =-1 ; dc->writewhat ="stream header" ; - dc->copywhat ="save v2 stream" ; - dc->writefd = stream->fd; - dc->maxsz =-1 ; dc->callback = stream_header_done; rc =libxl__datacopier_start (dc);@@ -279,6 +290,7 @@ void libxl__stream_write_start_checkpoint(libxl__egc *egc, {assert (stream->running);assert (!stream->in_checkpoint); +assert (!stream->back_channel); stream->in_checkpoint = true;write_emulator_xenstore_record (egc, stream);
tools/libxl/libxl_stream_write.c static void stream_done(libxl__egc *egc, · line 607
Quoted 7 lines
tools/libxl/libxl_stream_write.c +3
-1@@ -590,7 +602,9 @@ static void stream_done(libxl__egc *egc,libxl__carefd_close (stream->emu_carefd);free (stream->emu_body); -check_all_finished (egc, stream, rc); +if (!stream->back_channel) +/* back channel stream doesn't have save helper */ +check_all_finished (egc, stream, rc);
Though it doesn't have helper, do you not need to check if the back channel stream itself is OK? The comment itself doesn't seem to justify this change.
Wei.
Quoted 13 lines
tools/libxl/libxl_stream_write.c +0
-0} static void checkpoint_done(libxl__egc *egc,Signature · 9 lines
2.5.0 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH v10 10/31] tools/libxl: add back channel support to write stream
Quoted 46 lines · Wei Liu
Quoted 45 lines · Wen Congyang
Add back channel support to write stream. If the write stream is a back channel stream, this means the write stream is used by Secondary to send some records back.
Signed-off-by Yang Hongyang <[email protected]>Signed-off-by Wen Congyang <[email protected]>--- tools/libxl/libxl_dom_save.c | 1 + tools/libxl/libxl_internal.h | 1 + tools/libxl/libxl_stream_write.c | 26 ++++++++++++++++++++------ 3 files changed, 22 insertions(+), 6 deletions(-)tools/libxl/libxl_dom_save.c +1
-0@@ -404,6 +404,7 @@ void libxl__domain_save(libxl__egc *egc, libxl__domain_save_state *dss) dss->sws.ao = dss->ao; dss->sws.dss = dss; dss->sws.fd = dss->fd; + dss->sws.back_channel = false; dss->sws.completion_callback = stream_done;libxl__stream_write_start (egc, &dss->sws);tools/libxl/libxl_internal.h +1
-0@@ -3044,6 +3044,7 @@ struct libxl__stream_write_state {libxl__ao *ao;libxl__domain_save_state *dss;int fd; +bool back_channel;void (*completion_callback)(libxl__egc *egc,libxl__stream_write_state *sws,int rc);tools/libxl/libxl_stream_write.c +1
-0@@ -49,6 +49,13 @@* - if (hvm) * - Emulator context record * - Checkpoint end record +*
Quoted 8 lines
tools/libxl/libxl_stream_write.c line 58
Quoted 6 lines
tools/libxl/libxl_stream_write.c +6
-0+* For back channel stream: +* - libxl__stream_write_start() +* - Set up the stream to running state +* +* - Add a new API to write the record. When the record is written +* out, call stream->checkpoint_callback() to return. What does this mean? Which new API?
The next patch introduces this API. The commits is very old.
I think I can merge these two patches into one patch.
Quoted 24 lines
Quoted 7 lines
tools/libxl/libxl_stream_write.c +0
-0*/ /* Success/error/cleanup handling. */ @@ -225,6 +232,15 @@ void libxl__stream_write_start(libxl__egc *egc, stream->running = true;tools/libxl/libxl_stream_write.c void libxl__stream_write_start(libxl__egc *egc, · line 243
Quoted 10 lines
tools/libxl/libxl_stream_write.c +9
-0+ dc->ao = ao; + dc->readfd =-1 ; + dc->copywhat ="save v2 stream" ; + dc->writefd = stream->fd; + dc->maxsz =-1 ; + +if (stream->back_channel) +return ; +There seems to be very subtle change of behaviour.
Before this patch, the dc->* are not set until the emulator check is done. With this path, it is possible in the normal case some of the fields are initialised in the error path.
Quoted 5 lines
I think this is OK given the callbacks in the upper layer and in the writer don't rely on those fields to clean up. Just one thing to note.
That said, I suggest you move all initialisation of dc->* in one place.
OK, I will do it.
Quoted 29 lines
Quoted 29 lines
tools/libxl/libxl_stream_write.c +1
-5if (dss->type ==LIBXL_DOMAIN_TYPE_HVM ) { stream->device_model_version =libxl__device_model_version_running (gc, dss->domid);@@ -249,12 +265,7 @@ void libxl__stream_write_start(libxl__egc *egc, stream->emu_sub_hdr.index =0 ; } - dc->ao = ao; - dc->readfd =-1 ; dc->writewhat ="stream header" ; - dc->copywhat ="save v2 stream" ; - dc->writefd = stream->fd; - dc->maxsz =-1 ; dc->callback = stream_header_done; rc =libxl__datacopier_start (dc);@@ -279,6 +290,7 @@ void libxl__stream_write_start_checkpoint(libxl__egc *egc, {assert (stream->running);assert (!stream->in_checkpoint); +assert (!stream->back_channel); stream->in_checkpoint = true;write_emulator_xenstore_record (egc, stream);@@ -590,7 +602,9 @@ static void stream_done(libxl__egc *egc,libxl__carefd_close (stream->emu_carefd);free (stream->emu_body);
Quoted 8 lines
tools/libxl/libxl_stream_write.c static void stream_done(libxl__egc *egc, · line 607
Quoted 4 lines
tools/libxl/libxl_stream_write.c +3
-1-check_all_finished (egc, stream, rc); +if (!stream->back_channel) +/* back channel stream doesn't have save helper */ +check_all_finished (egc, stream, rc);Though it doesn't have helper, do you not need to check if the back channel stream itself is OK? The comment itself doesn't seem to justify this change.
What do you want to check? assert(!stream->shs) or assert(!libxl__stream_write_inuse(stream))?
Thanks
Wen Congyang
Quoted 12 lines
Wei.
Quoted 9 lines
tools/libxl/libxl_stream_write.c +0
-0} static void checkpoint_done(libxl__egc *egc,Signature · 1 line
2.5.0
Quoted 8 lines
Quoted 4 lines
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH v10 10/31] tools/libxl: add back channel support to write stream
Quoted 56 lines · Wen Congyang
Quoted 46 lines · Wei Liu
Quoted 45 lines · Wen Congyang
Add back channel support to write stream. If the write stream is a back channel stream, this means the write stream is used by Secondary to send some records back.
Signed-off-by Yang Hongyang <[email protected]>Signed-off-by Wen Congyang <[email protected]>--- tools/libxl/libxl_dom_save.c | 1 + tools/libxl/libxl_internal.h | 1 + tools/libxl/libxl_stream_write.c | 26 ++++++++++++++++++++------ 3 files changed, 22 insertions(+), 6 deletions(-)tools/libxl/libxl_dom_save.c +1
-0@@ -404,6 +404,7 @@ void libxl__domain_save(libxl__egc *egc, libxl__domain_save_state *dss) dss->sws.ao = dss->ao; dss->sws.dss = dss; dss->sws.fd = dss->fd; + dss->sws.back_channel = false; dss->sws.completion_callback = stream_done;libxl__stream_write_start (egc, &dss->sws);tools/libxl/libxl_internal.h +1
-0@@ -3044,6 +3044,7 @@ struct libxl__stream_write_state {libxl__ao *ao;libxl__domain_save_state *dss;int fd; +bool back_channel;void (*completion_callback)(libxl__egc *egc,libxl__stream_write_state *sws,int rc);tools/libxl/libxl_stream_write.c +1
-0@@ -49,6 +49,13 @@* - if (hvm) * - Emulator context record * - Checkpoint end record +* Quoted 8 lines
tools/libxl/libxl_stream_write.c line 58
Quoted 6 lines
tools/libxl/libxl_stream_write.c +6
-0+* For back channel stream: +* - libxl__stream_write_start() +* - Set up the stream to running state +* +* - Add a new API to write the record. When the record is written +* out, call stream->checkpoint_callback() to return. What does this mean? Which new API?
Quoted 4 lines
The next patch introduces this API. The commits is very old.
I think I can merge these two patches into one patch.
Please reference the actual function / API.
Quoted 70 lines
Quoted 24 lines
Quoted 7 lines
tools/libxl/libxl_stream_write.c +0
-0*/ /* Success/error/cleanup handling. */ @@ -225,6 +232,15 @@ void libxl__stream_write_start(libxl__egc *egc, stream->running = true;tools/libxl/libxl_stream_write.c void libxl__stream_write_start(libxl__egc *egc, · line 243
Quoted 10 lines
tools/libxl/libxl_stream_write.c +9
-0+ dc->ao = ao; + dc->readfd =-1 ; + dc->copywhat ="save v2 stream" ; + dc->writefd = stream->fd; + dc->maxsz =-1 ; + +if (stream->back_channel) +return ; +There seems to be very subtle change of behaviour.
Before this patch, the dc->* are not set until the emulator check is done. With this path, it is possible in the normal case some of the fields are initialised in the error path.
Quoted 5 lines
I think this is OK given the callbacks in the upper layer and in the writer don't rely on those fields to clean up. Just one thing to note.
That said, I suggest you move all initialisation of dc->* in one place.
OK, I will do it.
Quoted 29 lines
Quoted 29 lines
tools/libxl/libxl_stream_write.c +1
-5if (dss->type ==LIBXL_DOMAIN_TYPE_HVM ) { stream->device_model_version =libxl__device_model_version_running (gc, dss->domid);@@ -249,12 +265,7 @@ void libxl__stream_write_start(libxl__egc *egc, stream->emu_sub_hdr.index =0 ; } - dc->ao = ao; - dc->readfd =-1 ; dc->writewhat ="stream header" ; - dc->copywhat ="save v2 stream" ; - dc->writefd = stream->fd; - dc->maxsz =-1 ; dc->callback = stream_header_done; rc =libxl__datacopier_start (dc);@@ -279,6 +290,7 @@ void libxl__stream_write_start_checkpoint(libxl__egc *egc, {assert (stream->running);assert (!stream->in_checkpoint); +assert (!stream->back_channel); stream->in_checkpoint = true;write_emulator_xenstore_record (egc, stream);@@ -590,7 +602,9 @@ static void stream_done(libxl__egc *egc,libxl__carefd_close (stream->emu_carefd);free (stream->emu_body);Quoted 8 lines
tools/libxl/libxl_stream_write.c static void stream_done(libxl__egc *egc, · line 607
Quoted 4 lines
tools/libxl/libxl_stream_write.c +3
-1-check_all_finished (egc, stream, rc); +if (!stream->back_channel) +/* back channel stream doesn't have save helper */ +check_all_finished (egc, stream, rc);Though it doesn't have helper, do you not need to check if the back channel stream itself is OK? The comment itself doesn't seem to justify this change.
Quoted 2 lines
What do you want to check?
assert(!stream->shs)or assert(!libxl__stream_write_inuse(stream))?
The stream itself is not in use.
Also check_all_finished calls completion_callback. Don't you need that, too?
Wei.
Quoted 27 lines
Thanks
Wen CongyangQuoted 20 lines
Wei.
Quoted 13 lines
tools/libxl/libxl_stream_write.c +0
-0} static void checkpoint_done(libxl__egc *egc,Signature · 9 lines
2.5.0 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH v10 10/31] tools/libxl: add back channel support to write stream
Quoted 134 lines · Wei Liu
Quoted 56 lines · Wen Congyang
Quoted 46 lines · Wei Liu
Quoted 45 lines · Wen Congyang
Add back channel support to write stream. If the write stream is a back channel stream, this means the write stream is used by Secondary to send some records back.
Signed-off-by Yang Hongyang <[email protected]>Signed-off-by Wen Congyang <[email protected]>--- tools/libxl/libxl_dom_save.c | 1 + tools/libxl/libxl_internal.h | 1 + tools/libxl/libxl_stream_write.c | 26 ++++++++++++++++++++------ 3 files changed, 22 insertions(+), 6 deletions(-)tools/libxl/libxl_dom_save.c +1
-0@@ -404,6 +404,7 @@ void libxl__domain_save(libxl__egc *egc, libxl__domain_save_state *dss) dss->sws.ao = dss->ao; dss->sws.dss = dss; dss->sws.fd = dss->fd; + dss->sws.back_channel = false; dss->sws.completion_callback = stream_done;libxl__stream_write_start (egc, &dss->sws);tools/libxl/libxl_internal.h +1
-0@@ -3044,6 +3044,7 @@ struct libxl__stream_write_state {libxl__ao *ao;libxl__domain_save_state *dss;int fd; +bool back_channel;void (*completion_callback)(libxl__egc *egc,libxl__stream_write_state *sws,int rc);tools/libxl/libxl_stream_write.c +1
-0@@ -49,6 +49,13 @@* - if (hvm) * - Emulator context record * - Checkpoint end record +* Quoted 8 lines
tools/libxl/libxl_stream_write.c line 58
Quoted 6 lines
tools/libxl/libxl_stream_write.c +6
-0+* For back channel stream: +* - libxl__stream_write_start() +* - Set up the stream to running state +* +* - Add a new API to write the record. When the record is written +* out, call stream->checkpoint_callback() to return. What does this mean? Which new API?
Quoted 4 lines
The next patch introduces this API. The commits is very old.
I think I can merge these two patches into one patch.
Please reference the actual function / API.
Quoted 70 lines
Quoted 24 lines
Quoted 7 lines
tools/libxl/libxl_stream_write.c +0
-0*/ /* Success/error/cleanup handling. */ @@ -225,6 +232,15 @@ void libxl__stream_write_start(libxl__egc *egc, stream->running = true;tools/libxl/libxl_stream_write.c void libxl__stream_write_start(libxl__egc *egc, · line 243
Quoted 10 lines
tools/libxl/libxl_stream_write.c +9
-0+ dc->ao = ao; + dc->readfd =-1 ; + dc->copywhat ="save v2 stream" ; + dc->writefd = stream->fd; + dc->maxsz =-1 ; + +if (stream->back_channel) +return ; +There seems to be very subtle change of behaviour.
Before this patch, the dc->* are not set until the emulator check is done. With this path, it is possible in the normal case some of the fields are initialised in the error path.
Quoted 5 lines
I think this is OK given the callbacks in the upper layer and in the writer don't rely on those fields to clean up. Just one thing to note.
That said, I suggest you move all initialisation of dc->* in one place.
OK, I will do it.
Quoted 37 lines
Quoted 26 lines
tools/libxl/libxl_stream_write.c +1
-5if (dss->type ==LIBXL_DOMAIN_TYPE_HVM ) { stream->device_model_version =libxl__device_model_version_running (gc, dss->domid);@@ -249,12 +265,7 @@ void libxl__stream_write_start(libxl__egc *egc, stream->emu_sub_hdr.index =0 ; } - dc->ao = ao; - dc->readfd =-1 ; dc->writewhat ="stream header" ; - dc->copywhat ="save v2 stream" ; - dc->writefd = stream->fd; - dc->maxsz =-1 ; dc->callback = stream_header_done; rc =libxl__datacopier_start (dc);@@ -279,6 +290,7 @@ void libxl__stream_write_start_checkpoint(libxl__egc *egc, {assert (stream->running);assert (!stream->in_checkpoint); +assert (!stream->back_channel); stream->in_checkpoint = true;write_emulator_xenstore_record (egc, stream);tools/libxl/libxl_stream_write.c static void stream_done(libxl__egc *egc, · line 607
Quoted 7 lines
tools/libxl/libxl_stream_write.c +3
-1@@ -590,7 +602,9 @@ static void stream_done(libxl__egc *egc,libxl__carefd_close (stream->emu_carefd);free (stream->emu_body); -check_all_finished (egc, stream, rc); +if (!stream->back_channel) +/* back channel stream doesn't have save helper */ +check_all_finished (egc, stream, rc);Though it doesn't have helper, do you not need to check if the back channel stream itself is OK? The comment itself doesn't seem to justify this change.
Quoted 5 lines
Quoted 2 lines
What do you want to check?
assert(!stream->shs)or assert(!libxl__stream_write_inuse(stream))?The stream itself is not in use.
We set stream->running to false in stream_done, so libxl__stream_write_inuse() will return false. So I think there is no need to check it. I will update the comments to document it.
Quoted 3 lines
Also
check_all_finishedcallscompletion_callback. Don't you need that, too?
back channel stream doesn't have completion_callback. See the comments in check_all_finished().
Thanks
Wen Congyang
Quoted 25 lines
Wei.
Quoted 22 lines
Thanks
Wen CongyangQuoted 18 lines
Wei.
Quoted 13 lines
tools/libxl/libxl_stream_write.c +0
-0} static void checkpoint_done(libxl__egc *egc,Signature · 9 lines
2.5.0 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
Quoted 9 lines
Quoted 5 lines
Quoted 2 lines
.
.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
PATCH v10 11/31 tools/libxl: write checkpoint_state records into the stream
In reply to Wen Congyangwrite checkpoint_state records into the stream, used by both primary and secondary to send colo context.
--- tools/libxl/libxl_internal.h | 5 ++++ tools/libxl/libxl_stream_write.c | 60 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 64 insertions(+), 1 deletion(-)
tools/libxl/libxl_internal.h +5 -0
@@ -3056,6 +3056,7 @@ struct libxl__stream_write_state {bool running;bool in_checkpoint;bool sync_teardown;/* Only used to coordinate shutdown on error path. */ +bool in_checkpoint_state;libxl__save_helper_state shs;/* Main stream-writing data. */
@@ -3079,6 +3080,10 @@ _hidden void libxl__stream_write_start(libxl__egc *egc, _hidden voidlibxl__stream_write_start_checkpoint (libxl__egc *egc,libxl__stream_write_state *stream); +_hidden void +libxl__stream_write_checkpoint_state (libxl__egc *egc, +libxl__stream_write_state *stream, +libxl_sr_checkpoint_state *srcs); _hidden void libxl__stream_write_abort(libxl__egc *egc,libxl__stream_write_state *stream,int rc);
tools/libxl/libxl_stream_write.c +59 -1
84 lines not on this page · raw message
Signature · 1 line
2.5.0
PATCH v10 12/31 tools/libxl: add back channel support to read stream
In reply to Wen CongyangThis is used by primay to read records sent by secondary.
--- tools/libxl/libxl_create.c | 1 + tools/libxl/libxl_internal.h | 1 + tools/libxl/libxl_stream_read.c | 27 +++++++++++++++++++++++---- 3 files changed, 25 insertions(+), 4 deletions(-)
tools/libxl/libxl_create.c +1 -0
@@ -1030,6 +1030,7 @@ static void domcreate_bootloader_done(libxl__egc *egc, dcs->srs.dcs = dcs; dcs->srs.fd = restore_fd; dcs->srs.legacy = (dcs->restore_params.stream_version ==1 ); + dcs->srs.back_channel = false; dcs->srs.completion_callback = domcreate_stream_done;if (restore_fd >=0 ) {
tools/libxl/libxl_internal.h +1 -0
@@ -3420,6 +3420,7 @@ struct libxl__stream_read_state {libxl__domain_create_state *dcs;int fd;bool legacy; +bool back_channel;void (*completion_callback)(libxl__egc *egc,libxl__stream_read_state *srs,int rc);
tools/libxl/libxl_stream_read.c +23 -4
@@ -118,6 +118,15 @@* record, and therefore the buffered state is inconsistent. In * libxl__xc_domain_restore_done(), we just complete the stream and * stream->completion_callback() will be called to resume the guest +* +* For back channel stream: +* - libxl__stream_read_start() +* - Set up the stream to running state +* +* - libxl__stream_read_continue() +* - Set up reading the next record from a started stream. +* Add some codes to process_record() to handle the record. +* Then call stream->checkpoint_callback() to return. */ /* Success/error/cleanup handling. */
@@ -221,6 +230,17 @@ void libxl__stream_read_start(libxl__egc *egc, stream->running = true; stream->phase =SRS_PHASE_NORMAL ; + dc->ao = stream->ao; + dc->copywhat ="restore v2 stream" ; + dc->writefd =-1 ; + +if (stream->back_channel) { +assert (!stream->legacy); + + dc->readfd = stream->fd; +return ; + } +if (stream->legacy) {/* Convert the legacy stream. */ libxl__conversion_helper_state *chs = &stream->chs;
@@ -243,10 +263,7 @@ void libxl__stream_read_start(libxl__egc *egc, }/* stream->fd is now a v2 stream. */ - dc->ao = stream->ao; - dc->copywhat ="restore v2 stream" ; dc->readfd = stream->fd; - dc->writefd =-1 ;/* Start reading the stream header. */ rc = setup_read(stream, "stream header",
@@ -762,7 +779,9 @@ static void stream_done(libxl__egc *egc, LIBXL_STAILQ_FOREACH_SAFE(rec, &stream->record_queue, entry, trec)free_record (rec); -check_all_finished (egc, stream, rc); +if (!stream->back_channel) +/* back channel stream doesn't have restore helper */ +check_all_finished (egc, stream, rc); } void libxl__xc_domain_restore_done(libxl__egc *egc, void *dcs_void,
Signature · 1 line
2.5.0
Re: [PATCH v10 12/31] tools/libxl: add back channel support to read stream
Quoted 56 lines · Wen Congyang
This is used by primay to read records sent by secondary.
Signed-off-by Yang Hongyang <[email protected]>Signed-off-by Wen Congyang <[email protected]>--- tools/libxl/libxl_create.c | 1 + tools/libxl/libxl_internal.h | 1 + tools/libxl/libxl_stream_read.c | 27 +++++++++++++++++++++++---- 3 files changed, 25 insertions(+), 4 deletions(-)tools/libxl/libxl_create.c +1
-0@@ -1030,6 +1030,7 @@ static void domcreate_bootloader_done(libxl__egc *egc, dcs->srs.dcs = dcs; dcs->srs.fd = restore_fd; dcs->srs.legacy = (dcs->restore_params.stream_version ==1 ); + dcs->srs.back_channel = false; dcs->srs.completion_callback = domcreate_stream_done;if (restore_fd >=0 ) {tools/libxl/libxl_internal.h +1
-0@@ -3420,6 +3420,7 @@ struct libxl__stream_read_state {libxl__domain_create_state *dcs;int fd;bool legacy; +bool back_channel;void (*completion_callback)(libxl__egc *egc,libxl__stream_read_state *srs,int rc);tools/libxl/libxl_stream_read.c +9
-0@@ -118,6 +118,15 @@* record, and therefore the buffered state is inconsistent. In * libxl__xc_domain_restore_done(), we just complete the stream and * stream->completion_callback() will be called to resume the guest +* +* For back channel stream: +* - libxl__stream_read_start() +* - Set up the stream to running state +* +* - libxl__stream_read_continue() +* - Set up reading the next record from a started stream. +* Add some codes to process_record() to handle the record. +* Then call stream->checkpoint_callback() to return. */ /* Success/error/cleanup handling. */ @@ -221,6 +230,17 @@ void libxl__stream_read_start(libxl__egc *egc, stream->running = true;
tools/libxl/libxl_stream_read.c void libxl__stream_read_start(libxl__egc *egc, · line 240
Quoted 10 lines
tools/libxl/libxl_stream_read.c +8
-0stream->phase =SRS_PHASE_NORMAL ; + dc->ao = stream->ao; + dc->copywhat ="restore v2 stream" ; + dc->writefd =-1 ; + +if (stream->back_channel) { +assert (!stream->legacy); + + dc->readfd = stream->fd;
Why is this needed? dc->readfd is set to stream->fd no matter it is back channel or not. This can be moved outside this if {}.
Quoted 18 lines
tools/libxl/libxl_stream_read.c +3
-3+return ; + } +if (stream->legacy) {/* Convert the legacy stream. */ libxl__conversion_helper_state *chs = &stream->chs;@@ -243,10 +263,7 @@ void libxl__stream_read_start(libxl__egc *egc, }/* stream->fd is now a v2 stream. */ - dc->ao = stream->ao; - dc->copywhat ="restore v2 stream" ; dc->readfd = stream->fd; - dc->writefd =-1 ;/* Start reading the stream header. */ rc = setup_read(stream, "stream header",
tools/libxl/libxl_stream_read.c static void stream_done(libxl__egc *egc, · line 784
Quoted 7 lines
tools/libxl/libxl_stream_read.c +3
-1@@ -762,7 +779,9 @@ static void stream_done(libxl__egc *egc, LIBXL_STAILQ_FOREACH_SAFE(rec, &stream->record_queue, entry, trec)free_record (rec); -check_all_finished (egc, stream, rc); +if (!stream->back_channel) +/* back channel stream doesn't have restore helper */ +check_all_finished (egc, stream, rc);
Even if it doesn't have restore helper, check_all_finished also checks if the stream and the conversion helper are till in use. The explanation in the comment doesn't seem to justify this change.
Wei.
Quoted 13 lines
tools/libxl/libxl_stream_read.c +0
-0} void libxl__xc_domain_restore_done(libxl__egc *egc, void *dcs_void,Signature · 9 lines
2.5.0 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH v10 12/31] tools/libxl: add back channel support to read stream
Quoted 59 lines · Wei Liu
Quoted 58 lines · Wen Congyang
This is used by primay to read records sent by secondary.
Signed-off-by Yang Hongyang <[email protected]>Signed-off-by Wen Congyang <[email protected]>--- tools/libxl/libxl_create.c | 1 + tools/libxl/libxl_internal.h | 1 + tools/libxl/libxl_stream_read.c | 27 +++++++++++++++++++++++---- 3 files changed, 25 insertions(+), 4 deletions(-)tools/libxl/libxl_create.c +1
-0@@ -1030,6 +1030,7 @@ static void domcreate_bootloader_done(libxl__egc *egc, dcs->srs.dcs = dcs; dcs->srs.fd = restore_fd; dcs->srs.legacy = (dcs->restore_params.stream_version ==1 ); + dcs->srs.back_channel = false; dcs->srs.completion_callback = domcreate_stream_done;if (restore_fd >=0 ) {tools/libxl/libxl_internal.h +1
-0@@ -3420,6 +3420,7 @@ struct libxl__stream_read_state {libxl__domain_create_state *dcs;int fd;bool legacy; +bool back_channel;void (*completion_callback)(libxl__egc *egc,libxl__stream_read_state *srs,int rc);tools/libxl/libxl_stream_read.c +9
-0@@ -118,6 +118,15 @@* record, and therefore the buffered state is inconsistent. In * libxl__xc_domain_restore_done(), we just complete the stream and * stream->completion_callback() will be called to resume the guest +* +* For back channel stream: +* - libxl__stream_read_start() +* - Set up the stream to running state +* +* - libxl__stream_read_continue() +* - Set up reading the next record from a started stream. +* Add some codes to process_record() to handle the record. +* Then call stream->checkpoint_callback() to return. */ /* Success/error/cleanup handling. */ @@ -221,6 +230,17 @@ void libxl__stream_read_start(libxl__egc *egc, stream->running = true; stream->phase =SRS_PHASE_NORMAL ;
Quoted 11 lines
tools/libxl/libxl_stream_read.c void libxl__stream_read_start(libxl__egc *egc, · line 240
Quoted 8 lines
tools/libxl/libxl_stream_read.c +8
-0+ dc->ao = stream->ao; + dc->copywhat ="restore v2 stream" ; + dc->writefd =-1 ; + +if (stream->back_channel) { +assert (!stream->legacy); + + dc->readfd = stream->fd;Why is this needed?
dc->readfdis set tostream->fdno matter it is back channel or not. This can be moved outside this if {}.
Yes, will fix it in the next version.
Quoted 22 lines
Quoted 22 lines
tools/libxl/libxl_stream_read.c +3
-3+return ; + } +if (stream->legacy) {/* Convert the legacy stream. */ libxl__conversion_helper_state *chs = &stream->chs;@@ -243,10 +263,7 @@ void libxl__stream_read_start(libxl__egc *egc, }/* stream->fd is now a v2 stream. */ - dc->ao = stream->ao; - dc->copywhat ="restore v2 stream" ; dc->readfd = stream->fd; - dc->writefd =-1 ;/* Start reading the stream header. */ rc = setup_read(stream, "stream header",@@ -762,7 +779,9 @@ static void stream_done(libxl__egc *egc, LIBXL_STAILQ_FOREACH_SAFE(rec, &stream->record_queue, entry, trec)free_record (rec);
Quoted 8 lines
tools/libxl/libxl_stream_read.c static void stream_done(libxl__egc *egc, · line 784
Quoted 4 lines
tools/libxl/libxl_stream_read.c +3
-1-check_all_finished (egc, stream, rc); +if (!stream->back_channel) +/* back channel stream doesn't have restore helper */ +check_all_finished (egc, stream, rc);Even if it doesn't have restore helper,
check_all_finishedalso checks if the stream and the conversion helper are till in use. The explanation in the comment doesn't seem to justify this change.
In stream_done(), stream->running is set to false, so libxl__stream_read_in_use() returns false.
Back channel stream doesn't support legacy stream, so there is no conversion helper.
I will update the comments in the next version.
Thanks
Wen Congyang
Quoted 12 lines
Wei.
Quoted 9 lines
tools/libxl/libxl_stream_read.c +0
-0} void libxl__xc_domain_restore_done(libxl__egc *egc, void *dcs_void,Signature · 1 line
2.5.0
Quoted 8 lines
Quoted 4 lines
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH v10 12/31] tools/libxl: add back channel support to read stream
On Fri, Feb 26, 2016 at 10:16:43AM +0800, Wen Congyang wrote:
[...]
Quoted 5 lines
Quoted 4 lines
Even if it doesn't have restore helper,
check_all_finishedalso checks if the stream and the conversion helper are till in use. The explanation in the comment doesn't seem to justify this change.
Quoted 7 lines
In
stream_done(),stream->runningis set to false, solibxl__stream_read_in_use()returns false.Back channel stream doesn't support legacy stream, so there is no conversion helper.
I will update the comments in the next version.
Yes, please do. Say clearly why it is not needed.
Wei.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
PATCH v10 13/31 tools/libxl: handle checkpoint_state records in a libxl migration v2 read stream
In reply to Wen CongyangRead a checkpoint_state and call stream->checkpoint_callback to handle it.
--- tools/libxl/libxl_internal.h | 3 +++ tools/libxl/libxl_stream_read.c | 57 ++++++++++++++++++++++++++++++++++++++++- 2 files changed, 59 insertions(+), 1 deletion(-)
tools/libxl/libxl_internal.h +3 -0
@@ -3432,6 +3432,7 @@ struct libxl__stream_read_state {bool running;bool in_checkpoint;bool sync_teardown;/* Only used to coordinate shutdown on error path. */ +bool in_checkpoint_state;libxl__save_helper_state shs;libxl__conversion_helper_state chs;
@@ -3459,6 +3460,8 @@ _hidden void libxl__stream_read_start(libxl__egc *egc, libxl__stream_read_state *stream); _hidden void libxl__stream_read_start_checkpoint(libxl__egc *egc,libxl__stream_read_state *stream); +_hidden void libxl__stream_read_checkpoint_state(libxl__egc *egc, +libxl__stream_read_state *stream); _hidden void libxl__stream_read_abort(libxl__egc *egc,libxl__stream_read_state *stream,int rc); static inline bool
tools/libxl/libxl_stream_read.c +56 -1
93 lines not on this page · raw message
Signature · 1 line
2.5.0
PATCH v10 14/31 tools/libx{l, c}: introduce wait_checkpoint callback
In reply to Wen CongyangUnder COLO, we are doing checkpoint on demand, if this callback returns 1, we will take another checkpoint. 0 indicates unexpected error.
--- tools/libxc/include/xenguest.h | 18 ++++++++++++++++++ tools/libxl/libxl_save_msgs_gen.pl | 7 ++++--- 2 files changed, 22 insertions(+), 3 deletions(-)
tools/libxc/include/xenguest.h +18 -0
@@ -68,6 +68,15 @@ struct save_callbacks {* 1: take another checkpoint */ int (*checkpoint)(void * data); +/* +* Called after the checkpoint callback. +* +* returns: +* 0: terminate checkpointing gracefully +* 1: take another checkpoint +*/ +int (*wait_checkpoint)(void * data); +/* Enable qemu-dm logging dirty pages to xen */ int (*switch_qemu_logdirty)(int domid,unsigned enable,void *data);/* HVM only */
@@ -99,6 +108,15 @@ struct restore_callbacks {#define XGR_CHECKPOINT_FAILOVER 2/* Failover and resume VM */ int (*checkpoint)(void * data); +/* +* Called after the checkpoint callback. +* +* returns: +* 0: terminate checkpointing gracefully +* 1: take another checkpoint +*/ +int (*wait_checkpoint)(void * data); +/* to be provided as the last argument to each callback function */ void * data; };
tools/libxl/libxl_save_msgs_gen.pl +4 -3
@@ -26,11 +26,12 @@ our @msgs = ( [ 3, 'scxA', "suspend", [] ], [ 4, 'scxA', "postcopy", [] ], [ 5, 'srcxA', "checkpoint", [] ], - [ 6, 'scxA', "switch_qemu_logdirty", [qw(int domid + [ 6, 'srcxA', "wait_checkpoint", [] ], + [ 7, 'scxA', "switch_qemu_logdirty", [qw(int domid unsigned enable)] ], - [ 7, 'r', "restore_results", ['unsigned long', 'store_mfn', + [ 8, 'r', "restore_results", ['unsigned long', 'store_mfn', 'unsigned long', 'console_mfn'] ], - [ 8, 'srW', "complete", [qw(int retval + [ 9, 'srW', "complete", [qw(int retval int errnoval)] ], );
Signature · 1 line
2.5.0
PATCH v10 15/31 tools/libx{l, c}: add postcopy/suspend callback to restore side
In reply to Wen CongyangSecondary(restore side) is running under COLO, we also need postcopy/suspend callbacks.
--- tools/libxc/include/xenguest.h | 10 ++++++++++ tools/libxl/libxl_save_msgs_gen.pl | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-)
tools/libxc/include/xenguest.h +10 -0
@@ -101,6 +101,16 @@ int xc_domain_save(xc_interface *xch, int io_fd, uint32_t dom, uint32_t max_iter/* callbacks provided by xc_domain_restore */ struct restore_callbacks { +/* Called after a new checkpoint to suspend the guest. +*/ +int (*suspend)(void * data); + +/* Called after the secondary vm is ready to resume. +* Callback function resumes the guest & the device model, +* returns to xc_domain_restore. +*/ +int (*postcopy)(void * data); +/* A checkpoint record has been found in the stream. * returns: */ #define XGR_CHECKPOINT_ERROR 0/* Terminate processing */
tools/libxl/libxl_save_msgs_gen.pl +2 -2
@@ -23,8 +23,8 @@ our @msgs = ( STRING doing_what), 'unsigned long', 'done', 'unsigned long', 'total'] ], - [ 3, 'scxA', "suspend", [] ], - [ 4, 'scxA', "postcopy", [] ], + [ 3, 'srcxA', "suspend", [] ], + [ 4, 'srcxA', "postcopy", [] ], [ 5, 'srcxA', "checkpoint", [] ], [ 6, 'srcxA', "wait_checkpoint", [] ], [ 7, 'scxA', "switch_qemu_logdirty", [qw(int domid
Signature · 1 line
2.5.0
PATCH v10 16/31 secondary vm suspend/resume/checkpoint code
In reply to Wen CongyangSecondary vm is running in colo mode. So we will do
the following things again and again:
1. Resume secondary vm
a. Send CHECKPOINT_SVM_READY to master.
b. If it is not the first resume, call libxl__checkpoint_devices_preresume(). c. If it is the first resume(resume right after live migration),
- call libxl__xc_domain_restore_done() to build the secondary vm.
- enable secondary vm's logdirty.
- call libxl__domain_resume() to resume secondary vm.
- call libxl__checkpoint_devices_setup() to setup checkpoint devices.
d. Send CHECKPOINT_SVM_RESUMED to master.
2. Wait a new checkpoint
a. Call libxl__checkpoint_devices_commit().
b. Read CHECKPOINT_NEW from master.
3. Suspend secondary vm
a. Suspend secondary vm.
b. Call libxl__checkpoint_devices_postsuspend().
c. Send CHECKPOINT_SVM_SUSPENDED to master.
--- tools/libxc/xc_sr_common.h | 2 + tools/libxc/xc_sr_save.c | 3 +- tools/libxl/Makefile | 1 + tools/libxl/libxl_colo.h | 24 + tools/libxl/libxl_colo_restore.c | 1038 ++++++++++++++++++++++++++++++++++++++ tools/libxl/libxl_create.c | 37 ++ tools/libxl/libxl_internal.h | 19 + tools/libxl/libxl_save_callout.c | 7 +- tools/libxl/libxl_stream_read.c | 12 + tools/libxl/libxl_types.idl | 1 + 10 files changed, 1142 insertions(+), 2 deletions(-) create mode 100644 tools/libxl/libxl_colo.h create mode 100644 tools/libxl/libxl_colo_restore.c
tools/libxc/xc_sr_common.h +2 -0
@@ -184,10 +184,12 @@ struct xc_sr_context* migration stream * 0: Plain VM * 1: Remus +* 2: COLO */ enum {MIG_STREAM_NONE ,/* plain stream */ MIG_STREAM_REMUS , +MIG_STREAM_COLO , } migration_stream; union /* Common save or restore data. */
tools/libxc/xc_sr_save.c +2 -1
@@ -846,7 +846,8 @@ int xc_domain_save(xc_interface *xch, int io_fd, uint32_t dom,/* If altering migration_stream update this assert too. */ assert (checkpointed_stream ==MIG_STREAM_NONE || - checkpointed_stream ==MIG_STREAM_REMUS ); + checkpointed_stream ==MIG_STREAM_REMUS || + checkpointed_stream ==MIG_STREAM_COLO );/* * TODO: Find some time to better tweak the live migration algorithm.
tools/libxl/Makefile +1 -0
@@ -65,6 +65,7 @@ LIBXL_OBJS-y += libxl_no_convert_callout.o endif LIBXL_OBJS-y += libxl_remus.o libxl_checkpoint_device.o libxl_remus_disk_drbd.o +LIBXL_OBJS-y += libxl_colo_restore.o LIBXL_OBJS-$(CONFIG_X86) += libxl_cpuid.o libxl_x86.o libxl_psr.o LIBXL_OBJS-$(CONFIG_ARM) += libxl_nocpuid.o libxl_arm.o libxl_libfdt_compat.o
tools/libxl/libxl_colo.h new file +24 -0
@@ -0,0 +1,24 @@ +/* +* Copyright (C) 2014 FUJITSU LIMITED +* Author: Wen Congyang <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License as published +* by the Free Software Foundation; version 2.1 only. with the special +* exception on linking described in file LICENSE. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License for more details. +*/ + +#ifndef LIBXL_COLO_H +#define LIBXL_COLO_H + +extern void libxl__colo_restore_setup (libxl__egc *egc, +libxl__colo_restore_state *crs); +extern void libxl__colo_restore_teardown (libxl__egc *egc,void *dcs_void, +int ret,int retval,int errnoval); + +#endif
tools/libxl/libxl_colo_restore.c new file +1038 -0
1,038 lines not on this page · raw message
tools/libxl/libxl_create.c +37 -0
@@ -19,6 +19,7 @@#include "libxl_internal.h" #include "libxl_arch.h" +#include "libxl_colo.h" #include <xc_dom.h> #include <xenguest.h>
@@ -981,6 +982,23 @@ static void domcreate_console_available(libxl__egc *egc, dcs->aop_console_how.for_event)); } +static void libxl__colo_restore_setup_done (libxl__egc *egc, +libxl__colo_restore_state *crs, +int rc) +{ +libxl__domain_create_state *dcs =CONTAINER_OF (crs, *dcs, crs); + +EGC_GC ; + +if (rc) { +LOG (ERROR ,"colo restore setup fails: %d" , rc); +domcreate_stream_done (egc, &dcs->srs, rc); +return ; + } + +libxl__stream_read_start (egc, &dcs->srs); +} +static void domcreate_bootloader_done (libxl__egc *egc,libxl__bootloader_state *bl,int rc)
@@ -994,6 +1012,8 @@ static void domcreate_bootloader_done(libxl__egc *egc,const int restore_fd = dcs->restore_fd;libxl__domain_build_state *const state = &dcs->build_state;const int checkpointed_stream = dcs->restore_params.checkpointed_stream; +libxl__colo_restore_state *const crs = &dcs->crs; +libxl_domain_build_info *const info = &d_config->b_info;if (rc) {domcreate_rebuild_done (egc, dcs, rc);
@@ -1022,6 +1042,13 @@ static void domcreate_bootloader_done(libxl__egc *egc,/* Restore */ +/* COLO only supports HVM now */ +if (info->type !=LIBXL_DOMAIN_TYPE_HVM && + checkpointed_stream ==LIBXL_CHECKPOINTED_STREAM_COLO ) { + rc =ERROR_FAIL ; + goto out; + } + rc =libxl__build_pre (gc, domid, d_config, state);if (rc) goto out;
@@ -1035,6 +1062,16 @@ static void domcreate_bootloader_done(libxl__egc *egc,if (restore_fd >=0 ) {switch (checkpointed_stream) { +case LIBXL_CHECKPOINTED_STREAM_COLO : +/* colo restore setup */ + crs->ao = ao; + crs->domid = domid; + crs->send_back_fd = dcs->send_back_fd; + crs->recv_fd = restore_fd; + crs->hvm = (info->type ==LIBXL_DOMAIN_TYPE_HVM ); + crs->callback = libxl__colo_restore_setup_done; +libxl__colo_restore_setup (egc, crs); +break ;case LIBXL_CHECKPOINTED_STREAM_REMUS :libxl__remus_restore_setup (egc, dcs);/* fall through */
tools/libxl/libxl_internal.h +19 -0
@@ -3470,6 +3470,23 @@ libxl__stream_read_inuse(const libxl__stream_read_state *stream)return stream->running; } +/* colo related structure */ +typedef struct libxl__colo_restore_state libxl__colo_restore_state ; +typedef void libxl__colo_callback (libxl__egc *, +libxl__colo_restore_state *,int rc); +struct libxl__colo_restore_state { +/* must set by caller of libxl__colo_(setup|teardown) */ +libxl__ao *ao; +uint32_t domid; +int send_back_fd; +int recv_fd; +int hvm; +libxl__colo_callback *callback; + +/* private, colo restore checkpoint state */ +libxl__domain_create_cb *saved_cb; +void *crcs; +};struct libxl__domain_create_state {/* filled in by user */
@@ -3486,6 +3503,8 @@ struct libxl__domain_create_state {/* private to domain_create */ int guest_domid;libxl__domain_build_state build_state; +libxl__colo_restore_state crs; +libxl__checkpoint_devices_state cds;libxl__bootloader_state bl;libxl__stub_dm_spawn_state dmss;/* If we're not doing stubdom, we use only dmss.dm,
tools/libxl/libxl_save_callout.c +6 -1
@@ -15,6 +15,7 @@#include "libxl_osdeps.h" #include "libxl_internal.h" +#include "libxl_colo.h" /* stream_fd is as from the caller (eventually, the application). * It may be 0, 1 or 2, in which case we need to dup it elsewhere.
@@ -68,7 +69,11 @@ void libxl__xc_domain_restore(libxl__egc *egc, libxl__domain_create_state *dcs, shs->ao = ao; shs->domid = domid; shs->recv_callback = libxl__srm_callout_received_restore; - shs->completion_callback = libxl__xc_domain_restore_done; +if (dcs->restore_params.checkpointed_stream == +LIBXL_CHECKPOINTED_STREAM_COLO ) + shs->completion_callback = libxl__colo_restore_teardown; +else + shs->completion_callback = libxl__xc_domain_restore_done; shs->caller_state = dcs; shs->need_results =1 ;
tools/libxl/libxl_stream_read.c +12 -0
@@ -846,6 +846,18 @@ void libxl__xc_domain_restore_done(libxl__egc *egc, void *dcs_void,*/ if (libxl__stream_read_inuse (stream)) {switch (checkpointed_stream) { +case LIBXL_CHECKPOINTED_STREAM_COLO : +if (stream->completion_callback) { +/* +* restore, just build the secondary vm, don't close +* the stream +*/ + stream->completion_callback (egc, stream,0 ); + }else { +/* failover, just close the stream */ +stream_complete (egc, stream,0 ); + } +break ;case LIBXL_CHECKPOINTED_STREAM_REMUS :/* * Failover from primary. Domain state is currently at a
tools/libxl/libxl_types.idl +1 -0
@@ -232,6 +232,7 @@ libxl_hdtype = Enumeration("hdtype", [ libxl_checkpointed_stream = Enumeration("checkpointed_stream", [ (0, "NONE"), (1, "REMUS"), + (2, "COLO"), ]) #
Signature · 1 line
2.5.0
Re: [PATCH v10 16/31] secondary vm suspend/resume/checkpoint code
Quoted 21 lines · Wen Congyang
Secondary vm is running in colo mode. So we will do
the following things again and again:
1. Resume secondary vm
a. SendCHECKPOINT_SVM_READYto master.
b. If it is not the first resume, calllibxl__checkpoint_devices_preresume(). c. If it is the first resume(resume right after live migration),
- calllibxl__xc_domain_restore_done()to build the secondary vm.
- enable secondary vm's logdirty.
- calllibxl__domain_resume()to resume secondary vm.
- calllibxl__checkpoint_devices_setup()to setup checkpoint devices.
d. SendCHECKPOINT_SVM_RESUMEDto master.
2. Wait a new checkpoint
a. Calllibxl__checkpoint_devices_commit().
b. ReadCHECKPOINT_NEWfrom master.
3. Suspend secondary vm
a. Suspend secondary vm.
b. Calllibxl__checkpoint_devices_postsuspend().
c. SendCHECKPOINT_SVM_SUSPENDEDto master.Signed-off-by Wen Congyang <[email protected]>Signed-off-by Yang Hongyang <[email protected]>
Quoted 11 lines
--- tools/libxc/xc_sr_common.h | 2 + tools/libxc/xc_sr_save.c | 3 +- tools/libxl/Makefile | 1 + tools/libxl/libxl_colo.h | 24 + tools/libxl/libxl_colo_restore.c | 1038 ++++++++++++++++++++++++++++++++++++++ tools/libxl/libxl_create.c | 37 ++ tools/libxl/libxl_internal.h | 19 + tools/libxl/libxl_save_callout.c | 7 +- tools/libxl/libxl_stream_read.c | 12 + tools/libxl/libxl_types.idl | 1 +
There is a bunch of TODOs in libxl_colo.c but I don't think you're in a better position to judge whether they should be blocker or not.
Quoted 35 lines
10 files changed, 1142 insertions(+), 2 deletions(-) create mode 100644 tools/libxl/libxl_colo.h create mode 100644 tools/libxl/libxl_colo_restore.ctools/libxc/xc_sr_common.h +2
-0@@ -184,10 +184,12 @@ struct xc_sr_context* migration stream * 0: Plain VM * 1: Remus +* 2: COLO */ enum {MIG_STREAM_NONE ,/* plain stream */ MIG_STREAM_REMUS , +MIG_STREAM_COLO , } migration_stream; union /* Common save or restore data. */tools/libxc/xc_sr_save.c +2
-1@@ -846,7 +846,8 @@ int xc_domain_save(xc_interface *xch, int io_fd, uint32_t dom,/* If altering migration_stream update this assert too. */ assert (checkpointed_stream ==MIG_STREAM_NONE || - checkpointed_stream ==MIG_STREAM_REMUS ); + checkpointed_stream ==MIG_STREAM_REMUS || + checkpointed_stream ==MIG_STREAM_COLO );/* * TODO: Find some time to better tweak the live migration algorithm.
[...]
Quoted 21 lines
tools/libxc/xc_sr_save.c +21
-0+ +#include "libxl_osdeps.h" /* must come before any other headers */ + +#include "libxl_internal.h" +#include "libxl_colo.h" +#include "libxl_sr_stream_format.h" + +enum { +LIBXL_COLO_SETUPED , +LIBXL_COLO_SUSPENDED , +LIBXL_COLO_RESUMED , +}; + +typedef struct libxl__colo_restore_checkpoint_state libxl__colo_restore_checkpoint_state ; +struct libxl__colo_restore_checkpoint_state { +libxl__domain_suspend_state dsps; +libxl__logdirty_switch lds; +libxl__colo_restore_state *crs; +libxl__stream_write_state sws; +int status; +bool preresume;
tools/libxc/xc_sr_save.c
Quoted 10 lines
tools/libxc/xc_sr_save.c +10
-0+/* used for teardown */ +int teardown_devices; +int saved_rc; +char *state_file; + +void (*callback)(libxl__egc *, +libxl__colo_restore_checkpoint_state *, +int ); +}; +
Shouldn't the enum and struct belong to libxl_colo.h ?
tools/libxc/xc_sr_save.c
Quoted 10 lines
tools/libxc/xc_sr_save.c +10
-0+ +static void libxl__colo_restore_domain_resume_callback (void *data); +static void libxl__colo_restore_domain_checkpoint_callback (void *data); +static void libxl__colo_restore_domain_wait_checkpoint_callback (void *data); +static void libxl__colo_restore_domain_suspend_callback (void *data); + +static const libxl__checkpoint_device_instance_ops *colo_restore_ops[] = { +NULL , +}; +
It would be helpful to list the callbacks at the beginning of the time in the order they are supposed to occur.
See libxl_create.c for example. Search for "Event callbacks, in this order".
I've tried to map the algorithm you described in commit message to all the callbacks, but without some references it is just too time consuming from my end.
I think what I'm going to do is to make sure the normal path that doesn't use COLO is not broken and leave the internal to you and Ian (if he fancies to dig into details).
[...]
Quoted 29 lines
tools/libxc/xc_sr_save.c +29
-0+ +void libxl__colo_restore_setup (libxl__egc *egc, +libxl__colo_restore_state *crs) +{ +libxl__domain_create_state *dcs =CONTAINER_OF (crs, *dcs, crs); +libxl__colo_restore_checkpoint_state *crcs; +int rc =ERROR_FAIL ; + +/* Convenience aliases */ +libxl__srm_restore_autogen_callbacks *const callbacks = + &dcs->srs.shs.callbacks.restore.a; +const int domid = crs->domid; + +STATE_AO_GC (crs->ao); + +GCNEW (crcs); + crs->crcs = crcs; + crcs->crs = crs; + +/* setup dsps */ + crcs->dsps.ao = ao; + crcs->dsps.domid = domid; +if (init_dsps (&crcs->dsps)) + goto err; + + callbacks->suspend = libxl__colo_restore_domain_suspend_callback; + callbacks->postcopy = libxl__colo_restore_domain_resume_callback; + callbacks->checkpoint = libxl__colo_restore_domain_checkpoint_callback; + callbacks->wait_checkpoint = libxl__colo_restore_domain_wait_checkpoint_callback;
tools/libxc/xc_sr_save.c
Quoted 10 lines
tools/libxc/xc_sr_save.c +10
-0+ +/* +* Secondary vm is running in colo mode, so we need to call +* libxl__xc_domain_restore_done() to create secondary vm. +* But we will exit in domain_create_cb(). So replace the +* callback here. +*/ + crs->saved_cb = dcs->callback; + dcs->callback = libxl__colo_domain_create_cb; + crcs->state_file =GCSPRINTF (LIBXL_DEVICE_MODEL_RESTORE_FILE ".%d" , domid);
Can you use a different name space from the normal one?
For example, you can put
#define LIBXL_COLO_DEVICE_MODEL_RESTORE_FILE XXXX
in libxl_colo.h and use it in all COLO code.
Quoted 33 lines
tools/libxc/xc_sr_save.c +33
-0+ crcs->status =LIBXL_COLO_SETUPED ; + +libxl__logdirty_init (&crcs->lds); + crcs->lds.ao = ao; + + crcs->sws.fd = crs->send_back_fd; + crcs->sws.ao = ao; + crcs->sws.back_channel = true; + + dcs->cds.concrete_data = crs; + +libxl__stream_write_start (egc, &crcs->sws); + + rc =0 ; + +out: + crs->callback (egc, crs, rc); +return ; + +err: + goto out; +} + +static void libxl__colo_domain_create_cb (libxl__egc *egc, +libxl__domain_create_state *dcs, +int rc,uint32_t domid) +{ +libxl__colo_restore_checkpoint_state *crcs = dcs->crs.crcs; + + crcs->callback (egc, crcs, rc); +} + +
[...]
Quoted 6 lines
tools/libxc/xc_sr_save.c +6
-0+ +static void colo_disable_logdirty_done (libxl__egc *egc, +libxl__logdirty_switch *lds, +int rc) +{ +libxl__colo_restore_checkpoint_state *crcs =CONTAINER_OF (lds, *crcs, lds);
tools/libxc/xc_sr_save.c
Quoted 10 lines
tools/libxc/xc_sr_save.c +10
-0+ +EGC_GC ; + +if (rc) +LOG (WARN ,"cannot disable logdirty" ); + +if (crcs->status ==LIBXL_COLO_SUSPENDED ) { +/* +* failover when reading state from master, so no need to +* call libxl__domain_restore().
You need to update this comment to the right function name.
Quoted 9 lines
tools/libxc/xc_sr_save.c +9
-0+*/ +colo_resume_vm (egc, crcs,0 ); +return ; + } + +/* If we cannot disable logdirty, we still can do failover */ + crcs->callback (egc, crcs,0 ); +} +
[...]
Quoted 9 lines
tools/libxc/xc_sr_save.c +7
-0+/* colo related structure */ +typedef struct libxl__colo_restore_state libxl__colo_restore_state ; +typedef void libxl__colo_callback (libxl__egc *, +libxl__colo_restore_state *,int rc); +struct libxl__colo_restore_state { +/* must set by caller of libxl__colo_(setup|teardown) */ +libxl__ao *ao;
tools/libxc/xc_sr_save.c
Quoted 10 lines
tools/libxc/xc_sr_save.c +10
-0+uint32_t domid; +int send_back_fd; +int recv_fd; +int hvm; +libxl__colo_callback *callback; + +/* private, colo restore checkpoint state */ +libxl__domain_create_cb *saved_cb; +void *crcs; +};
And this should go to libxl_colo.h, too? And libxl_internal.h includes libxl_colo.h?
I just don't want to colo structures and functions scatter in different places.
Quoted 24 lines
struct libxl__domain_create_state { /* filled in by user */tools/libxc/xc_sr_save.c +2
-0@@ -3486,6 +3503,8 @@ struct libxl__domain_create_state {/* private to domain_create */ int guest_domid;libxl__domain_build_state build_state; +libxl__colo_restore_state crs; +libxl__checkpoint_devices_state cds;libxl__bootloader_state bl;libxl__stub_dm_spawn_state dmss;/* If we're not doing stubdom, we use only dmss.dm, tools/libxl/libxl_save_callout.c +1
-0@@ -15,6 +15,7 @@#include "libxl_osdeps.h" #include "libxl_internal.h" +#include "libxl_colo.h" /* stream_fd is as from the caller (eventually, the application). * It may be 0, 1 or 2, in which case we need to dup it elsewhere.
tools/libxl/libxl_save_callout.c void libxl__xc_domain_restore(libxl__egc *egc, libxl__domain_create_state *dcs, · line 73
Quoted 6 lines
tools/libxl/libxl_save_callout.c +2
-1@@ -68,7 +69,11 @@ void libxl__xc_domain_restore(libxl__egc *egc, libxl__domain_create_state *dcs, shs->ao = ao; shs->domid = domid; shs->recv_callback = libxl__srm_callout_received_restore; - shs->completion_callback = libxl__xc_domain_restore_done; +if (dcs->restore_params.checkpointed_stream == +LIBXL_CHECKPOINTED_STREAM_COLO )
This is very strange line wrap.
Quoted 51 lines
tools/libxl/libxl_save_callout.c +3
-0+ shs->completion_callback = libxl__colo_restore_teardown; + else + shs->completion_callback = libxl__xc_domain_restore_done; shs->caller_state = dcs; shs->need_results =1 ;tools/libxl/libxl_stream_read.c +12
-0@@ -846,6 +846,18 @@ void libxl__xc_domain_restore_done(libxl__egc *egc, void *dcs_void,*/ if (libxl__stream_read_inuse (stream)) {switch (checkpointed_stream) { +case LIBXL_CHECKPOINTED_STREAM_COLO : +if (stream->completion_callback) { +/* +* restore, just build the secondary vm, don't close +* the stream +*/ + stream->completion_callback (egc, stream,0 ); + }else { +/* failover, just close the stream */ +stream_complete (egc, stream,0 ); + } +break ;case LIBXL_CHECKPOINTED_STREAM_REMUS :/* * Failover from primary. Domain state is currently at a tools/libxl/libxl_types.idl +1
-0@@ -232,6 +232,7 @@ libxl_hdtype = Enumeration("hdtype", [ libxl_checkpointed_stream = Enumeration("checkpointed_stream", [ (0, "NONE"), (1, "REMUS"), + (2, "COLO"), ]) #Signature · 9 lines
2.5.0 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH v10 16/31] secondary vm suspend/resume/checkpoint code
Quoted 100 lines · Wei Liu
Quoted 21 lines · Wen Congyang
Secondary vm is running in colo mode. So we will do
the following things again and again:
1. Resume secondary vm
a. SendCHECKPOINT_SVM_READYto master.
b. If it is not the first resume, calllibxl__checkpoint_devices_preresume(). c. If it is the first resume(resume right after live migration),
- calllibxl__xc_domain_restore_done()to build the secondary vm.
- enable secondary vm's logdirty.
- calllibxl__domain_resume()to resume secondary vm.
- calllibxl__checkpoint_devices_setup()to setup checkpoint devices.
d. SendCHECKPOINT_SVM_RESUMEDto master.
2. Wait a new checkpoint
a. Calllibxl__checkpoint_devices_commit().
b. ReadCHECKPOINT_NEWfrom master.
3. Suspend secondary vm
a. Suspend secondary vm.
b. Calllibxl__checkpoint_devices_postsuspend().
c. SendCHECKPOINT_SVM_SUSPENDEDto master.Signed-off-by Wen Congyang <[email protected]>Signed-off-by Yang Hongyang <[email protected]>Quoted 11 lines
--- tools/libxc/xc_sr_common.h | 2 + tools/libxc/xc_sr_save.c | 3 +- tools/libxl/Makefile | 1 + tools/libxl/libxl_colo.h | 24 + tools/libxl/libxl_colo_restore.c | 1038 ++++++++++++++++++++++++++++++++++++++ tools/libxl/libxl_create.c | 37 ++ tools/libxl/libxl_internal.h | 19 + tools/libxl/libxl_save_callout.c | 7 +- tools/libxl/libxl_stream_read.c | 12 + tools/libxl/libxl_types.idl | 1 +There is a bunch of TODOs in
libxl_colo.cbut I don't think you're in a better position to judge whether they should be blocker or not.Quoted 35 lines
10 files changed, 1142 insertions(+), 2 deletions(-) create mode 100644 tools/libxl/libxl_colo.h create mode 100644 tools/libxl/libxl_colo_restore.ctools/libxc/xc_sr_common.h +2
-0@@ -184,10 +184,12 @@ struct xc_sr_context* migration stream * 0: Plain VM * 1: Remus +* 2: COLO */ enum {MIG_STREAM_NONE ,/* plain stream */ MIG_STREAM_REMUS , +MIG_STREAM_COLO , } migration_stream; union /* Common save or restore data. */tools/libxc/xc_sr_save.c +2
-1@@ -846,7 +846,8 @@ int xc_domain_save(xc_interface *xch, int io_fd, uint32_t dom,/* If altering migration_stream update this assert too. */ assert (checkpointed_stream ==MIG_STREAM_NONE || - checkpointed_stream ==MIG_STREAM_REMUS ); + checkpointed_stream ==MIG_STREAM_REMUS || + checkpointed_stream ==MIG_STREAM_COLO );/* * TODO: Find some time to better tweak the live migration algorithm. [...]
Quoted 25 lines
tools/libxc/xc_sr_save.c +25
-0+ +#include "libxl_osdeps.h" /* must come before any other headers */ + +#include "libxl_internal.h" +#include "libxl_colo.h" +#include "libxl_sr_stream_format.h" + +enum { +LIBXL_COLO_SETUPED , +LIBXL_COLO_SUSPENDED , +LIBXL_COLO_RESUMED , +}; + +typedef struct libxl__colo_restore_checkpoint_state libxl__colo_restore_checkpoint_state ; +struct libxl__colo_restore_checkpoint_state { +libxl__domain_suspend_state dsps; +libxl__logdirty_switch lds; +libxl__colo_restore_state *crs; +libxl__stream_write_state sws; +int status; +bool preresume; +/* used for teardown */ +int teardown_devices; +int saved_rc; +char *state_file;
Quoted 8 lines
tools/libxc/xc_sr_save.c
Quoted 6 lines
tools/libxc/xc_sr_save.c +6
-0+ +void (*callback)(libxl__egc *, +libxl__colo_restore_checkpoint_state *, +int ); +}; +Shouldn't the enum and struct belong to
libxl_colo.h?
It only be used by restore side. I think it is OK to move them to libxl_colo.h.
Quoted 15 lines
tools/libxc/xc_sr_save.c
Quoted 11 lines
tools/libxc/xc_sr_save.c +10
-0+ +static void libxl__colo_restore_domain_resume_callback (void *data); +static void libxl__colo_restore_domain_checkpoint_callback (void *data); +static void libxl__colo_restore_domain_wait_checkpoint_callback (void *data); +static void libxl__colo_restore_domain_suspend_callback (void *data); + +static const libxl__checkpoint_device_instance_ops *colo_restore_ops[] = { +NULL , +}; +It would be helpful to list the callbacks at the beginning of the time in the order they are supposed to occur.
Quoted 2 lines
See
libxl_create.cfor example. Search for "Event callbacks, in this order".
OK, will fix it in the next version.
Quoted 43 lines
I've tried to map the algorithm you described in commit message to all the callbacks, but without some references it is just too time consuming from my end.
I think what I'm going to do is to make sure the normal path that doesn't use COLO is not broken and leave the internal to you and Ian (if he fancies to dig into details).
[...]
Quoted 33 lines
tools/libxc/xc_sr_save.c +33
-0+ +void libxl__colo_restore_setup (libxl__egc *egc, +libxl__colo_restore_state *crs) +{ +libxl__domain_create_state *dcs =CONTAINER_OF (crs, *dcs, crs); +libxl__colo_restore_checkpoint_state *crcs; +int rc =ERROR_FAIL ; + +/* Convenience aliases */ +libxl__srm_restore_autogen_callbacks *const callbacks = + &dcs->srs.shs.callbacks.restore.a; +const int domid = crs->domid; + +STATE_AO_GC (crs->ao); + +GCNEW (crcs); + crs->crcs = crcs; + crcs->crs = crs; + +/* setup dsps */ + crcs->dsps.ao = ao; + crcs->dsps.domid = domid; +if (init_dsps (&crcs->dsps)) + goto err; + + callbacks->suspend = libxl__colo_restore_domain_suspend_callback; + callbacks->postcopy = libxl__colo_restore_domain_resume_callback; + callbacks->checkpoint = libxl__colo_restore_domain_checkpoint_callback; + callbacks->wait_checkpoint = libxl__colo_restore_domain_wait_checkpoint_callback; + +/* +* Secondary vm is running in colo mode, so we need to call +* libxl__xc_domain_restore_done() to create secondary vm.
Quoted 8 lines
tools/libxc/xc_sr_save.c
Quoted 6 lines
tools/libxc/xc_sr_save.c +6
-0+* But we will exit in domain_create_cb(). So replace the +* callback here. +*/ + crs->saved_cb = dcs->callback; + dcs->callback = libxl__colo_domain_create_cb; + crcs->state_file =GCSPRINTF (LIBXL_DEVICE_MODEL_RESTORE_FILE ".%d" , domid);Can you use a different name space from the normal one?
We write the qemu state into the restore file in write_emulator_blob().
Quoted 4 lines
For example, you can put
#define
LIBXL_COLO_DEVICE_MODEL_RESTORE_FILEXXXX
So if we use a different name space, we should do
#define LIBXL_COLO_DEVICE_MODEL_RESTORE_FILE LIBXL_DEVICE_MODEL_RESTORE_FILE
In colo codes, IIRC there is no other code use it.
Quoted 48 lines
in
libxl_colo.hand use it in all COLO code.Quoted 33 lines
tools/libxc/xc_sr_save.c +33
-0+ crcs->status =LIBXL_COLO_SETUPED ; + +libxl__logdirty_init (&crcs->lds); + crcs->lds.ao = ao; + + crcs->sws.fd = crs->send_back_fd; + crcs->sws.ao = ao; + crcs->sws.back_channel = true; + + dcs->cds.concrete_data = crs; + +libxl__stream_write_start (egc, &crcs->sws); + + rc =0 ; + +out: + crs->callback (egc, crs, rc); +return ; + +err: + goto out; +} + +static void libxl__colo_domain_create_cb (libxl__egc *egc, +libxl__domain_create_state *dcs, +int rc,uint32_t domid) +{ +libxl__colo_restore_checkpoint_state *crcs = dcs->crs.crcs; + + crcs->callback (egc, crcs, rc); +} + +[...]
Quoted 10 lines
tools/libxc/xc_sr_save.c +10
-0+ +static void colo_disable_logdirty_done (libxl__egc *egc, +libxl__logdirty_switch *lds, +int rc) +{ +libxl__colo_restore_checkpoint_state *crcs =CONTAINER_OF (lds, *crcs, lds); + +EGC_GC ; + +if (rc)
Quoted 8 lines
tools/libxc/xc_sr_save.c
Quoted 6 lines
tools/libxc/xc_sr_save.c +6
-0+LOG (WARN ,"cannot disable logdirty" ); + +if (crcs->status ==LIBXL_COLO_SUSPENDED ) { +/* +* failover when reading state from master, so no need to +* call libxl__domain_restore(). You need to update this comment to the right function name.
OK, will fix it in the next version.
Quoted 34 lines
Quoted 10 lines
tools/libxc/xc_sr_save.c +9
-0+*/ +colo_resume_vm (egc, crcs,0 ); +return ; + } + +/* If we cannot disable logdirty, we still can do failover */ + crcs->callback (egc, crcs,0 ); +} +[...]
Quoted 9 lines
tools/libxc/xc_sr_save.c +7
-0+/* colo related structure */ +typedef struct libxl__colo_restore_state libxl__colo_restore_state ; +typedef void libxl__colo_callback (libxl__egc *, +libxl__colo_restore_state *,int rc); +struct libxl__colo_restore_state { +/* must set by caller of libxl__colo_(setup|teardown) */ +libxl__ao *ao;tools/libxc/xc_sr_save.c
Quoted 10 lines
tools/libxc/xc_sr_save.c +10
-0+uint32_t domid; +int send_back_fd; +int recv_fd; +int hvm; +libxl__colo_callback *callback; + +/* private, colo restore checkpoint state */ +libxl__domain_create_cb *saved_cb; +void *crcs; +};And this should go to
libxl_colo.h, too? Andlibxl_internal.hincludeslibxl_colo.h?
Quoted 2 lines
I just don't want to colo structures and functions scatter in different places.
OK, will fix it in the next version.
Quoted 22 lines
Quoted 22 lines
struct libxl__domain_create_state { /* filled in by user */tools/libxc/xc_sr_save.c +2
-0@@ -3486,6 +3503,8 @@ struct libxl__domain_create_state {/* private to domain_create */ int guest_domid;libxl__domain_build_state build_state; +libxl__colo_restore_state crs; +libxl__checkpoint_devices_state cds;libxl__bootloader_state bl;libxl__stub_dm_spawn_state dmss;/* If we're not doing stubdom, we use only dmss.dm, tools/libxl/libxl_save_callout.c +1
-0@@ -15,6 +15,7 @@#include "libxl_osdeps.h" #include "libxl_internal.h" +#include "libxl_colo.h"
Quoted 11 lines
tools/libxl/libxl_save_callout.c void libxl__xc_domain_restore(libxl__egc *egc, libxl__domain_create_state *dcs, · line 73
Quoted 9 lines
tools/libxl/libxl_save_callout.c +2
-1/* stream_fd is as from the caller (eventually, the application). * It may be 0, 1 or 2, in which case we need to dup it elsewhere. @@ -68,7 +69,11 @@ void libxl__xc_domain_restore(libxl__egc *egc, libxl__domain_create_state *dcs, shs->ao = ao; shs->domid = domid; shs->recv_callback = libxl__srm_callout_received_restore; - shs->completion_callback = libxl__xc_domain_restore_done; +if (dcs->restore_params.checkpointed_stream == +LIBXL_CHECKPOINTED_STREAM_COLO )This is very strange line wrap.
Yes, will fix it in the next version.
Thanks
Wen Congyang
Quoted 48 lines
Quoted 48 lines
tools/libxl/libxl_save_callout.c +3
-0+ shs->completion_callback = libxl__colo_restore_teardown; + else + shs->completion_callback = libxl__xc_domain_restore_done; shs->caller_state = dcs; shs->need_results =1 ;tools/libxl/libxl_stream_read.c +12
-0@@ -846,6 +846,18 @@ void libxl__xc_domain_restore_done(libxl__egc *egc, void *dcs_void,*/ if (libxl__stream_read_inuse (stream)) {switch (checkpointed_stream) { +case LIBXL_CHECKPOINTED_STREAM_COLO : +if (stream->completion_callback) { +/* +* restore, just build the secondary vm, don't close +* the stream +*/ + stream->completion_callback (egc, stream,0 ); + }else { +/* failover, just close the stream */ +stream_complete (egc, stream,0 ); + } +break ;case LIBXL_CHECKPOINTED_STREAM_REMUS :/* * Failover from primary. Domain state is currently at a tools/libxl/libxl_types.idl +1
-0@@ -232,6 +232,7 @@ libxl_hdtype = Enumeration("hdtype", [ libxl_checkpointed_stream = Enumeration("checkpointed_stream", [ (0, "NONE"), (1, "REMUS"), + (2, "COLO"), ]) #Signature · 1 line
2.5.0
Quoted 8 lines
Quoted 4 lines
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH v10 16/31] secondary vm suspend/resume/checkpoint code
In reply to Wei LiuQuoted 100 lines · Wei Liu
Quoted 21 lines · Wen Congyang
Secondary vm is running in colo mode. So we will do
the following things again and again:
1. Resume secondary vm
a. SendCHECKPOINT_SVM_READYto master.
b. If it is not the first resume, calllibxl__checkpoint_devices_preresume(). c. If it is the first resume(resume right after live migration),
- calllibxl__xc_domain_restore_done()to build the secondary vm.
- enable secondary vm's logdirty.
- calllibxl__domain_resume()to resume secondary vm.
- calllibxl__checkpoint_devices_setup()to setup checkpoint devices.
d. SendCHECKPOINT_SVM_RESUMEDto master.
2. Wait a new checkpoint
a. Calllibxl__checkpoint_devices_commit().
b. ReadCHECKPOINT_NEWfrom master.
3. Suspend secondary vm
a. Suspend secondary vm.
b. Calllibxl__checkpoint_devices_postsuspend().
c. SendCHECKPOINT_SVM_SUSPENDEDto master.Signed-off-by Wen Congyang <[email protected]>Signed-off-by Yang Hongyang <[email protected]>Quoted 11 lines
--- tools/libxc/xc_sr_common.h | 2 + tools/libxc/xc_sr_save.c | 3 +- tools/libxl/Makefile | 1 + tools/libxl/libxl_colo.h | 24 + tools/libxl/libxl_colo_restore.c | 1038 ++++++++++++++++++++++++++++++++++++++ tools/libxl/libxl_create.c | 37 ++ tools/libxl/libxl_internal.h | 19 + tools/libxl/libxl_save_callout.c | 7 +- tools/libxl/libxl_stream_read.c | 12 + tools/libxl/libxl_types.idl | 1 +There is a bunch of TODOs in
libxl_colo.cbut I don't think you're in a better position to judge whether they should be blocker or not.Quoted 35 lines
10 files changed, 1142 insertions(+), 2 deletions(-) create mode 100644 tools/libxl/libxl_colo.h create mode 100644 tools/libxl/libxl_colo_restore.ctools/libxc/xc_sr_common.h +2
-0@@ -184,10 +184,12 @@ struct xc_sr_context* migration stream * 0: Plain VM * 1: Remus +* 2: COLO */ enum {MIG_STREAM_NONE ,/* plain stream */ MIG_STREAM_REMUS , +MIG_STREAM_COLO , } migration_stream; union /* Common save or restore data. */tools/libxc/xc_sr_save.c +2
-1@@ -846,7 +846,8 @@ int xc_domain_save(xc_interface *xch, int io_fd, uint32_t dom,/* If altering migration_stream update this assert too. */ assert (checkpointed_stream ==MIG_STREAM_NONE || - checkpointed_stream ==MIG_STREAM_REMUS ); + checkpointed_stream ==MIG_STREAM_REMUS || + checkpointed_stream ==MIG_STREAM_COLO );/* * TODO: Find some time to better tweak the live migration algorithm. [...]
Quoted 25 lines
tools/libxc/xc_sr_save.c +25
-0+ +#include "libxl_osdeps.h" /* must come before any other headers */ + +#include "libxl_internal.h" +#include "libxl_colo.h" +#include "libxl_sr_stream_format.h" + +enum { +LIBXL_COLO_SETUPED , +LIBXL_COLO_SUSPENDED , +LIBXL_COLO_RESUMED , +}; + +typedef struct libxl__colo_restore_checkpoint_state libxl__colo_restore_checkpoint_state ; +struct libxl__colo_restore_checkpoint_state { +libxl__domain_suspend_state dsps; +libxl__logdirty_switch lds; +libxl__colo_restore_state *crs; +libxl__stream_write_state sws; +int status; +bool preresume; +/* used for teardown */ +int teardown_devices; +int saved_rc; +char *state_file;
Quoted 8 lines
tools/libxc/xc_sr_save.c
Quoted 6 lines
tools/libxc/xc_sr_save.c +6
-0+ +void (*callback)(libxl__egc *, +libxl__colo_restore_checkpoint_state *, +int ); +}; +Shouldn't the enum and struct belong to
libxl_colo.h?
If we inlucde libxl_colo.h in libxl_internal.h, we cannot move this into colo.h, because this structure needs libxl__domain_suspend_state, libxl__logdirty_switch, ... We cannot just declare it, because this structure needs know there size.
Quoted 153 lines
tools/libxc/xc_sr_save.c
Quoted 11 lines
tools/libxc/xc_sr_save.c +10
-0+ +static void libxl__colo_restore_domain_resume_callback (void *data); +static void libxl__colo_restore_domain_checkpoint_callback (void *data); +static void libxl__colo_restore_domain_wait_checkpoint_callback (void *data); +static void libxl__colo_restore_domain_suspend_callback (void *data); + +static const libxl__checkpoint_device_instance_ops *colo_restore_ops[] = { +NULL , +}; +It would be helpful to list the callbacks at the beginning of the time in the order they are supposed to occur.
See
libxl_create.cfor example. Search for "Event callbacks, in this order".I've tried to map the algorithm you described in commit message to all the callbacks, but without some references it is just too time consuming from my end.
I think what I'm going to do is to make sure the normal path that doesn't use COLO is not broken and leave the internal to you and Ian (if he fancies to dig into details).
[...]
Quoted 29 lines
tools/libxc/xc_sr_save.c +29
-0+ +void libxl__colo_restore_setup (libxl__egc *egc, +libxl__colo_restore_state *crs) +{ +libxl__domain_create_state *dcs =CONTAINER_OF (crs, *dcs, crs); +libxl__colo_restore_checkpoint_state *crcs; +int rc =ERROR_FAIL ; + +/* Convenience aliases */ +libxl__srm_restore_autogen_callbacks *const callbacks = + &dcs->srs.shs.callbacks.restore.a; +const int domid = crs->domid; + +STATE_AO_GC (crs->ao); + +GCNEW (crcs); + crs->crcs = crcs; + crcs->crs = crs; + +/* setup dsps */ + crcs->dsps.ao = ao; + crcs->dsps.domid = domid; +if (init_dsps (&crcs->dsps)) + goto err; + + callbacks->suspend = libxl__colo_restore_domain_suspend_callback; + callbacks->postcopy = libxl__colo_restore_domain_resume_callback; + callbacks->checkpoint = libxl__colo_restore_domain_checkpoint_callback; + callbacks->wait_checkpoint = libxl__colo_restore_domain_wait_checkpoint_callback;tools/libxc/xc_sr_save.c
Quoted 10 lines
tools/libxc/xc_sr_save.c +10
-0+ +/* +* Secondary vm is running in colo mode, so we need to call +* libxl__xc_domain_restore_done() to create secondary vm. +* But we will exit in domain_create_cb(). So replace the +* callback here. +*/ + crs->saved_cb = dcs->callback; + dcs->callback = libxl__colo_domain_create_cb; + crcs->state_file =GCSPRINTF (LIBXL_DEVICE_MODEL_RESTORE_FILE ".%d" , domid);Can you use a different name space from the normal one?
For example, you can put
#define
LIBXL_COLO_DEVICE_MODEL_RESTORE_FILEXXXXin
libxl_colo.hand use it in all COLO code.Quoted 33 lines
tools/libxc/xc_sr_save.c +33
-0+ crcs->status =LIBXL_COLO_SETUPED ; + +libxl__logdirty_init (&crcs->lds); + crcs->lds.ao = ao; + + crcs->sws.fd = crs->send_back_fd; + crcs->sws.ao = ao; + crcs->sws.back_channel = true; + + dcs->cds.concrete_data = crs; + +libxl__stream_write_start (egc, &crcs->sws); + + rc =0 ; + +out: + crs->callback (egc, crs, rc); +return ; + +err: + goto out; +} + +static void libxl__colo_domain_create_cb (libxl__egc *egc, +libxl__domain_create_state *dcs, +int rc,uint32_t domid) +{ +libxl__colo_restore_checkpoint_state *crcs = dcs->crs.crcs; + + crcs->callback (egc, crcs, rc); +} + +[...]
Quoted 6 lines
tools/libxc/xc_sr_save.c +6
-0+ +static void colo_disable_logdirty_done (libxl__egc *egc, +libxl__logdirty_switch *lds, +int rc) +{ +libxl__colo_restore_checkpoint_state *crcs =CONTAINER_OF (lds, *crcs, lds);tools/libxc/xc_sr_save.c
Quoted 10 lines
tools/libxc/xc_sr_save.c +10
-0+ +EGC_GC ; + +if (rc) +LOG (WARN ,"cannot disable logdirty" ); + +if (crcs->status ==LIBXL_COLO_SUSPENDED ) { +/* +* failover when reading state from master, so no need to +* call libxl__domain_restore(). You need to update this comment to the right function name.
Quoted 9 lines
tools/libxc/xc_sr_save.c +9
-0+*/ +colo_resume_vm (egc, crcs,0 ); +return ; + } + +/* If we cannot disable logdirty, we still can do failover */ + crcs->callback (egc, crcs,0 ); +} +[...]
Quoted 14 lines
tools/libxc/xc_sr_save.c +13
-0+/* colo related structure */ +typedef struct libxl__colo_restore_state libxl__colo_restore_state ; +typedef void libxl__colo_callback (libxl__egc *, +libxl__colo_restore_state *,int rc); +struct libxl__colo_restore_state { +/* must set by caller of libxl__colo_(setup|teardown) */ +libxl__ao *ao; +uint32_t domid; +int send_back_fd; +int recv_fd; +int hvm; +libxl__colo_callback *callback; +
Quoted 8 lines
tools/libxc/xc_sr_save.c
Quoted 5 lines
tools/libxc/xc_sr_save.c +4
-0+/* private, colo restore checkpoint state */ +libxl__domain_create_cb *saved_cb; +void *crcs; +};And this should go to
libxl_colo.h, too? Andlibxl_internal.hincludeslibxl_colo.h?
If we do so, we should declare libxl__ao, libxl__domain_create_cb in libxl_colo.h
Thanks
Wen Congyang
Quoted 84 lines
I just don't want to colo structures and functions scatter in different places.
Quoted 24 lines
struct libxl__domain_create_state { /* filled in by user */tools/libxc/xc_sr_save.c +2
-0@@ -3486,6 +3503,8 @@ struct libxl__domain_create_state {/* private to domain_create */ int guest_domid;libxl__domain_build_state build_state; +libxl__colo_restore_state crs; +libxl__checkpoint_devices_state cds;libxl__bootloader_state bl;libxl__stub_dm_spawn_state dmss;/* If we're not doing stubdom, we use only dmss.dm, tools/libxl/libxl_save_callout.c +1
-0@@ -15,6 +15,7 @@#include "libxl_osdeps.h" #include "libxl_internal.h" +#include "libxl_colo.h" /* stream_fd is as from the caller (eventually, the application). * It may be 0, 1 or 2, in which case we need to dup it elsewhere. tools/libxl/libxl_save_callout.c void libxl__xc_domain_restore(libxl__egc *egc, libxl__domain_create_state *dcs, · line 73
Quoted 6 lines
tools/libxl/libxl_save_callout.c +2
-1@@ -68,7 +69,11 @@ void libxl__xc_domain_restore(libxl__egc *egc, libxl__domain_create_state *dcs, shs->ao = ao; shs->domid = domid; shs->recv_callback = libxl__srm_callout_received_restore; - shs->completion_callback = libxl__xc_domain_restore_done; +if (dcs->restore_params.checkpointed_stream == +LIBXL_CHECKPOINTED_STREAM_COLO )This is very strange line wrap.
Quoted 47 lines
tools/libxl/libxl_save_callout.c +3
-0+ shs->completion_callback = libxl__colo_restore_teardown; + else + shs->completion_callback = libxl__xc_domain_restore_done; shs->caller_state = dcs; shs->need_results =1 ;tools/libxl/libxl_stream_read.c +12
-0@@ -846,6 +846,18 @@ void libxl__xc_domain_restore_done(libxl__egc *egc, void *dcs_void,*/ if (libxl__stream_read_inuse (stream)) {switch (checkpointed_stream) { +case LIBXL_CHECKPOINTED_STREAM_COLO : +if (stream->completion_callback) { +/* +* restore, just build the secondary vm, don't close +* the stream +*/ + stream->completion_callback (egc, stream,0 ); + }else { +/* failover, just close the stream */ +stream_complete (egc, stream,0 ); + } +break ;case LIBXL_CHECKPOINTED_STREAM_REMUS :/* * Failover from primary. Domain state is currently at a tools/libxl/libxl_types.idl +1
-0@@ -232,6 +232,7 @@ libxl_hdtype = Enumeration("hdtype", [ libxl_checkpointed_stream = Enumeration("checkpointed_stream", [ (0, "NONE"), (1, "REMUS"), + (2, "COLO"), ]) #Signature · 1 line
2.5.0
Quoted 8 lines
Quoted 4 lines
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
PATCH v10 17/31 primary vm suspend/resume/checkpoint code
In reply to Wen CongyangWe will do the following things again and again:
1. Suspend primary vm
a. Suspend primary vm
b. do postsuspend
c. Read CHECKPOINT_SVM_SUSPENDED sent by secondary
2. Resume primary vm
a. Read CHECKPOINT_SVM_READY from slave
b. Do presume
c. Resume primary vm
d. Read CHECKPOINT_SVM_RESUMED from slave
3. Wait a new checkpoint
a. Wait a new checkpoint(not implemented) b. Send CHECKPOINT_NEW to slave
--- tools/libxl/Makefile | 2 +- tools/libxl/libxl.c | 6 +- tools/libxl/libxl_colo.h | 6 + tools/libxl/libxl_colo_save.c | 563 ++++++++++++++++++++++++++++++++++++++++++ tools/libxl/libxl_dom_save.c | 8 +- tools/libxl/libxl_internal.h | 168 +++++++------ tools/libxl/libxl_types.idl | 1 + 7 files changed, 674 insertions(+), 80 deletions(-) create mode 100644 tools/libxl/libxl_colo_save.c
tools/libxl/Makefile +1 -1
@@ -65,7 +65,7 @@ LIBXL_OBJS-y += libxl_no_convert_callout.o endif LIBXL_OBJS-y += libxl_remus.o libxl_checkpoint_device.o libxl_remus_disk_drbd.o -LIBXL_OBJS-y += libxl_colo_restore.o +LIBXL_OBJS-y += libxl_colo_restore.o libxl_colo_save.o LIBXL_OBJS-$(CONFIG_X86) += libxl_cpuid.o libxl_x86.o libxl_psr.o LIBXL_OBJS-$(CONFIG_ARM) += libxl_nocpuid.o libxl_arm.o libxl_libfdt_compat.o
tools/libxl/libxl.c +5 -1
@@ -17,6 +17,7 @@#include "libxl_osdeps.h" #include "libxl_internal.h" +#include "libxl_colo.h" #define PAGE_TO_MEMKB (pages) ((pages) * 4)#define BACKEND_STRING_SIZE 5
@@ -880,7 +881,10 @@ int libxl_domain_remus_start(libxl_ctx *ctx, libxl_domain_remus_info *info,assert (info);/* Point of no return */ -libxl__remus_setup (egc, &dss->rs); +if (libxl_defbool_val (info->colo)) +libxl__colo_save_setup (egc, &dss->css); +else +libxl__remus_setup (egc, &dss->rs);return AO_INPROGRESS ; out:
tools/libxl/libxl_colo.h +6 -0
@@ -21,4 +21,10 @@ extern void libxl__colo_restore_setup(libxl__egc *egc,extern void libxl__colo_restore_teardown (libxl__egc *egc,void *dcs_void,int ret,int retval,int errnoval); +extern void libxl__colo_save_setup (libxl__egc *egc, +libxl__colo_save_state *css); +extern void libxl__colo_save_teardown (libxl__egc *egc, +libxl__colo_save_state *css, +int rc); +#endif
tools/libxl/libxl_colo_save.c new file +563 -0
563 lines not on this page · raw message
tools/libxl/libxl_dom_save.c +6 -2
@@ -16,6 +16,7 @@#include "libxl_osdeps.h" /* must come before any other headers */ #include "libxl_internal.h" +#include "libxl_colo.h" #include <xen/errno.h>
@@ -437,12 +438,15 @@ static void domain_save_done(libxl__egc *egc,if (dss->remus) {/* -* With Remus, if we reach this point, it means either +* With Remus/COLO, if we reach this point, it means either * backup died or some network error occurred preventing us * from sending checkpoints. Teardown the network buffers and * release netlink resources. This is an async op. */ -libxl__remus_teardown (egc, &dss->rs, rc); +if (libxl_defbool_val (dss->remus->colo)) +libxl__colo_save_teardown (egc, &dss->css, rc); +else +libxl__remus_teardown (egc, &dss->rs, rc);return ; }
tools/libxl/libxl_internal.h +92 -76
204 lines not on this page · raw message
tools/libxl/libxl_types.idl +1 -0
@@ -763,6 +763,7 @@ libxl_domain_remus_info = Struct("domain_remus_info",[ ("netbuf", libxl_defbool), ("netbufscript", string), ("diskbuf", libxl_defbool), + ("colo", libxl_defbool) ]) libxl_event_type = Enumeration("event_type", [
Signature · 1 line
2.5.0
Re: [PATCH v10 17/31] primary vm suspend/resume/checkpoint code
On Mon, Feb 22, 2016 at 10:52:21AM +0800, Wen Congyang wrote:
[...]
Quoted 28 lines
tools/libxl/libxl_colo_save.c new file +28
-0+#include "libxl_osdeps.h" /* must come before any other headers */ + +#include "libxl_internal.h" +#include "libxl_colo.h" + +static const libxl__checkpoint_device_instance_ops *colo_ops[] = { +NULL , +}; + +/* ================= helper functions ================= */ +static int init_device_subkind (libxl__checkpoint_devices_state *cds) +{ +/* init device subkind-specific state in the libxl ctx */ +int rc; +STATE_AO_GC (cds->ao); + + rc =0 ; +return rc; +} + +static void cleanup_device_subkind (libxl__checkpoint_devices_state *cds) +{ +/* cleanup device subkind-specific state in the libxl ctx */ +STATE_AO_GC (cds->ao); +} + +/* ================= colo: setup save environment ================= */ +static void colo_save_setup_done(libxl__egc *egc,
tools/libxl/libxl_colo_save.c line 54
Quoted 10 lines
tools/libxl/libxl_colo_save.c new file +10
-0+libxl__checkpoint_devices_state *cds, + int rc); +static void colo_save_setup_failed (libxl__egc *egc, +libxl__checkpoint_devices_state *cds, +int rc); +static void libxl__colo_save_domain_suspend_callback (void *data); +static void libxl__colo_save_domain_checkpoint_callback (void *data); +static void libxl__colo_save_domain_resume_callback (void *data); +static void libxl__colo_save_domain_wait_checkpoint_callback (void *data); +
An ordered list of callbacks is appreciated. This doesn't seem to cover all callbacks and I'm not sure if this is the order they are supposed to fire either.
Wei.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH v10 17/31] primary vm suspend/resume/checkpoint code
Quoted 37 lines · Wei Liu
On Mon, Feb 22, 2016 at 10:52:21AM +0800, Wen Congyang wrote:
[...]Quoted 35 lines
tools/libxl/libxl_colo_save.c new file +35
-0+#include "libxl_osdeps.h" /* must come before any other headers */ + +#include "libxl_internal.h" +#include "libxl_colo.h" + +static const libxl__checkpoint_device_instance_ops *colo_ops[] = { +NULL , +}; + +/* ================= helper functions ================= */ +static int init_device_subkind (libxl__checkpoint_devices_state *cds) +{ +/* init device subkind-specific state in the libxl ctx */ +int rc; +STATE_AO_GC (cds->ao); + + rc =0 ; +return rc; +} + +static void cleanup_device_subkind (libxl__checkpoint_devices_state *cds) +{ +/* cleanup device subkind-specific state in the libxl ctx */ +STATE_AO_GC (cds->ao); +} + +/* ================= colo: setup save environment ================= */ +static void colo_save_setup_done (libxl__egc *egc, +libxl__checkpoint_devices_state *cds, +int rc); +static void colo_save_setup_failed (libxl__egc *egc, +libxl__checkpoint_devices_state *cds, +int rc); +static void libxl__colo_save_domain_suspend_callback (void *data); +static void libxl__colo_save_domain_checkpoint_callback (void *data);
Quoted 8 lines
tools/libxl/libxl_colo_save.c line 54
Quoted 3 lines
tools/libxl/libxl_colo_save.c new file +3
-0+static void libxl__colo_save_domain_resume_callback (void *data); +static void libxl__colo_save_domain_wait_checkpoint_callback (void *data); +An ordered list of callbacks is appreciated. This doesn't seem to cover all callbacks and I'm not sure if this is the order they are supposed to fire either.
OK, I will check it and fix it in the next version.
Thanks
Wen Congyang
Quoted 6 lines
Wei.
.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
PATCH v10 18/31 libxc/restore: support COLO restore
In reply to Wen Congyangcall the callbacks resume/checkpoint/suspend while secondary vm status is consistent with primary.
--- tools/libxc/xc_sr_common.h | 4 +-- tools/libxc/xc_sr_restore.c | 60 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+), 2 deletions(-)
tools/libxc/xc_sr_common.h +2 -2
@@ -234,13 +234,13 @@ struct xc_sr_contextuint32_t guest_page_size;/* Plain VM, or checkpoints over time. */ -bool checkpointed; +int checkpointed;/* Currently buffering records between a checkpoint */ bool buffer_all_records;/* -* With Remus, we buffer the records sent by the primary at checkpoint, +* With Remus/COLO, we buffer the records sent by the primary at checkpoint, * in case the primary will fail, we can recover from the last * checkpoint state. * This should be enough for most of the cases because primary only send
tools/libxc/xc_sr_restore.c +60 -0
78 lines not on this page · raw message
Signature · 1 line
2.5.0
Re: [PATCH v10 18/31] libxc/restore: support COLO restore
On Mon, Feb 22, 2016 at 10:52:22AM +0800, Wen Congyang wrote:
[...]
Quoted 44 lines
- * With Remus, we buffer the records sent by the primary at checkpoint,
+ * With Remus/COLO, we buffer the records sent by the primary at checkpoint,
* in case the primary will fail, we can recover from the last
* checkpoint state.
* This should be enough for most of the cases because primary only sendtools/libxc/xc_sr_restore.c +31
-0@@ -460,6 +460,49 @@ static int handle_checkpoint(struct xc_sr_context *ctx)else ctx->restore.buffer_all_records = true; +if ( ctx->restore.checkpointed ==MIG_STREAM_COLO ) + { +#define HANDLE_CALLBACK_RETURN_VALUE(ret) \ + do { \ + if ( ret == 1 ) \ + rc = 0; /* Success */ \ + else \ + { \ +if ( ret ==2 ) \ + rc =BROKEN_CHANNEL ; \ +else \ + rc =-1 ;/* Some unspecified error */ \ + goto err; \ + } \ + }while (0 ) + +/* COLO */ + +/* We need to resume guest */ + rc = ctx->restore.ops.stream_complete (ctx); +if ( rc ) + goto err; + +/* TODO: call restore_results */ + +/* Resume secondary vm */ + ret = ctx->restore.callbacks->postcopy (ctx->restore.callbacks->data); +HANDLE_CALLBACK_RETURN_VALUE (ret); + +/* Wait for a new checkpoint */ + ret = ctx->restore.callbacks->wait_checkpoint(
tools/libxc/xc_sr_restore.c static int handle_checkpoint(struct xc_sr_context *ctx) · line 503
Quoted 10 lines
tools/libxc/xc_sr_restore.c +10
-0+ ctx->restore.callbacks->data); +HANDLE_CALLBACK_RETURN_VALUE (ret); + +/* suspend secondary vm */ + ret = ctx->restore.callbacks->suspend (ctx->restore.callbacks->data); +HANDLE_CALLBACK_RETURN_VALUE (ret); + +#undef HANDLE_CALLBACK_RETURN_VALUE + +/* TODO: send dirty pfn list to primary */
You replace the TODOs with actual code in the next two patches.
You can rearrange them a bit so that you don't need to add TODOs at all.
Wei.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH v10 18/31] libxc/restore: support COLO restore
Quoted 59 lines · Wei Liu
On Mon, Feb 22, 2016 at 10:52:22AM +0800, Wen Congyang wrote:
[...]Quoted 44 lines
- * With Remus, we buffer the records sent by the primary at checkpoint,
+ * With Remus/COLO, we buffer the records sent by the primary at checkpoint,
* in case the primary will fail, we can recover from the last
* checkpoint state.
* This should be enough for most of the cases because primary only sendtools/libxc/xc_sr_restore.c +31
-0@@ -460,6 +460,49 @@ static int handle_checkpoint(struct xc_sr_context *ctx)else ctx->restore.buffer_all_records = true; +if ( ctx->restore.checkpointed ==MIG_STREAM_COLO ) + { +#define HANDLE_CALLBACK_RETURN_VALUE(ret) \ + do { \ + if ( ret == 1 ) \ + rc = 0; /* Success */ \ + else \ + { \ +if ( ret ==2 ) \ + rc =BROKEN_CHANNEL ; \ +else \ + rc =-1 ;/* Some unspecified error */ \ + goto err; \ + } \ + }while (0 ) + +/* COLO */ + +/* We need to resume guest */ + rc = ctx->restore.ops.stream_complete (ctx); +if ( rc ) + goto err; + +/* TODO: call restore_results */ + +/* Resume secondary vm */ + ret = ctx->restore.callbacks->postcopy (ctx->restore.callbacks->data); +HANDLE_CALLBACK_RETURN_VALUE (ret); + +/* Wait for a new checkpoint */ + ret = ctx->restore.callbacks->wait_checkpoint(tools/libxc/xc_sr_restore.c static int handle_checkpoint(struct xc_sr_context *ctx) · line 503
Quoted 10 lines
tools/libxc/xc_sr_restore.c +10
-0+ ctx->restore.callbacks->data); +HANDLE_CALLBACK_RETURN_VALUE (ret); + +/* suspend secondary vm */ + ret = ctx->restore.callbacks->suspend (ctx->restore.callbacks->data); +HANDLE_CALLBACK_RETURN_VALUE (ret); + +#undef HANDLE_CALLBACK_RETURN_VALUE + +/* TODO: send dirty pfn list to primary */ You replace the TODOs with actual code in the next two patches.
Quoted 1 line
You can rearrange them a bit so that you don't need to add TODOs at all.
Yes, will fix it in the next version.
Thanks
Wen Congyang
Quoted 7 lines
Wei.
.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
PATCH v10 19/31 libxc/restore: send dirty pfn list to primary when checkpoint under colo
In reply to Wen CongyangSend dirty pfn list to primary when checkpoint under colo.
--- tools/libxc/xc_sr_common.h | 4 ++ tools/libxc/xc_sr_restore.c | 120 +++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 123 insertions(+), 1 deletion(-)
tools/libxc/xc_sr_common.h +4 -0
@@ -226,6 +226,10 @@ struct xc_sr_contextstruct xc_sr_restore_ops ops;struct restore_callbacks *callbacks; +int send_back_fd; +unsigned long p2m_size; +xc_hypercall_buffer_t dirty_bitmap_hbuf; +/* From Image Header. */ uint32_t format_version;
tools/libxc/xc_sr_restore.c +119 -1
166 lines not on this page · raw message
Signature · 1 line
2.5.0
PATCH v10 20/31 send store gfn and console gfn to xl before resuming secondary vm
In reply to Wen CongyangWe will call libxl__xc_domain_restore_done() to rebuild secondary vm. But we need store gfn and console gfn when rebuilding secondary vm. So make restore_results a function pointer in callback struct and struct {save,restore}_callbacks, and use this callback to send store gfn and console gfn to xl.
--- tools/libxc/include/xenguest.h | 8 ++++++++ tools/libxc/xc_sr_restore.c | 7 +++++-- tools/libxl/libxl_colo_restore.c | 5 ----- tools/libxl/libxl_create.c | 3 +++ tools/libxl/libxl_save_msgs_gen.pl | 4 ++-- 5 files changed, 18 insertions(+), 9 deletions(-)
tools/libxc/include/xenguest.h +8 -0
@@ -127,6 +127,14 @@ struct restore_callbacks {*/ int (*wait_checkpoint)(void * data); +/* +* callback to send store gfn and console gfn to xl +* if we want to resume vm before xc_domain_save() +* exits. +*/ +void (*restore_results)(xen_pfn_t store_gfn,xen_pfn_t console_gfn, +void *data); +/* to be provided as the last argument to each callback function */ void * data; };
tools/libxc/xc_sr_restore.c +5 -2
@@ -569,7 +569,9 @@ static int handle_checkpoint(struct xc_sr_context *ctx)if ( rc ) goto err; -/* TODO: call restore_results */ + ctx->restore.callbacks->restore_results (ctx->restore.xenstore_gfn, + ctx->restore.console_gfn, + ctx->restore.callbacks->data);/* Resume secondary vm */ ret = ctx->restore.callbacks->postcopy (ctx->restore.callbacks->data);
@@ -852,7 +854,8 @@ int xc_domain_restore(xc_interface *xch, int io_fd, uint32_t dom,/* this is COLO restore */ assert (callbacks->suspend && callbacks->postcopy && - callbacks->wait_checkpoint); + callbacks->wait_checkpoint && + callbacks->restore_results); } DPRINTF("fd %d, dom %u, hvm %u, pae %u, superpages %d"
tools/libxl/libxl_colo_restore.c +0 -5
@@ -139,11 +139,6 @@ static void colo_resume_vm(libxl__egc *egc,return ; } -/* -* TODO: get store gfn and console gfn -* We should call the callback restore_results in -* xc_domain_restore() before resuming the guest. -*/ libxl__xc_domain_restore_done (egc, dcs,0 ,0 ,0 );return ;
tools/libxl/libxl_create.c +3 -0
@@ -1014,6 +1014,8 @@ static void domcreate_bootloader_done(libxl__egc *egc,const int checkpointed_stream = dcs->restore_params.checkpointed_stream;libxl__colo_restore_state *const crs = &dcs->crs;libxl_domain_build_info *const info = &d_config->b_info; +libxl__srm_restore_autogen_callbacks *const callbacks = + &dcs->srs.shs.callbacks.restore.a;if (rc) {domcreate_rebuild_done (egc, dcs, rc);
@@ -1041,6 +1043,7 @@ static void domcreate_bootloader_done(libxl__egc *egc, }/* Restore */ + callbacks->restore_results = libxl__srm_callout_callback_restore_results;/* COLO only supports HVM now */ if (info->type != LIBXL_DOMAIN_TYPE_HVM &&
tools/libxl/libxl_save_msgs_gen.pl +2 -2
@@ -29,8 +29,8 @@ our @msgs = ( [ 6, 'srcxA', "wait_checkpoint", [] ], [ 7, 'scxA', "switch_qemu_logdirty", [qw(int domid unsigned enable)] ], - [ 8, 'r', "restore_results", ['unsigned long', 'store_mfn', - 'unsigned long', 'console_mfn'] ], + [ 8, 'rcx', "restore_results", ['unsigned long', 'store_gfn', + 'unsigned long', 'console_gfn'] ], [ 9, 'srW', "complete", [qw(int retval int errnoval)] ], );
Signature · 1 line
2.5.0
PATCH v10 21/31 libxc/save: support COLO save
In reply to Wen CongyangAfter suspend primary vm, get dirty bitmap on secondary vm, and send pages both dirty on primary/secondary to secondary.
--- tools/libxc/xc_sr_common.h | 2 + tools/libxc/xc_sr_save.c | 104 ++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 101 insertions(+), 5 deletions(-)
tools/libxc/xc_sr_common.h +2 -0
@@ -196,6 +196,8 @@ struct xc_sr_context {struct /* Save data. */ { +int recv_fd; +struct xc_sr_save_ops ops;struct save_callbacks *callbacks;
tools/libxc/xc_sr_save.c +99 -5
136 lines not on this page · raw message
Signature · 1 line
2.5.0
Re: [PATCH v10 21/31] libxc/save: support COLO save
On Mon, Feb 22, 2016 at 10:52:25AM +0800, Wen Congyang wrote:
[...]
Quoted 31 lines
/*
* Suspend the domain and send dirty memory.
* This is the last iteration of the live migration and thetools/libxc/xc_sr_save.c +14
-3@@ -558,6 +610,16 @@ static int suspend_and_send_dirty(struct xc_sr_context *ctx)bitmap_or (dirty_bitmap, ctx->save.deferred_pages, ctx->save.p2m_size); +if ( !ctx->save.live && ctx->save.checkpointed ==MIG_STREAM_COLO ) + { + rc =merge_secondary_dirty_bitmap (ctx); +if ( rc ) + { +PERROR ("Failed to get secondary vm's dirty pages" ); + goto out; + } + } + rc =send_dirty_pages (ctx, stats.dirty_count + ctx->save.nr_deferred_pages);if ( rc ) goto out;@@ -791,13 +853,42 @@ static int save(struct xc_sr_context *ctx, uint16_t guest_type)if ( rc ) goto err; - rc = ctx->save.callbacks->postcopy (ctx->save.callbacks->data); -if ( rc <=0 ) - goto err; +if ( ctx->save.checkpointed ==MIG_STREAM_COLO ) + { + rc = ctx->save.callbacks->checkpoint (ctx->save.callbacks->data); +if ( !rc )
tools/libxc/xc_sr_save.c static int save(struct xc_sr_context *ctx, uint16_t guest_type) · line 867
Quoted 10 lines
tools/libxc/xc_sr_save.c +7
-2+ { + rc =-1 ; + goto err; + } + } - rc = ctx->save.callbacks->checkpoint (ctx->save.callbacks->data); -if ( rc <=0 ) + rc = ctx->save.callbacks->postcopy (ctx->save.callbacks->data); +if ( !rc )
This original code for checking postcopy return value is if ( rc <= 0 ).
Wei.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH v10 21/31] libxc/save: support COLO save
Quoted 39 lines · Wei Liu
On Mon, Feb 22, 2016 at 10:52:25AM +0800, Wen Congyang wrote:
[...]Quoted 37 lines
/*
* Suspend the domain and send dirty memory.
* This is the last iteration of the live migration and thetools/libxc/xc_sr_save.c +19
-3@@ -558,6 +610,16 @@ static int suspend_and_send_dirty(struct xc_sr_context *ctx)bitmap_or (dirty_bitmap, ctx->save.deferred_pages, ctx->save.p2m_size); +if ( !ctx->save.live && ctx->save.checkpointed ==MIG_STREAM_COLO ) + { + rc =merge_secondary_dirty_bitmap (ctx); +if ( rc ) + { +PERROR ("Failed to get secondary vm's dirty pages" ); + goto out; + } + } + rc =send_dirty_pages (ctx, stats.dirty_count + ctx->save.nr_deferred_pages);if ( rc ) goto out;@@ -791,13 +853,42 @@ static int save(struct xc_sr_context *ctx, uint16_t guest_type)if ( rc ) goto err; - rc = ctx->save.callbacks->postcopy (ctx->save.callbacks->data); -if ( rc <=0 ) - goto err; +if ( ctx->save.checkpointed ==MIG_STREAM_COLO ) + { + rc = ctx->save.callbacks->checkpoint (ctx->save.callbacks->data); +if ( !rc ) + { + rc =-1 ; + goto err; + } + }
Quoted 6 lines
tools/libxc/xc_sr_save.c static int save(struct xc_sr_context *ctx, uint16_t guest_type) · line 867
Quoted 4 lines
tools/libxc/xc_sr_save.c +2
-2- rc = ctx->save.callbacks->checkpoint (ctx->save.callbacks->data); -if ( rc <=0 ) + rc = ctx->save.callbacks->postcopy (ctx->save.callbacks->data); +if ( !rc )This original code for checking postcopy return value is if ( rc <= 0 ).
OK, I will check it.
Thanks
Wen Congyang
Quoted 6 lines
Wei.
.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
PATCH v10 22/31 implement the cmdline for COLO
In reply to Wen CongyangAdd a new option -c to the command 'xl remus'. If you want to use COLO HA instead of Remus HA, please use -c option.
Update man pages to reflect the addition of a new option to 'xl remus' command.
Also add a new option -c to the internal command 'xl migrate-receive'.
--- docs/man/xl.pod.1 | 12 +++++++-- tools/libxl/libxl.c | 23 ++++++++++++++++-- tools/libxl/xl_cmdimpl.c | 62 ++++++++++++++++++++++++++++++++++++----------- tools/libxl/xl_cmdtable.c | 4 ++- 4 files changed, 82 insertions(+), 19 deletions(-)
docs/man/xl.pod.1 +10 -2
@@ -447,12 +447,15 @@ Print huge (!) amount of debug during the migration process. =item B<remus> [I<OPTIONS>] I<domain-id> I<host> -Enable Remus HA for domain. By default B<xl> relies on ssh as a transport -mechanism between the two hosts. +Enable Remus HA or COLO HA for domain. By default B<xl> relies on ssh as a +transport mechanism between the two hosts. N.B: Remus support in xl is still in experimental (proof-of-concept) phase. Disk replication support is limited to DRBD disks. + COLO support in xl is still in experimental (proof-of-concept) phase. + There is no support for network or disk at the moment. + B<OPTIONS> =over 4
@@ -498,6 +501,11 @@ Disable network output buffering. Requires enabling unsafe mode. Disable disk replication. Requires enabling unsafe mode. +=item B<-c> + +Enable COLO HA. This conflicts with B<-i> and B<-b>, and memory +checkpoint compression must be disabled. + =back =item B<pause> I<domain-id>
tools/libxl/libxl.c +21 -2
@@ -849,12 +849,28 @@ int libxl_domain_remus_start(libxl_ctx *ctx, libxl_domain_remus_info *info, goto out; } +/* The caller must set this defbool */ +if (libxl_defbool_is_default (info->colo)) { +LOG (ERROR ,"colo mode must be enabled/disabled" ); + rc =ERROR_FAIL ; + goto out; + } +libxl_defbool_setdefault (&info->allow_unsafe, false);libxl_defbool_setdefault (&info->blackhole, false); -libxl_defbool_setdefault (&info->compression, true); +libxl_defbool_setdefault (&info->compression, + !libxl_defbool_val (info->colo));libxl_defbool_setdefault (&info->netbuf, true);libxl_defbool_setdefault (&info->diskbuf, true); +if (libxl_defbool_val (info->colo)) { +if (libxl_defbool_val (info->compression)) { +LOG (ERROR ,"cannot use memory checkpoint compression in COLO mode" ); + rc =ERROR_FAIL ; + goto out; + } + } + if (!libxl_defbool_val(info->allow_unsafe) && (libxl_defbool_val(info->blackhole) || !libxl_defbool_val(info->netbuf) ||
@@ -876,7 +892,10 @@ int libxl_domain_remus_start(libxl_ctx *ctx, libxl_domain_remus_info *info, dss->live =1 ; dss->debug =0 ; dss->remus = info; - dss->checkpointed_stream =LIBXL_CHECKPOINTED_STREAM_REMUS ; +if (libxl_defbool_val (info->colo)) + dss->checkpointed_stream =LIBXL_CHECKPOINTED_STREAM_COLO ; +else + dss->checkpointed_stream =LIBXL_CHECKPOINTED_STREAM_REMUS ;assert (info);
tools/libxl/xl_cmdimpl.c +48 -14
144 lines not on this page · raw message
tools/libxl/xl_cmdtable.c +3 -1
@@ -499,7 +499,9 @@ struct cmd_spec cmd_table[] = { "-b Replicate memory checkpoints to /dev/null (blackhole).\n" " Works only in unsafe mode.\n" "-n Disable network output buffering. Works only in unsafe mode.\n" - "-d Disable disk replication. Works only in unsafe mode." + "-d Disable disk replication. Works only in unsafe mode.\n" + "-c Enable COLO HA. It is conflict with -i and -b, and memory\n" + " checkpoint must be disabled" }, #endif { "devd",
Signature · 1 line
2.5.0
Re: [PATCH v10 22/31] implement the cmdline for COLO
On Mon, Feb 22, 2016 at 10:52:26AM +0800, Wen Congyang wrote:
[...]
tools/libxl/libxl.c int libxl_domain_remus_start(libxl_ctx *ctx, libxl_domain_remus_info *info, · line 867
Quoted 2 lines
tools/libxl/libxl.c +2
-0+if (libxl_defbool_val (info->colo)) { +if (libxl_defbool_val (info->compression)) {
This can be simplified as
if (libxl_defbool_val(xxx) && libxl_defbool_val(yyy))
Quoted 35 lines
tools/libxl/libxl.c +10
-1+LOG (ERROR ,"cannot use memory checkpoint compression in COLO mode" ); + rc =ERROR_FAIL ; + goto out; + } + } + if (!libxl_defbool_val(info->allow_unsafe) && (libxl_defbool_val(info->blackhole) || !libxl_defbool_val(info->netbuf) ||@@ -876,7 +892,10 @@ int libxl_domain_remus_start(libxl_ctx *ctx, libxl_domain_remus_info *info, dss->live =1 ; dss->debug =0 ; dss->remus = info; - dss->checkpointed_stream =LIBXL_CHECKPOINTED_STREAM_REMUS ; +if (libxl_defbool_val (info->colo)) + dss->checkpointed_stream =LIBXL_CHECKPOINTED_STREAM_COLO ; +else + dss->checkpointed_stream =LIBXL_CHECKPOINTED_STREAM_REMUS ;assert (info);tools/libxl/xl_cmdimpl.c +2
-0@@ -4440,6 +4440,8 @@ static void migrate_receive(int debug, int daemonize, int monitor,char rc_buf;char *migration_domname;struct domain_create dom_info; +const char *ha = checkpointed ==LIBXL_CHECKPOINTED_STREAM_COLO ? +"COLO" :"Remus" ;signal (SIGPIPE ,SIG_IGN );/* if we get SIGPIPE we'd rather just have it as an error */
tools/libxl/xl_cmdimpl.c static void migrate_receive(int debug, int daemonize, int monitor, · line 4468
Quoted 7 lines
tools/libxl/xl_cmdimpl.c +3
-0@@ -4460,6 +4462,9 @@ static void migrate_receive(int debug, int daemonize, int monitor, dom_info.send_back_fd = send_fd; dom_info.migration_domname_r = &migration_domname; dom_info.checkpointed_stream = checkpointed; +if (checkpointed ==LIBXL_CHECKPOINTED_STREAM_COLO ) +/* COLO uses stdout to send control message to master */ + dom_info.quiet =1 ;
It seems that dom_info->quiet affects stderr, not stdout. See the only place that checks this in xl_cmdimpl.c.
Quoted 94 lines
tools/libxl/xl_cmdimpl.c +27
-11rc =create_domain (&dom_info);if (rc <0 ) {@@ -4472,11 +4477,12 @@ static void migrate_receive(int debug, int daemonize, int monitor,switch (checkpointed) {case LIBXL_CHECKPOINTED_STREAM_REMUS : +case LIBXL_CHECKPOINTED_STREAM_COLO :/* If we are here, it means that the sender (primary) has crashed. * TODO: Split-Brain Check. */ -fprintf (stderr,"migration target: Remus Failover for domain %u\n" , - domid); +fprintf (stderr,"migration target: %s Failover for domain %u\n" , + ha, domid);/* * If domain renaming fails, lets just continue (as we need the domain @@ -4492,16 +4498,20 @@ static void migrate_receive(int debug, int daemonize, int monitor, rc =libxl_domain_rename (ctx, domid, migration_domname, common_domname);if (rc) -fprintf (stderr,"migration target (Remus): " +fprintf (stderr,"migration target (%s): " "Failed to rename domain from %s to %s:%d\n" , - migration_domname, common_domname, rc); + ha, migration_domname, common_domname, rc); } +if (checkpointed ==LIBXL_CHECKPOINTED_STREAM_COLO ) +/* The guest is running after failover in COLO mode */ +exit (rc ? -ERROR_FAIL :0 ); + rc =libxl_domain_unpause (ctx, domid);if (rc) -fprintf (stderr,"migration target (Remus): " +fprintf (stderr,"migration target (%s): " "Failed to unpause domain %s (id: %u):%d\n" , - common_domname, domid, rc); + ha, common_domname, domid, rc);exit (rc ? -ERROR_FAIL :0 );default :@@ -4649,7 +4659,7 @@ int main_migrate_receive(int argc, char **argv)libxl_checkpointed_stream checkpointed =LIBXL_CHECKPOINTED_STREAM_NONE ;int opt; - SWITCH_FOREACH_OPT(opt, "Fedr", NULL, "migrate-receive", 0) { + SWITCH_FOREACH_OPT(opt, "Fedrc", NULL, "migrate-receive", 0) {case 'F' : daemonize =0 ;break ;@@ -4663,6 +4673,9 @@ int main_migrate_receive(int argc, char **argv)case 'r' : checkpointed =LIBXL_CHECKPOINTED_STREAM_REMUS ;break ; +case 'c' : + checkpointed =LIBXL_CHECKPOINTED_STREAM_COLO ; +break ; }if (argc-optind !=0 ) {@@ -8032,11 +8045,8 @@ int main_remus(int argc, char **argv)int config_len;memset (&r_info,0 ,sizeof (libxl_domain_remus_info)); -/* Defaults */ - r_info.interval =200 ; -libxl_defbool_setdefault (&r_info.blackhole, false); - SWITCH_FOREACH_OPT(opt, "Fbundi:s:N:e", NULL, "remus", 2) { + SWITCH_FOREACH_OPT(opt, "Fbundi:s:N:ec", NULL, "remus", 2) {case 'i' : r_info.interval =atoi (optarg);break ;@@ -8064,11 +8074,32 @@ int main_remus(int argc, char **argv)case 'e' : daemonize =0 ;break ; +case 'c' : +libxl_defbool_set (&r_info.colo, true); } domid =find_domain (argv[optind]); host = argv[optind +1 ]; +/* Defaults */ +libxl_defbool_setdefault (&r_info.blackhole, false); +libxl_defbool_setdefault (&r_info.colo, false); +if (!libxl_defbool_val (r_info.colo) && !r_info.interval) + r_info.interval =200 ; + +if (libxl_defbool_val (r_info.colo)) { +if (r_info.interval ||libxl_defbool_val (r_info.blackhole)) { +perror ("Option -c conflicts with -i or -b" );
tools/libxl/xl_cmdimpl.c int main_remus(int argc, char **argv) · line 8102
Quoted 10 lines
tools/libxl/xl_cmdimpl.c +10
-0+exit (-1 ); + } + +if (libxl_defbool_is_default (r_info.compression)) { +perror ("COLO can't be used with memory compression. " +"Disable memory checkpoint compression now..." ); +libxl_defbool_set (&r_info.compression, false); + } + } +
I don't think I'm entirely happy with how these things are arranged. Remus and COLO don't seem to have a set of consistent APIs that arbitrary users can call.
But for the sake of not growing this series any longer let's leave it like this for the moment. I think COLO at best is going to be (as you stated in manpage) experimental at this stage.
Quoted 59 lines
tools/libxl/xl_cmdimpl.c +6
-3if (!r_info.netbufscript) r_info.netbufscript = default_remus_netbufscript;@@ -8083,8 +8114,9 @@ int main_remus(int argc, char **argv)if (!ssh_command[0 ]) { rune = host; }else { -xasprintf (&rune,"exec %s %s xl migrate-receive -r %s" , +xasprintf (&rune,"exec %s %s xl migrate-receive %s %s" , ssh_command, host, +libxl_defbool_val (r_info.colo) ?"-c" :"-r" , daemonize ?"" :" -e" ); }@@ -8112,7 +8144,8 @@ int main_remus(int argc, char **argv)* domain to force failover */ if (libxl_domain_info (ctx,0 , domid)) { -fprintf (stderr,"Remus: Primary domain has been destroyed.\n" ); +fprintf (stderr,"%s: Primary domain has been destroyed.\n" , +libxl_defbool_val (r_info.colo) ?"COLO" :"Remus" );close (send_fd);return 0 ; }@@ -8124,7 +8157,8 @@ int main_remus(int argc, char **argv)if (rc ==ERROR_GUEST_TIMEDOUT )fprintf (stderr,"Failed to suspend domain at primary.\n" );else { -fprintf (stderr,"Remus: Backup failed? resuming domain at primary.\n" ); +fprintf (stderr,"%s: Backup failed? resuming domain at primary.\n" , +libxl_defbool_val (r_info.colo) ?"COLO" :"Remus" );libxl_domain_resume (ctx, domid,1 ,0 ); }tools/libxl/xl_cmdtable.c +3
-1@@ -499,7 +499,9 @@ struct cmd_spec cmd_table[] = { "-b Replicate memory checkpoints to /dev/null (blackhole).\n" " Works only in unsafe mode.\n" "-n Disable network output buffering. Works only in unsafe mode.\n" - "-d Disable disk replication. Works only in unsafe mode." + "-d Disable disk replication. Works only in unsafe mode.\n" + "-c Enable COLO HA. It is conflict with -i and -b, and memory\n" + " checkpoint must be disabled" }, #endif { "devd",Signature · 9 lines
2.5.0 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH v10 22/31] implement the cmdline for COLO
Quoted 8 lines · Wei Liu
On Mon, Feb 22, 2016 at 10:52:26AM +0800, Wen Congyang wrote:
[...]tools/libxl/libxl.c int libxl_domain_remus_start(libxl_ctx *ctx, libxl_domain_remus_info *info, · line 867
Quoted 2 lines
tools/libxl/libxl.c +2
-0+if (libxl_defbool_val (info->colo)) { +if (libxl_defbool_val (info->compression)) {This can be simplified as
if (libxl_defbool_val(xxx) && libxl_defbool_val(yyy))
OK. will fix it in the next version.
Quoted 156 lines
Quoted 36 lines
tools/libxl/libxl.c +10
-1+LOG (ERROR ,"cannot use memory checkpoint compression in COLO mode" ); + rc =ERROR_FAIL ; + goto out; + } + } + if (!libxl_defbool_val(info->allow_unsafe) && (libxl_defbool_val(info->blackhole) || !libxl_defbool_val(info->netbuf) ||@@ -876,7 +892,10 @@ int libxl_domain_remus_start(libxl_ctx *ctx, libxl_domain_remus_info *info, dss->live =1 ; dss->debug =0 ; dss->remus = info; - dss->checkpointed_stream =LIBXL_CHECKPOINTED_STREAM_REMUS ; +if (libxl_defbool_val (info->colo)) + dss->checkpointed_stream =LIBXL_CHECKPOINTED_STREAM_COLO ; +else + dss->checkpointed_stream =LIBXL_CHECKPOINTED_STREAM_REMUS ;assert (info);tools/libxl/xl_cmdimpl.c +2
-0@@ -4440,6 +4440,8 @@ static void migrate_receive(int debug, int daemonize, int monitor,char rc_buf;char *migration_domname;struct domain_create dom_info; +const char *ha = checkpointed ==LIBXL_CHECKPOINTED_STREAM_COLO ? +"COLO" :"Remus" ;signal (SIGPIPE ,SIG_IGN );/* if we get SIGPIPE we'd rather just have it as an error */ tools/libxl/xl_cmdimpl.c static void migrate_receive(int debug, int daemonize, int monitor, · line 4468
Quoted 7 lines
tools/libxl/xl_cmdimpl.c +3
-0@@ -4460,6 +4462,9 @@ static void migrate_receive(int debug, int daemonize, int monitor, dom_info.send_back_fd = send_fd; dom_info.migration_domname_r = &migration_domname; dom_info.checkpointed_stream = checkpointed; +if (checkpointed ==LIBXL_CHECKPOINTED_STREAM_COLO ) +/* COLO uses stdout to send control message to master */ + dom_info.quiet =1 ;It seems that
dom_info->quietaffects stderr, not stdout. See the only place that checks this inxl_cmdimpl.c.Quoted 94 lines
tools/libxl/xl_cmdimpl.c +27
-11rc =create_domain (&dom_info);if (rc <0 ) {@@ -4472,11 +4477,12 @@ static void migrate_receive(int debug, int daemonize, int monitor,switch (checkpointed) {case LIBXL_CHECKPOINTED_STREAM_REMUS : +case LIBXL_CHECKPOINTED_STREAM_COLO :/* If we are here, it means that the sender (primary) has crashed. * TODO: Split-Brain Check. */ -fprintf (stderr,"migration target: Remus Failover for domain %u\n" , - domid); +fprintf (stderr,"migration target: %s Failover for domain %u\n" , + ha, domid);/* * If domain renaming fails, lets just continue (as we need the domain @@ -4492,16 +4498,20 @@ static void migrate_receive(int debug, int daemonize, int monitor, rc =libxl_domain_rename (ctx, domid, migration_domname, common_domname);if (rc) -fprintf (stderr,"migration target (Remus): " +fprintf (stderr,"migration target (%s): " "Failed to rename domain from %s to %s:%d\n" , - migration_domname, common_domname, rc); + ha, migration_domname, common_domname, rc); } +if (checkpointed ==LIBXL_CHECKPOINTED_STREAM_COLO ) +/* The guest is running after failover in COLO mode */ +exit (rc ? -ERROR_FAIL :0 ); + rc =libxl_domain_unpause (ctx, domid);if (rc) -fprintf (stderr,"migration target (Remus): " +fprintf (stderr,"migration target (%s): " "Failed to unpause domain %s (id: %u):%d\n" , - common_domname, domid, rc); + ha, common_domname, domid, rc);exit (rc ? -ERROR_FAIL :0 );default :@@ -4649,7 +4659,7 @@ int main_migrate_receive(int argc, char **argv)libxl_checkpointed_stream checkpointed =LIBXL_CHECKPOINTED_STREAM_NONE ;int opt; - SWITCH_FOREACH_OPT(opt, "Fedr", NULL, "migrate-receive", 0) { + SWITCH_FOREACH_OPT(opt, "Fedrc", NULL, "migrate-receive", 0) {case 'F' : daemonize =0 ;break ;@@ -4663,6 +4673,9 @@ int main_migrate_receive(int argc, char **argv)case 'r' : checkpointed =LIBXL_CHECKPOINTED_STREAM_REMUS ;break ; +case 'c' : + checkpointed =LIBXL_CHECKPOINTED_STREAM_COLO ; +break ; }if (argc-optind !=0 ) {@@ -8032,11 +8045,8 @@ int main_remus(int argc, char **argv)int config_len;memset (&r_info,0 ,sizeof (libxl_domain_remus_info)); -/* Defaults */ - r_info.interval =200 ; -libxl_defbool_setdefault (&r_info.blackhole, false); - SWITCH_FOREACH_OPT(opt, "Fbundi:s:N:e", NULL, "remus", 2) { + SWITCH_FOREACH_OPT(opt, "Fbundi:s:N:ec", NULL, "remus", 2) {case 'i' : r_info.interval =atoi (optarg);break ;@@ -8064,11 +8074,32 @@ int main_remus(int argc, char **argv)case 'e' : daemonize =0 ;break ; +case 'c' : +libxl_defbool_set (&r_info.colo, true); } domid =find_domain (argv[optind]); host = argv[optind +1 ]; +/* Defaults */ +libxl_defbool_setdefault (&r_info.blackhole, false); +libxl_defbool_setdefault (&r_info.colo, false); +if (!libxl_defbool_val (r_info.colo) && !r_info.interval) + r_info.interval =200 ; + +if (libxl_defbool_val (r_info.colo)) { +if (r_info.interval ||libxl_defbool_val (r_info.blackhole)) { +perror ("Option -c conflicts with -i or -b" );tools/libxl/xl_cmdimpl.c int main_remus(int argc, char **argv) · line 8102
Quoted 10 lines
tools/libxl/xl_cmdimpl.c +10
-0+exit (-1 ); + } + +if (libxl_defbool_is_default (r_info.compression)) { +perror ("COLO can't be used with memory compression. " +"Disable memory checkpoint compression now..." ); +libxl_defbool_set (&r_info.compression, false); + } + } +I don't think I'm entirely happy with how these things are arranged. Remus and COLO don't seem to have a set of consistent APIs that arbitrary users can call.
Quoted 3 lines
But for the sake of not growing this series any longer let's leave it like this for the moment. I think COLO at best is going to be (as you stated in manpage) experimental at this stage.
Yes, it is experimental now.
Thanks
Wen Congyang
Quoted 57 lines
Quoted 57 lines
tools/libxl/xl_cmdimpl.c +6
-3if (!r_info.netbufscript) r_info.netbufscript = default_remus_netbufscript;@@ -8083,8 +8114,9 @@ int main_remus(int argc, char **argv)if (!ssh_command[0 ]) { rune = host; }else { -xasprintf (&rune,"exec %s %s xl migrate-receive -r %s" , +xasprintf (&rune,"exec %s %s xl migrate-receive %s %s" , ssh_command, host, +libxl_defbool_val (r_info.colo) ?"-c" :"-r" , daemonize ?"" :" -e" ); }@@ -8112,7 +8144,8 @@ int main_remus(int argc, char **argv)* domain to force failover */ if (libxl_domain_info (ctx,0 , domid)) { -fprintf (stderr,"Remus: Primary domain has been destroyed.\n" ); +fprintf (stderr,"%s: Primary domain has been destroyed.\n" , +libxl_defbool_val (r_info.colo) ?"COLO" :"Remus" );close (send_fd);return 0 ; }@@ -8124,7 +8157,8 @@ int main_remus(int argc, char **argv)if (rc ==ERROR_GUEST_TIMEDOUT )fprintf (stderr,"Failed to suspend domain at primary.\n" );else { -fprintf (stderr,"Remus: Backup failed? resuming domain at primary.\n" ); +fprintf (stderr,"%s: Backup failed? resuming domain at primary.\n" , +libxl_defbool_val (r_info.colo) ?"COLO" :"Remus" );libxl_domain_resume (ctx, domid,1 ,0 ); }tools/libxl/xl_cmdtable.c +3
-1@@ -499,7 +499,9 @@ struct cmd_spec cmd_table[] = { "-b Replicate memory checkpoints to /dev/null (blackhole).\n" " Works only in unsafe mode.\n" "-n Disable network output buffering. Works only in unsafe mode.\n" - "-d Disable disk replication. Works only in unsafe mode." + "-d Disable disk replication. Works only in unsafe mode.\n" + "-c Enable COLO HA. It is conflict with -i and -b, and memory\n" + " checkpoint must be disabled" }, #endif { "devd",Signature · 1 line
2.5.0
Quoted 8 lines
Quoted 4 lines
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
PATCH v10 23/31 COLO: introduce new API to prepare/start/do/get_error/stop replication
In reply to Wen CongyangWe will use qemu block replication, and qemu provides some qmp commands to prepare replication, start replication, get replication error, and stop replication. Introduce new API to execute these qmp commands.
--- tools/libxl/libxl_internal.h | 20 +++++++++ tools/libxl/libxl_qmp.c | 96 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 116 insertions(+)
tools/libxl/libxl_internal.h +20 -0
@@ -1771,6 +1771,26 @@ _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); +/* Start NBD server */ +_hidden int libxl__qmp_nbd_server_start(libxl__gc *gc, int domid, +const char *host,const char *port); +/* Add a disk to NBD server */ +_hidden int libxl__qmp_nbd_server_add(libxl__gc *gc, int domid, const char *disk); +/* Start replication */ +_hidden int libxl__qmp_start_replication(libxl__gc *gc, int domid, bool primary); +/* Get replication error that occurs when the vm is running */ +_hidden int libxl__qmp_get_replication_error(libxl__gc *gc, int domid); +/* Do checkpoint */ +_hidden int libxl__qmp_do_checkpoint(libxl__gc *gc, int domid); +/* Stop replication */ +_hidden int libxl__qmp_stop_replication(libxl__gc *gc, int domid, bool primary); +/* Stop NBD server */ +_hidden int libxl__qmp_nbd_server_stop(libxl__gc *gc, int domid); +/* Add or remove a child to/from quorum */ +_hidden int libxl__qmp_x_blockdev_change(libxl__gc *gc, int domid, const char *parant, +const char *child,const char *node); +/* run a hmp command in qmp mode */ +_hidden int libxl__qmp_hmp(libxl__gc *gc, int domid, const char *command_line);/* 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 +96 -0
102 lines not on this page · raw message
Signature · 1 line
2.5.0
Re: [PATCH v10 23/31] COLO: introduce new API to prepare/start/do/get_error/stop replication
Quoted 5 lines · Wen Congyang
We will use qemu block replication, and qemu provides some qmp commands to prepare replication, start replication, get replication error, and stop replication. Introduce new API to execute these qmp commands.
Signed-off-by Wen Congyang <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
PATCH v10 24/31 Support colo mode for qemu disk
In reply to Wen CongyangUsage: disk = ['...,colo,colo-host=xxx,colo-port=xxx,colo-export=xxx,active-disk=xxx,hidden-disk=xxx...'] For QEMU block replication details:
http://wiki.qemu.org/Features/BlockReplication
--- docs/man/xl.pod.1 | 2 +- docs/misc/xl-disk-configuration.txt | 50 ++++++++++ tools/libxl/libxl.c | 62 +++++++++++- tools/libxl/libxl_create.c | 25 ++++- tools/libxl/libxl_device.c | 54 +++++++++++ tools/libxl/libxl_dm.c | 184 ++++++++++++++++++++++++++++++++++-- tools/libxl/libxl_types.idl | 7 ++ tools/libxl/libxlu_disk_l.l | 7 ++ 8 files changed, 382 insertions(+), 9 deletions(-)
docs/man/xl.pod.1 +1 -1
@@ -454,7 +454,7 @@ N.B: Remus support in xl is still in experimental (proof-of-concept) phase. Disk replication support is limited to DRBD disks. COLO support in xl is still in experimental (proof-of-concept) phase. - There is no support for network or disk at the moment. + There is no support for network at the moment. B<OPTIONS>
docs/misc/xl-disk-configuration.txt +50 -0
56 lines not on this page · raw message
tools/libxl/libxl.c +61 -1
86 lines not on this page · raw message
tools/libxl/libxl_create.c +24 -1
@@ -1801,12 +1801,29 @@ static void domain_create_cb(libxl__egc *egc,libxl__ao_complete (egc, ao, rc); } - + +static void set_disk_colo_restore (libxl_domain_config *d_config) +{ +int i; + +for (i =0 ; i < d_config->num_disks; i++) +libxl_defbool_set (&d_config->disks[i].colo_restore_enable, true); +} + +static void unset_disk_colo_restore (libxl_domain_config *d_config) +{ +int i; + +for (i =0 ; i < d_config->num_disks; i++) +libxl_defbool_set (&d_config->disks[i].colo_restore_enable, false); +} +int libxl_domain_create_new (libxl_ctx *ctx,libxl_domain_config *d_config,uint32_t *domid,const libxl_asyncop_how *ao_how,const libxl_asyncprogress_how *aop_console_how) { +unset_disk_colo_restore (d_config);return do_domain_create (ctx, d_config, domid,-1 ,-1 ,NULL , ao_how, aop_console_how); }
@@ -1818,6 +1835,12 @@ int libxl_domain_create_restore(libxl_ctx *ctx, libxl_domain_config *d_config,const libxl_asyncop_how *ao_how, const libxl_asyncprogress_how *aop_console_how) { + if (params->checkpointed_stream == LIBXL_CHECKPOINTED_STREAM_COLO) { +set_disk_colo_restore (d_config ); + } else { +unset_disk_colo_restore (d_config); + } +return do_domain_create (ctx, d_config, domid, restore_fd, send_back_fd, params, ao_how, aop_console_how); }
tools/libxl/libxl_device.c +54 -0
78 lines not on this page · raw message
tools/libxl/libxl_dm.c +178 -6
212 lines not on this page · raw message
tools/libxl/libxl_types.idl +7 -0
@@ -575,6 +575,13 @@ libxl_device_disk = Struct("device_disk", [ ("is_cdrom", integer), ("direct_io_safe", bool), ("discard_enable", libxl_defbool), + ("colo_enable", libxl_defbool), + ("colo_restore_enable", libxl_defbool), + ("colo_host", string), + ("colo_port", string), + ("colo_export", string), + ("active_disk", string), + ("hidden_disk", string) ]) libxl_device_nic = Struct("device_nic", [
tools/libxl/libxlu_disk_l.l +7 -0
@@ -176,6 +176,13 @@ script=[^,]*,? { STRIP(','); SAVESTRING("script", script, FROMEQUALS); } direct-io-safe,? { DPC->disk->direct_io_safe = 1; } discard,? { libxl_defbool_set(&DPC->disk->discard_enable, true); } no-discard,? { libxl_defbool_set(&DPC->disk->discard_enable, false); } +colo,? { libxl_defbool_set(&DPC->disk->colo_enable, true); } +no-colo,? { libxl_defbool_set(&DPC->disk->colo_enable, false); } +colo-host=[^,]*,? { STRIP(','); SAVESTRING("colo-host", colo_host, FROMEQUALS); } +colo-port=[^,]*,? { STRIP(','); SAVESTRING("colo-port", colo_port, FROMEQUALS); } +colo-export=[^,]*,? { STRIP(','); SAVESTRING("colo-export", colo_export, FROMEQUALS); } +active-disk=[^,]*,? { STRIP(','); SAVESTRING("active-disk", active_disk, FROMEQUALS); } +hidden-disk=[^,]*,? { STRIP(','); SAVESTRING("hidden-disk", hidden_disk, FROMEQUALS); } /* the target magic parameter, eats the rest of the string */
Signature · 1 line
2.5.0
Re: [PATCH v10 24/31] Support colo mode for qemu disk
Quoted 22 lines · Wen Congyang
Usage: disk = ['...,colo,colo-host=xxx,colo-port=xxx,colo-export=xxx,active-disk=xxx,hidden-disk=xxx...'] For QEMU block replication details:
http://wiki.qemu.org/Features/BlockReplicationSigned-off-by Wen Congyang <[email protected]>Signed-off-by Yang Hongyang <[email protected]>--- docs/man/xl.pod.1 | 2 +- docs/misc/xl-disk-configuration.txt | 50 ++++++++++ tools/libxl/libxl.c | 62 +++++++++++- tools/libxl/libxl_create.c | 25 ++++- tools/libxl/libxl_device.c | 54 +++++++++++ tools/libxl/libxl_dm.c | 184 ++++++++++++++++++++++++++++++++++-- tools/libxl/libxl_types.idl | 7 ++ tools/libxl/libxlu_disk_l.l | 7 ++ 8 files changed, 382 insertions(+), 9 deletions(-)docs/man/xl.pod.1 +0
-0
docs/man/xl.pod.1 N.B: Remus support in xl is still in experimental (proof-of-concept) phase. · line 457
Quoted 5 lines
docs/man/xl.pod.1 +1
-1@@ -454,7 +454,7 @@ N.B: Remus support in xl is still in experimental (proof-of-concept) phase. Disk replication support is limited to DRBD disks. COLO support in xl is still in experimental (proof-of-concept) phase. - There is no support for network or disk at the moment. + There is no support for network at the moment.
You need some document here for the syntax, otherwise users have no clue how to configure disk replicate support. I also won't be able to meaningfully review this patch without a reference.
docs/misc/xl-disk-configuration.txt were intentionally created non-sparse to avoid fragmentation of the · line 236
Quoted 11 lines
docs/man/xl.pod.1 +0
-0B<OPTIONS>docs/misc/xl-disk-configuration.txt +0
-0@@ -234,6 +234,56 @@ were intentionally created non-sparse to avoid fragmentation of the file.
Some nitpicking about the format below.
Quoted 5 lines
docs/misc/xl-disk-configuration.txt +5
-0+=============== +COLO PARAMETERS +=============== + +
docs/misc/xl-disk-configuration.txt were intentionally created non-sparse to avoid fragmentation of the · line 251
Quoted 10 lines
docs/misc/xl-disk-configuration.txt +10
-0+colo +---- + +Enable COLO HA for disk. For better understanding block replication on +QEMU, please refer to: +http://wiki.qemu.org/Features/BlockReplication + + +colo-host +---------
Blank line here please.
docs/misc/xl-disk-configuration.txt were intentionally created non-sparse to avoid fragmentation of the · line 257
Quoted 6 lines
docs/misc/xl-disk-configuration.txt +6
-0+Description: Secondary host's address +Mandatory: Yes when COLO enabled + + +colo-port +---------
Ditto.
docs/misc/xl-disk-configuration.txt were intentionally created non-sparse to avoid fragmentation of the · line 265
Quoted 8 lines
docs/misc/xl-disk-configuration.txt +8
-0+Description: Secondary port + We will run a nbd server on secondary host, + and the nbd server will listen this port. +Mandatory: Yes when COLO enabled + + +colo-export +---------
Here as well. And some more "-"s to match "colo-export".
Quoted 11 lines
docs/misc/xl-disk-configuration.txt +11
-0+Description: We will run a nbd server on secondary host, + exportname is the nbd server's disk export name. +Mandatory: Yes when COLO enabled + + +active-disk +----------- + +Description: This is used by secondary. Secondary guest's write + will be buffered in this disk. +Mandatory: Yes when COLO enabled
docs/misc/xl-disk-configuration.txt were intentionally created non-sparse to avoid fragmentation of the · line 286
Quoted 10 lines
docs/misc/xl-disk-configuration.txt +10
-0+ + +hidden-disk +----------- + +Description: This is used by secondary. It buffers the original + content that is modified by the primary VM. +Mandatory: Yes when COLO enabled + +
The rest of the patch is mainly for manipulating QEMU parameters. I've skipped it for now.
Quoted 36 lines
docs/misc/xl-disk-configuration.txt +0
-0============================================ DEPRECATED PARAMETERS, PREFIXES AND SYNTAXES ============================================tools/libxl/libxl.c +14
-0@@ -2309,6 +2309,8 @@ int libxl__device_disk_setdefault(libxl__gc *gc, libxl_device_disk *disk)int rc;libxl_defbool_setdefault (&disk->discard_enable, !!disk->readwrite); +libxl_defbool_setdefault (&disk->colo_enable, false); +libxl_defbool_setdefault (&disk->colo_restore_enable, false); rc =libxl__resolve_domid (gc, disk->backend_domname, &disk->backend_domid);if (rc <0 )return rc;@@ -2507,6 +2509,18 @@ static void device_disk_add(libxl__egc *egc, uint32_t domid,flexarray_append (back,"params" );flexarray_append (back,GCSPRINTF ("%s:%s" ,libxl__device_disk_string_of_format (disk->format), disk->pdev_path)); +if (libxl_defbool_val (disk->colo_enable)) { +flexarray_append (back,"colo-host" ); +flexarray_append (back,libxl__sprintf (gc,"%s" , disk->colo_host)); +flexarray_append (back,"colo-port" ); +flexarray_append (back,libxl__sprintf (gc,"%s" , disk->colo_port)); +flexarray_append (back,"colo-export" ); +flexarray_append (back,libxl__sprintf (gc,"%s" , disk->colo_export)); +flexarray_append (back,"active-disk" ); +flexarray_append (back,libxl__sprintf (gc,"%s" , disk->active_disk)); +flexarray_append (back,"hidden-disk" ); +flexarray_append (back,libxl__sprintf (gc,"%s" , disk->hidden_disk)); + }assert (device->backend_kind ==LIBXL__DEVICE_KIND_QDISK );break ;default :
tools/libxl/libxl.c static int libxl__device_disk_from_xs_be(libxl__gc *gc, · line 2641
Quoted 7 lines
tools/libxl/libxl.c +3
-1@@ -2622,7 +2636,10 @@ static int libxl__device_disk_from_xs_be(libxl__gc *gc, goto cleanup; } -/* "params" may not be present; but everything else must be. */ +/* +* "params" and "colo-host" may not be present; but everything +* else must be.
I don't think this is correct. You have certainly have colo disabled. I think you can just avoid modifying this comment.
Wei.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH v10 24/31] Support colo mode for qemu disk
Quoted 25 lines · Wei Liu
Quoted 24 lines · Wen Congyang
Usage: disk = ['...,colo,colo-host=xxx,colo-port=xxx,colo-export=xxx,active-disk=xxx,hidden-disk=xxx...'] For QEMU block replication details:
http://wiki.qemu.org/Features/BlockReplicationSigned-off-by Wen Congyang <[email protected]>Signed-off-by Yang Hongyang <[email protected]>--- docs/man/xl.pod.1 | 2 +- docs/misc/xl-disk-configuration.txt | 50 ++++++++++ tools/libxl/libxl.c | 62 +++++++++++- tools/libxl/libxl_create.c | 25 ++++- tools/libxl/libxl_device.c | 54 +++++++++++ tools/libxl/libxl_dm.c | 184 ++++++++++++++++++++++++++++++++++-- tools/libxl/libxl_types.idl | 7 ++ tools/libxl/libxlu_disk_l.l | 7 ++ 8 files changed, 382 insertions(+), 9 deletions(-)docs/man/xl.pod.1 +0
-0@@ -454,7 +454,7 @@ N.B: Remus support in xl is still in experimental (proof-of-concept) phase. Disk replication support is limited to DRBD disks.
Quoted 7 lines
docs/man/xl.pod.1 N.B: Remus support in xl is still in experimental (proof-of-concept) phase. · line 457
Quoted 3 lines
docs/man/xl.pod.1 +1
-1COLO support in xl is still in experimental (proof-of-concept) phase. - There is no support for network or disk at the moment. + There is no support for network at the moment.You need some document here for the syntax, otherwise users have no clue how to configure disk replicate support. I also won't be able to meaningfully review this patch without a reference.
OK. will fix it in the next version.
Quoted 69 lines
docs/misc/xl-disk-configuration.txt were intentionally created non-sparse to avoid fragmentation of the · line 236
Quoted 12 lines
docs/man/xl.pod.1 +0
-0B<OPTIONS>docs/misc/xl-disk-configuration.txt +0
-0@@ -234,6 +234,56 @@ were intentionally created non-sparse to avoid fragmentation of the file.Some nitpicking about the format below.
Quoted 5 lines
docs/misc/xl-disk-configuration.txt +5
-0+=============== +COLO PARAMETERS +=============== + +docs/misc/xl-disk-configuration.txt were intentionally created non-sparse to avoid fragmentation of the · line 251
Quoted 10 lines
docs/misc/xl-disk-configuration.txt +10
-0+colo +---- + +Enable COLO HA for disk. For better understanding block replication on +QEMU, please refer to: +http://wiki.qemu.org/Features/BlockReplication + + +colo-host +---------Blank line here please.
docs/misc/xl-disk-configuration.txt were intentionally created non-sparse to avoid fragmentation of the · line 257
Quoted 6 lines
docs/misc/xl-disk-configuration.txt +6
-0+Description: Secondary host's address +Mandatory: Yes when COLO enabled + + +colo-port +---------Ditto.
docs/misc/xl-disk-configuration.txt were intentionally created non-sparse to avoid fragmentation of the · line 265
Quoted 8 lines
docs/misc/xl-disk-configuration.txt +8
-0+Description: Secondary port + We will run a nbd server on secondary host, + and the nbd server will listen this port. +Mandatory: Yes when COLO enabled + + +colo-export +---------Here as well. And some more "-"s to match "colo-export".
Quoted 16 lines
docs/misc/xl-disk-configuration.txt +16
-0+Description: We will run a nbd server on secondary host, + exportname is the nbd server's disk export name. +Mandatory: Yes when COLO enabled + + +active-disk +----------- + +Description: This is used by secondary. Secondary guest's write + will be buffered in this disk. +Mandatory: Yes when COLO enabled + + +hidden-disk +----------- +
Quoted 8 lines
docs/misc/xl-disk-configuration.txt were intentionally created non-sparse to avoid fragmentation of the · line 286
Quoted 5 lines
docs/misc/xl-disk-configuration.txt +5
-0+Description: This is used by secondary. It buffers the original + content that is modified by the primary VM. +Mandatory: Yes when COLO enabled + +The rest of the patch is mainly for manipulating QEMU parameters. I've skipped it for now.
If you want to know about how qemu block repication works, you can see:
http://wiki.qemu.org/Features/BlockReplication
Quoted 40 lines
Quoted 40 lines
docs/misc/xl-disk-configuration.txt +0
-0============================================ DEPRECATED PARAMETERS, PREFIXES AND SYNTAXES ============================================tools/libxl/libxl.c +14
-0@@ -2309,6 +2309,8 @@ int libxl__device_disk_setdefault(libxl__gc *gc, libxl_device_disk *disk)int rc;libxl_defbool_setdefault (&disk->discard_enable, !!disk->readwrite); +libxl_defbool_setdefault (&disk->colo_enable, false); +libxl_defbool_setdefault (&disk->colo_restore_enable, false); rc =libxl__resolve_domid (gc, disk->backend_domname, &disk->backend_domid);if (rc <0 )return rc;@@ -2507,6 +2509,18 @@ static void device_disk_add(libxl__egc *egc, uint32_t domid,flexarray_append (back,"params" );flexarray_append (back,GCSPRINTF ("%s:%s" ,libxl__device_disk_string_of_format (disk->format), disk->pdev_path)); +if (libxl_defbool_val (disk->colo_enable)) { +flexarray_append (back,"colo-host" ); +flexarray_append (back,libxl__sprintf (gc,"%s" , disk->colo_host)); +flexarray_append (back,"colo-port" ); +flexarray_append (back,libxl__sprintf (gc,"%s" , disk->colo_port)); +flexarray_append (back,"colo-export" ); +flexarray_append (back,libxl__sprintf (gc,"%s" , disk->colo_export)); +flexarray_append (back,"active-disk" ); +flexarray_append (back,libxl__sprintf (gc,"%s" , disk->active_disk)); +flexarray_append (back,"hidden-disk" ); +flexarray_append (back,libxl__sprintf (gc,"%s" , disk->hidden_disk)); + }assert (device->backend_kind ==LIBXL__DEVICE_KIND_QDISK );break ;default :@@ -2622,7 +2636,10 @@ static int libxl__device_disk_from_xs_be(libxl__gc *gc, goto cleanup; }
Quoted 7 lines
tools/libxl/libxl.c static int libxl__device_disk_from_xs_be(libxl__gc *gc, · line 2641
Quoted 4 lines
tools/libxl/libxl.c +3
-1-/* "params" may not be present; but everything else must be. */ +/* +* "params" and "colo-host" may not be present; but everything +* else must be. I don't think this is correct. You have certainly have colo disabled. I think you can just avoid modifying this comment.
Hmm, add the following comments:
/* colo releated entries(colo-host, colo-port, colo-export,
* active-disk and hidden-disk) are present only if colo is
* disabled.
*/
Thanks
Wen Congyang
Quoted 6 lines
Wei.
.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
PATCH v10 25/31 COLO: use qemu block replication
In reply to Wen CongyangUse qemu block replication as our block replication solution. Note that guest must be paused before starting COLO, otherwise, the disk won't be consistent between primary and secondary.
--- tools/libxl/Makefile | 1 + tools/libxl/libxl_colo_qdisk.c | 226 +++++++++++++++++++++++++++++++++++++++ tools/libxl/libxl_colo_restore.c | 42 +++++++- tools/libxl/libxl_colo_save.c | 54 +++++++++- tools/libxl/libxl_internal.h | 13 +++ 5 files changed, 331 insertions(+), 5 deletions(-) create mode 100644 tools/libxl/libxl_colo_qdisk.c
tools/libxl/Makefile +1 -0
@@ -66,6 +66,7 @@ endif LIBXL_OBJS-y += libxl_remus.o libxl_checkpoint_device.o libxl_remus_disk_drbd.o LIBXL_OBJS-y += libxl_colo_restore.o libxl_colo_save.o +LIBXL_OBJS-y += libxl_colo_qdisk.o LIBXL_OBJS-$(CONFIG_X86) += libxl_cpuid.o libxl_x86.o libxl_psr.o LIBXL_OBJS-$(CONFIG_ARM) += libxl_nocpuid.o libxl_arm.o libxl_libfdt_compat.o
tools/libxl/libxl_colo_qdisk.c new file +226 -0
226 lines not on this page · raw message
tools/libxl/libxl_colo_restore.c +39 -3
104 lines not on this page · raw message
tools/libxl/libxl_colo_save.c +52 -2
105 lines not on this page · raw message
tools/libxl/libxl_internal.h +13 -0
@@ -2902,6 +2902,8 @@ int init_subkind_nic(libxl__checkpoint_devices_state *cds);void cleanup_subkind_nic (libxl__checkpoint_devices_state *cds);int init_subkind_drbd_disk (libxl__checkpoint_devices_state *cds);void cleanup_subkind_drbd_disk (libxl__checkpoint_devices_state *cds); +int init_subkind_qdisk (libxl__checkpoint_devices_state *cds); +void cleanup_subkind_qdisk (libxl__checkpoint_devices_state *cds); typedef void libxl__checkpoint_callback(libxl__egc *, libxl__checkpoint_devices_state *,
@@ -3119,6 +3121,11 @@ struct libxl__colo_save_state {libxl__stream_read_state srs;void (*callback)(libxl__egc *,libxl__colo_save_state *,int );bool svm_running; +bool paused; + +/* private, used by qdisk block replication */ +bool qdisk_used; +bool qdisk_setuped; };/*----- Domain suspend (save) state structure -----*/
@@ -3522,6 +3529,12 @@ struct libxl__colo_restore_state {/* private, colo restore checkpoint state */ libxl__domain_create_cb *saved_cb;void *crcs; + +/* private, used by qdisk block replication */ +bool qdisk_used; +bool qdisk_setuped; +const char *host; +const char *port; };struct libxl__domain_create_state {
Signature · 1 line
2.5.0
Re: [PATCH v10 25/31] COLO: use qemu block replication
Quoted 4 lines · Wen Congyang
Use qemu block replication as our block replication solution. Note that guest must be paused before starting COLO, otherwise, the disk won't be consistent between primary and secondary.
Quoted 8 lines
Signed-off-by Wen Congyang <[email protected]>Signed-off-by Yang Hongyang <[email protected]>--- tools/libxl/Makefile | 1 + tools/libxl/libxl_colo_qdisk.c | 226 +++++++++++++++++++++++++++++++++++++++ tools/libxl/libxl_colo_restore.c | 42 +++++++- tools/libxl/libxl_colo_save.c | 54 +++++++++- tools/libxl/libxl_internal.h | 13 +++
All the changes look internal to COLO and are trying to manipulate QEMU or whatnot. I don't think I can provide very detailed feedback. I am tempted to just ack this patch.
Wei.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
PATCH v10 26/31 COLO proxy: implement setup/teardown of COLO proxy module
In reply to Wen Congyangsetup/teardown of COLO proxy module.
we use netlink to communicate with proxy module.
About colo-proxy module:
https://lkml.org/lkml/2015/6/18/32
How to use:
http://wiki.xen.org/wiki/COLO_-_Coarse_Grain_Lock_Stepping
--- tools/libxl/Makefile | 1 + tools/libxl/libxl_colo.h | 2 + tools/libxl/libxl_colo_proxy.c | 230 +++++++++++++++++++++++++++++++++++++++++ tools/libxl/libxl_internal.h | 15 +++ 4 files changed, 248 insertions(+) create mode 100644 tools/libxl/libxl_colo_proxy.c
tools/libxl/Makefile +1 -0
@@ -67,6 +67,7 @@ endif LIBXL_OBJS-y += libxl_remus.o libxl_checkpoint_device.o libxl_remus_disk_drbd.o LIBXL_OBJS-y += libxl_colo_restore.o libxl_colo_save.o LIBXL_OBJS-y += libxl_colo_qdisk.o +LIBXL_OBJS-y += libxl_colo_proxy.o LIBXL_OBJS-$(CONFIG_X86) += libxl_cpuid.o libxl_x86.o libxl_psr.o LIBXL_OBJS-$(CONFIG_ARM) += libxl_nocpuid.o libxl_arm.o libxl_libfdt_compat.o
tools/libxl/libxl_colo.h +2 -0
@@ -27,4 +27,6 @@ extern void libxl__colo_save_teardown(libxl__egc *egc,libxl__colo_save_state *css, int rc); +extern int colo_proxy_setup (libxl__colo_proxy_state *cps); +extern void colo_proxy_teardown (libxl__colo_proxy_state *cps);#endif
tools/libxl/libxl_colo_proxy.c new file +230 -0
230 lines not on this page · raw message
tools/libxl/libxl_internal.h +15 -0
@@ -3112,6 +3112,15 @@ libxl__stream_read_inuse(const libxl__stream_read_state *stream) }/*----- colo related state structure -----*/ +typedef struct libxl__colo_proxy_state libxl__colo_proxy_state ; +struct libxl__colo_proxy_state { +/* set by caller of colo_proxy_setup */ +libxl__ao *ao; + +int sock_fd; +int index; +}; +typedef struct libxl__colo_save_state libxl__colo_save_state ;struct libxl__colo_save_state {int send_fd;
@@ -3126,6 +3135,9 @@ struct libxl__colo_save_state {/* private, used by qdisk block replication */ bool qdisk_used;bool qdisk_setuped; + +/* private, used by colo-proxy */ +libxl__colo_proxy_state cps; };/*----- Domain suspend (save) state structure -----*/
@@ -3535,6 +3547,9 @@ struct libxl__colo_restore_state {bool qdisk_setuped;const char *host;const char *port; + +/* private, used by colo-proxy */ +libxl__colo_proxy_state cps; };struct libxl__domain_create_state {
Signature · 1 line
2.5.0
Re: [PATCH v10 26/31] COLO proxy: implement setup/teardown of COLO proxy module
Quoted 9 lines · Wen Congyang
setup/teardown of COLO proxy module.
we use netlink to communicate with proxy module.
About colo-proxy module:
https://lkml.org/lkml/2015/6/18/32
How to use:
http://wiki.xen.org/wiki/COLO_-_Coarse_Grain_Lock_SteppingSigned-off-by Yang Hongyang <[email protected]>Signed-off-by Wen Congyang <[email protected]>
I'm tempted to just ack this patch as well.
Wei.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH v10 26/31] COLO proxy: implement setup/teardown of COLO proxy module
In reply to Wen Congyangtools/libxl/libxl_colo_proxy.c line 2
Quoted 11 lines
tools/libxl/libxl_colo.h +2
-0+extern int colo_proxy_setup (libxl__colo_proxy_state *cps); +extern void colo_proxy_teardown (libxl__colo_proxy_state *cps);#endif tools/libxl/libxl_colo_proxy.c new file +2
-0@@ -0,0 +1,230 @@ +/* +* Copyright (C) 2015 FUJITSU LIMITED
2016?
Quoted 10 lines
tools/libxl/libxl_colo_proxy.c new file +10
-0+* Author: Yang Hongyang <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License as published +* by the Free Software Foundation; version 2.1 only. with the special +* exception on linking described in file LICENSE. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
tools/libxl/libxl_colo_proxy.c line 22
Quoted 10 lines
tools/libxl/libxl_colo_proxy.c new file +10
-0+* GNU Lesser General Public License for more details. +*/ + +#include "libxl_osdeps.h" /* must come before any other headers */ + +#include "libxl_internal.h" +#include "libxl_colo.h" +#include <linux/netlink.h> + +#define NETLINK_COLO 28
Can you include a comment why 28? Why not 31415?
Quoted 22 lines
tools/libxl/libxl_colo_proxy.c new file +22
-0+ +enum colo_netlink_op { +COLO_QUERY_CHECKPOINT = (NLMSG_MIN_TYPE +1 ), +COLO_CHECKPOINT , +COLO_FAILOVER , +COLO_PROXY_INIT , +COLO_PROXY_RESET ,/* UNUSED, will be used for continuous FT */ +}; + +/* ========= colo-proxy: helper functions ========== */ + +static int colo_proxy_send (libxl__colo_proxy_state *cps,uint8_t *buff, +uint64_t size,int type) +{ +struct sockaddr_nl sa; +struct nlmsghdr msg; +struct iovec iov; +struct msghdr mh; +int ret; + +STATE_AO_GC (cps->ao); +
tools/libxl/libxl_colo_proxy.c line 54
Quoted 10 lines
tools/libxl/libxl_colo_proxy.c new file +10
-0+memset (&sa,0 ,sizeof (sa)); + sa.nl_family =AF_NETLINK ; + sa.nl_pid =0 ; + sa.nl_groups =0 ; + + msg.nlmsg_len =NLMSG_SPACE (0 ); + msg.nlmsg_flags =NLM_F_REQUEST ; +if (type ==COLO_PROXY_INIT ) { + msg.nlmsg_flags |=NLM_F_ACK ; + }
I don't think you need the { }?
Ah, yup:
5. Block structure
Every indented statement is braced apart from blocks that contain just one statement.
tools/libxl/libxl_colo_proxy.c line 56
Quoted 2 lines
tools/libxl/libxl_colo_proxy.c new file +2
-0+ msg.nlmsg_seq =0 ; +/* This is untrusty */
Umm, can you be more specific pls?
Quoted 45 lines
tools/libxl/libxl_colo_proxy.c new file +45
-0+ msg.nlmsg_pid = cps->index; + msg.nlmsg_type = type; + + iov.iov_base = &msg; + iov.iov_len = msg.nlmsg_len; + + mh.msg_name = &sa; + mh.msg_namelen =sizeof (sa); + mh.msg_iov = &iov; + mh.msg_iovlen =1 ; + mh.msg_control =NULL ; + mh.msg_controllen =0 ; + mh.msg_flags =0 ; + + ret =sendmsg (cps->sock_fd, &mh,0 ); +if (ret <=0 ) { +LOG (ERROR ,"can't send msg to kernel by netlink: %s" , +strerror (errno)); + } + +return ret; +} + +/* error: return -1, otherwise return 0 */ +static int64_t colo_proxy_recv (libxl__colo_proxy_state *cps,uint8_t **buff, +unsigned int timeout_us) +{ +struct sockaddr_nl sa; +struct iovec iov; +struct msghdr mh = { + .msg_name = &sa, + .msg_namelen =sizeof (sa), + .msg_iov = &iov, + .msg_iovlen =1 , + }; +struct timeval tv; +uint32_t size =16384 ; +int64_t len =0 ; +int ret; + +STATE_AO_GC (cps->ao); +uint8_t *tmp =libxl__malloc (NOGC , size); + +if (timeout_us) { + tv.tv_sec = timeout_us /1000000 ;
tools/libxl/libxl_colo_proxy.c line 111
Quoted 10 lines
tools/libxl/libxl_colo_proxy.c new file +10
-0+ tv.tv_usec = timeout_us %1000000 ; +setsockopt (cps->sock_fd,SOL_SOCKET ,SO_RCVTIMEO , &tv,sizeof (tv)); + } + + iov.iov_base = tmp; + iov.iov_len = size; +next: + ret =recvmsg (cps->sock_fd, &mh,0 ); +if (ret <=0 ) { +if (errno !=EAGAIN && errno !=EWOULDBLOCK )
-EINTR ?
tools/libxl/libxl_colo_proxy.c line 119
Quoted 8 lines
tools/libxl/libxl_colo_proxy.c new file +8
-0+LOGE (ERROR ,"can't recv msg from kernel by netlink" ); + goto err; + } + + len += ret; +if (mh.msg_flags &MSG_TRUNC ) { + size +=16384 ; + tmp =libxl__realloc (NOGC , tmp, size);
You really should check 'tmp'.
If this loop continues on for some time the 'size' may be in milions and this realloc will fail.
Quoted 58 lines
tools/libxl/libxl_colo_proxy.c new file +57
-0+ iov.iov_base = tmp + len; + iov.iov_len = size - len; + goto next; + } + + *buff = tmp; + ret = len; + goto out; + +err: +free (tmp); + *buff =NULL ; + +out: +if (timeout_us) { + tv.tv_sec =0 ; + tv.tv_usec =0 ; +setsockopt (cps->sock_fd,SOL_SOCKET ,SO_RCVTIMEO , &tv,sizeof (tv)); + } +return ret; +} + +/* ========= colo-proxy: setup and teardown ========== */ + +int colo_proxy_setup (libxl__colo_proxy_state *cps) +{ +int skfd =0 ; +struct sockaddr_nl sa; +struct nlmsghdr *h; +int i =1 ; +int ret =ERROR_FAIL ; +uint8_t *buff =NULL ; +int64_t size; + +STATE_AO_GC (cps->ao); + + skfd =socket (PF_NETLINK ,SOCK_RAW ,NETLINK_COLO ); +if (skfd <0 ) { +LOG (ERROR ,"can not create a netlink socket: %s" ,strerror (errno)); + goto out; + } + cps->sock_fd = skfd; +memset (&sa,0 ,sizeof (sa)); + sa.nl_family =AF_NETLINK ; + sa.nl_groups =0 ; +retry: + sa.nl_pid = i++; + +if (i >10 ) { +LOG (ERROR ,"netlink bind error" ); + goto out; + } + + ret =bind (skfd, (struct sockaddr *)&sa,sizeof (sa)); +if (ret <0 && errno ==EADDRINUSE ) { +LOG (ERROR ,"colo index %d has already in used" , sa.nl_pid); + goto retry;
tools/libxl/libxl_colo_proxy.c line 186
Quoted 10 lines
tools/libxl/libxl_colo_proxy.c new file +10
-0+ }else if (ret <0 ) { +LOG (ERROR ,"netlink bind error" ); + goto out; + } + + cps->index = sa.nl_pid; + ret =colo_proxy_send (cps,NULL ,0 ,COLO_PROXY_INIT ); +if (ret <0 ) { + goto out; + }
Ditto. You can remove it.
Quoted 89 lines
tools/libxl/libxl_colo_proxy.c new file +44
-0+/* receive ack */ + size =colo_proxy_recv (cps, &buff,500000 ); +if (size <0 ) { +LOG (ERROR ,"Can't recv msg from kernel by netlink: %s" , +strerror (errno)); + goto out; + } + +if (size) { + h = (struct nlmsghdr *)buff; +if (h->nlmsg_type ==NLMSG_ERROR ) { +/* ack's type is NLMSG_ERROR */ +struct nlmsgerr *err = (struct nlmsgerr *)NLMSG_DATA (h); + +if (size -sizeof (*h) <sizeof (*err)) { +LOG (ERROR ,"NLMSG_LENGTH is too short" ); + goto out; + } + +if (err->error) { +LOG (ERROR ,"NLMSG_ERROR contains error %d" , err->error); + goto out; + } + } + } + + ret =0 ; + +out: +free (buff); +if (ret) { +close (cps->sock_fd); + cps->sock_fd =-1 ; + } +return ret; +} + +void colo_proxy_teardown (libxl__colo_proxy_state *cps) +{ +if (cps->sock_fd >=0 ) { +close (cps->sock_fd); + cps->sock_fd =-1 ; + } +}tools/libxl/libxl_internal.h +15
-0@@ -3112,6 +3112,15 @@ libxl__stream_read_inuse(const libxl__stream_read_state *stream) }/*----- colo related state structure -----*/ +typedef struct libxl__colo_proxy_state libxl__colo_proxy_state ; +struct libxl__colo_proxy_state { +/* set by caller of colo_proxy_setup */ +libxl__ao *ao; + +int sock_fd; +int index; +}; +typedef struct libxl__colo_save_state libxl__colo_save_state ;struct libxl__colo_save_state {int send_fd;@@ -3126,6 +3135,9 @@ struct libxl__colo_save_state {/* private, used by qdisk block replication */ bool qdisk_used;bool qdisk_setuped; + +/* private, used by colo-proxy */ +libxl__colo_proxy_state cps; };/*----- Domain suspend (save) state structure -----*/ @@ -3535,6 +3547,9 @@ struct libxl__colo_restore_state {bool qdisk_setuped;const char *host;const char *port; + +/* private, used by colo-proxy */ +libxl__colo_proxy_state cps; };struct libxl__domain_create_state {Signature · 1 line
2.5.0
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH v10 26/31] COLO proxy: implement setup/teardown of COLO proxy module
Quoted 5 lines · Konrad Rzeszutek Wilk
Quoted 5 lines
tools/libxl/libxl_colo.h +2
-0+extern int colo_proxy_setup (libxl__colo_proxy_state *cps); +extern void colo_proxy_teardown (libxl__colo_proxy_state *cps);#endif tools/libxl/libxl_colo_proxy.c new file +0
-0
Quoted 8 lines
tools/libxl/libxl_colo_proxy.c line 2
Quoted 6 lines
index 0000000..e07e640
tools/libxl/libxl_colo_proxy.c new file +2
-0@@ -0,0 +1,230 @@ +/* +* Copyright (C) 2015 FUJITSU LIMITED 2016?
Yes, I will check all new files.
Quoted 14 lines
Quoted 14 lines
tools/libxl/libxl_colo_proxy.c new file +14
-0+* Author: Yang Hongyang <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License as published +* by the Free Software Foundation; version 2.1 only. with the special +* exception on linking described in file LICENSE. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License for more details. +*/ + +#include "libxl_osdeps.h" /* must come before any other headers */
Quoted 8 lines
tools/libxl/libxl_colo_proxy.c line 22
Quoted 6 lines
tools/libxl/libxl_colo_proxy.c new file +6
-0+ +#include "libxl_internal.h" +#include "libxl_colo.h" +#include <linux/netlink.h> + +#define NETLINK_COLO 28Can you include a comment why 28? Why not 31415?
OK, will add a comment to describe it.
Quoted 27 lines
Quoted 27 lines
tools/libxl/libxl_colo_proxy.c new file +26
-0+ +enum colo_netlink_op { +COLO_QUERY_CHECKPOINT = (NLMSG_MIN_TYPE +1 ), +COLO_CHECKPOINT , +COLO_FAILOVER , +COLO_PROXY_INIT , +COLO_PROXY_RESET ,/* UNUSED, will be used for continuous FT */ +}; + +/* ========= colo-proxy: helper functions ========== */ + +static int colo_proxy_send (libxl__colo_proxy_state *cps,uint8_t *buff, +uint64_t size,int type) +{ +struct sockaddr_nl sa; +struct nlmsghdr msg; +struct iovec iov; +struct msghdr mh; +int ret; + +STATE_AO_GC (cps->ao); + +memset (&sa,0 ,sizeof (sa)); + sa.nl_family =AF_NETLINK ; + sa.nl_pid =0 ; + sa.nl_groups =0 ;
Quoted 8 lines
tools/libxl/libxl_colo_proxy.c line 54
Quoted 6 lines
tools/libxl/libxl_colo_proxy.c new file +6
-0+ + msg.nlmsg_len =NLMSG_SPACE (0 ); + msg.nlmsg_flags =NLM_F_REQUEST ; +if (type ==COLO_PROXY_INIT ) { + msg.nlmsg_flags |=NLM_F_ACK ; + }I don't think you need the { }?
Yes, will fix it in the next version.
Quoted 62 lines
Ah, yup:
5. Block structure
Every indented statement is braced apart from blocks that contain just one statement.
tools/libxl/libxl_colo_proxy.c line 56
Quoted 2 lines
tools/libxl/libxl_colo_proxy.c new file +2
-0+ msg.nlmsg_seq =0 ; +/* This is untrusty */ Umm, can you be more specific pls?
Quoted 49 lines
tools/libxl/libxl_colo_proxy.c new file +49
-0+ msg.nlmsg_pid = cps->index; + msg.nlmsg_type = type; + + iov.iov_base = &msg; + iov.iov_len = msg.nlmsg_len; + + mh.msg_name = &sa; + mh.msg_namelen =sizeof (sa); + mh.msg_iov = &iov; + mh.msg_iovlen =1 ; + mh.msg_control =NULL ; + mh.msg_controllen =0 ; + mh.msg_flags =0 ; + + ret =sendmsg (cps->sock_fd, &mh,0 ); +if (ret <=0 ) { +LOG (ERROR ,"can't send msg to kernel by netlink: %s" , +strerror (errno)); + } + +return ret; +} + +/* error: return -1, otherwise return 0 */ +static int64_t colo_proxy_recv (libxl__colo_proxy_state *cps,uint8_t **buff, +unsigned int timeout_us) +{ +struct sockaddr_nl sa; +struct iovec iov; +struct msghdr mh = { + .msg_name = &sa, + .msg_namelen =sizeof (sa), + .msg_iov = &iov, + .msg_iovlen =1 , + }; +struct timeval tv; +uint32_t size =16384 ; +int64_t len =0 ; +int ret; + +STATE_AO_GC (cps->ao); +uint8_t *tmp =libxl__malloc (NOGC , size); + +if (timeout_us) { + tv.tv_sec = timeout_us /1000000 ; + tv.tv_usec = timeout_us %1000000 ; +setsockopt (cps->sock_fd,SOL_SOCKET ,SO_RCVTIMEO , &tv,sizeof (tv)); + } +
Quoted 8 lines
tools/libxl/libxl_colo_proxy.c line 111
Quoted 6 lines
tools/libxl/libxl_colo_proxy.c new file +6
-0+ iov.iov_base = tmp; + iov.iov_len = size; +next: + ret =recvmsg (cps->sock_fd, &mh,0 ); +if (ret <=0 ) { +if (errno !=EAGAIN && errno !=EWOULDBLOCK )
-EINTR?
IIRC, WAGAIN and EWOULDBLOCK may have different value in some system. EINTR is not handled here.
Quoted 10 lines
tools/libxl/libxl_colo_proxy.c line 119
Quoted 9 lines
tools/libxl/libxl_colo_proxy.c new file +8
-0+LOGE (ERROR ,"can't recv msg from kernel by netlink" ); + goto err; + } + + len += ret; +if (mh.msg_flags &MSG_TRUNC ) { + size +=16384 ; + tmp =libxl__realloc (NOGC , tmp, size);
Quoted 4 lines
You really should check 'tmp'.
If this loop continues on for some time the 'size' may be in milions and this realloc will fail.
OK, will fix it in the next version.
Quoted 63 lines
Quoted 63 lines
tools/libxl/libxl_colo_proxy.c new file +61
-0+ iov.iov_base = tmp + len; + iov.iov_len = size - len; + goto next; + } + + *buff = tmp; + ret = len; + goto out; + +err: +free (tmp); + *buff =NULL ; + +out: +if (timeout_us) { + tv.tv_sec =0 ; + tv.tv_usec =0 ; +setsockopt (cps->sock_fd,SOL_SOCKET ,SO_RCVTIMEO , &tv,sizeof (tv)); + } +return ret; +} + +/* ========= colo-proxy: setup and teardown ========== */ + +int colo_proxy_setup (libxl__colo_proxy_state *cps) +{ +int skfd =0 ; +struct sockaddr_nl sa; +struct nlmsghdr *h; +int i =1 ; +int ret =ERROR_FAIL ; +uint8_t *buff =NULL ; +int64_t size; + +STATE_AO_GC (cps->ao); + + skfd =socket (PF_NETLINK ,SOCK_RAW ,NETLINK_COLO ); +if (skfd <0 ) { +LOG (ERROR ,"can not create a netlink socket: %s" ,strerror (errno)); + goto out; + } + cps->sock_fd = skfd; +memset (&sa,0 ,sizeof (sa)); + sa.nl_family =AF_NETLINK ; + sa.nl_groups =0 ; +retry: + sa.nl_pid = i++; + +if (i >10 ) { +LOG (ERROR ,"netlink bind error" ); + goto out; + } + + ret =bind (skfd, (struct sockaddr *)&sa,sizeof (sa)); +if (ret <0 && errno ==EADDRINUSE ) { +LOG (ERROR ,"colo index %d has already in used" , sa.nl_pid); + goto retry; + }else if (ret <0 ) { +LOG (ERROR ,"netlink bind error" ); + goto out; + }
Quoted 8 lines
tools/libxl/libxl_colo_proxy.c line 186
Quoted 6 lines
tools/libxl/libxl_colo_proxy.c new file +6
-0+ + cps->index = sa.nl_pid; + ret =colo_proxy_send (cps,NULL ,0 ,COLO_PROXY_INIT ); +if (ret <0 ) { + goto out; + }Ditto. You can remove it.
OK, will check all codes.
Thanks
Wen Congyang
Quoted 84 lines
Quoted 84 lines
tools/libxl/libxl_colo_proxy.c new file +44
-0+/* receive ack */ + size =colo_proxy_recv (cps, &buff,500000 ); +if (size <0 ) { +LOG (ERROR ,"Can't recv msg from kernel by netlink: %s" , +strerror (errno)); + goto out; + } + +if (size) { + h = (struct nlmsghdr *)buff; +if (h->nlmsg_type ==NLMSG_ERROR ) { +/* ack's type is NLMSG_ERROR */ +struct nlmsgerr *err = (struct nlmsgerr *)NLMSG_DATA (h); + +if (size -sizeof (*h) <sizeof (*err)) { +LOG (ERROR ,"NLMSG_LENGTH is too short" ); + goto out; + } + +if (err->error) { +LOG (ERROR ,"NLMSG_ERROR contains error %d" , err->error); + goto out; + } + } + } + + ret =0 ; + +out: +free (buff); +if (ret) { +close (cps->sock_fd); + cps->sock_fd =-1 ; + } +return ret; +} + +void colo_proxy_teardown (libxl__colo_proxy_state *cps) +{ +if (cps->sock_fd >=0 ) { +close (cps->sock_fd); + cps->sock_fd =-1 ; + } +}tools/libxl/libxl_internal.h +15
-0@@ -3112,6 +3112,15 @@ libxl__stream_read_inuse(const libxl__stream_read_state *stream) }/*----- colo related state structure -----*/ +typedef struct libxl__colo_proxy_state libxl__colo_proxy_state ; +struct libxl__colo_proxy_state { +/* set by caller of colo_proxy_setup */ +libxl__ao *ao; + +int sock_fd; +int index; +}; +typedef struct libxl__colo_save_state libxl__colo_save_state ;struct libxl__colo_save_state {int send_fd;@@ -3126,6 +3135,9 @@ struct libxl__colo_save_state {/* private, used by qdisk block replication */ bool qdisk_used;bool qdisk_setuped; + +/* private, used by colo-proxy */ +libxl__colo_proxy_state cps; };/*----- Domain suspend (save) state structure -----*/ @@ -3535,6 +3547,9 @@ struct libxl__colo_restore_state {bool qdisk_setuped;const char *host;const char *port; + +/* private, used by colo-proxy */ +libxl__colo_proxy_state cps; };
Quoted 10 lines
Quoted 6 lines
tools/libxl/libxl_internal.h +0
-0struct libxl__domain_create_state {Signature · 1 line
2.5.0.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH v10 26/31] COLO proxy: implement setup/teardown of COLO proxy module
Quoted 151 lines · Wen Congyang
Quoted 5 lines · Konrad Rzeszutek Wilk
Quoted 5 lines
tools/libxl/libxl_colo.h +2
-0+extern int colo_proxy_setup (libxl__colo_proxy_state *cps); +extern void colo_proxy_teardown (libxl__colo_proxy_state *cps);#endif tools/libxl/libxl_colo_proxy.c new file +0
-0Quoted 8 lines
tools/libxl/libxl_colo_proxy.c line 2
Quoted 6 lines
index 0000000..e07e640
tools/libxl/libxl_colo_proxy.c new file +2
-0@@ -0,0 +1,230 @@ +/* +* Copyright (C) 2015 FUJITSU LIMITED 2016?
Yes, I will check all new files.
Quoted 14 lines
Quoted 14 lines
tools/libxl/libxl_colo_proxy.c new file +14
-0+* Author: Yang Hongyang <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License as published +* by the Free Software Foundation; version 2.1 only. with the special +* exception on linking described in file LICENSE. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License for more details. +*/ + +#include "libxl_osdeps.h" /* must come before any other headers */ Quoted 8 lines
tools/libxl/libxl_colo_proxy.c line 22
Quoted 6 lines
tools/libxl/libxl_colo_proxy.c new file +6
-0+ +#include "libxl_internal.h" +#include "libxl_colo.h" +#include <linux/netlink.h> + +#define NETLINK_COLO 28Can you include a comment why 28? Why not 31415?
OK, will add a comment to describe it.
Quoted 27 lines
Quoted 27 lines
tools/libxl/libxl_colo_proxy.c new file +26
-0+ +enum colo_netlink_op { +COLO_QUERY_CHECKPOINT = (NLMSG_MIN_TYPE +1 ), +COLO_CHECKPOINT , +COLO_FAILOVER , +COLO_PROXY_INIT , +COLO_PROXY_RESET ,/* UNUSED, will be used for continuous FT */ +}; + +/* ========= colo-proxy: helper functions ========== */ + +static int colo_proxy_send (libxl__colo_proxy_state *cps,uint8_t *buff, +uint64_t size,int type) +{ +struct sockaddr_nl sa; +struct nlmsghdr msg; +struct iovec iov; +struct msghdr mh; +int ret; + +STATE_AO_GC (cps->ao); + +memset (&sa,0 ,sizeof (sa)); + sa.nl_family =AF_NETLINK ; + sa.nl_pid =0 ; + sa.nl_groups =0 ;Quoted 8 lines
tools/libxl/libxl_colo_proxy.c line 54
Quoted 6 lines
tools/libxl/libxl_colo_proxy.c new file +6
-0+ + msg.nlmsg_len =NLMSG_SPACE (0 ); + msg.nlmsg_flags =NLM_F_REQUEST ; +if (type ==COLO_PROXY_INIT ) { + msg.nlmsg_flags |=NLM_F_ACK ; + }I don't think you need the { }?
Yes, will fix it in the next version.
Quoted 62 lines
Ah, yup:
5. Block structure
Every indented statement is braced apart from blocks that contain just one statement.
tools/libxl/libxl_colo_proxy.c line 56
Quoted 2 lines
tools/libxl/libxl_colo_proxy.c new file +2
-0+ msg.nlmsg_seq =0 ; +/* This is untrusty */ Umm, can you be more specific pls?
Quoted 49 lines
tools/libxl/libxl_colo_proxy.c new file +49
-0+ msg.nlmsg_pid = cps->index; + msg.nlmsg_type = type; + + iov.iov_base = &msg; + iov.iov_len = msg.nlmsg_len; + + mh.msg_name = &sa; + mh.msg_namelen =sizeof (sa); + mh.msg_iov = &iov; + mh.msg_iovlen =1 ; + mh.msg_control =NULL ; + mh.msg_controllen =0 ; + mh.msg_flags =0 ; + + ret =sendmsg (cps->sock_fd, &mh,0 ); +if (ret <=0 ) { +LOG (ERROR ,"can't send msg to kernel by netlink: %s" , +strerror (errno)); + } + +return ret; +} + +/* error: return -1, otherwise return 0 */ +static int64_t colo_proxy_recv (libxl__colo_proxy_state *cps,uint8_t **buff, +unsigned int timeout_us) +{ +struct sockaddr_nl sa; +struct iovec iov; +struct msghdr mh = { + .msg_name = &sa, + .msg_namelen =sizeof (sa), + .msg_iov = &iov, + .msg_iovlen =1 , + }; +struct timeval tv; +uint32_t size =16384 ; +int64_t len =0 ; +int ret; + +STATE_AO_GC (cps->ao); +uint8_t *tmp =libxl__malloc (NOGC , size); + +if (timeout_us) { + tv.tv_sec = timeout_us /1000000 ; + tv.tv_usec = timeout_us %1000000 ; +setsockopt (cps->sock_fd,SOL_SOCKET ,SO_RCVTIMEO , &tv,sizeof (tv)); + } +Quoted 8 lines
tools/libxl/libxl_colo_proxy.c line 111
Quoted 6 lines
tools/libxl/libxl_colo_proxy.c new file +6
-0+ iov.iov_base = tmp; + iov.iov_len = size; +next: + ret =recvmsg (cps->sock_fd, &mh,0 ); +if (ret <=0 ) { +if (errno !=EAGAIN && errno !=EWOULDBLOCK )
-EINTR?
Quoted 17 lines
IIRC, WAGAIN and EWOULDBLOCK may have different value in some system. EINTR is not handled here.
Quoted 14 lines
tools/libxl/libxl_colo_proxy.c line 119
Quoted 9 lines
tools/libxl/libxl_colo_proxy.c new file +8
-0+LOGE (ERROR ,"can't recv msg from kernel by netlink" ); + goto err; + } + + len += ret; +if (mh.msg_flags &MSG_TRUNC ) { + size +=16384 ; + tmp =libxl__realloc (NOGC , tmp, size);You really should check 'tmp'.
If this loop continues on for some time the 'size' may be in milions and this realloc will fail.
As i see from the code, libxl_realloc will invoke _exit(-1) if malloc failed, so we'll keep it.
Thanks
-Xie
Quoted 175 lines
OK, will fix it in the next version.
Quoted 63 lines
Quoted 63 lines
tools/libxl/libxl_colo_proxy.c new file +61
-0+ iov.iov_base = tmp + len; + iov.iov_len = size - len; + goto next; + } + + *buff = tmp; + ret = len; + goto out; + +err: +free (tmp); + *buff =NULL ; + +out: +if (timeout_us) { + tv.tv_sec =0 ; + tv.tv_usec =0 ; +setsockopt (cps->sock_fd,SOL_SOCKET ,SO_RCVTIMEO , &tv,sizeof (tv)); + } +return ret; +} + +/* ========= colo-proxy: setup and teardown ========== */ + +int colo_proxy_setup (libxl__colo_proxy_state *cps) +{ +int skfd =0 ; +struct sockaddr_nl sa; +struct nlmsghdr *h; +int i =1 ; +int ret =ERROR_FAIL ; +uint8_t *buff =NULL ; +int64_t size; + +STATE_AO_GC (cps->ao); + + skfd =socket (PF_NETLINK ,SOCK_RAW ,NETLINK_COLO ); +if (skfd <0 ) { +LOG (ERROR ,"can not create a netlink socket: %s" ,strerror (errno)); + goto out; + } + cps->sock_fd = skfd; +memset (&sa,0 ,sizeof (sa)); + sa.nl_family =AF_NETLINK ; + sa.nl_groups =0 ; +retry: + sa.nl_pid = i++; + +if (i >10 ) { +LOG (ERROR ,"netlink bind error" ); + goto out; + } + + ret =bind (skfd, (struct sockaddr *)&sa,sizeof (sa)); +if (ret <0 && errno ==EADDRINUSE ) { +LOG (ERROR ,"colo index %d has already in used" , sa.nl_pid); + goto retry; + }else if (ret <0 ) { +LOG (ERROR ,"netlink bind error" ); + goto out; + }Quoted 8 lines
tools/libxl/libxl_colo_proxy.c line 186
Quoted 6 lines
tools/libxl/libxl_colo_proxy.c new file +6
-0+ + cps->index = sa.nl_pid; + ret =colo_proxy_send (cps,NULL ,0 ,COLO_PROXY_INIT ); +if (ret <0 ) { + goto out; + }Ditto. You can remove it.
OK, will check all codes.
Thanks
Wen CongyangQuoted 84 lines
Quoted 84 lines
tools/libxl/libxl_colo_proxy.c new file +44
-0+/* receive ack */ + size =colo_proxy_recv (cps, &buff,500000 ); +if (size <0 ) { +LOG (ERROR ,"Can't recv msg from kernel by netlink: %s" , +strerror (errno)); + goto out; + } + +if (size) { + h = (struct nlmsghdr *)buff; +if (h->nlmsg_type ==NLMSG_ERROR ) { +/* ack's type is NLMSG_ERROR */ +struct nlmsgerr *err = (struct nlmsgerr *)NLMSG_DATA (h); + +if (size -sizeof (*h) <sizeof (*err)) { +LOG (ERROR ,"NLMSG_LENGTH is too short" ); + goto out; + } + +if (err->error) { +LOG (ERROR ,"NLMSG_ERROR contains error %d" , err->error); + goto out; + } + } + } + + ret =0 ; + +out: +free (buff); +if (ret) { +close (cps->sock_fd); + cps->sock_fd =-1 ; + } +return ret; +} + +void colo_proxy_teardown (libxl__colo_proxy_state *cps) +{ +if (cps->sock_fd >=0 ) { +close (cps->sock_fd); + cps->sock_fd =-1 ; + } +}tools/libxl/libxl_internal.h +15
-0@@ -3112,6 +3112,15 @@ libxl__stream_read_inuse(const libxl__stream_read_state *stream) }/*----- colo related state structure -----*/ +typedef struct libxl__colo_proxy_state libxl__colo_proxy_state ; +struct libxl__colo_proxy_state { +/* set by caller of colo_proxy_setup */ +libxl__ao *ao; + +int sock_fd; +int index; +}; +typedef struct libxl__colo_save_state libxl__colo_save_state ;struct libxl__colo_save_state {int send_fd;@@ -3126,6 +3135,9 @@ struct libxl__colo_save_state {/* private, used by qdisk block replication */ bool qdisk_used;bool qdisk_setuped; + +/* private, used by colo-proxy */ +libxl__colo_proxy_state cps; };/*----- Domain suspend (save) state structure -----*/ @@ -3535,6 +3547,9 @@ struct libxl__colo_restore_state {bool qdisk_setuped;const char *host;const char *port; + +/* private, used by colo-proxy */ +libxl__colo_proxy_state cps; };Quoted 10 lines
Quoted 6 lines
tools/libxl/libxl_internal.h +0
-1struct libxl__domain_create_state { --2.5.0
.
Quoted 2 lines
.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
PATCH v10 27/31 COLO proxy: preresume, postresume and checkpoint
In reply to Wen Congyangpreresume, postresume and checkpoint
--- tools/libxl/libxl_colo.h | 4 +++ tools/libxl/libxl_colo_proxy.c | 62 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+)
tools/libxl/libxl_colo.h +4 -0
@@ -29,4 +29,8 @@ extern void libxl__colo_save_teardown(libxl__egc *egc,extern int colo_proxy_setup (libxl__colo_proxy_state *cps);extern void colo_proxy_teardown (libxl__colo_proxy_state *cps); +extern void colo_proxy_preresume (libxl__colo_proxy_state *cps); +extern void colo_proxy_postresume (libxl__colo_proxy_state *cps); +extern int colo_proxy_checkpoint (libxl__colo_proxy_state *cps, +unsigned int timeout_us);#endif
tools/libxl/libxl_colo_proxy.c +62 -0
65 lines not on this page · raw message
Signature · 1 line
2.5.0
Re: [PATCH v10 27/31] COLO proxy: preresume, postresume and checkpoint
Quoted 4 lines · Wen Congyang
preresume, postresume and checkpoint
Signed-off-by Yang Hongyang <[email protected]>Signed-off-by Wen Congyang <[email protected]>
Same as last patch...
Wei.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
PATCH v10 28/31 COLO nic: implement COLO nic subkind
In reply to Wen Congyangimplement COLO nic subkind.
--- tools/hotplug/Linux/Makefile | 1 + tools/hotplug/Linux/colo-proxy-setup | 135 +++++++++++++++ tools/libxl/Makefile | 1 + tools/libxl/libxl_colo_nic.c | 321 +++++++++++++++++++++++++++++++++++ tools/libxl/libxl_internal.h | 5 + tools/libxl/libxl_types.idl | 1 + 6 files changed, 464 insertions(+) create mode 100755 tools/hotplug/Linux/colo-proxy-setup create mode 100644 tools/libxl/libxl_colo_nic.c
tools/hotplug/Linux/Makefile +1 -0
@@ -28,6 +28,7 @@ XEN_SCRIPTS += block-iscsi XEN_SCRIPTS += block-tap XEN_SCRIPTS += block-drbd-probe XEN_SCRIPTS += $(XEN_SCRIPTS-y) +XEN_SCRIPTS += colo-proxy-setup SUBDIRS-$(CONFIG_SYSTEMD) += systemd
tools/hotplug/Linux/colo-proxy-setup new file +135 -0
135 lines not on this page · raw message
tools/libxl/Makefile +1 -0
@@ -68,6 +68,7 @@ LIBXL_OBJS-y += libxl_remus.o libxl_checkpoint_device.o libxl_remus_disk_drbd.o LIBXL_OBJS-y += libxl_colo_restore.o libxl_colo_save.o LIBXL_OBJS-y += libxl_colo_qdisk.o LIBXL_OBJS-y += libxl_colo_proxy.o +LIBXL_OBJS-y += libxl_colo_nic.o LIBXL_OBJS-$(CONFIG_X86) += libxl_cpuid.o libxl_x86.o libxl_psr.o LIBXL_OBJS-$(CONFIG_ARM) += libxl_nocpuid.o libxl_arm.o libxl_libfdt_compat.o
tools/libxl/libxl_colo_nic.c new file +321 -0
321 lines not on this page · raw message
tools/libxl/libxl_internal.h +5 -0
@@ -2904,6 +2904,8 @@ int init_subkind_drbd_disk(libxl__checkpoint_devices_state *cds);void cleanup_subkind_drbd_disk (libxl__checkpoint_devices_state *cds);int init_subkind_qdisk (libxl__checkpoint_devices_state *cds);void cleanup_subkind_qdisk (libxl__checkpoint_devices_state *cds); +int init_subkind_colo_nic (libxl__checkpoint_devices_state *cds); +void cleanup_subkind_colo_nic (libxl__checkpoint_devices_state *cds); typedef void libxl__checkpoint_callback(libxl__egc *, libxl__checkpoint_devices_state *,
@@ -3125,6 +3127,7 @@ typedef struct libxl__colo_save_state libxl__colo_save_state;struct libxl__colo_save_state {int send_fd;int recv_fd; +char *colo_proxy_script;/* private */ libxl__stream_read_state srs;
@@ -3537,6 +3540,7 @@ struct libxl__colo_restore_state {int recv_fd;int hvm;libxl__colo_callback *callback; +char *colo_proxy_script;/* private, colo restore checkpoint state */ libxl__domain_create_cb *saved_cb;
@@ -3566,6 +3570,7 @@ struct libxl__domain_create_state {libxl_asyncprogress_how aop_console_how;/* private to domain_create */ int guest_domid; +const char *colo_proxy_script;libxl__domain_build_state build_state;libxl__colo_restore_state crs;libxl__checkpoint_devices_state cds;
tools/libxl/libxl_types.idl +1 -0
@@ -599,6 +599,7 @@ libxl_device_nic = Struct("device_nic", [ ("rate_bytes_per_interval", uint64), ("rate_interval_usecs", uint32), ("gatewaydev", string), + ("forwarddev", string) ]) libxl_device_pci = Struct("device_pci", [
Signature · 1 line
2.5.0
Re: [PATCH v10 28/31] COLO nic: implement COLO nic subkind
Quoted 11 lines · Wen Congyang
implement COLO nic subkind.
Signed-off-by Yang Hongyang <[email protected]>Signed-off-by Wen Congyang <[email protected]>--- tools/hotplug/Linux/Makefile | 1 + tools/hotplug/Linux/colo-proxy-setup | 135 +++++++++++++++ tools/libxl/Makefile | 1 + tools/libxl/libxl_colo_nic.c | 321 +++++++++++++++++++++++++++++++++++ tools/libxl/libxl_internal.h | 5 + tools/libxl/libxl_types.idl | 1 +
I skipped this patch because it looks mostly internal to COLO.
Wei.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
PATCH v10 29/31 setup and control colo proxy on primary side
In reply to Wen Congyangsetup and control colo proxy on primary side
--- tools/libxl/libxl_colo_save.c | 124 +++++++++++++++++++++++++++++++++++++++--- tools/libxl/libxl_internal.h | 1 + 2 files changed, 117 insertions(+), 8 deletions(-)
tools/libxl/libxl_colo_save.c +116 -8
@@ -19,9 +19,11 @@#include "libxl_internal.h" #include "libxl_colo.h" +extern const libxl__checkpoint_device_instance_ops colo_save_device_nic;extern const libxl__checkpoint_device_instance_ops colo_save_device_qdisk;static const libxl__checkpoint_device_instance_ops *colo_ops[] = { + &colo_save_device_nic, &colo_save_device_qdisk,NULL , };
@@ -33,9 +35,15 @@ static int init_device_subkind(libxl__checkpoint_devices_state *cds)int rc;STATE_AO_GC (cds->ao); - rc =init_subkind_qdisk (cds); + rc =init_subkind_colo_nic (cds);if (rc) goto out; + rc =init_subkind_qdisk (cds); +if (rc) { +cleanup_subkind_colo_nic (cds); + goto out; + } + rc =0 ; out:return rc;
@@ -46,6 +54,7 @@ static void cleanup_device_subkind(libxl__checkpoint_devices_state *cds)/* cleanup device subkind-specific state in the libxl ctx */ STATE_AO_GC (cds->ao); +cleanup_subkind_colo_nic (cds);cleanup_subkind_qdisk (cds); }
@@ -83,9 +92,16 @@ void libxl__colo_save_setup(libxl__egc *egc, libxl__colo_save_state *css) css->paused = true; css->qdisk_setuped = false; css->qdisk_used = false; +libxl__ev_child_init (&css->child); -/* TODO: nic support */ - cds->device_kind_flags = (1 <<LIBXL__DEVICE_KIND_VBD ); +if (dss->remus->netbufscript) + css->colo_proxy_script =libxl__strdup (gc, dss->remus->netbufscript); +else + css->colo_proxy_script =GCSPRINTF ("%s/colo-proxy-setup" , +libxl__xen_script_dir_path ()); + + cds->device_kind_flags = (1 <<LIBXL__DEVICE_KIND_VIF ) | + (1 <<LIBXL__DEVICE_KIND_VBD ); cds->ops = colo_ops; cds->callback = colo_save_setup_done; cds->ao = ao;
@@ -96,6 +112,12 @@ void libxl__colo_save_setup(libxl__egc *egc, libxl__colo_save_state *css) css->srs.fd = css->recv_fd; css->srs.back_channel = true;libxl__stream_read_start (egc, &css->srs); + css->cps.ao = ao; +if (colo_proxy_setup (&css->cps)) { +LOG (ERROR ,"COLO: failed to setup colo proxy for guest with domid %u" , + cds->domid); + goto out; + }if (init_device_subkind (cds)) goto out;
@@ -183,6 +205,7 @@ static void colo_teardown_done(libxl__egc *egc,libxl__domain_save_state *dss =CONTAINER_OF (css, *dss, css);cleanup_device_subkind (cds); +colo_proxy_teardown (&css->cps); dss->callback (egc, dss, rc); }
@@ -382,6 +405,8 @@ static void colo_read_svm_ready_done(libxl__egc *egc, goto out; } +colo_proxy_preresume (&css->cps); + css->svm_running = true; dss->cds.callback = colo_preresume_cb;libxl__checkpoint_devices_preresume (egc, &dss->cds);
@@ -466,6 +491,8 @@ static void colo_read_svm_resumed_done(libxl__egc *egc, goto out; } +colo_proxy_postresume (&css->cps); + ok =1 ; out:
@@ -474,6 +501,91 @@ out:/* ===================== colo: wait new checkpoint ===================== */ + +static void colo_start_new_checkpoint (libxl__egc *egc, +libxl__checkpoint_devices_state *cds, +int rc); +static void colo_proxy_async_wait_for_checkpoint (libxl__colo_save_state *css); +static void colo_proxy_async_call_done (libxl__egc *egc, +libxl__ev_child *child, +int pid, +int status); + +static void colo_proxy_async_call (libxl__egc *egc, +libxl__colo_save_state *css, +void func (libxl__colo_save_state *), +libxl__ev_child_callback callback) +{ +libxl__domain_save_state *dss =CONTAINER_OF (css, *dss, css); +int pid =-1 , rc; + +STATE_AO_GC (dss->cds.ao); + +/* Fork and call */ + pid =libxl__ev_child_fork (gc, &css->child, callback); +if (pid ==-1 ) { +LOG (ERROR ,"unable to fork" ); + rc =ERROR_FAIL ; + goto out; + } + +if (!pid) { +/* child */ +func (css); +/* notreached */ +abort (); + } + +return ; + +out: +callback (egc, &css->child,-1 ,1 ); +} + +static void colo_proxy_wait_for_checkpoint (libxl__egc *egc, +libxl__colo_save_state *css) +{ +colo_proxy_async_call (egc, css, + colo_proxy_async_wait_for_checkpoint, + colo_proxy_async_call_done); +} + +static void colo_proxy_async_wait_for_checkpoint (libxl__colo_save_state *css) +{ +int req; + + req =colo_proxy_checkpoint (&css->cps,5000000 ); +if (req <0 ) { +/* some error happens */ +_exit (1 ); + }else if (!req) { +/* no checkpoint is needed, do a checkpint every 5s */ +_exit (0 ); + }else { +/* net packets is not consistent, we need to start a checkpoint */ +_exit (0 ); + } +} + +static void colo_proxy_async_call_done (libxl__egc *egc, +libxl__ev_child *child, +int pid, +int status) +{ +libxl__colo_save_state *css =CONTAINER_OF (child, *css, child); +libxl__domain_save_state *dss =CONTAINER_OF (css, *dss, css); + +EGC_GC ; + +if (status) { +LOG (ERROR ,"failed to wait for new checkpoint" ); +colo_start_new_checkpoint (egc, &dss->cds,ERROR_FAIL ); +return ; + } + +colo_start_new_checkpoint (egc, &dss->cds,0 ); +} +/* * Do the following things: * 1. do commit
@@ -483,9 +595,6 @@ out:static void colo_device_commit_cb (libxl__egc *egc,libxl__checkpoint_devices_state *cds,int rc); -static void colo_start_new_checkpoint (libxl__egc *egc, -libxl__checkpoint_devices_state *cds, -int rc);static void libxl__colo_save_domain_wait_checkpoint_callback (void *data) {
@@ -515,8 +624,7 @@ static void colo_device_commit_cb(libxl__egc *egc, goto out; } -/* TODO: wait a new checkpoint */ -colo_start_new_checkpoint (egc, cds,0 ); +colo_proxy_wait_for_checkpoint (egc, css);return ; out:
tools/libxl/libxl_internal.h +1 -0
@@ -3141,6 +3141,7 @@ struct libxl__colo_save_state {/* private, used by colo-proxy */ libxl__colo_proxy_state cps; +libxl__ev_child child; };/*----- Domain suspend (save) state structure -----*/
Signature · 1 line
2.5.0
PATCH v10 30/31 setup and control colo proxy on secondary side
In reply to Wen Congyangsetup and control colo proxy on secondary side
--- tools/libxl/libxl_colo_restore.c | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-)
tools/libxl/libxl_colo_restore.c +25 -3
@@ -50,9 +50,11 @@ static void libxl__colo_restore_domain_checkpoint_callback(void *data);static void libxl__colo_restore_domain_wait_checkpoint_callback (void *data);static void libxl__colo_restore_domain_suspend_callback (void *data); +extern const libxl__checkpoint_device_instance_ops colo_restore_device_nic;extern const libxl__checkpoint_device_instance_ops colo_restore_device_qdisk;static const libxl__checkpoint_device_instance_ops *colo_restore_ops[] = { + &colo_restore_device_nic, &colo_restore_device_qdisk,NULL , };
@@ -153,8 +155,14 @@ static int init_device_subkind(libxl__checkpoint_devices_state *cds)int rc;STATE_AO_GC (cds->ao); + rc =init_subkind_colo_nic (cds); +if (rc) goto out; + rc =init_subkind_qdisk (cds); -if (rc) goto out; +if (rc) { +cleanup_subkind_colo_nic (cds); + goto out; + } rc =0 ; out:
@@ -166,6 +174,7 @@ static void cleanup_device_subkind(libxl__checkpoint_devices_state *cds)/* cleanup device subkind-specific state in the libxl ctx */ STATE_AO_GC (cds->ao); +cleanup_subkind_colo_nic (cds);cleanup_subkind_qdisk (cds); }
@@ -347,6 +356,8 @@ static void colo_restore_teardown_devices_done(libxl__egc *egc,if (crcs->teardown_devices)cleanup_device_subkind (cds); +colo_proxy_teardown (&crs->cps); + rc = crcs->saved_rc;if (!rc) { crcs->callback = do_failover_done;
@@ -605,6 +616,8 @@ static void colo_restore_preresume_cb(libxl__egc *egc, } } +colo_proxy_preresume (&crs->cps); +colo_restore_resume_vm (egc, crcs);return ;
@@ -641,6 +654,8 @@ static void colo_resume_vm_done(libxl__egc *egc, crcs->status =LIBXL_COLO_RESUMED ; +colo_proxy_postresume (&crs->cps); +/* avoid calling stream->completion_callback() more than once */ if (crs->saved_cb) { dcs->callback = crs->saved_cb;
@@ -762,13 +777,20 @@ static void colo_setup_checkpoint_devices(libxl__egc *egc,STATE_AO_GC (crs->ao); -/* TODO: nic support */ - cds->device_kind_flags = (1 <<LIBXL__DEVICE_KIND_VBD ); + cds->device_kind_flags = (1 <<LIBXL__DEVICE_KIND_VIF ) | + (1 <<LIBXL__DEVICE_KIND_VBD ); cds->callback = colo_restore_setup_cds_done; cds->ao = ao; cds->domid = crs->domid; cds->ops = colo_restore_ops; + crs->cps.ao = ao; +if (colo_proxy_setup (&crs->cps)) { +LOG (ERROR ,"COLO: failed to setup colo proxy for guest with domid %u" , + cds->domid); + goto out; + } +if (init_device_subkind (cds)) goto out;
Signature · 1 line
2.5.0
PATCH v10 31/31 cmdline switches and config vars to control colo-proxy
In reply to Wen CongyangAdd cmdline switches to 'xl migrate-receive' command to specify a domain-specific hotplug script to setup COLO proxy.
Add a new config var 'colo.default.agentscript' to xl.conf, that allows the user to override the default global script used to setup COLO proxy.
--- docs/man/xl.conf.pod.5 | 6 ++++++ docs/man/xl.pod.1 | 1 - tools/libxl/libxl.c | 6 ++++++ tools/libxl/libxl_create.c | 14 ++++++++++++-- tools/libxl/libxl_types.idl | 1 + tools/libxl/xl.c | 3 +++ tools/libxl/xl.h | 1 + tools/libxl/xl_cmdimpl.c | 47 ++++++++++++++++++++++++++++++++++----------- 8 files changed, 65 insertions(+), 14 deletions(-)
docs/man/xl.conf.pod.5 +6 -0
@@ -111,6 +111,12 @@ Configures the default script used by Remus to setup network buffering. Default: C</etc/xen/scripts/remus-netbuf-setup> +=item B<colo.default.proxyscript="PATH"> + +Configures the default script used by COLO to setup colo-proxy. + +Default: C</etc/xen/scripts/colo-proxy-setup> + =item B<output_format="json|sxp"> Configures the default output format used by xl when printing "machine
docs/man/xl.pod.1 +0 -1
@@ -454,7 +454,6 @@ N.B: Remus support in xl is still in experimental (proof-of-concept) phase. Disk replication support is limited to DRBD disks. COLO support in xl is still in experimental (proof-of-concept) phase. - There is no support for network at the moment. B<OPTIONS>
tools/libxl/libxl.c +6 -0
@@ -3392,6 +3392,11 @@ void libxl__device_nic_add(libxl__egc *egc, uint32_t domid,flexarray_append (back, nic->ifname); } +if (nic->forwarddev) { +flexarray_append (back,"forwarddev" ); +flexarray_append (back, nic->forwarddev); + } +flexarray_append (back,"mac" );flexarray_append (back,GCSPRINTF (LIBXL_MAC_FMT ,LIBXL_MAC_BYTES (nic->mac)));if (nic->ip) {
@@ -3514,6 +3519,7 @@ static int libxl__device_nic_from_xs_be(libxl__gc *gc, nic->ip =READ_BACKEND (NOGC ,"ip" ); nic->bridge =READ_BACKEND (NOGC ,"bridge" ); nic->script =READ_BACKEND (NOGC ,"script" ); + nic->forwarddev =READ_BACKEND (NOGC ,"forwarddev" );/* vif_ioemu nics use the same xenstore entries as vif interfaces */ tmp =READ_BACKEND (gc,"type" );
tools/libxl/libxl_create.c +12 -2
@@ -1073,6 +1073,11 @@ static void domcreate_bootloader_done(libxl__egc *egc, crs->recv_fd = restore_fd; crs->hvm = (info->type ==LIBXL_DOMAIN_TYPE_HVM ); crs->callback = libxl__colo_restore_setup_done; +if (dcs->colo_proxy_script) + crs->colo_proxy_script =libxl__strdup (gc, dcs->colo_proxy_script); +else + crs->colo_proxy_script =GCSPRINTF ("%s/colo-proxy-setup" , +libxl__xen_script_dir_path ());libxl__colo_restore_setup (egc, crs);break ;case LIBXL_CHECKPOINTED_STREAM_REMUS :
@@ -1615,6 +1620,7 @@ static void domain_create_cb(libxl__egc *egc,static int do_domain_create (libxl_ctx *ctx,libxl_domain_config *d_config,uint32_t *domid,int restore_fd,int send_back_fd,const libxl_domain_restore_params *params, +const char *colo_proxy_script,const libxl_asyncop_how *ao_how,const libxl_asyncprogress_how *aop_console_how) {
@@ -1638,6 +1644,7 @@ static int do_domain_create(libxl_ctx *ctx, libxl_domain_config *d_config, } cdcs->dcs.callback = domain_create_cb; cdcs->dcs.domid_soft_reset =INVALID_DOMID ; + cdcs->dcs.colo_proxy_script = colo_proxy_script;libxl__ao_progress_gethow (&cdcs->dcs.aop_console_how, aop_console_how); cdcs->domid_out = domid;
@@ -1824,7 +1831,7 @@ int libxl_domain_create_new(libxl_ctx *ctx, libxl_domain_config *d_config, const libxl_asyncprogress_how *aop_console_how) {unset_disk_colo_restore (d_config); -return do_domain_create (ctx, d_config, domid,-1 ,-1 ,NULL , +return do_domain_create (ctx, d_config, domid,-1 ,-1 ,NULL ,NULL , ao_how, aop_console_how); }
@@ -1835,14 +1842,17 @@ int libxl_domain_create_restore(libxl_ctx *ctx, libxl_domain_config *d_config,const libxl_asyncop_how *ao_how, const libxl_asyncprogress_how *aop_console_how) { + char *colo_proxy_script = NULL; +if (params->checkpointed_stream ==LIBXL_CHECKPOINTED_STREAM_COLO ) { + colo_proxy_script = params->colo_proxy_script;set_disk_colo_restore (d_config); }else {unset_disk_colo_restore (d_config); }return do_domain_create (ctx, d_config, domid, restore_fd, send_back_fd, - params, ao_how, aop_console_how); + params, colo_proxy_script, ao_how, aop_console_how); } int libxl_domain_soft_reset(libxl_ctx *ctx,
tools/libxl/libxl_types.idl +1 -0
@@ -385,6 +385,7 @@ libxl_domain_create_info = Struct("domain_create_info",[ libxl_domain_restore_params = Struct("domain_restore_params", [ ("checkpointed_stream", integer), ("stream_version", uint32, {'init_val': '1'}), + ("colo_proxy_script", string), ]) libxl_domain_sched_params = Struct("domain_sched_params",[
tools/libxl/xl.c +3 -0
@@ -45,6 +45,7 @@ char *default_bridge = NULL;char *default_gatewaydev =NULL ;char *default_vifbackend =NULL ;char *default_remus_netbufscript =NULL ; +char *default_colo_proxy_script =NULL ;enum output_format default_output_format =OUTPUT_FORMAT_JSON ;int claim_mode =1 ;bool progress_use_cr =0 ;
@@ -179,6 +180,8 @@ static void parse_global_config(const char *configfile,xlu_cfg_replace_string (config,"remus.default.netbufscript" , &default_remus_netbufscript,0 ); +xlu_cfg_replace_string (config,"colo.default.proxyscript" , + &default_colo_proxy_script,0 );xlu_cfg_destroy (config); }
tools/libxl/xl.h +1 -0
@@ -189,6 +189,7 @@ extern char *default_bridge;extern char *default_gatewaydev;extern char *default_vifbackend;extern char *default_remus_netbufscript; +extern char *default_colo_proxy_script;extern char *blkdev_start;enum output_format {
tools/libxl/xl_cmdimpl.c +36 -11
114 lines not on this page · raw message
Signature · 1 line
2.5.0
Re: [PATCH v10 31/31] cmdline switches and config vars to control colo-proxy
Quoted 42 lines · Wen Congyang
Add cmdline switches to 'xl migrate-receive' command to specify a domain-specific hotplug script to setup COLO proxy.
Add a new config var 'colo.default.agentscript' to xl.conf, that allows the user to override the default global script used to setup COLO proxy.
Signed-off-by Yang Hongyang <[email protected]>Signed-off-by Wen Congyang <[email protected]>--- docs/man/xl.conf.pod.5 | 6 ++++++ docs/man/xl.pod.1 | 1 - tools/libxl/libxl.c | 6 ++++++ tools/libxl/libxl_create.c | 14 ++++++++++++-- tools/libxl/libxl_types.idl | 1 + tools/libxl/xl.c | 3 +++ tools/libxl/xl.h | 1 + tools/libxl/xl_cmdimpl.c | 47 ++++++++++++++++++++++++++++++++++----------- 8 files changed, 65 insertions(+), 14 deletions(-)docs/man/xl.conf.pod.5 +6
-0@@ -111,6 +111,12 @@ Configures the default script used by Remus to setup network buffering. Default: C</etc/xen/scripts/remus-netbuf-setup> +=item B<colo.default.proxyscript="PATH"> + +Configures the default script used by COLO to setup colo-proxy. + +Default: C</etc/xen/scripts/colo-proxy-setup> + =item B<output_format="json|sxp"> Configures the default output format used by xl when printing "machinedocs/man/xl.pod.1 +0
-0
docs/man/xl.pod.1 N.B: Remus support in xl is still in experimental (proof-of-concept) phase. · line 457
Quoted 4 lines
docs/man/xl.pod.1 +0
-1@@ -454,7 +454,6 @@ N.B: Remus support in xl is still in experimental (proof-of-concept) phase. Disk replication support is limited to DRBD disks. COLO support in xl is still in experimental (proof-of-concept) phase. - There is no support for network at the moment.
Same here, missing documentation on how to use the new parameters (if any). Please provide adequate documentation otherwise we can't meaningfully review the rest of this patch.
Wei.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH v10 31/31] cmdline switches and config vars to control colo-proxy
Quoted 45 lines · Wei Liu
Quoted 44 lines · Wen Congyang
Add cmdline switches to 'xl migrate-receive' command to specify a domain-specific hotplug script to setup COLO proxy.
Add a new config var 'colo.default.agentscript' to xl.conf, that allows the user to override the default global script used to setup COLO proxy.
Signed-off-by Yang Hongyang <[email protected]>Signed-off-by Wen Congyang <[email protected]>--- docs/man/xl.conf.pod.5 | 6 ++++++ docs/man/xl.pod.1 | 1 - tools/libxl/libxl.c | 6 ++++++ tools/libxl/libxl_create.c | 14 ++++++++++++-- tools/libxl/libxl_types.idl | 1 + tools/libxl/xl.c | 3 +++ tools/libxl/xl.h | 1 + tools/libxl/xl_cmdimpl.c | 47 ++++++++++++++++++++++++++++++++++----------- 8 files changed, 65 insertions(+), 14 deletions(-)docs/man/xl.conf.pod.5 +6
-0@@ -111,6 +111,12 @@ Configures the default script used by Remus to setup network buffering. Default: C</etc/xen/scripts/remus-netbuf-setup> +=item B<colo.default.proxyscript="PATH"> + +Configures the default script used by COLO to setup colo-proxy. + +Default: C</etc/xen/scripts/colo-proxy-setup> + =item B<output_format="json|sxp"> Configures the default output format used by xl when printing "machinedocs/man/xl.pod.1 +0
-0@@ -454,7 +454,6 @@ N.B: Remus support in xl is still in experimental (proof-of-concept) phase. Disk replication support is limited to DRBD disks.
Quoted 7 lines
docs/man/xl.pod.1 N.B: Remus support in xl is still in experimental (proof-of-concept) phase. · line 457
Quoted 2 lines
docs/man/xl.pod.1 +0
-1COLO support in xl is still in experimental (proof-of-concept) phase. - There is no support for network at the moment.Same here, missing documentation on how to use the new parameters (if any). Please provide adequate documentation otherwise we can't meaningfully review the rest of this patch.
OK, will fix it in the next version.
Thanks
Wen Congyang
Quoted 6 lines
Wei.
.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
I managed to go through up to patch 21 today. I will see if I can get some more time to look at the rest.
Wei.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel