COarse-grain LOck-stepping Virtual Machines for Non-stop Service
v6 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:
[PATCH v2 COLOPre 00/13] Prerequisite patches for COLO
We only support hvm guest now. The codes are also hosted on github:
https://github.com/macrosheep/xen/tree/colo-v6
Patch 1 : Add readme
Patch 2-7: COLO framework related codes Patch 8-9: Implement disk replication Patch 10-15: Implement nic replication
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 (6):
secondary vm suspend/resume/checkpoint code
primary vm suspend/get_dirty_pfn/resume/checkpoint code send store mfn and console mfn to xl before resuming secondary vm implement the cmdline for COLO
Support colo mode for qemu disk
COLO: use qemu block replication
Yang Hongyang (9):
docs: add colo readme
libxc/restore: support COLO restore
libxc/save: support COLO save
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 +- tools/hotplug/Linux/Makefile | 1 + tools/hotplug/Linux/colo-proxy-setup | 131 ++++ tools/libxc/include/xenguest.h | 40 ++ tools/libxc/xc_sr_common.h | 11 +- tools/libxc/xc_sr_restore.c | 67 +- tools/libxc/xc_sr_restore_x86_hvm.c | 1 + tools/libxc/xc_sr_save.c | 49 +- tools/libxl/Makefile | 4 + tools/libxl/libxl.c | 70 +- tools/libxl/libxl_colo.h | 53 ++ tools/libxl/libxl_colo_nic.c | 317 +++++++++ tools/libxl/libxl_colo_proxy.c | 267 ++++++++ tools/libxl/libxl_colo_qdisk.c | 209 ++++++ tools/libxl/libxl_colo_restore.c | 1192 ++++++++++++++++++++++++++++++++++ tools/libxl/libxl_colo_save.c | 784 ++++++++++++++++++++++ tools/libxl/libxl_create.c | 156 ++++- tools/libxl/libxl_device.c | 38 ++ tools/libxl/libxl_dm.c | 262 +++++++- tools/libxl/libxl_dom_save.c | 17 +- tools/libxl/libxl_internal.h | 94 ++- tools/libxl/libxl_qmp.c | 31 + tools/libxl/libxl_save_callout.c | 6 +- tools/libxl/libxl_save_msgs_gen.pl | 9 +- tools/libxl/libxl_types.idl | 8 + tools/libxl/libxlu_disk_l.l | 5 + tools/libxl/xl.c | 3 + tools/libxl/xl.h | 1 + tools/libxl/xl_cmdimpl.c | 92 ++- tools/libxl/xl_cmdtable.c | 4 +- 32 files changed, 3896 insertions(+), 52 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
1.9.1
PATCH v6 1/15 docs: add colo readme
add 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
1.9.1
Re: [PATCH v6 COLO 01/15] docs: add colo readme
Quoted 4 lines · Yang Hongyang
add colo readme, refer to
http://wiki.xen.org/wiki/COLO_-_Coarse_Grain_Lock_SteppingSigned-off-by Yang Hongyang <[email protected]>
This is fine as far as it goes but I wonder if perhaps docs/README.{remus,colo} ought to be moved into docs/misc, perhaps converted to markdown (which should be trivial) and perhaps merged into a single document about checkpointing?
The reason for the move is twofold, first it is a bit a typical for docs to live in the top-level docs dir and secondly moving it into misc will cause it to appear automatically at
http://xenbits.xen.org/docs/unstable/ etc.
Ian.
Quoted 20 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.
Re: [PATCH v6 COLO 01/15] docs: add colo readme
Quoted 10 lines · Ian Campbell
Quoted 4 lines · Yang Hongyang
add colo readme, refer to
http://wiki.xen.org/wiki/COLO_-_Coarse_Grain_Lock_SteppingSigned-off-by Yang Hongyang <[email protected]>This is fine as far as it goes but I wonder if perhaps docs/README.{remus,colo} ought to be moved into docs/misc, perhaps converted to markdown (which should be trivial) and perhaps merged into a single document about checkpointing?
Agreeed that we can add a checkpointing.txt to docs/misc, and describe remus/COLO in that file. but can we do this later when COLO feature is merged? at that time we can do this within one patch.
Quoted 31 lines
The reason for the move is twofold, first it is a bit a typical for docs to live in the top-level docs dir and secondly moving it into misc will cause it to appear automatically at
http://xenbits.xen.org/docs/unstable/ etc.Ian.
Quoted 11 lines
--- docs/README.colo | 9 +++++++++ 1 file changed, 9 insertions(+)create mode 100644 docs/README.colo
docs/README.colo new file +0
-0docs/README.colo line 9
Quoted 9 lines
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 · 2 lines
Thanks, Yang.
PATCH v6 2/15 secondary vm suspend/resume/checkpoint code
In reply to Yang HongyangFrom: Wen Congyang <[email protected]>
Secondary vm is running in colo mode. So we will do
the following things again and again:
1. Resume secondary vm
a. Send LIBXL_COLO_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 LIBXL_COLO_SVM_RESUMED to master.
2. Wait a new checkpoint
a. Call libxl__checkpoint_devices_commit().
b. Read LIBXL_COLO_NEW_CHECKPOINT from master.
3. Suspend secondary vm
a. Suspend secondary vm.
b. Call libxl__checkpoint_devices_postsuspend().
c. Get secondary vm's dirty page information.
d. Send LIBXL_COLO_SVM_SUSPENDED to master.
e. Send secondary vm's dirty page information to master(count + pfn list).
--- tools/libxc/include/xenguest.h | 20 + tools/libxl/Makefile | 1 + tools/libxl/libxl_colo.h | 38 ++ tools/libxl/libxl_colo_restore.c | 1158 ++++++++++++++++++++++++++++++++++++ tools/libxl/libxl_create.c | 116 +++- tools/libxl/libxl_dom_save.c | 2 +- tools/libxl/libxl_internal.h | 24 + tools/libxl/libxl_save_callout.c | 6 +- tools/libxl/libxl_save_msgs_gen.pl | 6 +- 9 files changed, 1364 insertions(+), 7 deletions(-) create mode 100644 tools/libxl/libxl_colo.h create mode 100644 tools/libxl/libxl_colo_restore.c
tools/libxc/include/xenguest.h +20 -0
@@ -98,6 +98,26 @@ int xc_domain_save2(xc_interface *xch, int io_fd, uint32_t dom, uint32_t max_ite/* 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); + +/* callback to wait a new checkpoint +* +* returns: +* 0: terminate checkpointing gracefully +* 1: take another checkpoint */ +int (*checkpoint)(void * data); + +/* Enable qemu-dm logging dirty pages to xen */ +int (*switch_qemu_logdirty)(int domid,unsigned enable,void *data);/* HVM only */ +/* callback to restore toolstack specific data */ int (*toolstack_restore)(uint32_t domid,const uint8_t *buf,uint32_t size,void * data);
tools/libxl/Makefile +1 -0
@@ -57,6 +57,7 @@ LIBXL_OBJS-y += libxl_nonetbuffer.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 +38 -0
@@ -0,0 +1,38 @@ +/* +* 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 + +/* +* values to control suspend/resume primary vm and secondary vm +* at the same time +*/ +enum { +LIBXL_COLO_NEW_CHECKPOINT =1 , +LIBXL_COLO_SVM_SUSPENDED , +LIBXL_COLO_SVM_READY , +LIBXL_COLO_SVM_RESUMED , +}; + +extern void libxl__colo_restore_done (libxl__egc *egc,void *dcs_void, +int ret,int retval,int errnoval); +extern void libxl__colo_restore_setup (libxl__egc *egc, +libxl__colo_restore_state *crs); +extern void libxl__colo_restore_teardown (libxl__egc *egc, +libxl__colo_restore_state *crs, +int rc); + +#endif
tools/libxl/libxl_colo_restore.c new file +1158 -0
1,158 lines not on this page · raw message
tools/libxl/libxl_create.c +114 -2
146 lines not on this page · raw message
tools/libxl/libxl_dom_save.c +1 -1
@@ -46,7 +46,7 @@ static void switch_logdirty_xswatch(libxl__egc *egc, libxl__ev_xswatch*,static void switch_logdirty_done (libxl__egc *egc,libxl__logdirty_switch *lds,int ok); -static void logdirty_init (libxl__logdirty_switch *lds) +void logdirty_init (libxl__logdirty_switch *lds) { lds->cmd_path =0 ;libxl__ev_xswatch_init (&lds->watch);
tools/libxl/libxl_internal.h +24 -0
@@ -2864,6 +2864,8 @@ typedef struct libxl__logdirty_switch {libxl__ev_time timeout; } libxl__logdirty_switch; +_hidden void logdirty_init(libxl__logdirty_switch *lds); +struct libxl__domain_suspend_state {/* set by caller of domain_suspend_callback_common */ libxl__ao *ao;
@@ -3151,6 +3153,27 @@ typedef void libxl__domain_create_cb(libxl__egc *egc, libxl__domain_create_state*, int rc, uint32_t domid); +/* 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_fd; +int recv_fd; +int hvm; +int pae; +int superpages; +libxl__colo_callback *callback; + +/* private, colo restore checkpoint state */ +libxl__domain_create_cb *saved_cb; +void *crcs; +libxl__checkpoint_devices_state cds; +}; +struct libxl__domain_create_state {/* filled in by user */ libxl__ao *ao;
@@ -3164,6 +3187,7 @@ struct libxl__domain_create_state {int guest_domid;int checkpointed_stream;libxl__domain_build_state build_state; +libxl__colo_restore_state crs;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 +5 -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.
@@ -65,7 +66,10 @@ void libxl__xc_domain_restore(libxl__egc *egc, libxl__domain_create_state *dcs, dcs->shs.ao = ao; dcs->shs.domid = domid; dcs->shs.recv_callback = libxl__srm_callout_received_restore; - dcs->shs.completion_callback = libxl__xc_domain_restore_done; +if (dcs->checkpointed_stream ==LIBXL_CHECKPOINTED_STREAM_COLO ) + dcs->shs.completion_callback = libxl__colo_restore_done; +else + dcs->shs.completion_callback = libxl__xc_domain_restore_done; dcs->shs.caller_state = dcs; dcs->shs.need_results =1 ; dcs->shs.toolstack_data_file =0 ;
tools/libxl/libxl_save_msgs_gen.pl +3 -3
@@ -24,9 +24,9 @@ our @msgs = ( STRING doing_what), 'unsigned long', 'done', 'unsigned long', 'total'] ], - [ 3, 'scxA', "suspend", [] ], - [ 4, 'scxA', "postcopy", [] ], - [ 5, 'scxA', "checkpoint", [] ], + [ 3, 'srcxA', "suspend", [] ], + [ 4, 'srcxA', "postcopy", [] ], + [ 5, 'srcxA', "checkpoint", [] ], [ 6, 'scxA', "switch_qemu_logdirty", [qw(int domid unsigned enable)] ], # toolstack_save done entirely `by hand'
Signature · 1 line
1.9.1
Re: [PATCH v6 COLO 02/15] secondary vm suspend/resume/checkpoint code
Quoted 26 lines · Yang Hongyang
From: Wen Congyang <[email protected]>
Secondary vm is running in colo mode. So we will do
the following things again and again:
1. Resume secondary vm
a. SendLIBXL_COLO_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. SendLIBXL_COLO_SVM_RESUMEDto master.
2. Wait a new checkpoint
a. Calllibxl__checkpoint_devices_commit().
b. ReadLIBXL_COLO_NEW_CHECKPOINTfrom master.
3. Suspend secondary vm
a. Suspend secondary vm.
b. Calllibxl__checkpoint_devices_postsuspend().
c. Get secondary vm's dirty page information.
d. SendLIBXL_COLO_SVM_SUSPENDEDto master.
e. Send secondary vm's dirty page information to master(count + pfn list).Signed-off-by Wen Congyang <[email protected]>Signed-off-by Yang Hongyang <[email protected]>---
[...]
Quoted 8 lines
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ */tools/libxl/libxl_colo.h new file +5
-0+ +#ifndef LIBXL_COLO_H +#define LIBXL_COLO_H + +/*
tools/libxl/libxl_colo.h line 29
Quoted 10 lines
tools/libxl/libxl_colo.h new file +10
-0+* values to control suspend/resume primary vm and secondary vm +* at the same time +*/ +enum { +LIBXL_COLO_NEW_CHECKPOINT =1 , +LIBXL_COLO_SVM_SUSPENDED , +LIBXL_COLO_SVM_READY , +LIBXL_COLO_SVM_RESUMED , +}; +
Any reason to not have this in IDL?
Quoted 29 lines
tools/libxl/libxl_colo.h new file +9
-0+extern void libxl__colo_restore_done (libxl__egc *egc,void *dcs_void, +int ret,int retval,int errnoval); +extern void libxl__colo_restore_setup (libxl__egc *egc, +libxl__colo_restore_state *crs); +extern void libxl__colo_restore_teardown (libxl__egc *egc, +libxl__colo_restore_state *crs, +int rc); + +#endif tools/libxl/libxl_colo_restore.c new file +14
-0@@ -0,0 +1,1158 @@ +/* +* Copyright (C) 2014 FUJITSU LIMITED +* Author: Wen Congyang <[email protected]> +* 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.
tools/libxl/libxl_colo_restore.c line 24
Quoted 10 lines
tools/libxl/libxl_colo_restore.c new file +10
-0+*/ + +#include "libxl_osdeps.h" /* must come before any other headers */ + +#include "libxl_internal.h" +#include "libxl_colo.h" +#include "xc_bitops.h" + +#define XC_PAGE_SHIFT 12 +#define PAGE_SHIFT XC_PAGE_SHIFT
I don't think you need these.
tools/libxl/libxl_colo_restore.c line 26
Quoted 2 lines
tools/libxl/libxl_colo_restore.c new file +2
-0+#define ROUNDUP (_x,_w) (((unsigned long)(_x)+(1UL<<(_w))-1) & ~((1UL<<(_w))-1)) +#define NRPAGES (x) (ROUNDUP(x, PAGE_SHIFT) >> PAGE_SHIFT)
And you can use XC_PAGE_SHIFT directly in above macro.
tools/libxl/libxl_colo_restore.c line 33
Quoted 7 lines
tools/libxl/libxl_colo_restore.c new file +7
-0+ +enum { +LIBXL_COLO_SETUPED , +LIBXL_COLO_SUSPENDED , +LIBXL_COLO_RESUMED , +}; +
Move it to IDL as well?
tools/libxl/libxl_colo_restore.c line 37
Quoted 4 lines
tools/libxl/libxl_colo_restore.c new file +4
-0+typedef struct libxl__colo_restore_checkpoint_state libxl__colo_restore_checkpoint_state ; +struct libxl__colo_restore_checkpoint_state { +xc_hypercall_buffer_t _dirty_bitmap; +xc_hypercall_buffer_t *dirty_bitmap;
This one looks like layer violation to me. I don't have other good suggestion on how to do this though. Maybe Ian and Ian have better idea.
tools/libxl/libxl_colo_restore.c line 41
Quoted 4 lines
tools/libxl/libxl_colo_restore.c new file +4
-0+unsigned long p2m_size; +libxl__domain_suspend_state dsps; +libxl__datacopier_state dc; +uint8_t section;
This could use a better name like "stage" / "state"?
Quoted 30 lines
tools/libxl/libxl_colo_restore.c new file +30
-0+libxl__logdirty_switch lds; +libxl__colo_restore_state *crs; +int status; +bool preresume; +/* used for teardown */ +int teardown_devices; +int saved_rc; + +void (*callback)(libxl__egc *, +libxl__colo_restore_checkpoint_state *, +int ); + +/* +* 0: secondary vm's dirty bitmap for domain @domid +* 1: secondary vm is ready(domain @domid) +* 2: secondary vm is resumed(domain @domid) +* 3. new checkpoint is triggered(domain @domid) +*/ +const char *copywhat[4 ]; +}; + + +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_suspend_callback (void *data); + +static const libxl__checkpoint_device_instance_ops *colo_restore_ops[] = { +NULL , +}; +
[...]
tools/libxl/libxl_colo_restore.c line 638
Quoted 7 lines
tools/libxl/libxl_colo_restore.c new file +7
-0+ crcs->status =LIBXL_COLO_RESUMED ; + +/* avoid calling libxl__xc_domain_restore_done() more than once */ +if (crs->saved_cb) { + dcs->callback = crs->saved_cb; + crs->saved_cb =NULL ; +
I have a feeling that this trick should be avoided. But I'm not an expert on this so I will defer judgement to Ian J.
Quoted 12 lines
tools/libxl/libxl_colo_restore.c new file +12
-0+ lds->callback = colo_enable_logdirty_done; +colo_enable_logdirty (crs, egc); +return ; + } + +colo_write_svm_resumed (egc, crcs); +return ; + +out: +libxl__xc_domain_saverestore_async_callback_done (egc, shs,0 ); +} +
[...]
tools/libxl/libxl_colo_restore.c
Quoted 3 lines
tools/libxl/libxl_colo_restore.c new file +2
-0+_hidden void logdirty_init(libxl__logdirty_switch *lds); +
This function should be in libxl__ namespace.
Other than these cosmetic issues I don't really have the expertise to comment further.
Wei.
Re: [PATCH v6 COLO 02/15] secondary vm suspend/resume/checkpoint code
Wei Liu writes ("Re: [Xen-devel] [PATCH v6 COLO 02/15] secondary vm suspend/resume/checkpoint code"):
Quoted 11 lines · Yang Hongyang
tools/libxl/libxl_colo_restore.c line 637
Quoted 7 lines
From: Wen Congyang <[email protected]>
tools/libxl/libxl_colo_restore.c new file +6
-0+ crcs->status =LIBXL_COLO_RESUMED ; + +/* avoid calling libxl__xc_domain_restore_done() more than once */ +if (crs->saved_cb) { + dcs->callback = crs->saved_cb; + crs->saved_cb =NULL ;I have a feeling that this trick should be avoided. But I'm not an expert on this so I will defer judgement to Ian J.
Yes, this trick should be avoided. It will make the resulting control flow very confusing.
Ian.
Re: [PATCH v6 COLO 02/15] secondary vm suspend/resume/checkpoint code
Hi Ian J, Wei,
Quoted 10 lines · Ian Jackson
Wei Liu writes ("Re: [Xen-devel] [PATCH v6 COLO 02/15] secondary vm suspend/resume/checkpoint code"):
Quoted 9 lines · Yang Hongyang
Quoted 7 lines
From: Wen Congyang <[email protected]>
tools/libxl/libxl_colo_restore.c new file +6
-0+ crcs->status =LIBXL_COLO_RESUMED ; + +/* avoid calling libxl__xc_domain_restore_done() more than once */ +if (crs->saved_cb) { + dcs->callback = crs->saved_cb; + crs->saved_cb =NULL ;
Quoted 5 lines
Quoted 2 lines
I have a feeling that this trick should be avoided. But I'm not an expert on this so I will defer judgement to Ian J.
Yes, this trick should be avoided. It will make the resulting control flow very confusing.
I agree that this part is a bit of tricky. I will try to find another way to do this. Maybe add another state variable to indicate what stage we are in, the first boot or under checkpoint.
Quoted 4 lines
Ian.
.
Signature · 2 lines
Thanks, Yang.
Re: [PATCH v6 COLO 02/15] secondary vm suspend/resume/checkpoint code
In reply to Wei LiuQuoted 40 lines · Wei Liu
Quoted 26 lines · Yang Hongyang
From: Wen Congyang <[email protected]>
Secondary vm is running in colo mode. So we will do
the following things again and again:
1. Resume secondary vm
a. SendLIBXL_COLO_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. SendLIBXL_COLO_SVM_RESUMEDto master.
2. Wait a new checkpoint
a. Calllibxl__checkpoint_devices_commit().
b. ReadLIBXL_COLO_NEW_CHECKPOINTfrom master.
3. Suspend secondary vm
a. Suspend secondary vm.
b. Calllibxl__checkpoint_devices_postsuspend().
c. Get secondary vm's dirty page information.
d. SendLIBXL_COLO_SVM_SUSPENDEDto master.
e. Send secondary vm's dirty page information to master(count + pfn list).Signed-off-by Wen Congyang <[email protected]>Signed-off-by Yang Hongyang <[email protected]>---
[...]
Quoted 12 lines
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ */tools/libxl/libxl_colo.h new file +9
-0+ +#ifndef LIBXL_COLO_H +#define LIBXL_COLO_H + +/* +* values to control suspend/resume primary vm and secondary vm +* at the same time +*/ +enum {
Quoted 8 lines
tools/libxl/libxl_colo.h line 29
Quoted 6 lines
tools/libxl/libxl_colo.h new file +6
-0+LIBXL_COLO_NEW_CHECKPOINT =1 , +LIBXL_COLO_SVM_SUSPENDED , +LIBXL_COLO_SVM_READY , + LIBXL_COLO_SVM_RESUMED, +}; +Any reason to not have this in IDL?
No, will move it to IDL in the next version.
Quoted 43 lines
Quoted 30 lines
tools/libxl/libxl_colo.h new file +9
-0+extern void libxl__colo_restore_done (libxl__egc *egc,void *dcs_void, +int ret,int retval,int errnoval); +extern void libxl__colo_restore_setup (libxl__egc *egc, +libxl__colo_restore_state *crs); +extern void libxl__colo_restore_teardown (libxl__egc *egc, +libxl__colo_restore_state *crs, +int rc); + +#endif tools/libxl/libxl_colo_restore.c new file +14
-0@@ -0,0 +1,1158 @@ +/* +* Copyright (C) 2014 FUJITSU LIMITED +* Author: Wen Congyang <[email protected]> +* 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. tools/libxl/libxl_colo_restore.c line 24
Quoted 10 lines
tools/libxl/libxl_colo_restore.c new file +10
-0+*/ + +#include "libxl_osdeps.h" /* must come before any other headers */ + +#include "libxl_internal.h" +#include "libxl_colo.h" +#include "xc_bitops.h" + +#define XC_PAGE_SHIFT 12 +#define PAGE_SHIFT XC_PAGE_SHIFTI don't think you need these.
Quoted 4 lines
tools/libxl/libxl_colo_restore.c line 26
Quoted 2 lines
tools/libxl/libxl_colo_restore.c new file +2
-0+#define ROUNDUP (_x,_w) (((unsigned long)(_x)+(1UL<<(_w))-1) & ~((1UL<<(_w))-1)) +#define NRPAGES (x) (ROUNDUP(x, PAGE_SHIFT) >> PAGE_SHIFT)And you can use
XC_PAGE_SHIFTdirectly in above macro.
Okay, thanks.
Quoted 10 lines
tools/libxl/libxl_colo_restore.c line 33
Quoted 8 lines
tools/libxl/libxl_colo_restore.c new file +7
-0+ +enum { +LIBXL_COLO_SETUPED , +LIBXL_COLO_SUSPENDED , +LIBXL_COLO_RESUMED , +}; +Move it to IDL as well?
Ok.
Quoted 8 lines
tools/libxl/libxl_colo_restore.c line 37
Quoted 5 lines
tools/libxl/libxl_colo_restore.c new file +4
-0+typedef struct libxl__colo_restore_checkpoint_state libxl__colo_restore_checkpoint_state ; +struct libxl__colo_restore_checkpoint_state { +xc_hypercall_buffer_t _dirty_bitmap; +xc_hypercall_buffer_t *dirty_bitmap;This one looks like layer violation to me. I don't have other good suggestion on how to do this though. Maybe Ian and Ian have better idea.
We are talking about moving this operation to libxc layer, what's your opinion? Please refer to the 4th COLOPre patch.
Quoted 7 lines
tools/libxl/libxl_colo_restore.c line 41
Quoted 5 lines
tools/libxl/libxl_colo_restore.c new file +4
-0+unsigned long p2m_size; +libxl__domain_suspend_state dsps; +libxl__datacopier_state dc; +uint8_t section;This could use a better name like "stage" / "state"?
stage should be better, thank you.
Quoted 57 lines
Quoted 31 lines
tools/libxl/libxl_colo_restore.c new file +30
-0+libxl__logdirty_switch lds; +libxl__colo_restore_state *crs; +int status; +bool preresume; +/* used for teardown */ +int teardown_devices; +int saved_rc; + +void (*callback)(libxl__egc *, +libxl__colo_restore_checkpoint_state *, +int ); + +/* +* 0: secondary vm's dirty bitmap for domain @domid +* 1: secondary vm is ready(domain @domid) +* 2: secondary vm is resumed(domain @domid) +* 3. new checkpoint is triggered(domain @domid) +*/ +const char *copywhat[4 ]; +}; + + +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_suspend_callback (void *data); + +static const libxl__checkpoint_device_instance_ops *colo_restore_ops[] = { +NULL , +}; +[...]
tools/libxl/libxl_colo_restore.c line 638
Quoted 7 lines
tools/libxl/libxl_colo_restore.c new file +7
-0+ crcs->status =LIBXL_COLO_RESUMED ; + +/* avoid calling libxl__xc_domain_restore_done() more than once */ +if (crs->saved_cb) { + dcs->callback = crs->saved_cb; + crs->saved_cb =NULL ; +I have a feeling that this trick should be avoided. But I'm not an expert on this so I will defer judgement to Ian J.
Quoted 12 lines
tools/libxl/libxl_colo_restore.c new file +12
-0+ lds->callback = colo_enable_logdirty_done; +colo_enable_logdirty (crs, egc); +return ; + } + +colo_write_svm_resumed (egc, crcs); +return ; + +out: +libxl__xc_domain_saverestore_async_callback_done (egc, shs,0 ); +} +[...]
Quoted 1 line
Quoted 4 lines
tools/libxl/libxl_colo_restore.c
Quoted 2 lines
tools/libxl/libxl_colo_restore.c new file +2
-0+_hidden void logdirty_init(libxl__logdirty_switch *lds); +This function should be in
libxl__namespace.
OK, thanks.
Quoted 7 lines
Other than these cosmetic issues I don't really have the expertise to comment further.
Wei.
.
Signature · 2 lines
Thanks, Yang.
Re: [PATCH v6 COLO 02/15] secondary vm suspend/resume/checkpoint code
Yang Hongyang writes ("Re: [Xen-devel] [PATCH v6 COLO 02/15] secondary vm suspend/resume/checkpoint code"):
Quoted 1 line
Quoted 1 line · Yang Hongyang
...
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
3. Suspend secondary vm
a. Suspend secondary vm.
b. Calllibxl__checkpoint_devices_postsuspend().
c. Get secondary vm's dirty page information.
d. SendLIBXL_COLO_SVM_SUSPENDEDto master.
e. Send secondary vm's dirty page information to master(count + pfn list).
In the pdf
http://www.socc2013.org/home/program/a3-dong.pdf?attredirects=0
linked from the wiki page
http://wiki.xen.org/wiki/COLO_-_Coarse_Grain_Lock_Stepping
it says that the secondary keeps a copy of the original contents of its dirty pages. So I don't understand why you need to send the dirty bitmap to the primary.
Thanks,
Ian.
PATCH v6 3/15 primary vm suspend/get_dirty_pfn/resume/checkpoint code
In reply to Yang HongyangFrom: Wen Congyang <[email protected]>
We will do the following things again and again:
1. Suspend primary vm
a. Suspend primary vm
b. do postsuspend
c. Read LIBXL_COLO_SVM_SUSPENDED sent by secondary
d. Read secondary vm's dirty page information to master(count + pfn list)
2. Get dirty pfn list callback, used by libxc
a. Return secondary vm's dirty pfn list
3. Resume primary vm
a. Read LIBXL_COLO_SVM_READY from slave
b. Do presume
c. Resume primary vm
d. Read LIBXL_COLO_SVM_RESUMED from slave
4. Wait a new checkpoint
a. Wait a new checkpoint(not implemented)
b. Send LIBXL_COLO_NEW_CHECKPOINT to slave
--- tools/libxc/include/xenguest.h | 12 + tools/libxl/Makefile | 2 +- tools/libxl/libxl.c | 6 +- tools/libxl/libxl_colo.h | 10 + tools/libxl/libxl_colo_save.c | 643 +++++++++++++++++++++++++++++++++++++ tools/libxl/libxl_dom_save.c | 15 +- tools/libxl/libxl_internal.h | 31 +- tools/libxl/libxl_save_msgs_gen.pl | 1 + tools/libxl/libxl_types.idl | 1 + 9 files changed, 712 insertions(+), 9 deletions(-) create mode 100644 tools/libxl/libxl_colo_save.c
tools/libxc/include/xenguest.h +12 -0
@@ -75,6 +75,18 @@ struct save_callbacks {*/ int (*toolstack_save)(uint32_t domid,uint8_t **buf,uint32_t *len,void *data); +/* Called after the guest is suspended. +* +* returns the list of dirty pfn: +* struct { +* uint64_t count; +* uint64_t pfn[]; +* }; +* +* Note: the caller must free the return value. +*/ +uint8_t *(*get_dirty_pfn)(void *data); +/* to be provided as the last argument to each callback function */ void * data; };
tools/libxl/Makefile +1 -1
@@ -57,7 +57,7 @@ LIBXL_OBJS-y += libxl_nonetbuffer.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
@@ -841,7 +842,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 +10 -0
@@ -35,4 +35,14 @@ extern void libxl__colo_restore_teardown(libxl__egc *egc,libxl__colo_restore_state *crs, int rc); +extern void libxl__colo_save_domain_suspend_callback (void *data); +extern void libxl__colo_save_domain_resume_callback (void *data); +extern void libxl__colo_save_domain_checkpoint_callback (void *data); +extern void libxl__colo_save_get_dirty_pfn_callback (void *data); +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 +643 -0
643 lines not on this page · raw message
tools/libxl/libxl_dom_save.c +12 -3
@@ -16,6 +16,7 @@#include "libxl_osdeps.h" /* must come before any other headers */ #include "libxl_internal.h" +#include "libxl_colo.h" struct libxl__physmap_info {uint64_t phys_offset;
@@ -426,7 +427,12 @@ void libxl__domain_save(libxl__egc *egc, libxl__domain_save_state *dss) }memset (callbacks,0 ,sizeof (*callbacks)); -if (r_info !=NULL ) { +if (r_info !=NULL &&libxl_defbool_val (r_info->colo)) { + callbacks->suspend = libxl__colo_save_domain_suspend_callback; + callbacks->postcopy = libxl__colo_save_domain_resume_callback; + callbacks->checkpoint = libxl__colo_save_domain_checkpoint_callback; + callbacks->get_dirty_pfn = libxl__colo_save_get_dirty_pfn_callback; + }else if (r_info !=NULL ) { callbacks->suspend = libxl__remus_domain_suspend_callback; callbacks->postcopy = libxl__remus_domain_resume_callback; callbacks->checkpoint = libxl__remus_domain_checkpoint_callback;
@@ -595,12 +601,15 @@ static void domain_save_done(libxl__egc *egc, }/* -* 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); }/*==================== Domain restore ====================*/
tools/libxl/libxl_internal.h +27 -4
@@ -2653,7 +2653,7 @@ typedef struct libxl__save_helper_state {/* * The abstract checkpoint device layer exposes a common * set of API to [external] libxl for manipulating devices attached to -* a guest protected by Remus. The device layer also exposes a set of +* a guest protected by Remus/COLO. The device layer also exposes a set of * [internal] interfaces that every device type must implement. * * The following API are exposed to libxl:
@@ -2671,7 +2671,7 @@ typedef struct libxl__save_helper_state {* +libxl__checkpoint_devices_commit * * Each device type needs to implement the interfaces specified in -* the libxl__checkpoint_device_instance_ops if it wishes to support Remus. +* the libxl__checkpoint_device_instance_ops if it wishes to support Remus/COLO. * * The high-level control flow through the checkpoint device layer is shown * below:
@@ -2691,7 +2691,7 @@ typedef struct libxl__checkpoint_device_instance_ops libxl__checkpoint_device_in/* * Interfaces to be implemented by every device subkind that wishes to -* support Remus. Functions must be implemented unless otherwise +* support Remus/COLO. Functions must be implemented unless otherwise * stated. Many of these functions are asynchronous. They call * dev->aodev.callback when done. The actual implementations may be * synchronous and call dev->aodev.callback directly (as the last
@@ -2841,6 +2841,24 @@ struct libxl__remus_state { }; _hidden int libxl__netbuffer_enabled(libxl__gc *gc); +/*----- colo related state structure -----*/ +typedef struct libxl__colo_save_state libxl__colo_save_state ; +struct libxl__colo_save_state { +libxl__checkpoint_devices_state cds; +int send_fd; +int recv_fd; + +/* private */ +libxl__datacopier_state dc; +uint8_t section; +uint64_t count; +uint64_t *buff; +/* read section and count, and then store it in temp_buff */ +uint8_t temp_buff[9 ]; +void (*callback)(libxl__egc *,libxl__colo_save_state *); +bool svm_running; +}; +/*----- Domain suspend (save) state structure -----*/ typedef struct libxl__domain_suspend_state libxl__domain_suspend_state ;
@@ -2900,7 +2918,12 @@ struct libxl__domain_save_state {libxl__domain_suspend_state dsps;int hvm;int xcflags; -libxl__remus_state rs; +union { +/* for Remus */ +libxl__remus_state rs; +/* for COLO */ +libxl__colo_save_state css; + };libxl__save_helper_state shs;libxl__logdirty_switch logdirty;/* private for libxl__domain_save_device_model */
tools/libxl/libxl_save_msgs_gen.pl +1 -0
@@ -36,6 +36,7 @@ our @msgs = ( 'unsigned long', 'console_mfn'] ], [ 9, 'srW', "complete", [qw(int retval int errnoval)] ], + [ 10, 'scxAB', "get_dirty_pfn", [] ], ); #----------------------------------------
tools/libxl/libxl_types.idl +1 -0
@@ -695,6 +695,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
1.9.1
Re: [PATCH v6 COLO 03/15] primary vm suspend/get_dirty_pfn/resume/checkpoint code
Quoted 5 lines · Yang Hongyang
tools/libxc/include/xenguest.h +0
-0
tools/libxc/include/xenguest.h struct save_callbacks { · line 84
Quoted 10 lines
tools/libxc/include/xenguest.h +7
-0@@ -75,6 +75,18 @@ struct save_callbacks {*/ int (*toolstack_save)(uint32_t domid,uint8_t **buf,uint32_t *len,void *data); +/* Called after the guest is suspended. +* +* returns the list of dirty pfn: +* struct { +* uint64_t count; +* uint64_t pfn[]; +* };
Seeing this comment and then a callback which returns a uint8_t* makes me suspicious. Can we not do something a bit more typesafe here, like returning a pointer to a suitable struct?
Quoted 21 lines
tools/libxc/include/xenguest.h +5
-0+* +* Note: the caller must free the return value. +*/ +uint8_t *(*get_dirty_pfn)(void *data); +/* to be provided as the last argument to each callback function */ void * data; };tools/libxl/libxl.c +1
-0@@ -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
tools/libxl/libxl.c int libxl_domain_remus_start(libxl_ctx *ctx, libxl_domain_remus_info *info, · line 845
Quoted 5 lines
tools/libxl/libxl.c +1
-1@@ -841,7 +842,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 code must arrange to have called libxl_defbool_setdefault before using libxl_defbool_val, which I don't see here. There is a big block of such settings near the top of this function which you should add to.
On the other hand -- is it possible for a caller to say they don't care what kind of check pointing they want and have libxl decide? If not then it doesn't make sense to use a defbool, a regular bool would be appropriate.
I'm also wondering to what extent COLO could be considered an extension to Remus, as opposed to an alternative -- iow I'm unsure if reusing libxl_domain_remus_start as the API makes sense (the implementation could still be shared where appropriate).
Quoted 7 lines
tools/libxl/libxl_colo.h +0
-0@@ -35,4 +35,14 @@ extern void libxl__colo_restore_teardown(libxl__egc *egc,libxl__colo_restore_state *crs, int rc);
tools/libxl/libxl_colo.h extern void libxl__colo_restore_teardown(libxl__egc *egc, · line 46
Quoted 10 lines
tools/libxl/libxl_colo.h +9
-0+extern void libxl__colo_save_domain_suspend_callback (void *data); +extern void libxl__colo_save_domain_resume_callback (void *data); +extern void libxl__colo_save_domain_checkpoint_callback (void *data); +extern void libxl__colo_save_get_dirty_pfn_callback (void *data); +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);
Should all be marked _hidden I think?
[...]
PATCH v6 4/15 libxc/restore: support COLO restore
In reply to Yang Hongyangcall the callbacks resume/checkpoint/suspend while secondary vm status is consistent with primary.
--- tools/libxc/xc_sr_common.h | 11 +++++-- tools/libxc/xc_sr_restore.c | 63 ++++++++++++++++++++++++++++++++++++- tools/libxc/xc_sr_restore_x86_hvm.c | 1 + 3 files changed, 72 insertions(+), 3 deletions(-)
tools/libxc/xc_sr_common.h +9 -2
@@ -132,8 +132,11 @@ struct xc_sr_restore_ops* * @return 0 for success, -1 for failure, or the sentinel value * RECORD_NOT_PROCESSED. +* BROKEN_CHANNEL: if we are under Remus/COLO, this means master may dead, +* we will failover. */ #define RECORD_NOT_PROCESSED 1 +#define BROKEN_CHANNEL 2int (*process_record)(struct xc_sr_context *ctx,struct xc_sr_record *rec);/**
@@ -205,8 +208,12 @@ struct xc_sr_contextuint32_t guest_type;uint32_t guest_page_size; -/* Plain VM, or checkpoints over time. */ -bool checkpointed; +/* +* 0: Plain VM +* 1: Remus +* 2: COLO +*/ +int checkpointed;/* Currently buffering records between a checkpoint */ bool buffer_all_records;
tools/libxc/xc_sr_restore.c +62 -1
97 lines not on this page · raw message
tools/libxc/xc_sr_restore_x86_hvm.c +1 -0
@@ -181,6 +181,7 @@ static int handle_qemu(struct xc_sr_context *ctx)if ( fp )fclose (fp);free (qbuf); + ctx->x86_hvm.restore.qbuf =NULL ;return rc; }
Signature · 1 line
1.9.1
Re: [PATCH v6 COLO 04/15] libxc/restore: support COLO restore
Quoted 17 lines · Yang Hongyang
call the callbacks resume/checkpoint/suspend while secondary vm status is consistent with primary.
Signed-off-by Yang Hongyang <[email protected]>Signed-off-by Wen Congyang <[email protected]>CC Andrew Cooper <[email protected]>--- tools/libxc/xc_sr_common.h | 11 +++++-- tools/libxc/xc_sr_restore.c | 63 ++++++++++++++++++++++++++++++++++++- tools/libxc/xc_sr_restore_x86_hvm.c | 1 + 3 files changed, 72 insertions(+), 3 deletions(-)tools/libxc/xc_sr_common.h +0
-0
tools/libxc/xc_sr_common.h struct xc_sr_restore_ops · line 136
Quoted 5 lines
tools/libxc/xc_sr_common.h +2
-0@@ -132,8 +132,11 @@ struct xc_sr_restore_ops* * @return 0 for success, -1 for failure, or the sentinel value * RECORD_NOT_PROCESSED. +* BROKEN_CHANNEL: if we are under Remus/COLO, this means master may dead, +* we will failover.
"this means that the master"
Quoted 8 lines
tools/libxc/xc_sr_common.h +1
-0*/ #define RECORD_NOT_PROCESSED 1 +#define BROKEN_CHANNEL 2int (*process_record)(struct xc_sr_context *ctx,struct xc_sr_record *rec);/** @@ -205,8 +208,12 @@ struct xc_sr_contextuint32_t guest_type;
tools/libxc/xc_sr_common.h struct xc_sr_context · line 216
Quoted 10 lines
tools/libxc/xc_sr_common.h +6
-2uint32_t guest_page_size; -/* Plain VM, or checkpoints over time. */ -bool checkpointed; +/* +* 0: Plain VM +* 1: Remus +* 2: COLO +*/ +int checkpointed;
I think this would be nicer as
enum {STREAM_PLAIN,STREAM_REMUS,STREAM_COLO,
} stream;
perhaps? It would reduce the use of a magic 2 in the code.
Quoted 23 lines
tools/libxc/xc_sr_common.h +0
-0/* Currently buffering records between a checkpoint */ bool buffer_all_records;tools/libxc/xc_sr_restore.c +2
-1@@ -1,4 +1,5 @@#include <arpa/inet.h> +#include <assert.h> #include "xc_sr_common.h" @@ -472,7 +473,7 @@ static int process_record(struct xc_sr_context *ctx, struct xc_sr_record *rec);static int handle_checkpoint (struct xc_sr_context *ctx) {xc_interface *xch = ctx->xch; -int rc =0 ; +int rc =0 , ret;unsigned i;if ( !ctx->restore.checkpointed )
tools/libxc/xc_sr_restore.c static int handle_checkpoint(struct xc_sr_context *ctx) · line 504
Quoted 6 lines
tools/libxc/xc_sr_restore.c +3
-0@@ -498,6 +499,46 @@ static int handle_checkpoint(struct xc_sr_context *ctx)else ctx->restore.buffer_all_records = true; +if ( ctx->restore.checkpointed ==2 ) + { +#define HANDLE_CALLBACK_RETURN_VALUE (ret) \
I would ideally like to avoid macros like this in an effort to avoid the code slipping back into the state that the legacy code was in, but at least it is local to the area used.
Quoted 4 lines
tools/libxc/xc_sr_restore.c +4
-0+ do { \ + if ( ret == 0 ) \ + { \ + /* Some internal error happens */ \
tools/libxc/xc_sr_restore.c static int handle_checkpoint(struct xc_sr_context *ctx) · line 518
Quoted 10 lines
tools/libxc/xc_sr_restore.c +10
-0+ rc =-1 ; \ + goto err; \ + } \ +else if ( ret ==2 ) \ + { \ +/* Reading/writing error, do failover */ \ + rc =BROKEN_CHANNEL ; \ + goto err; \ + } \ + }while (0 )
This should have the logic inverted somewhat, to cover all possible values of ret, including the negative half.
e.g.
if ( ret == 1 )
rc = 0; /* Success */
else
{
if ( ret == 2 )
rc = BROKEN_CHANNEL;
else
rc = -1; /* Some unspecified error */
goto err;
}Quoted 11 lines
tools/libxc/xc_sr_restore.c +11
-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 */
tools/libxc/xc_sr_restore.c static int handle_checkpoint(struct xc_sr_context *ctx) · line 539
Quoted 10 lines
tools/libxc/xc_sr_restore.c +10
-0+ ret = ctx->restore.callbacks->postcopy (ctx->restore.callbacks->data); +HANDLE_CALLBACK_RETURN_VALUE (ret); + +/* wait for new checkpoint */ + ret = ctx->restore.callbacks->checkpoint (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);
Please #undef HANDLE_CALLBACK_RETURN_VALUE here.
Quoted 31 lines
tools/libxc/xc_sr_restore.c +13
-0+ } + err:return rc; }@@ -678,6 +719,8 @@ static int restore(struct xc_sr_context *ctx) goto err; } } +else if ( rc ==BROKEN_CHANNEL ) + goto remus_failover;else if ( rc ) goto err; }@@ -685,6 +728,15 @@ static int restore(struct xc_sr_context *ctx) }while ( rec.type !=REC_TYPE_END ); remus_failover: + +if ( ctx->restore.checkpointed ==2 ) + { +/* With COLO, we have already called stream_complete */ + rc =0 ; +IPRINTF ("COLO Failover" ); + goto done; + } +/* * With Remus, if we reach here, there must be some error on primary, * failover from the last checkpoint state.
tools/libxc/xc_sr_restore.c int xc_domain_restore2(xc_interface *xch, int io_fd, uint32_t dom, · line 796
Quoted 10 lines
tools/libxc/xc_sr_restore.c +7
-0@@ -735,6 +787,15 @@ int xc_domain_restore2(xc_interface *xch, int io_fd, uint32_t dom, ctx.restore.checkpointed = checkpointed_stream; ctx.restore.callbacks = callbacks; +/* Sanity checks for callbacks. */ +if ( ctx.restore.checkpointed ==2 ) + { +/* this is COLO restore */ +assert (callbacks->suspend && + callbacks->checkpoint && + callbacks->postcopy);
FWIW, I need to make the ->checkpoint() callback used even in the remus case for qemu handling in libxl migration v2.
Quoted 10 lines
tools/libxc/xc_sr_restore.c +2
-0+ } +IPRINTF ("In experimental %s" , __func__); DPRINTF("fd %d, dom %u, hvm %u, pae %u, superpages %d" ", checkpointed_stream %d", io_fd, dom, hvm, pae,tools/libxc/xc_sr_restore_x86_hvm.c +0
-0
tools/libxc/xc_sr_restore_x86_hvm.c static int handle_qemu(struct xc_sr_context *ctx) · line 184
Quoted 4 lines
tools/libxc/xc_sr_restore_x86_hvm.c +1
-0@@ -181,6 +181,7 @@ static int handle_qemu(struct xc_sr_context *ctx)if ( fp )fclose (fp);free (qbuf); + ctx->x86_hvm.restore.qbuf =NULL ;
This looks like an unrelated bugfix.
~Andrew
Quoted 3 lines
tools/libxc/xc_sr_restore_x86_hvm.c +0
-0return rc; }
Re: [PATCH v6 COLO 04/15] libxc/restore: support COLO restore
Quoted 13 lines · Andrew Cooper
Quoted 12 lines · Yang Hongyang
call the callbacks resume/checkpoint/suspend while secondary vm status is consistent with primary.
Signed-off-by Yang Hongyang <[email protected]>Signed-off-by Wen Congyang <[email protected]>CC Andrew Cooper <[email protected]>--- tools/libxc/xc_sr_common.h | 11 +++++-- tools/libxc/xc_sr_restore.c | 63 ++++++++++++++++++++++++++++++++++++- tools/libxc/xc_sr_restore_x86_hvm.c | 1 + 3 files changed, 72 insertions(+), 3 deletions(-)
Quoted 12 lines
tools/libxc/xc_sr_common.h struct xc_sr_restore_ops · line 136
Quoted 10 lines
tools/libxc/xc_sr_common.h +2
-0@@ -132,8 +132,11 @@ struct xc_sr_restore_ops* * @return 0 for success, -1 for failure, or the sentinel value * RECORD_NOT_PROCESSED. +* BROKEN_CHANNEL: if we are under Remus/COLO, this means master may dead, +* we will failover. "this means that the master"
Thanks.
Quoted 22 lines
Quoted 9 lines
tools/libxc/xc_sr_common.h +1
-0*/ #define RECORD_NOT_PROCESSED 1 +#define BROKEN_CHANNEL 2int (*process_record)(struct xc_sr_context *ctx,struct xc_sr_record *rec);/** @@ -205,8 +208,12 @@ struct xc_sr_contextuint32_t guest_type;tools/libxc/xc_sr_common.h struct xc_sr_context · line 216
Quoted 10 lines
tools/libxc/xc_sr_common.h +6
-2uint32_t guest_page_size; -/* Plain VM, or checkpoints over time. */ -bool checkpointed; +/* +* 0: Plain VM +* 1: Remus +* 2: COLO +*/ +int checkpointed;I think this would be nicer as
Quoted 7 lines
enum {
STREAM_PLAIN,STREAM_REMUS,STREAM_COLO,
} stream;perhaps? It would reduce the use of a magic 2 in the code.
This is another place that I missed, good catch, and it's better, thank you.
Quoted 50 lines
Quoted 24 lines
tools/libxc/xc_sr_common.h +0
-0/* Currently buffering records between a checkpoint */ bool buffer_all_records;tools/libxc/xc_sr_restore.c +2
-1@@ -1,4 +1,5 @@#include <arpa/inet.h> +#include <assert.h> #include "xc_sr_common.h" @@ -472,7 +473,7 @@ static int process_record(struct xc_sr_context *ctx, struct xc_sr_record *rec);static int handle_checkpoint (struct xc_sr_context *ctx) {xc_interface *xch = ctx->xch; -int rc =0 ; +int rc =0 , ret;unsigned i;if ( !ctx->restore.checkpointed )tools/libxc/xc_sr_restore.c static int handle_checkpoint(struct xc_sr_context *ctx) · line 504
Quoted 6 lines
tools/libxc/xc_sr_restore.c +3
-0@@ -498,6 +499,46 @@ static int handle_checkpoint(struct xc_sr_context *ctx)else ctx->restore.buffer_all_records = true; +if ( ctx->restore.checkpointed ==2 ) + { +#define HANDLE_CALLBACK_RETURN_VALUE (ret) \I would ideally like to avoid macros like this in an effort to avoid the code slipping back into the state that the legacy code was in, but at least it is local to the area used.
Quoted 4 lines
tools/libxc/xc_sr_restore.c +4
-0+ do { \ + if ( ret == 0 ) \ + { \ + /* Some internal error happens */ \tools/libxc/xc_sr_restore.c static int handle_checkpoint(struct xc_sr_context *ctx) · line 518
Quoted 10 lines
tools/libxc/xc_sr_restore.c +10
-0+ rc =-1 ; \ + goto err; \ + } \ +else if ( ret ==2 ) \ + { \ +/* Reading/writing error, do failover */ \ + rc =BROKEN_CHANNEL ; \ + goto err; \ + } \ + }while (0 )
Quoted 2 lines
This should have the logic inverted somewhat, to cover all possible values of ret, including the negative half.
yes, will fix in the next version.
Quoted 29 lines
e.g.
if ( ret == 1 )
rc = 0; /* Success */ else { if ( ret == 2 ) rc = BROKEN_CHANNEL; else rc = -1; /* Some unspecified error */ goto err; }Quoted 15 lines
tools/libxc/xc_sr_restore.c +15
-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 new checkpoint */
Quoted 8 lines
tools/libxc/xc_sr_restore.c static int handle_checkpoint(struct xc_sr_context *ctx) · line 539
Quoted 6 lines
tools/libxc/xc_sr_restore.c +6
-0+ ret = ctx->restore.callbacks->checkpoint (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);Please #undef
HANDLE_CALLBACK_RETURN_VALUEhere.
OK.
Quoted 35 lines
Quoted 35 lines
tools/libxc/xc_sr_restore.c +13
-0+ } + err:return rc; }@@ -678,6 +719,8 @@ static int restore(struct xc_sr_context *ctx) goto err; } } +else if ( rc ==BROKEN_CHANNEL ) + goto remus_failover;else if ( rc ) goto err; }@@ -685,6 +728,15 @@ static int restore(struct xc_sr_context *ctx) }while ( rec.type !=REC_TYPE_END ); remus_failover: + +if ( ctx->restore.checkpointed ==2 ) + { +/* With COLO, we have already called stream_complete */ + rc =0 ; +IPRINTF ("COLO Failover" ); + goto done; + } +/* * With Remus, if we reach here, there must be some error on primary, * failover from the last checkpoint state. @@ -735,6 +787,15 @@ int xc_domain_restore2(xc_interface *xch, int io_fd, uint32_t dom, ctx.restore.checkpointed = checkpointed_stream; ctx.restore.callbacks = callbacks;
Quoted 10 lines
tools/libxc/xc_sr_restore.c int xc_domain_restore2(xc_interface *xch, int io_fd, uint32_t dom, · line 796
Quoted 7 lines
tools/libxc/xc_sr_restore.c +7
-0+/* Sanity checks for callbacks. */ +if ( ctx.restore.checkpointed ==2 ) + { +/* this is COLO restore */ +assert (callbacks->suspend && + callbacks->checkpoint && + callbacks->postcopy);FWIW, I need to make the ->checkpoint() callback used even in the remus case for qemu handling in libxl migration v2.
So this should be move out in libxl migration v2 support.
Quoted 17 lines
Quoted 11 lines
tools/libxc/xc_sr_restore.c +2
-0+ } +IPRINTF ("In experimental %s" , __func__); DPRINTF("fd %d, dom %u, hvm %u, pae %u, superpages %d" ", checkpointed_stream %d", io_fd, dom, hvm, pae,tools/libxc/xc_sr_restore_x86_hvm.c +0
-0tools/libxc/xc_sr_restore_x86_hvm.c static int handle_qemu(struct xc_sr_context *ctx) · line 184
Quoted 4 lines
tools/libxc/xc_sr_restore_x86_hvm.c +1
-0@@ -181,6 +181,7 @@ static int handle_qemu(struct xc_sr_context *ctx)if ( fp )fclose (fp);free (qbuf); + ctx->x86_hvm.restore.qbuf =NULL ;This looks like an unrelated bugfix.
Yes, this is a bugfix. It won't trigger when in normal migration or Remus, but in colo case, this will cause error because handle_qemu will be called multiple times.
Quoted 9 lines
~Andrew
tools/libxc/xc_sr_restore_x86_hvm.c static int handle_qemu(struct xc_sr_context *ctx) · line 186
Quoted 3 lines
tools/libxc/xc_sr_restore_x86_hvm.c +0
-0return rc; }.
Signature · 2 lines
Thanks, Yang.
PATCH v6 5/15 send store mfn and console mfn to xl before resuming secondary vm
In reply to Yang HongyangFrom: Wen Congyang <[email protected]>
We will call libxl__xc_domain_restore_done() to rebuild secondary vm. But we need store mfn and console mfn when rebuilding secondary vm. So make restore_results is a function pointers in callbacks struct and struct {save,restore}_callbacks, and use this callback to send store mfn and console mfn to xl.
--- tools/libxc/include/xenguest.h | 8 ++++++++ tools/libxc/xc_sr_restore.c | 8 ++++++-- tools/libxl/libxl_colo_restore.c | 5 ----- tools/libxl/libxl_create.c | 1 + tools/libxl/libxl_save_msgs_gen.pl | 2 +- 5 files changed, 16 insertions(+), 8 deletions(-)
tools/libxc/include/xenguest.h +8 -0
@@ -130,6 +130,14 @@ struct restore_callbacks {/* Enable qemu-dm logging dirty pages to xen */ int (*switch_qemu_logdirty)(int domid,unsigned enable,void *data);/* HVM only */ +/* +* callback to send store mfn and console mfn to xl +* if we want to resume vm before xc_domain_save() +* exits. +*/ +void (*restore_results)(unsigned long store_mfn,unsigned long console_mfn, +void *data); +/* callback to restore toolstack specific data */ int (*toolstack_restore)(uint32_t domid,const uint8_t *buf,uint32_t size,void * data);
tools/libxc/xc_sr_restore.c +6 -2
@@ -524,7 +524,10 @@ static int handle_checkpoint(struct xc_sr_context *ctx)if ( rc ) goto err; -/* TODO: call restore_results */ +/* 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);
@@ -793,7 +796,8 @@ int xc_domain_restore2(xc_interface *xch, int io_fd, uint32_t dom,/* this is COLO restore */ assert (callbacks->suspend && callbacks->checkpoint && - callbacks->postcopy); + callbacks->postcopy && + callbacks->restore_results); }IPRINTF ("In experimental %s" , __func__);
tools/libxl/libxl_colo_restore.c +0 -5
@@ -153,11 +153,6 @@ static void colo_resume_vm(libxl__egc *egc,return ; } -/* -* TODO: get store mfn and console mfn -* 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 +1 -0
@@ -1157,6 +1157,7 @@ static void domcreate_bootloader_done(libxl__egc *egc, rc =ERROR_INVAL ; goto out; } + callbacks->restore_results = libxl__srm_callout_callback_restore_results;if (checkpointed_stream ==LIBXL_CHECKPOINTED_STREAM_COLO ) { crs->ao = ao;
tools/libxl/libxl_save_msgs_gen.pl +1 -1
@@ -32,7 +32,7 @@ our @msgs = ( # toolstack_save done entirely `by hand' [ 7, 'rcxW', "toolstack_restore", [qw(uint32_t domid BLOCK tsdata)] ], - [ 8, 'r', "restore_results", ['unsigned long', 'store_mfn', + [ 8, 'rcx', "restore_results", ['unsigned long', 'store_mfn', 'unsigned long', 'console_mfn'] ], [ 9, 'srW', "complete", [qw(int retval int errnoval)] ],
Signature · 1 line
1.9.1
Re: [PATCH v6 COLO 05/15] send store mfn and console mfn to xl before resuming secondary vm
Quoted 43 lines · Yang Hongyang
From: Wen Congyang <[email protected]>
We will call
libxl__xc_domain_restore_done()to rebuild secondary vm. But we need store mfn and console mfn when rebuilding secondary vm. So makerestore_resultsis a function pointers in callbacks struct and struct {save,restore}_callbacks, and use this callback to send store mfn and console mfn to xl.Signed-off-by Wen Congyang <[email protected]>Signed-off-by Yang Hongyang <[email protected]>CC Andrew Cooper <[email protected]>--- tools/libxc/include/xenguest.h | 8 ++++++++ tools/libxc/xc_sr_restore.c | 8 ++++++-- tools/libxl/libxl_colo_restore.c | 5 ----- tools/libxl/libxl_create.c | 1 + tools/libxl/libxl_save_msgs_gen.pl | 2 +- 5 files changed, 16 insertions(+), 8 deletions(-)tools/libxc/include/xenguest.h +8
-0@@ -130,6 +130,14 @@ struct restore_callbacks {/* Enable qemu-dm logging dirty pages to xen */ int (*switch_qemu_logdirty)(int domid,unsigned enable,void *data);/* HVM only */ +/* +* callback to send store mfn and console mfn to xl +* if we want to resume vm before xc_domain_save() +* exits. +*/ +void (*restore_results)(unsigned long store_mfn,unsigned long console_mfn, +void *data); +/* callback to restore toolstack specific data */ int (*toolstack_restore)(uint32_t domid,const uint8_t *buf,uint32_t size,void * data);tools/libxc/xc_sr_restore.c +0
-0
tools/libxc/xc_sr_restore.c static int handle_checkpoint(struct xc_sr_context *ctx) · line 527
Quoted 5 lines
tools/libxc/xc_sr_restore.c +1
-1@@ -524,7 +524,10 @@ static int handle_checkpoint(struct xc_sr_context *ctx)if ( rc ) goto err; -/* TODO: call restore_results */ +/* call restore_results */
I would drop this comment. It is entirely redundant now.
Otherwise, looks good.
~Andrew
Quoted 57 lines
tools/libxc/xc_sr_restore.c +5
-1+ 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);@@ -793,7 +796,8 @@ int xc_domain_restore2(xc_interface *xch, int io_fd, uint32_t dom,/* this is COLO restore */ assert (callbacks->suspend && callbacks->checkpoint && - callbacks->postcopy); + callbacks->postcopy && + callbacks->restore_results); }IPRINTF ("In experimental %s" , __func__);tools/libxl/libxl_colo_restore.c +0
-5@@ -153,11 +153,6 @@ static void colo_resume_vm(libxl__egc *egc,return ; } -/* -* TODO: get store mfn and console mfn -* 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 +1
-0@@ -1157,6 +1157,7 @@ static void domcreate_bootloader_done(libxl__egc *egc, rc =ERROR_INVAL ; goto out; } + callbacks->restore_results = libxl__srm_callout_callback_restore_results;if (checkpointed_stream ==LIBXL_CHECKPOINTED_STREAM_COLO ) { crs->ao = ao;tools/libxl/libxl_save_msgs_gen.pl +1
-1@@ -32,7 +32,7 @@ our @msgs = ( # toolstack_save done entirely `by hand' [ 7, 'rcxW', "toolstack_restore", [qw(uint32_t domid BLOCK tsdata)] ], - [ 8, 'r', "restore_results", ['unsigned long', 'store_mfn', + [ 8, 'rcx', "restore_results", ['unsigned long', 'store_mfn', 'unsigned long', 'console_mfn'] ], [ 9, 'srW', "complete", [qw(int retval int errnoval)] ],
Re: [PATCH v6 COLO 05/15] send store mfn and console mfn to xl before resuming secondary vm
Quoted 47 lines · Andrew Cooper
Quoted 46 lines · Yang Hongyang
From: Wen Congyang <[email protected]>
We will call
libxl__xc_domain_restore_done()to rebuild secondary vm. But we need store mfn and console mfn when rebuilding secondary vm. So makerestore_resultsis a function pointers in callbacks struct and struct {save,restore}_callbacks, and use this callback to send store mfn and console mfn to xl.Signed-off-by Wen Congyang <[email protected]>Signed-off-by Yang Hongyang <[email protected]>CC Andrew Cooper <[email protected]>--- tools/libxc/include/xenguest.h | 8 ++++++++ tools/libxc/xc_sr_restore.c | 8 ++++++-- tools/libxl/libxl_colo_restore.c | 5 ----- tools/libxl/libxl_create.c | 1 + tools/libxl/libxl_save_msgs_gen.pl | 2 +- 5 files changed, 16 insertions(+), 8 deletions(-)tools/libxc/include/xenguest.h +8
-0@@ -130,6 +130,14 @@ struct restore_callbacks {/* Enable qemu-dm logging dirty pages to xen */ int (*switch_qemu_logdirty)(int domid,unsigned enable,void *data);/* HVM only */ +/* +* callback to send store mfn and console mfn to xl +* if we want to resume vm before xc_domain_save() +* exits. +*/ +void (*restore_results)(unsigned long store_mfn,unsigned long console_mfn, +void *data); +/* callback to restore toolstack specific data */ int (*toolstack_restore)(uint32_t domid,const uint8_t *buf,uint32_t size,void * data);tools/libxc/xc_sr_restore.c +0
-0@@ -524,7 +524,10 @@ static int handle_checkpoint(struct xc_sr_context *ctx)if ( rc ) goto err;
Quoted 4 lines
tools/libxc/xc_sr_restore.c static int handle_checkpoint(struct xc_sr_context *ctx) · line 527
Quoted 2 lines
tools/libxc/xc_sr_restore.c +1
-1-/* TODO: call restore_results */ +/* call restore_results */ I would drop this comment. It is entirely redundant now.
will do, thanks.
Quoted 65 lines
Otherwise, looks good.
~Andrew
Quoted 49 lines
tools/libxc/xc_sr_restore.c +5
-1+ 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);@@ -793,7 +796,8 @@ int xc_domain_restore2(xc_interface *xch, int io_fd, uint32_t dom,/* this is COLO restore */ assert (callbacks->suspend && callbacks->checkpoint && - callbacks->postcopy); + callbacks->postcopy && + callbacks->restore_results); }IPRINTF ("In experimental %s" , __func__);tools/libxl/libxl_colo_restore.c +0
-5@@ -153,11 +153,6 @@ static void colo_resume_vm(libxl__egc *egc,return ; } -/* -* TODO: get store mfn and console mfn -* 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 +1
-0@@ -1157,6 +1157,7 @@ static void domcreate_bootloader_done(libxl__egc *egc, rc =ERROR_INVAL ; goto out; } + callbacks->restore_results = libxl__srm_callout_callback_restore_results;if (checkpointed_stream ==LIBXL_CHECKPOINTED_STREAM_COLO ) { crs->ao = ao;tools/libxl/libxl_save_msgs_gen.pl +0
-0tools/libxl/libxl_save_msgs_gen.pl our @msgs = ( · line 38
Quoted 8 lines
tools/libxl/libxl_save_msgs_gen.pl +1
-1@@ -32,7 +32,7 @@ our @msgs = ( # toolstack_save done entirely `by hand' [ 7, 'rcxW', "toolstack_restore", [qw(uint32_t domid BLOCK tsdata)] ], - [ 8, 'r', "restore_results", ['unsigned long', 'store_mfn', + [ 8, 'rcx', "restore_results", ['unsigned long', 'store_mfn', 'unsigned long', 'console_mfn'] ], [ 9, 'srW', "complete", [qw(int retval int errnoval)] ],.
Signature · 2 lines
Thanks, Yang.
Re: [PATCH v6 COLO 05/15] send store mfn and console mfn to xl before resuming secondary vm
In reply to Yang HongyangQuoted 5 lines · Yang Hongyang
From: Wen Congyang <[email protected]>
We will call
libxl__xc_domain_restore_done()to rebuild secondary vm. But we need store mfn and console mfn when rebuilding secondary vm. So makerestore_resultsis a function pointers in callbacks struct and struct
"...make restore_results a function pointer in callback struct...".
Quoted 2 lines
{save,restore}_callbacks, and use this callback to send store mfn and console mfn to xl.
Since those are currently returned by some other means should we deprecate/remove that path too, especially since this new call back is mandatory.
PATCH v6 6/15 libxc/save: support COLO save
In reply to Yang Hongyangcall callbacks->get_dirty_pfn() after suspend primary vm to get dirty pages on secondary vm, and send pages both dirty on primary/secondary to secondary.
--- tools/libxc/xc_sr_save.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-)
tools/libxc/xc_sr_save.c +48 -1
@@ -515,6 +515,31 @@ static int send_memory_live(struct xc_sr_context *ctx)return rc; } +static int update_dirty_bitmap (uint8_t *(*get_dirty_pfn)(void *),void *data, +unsigned long p2m_size,unsigned long *bitmap) +{ +uint64_t *pfn_list; +uint64_t count, i; +uint64_t pfn; + + pfn_list = (uint64_t *)get_dirty_pfn (data); +assert (pfn_list); + + count = pfn_list[0 ]; +for (i =0 ; i < count; i++) { + pfn = pfn_list[i +1 ]; +if (pfn > p2m_size) { + errno =EINVAL ; +return -1 ; + } + +set_bit (pfn, bitmap); + } + +free (pfn_list); +return 0 ; +} +/* * Suspend the domain and send dirty memory. * This is the last iteration of the live migration and the
@@ -555,6 +580,19 @@ 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.callbacks->get_dirty_pfn ) + { + rc =update_dirty_bitmap (ctx->save.callbacks->get_dirty_pfn, + ctx->save.callbacks->data, + ctx->save.p2m_size, + dirty_bitmap); +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;
@@ -784,7 +822,16 @@ static int save(struct xc_sr_context *ctx, uint16_t guest_type)if ( rc ) goto err; - ctx->save.callbacks->postcopy (ctx->save.callbacks->data); + rc = ctx->save.callbacks->postcopy (ctx->save.callbacks->data); +if ( !rc ) { +if ( !errno ) + { +/* Postcopy request failed (without errno, using EINVAL) */ + errno =EINVAL ; + } + rc =-1 ; + goto err; + } rc = ctx->save.callbacks->checkpoint (ctx->save.callbacks->data);if ( rc <=0 )
Signature · 1 line
1.9.1
Re: [PATCH v6 COLO 06/15] libxc/save: support COLO save
Quoted 16 lines · Yang Hongyang
call
callbacks->get_dirty_pfn()after suspend primary vm to get dirty pages on secondary vm, and send pages both dirty on primary/secondary to secondary.Signed-off-by Yang Hongyang <[email protected]>Signed-off-by Wen Congyang <[email protected]>CC Andrew Cooper <[email protected]>--- tools/libxc/xc_sr_save.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-)tools/libxc/xc_sr_save.c +0
-0
tools/libxc/xc_sr_save.c static int send_memory_live(struct xc_sr_context *ctx) · line 519
Quoted 5 lines
tools/libxc/xc_sr_save.c +2
-0@@ -515,6 +515,31 @@ static int send_memory_live(struct xc_sr_context *ctx)return rc; } +static int update_dirty_bitmap (uint8_t *(*get_dirty_pfn)(void *),void *data, +unsigned long p2m_size,unsigned long *bitmap)
This function should take a ctx rather than having the caller expand 3 parameters. Also, "update_dirty_bitmap" is a little misleading, as it isn't querying the hypervisor for the dirty bitmap.
tools/libxc/xc_sr_save.c static int send_memory_live(struct xc_sr_context *ctx) · line 525
Quoted 6 lines
tools/libxc/xc_sr_save.c +6
-0+{ +uint64_t *pfn_list; +uint64_t count, i; +uint64_t pfn; + + pfn_list = (uint64_t *)get_dirty_pfn (data);
This looks like a recipe for width-errors. The get_dirty_pfn() call should take a pointer to a struct for it to fill.
tools/libxc/xc_sr_save.c static int send_memory_live(struct xc_sr_context *ctx) · line 526
Quoted 1 line
tools/libxc/xc_sr_save.c +1
-0+assert (pfn_list);
This should turn into an error rather than an abort().
tools/libxc/xc_sr_save.c static int send_memory_live(struct xc_sr_context *ctx) · line 529
Quoted 3 lines
tools/libxc/xc_sr_save.c +3
-0+ + count = pfn_list[0 ]; +for (i =0 ; i < count; i++) {
style
Quoted 17 lines
tools/libxc/xc_sr_save.c +13
-0+ pfn = pfn_list[i +1 ]; +if (pfn > p2m_size) { + errno =EINVAL ; +return -1 ; + } + +set_bit (pfn, bitmap); + } + +free (pfn_list); +return 0 ; +} +/* * Suspend the domain and send dirty memory. * This is the last iteration of the live migration and the
tools/libxc/xc_sr_save.c static int suspend_and_send_dirty(struct xc_sr_context *ctx) · line 584
Quoted 5 lines
tools/libxc/xc_sr_save.c +2
-0@@ -555,6 +580,19 @@ 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.callbacks->get_dirty_pfn ) + {
Shouldn't get_dirty_pfn be mandatory for COLO streams (even if it is a noop to start with) ?
~Andrew
Quoted 32 lines
tools/libxc/xc_sr_save.c +21
-1+ rc =update_dirty_bitmap (ctx->save.callbacks->get_dirty_pfn, + ctx->save.callbacks->data, + ctx->save.p2m_size, + dirty_bitmap); +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;@@ -784,7 +822,16 @@ static int save(struct xc_sr_context *ctx, uint16_t guest_type)if ( rc ) goto err; - ctx->save.callbacks->postcopy (ctx->save.callbacks->data); + rc = ctx->save.callbacks->postcopy (ctx->save.callbacks->data); +if ( !rc ) { +if ( !errno ) + { +/* Postcopy request failed (without errno, using EINVAL) */ + errno =EINVAL ; + } + rc =-1 ; + goto err; + } rc = ctx->save.callbacks->checkpoint (ctx->save.callbacks->data);if ( rc <=0 )
Re: [PATCH v6 COLO 06/15] libxc/save: support COLO save
Quoted 20 lines · Andrew Cooper
Quoted 19 lines · Yang Hongyang
call
callbacks->get_dirty_pfn()after suspend primary vm to get dirty pages on secondary vm, and send pages both dirty on primary/secondary to secondary.Signed-off-by Yang Hongyang <[email protected]>Signed-off-by Wen Congyang <[email protected]>CC Andrew Cooper <[email protected]>--- tools/libxc/xc_sr_save.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-)tools/libxc/xc_sr_save.c +0
-0@@ -515,6 +515,31 @@ static int send_memory_live(struct xc_sr_context *ctx)return rc; }
Quoted 6 lines
tools/libxc/xc_sr_save.c static int send_memory_live(struct xc_sr_context *ctx) · line 519
Quoted 2 lines
tools/libxc/xc_sr_save.c +2
-0+static int update_dirty_bitmap (uint8_t *(*get_dirty_pfn)(void *),void *data, +unsigned long p2m_size,unsigned long *bitmap)This function should take a ctx rather than having the caller expand 3 parameters. Also, "
update_dirty_bitmap" is a little misleading, as it isn't querying the hypervisor for the dirty bitmap.
ok.
Quoted 10 lines
tools/libxc/xc_sr_save.c static int send_memory_live(struct xc_sr_context *ctx) · line 525
Quoted 7 lines
tools/libxc/xc_sr_save.c +6
-0+{ +uint64_t *pfn_list; +uint64_t count, i; +uint64_t pfn; + + pfn_list = (uint64_t *)get_dirty_pfn (data);This looks like a recipe for width-errors. The
get_dirty_pfn()call should take a pointer to a struct for it to fill.
but the size is unknown for the caller.pfn_list[0] is the count of pfn.
Quoted 4 lines
tools/libxc/xc_sr_save.c static int send_memory_live(struct xc_sr_context *ctx) · line 526
Quoted 2 lines
tools/libxc/xc_sr_save.c +1
-0+assert (pfn_list);This should turn into an error rather than an
abort().
Even if there are no dirty pages on secondary, pfn_list shouldn't be NULL, it's just that pfn_list[0] will be 0. if pfn_list is NULL, there might be unexpected error happened.
Quoted 25 lines
tools/libxc/xc_sr_save.c static int send_memory_live(struct xc_sr_context *ctx) · line 529
Quoted 4 lines
tools/libxc/xc_sr_save.c +3
-0+ + count = pfn_list[0 ]; +for (i =0 ; i < count; i++) {style
Quoted 18 lines
tools/libxc/xc_sr_save.c +13
-0+ pfn = pfn_list[i +1 ]; +if (pfn > p2m_size) { + errno =EINVAL ; +return -1 ; + } + +set_bit (pfn, bitmap); + } + +free (pfn_list); +return 0 ; +} +/* * Suspend the domain and send dirty memory. * This is the last iteration of the live migration and the @@ -555,6 +580,19 @@ static int suspend_and_send_dirty(struct xc_sr_context *ctx)
Quoted 7 lines
tools/libxc/xc_sr_save.c static int suspend_and_send_dirty(struct xc_sr_context *ctx) · line 584
Quoted 4 lines
tools/libxc/xc_sr_save.c +2
-0bitmap_or (dirty_bitmap, ctx->save.deferred_pages, ctx->save.p2m_size); +if ( !ctx->save.live && ctx->save.callbacks->get_dirty_pfn ) + {Shouldn't
get_dirty_pfnbe mandatory for COLO streams (even if it is a noop to start with) ?
It should be mandatory, it shouldn't be noop under COLO. perhaps we should add sanity check at the beginning. But problem is save side do not have a param passed from libxl to indicate the stream type(like checkpointed_stream in restore side). So we may need to add another XCFLAGS? Currently there is XCFLAGS_CHECKPOINTED which represents Remus, we might need to change this to XCFLAGS_STREAM_REMUSXCFLAGS_STREAM_COLO
so that we can know what kind of stream we are handling?
Quoted 38 lines
~Andrew
Quoted 22 lines
tools/libxc/xc_sr_save.c +14
-1+ rc =update_dirty_bitmap (ctx->save.callbacks->get_dirty_pfn, + ctx->save.callbacks->data, + ctx->save.p2m_size, + dirty_bitmap); +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;@@ -784,7 +822,16 @@ static int save(struct xc_sr_context *ctx, uint16_t guest_type)if ( rc ) goto err; - ctx->save.callbacks->postcopy (ctx->save.callbacks->data); + rc = ctx->save.callbacks->postcopy (ctx->save.callbacks->data); +if ( !rc ) { +if ( !errno )tools/libxc/xc_sr_save.c static int save(struct xc_sr_context *ctx, uint16_t guest_type) · line 837
Quoted 10 lines
tools/libxc/xc_sr_save.c +7
-0+ { +/* Postcopy request failed (without errno, using EINVAL) */ + errno =EINVAL ; + } + rc =-1 ; + goto err; + } rc = ctx->save.callbacks->checkpoint (ctx->save.callbacks->data);if ( rc <=0 ).
Signature · 2 lines
Thanks, Yang.
Re: [PATCH v6 COLO 06/15] libxc/save: support COLO save
Quoted 34 lines · Yang Hongyang
Quoted 22 lines · Andrew Cooper
Quoted 21 lines · Yang Hongyang
call
callbacks->get_dirty_pfn()after suspend primary vm to get dirty pages on secondary vm, and send pages both dirty on primary/secondary to secondary.Signed-off-by Yang Hongyang <[email protected]>Signed-off-by Wen Congyang <[email protected]>CC Andrew Cooper <[email protected]>--- tools/libxc/xc_sr_save.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-)tools/libxc/xc_sr_save.c +0
-0@@ -515,6 +515,31 @@ static int send_memory_live(struct xc_sr_context *ctx)return rc; }Quoted 8 lines
tools/libxc/xc_sr_save.c static int send_memory_live(struct · line 522
Quoted 4 lines
tools/libxc/xc_sr_save.c +2
-0+static int update_dirty_bitmap (uint8_t *(*get_dirty_pfn)(void *),void *data, +unsigned long p2m_size,unsigned long *bitmap)This function should take a ctx rather than having the caller expand 3 parameters. Also, "
update_dirty_bitmap" is a little misleading, as it isn't querying the hypervisor for the dirty bitmap.
Quoted 1 line
ok.
(Merging the other thread)
Quoted 1 line
how about
merge_secondary_dirty_bitmap()?
Much better!
Quoted 16 lines
Quoted 11 lines
tools/libxc/xc_sr_save.c static int send_memory_live(struct xc_sr_context *ctx) · line 525
Quoted 8 lines
tools/libxc/xc_sr_save.c +6
-0+{ +uint64_t *pfn_list; +uint64_t count, i; +uint64_t pfn; + + pfn_list = (uint64_t *)get_dirty_pfn (data);This looks like a recipe for width-errors. The
get_dirty_pfn()call should take a pointer to a struct for it to fill.but the size is unknown for the caller.pfn_list[0] is the count of pfn.
Quoted 1 line
Quoted 7 lines
Quoted 3 lines
tools/libxc/xc_sr_save.c static int send_memory_live(struct xc_sr_context *ctx) · line 526
Quoted 1 line
tools/libxc/xc_sr_save.c +1
-0+assert (pfn_list);This should turn into an error rather than an
abort().Even if there are no dirty pages on secondary,
pfn_listshouldn't be NULL, it's just that pfn_list[0] will be 0. ifpfn_listis NULL, there might be unexpected error happened.
get_dirty_pfn() should be declared alongside a
struct pfn_data
{
uint64_t count;
uint64_t *pfns;
};and this function here should create one of these on the stack and pass it by pointer to get_dirty_pfn(). I might also be tempted to rename this to get_remote_logdirty() or similar, to indicate that it is a source of logdirty data from something other than the current hypervisor.
Quoted 36 lines
Quoted 27 lines
tools/libxc/xc_sr_save.c static int send_memory_live(struct xc_sr_context *ctx) · line 529
Quoted 5 lines
tools/libxc/xc_sr_save.c +3
-0+ + count = pfn_list[0 ]; +for (i =0 ; i < count; i++) {style
Quoted 19 lines
tools/libxc/xc_sr_save.c +13
-0+ pfn = pfn_list[i +1 ]; +if (pfn > p2m_size) { + errno =EINVAL ; +return -1 ; + } + +set_bit (pfn, bitmap); + } + +free (pfn_list); +return 0 ; +} +/*
* Suspend the domain and send dirty memory.
* This is the last iteration of the live migration and thetools/libxc/xc_sr_save.c +0
-0@@ -555,6 +580,19 @@ static int suspend_and_send_dirty(struct xc_sr_context *ctx)Quoted 8 lines
tools/libxc/xc_sr_save.c static int suspend_and_send_dirty(struct xc_sr_context *ctx) · line 584
Quoted 5 lines
tools/libxc/xc_sr_save.c +2
-0bitmap_or (dirty_bitmap, ctx->save.deferred_pages, ctx->save.p2m_size); +if ( !ctx->save.live && ctx->save.callbacks->get_dirty_pfn ) + {Shouldn't
get_dirty_pfnbe mandatory for COLO streams (even if it is a noop to start with) ?
Quoted 11 lines
It should be mandatory, it shouldn't be noop under COLO. perhaps we should
add sanity check at the beginning. But problem is save side do not have a param
passed from libxl to indicate the streamtype(like checkpointed_stream in restore side). So we may need to add another XCFLAGS? Currently there isXCFLAGS_CHECKPOINTEDwhich represents Remus, we might need to change this toXCFLAGS_STREAM_REMUSXCFLAGS_STREAM_COLO
so that we can know what kind of stream we are handling?
checkpointed_stream started out as a bugfix for a legacy stream migration breakage. Really, this information should have been passed right from the start.
It would probably be best to take the enum{} suggested elsewhere and make it a top level ctx item, and have it present for both save and restore, with sutable parameters passed in from the top. (When I am finally able to take out the legacy code, there is going to be a severe pruning/consolidation of the parameters.)
~Andrew
Quoted 45 lines
Quoted 44 lines
~Andrew
Quoted 35 lines
tools/libxc/xc_sr_save.c +11
-0+ rc =update_dirty_bitmap (ctx->save.callbacks->get_dirty_pfn, + ctx->save.callbacks->data, + ctx->save.p2m_size, + dirty_bitmap); +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;tools/libxc/xc_sr_save.c +5
-1@@ -784,7 +822,16 @@ static int save(struct xc_sr_context *ctx, uint16_t guest_type)if ( rc ) goto err; - ctx->save.callbacks->postcopy (ctx->save.callbacks->data); + rc = ctx->save.callbacks->postcopy (ctx->save.callbacks->data); +if ( !rc ) { +if ( !errno ) + { +/* Postcopy request failed (without errno, using EINVAL) */
tools/libxc/xc_sr_save.c +5
-0+ errno =EINVAL ; + } + rc =-1 ; + goto err; + } rc =Quoted 2 lines
ctx->save.callbacks->checkpoint(ctx->save.callbacks->data); if ( rc <= 0 ).
Re: [PATCH v6 COLO 06/15] libxc/save: support COLO save
Quoted 75 lines · Andrew Cooper
Quoted 34 lines · Yang Hongyang
Quoted 22 lines · Andrew Cooper
Quoted 21 lines · Yang Hongyang
call
callbacks->get_dirty_pfn()after suspend primary vm to get dirty pages on secondary vm, and send pages both dirty on primary/secondary to secondary.Signed-off-by Yang Hongyang <[email protected]>Signed-off-by Wen Congyang <[email protected]>CC Andrew Cooper <[email protected]>--- tools/libxc/xc_sr_save.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-)tools/libxc/xc_sr_save.c +0
-0@@ -515,6 +515,31 @@ static int send_memory_live(struct xc_sr_context *ctx)return rc; }Quoted 8 lines
tools/libxc/xc_sr_save.c static int send_memory_live(struct · line 522
Quoted 4 lines
tools/libxc/xc_sr_save.c +2
-0+static int update_dirty_bitmap (uint8_t *(*get_dirty_pfn)(void *),void *data, +unsigned long p2m_size,unsigned long *bitmap)This function should take a ctx rather than having the caller expand 3 parameters. Also, "
update_dirty_bitmap" is a little misleading, as it isn't querying the hypervisor for the dirty bitmap.Quoted 1 line
ok.
(Merging the other thread)
Quoted 1 line
how about
merge_secondary_dirty_bitmap()?Much better!
Quoted 16 lines
Quoted 11 lines
tools/libxc/xc_sr_save.c static int send_memory_live(struct xc_sr_context *ctx) · line 525
Quoted 8 lines
tools/libxc/xc_sr_save.c +6
-0+{ +uint64_t *pfn_list; +uint64_t count, i; +uint64_t pfn; + + pfn_list = (uint64_t *)get_dirty_pfn (data);This looks like a recipe for width-errors. The
get_dirty_pfn()call should take a pointer to a struct for it to fill.but the size is unknown for the caller.pfn_list[0] is the count of pfn.
Quoted 1 line
Quoted 7 lines
Quoted 3 lines
tools/libxc/xc_sr_save.c static int send_memory_live(struct xc_sr_context *ctx) · line 526
Quoted 1 line
tools/libxc/xc_sr_save.c +1
-0+assert (pfn_list);This should turn into an error rather than an
abort().Even if there are no dirty pages on secondary,
pfn_listshouldn't be NULL, it's just that pfn_list[0] will be 0. ifpfn_listis NULL, there might be unexpected error happened.
get_dirty_pfn()should be declared alongside astruct
pfn_data{ uint64_t count; uint64_t *pfns; };
Quoted 4 lines
and this function here should create one of these on the stack and pass it by pointer to
get_dirty_pfn(). I might also be tempted to rename this toget_remote_logdirty()or similar, to indicate that it is a source of logdirty data from something other than the current hypervisor.
This is a callback, I can't find a way to pass pointer from libxc to libxl, libxl can not access the pointer data...The struct can be used for represent the data however.
I like with the rename part, sounds much better.
Quoted 49 lines
Quoted 37 lines
Quoted 28 lines
tools/libxc/xc_sr_save.c static int send_memory_live(struct xc_sr_context *ctx) · line 529
Quoted 6 lines
tools/libxc/xc_sr_save.c +3
-0+ + count = pfn_list[0 ]; +for (i =0 ; i < count; i++) {style
Quoted 19 lines
tools/libxc/xc_sr_save.c +13
-0+ pfn = pfn_list[i +1 ]; +if (pfn > p2m_size) { + errno =EINVAL ; +return -1 ; + } + +set_bit (pfn, bitmap); + } + +free (pfn_list); +return 0 ; +} +/*
* Suspend the domain and send dirty memory.
* This is the last iteration of the live migration and thetools/libxc/xc_sr_save.c +0
-0@@ -555,6 +580,19 @@ static int suspend_and_send_dirty(struct xc_sr_context *ctx)Quoted 8 lines
tools/libxc/xc_sr_save.c static int suspend_and_send_dirty(struct xc_sr_context *ctx) · line 584
Quoted 5 lines
tools/libxc/xc_sr_save.c +2
-0bitmap_or (dirty_bitmap, ctx->save.deferred_pages, ctx->save.p2m_size); +if ( !ctx->save.live && ctx->save.callbacks->get_dirty_pfn ) + {Shouldn't
get_dirty_pfnbe mandatory for COLO streams (even if it is a noop to start with) ?Quoted 11 lines
It should be mandatory, it shouldn't be noop under COLO. perhaps we should
add sanity check at the beginning. But problem is save side do not have a param
passed from libxl to indicate the streamtype(like checkpointed_stream in restore side). So we may need to add another XCFLAGS? Currently there isXCFLAGS_CHECKPOINTEDwhich represents Remus, we might need to change this toXCFLAGS_STREAM_REMUSXCFLAGS_STREAM_COLO
so that we can know what kind of stream we are handling?
Quoted 3 lines
checkpointed_streamstarted out as a bugfix for a legacy stream migration breakage. Really, this information should have been passed right from the start.
Did I miss the bugfix? is it not in upstream?
Quoted 6 lines
It would probably be best to take the enum{} suggested elsewhere and make it a top level ctx item, and have it present for both save and restore, with sutable parameters passed in from the top. (When I am finally able to take out the legacy code, there is going to be a severe pruning/consolidation of the parameters.)
This is what I thought when I saw the enum{} suggested.
Quoted 51 lines
~Andrew
Quoted 38 lines
Quoted 38 lines
~Andrew
Quoted 34 lines
tools/libxc/xc_sr_save.c +11
-0+ rc =update_dirty_bitmap (ctx->save.callbacks->get_dirty_pfn, + ctx->save.callbacks->data, + ctx->save.p2m_size, + dirty_bitmap); +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;tools/libxc/xc_sr_save.c +5
-1@@ -784,7 +822,16 @@ static int save(struct xc_sr_context *ctx, uint16_t guest_type)if ( rc ) goto err; - ctx->save.callbacks->postcopy (ctx->save.callbacks->data); + rc = ctx->save.callbacks->postcopy (ctx->save.callbacks->data); +if ( !rc ) { +if ( !errno ) + { +/* Postcopy request failed (without errno, using EINVAL) */
tools/libxc/xc_sr_save.c +5
-0+ errno =EINVAL ; + } + rc =-1 ; + goto err; + }Quoted 7 lines
Quoted 6 lines
Quoted 3 lines
rc =
ctx->save.callbacks->checkpoint(ctx->save.callbacks->data); if ( rc <= 0 ).
.
Signature · 2 lines
Thanks, Yang.
Re: [PATCH v6 COLO 06/15] libxc/save: support COLO save
Quoted 19 lines · Yang Hongyang
Quoted 13 lines
Quoted 4 lines
Even if there are no dirty pages on secondary,
pfn_listshouldn't be NULL, it's just that pfn_list[0] will be 0. ifpfn_listis NULL, there might be unexpected error happened.
get_dirty_pfn()should be declared alongside astruct
pfn_data{ uint64_t count; uint64_t *pfns; };Quoted 5 lines
and this function here should create one of these on the stack and pass it by pointer to
get_dirty_pfn(). I might also be tempted to rename this toget_remote_logdirty()or similar, to indicate that it is a source of logdirty data from something other than the current hypervisor.
Quoted 5 lines
This is a callback, I can't find a way to pass pointer from libxc to libxl,
libxl can not access the pointer data...The struct can be used for represent
the data however.
Right - my point is that it should be the implementation of get_remote_logdirty() (i.e. in libxl_save_helper) which is responsible for unpackaging the data from whatever RPC method is used, rather than the caller.
Quoted 18 lines
Quoted 18 lines
Quoted 17 lines
Quoted 3 lines
Shouldn't
get_dirty_pfnbe mandatory for COLO streams (even if it is a noop to start with) ?It should be mandatory, it shouldn't be noop under COLO. perhaps we should
add sanity check at the beginning. But problem is save side do not have a param
passed from libxl to indicate the stream type(likecheckpointed_streamin
restore side). So we may need to add another XCFLAGS? Currently there isXCFLAGS_CHECKPOINTEDwhich represents Remus, we might need to change this toXCFLAGS_STREAM_REMUSXCFLAGS_STREAM_COLO
so that we can know what kind of stream we are handling?
Quoted 5 lines
Quoted 3 lines
checkpointed_streamstarted out as a bugfix for a legacy stream migration breakage. Really, this information should have been passed right from the start.Did I miss the bugfix? is it not in upstream?
c/s 7051d5c
~Andrew
Re: [PATCH v6 COLO 06/15] libxc/save: support COLO save
Quoted 26 lines · Andrew Cooper
Quoted 19 lines · Yang Hongyang
Quoted 13 lines
Quoted 4 lines
Even if there are no dirty pages on secondary,
pfn_listshouldn't be NULL, it's just that pfn_list[0] will be 0. ifpfn_listis NULL, there might be unexpected error happened.
get_dirty_pfn()should be declared alongside astruct
pfn_data{ uint64_t count; uint64_t *pfns; };Quoted 5 lines
and this function here should create one of these on the stack and pass it by pointer to
get_dirty_pfn(). I might also be tempted to rename this toget_remote_logdirty()or similar, to indicate that it is a source of logdirty data from something other than the current hypervisor.Quoted 5 lines
This is a callback, I can't find a way to pass pointer from libxc to libxl,
libxl can not access the pointer data...The struct can be used for represent
the data however.
Quoted 4 lines
Right - my point is that it should be the implementation of
get_remote_logdirty()(i.e. inlibxl_save_helper) which is responsible for unpackaging the data from whatever RPC method is used, rather than the caller.
Now I know what you mean, I will fix it in the next version, thanks!
Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
Quoted 18 lines
Quoted 4 lines
Shouldn't
get_dirty_pfnbe mandatory for COLO streams (even if it is a noop to start with) ?It should be mandatory, it shouldn't be noop under COLO. perhaps we should
add sanity check at the beginning. But problem is save side do not have a param
passed from libxl to indicate the stream type(likecheckpointed_streamin
restore side). So we may need to add another XCFLAGS? Currently there isXCFLAGS_CHECKPOINTEDwhich represents Remus, we might need to change this toXCFLAGS_STREAM_REMUSXCFLAGS_STREAM_COLO
so that we can know what kind of stream we are handling?
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
checkpointed_streamstarted out as a bugfix for a legacy stream migration breakage. Really, this information should have been passed right from the start.Did I miss the bugfix? is it not in upstream?
c/s 7051d5c
Ah, you are talking about the restore side, I'm talking about the save side checkpointed_stream, so I should also post a prereq patch to add checkpointed_stream to the save side? or there's already the fix out there?
Quoted 4 lines
~Andrew
.
Signature · 2 lines
Thanks, Yang.
Re: [PATCH v6 COLO 06/15] libxc/save: support COLO save
Quoted 26 lines · Yang Hongyang
Quoted 26 lines
Quoted 26 lines
Quoted 25 lines
Quoted 8 lines
Quoted 7 lines
Shouldn't
get_dirty_pfnbe mandatory for COLO streams (even if it is a
noop to start with) ?Quoted 13 lines
It should be mandatory, it shouldn't be noop under COLO. perhaps we should
add sanity check at the beginning. But problem is save side do not have a param
passed from libxl to indicate the stream type(likecheckpointed_streamin
restore side). So we may need to add another XCFLAGS? Currently there isXCFLAGS_CHECKPOINTEDwhich represents Remus, we might need to change this toXCFLAGS_STREAM_REMUSXCFLAGS_STREAM_COLO
so that we can know what kind of stream we are handling?
checkpointed_streamstarted out as a bugfix for a legacy stream migration breakage. Really, this information should have been passed right from the start.
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
Did I miss the bugfix? is it not in upstream?
c/s 7051d5c
Ah, you are talking about the restore side, I'm talking about the save side
checkpointed_stream, so I should also post a prereq patch to addcheckpointed_streamto the save side? or there's already the fix out there?
Sorry for being unclear. You will have to add one to the save side. The restore side only has one as a bugfix.
~Andrew
Re: [PATCH v6 COLO 06/15] libxc/save: support COLO save
Quoted 31 lines · Andrew Cooper
Quoted 30 lines · Yang Hongyang
Quoted 29 lines
Quoted 22 lines
Quoted 22 lines
Quoted 21 lines
Quoted 7 lines
Shouldn't
get_dirty_pfnbe mandatory for COLO streams (even if it is a
noop to start with) ?It should be mandatory, it shouldn't be noop under COLO. perhaps we should
add sanity check at the beginning. But problem is save side do not have a param
passed from libxl to indicate the stream type(likecheckpointed_streamin
restore side). So we may need to add another XCFLAGS? Currently there isXCFLAGS_CHECKPOINTEDwhich represents Remus, we might need to change this toXCFLAGS_STREAM_REMUSXCFLAGS_STREAM_COLO
so that we can know what kind of stream we are handling?Quoted 5 lines
Quoted 3 lines
checkpointed_streamstarted out as a bugfix for a legacy stream migration breakage. Really, this information should have been passed right from the start.Did I miss the bugfix? is it not in upstream?
c/s 7051d5c
Quoted 7 lines
Quoted 4 lines
Ah, you are talking about the restore side, I'm talking about the save side
checkpointed_stream, so I should also post a prereq patch to addcheckpointed_streamto the save side? or there's already the fix out there?Sorry for being unclear. You will have to add one to the save side. The restore side only has one as a bugfix.
Got it~ thanks!
Quoted 4 lines
~Andrew
.
Signature · 2 lines
Thanks, Yang.
Re: [PATCH v6 COLO 06/15] libxc/save: support COLO save
In reply to Andrew CooperQuoted 20 lines · Andrew Cooper
Quoted 19 lines · Yang Hongyang
call
callbacks->get_dirty_pfn()after suspend primary vm to get dirty pages on secondary vm, and send pages both dirty on primary/secondary to secondary.Signed-off-by Yang Hongyang <[email protected]>Signed-off-by Wen Congyang <[email protected]>CC Andrew Cooper <[email protected]>--- tools/libxc/xc_sr_save.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-)tools/libxc/xc_sr_save.c +0
-0@@ -515,6 +515,31 @@ static int send_memory_live(struct xc_sr_context *ctx)return rc; }
Quoted 6 lines
tools/libxc/xc_sr_save.c static int send_memory_live(struct xc_sr_context *ctx) · line 519
Quoted 2 lines
tools/libxc/xc_sr_save.c +2
-0+static int update_dirty_bitmap (uint8_t *(*get_dirty_pfn)(void *),void *data, +unsigned long p2m_size,unsigned long *bitmap)This function should take a ctx rather than having the caller expand 3 parameters. Also, "
update_dirty_bitmap" is a little misleading, as it isn't querying the hypervisor for the dirty bitmap.
how about merge_secondary_dirty_bitmap()?
Quoted 84 lines
tools/libxc/xc_sr_save.c static int send_memory_live(struct xc_sr_context *ctx) · line 525
Quoted 7 lines
tools/libxc/xc_sr_save.c +6
-0+{ +uint64_t *pfn_list; +uint64_t count, i; +uint64_t pfn; + + pfn_list = (uint64_t *)get_dirty_pfn (data);This looks like a recipe for width-errors. The
get_dirty_pfn()call should take a pointer to a struct for it to fill.tools/libxc/xc_sr_save.c static int send_memory_live(struct xc_sr_context *ctx) · line 526
Quoted 1 line
tools/libxc/xc_sr_save.c +1
-0+assert (pfn_list);This should turn into an error rather than an
abort().tools/libxc/xc_sr_save.c static int send_memory_live(struct xc_sr_context *ctx) · line 529
Quoted 3 lines
tools/libxc/xc_sr_save.c +3
-0+ + count = pfn_list[0 ]; +for (i =0 ; i < count; i++) {style
Quoted 17 lines
tools/libxc/xc_sr_save.c +13
-0+ pfn = pfn_list[i +1 ]; +if (pfn > p2m_size) { + errno =EINVAL ; +return -1 ; + } + +set_bit (pfn, bitmap); + } + +free (pfn_list); +return 0 ; +} +/* * Suspend the domain and send dirty memory. * This is the last iteration of the live migration and the tools/libxc/xc_sr_save.c static int suspend_and_send_dirty(struct xc_sr_context *ctx) · line 584
Quoted 5 lines
tools/libxc/xc_sr_save.c +2
-0@@ -555,6 +580,19 @@ 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.callbacks->get_dirty_pfn ) + {Shouldn't
get_dirty_pfnbe mandatory for COLO streams (even if it is a noop to start with) ?~Andrew
Quoted 22 lines
tools/libxc/xc_sr_save.c +14
-1+ rc =update_dirty_bitmap (ctx->save.callbacks->get_dirty_pfn, + ctx->save.callbacks->data, + ctx->save.p2m_size, + dirty_bitmap); +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;@@ -784,7 +822,16 @@ static int save(struct xc_sr_context *ctx, uint16_t guest_type)if ( rc ) goto err; - ctx->save.callbacks->postcopy (ctx->save.callbacks->data); + rc = ctx->save.callbacks->postcopy (ctx->save.callbacks->data); +if ( !rc ) { +if ( !errno )tools/libxc/xc_sr_save.c static int save(struct xc_sr_context *ctx, uint16_t guest_type) · line 837
Quoted 10 lines
tools/libxc/xc_sr_save.c +7
-0+ { +/* Postcopy request failed (without errno, using EINVAL) */ + errno =EINVAL ; + } + rc =-1 ; + goto err; + } rc = ctx->save.callbacks->checkpoint (ctx->save.callbacks->data);if ( rc <=0 ).
Signature · 2 lines
Thanks, Yang.
PATCH v6 7/15 implement the cmdline for COLO
In reply to Yang HongyangFrom: Wen Congyang <[email protected]>
Add 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 | 16 ++++++++++++++ tools/libxl/xl_cmdimpl.c | 53 +++++++++++++++++++++++++++++++++++++++-------- tools/libxl/xl_cmdtable.c | 4 +++- 4 files changed, 73 insertions(+), 12 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. It is conflict with B<-i> and B<-b>, and memory +checkpoint compression must be disabled. + =back =item B<pause> I<domain-id>
tools/libxl/libxl.c +16 -0
@@ -811,6 +811,22 @@ 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; + } + +if (libxl_defbool_val (info->colo)) { +libxl_defbool_setdefault (&info->compression, false); +if (libxl_defbool_val (info->compression)) { +LOG (ERROR ,"cannot use memory checkpoint compression in COLO mode" ); + rc =ERROR_FAIL ; + goto out; + } + } +libxl_defbool_setdefault (&info->allow_unsafe, false);libxl_defbool_setdefault (&info->blackhole, false);libxl_defbool_setdefault (&info->compression, true);
tools/libxl/xl_cmdimpl.c +44 -9
135 lines not on this page · raw message
tools/libxl/xl_cmdtable.c +3 -1
@@ -515,7 +515,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
1.9.1
Re: [PATCH v6 COLO 07/15] implement the cmdline for COLO
Quoted 9 lines · Yang Hongyang
From: Wen Congyang <[email protected]>
Add 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'.
I asked about whether COLO was an extension or a peer to Remus in an earlier patch. the answer may have an impact here too.
docs/man/xl.pod.1 Disable network output buffering. Requires enabling unsafe mode. · line 506
Quoted 7 lines
docs/man/xl.pod.1 +3
-0@@ -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. It is conflict with B<-i> and B<-b>, and memory
"It conflicts with" or "This conflicts with".
Quoted 10 lines
docs/man/xl.pod.1 +2
-0+checkpoint compression must be disabled. + =back =item B<pause> I<domain-id>tools/libxl/libxl.c +0
-0
tools/libxl/libxl.c int libxl_domain_remus_start(libxl_ctx *ctx, libxl_domain_remus_info *info, · line 816
Quoted 6 lines
tools/libxl/libxl.c +3
-0@@ -811,6 +811,22 @@ 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" );
As I wondered earlier -- this suggests it should not be a defbool, or that the interfaces should split.
tools/libxl/libxl.c int libxl_domain_remus_start(libxl_ctx *ctx, libxl_domain_remus_info *info, · line 822
Quoted 6 lines
tools/libxl/libxl.c +6
-0+ rc =ERROR_FAIL ; + goto out; + } + +if (libxl_defbool_val (info->colo)) { +libxl_defbool_setdefault (&info->compression, false);
Assuming this isn't invalidated by the above comments, you should make the existing:
libxl_defbool_setdefault(&info->compression, true);
into
libxl_defbool_setdefault(&info->compression, libxl_defbool_val(colo));
and then do an error check later.
Quoted 15 lines
tools/libxl/libxl.c +7
-0+if (libxl_defbool_val (info->compression)) { +LOG (ERROR ,"cannot use memory checkpoint compression in COLO mode" ); + rc =ERROR_FAIL ; + goto out; + } + } +libxl_defbool_setdefault (&info->allow_unsafe, false);libxl_defbool_setdefault (&info->blackhole, false);libxl_defbool_setdefault (&info->compression, true);tools/libxl/xl_cmdimpl.c +0
-0
tools/libxl/xl_cmdimpl.c static void migrate_receive(int debug, int daemonize, int monitor, · line 4278
Quoted 6 lines
tools/libxl/xl_cmdimpl.c +3
-0@@ -4273,6 +4273,9 @@ static void migrate_receive(int debug, int daemonize, int monitor, dom_info.send_fd = send_fd; dom_info.migration_domname_r = &migration_domname; dom_info.checkpointed_stream = remus; +if (remus ==LIBXL_CHECKPOINTED_STREAM_COLO ) +/* COLO uses stdout to send control message to master */ + dom_info.quiet =1 ;
Please set a const char * to either "COLO" or "Remus" here and use it everywhere you've currently got an open coded decision on that.
Quoted 65 lines
tools/libxl/xl_cmdimpl.c +15
-5rc =create_domain (&dom_info);if (rc <0 ) {@@ -4287,7 +4290,8 @@ static void migrate_receive(int debug, int daemonize, int monitor,/* 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" , +fprintf (stderr,"migration target: %s Failover for domain %u\n" , + remus ==LIBXL_CHECKPOINTED_STREAM_COLO ?"COLO" :"Remus" , domid);/* @@ -4304,15 +4308,21 @@ 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" , + remus ==LIBXL_CHECKPOINTED_STREAM_COLO ?"COLO" :"Remus" , migration_domname, common_domname, rc); } +if (remus ==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" , + remus ==LIBXL_CHECKPOINTED_STREAM_COLO ?"COLO" :"Remus" , common_domname, domid, rc);exit (rc ? -ERROR_FAIL :0 );@@ -4458,7 +4468,7 @@ int main_migrate_receive(int argc, char **argv)int debug =0 , daemonize =1 , monitor =1 , remus =0 ;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 ;@@ -4470,8 +4480,10 @@ int main_migrate_receive(int argc, char **argv) debug =1 ;break ;case 'r' : - remus =1 ; + remus =LIBXL_CHECKPOINTED_STREAM_REMUS ;break ; +case 'c' : + remus =LIBXL_CHECKPOINTED_STREAM_COLO ; }if (argc-optind !=0 ) {@@ -7958,15 +7970,18 @@ int main_remus(int argc, char **argv)pid_t child =-1 ;uint8_t *config_data;int config_len; +int interval =0 ;memset (&r_info,0 ,sizeof (libxl_domain_remus_info));
tools/libxl/xl_cmdimpl.c int main_remus(int argc, char **argv) · line 7984
Quoted 10 lines
tools/libxl/xl_cmdimpl.c +3
-1/* Defaults */ r_info.interval =200 ;libxl_defbool_setdefault (&r_info.blackhole, false); +libxl_defbool_setdefault (&r_info.colo, 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); + interval =1 ;
This duplication of r_info.interval and interval seems odd. Perhaps interval is really "interval_was_set" but even so I'm not sure this would be better achieved with some more refactoring.
Quoted 10 lines
tools/libxl/xl_cmdimpl.c +2
-0break ;case 'F' :libxl_defbool_set (&r_info.allow_unsafe, true);@@ -7992,11 +8007,28 @@ int main_remus(int argc, char **argv)case 'e' : daemonize =0 ;break ; +case 'c' : +libxl_defbool_set (&r_info.colo, true); }
tools/libxl/xl_cmdimpl.c int main_remus(int argc, char **argv) · line 8022
Quoted 10 lines
tools/libxl/xl_cmdimpl.c +6
-0domid =find_domain (argv[optind]); host = argv[optind +1 ]; +if (libxl_defbool_val (r_info.colo)) { +if (!interval) + r_info.interval =0 ; + +if (r_info.interval ||libxl_defbool_val (r_info.blackhole)) { +perror ("option -c is conflict with -i or -b" );
"...-c conflicts with..."
tools/libxl/xl_cmdimpl.c int main_remus(int argc, char **argv) · line 8027
Quoted 5 lines
tools/libxl/xl_cmdimpl.c +5
-0+exit (-1 ); + } + +if (libxl_defbool_is_default (r_info.compression)) { +perror ("option -u must be specified when using COLO" );
Then enforce it using setdefault I think instead of making the user jump through a pointless hoop.
Ian.
Re: [PATCH v6 COLO 07/15] implement the cmdline for COLO
Quoted 6 lines · Ian Campbell
Quoted 5 lines · Yang Hongyang
From: Wen Congyang <[email protected]>
Add a new option -c to the command 'xl remus'. If you want to use COLO HA instead of Remus HA, please use -c option.
Quoted 7 lines
Quoted 4 lines
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'.
I asked about whether COLO was an extension or a peer to Remus in an earlier patch. the answer may have an impact here too.
We implemented COLO based on Remus, so we assume it is an extension to Remus.
Quoted 187 lines
docs/man/xl.pod.1 Disable network output buffering. Requires enabling unsafe mode. · line 506
Quoted 8 lines
docs/man/xl.pod.1 +3
-0@@ -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. It is conflict with B<-i> and B<-b>, and memory"It conflicts with" or "This conflicts with".
Quoted 10 lines
docs/man/xl.pod.1 +2
-0+checkpoint compression must be disabled. + =back =item B<pause> I<domain-id>tools/libxl/libxl.c +0
-0tools/libxl/libxl.c int libxl_domain_remus_start(libxl_ctx *ctx, libxl_domain_remus_info *info, · line 816
Quoted 6 lines
tools/libxl/libxl.c +3
-0@@ -811,6 +811,22 @@ 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" );As I wondered earlier -- this suggests it should not be a defbool, or that the interfaces should split.
tools/libxl/libxl.c int libxl_domain_remus_start(libxl_ctx *ctx, libxl_domain_remus_info *info, · line 822
Quoted 6 lines
tools/libxl/libxl.c +6
-0+ rc =ERROR_FAIL ; + goto out; + } + +if (libxl_defbool_val (info->colo)) { +libxl_defbool_setdefault (&info->compression, false);Assuming this isn't invalidated by the above comments, you should make the existing:
libxl_defbool_setdefault(&info->compression, true);
into
libxl_defbool_setdefault(&info->compression, libxl_defbool_val(colo));and then do an error check later.
Quoted 15 lines
tools/libxl/libxl.c +7
-0+if (libxl_defbool_val (info->compression)) { +LOG (ERROR ,"cannot use memory checkpoint compression in COLO mode" ); + rc =ERROR_FAIL ; + goto out; + } + } +libxl_defbool_setdefault (&info->allow_unsafe, false);libxl_defbool_setdefault (&info->blackhole, false);libxl_defbool_setdefault (&info->compression, true);tools/libxl/xl_cmdimpl.c +0
-0tools/libxl/xl_cmdimpl.c static void migrate_receive(int debug, int daemonize, int monitor, · line 4278
Quoted 6 lines
tools/libxl/xl_cmdimpl.c +3
-0@@ -4273,6 +4273,9 @@ static void migrate_receive(int debug, int daemonize, int monitor, dom_info.send_fd = send_fd; dom_info.migration_domname_r = &migration_domname; dom_info.checkpointed_stream = remus; +if (remus ==LIBXL_CHECKPOINTED_STREAM_COLO ) +/* COLO uses stdout to send control message to master */ + dom_info.quiet =1 ;Please set a const char * to either "COLO" or "Remus" here and use it everywhere you've currently got an open coded decision on that.
Quoted 65 lines
tools/libxl/xl_cmdimpl.c +15
-5rc =create_domain (&dom_info);if (rc <0 ) {@@ -4287,7 +4290,8 @@ static void migrate_receive(int debug, int daemonize, int monitor,/* 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" , +fprintf (stderr,"migration target: %s Failover for domain %u\n" , + remus ==LIBXL_CHECKPOINTED_STREAM_COLO ?"COLO" :"Remus" , domid);/* @@ -4304,15 +4308,21 @@ 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" , + remus ==LIBXL_CHECKPOINTED_STREAM_COLO ?"COLO" :"Remus" , migration_domname, common_domname, rc); } +if (remus ==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" , + remus ==LIBXL_CHECKPOINTED_STREAM_COLO ?"COLO" :"Remus" , common_domname, domid, rc);exit (rc ? -ERROR_FAIL :0 );@@ -4458,7 +4468,7 @@ int main_migrate_receive(int argc, char **argv)int debug =0 , daemonize =1 , monitor =1 , remus =0 ;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 ;@@ -4470,8 +4480,10 @@ int main_migrate_receive(int argc, char **argv) debug =1 ;break ;case 'r' : - remus =1 ; + remus =LIBXL_CHECKPOINTED_STREAM_REMUS ;break ; +case 'c' : + remus =LIBXL_CHECKPOINTED_STREAM_COLO ; }if (argc-optind !=0 ) {@@ -7958,15 +7970,18 @@ int main_remus(int argc, char **argv)pid_t child =-1 ;uint8_t *config_data;int config_len; +int interval =0 ;memset (&r_info,0 ,sizeof (libxl_domain_remus_info));tools/libxl/xl_cmdimpl.c int main_remus(int argc, char **argv) · line 7984
Quoted 10 lines
tools/libxl/xl_cmdimpl.c +3
-1/* Defaults */ r_info.interval =200 ;libxl_defbool_setdefault (&r_info.blackhole, false); +libxl_defbool_setdefault (&r_info.colo, 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); + interval =1 ;This duplication of r_info.interval and interval seems odd. Perhaps interval is really "
interval_was_set" but even so I'm not sure this would be better achieved with some more refactoring.Quoted 10 lines
tools/libxl/xl_cmdimpl.c +2
-0break ;case 'F' :libxl_defbool_set (&r_info.allow_unsafe, true);@@ -7992,11 +8007,28 @@ int main_remus(int argc, char **argv)case 'e' : daemonize =0 ;break ; +case 'c' : +libxl_defbool_set (&r_info.colo, true); }tools/libxl/xl_cmdimpl.c int main_remus(int argc, char **argv) · line 8022
Quoted 10 lines
tools/libxl/xl_cmdimpl.c +6
-0domid =find_domain (argv[optind]); host = argv[optind +1 ]; +if (libxl_defbool_val (r_info.colo)) { +if (!interval) + r_info.interval =0 ; + +if (r_info.interval ||libxl_defbool_val (r_info.blackhole)) { +perror ("option -c is conflict with -i or -b" );"...-c conflicts with..."
tools/libxl/xl_cmdimpl.c int main_remus(int argc, char **argv) · line 8027
Quoted 5 lines
tools/libxl/xl_cmdimpl.c +5
-0+exit (-1 ); + } + +if (libxl_defbool_is_default (r_info.compression)) { +perror ("option -u must be specified when using COLO" );Then enforce it using setdefault I think instead of making the user jump through a pointless hoop.
Ian.
.
Signature · 2 lines
Thanks, Yang.
Re: [PATCH v6 COLO 07/15] implement the cmdline for COLO
Quoted 11 lines · Yang Hongyang
Quoted 9 lines · Ian Campbell
Quoted 8 lines · Yang Hongyang
From: Wen Congyang <[email protected]>
Add 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.
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
Also add a new option -c to the internal command 'xl migrate-receive'.
I asked about whether COLO was an extension or a peer to Remus in an earlier patch. the answer may have an impact here too.
We implemented COLO based on Remus, so we assume it is an extension to Remus.
It's not so much a question of implementation (since any two unrelated features might share some code, or be inspired by one another) but of how the features relate logically from the users point of view, is COLO an extension to Remus or is it an independent feature?
i.e. would a user expect the interface to be:
xl remus <...> # run remus on a domain
xl colo <...> # run colo on a domain
or
xl remus <...> # run remus on a domain
xl remus -c <...> # run remus with colo extensions on a domain
Quoted 1 line
From this end it seems that although colo builds upon the Remus code and
concepts in many ways to the end user it is actually a logically separate feature which fills a similar niche to Remus.
It might be that I've not fully appreciated how the two relate and colo really is "just" an extension to Remus, I'm not sure.
A similar argument applies further down the stack at the libxl API layer too (my comment on patch #3).
Ian.
PATCH v6 8/15 Support colo mode for qemu disk
In reply to Yang HongyangFrom: Wen Congyang <[email protected]>
Usage: disk = ['...,colo,colo-params=xxx,active-disk=xxx,hidden-disk=xxx...'] The format of colo-params: host:port:exportname=xx
--- docs/man/xl.pod.1 | 2 +- tools/libxl/libxl.c | 42 ++++++- tools/libxl/libxl_create.c | 25 ++++- tools/libxl/libxl_device.c | 38 +++++++ tools/libxl/libxl_dm.c | 262 ++++++++++++++++++++++++++++++++++++++++++-- tools/libxl/libxl_types.idl | 5 + tools/libxl/libxlu_disk_l.l | 5 + 7 files changed, 367 insertions(+), 12 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>
tools/libxl/libxl.c +41 -1
66 lines not on this page · raw message
tools/libxl/libxl_create.c +23 -2
@@ -1727,12 +1727,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 ,0 , ao_how, aop_console_how); }
@@ -1745,8 +1762,12 @@ int libxl_domain_create_restore(libxl_ctx *ctx, libxl_domain_config *d_config, {int send_fd =-1 ; -if (params->checkpointed_stream ==LIBXL_CHECKPOINTED_STREAM_COLO ) +if (params->checkpointed_stream ==LIBXL_CHECKPOINTED_STREAM_COLO ) { send_fd = params->send_fd; +set_disk_colo_restore (d_config); + }else { +unset_disk_colo_restore (d_config); + }return do_domain_create (ctx, d_config, domid, restore_fd, send_fd, params->checkpointed_stream, ao_how, aop_console_how);
tools/libxl/libxl_device.c +38 -0
@@ -196,6 +196,10 @@ static int disk_try_backend(disk_try_backend_args *a, goto bad_format; } +if (libxl_defbool_val (a->disk->colo_enable) || + a->disk->active_disk || a->disk->hidden_disk) + goto bad_colo; +if (a->disk->backend_domid !=LIBXL_TOOLSTACK_DOMID ) {LOG (DEBUG ,"Disk vdev=%s, is using a storage driver domain, " "skipping physical device check" , a->disk->vdev);
@@ -218,6 +222,10 @@ static int disk_try_backend(disk_try_backend_args *a,case LIBXL_DISK_BACKEND_TAP :if (a->disk->script) goto bad_script; +if (libxl_defbool_val (a->disk->colo_enable) || + a->disk->active_disk || a->disk->hidden_disk) + goto bad_colo; +if (a->disk->is_cdrom) {LOG (DEBUG ,"Disk vdev=%s, backend tap unsuitable for cdroms" , a->disk->vdev);
@@ -236,6 +244,16 @@ static int disk_try_backend(disk_try_backend_args *a,case LIBXL_DISK_BACKEND_QDISK :if (a->disk->script) goto bad_script; +if (libxl_defbool_val (a->disk->colo_enable)) { +if (!a->disk->colo_params) + goto bad_colo_params; + +if (!a->disk->active_disk) + goto bad_active_disk; + +if (!a->disk->hidden_disk) + goto bad_hidden_disk; + }return backend;default :
@@ -256,6 +274,26 @@ static int disk_try_backend(disk_try_backend_args *a,LOG (DEBUG ,"Disk vdev=%s, backend %s not compatible with script=..." , a->disk->vdev,libxl_disk_backend_to_string (backend));return 0 ; + + bad_colo: +LOG (DEBUG ,"Disk vdev=%s, backend %s not compatible with colo" , + a->disk->vdev,libxl_disk_backend_to_string (backend)); +return 0 ; + + bad_colo_params: +LOG (DEBUG ,"Disk vdev=%s, backend %s needs colo-params=... for colo" , + a->disk->vdev,libxl_disk_backend_to_string (backend)); +return 0 ; + + bad_active_disk: +LOG (DEBUG ,"Disk vdev=%s, backend %s needs active-disk=... for colo" , + a->disk->vdev,libxl_disk_backend_to_string (backend)); +return 0 ; + + bad_hidden_disk: +LOG (DEBUG ,"Disk vdev=%s, backend %s needs hidden-disk=... for colo" , + a->disk->vdev,libxl_disk_backend_to_string (backend)); +return 0 ; }int libxl__device_disk_set_backend (libxl__gc *gc,libxl_device_disk *disk) {
tools/libxl/libxl_dm.c +254 -8
282 lines not on this page · raw message
tools/libxl/libxl_types.idl +5 -0
@@ -516,6 +516,11 @@ 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_params", string), + ("active_disk", string), + ("hidden_disk", string) ]) libxl_device_nic = Struct("device_nic", [
tools/libxl/libxlu_disk_l.l +5 -0
@@ -176,6 +176,11 @@ 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-params=[^,]*,? { STRIP(','); SAVESTRING("colo-params", colo_params, 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
1.9.1
Re: [PATCH v6 COLO 08/15] Support colo mode for qemu disk
Quoted 4 lines · Yang Hongyang
From: Wen Congyang <[email protected]>
Usage: disk = ['...,colo,colo-params=xxx,active-disk=xxx,hidden-disk=xxx...'] The format of colo-params: host:port:exportname=xx
Please expand docs/misc/xl-disk-configuration.txt with what these mean.
I would hope that at least some of these could be removed from the user facing API (i.e. libxl's API) and either inferred from the use of the others or from colo being enabled for the domain.
Ian.
PATCH v6 9/15 COLO: use qemu block replication
In reply to Yang HongyangFrom: Wen Congyang <[email protected]>
The guest should be paused before doing COLO!!!
--- tools/libxl/Makefile | 1 + tools/libxl/libxl_colo_qdisk.c | 209 +++++++++++++++++++++++++++++++++++++++ tools/libxl/libxl_colo_restore.c | 21 +++- tools/libxl/libxl_colo_save.c | 36 ++++++- tools/libxl/libxl_internal.h | 18 ++++ tools/libxl/libxl_qmp.c | 31 ++++++ 6 files changed, 312 insertions(+), 4 deletions(-) create mode 100644 tools/libxl/libxl_colo_qdisk.c
tools/libxl/Makefile +1 -0
@@ -58,6 +58,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 +209 -0
209 lines not on this page · raw message
tools/libxl/libxl_colo_restore.c +19 -2
@@ -65,7 +65,10 @@ 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_suspend_callback (void *data); +extern const libxl__checkpoint_device_instance_ops colo_restore_device_qdisk; +static const libxl__checkpoint_device_instance_ops *colo_restore_ops[] = { + &colo_restore_device_qdisk,NULL , };
@@ -164,7 +167,11 @@ static int init_device_subkind(libxl__checkpoint_devices_state *cds)int rc;STATE_AO_GC (cds->ao); + rc =init_subkind_qdisk (cds); +if (rc) goto out; + rc =0 ; +out:return rc; }
@@ -172,6 +179,8 @@ 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_qdisk (cds); }
@@ -282,6 +291,8 @@ void libxl__colo_restore_setup(libxl__egc *egc,logdirty_init (&crcs->lds); crcs->lds.ao = ao; + crs->qdisk_setuped = false; + rc =0 ; out:
@@ -590,6 +601,12 @@ static void colo_restore_preresume_cb(libxl__egc *egc, goto out; } + rc =colo_qdisk_preresume (CTX , crs->domid); +if (rc) { +LOG (ERROR ,"colo_qdisk_preresume() fails" ); + goto out; + } +colo_restore_resume_vm (egc, crcs);return ;
@@ -775,8 +792,8 @@ static void colo_setup_checkpoint_devices(libxl__egc *egc,STATE_AO_GC (crs->ao); -/* TODO: disk/nic support */ - cds->device_kind_flags =0 ; +/* TODO: nic support */ + cds->device_kind_flags = (1 <<LIBXL__DEVICE_KIND_VBD ); cds->callback = colo_restore_setup_cds_done; cds->ao = ao; cds->domid = crs->domid;
tools/libxl/libxl_colo_save.c +34 -2
@@ -19,7 +19,10 @@#include "libxl_internal.h" #include "libxl_colo.h" +extern const libxl__checkpoint_device_instance_ops colo_save_device_qdisk; +static const libxl__checkpoint_device_instance_ops *colo_ops[] = { + &colo_save_device_qdisk,NULL , };
@@ -30,7 +33,11 @@ static int init_device_subkind(libxl__checkpoint_devices_state *cds)int rc;STATE_AO_GC (cds->ao); + rc =init_subkind_qdisk (cds); +if (rc) goto out; + rc =0 ; +out:return rc; }
@@ -38,6 +45,8 @@ 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_qdisk (cds); }/* ================= colo: setup save environment ================= */
@@ -65,9 +74,11 @@ void libxl__colo_save_setup(libxl__egc *egc, libxl__colo_save_state *css) css->send_fd = dss->fd; css->recv_fd = dss->recv_fd; css->svm_running = false; + css->paused = true; + css->qdisk_setuped = false; -/* TODO: disk/nic support */ - cds->device_kind_flags =0 ; +/* TODO: nic support */ + cds->device_kind_flags = (1 <<LIBXL__DEVICE_KIND_VBD ); cds->ops = colo_ops; cds->callback = colo_save_setup_done; cds->ao = ao;
@@ -453,12 +464,33 @@ static void colo_preresume_cb(libxl__egc *egc, goto out; } +if (!css->paused) { + rc =colo_qdisk_preresume (CTX , dss->domid); +if (rc) { +LOG (ERROR ,"colo_qdisk_preresume() fails" ); + goto out; + } + } +/* Resumes the domain and the device model */ if (libxl__domain_resume (gc, dss->domid,/* Fast Suspend */ 1 )) {LOG (ERROR ,"cannot resume primary vm" ); goto out; } +/* +* The guest should be paused before doing colo because there is +* no disk migration. +*/ +if (css->paused) { + rc =libxl__domain_unpause (gc, dss->domid); +if (rc) { +LOG (ERROR ,"cannot unpause primary vm" ); + goto out; + } + css->paused = false; + } +/* read LIBXL_COLO_SVM_RESUMED */ memset (dc,0 ,sizeof (*dc)); dc->ao = ao;
tools/libxl/libxl_internal.h +18 -0
@@ -1661,6 +1661,14 @@ _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 block replication */ +_hidden int libxl__qmp_block_start_replication(libxl__gc *gc, int domid, +bool primary,const char *addr); +/* Do block checkpoint */ +_hidden int libxl__qmp_block_do_checkpoint(libxl__gc *gc, int domid); +/* Stop block replication */ +_hidden int libxl__qmp_block_stop_replication(libxl__gc *gc, int domid, +bool primary);/* 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,
@@ -2733,6 +2741,9 @@ 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); +int colo_qdisk_preresume (libxl_ctx *ctx,domid_t domid); typedef void libxl__checkpoint_callback(libxl__egc *, libxl__checkpoint_devices_state *,
@@ -2857,6 +2868,10 @@ struct libxl__colo_save_state {uint8_t temp_buff[9 ];void (*callback)(libxl__egc *,libxl__colo_save_state *);bool svm_running; +bool paused; + +/* private, used by qdisk block replication */ +bool qdisk_setuped; };/*----- Domain suspend (save) state structure -----*/
@@ -3195,6 +3210,9 @@ struct libxl__colo_restore_state {libxl__domain_create_cb *saved_cb;void *crcs;libxl__checkpoint_devices_state cds; + +/* private, used by qdisk block replication */ +bool qdisk_setuped; };struct libxl__domain_create_state {
tools/libxl/libxl_qmp.c +31 -0
@@ -965,6 +965,37 @@ int libxl__qmp_cpu_add(libxl__gc *gc, int domid, int idx)return qmp_run_command (gc, domid,"cpu-add" , args,NULL ,NULL ); } +int libxl__qmp_block_start_replication (libxl__gc *gc,int domid, +bool primary,const char *addr) +{ +libxl__json_object *args =NULL ; + +qmp_parameters_add_bool (gc, &args,"enable" , true); +qmp_parameters_add_bool (gc, &args,"primary" , primary); +if (!primary) +qmp_parameters_add_string (gc, &args,"addr" , addr); + +return qmp_run_command (gc, domid,"xen-set-block-replication" , args, +NULL ,NULL ); +} + +int libxl__qmp_block_do_checkpoint (libxl__gc *gc,int domid) +{ +return qmp_run_command (gc, domid,"xen-do-block-checkpoint" ,NULL , +NULL ,NULL ); +} + +int libxl__qmp_block_stop_replication (libxl__gc *gc,int domid,bool primary) +{ +libxl__json_object *args =NULL ; + +qmp_parameters_add_bool (gc, &args,"enable" , false); +qmp_parameters_add_bool (gc, &args,"primary" , primary); + +return qmp_run_command (gc, domid,"xen-set-block-replication" , args, +NULL ,NULL ); +} +int libxl__qmp_initializations (libxl__gc *gc,uint32_t domid,const libxl_domain_config *guest_config) {
Signature · 1 line
1.9.1
Re: [PATCH v6 COLO 09/15] COLO: use qemu block replication
Quoted 3 lines · Yang Hongyang
From: Wen Congyang <[email protected]>
The guest should be paused before doing COLO!!!
I'm not sure what to make of this comment. Please write a commit message which explains what the commit does and the implication etc.
PATCH v6 10/15 COLO proxy: implement setup/teardown of COLO proxy module
In reply to Yang Hongyangsetup/teardown of COLO proxy module.
we use netlink to communicate with proxy module.
--- tools/libxl/Makefile | 1 + tools/libxl/libxl_colo.h | 2 + tools/libxl/libxl_colo_proxy.c | 210 +++++++++++++++++++++++++++++++++++++++++ tools/libxl/libxl_internal.h | 12 +++ 4 files changed, 225 insertions(+) create mode 100644 tools/libxl/libxl_colo_proxy.c
tools/libxl/Makefile +1 -0
@@ -59,6 +59,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
@@ -45,4 +45,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 +210 -0
210 lines not on this page · raw message
tools/libxl/libxl_internal.h +12 -0
@@ -2853,6 +2853,15 @@ struct libxl__remus_state { _hidden int libxl__netbuffer_enabled(libxl__gc *gc);/*----- 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 {libxl__checkpoint_devices_state cds;
@@ -2872,6 +2881,9 @@ struct libxl__colo_save_state {/* private, used by qdisk block replication */ bool qdisk_setuped; + +/* private, used by colo-proxy */ +libxl__colo_proxy_state cps; };/*----- Domain suspend (save) state structure -----*/
Signature · 1 line
1.9.1
Re: [PATCH v6 COLO 10/15] COLO proxy: implement setup/teardown of COLO proxy module
Quoted 2 lines · Yang Hongyang
setup/teardown of COLO proxy module.
we use netlink to communicate with proxy module.
What is a COLO proxy module and where would one get hold of such a thing?
Is this a new kernel feature with a patch? If so then please link to its posting to the appropriate upstream and indicate what you understand of its progress upstream.
(I seem to remember discussing a COLO networking component at the hackathon which seemed like it could be done using existing components, is that this?)
Re: [PATCH v6 COLO 10/15] COLO proxy: implement setup/teardown of COLO proxy module
Quoted 7 lines · Ian Campbell
Quoted 2 lines · Yang Hongyang
setup/teardown of COLO proxy module.
we use netlink to communicate with proxy module.What is a COLO proxy module and where would one get hold of such a thing?
Quoted 7 lines
Is this a new kernel feature with a patch? If so then please link to its posting to the appropriate upstream and indicate what you understand of its progress upstream.
(I seem to remember discussing a COLO networking component at the hackathon which seemed like it could be done using existing components, is that this?)
IIRC the existing component I was thinking of was
http://www.netfilter.org/projects/libnetfilter_queue/ which allows userspace to do pretty advanced filtering, queueing, gating, delaying etc of packets.
Ian.
Re: [PATCH v6 COLO 10/15] COLO proxy: implement setup/teardown of COLO proxy module
Quoted 12 lines · Ian Campbell
Quoted 11 lines · Ian Campbell
Quoted 2 lines · Yang Hongyang
setup/teardown of COLO proxy module.
we use netlink to communicate with proxy module.What is a COLO proxy module and where would one get hold of such a thing?
Is this a new kernel feature with a patch? If so then please link to its posting to the appropriate upstream and indicate what you understand of its progress upstream.
Quoted 8 lines
Quoted 3 lines
(I seem to remember discussing a COLO networking component at the hackathon which seemed like it could be done using existing components, is that this?)
IIRC the existing component I was thinking of was
http://www.netfilter.org/projects/libnetfilter_queue/ which allows userspace to do pretty advanced filtering, queueing, gating, delaying etc of packets.
The reason we are not using userspace solution is that we worried about the performance. There will be huge amount of packets pass through, the context switch cost will be an overhead. The colo-proxy module:
https://lkml.org/lkml/2015/6/18/32
Quoted 5 lines
Ian.
.
Signature · 2 lines
Thanks, Yang.
Re: [PATCH v6 COLO 10/15] COLO proxy: implement setup/teardown of COLO proxy module
Quoted 18 lines · Yang Hongyang
Quoted 16 lines · Ian Campbell
Quoted 14 lines · Ian Campbell
Quoted 2 lines · Yang Hongyang
setup/teardown of COLO proxy module.
we use netlink to communicate with proxy module.What is a COLO proxy module and where would one get hold of such a thing?
Is this a new kernel feature with a patch? If so then please link to its posting to the appropriate upstream and indicate what you understand of its progress upstream.
(I seem to remember discussing a COLO networking component at the hackathon which seemed like it could be done using existing components, is that this?)
Quoted 7 lines
Quoted 4 lines
IIRC the existing component I was thinking of was
http://www.netfilter.org/projects/libnetfilter_queue/ which allows userspace to do pretty advanced filtering, queueing, gating, delaying etc of packets.The reason we are not using userspace solution is that we worried about the performance.
Is this a theoretical concern or something which has actually been observed to be a problem in practice?
Quoted 10 lines
There will be huge amount of packets pass through, the
context switch cost will be an overhead. The colo-proxy module:
https://lkml.org/lkml/2015/6/18/32Quoted 5 lines
Ian.
.
Re: [PATCH v6 COLO 10/15] COLO proxy: implement setup/teardown of COLO proxy module
Quoted 24 lines · Ian Campbell
Quoted 23 lines · Yang Hongyang
Quoted 20 lines · Ian Campbell
Quoted 7 lines · Ian Campbell
Quoted 2 lines · Yang Hongyang
setup/teardown of COLO proxy module.
we use netlink to communicate with proxy module.What is a COLO proxy module and where would one get hold of such a thing?
Quoted 7 lines
Is this a new kernel feature with a patch? If so then please link to its posting to the appropriate upstream and indicate what you understand of its progress upstream.
(I seem to remember discussing a COLO networking component at the hackathon which seemed like it could be done using existing components, is that this?)
IIRC the existing component I was thinking of was
http://www.netfilter.org/projects/libnetfilter_queue/ which allows userspace to do pretty advanced filtering, queueing, gating, delaying etc of packets.
Quoted 5 lines
Quoted 2 lines
The reason we are not using userspace solution is that we worried about the performance.
Is this a theoretical concern or something which has actually been observed to be a problem in practice?
It is a theoretical concern, we haven't had time try to implement the userspace solution yet.
Quoted 15 lines
Quoted 11 lines
There will be huge amount of packets pass through, the
context switch cost will be an overhead. The colo-proxy module:
https://lkml.org/lkml/2015/6/18/32Quoted 5 lines
Ian.
.
.
Signature · 2 lines
Thanks, Yang.
PATCH v6 11/15 COLO proxy: preresume, postresume and checkpoint
In reply to Yang Hongyangpreresume, postresume and checkpoint
--- tools/libxl/libxl_colo.h | 3 +++ tools/libxl/libxl_colo_proxy.c | 57 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+)
tools/libxl/libxl_colo.h +3 -0
@@ -47,4 +47,7 @@ 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);#endif
tools/libxl/libxl_colo_proxy.c +57 -0
60 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH v6 12/15 COLO nic: implement COLO nic subkind
In reply to Yang Hongyangimplement COLO nic subkind.
--- tools/hotplug/Linux/Makefile | 1 + tools/hotplug/Linux/colo-proxy-setup | 131 +++++++++++++++ tools/libxl/Makefile | 1 + tools/libxl/libxl_colo_nic.c | 317 +++++++++++++++++++++++++++++++++++ tools/libxl/libxl_internal.h | 5 + tools/libxl/libxl_types.idl | 1 + 6 files changed, 456 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
@@ -25,6 +25,7 @@ XEN_SCRIPTS += vscsi XEN_SCRIPTS += block-iscsi 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 +131 -0
131 lines not on this page · raw message
tools/libxl/Makefile +1 -0
@@ -60,6 +60,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 +317 -0
317 lines not on this page · raw message
tools/libxl/libxl_internal.h +5 -0
@@ -2744,6 +2744,8 @@ 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 colo_qdisk_preresume (libxl_ctx *ctx,domid_t domid); +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 *,
@@ -2867,6 +2869,7 @@ struct libxl__colo_save_state {libxl__checkpoint_devices_state cds;int send_fd;int recv_fd; +char *colo_proxy_script;/* private */ libxl__datacopier_state dc;
@@ -3217,6 +3220,7 @@ struct libxl__colo_restore_state {int pae;int superpages;libxl__colo_callback *callback; +char *colo_proxy_script;/* private, colo restore checkpoint state */ libxl__domain_create_cb *saved_cb;
@@ -3239,6 +3243,7 @@ struct libxl__domain_create_state {/* private to domain_create */ int guest_domid;int checkpointed_stream; +const char *colo_proxy_script;libxl__domain_build_state build_state;libxl__colo_restore_state crs;libxl__bootloader_state bl;
tools/libxl/libxl_types.idl +1 -0
@@ -538,6 +538,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
1.9.1
Re: [PATCH v6 COLO 12/15] COLO nic: implement COLO nic subkind
Quoted 7 lines · Yang Hongyang
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 | 131 +++++++++++++++
There are hardcoded paths in this script. Please avoid that.
For one Debian has iptables under /sbin, not /usr/local/sbin.
Wei.
Re: [PATCH v6 COLO 12/15] COLO nic: implement COLO nic subkind
Quoted 9 lines · Wei Liu
Quoted 7 lines · Yang Hongyang
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 | 131 +++++++++++++++
Quoted 3 lines
There are hardcoded paths in this script. Please avoid that.
For one Debian has iptables under /sbin, not
/usr/local/sbin.
We are using a modified iptables here. But hardcode is not a good thing, will avoid this in the next version.
Quoted 4 lines
Wei.
.
Signature · 2 lines
Thanks, Yang.
PATCH v6 13/15 setup and control colo proxy on primary side
In reply to Yang Hongyangsetup and control colo proxy on primary side
--- tools/libxl/libxl_colo_save.c | 125 +++++++++++++++++++++++++++++++++++++++--- tools/libxl/libxl_internal.h | 1 + 2 files changed, 118 insertions(+), 8 deletions(-)
tools/libxl/libxl_colo_save.c +117 -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); }
@@ -76,14 +85,28 @@ void libxl__colo_save_setup(libxl__egc *egc, libxl__colo_save_state *css) css->svm_running = false; css->paused = true; css->qdisk_setuped = 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; cds->domid = dss->domid; + 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;
@@ -157,6 +180,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); }
@@ -437,6 +461,8 @@ static void colo_read_svm_ready_done(libxl__egc *egc, goto out; } +colo_proxy_preresume (&css->cps); + css->svm_running = true; css->cds.callback = colo_preresume_cb;libxl__checkpoint_devices_preresume (egc, &css->cds);
@@ -530,6 +556,8 @@ static void colo_read_svm_resumed_done(libxl__egc *egc, goto out; } +colo_proxy_postresume (&css->cps); + ok =1 ; out:
@@ -538,6 +566,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) +{ +int pid =-1 , rc; + +STATE_AO_GC (css->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; + +again: + req =colo_proxy_checkpoint (&css->cps); +if (req <0 ) { +/* some error happens */ +_exit (1 ); + }else if (!req) { +/* no checkpoint is needed, wait for 1ms and the check again */ +usleep (1000 ); + goto again; + }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); + +EGC_GC ; + +if (status) { +LOG (ERROR ,"failed to wait for new checkpoint" ); +colo_start_new_checkpoint (egc, &css->cds,ERROR_FAIL ); +return ; + } + +colo_start_new_checkpoint (egc, &css->cds,0 ); +} +/* * Do the following things: * 1. do commit
@@ -547,9 +660,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);void libxl__colo_save_domain_checkpoint_callback (void *data) {
@@ -578,8 +688,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
@@ -2887,6 +2887,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
1.9.1
PATCH v6 14/15 setup and control colo proxy on secondary side
In reply to Yang Hongyangsetup and control colo proxy on secondary side
--- tools/libxl/libxl_colo_restore.c | 28 +++++++++++++++++++++++++--- tools/libxl/libxl_internal.h | 3 +++ 2 files changed, 28 insertions(+), 3 deletions(-)
tools/libxl/libxl_colo_restore.c +25 -3
@@ -65,9 +65,11 @@ 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_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 , };
@@ -167,8 +169,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:
@@ -180,6 +188,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); }
@@ -398,6 +407,8 @@ static void colo_restore_teardown_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;
@@ -607,6 +618,8 @@ static void colo_restore_preresume_cb(libxl__egc *egc, goto out; } +colo_proxy_preresume (&crs->cps); +colo_restore_resume_vm (egc, crcs);return ;
@@ -643,6 +656,8 @@ static void colo_resume_vm_done(libxl__egc *egc, crcs->status =LIBXL_COLO_RESUMED ; +colo_proxy_postresume (&crs->cps); +/* avoid calling libxl__xc_domain_restore_done() more than once */ if (crs->saved_cb) { dcs->callback = crs->saved_cb;
@@ -792,13 +807,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;
tools/libxl/libxl_internal.h +3 -0
@@ -3230,6 +3230,9 @@ struct libxl__colo_restore_state {/* private, used by qdisk block replication */ bool qdisk_setuped; + +/* private, used by colo proxy */ +libxl__colo_proxy_state cps; };struct libxl__domain_create_state {
Signature · 1 line
1.9.1
PATCH v6 15/15 cmdline switches and config vars to control colo-proxy
In reply to Yang HongyangAdd 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 | 49 ++++++++++++++++++++++++++++++++++----------- 8 files changed, 66 insertions(+), 15 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
@@ -3375,6 +3375,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,libxl__sprintf (gc,LIBXL_MAC_FMT ,LIBXL_MAC_BYTES (nic->mac)));
@@ -3498,6 +3503,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
@@ -1168,6 +1168,11 @@ static void domcreate_bootloader_done(libxl__egc *egc, crs->superpages = superpages; crs->pae = pae; 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); }else libxl__xc_domain_restore(egc, dcs,
@@ -1692,6 +1697,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_fd,int checkpointed_stream, +const char *colo_proxy_script,const libxl_asyncop_how *ao_how,const libxl_asyncprogress_how *aop_console_how) {
@@ -1707,6 +1713,7 @@ static int do_domain_create(libxl_ctx *ctx, libxl_domain_config *d_config, cdcs->dcs.send_fd = send_fd; cdcs->dcs.callback = domain_create_cb; cdcs->dcs.checkpointed_stream = checkpointed_stream; + cdcs->dcs.colo_proxy_script = colo_proxy_script;libxl__ao_progress_gethow (&cdcs->dcs.aop_console_how, aop_console_how); cdcs->domid_out = domid;
@@ -1750,7 +1757,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 ,0 , +return do_domain_create (ctx, d_config, domid,-1 ,-1 ,0 ,NULL , ao_how, aop_console_how); }
@@ -1761,16 +1768,19 @@ int libxl_domain_create_restore(libxl_ctx *ctx, libxl_domain_config *d_config, const libxl_asyncprogress_how *aop_console_how) {int send_fd =-1 ; +char *colo_proxy_script =NULL ;if (params->checkpointed_stream ==LIBXL_CHECKPOINTED_STREAM_COLO ) { send_fd = params->send_fd; + 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_fd, - params->checkpointed_stream, ao_how, aop_console_how); + params->checkpointed_stream, colo_proxy_script, + ao_how, aop_console_how); }/*
tools/libxl/libxl_types.idl +1 -0
@@ -353,6 +353,7 @@ libxl_domain_create_info = Struct("domain_create_info",[ libxl_domain_restore_params = Struct("domain_restore_params", [ ("checkpointed_stream", integer), ("send_fd", integer), + ("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
@@ -178,6 +178,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 +37 -12
116 lines not on this page · raw message
Signature · 1 line
1.9.1