Features/COLO: Difference between revisions

From QEMU
(Add my contact info)
 
(56 intermediate revisions by 3 users not shown)
Line 3: Line 3:


= Background =
= Background =
Virtual machine (VM) replication is a well known technique for providing application-agnostic software-implemented hardware fault
Virtual machine (VM) replication is a well known technique for providing application-agnostic software-implemented hardware fault
tolerance "non-stop service". COLO is a high availability solution. Both primary VM (PVM) and secondary VM (SVM) run in parallel. They
tolerance "non-stop service". COLO 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
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.<br>
released immediately. Otherwise, a VM checkpoint (on demand) is conducted.<br>
The idea is presented in Xen summit 2012, and 2013,
 
and [http://www.socc2013.org/home/program/a3-dong.pdf?attredirects=0 academia paper in SOCC 2013]. It's also presented in
[http://www.linux-kvm.org/wiki/images/1/1d/Kvm-forum-2013-COLO.pdf KVM forum 2013],[http://www.linux-kvm.org/images/0/01/01x07-Hongyang_Yang-Status_update_on_KVM-COLO.pdf KVM forum 2015],[http://www.linux-kvm.org/images/a/af/03x08B-Hailang_Zhang-Status_Update_on_KVM-COLO_FT.pdf KVM forum2016]<br>


= Feature authors =
= Feature authors =
* '''Name:''' Hailiang Zhang, Congyang Wen, Chen Zhang
* '''Name:''' Chen Zhang, Lukas Straub, Hailiang Zhang, Congyang Wen, Yong Wang, Guang Wang
* ''' Email:''' zhang.zhanghailiang@huawei.com
* ''' Email:''' zhangckid@gmail.com/chen.zhang@intel.com, lukasstraub2@web.de, zhang.zhanghailiang@huawei.com, wency@cn.fujitsu.com, wang.yongD@h3c.com, wang.guanga@h3c.com
Zhang Hailiang <zhang.zhanghailiang@huawei.com>;Yang Hongyang <yanghy@cn.fujitsu.com>; Wen Congyang <wency@cn.fujitsu.com>
 
= Architecture =
The architecture of COLO is shown in the bellow diagram.
It consists of a pair of networked physical nodes:
The primary node running the PVM, and the secondary node running the SVM
to maintain a valid replica of the PVM.
PVM and SVM execute in parallel and generate output of response packets for
client requests according to the application semantics.
 
The incoming packets from the client or external network are received by the
primary node, and then forwarded to the secondary node, so that Both the PVM
and the SVM are stimulated with the same requests.
 
COLO receives the outbound packets from both the PVM and SVM and compares them
before allowing the output to be sent to clients.
 
The SVM is qualified as a valid replica of the PVM, as long as it generates
identical responses to all client requests. Once the differences in the outputs
are detected between the PVM and SVM, COLO withholds transmission of the
outbound packets until it has successfully synchronized the PVM state to the SVM.


COLO Framework:<br>
  Primary Node                                                              Secondary Node
[[File:kvm-colo.jpg]]<br>
+------------+  +-----------------------+      +------------------------+  +------------+
|            |  |      HeartBeat      +<----->+      HeartBeat        |  |            |
| Primary VM |  +-----------+-----------+      +-----------+------------+  |Secondary VM|
|            |              |                              |              |            |
|            |  +-----------|-----------+      +-----------|------------+  |            |
|            |  |QEMU  +---v----+      |      |QEMU  +----v---+        |  |            |
|            |  |      |Failover|      |      |      |Failover|        |  |            |
|            |  |      +--------+      |      |      +--------+        |  |            |
|            |  |  +---------------+  |      |  +---------------+    |  |            |
|            |  |  | VM Checkpoint +-------------->+ VM Checkpoint |    |  |            |
|            |  |  +---------------+  |      |  +---------------+    |  |            |
|Requests<--------------------------\ /-----------------\ /--------------------->Requests|
|            |  |                  ^ ^ |      |      | |              |  |            |
|Responses+---------------------\ /-|-|------------\ /-------------------------+Responses|
|            |  |              | | | | |      |  | |  | |              |  |            |
|            |  | +-----------+ | | | | |      |  | |  | | +----------+ |  |            |
|            |  | | COLO disk | | | | | |      |  | |  | | | COLO disk| |  |            |
|            |  | |  Manager +---------------------------->| Manager  | |  |            |
|            |  | ++----------+ v v | | |      |  | v  v | +---------++ |  |            |
|            |  |  |+-----------+-+-+-++|      | ++-+--+-+---------+ |  |  |            |
|            |  |  ||  COLO Proxy    ||      | |  COLO Proxy    | |  |  |            |
|            |  |  || (compare packet  ||      | |(adjust sequence | |  |  |            |
|            |  |  ||and mirror packet)||      | |    and ACK)    | |  |  |            |
|            |  |  |+------------+---^-+|      | +-----------------+ |  |  |            |
+------------+  +-----------------------+      +------------------------+  +------------+
+------------+    |            |  |                                |    +------------+
| VM Monitor |    |            |  |                                |    | VM Monitor |
+------------+    |            |  |                                |    +------------+
+---------------------------------------+      +----------------------------------------+
|  Kernel        |            |  |  |      |  Kernel            |                  |
+---------------------------------------+      +----------------------------------------+
                    |            |  |                                |
    +--------------v+  +---------v---+--+      +------------------+ +v-------------+
    |  Storage    |  |External Network|      | External Network | |  Storage    |
    +---------------+  +----------------+      +------------------+ +--------------+


= Components =
= Components introduction =


* HeartBeat (Not yet implemented)
: Runs on both the primary and secondary nodes, to periodically check platform
: availability. When the primary node suffers a hardware fail-stop failure,
: the heartbeat stops responding, the secondary node will trigger a failover
: as soon as it determines the absence.
* COLO Block Replication (Please refer to [http://wiki.qemu.org/Features/BlockReplication BlockReplication])
* COLO Block Replication (Please refer to [http://wiki.qemu.org/Features/BlockReplication BlockReplication])
: When primary VM writes data into image, the colo disk manger captures this data<br>
: When primary VM writes data into image, the colo disk manger captures this data<br>
: and send it to secondary VM’s which makes sure the context of secondary VM's image is consentient with<br>
: and send it to secondary VM’s which makes sure the context of secondary VM's image is consentient with<br>
: the context of primary VM 's image.
: the context of primary VM 's image.
: The following is the image of block replication workflow:
        +----------------------+            +------------------------+
        |Primary Write Requests|            |Secondary Write Requests|
        +----------------------+            +------------------------+
                  |                                      |
                  |                                      (4)
                  |                                      V
                  |                              /-------------\
                  |      Copy and Forward        |            |
                  |---------(1)----------+      | Disk Buffer |
                  |                      |      |            |
                  |                    (3)      \-------------/
                  |                speculative      ^
                  |                write through    (2)
                  |                      |          |
                  V                      V          |
          +--------------+          +----------------+
          | Primary Disk |          | Secondary Disk |
          +--------------+          +----------------+
    1) Primary write requests will be copied and forwarded to Secondary
      QEMU.
    2) Before Primary write requests are written to Secondary disk, the
      original sector content will be read from Secondary disk and
      buffered in the Disk buffer, but it will not overwrite the existing
      sector content (it could be from either "Secondary Write Requests" or
      previous COW of "Primary Write Requests") in the Disk buffer.
    3) Primary write requests will be written to Secondary disk.
    4) Secondary write requests will be buffered in the Disk buffer and it
      will overwrite the existing sector content in the buffer.
* COLO framework: COLO Checkpoint/Failover Controller  
* COLO framework: COLO Checkpoint/Failover Controller  
: Modifications of save/restore flow to realize continuous migration, to make sure the state of VM in Secondary side  
: Modifications of save/restore flow to realize continuous migration, to make sure the state of VM in Secondary side  
Line 33: Line 120:
: start a checkpoint according to some rules.
: start a checkpoint according to some rules.


= Current Status =
  Primary qemu                                                          Secondary qemu
  * Copyright (c) 2016 HUAWEI TECHNOLOGIES CO.,LTD.
+--------------------------------------------------------------+      +----------------------------------------------------------------+
  * Copyright (c) 2016 FUJITSU LIMITED
| +----------------------------------------------------------+ |      |  +-----------------------------------------------------------+ |
  * Copyright (c) 2016 Intel Corporation
| |                                                          | |      |  |                                                          | |
Github:(Checkout to latest colo branch)
| |                        guest                            | |      |  |                        guest                              | |
:[https://github.com/Pating/qemu COLO replication branch]
| |                                                          | |      |  |                                                          | |
:[https://github.com/coloft/qemu COLO framework branch]
| +-------^--------------------------+-----------------------+ |      |  +---------------------+--------+----------------------------+ |
:[https://github.com/zhangckid/qemu colo-proxy branch]
|        |                          |                        |      |                        ^        |                              |
|        |                          |                        |      |                        |        |                              |
|        |  +------------------------------------------------------+  |                        |        |                              |
|netfilter|  |                      |                        |    |  |  netfilter            |        |                              |
| +----------+ +----------------------------+                  |    |  |  +-----------------------------------------------------------+ |
| |      |  |                      |      |        out      |    |  |  |                    |        |  filter excute order      | |
| |      |  |          +-----------------------------+        |    |  |  |                    |        | +------------------->      | |
  | |      |  |          |            |      |        |        |    |  |  |                    |        |  TCP                      | |
  | | +-----+--+-+  +-----v----+ +-----v----+ |pri +----+----+sec|    |  |  | +------------+  +---+----+---v+rewriter++  +------------+ | |
  | | |          |  |          | |          | |in  |        |in |    |  |  | |            |  |        |              |  |            | | |
| | |  filter  |  |  filter  | |  filter  +------>  colo   <------+ +-------->  filter  +--> adjust |  adjust    +-->  filter  | | |
| | |  mirror  |  |redirector| |redirector| |    | compare |  |  |    |  | | redirector |  | ack    |  seq        |  | redirector | | |
| | |          |  |          | |          | |    |        |  |  |    |  | |            |  |        |              |  |            | | |
| | +----^-----+  +----+-----+ +----------+ |    +---------+  |  |    |  | +------------+  +--------+--------------+  +---+--------+ | |
| |      |  tx        |  rx          rx  |                  |  |    |  |            tx                        all      |  rx      | |
| |      |            |                    |                  |  |    |  +-----------------------------------------------------------+ |
| |      |            +--------------+    |                  |  |    |                                                  |            |
| |      |  filter excute order      |    |                  |  |    |                                                  |            |
| |      |  +---------------->        |    |                  |  +--------------------------------------------------------+            |
| +-----------------------------------------+                  |      |                                                                |
|        |                            |                        |      |                                                                |
+--------------------------------------------------------------+      +----------------------------------------------------------------+
          |guest receive              | guest send
          |                            |
+--------+----------------------------v------------------------+
|                                                              |                          NOTE: filter direction is rx/tx/all
|                        tap                                  |                          rx:receive packets sent to the netdev
|                                                              |                          tx:receive packets sent by the netdev
+--------------------------------------------------------------+
: In COLO-compare, we do packet comparing job.
: Packets coming from the primary char indev will be sent to outdev.
: Packets coming from the secondary char dev will be dropped after comparing.  
: colo-comapre need two input chardev and one output chardev: primary_in=chardev1-id (source: primary send packet) secondary_in=chardev2-id (source: secondary send packet) outdev=chardev3-id


= Failover command =
*'''Note:
We provide a qmp command:
: HeartBeat is not been realized, so you need to trigger failover process by using 'x-colo-lost-heartbeat' command.
<pre>x-colo-lost-heartbeat</pre>


This command will tell COLO that heartbeat is lost. COLO will do some action accordingly. External heartbeat modules can use this qmp command to communicate with COLO. Users can choose whatever heartbeat implementation they want.
= Current Status =
 
Have been merged in Qemu upstream (v4.0).
Failover rule:<br>
TODO:


= How to setup/test COLO =
= How to setup/test COLO =
=== '''Hardware requirements''' ===
For automatically managed colo: [[Features/COLO/Managed HOWTO]]
There is at least one directly connected nic to forward the network requests from client to secondary vm.
The directly connected nic must not be used by any other purpose. you should have directly connected nic for
each guest nic. If you don't have enouth directly connected nic, you can use vlan.
 
=== '''Network link topology''' ===
<pre>
=================================normal ======================================
                                +--------+
                                |client  |
        master                +----+---+                    slave
-------------------------+          |            + -------------------------+
  PVM                  |          +            |                          |
+-------+        +----[eth0]-----[switch]-----[eth0]---------+              |
|guest  |    +---+-+    |                        |      +---+-+            |
|    [tap0]--+ br0 |    |                        |      | br0 |            |
|      |    +-----+  [eth1]-----[forward]----[eth1]--+  +-----+    SVM    |
+-------+                |                        |    |            +-------+|
                        |                        |    |  +-----+  | guest ||
                      [eth2]---[checkpoint]---[eth2]  +--+br1  |-[tap0]    ||
                        |                        |      +-----+  |      ||
                        |                        |                +-------+|
-------------------------+                        +--------------------------+
e.g.
master:
br0: 192.168.0.33
eth1: 192.168.1.33
eth2: 192.168.2.33
 
slave:
br0: 192.168.0.88
br1: no ip address
eth1: 192.168.1.88
eth2: 192.168.2.88
NOTE: br0 is setup by adminitrator but br1 is setup by colo now.
</pre>
<pre>
===========================after failover=====================================
                                +--------+
                                |client  |
    master (dead)              +----+---+                slave (alive)
-------------------------+          |            ---------------------------+
  PVM                    |          +            |                          |
+-------+        +----[eth0]-----[switch]-----[eth0]-------+                |
|guest  |    +---+-+    |                        |    +---+-+              |
|    [tap0]--+ br0 |    |                        |    | br0 +--+          |
|      |    +-----+  [eth1]-----[forward]----[eth1]  +-----+  |    SVM  |
+-------+                |                        |              |  +-------+|
                        |                        |    +-----+  |  | guest ||
                      [eth2]---[checkpoint]---[eth2]  |br1  |  +[tap0]    ||
                        |                        |    +-----+    |      ||
                        |                        |                +-------+|
-------------------------+                        +--------------------------+
</pre>
 
=== '''Test environment prepare''' ===
* Prepare host kernel
:colo-proxy kernel module need cooperate with linux kernel.
:You should patch [https://github.com/coloft/colo-proxy/blob/master/patch4kernel/0001-colo-patch-for-kernel.patch colo-patch-for-kernel.patch] into kernel codes,
:then compile kernel and intall the new kernel (Recommend [https://www.kernel.org/ kernel-3.18.10])
 
* Proxy module
** proxy module is used for network packets compare.
<pre>
# git clone https://github.com/coloft/colo-proxy.git
# cd ./colo-proxy
# make
# make install
</pre>
* Modified [https://github.com/coloft/iptables.git iptables]
** We have add a new rule to iptables command.
<pre>
# git clone https://github.com/coloft/iptables.git
# cd ./iptables
# git checkout colo
# ./autogen.sh && ./configure
# make && make install
</pre>


*Modified arptables
For manual use of colo via qmp commands: [[Features/COLO/Manual HOWTO]]
** Please get the latest [http://git.netfilter.org/arptables arptables] and then compile and install


* Qemu colo
= Heartbeat Service =
** Checkout the latest colo branch from [https://github.com/coloft/qemu/tree/colo-v1.5-basic colo-v1.5-basic] or
COLO support internal and external heartbeat service, they both use same qemu interface(qmp or monitor commands).
***[https://github.com/coloft/qemu/tree/colo-v1.5-developing colo-v1.5-developing(More features)]
For internal service, we introduce new Qemu module named Advanced Watch Dog for this job.
Advanced Watch Dog is an universal monitoring module on VMM side, it can be used to detect network down(VMM to guest, VMM to VMM, VMM to another remote server) and do previously set operation.  
If you want to use it, please add "--enable-awd" when configure qemu.
In primary node:
<pre>
<pre>
# cd qemu
-monitor tcp::4445,server,nowait
# ./configure --target-list=x86_64-softmmu --enable-colo
-chardev socket,id=h1,host=3.3.3.3,port=9009,server,nowait
# make
-chardev socket,id=heartbeat0,host=3.3.3.3,port=4445
-object iothread,id=iothread1
-object advanced-watchdog,id=heart1,server=on,awd_node=h1,notification_node=heartbeat0,
opt_script=colo_primary_opt_script,iothread=iothread1,pulse_interval=1000,timeout=5000
</pre>
</pre>


* Set Up the Bridge and network environment
colo_primary_opt_script:
** You must setup you network environment like above picture('''Network link topology''' Normal).
<pre>
<pre>
In master, setup a bridge br0, using command brctl, like:
x_colo_lost_heartbeat
# ifconfig eth0 down
# ifconfig eth0 0.0.0.0
# brctl addbr br0
# brctl addif br0 eth0
# ifconfig br0 192.168.0.33 netmask 255.255.255.0
# ifconfig eth0 up
In slave, setup br0 like master side
</pre>
</pre>


* Qemu-ifup/Qemu-ifdown
In secondary node:
** We need a script to bring up the TAP interface.
** a qemu-ifdown script is needed to reset you networking configuration which is configured by qemu-ifup script
:You can find this info from [http://en.wikibooks.org/wiki/QEMU/Networking http://en.wikibooks.org/wiki/QEMU/Networking].
<pre>
NOTE: Don't forget to change this script file permission to be executable


Master:
root@master# cat /etc/qemu-ifup
#!/bin/sh
switch=br0
if [ -n "$1" ]; then
        ip link set $1 up
        brctl addif ${switch} $1
fi
root@master# cat /etc/qemu-ifdown
!/bin/sh
switch=br0
if [ -n "$1" ]; then
        brctl delif ${switch} $1
fi
Slave:
like Master side
</pre>
=== '''Test steps''' ===
('''''Note: We apply two scripts to help completing step (1) ~ step (2), [https://github.com/coloft/colo-test/blob/master/primary-colo.sh primary-colo.sh] [https://github.com/coloft/colo-test/blob/master/secondary-colo.sh secondary-colo.sh])'''''
*(1) Load modeule
<pre>
<pre>
# modprobe xt_PMYCOLO (For slave side, modprobe xt_SECCOLO)
-monitor tcp::4445,server,nowait
# modprobe nf_conntrack_colo (Other colo module will be automatically loaded by
-chardev socket,id=h1,host=3.3.3.3,port=9009,reconnect=1
script colo-proxy-script.sh)
-chardev socket,id=heart1,host=3.3.3.8,port=4445
# modprobe xt_mark
-object iothread,id=iothread1
# modprobe kvm-intel
-object advanced-watchdog,id=heart1,server=off,awd_node=h1,notification_node=he
art1,opt_script=colo_secondary_opt_script,iothread=iothread1,timeout=10000
</pre>
</pre>


*(2) Startup qemu
colo_secondary_opt_script:
 
*''Master side:''
<pre>
<pre>
# x86_64-softmmu/qemu-system-x86_64 -machine pc-i440fx-2.3,accel=kvm,usb=off \
nbd_server_stop
-netdev tap,id=hn0,script=/etc/qemu-ifup,downscript=/etc/qemu-ifdown,\
x_colo_lost_heartbeat
colo_script=./scripts/colo-proxy-script.sh,forward_nic=eth1 -device virtio-net-pci,id=net-pci0,netdev=hn0 \
-boot c -drive if=virtio,id=disk1,driver=quorum,read-pattern=fifo,cache=none,aio=native,\
children.0.file.filename=/mnt/sdb/pure_IMG/redhat/redhat-7.0.img,children.0.driver=raw \
-vnc :7 -m 2048 -smp 2 -device piix3-usb-uhci -device usb-tablet -monitor stdio -S
</pre>
</pre>
This parts of code still under review.
https://github.com/zhangckid/qemu/tree/colo-with-awd19dec1


*''Slave side:''
For external service, user can write service and policy itself, it detect network down, just need notify COLO service.
<pre>
# qemu-img create -f qcow2 /mnt/ramfs/active_disk.img 10G
 
# qemu-img create -f qcow2 /mnt/ramfs/hidden_disk.img 10G
 
# x86_64-softmmu/qemu-system-x86_64 -machine pc-i440fx-2.3,accel=kvm,usb=off \
-netdev tap,id=hn0,script=/etc/qemu-ifup,downscript=/etc/qemu-ifdown,\
colo_script=./scripts/colo-proxy-script.sh,forward_nic=eth1 -device virtio-net-pci,id=net-pci0,netdev=hn0 \
-drive if=none,driver=raw,file=/mnt/sdb/pure_IMG/redhat/redhat-7.0.img,id=colo1,cache=none,aio=native \
-drive if=virtio,driver=replication,mode=secondary,throttling.bps-total-max=70000000,\
file.file.filename=/mnt/ramfs/active_disk.img,file.driver=qcow2,\
file.backing.file.filename=/mnt/ramfs/hidden_disk.img,\
file.backing.driver=qcow2,\
file.backing.backing.backing_reference=colo1,\
file.backing.allow-write-backing-file=on \
-vnc :7 -m 2048 -smp 2 -device piix3-usb-uhci -device usb-tablet -monitor stdio -incoming tcp:0:8888
</pre>
  '''''Note:'''''
  ''1. The export name in secondary QEMU command line is the secondary disk's id. In the expampe, it is colo1.
  ''2. The export name for primary disk is not in the command line. It is in child_add's argument. Please see below.
  ''3. The export name for the same disk must be the same
  ''4. The qmp command nbd-server-start and nbd-server-add must be run before running the qmp command migrate on primary QEMU
  ''5. Don't use nbd-server-start's other options
  ''6. Active disk, hidden disk and nbd target's length should be the same.
  ''7. It is better to put active disk and hidden disk in ramdisk.
  ''8. It is all a single argument to -drive, and you should ignore the leading whitespace.
 
*(3) On Secondary VM's QEMU monitor, issue command (This command must be run before command in step (4))''
<pre>
(qemu) nbd_server_start 192.168.2.88:8889
(qemu) nbd_server_add -w colo1
</pre>
 
*(4) On Primary VM's QEMU monitor, issue command:
<pre>
(qemu) child_add disk1 child.driver=replication,child.mode=primary,child.file.host=192.168.2.88,child.file.port=8889,child.file.export=colo1,child.file.driver=nbd,child.ignore-errors=on
(qemu) migrate_set_capability colo on
(qemu) migrate tcp:192.168.2.88:8888
</pre>
  '''''Note:'''''
  ''1. There should be only one NBD Client.''
  ''2. host is the secondary physical machine's hostname or IP''
  ''3. Each disk must have its own export name.''


*(5) Done
= Supporting documentation =
** You will see two runing VMs, whenever you make changes to PVM, SVM will be synced.
The idea is presented in Xen summit 2012, 2013 and [https://static.sched.com/hosted_files/xensummit19/d0/Application%20Agnostic%20High%20Availability%20Solution%20On%20Hypervisor%20Level%20-%20V1.4.pdf 2019]
and [http://www.socc2013.org/home/program/a3-dong.pdf?attredirects=0 academia paper in SOCC 2013].


*(6) Failover test
It is also presented in
** You can kill SVM (PVM) and run 'colo_lost_heartbeat' in PVM's (SVM's) monitor at the same time, then PVM (SVM) will failover and client will not feel this change.
[https://www.linux-kvm.org/images/1/1d/Kvm-forum-2013-COLO.pdf KVM forum 2013], [http://www.linux-kvm.org/images/0/01/01x07-Hongyang_Yang-Status_update_on_KVM-COLO.pdf KVM forum 2015] and [http://www.linux-kvm.org/images/a/af/03x08B-Hailang_Zhang-Status_Update_on_KVM-COLO_FT.pdf KVM forum2016]


* For Questions/Issues, please contact: Zhang Hailiang <zhang.zhanghailiang@huawei.com>;Yang Hongyang <yanghy@cn.fujitsu.com>; Wen Congyang <wency@cn.fujitsu.com>
= Future works =
: 1. Support continuously VM replication.
: 2. Support shared storage.
: 3. Develop the heartbeat part.
: 4. Reduce checkpoint VM’s downtime while do checkpoint.


= Links =
= Links =
* [http://wiki.xen.org/wiki/COLO_-_Coarse_Grain_Lock_Stepping COLO on Xen]
* [http://wiki.xen.org/wiki/COLO_-_Coarse_Grain_Lock_Stepping COLO on Xen]

Latest revision as of 18:38, 30 January 2023

Feature Name

COarse-grained LOck-stepping Virtual Machines for Non-stop Service

Background

Virtual machine (VM) replication is a well known technique for providing application-agnostic software-implemented hardware fault tolerance "non-stop service". COLO 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.


Feature authors

  • Name: Chen Zhang, Lukas Straub, Hailiang Zhang, Congyang Wen, Yong Wang, Guang Wang
  • Email: zhangckid@gmail.com/chen.zhang@intel.com, lukasstraub2@web.de, zhang.zhanghailiang@huawei.com, wency@cn.fujitsu.com, wang.yongD@h3c.com, wang.guanga@h3c.com

Architecture

The architecture of COLO is shown in the bellow diagram. It consists of a pair of networked physical nodes: The primary node running the PVM, and the secondary node running the SVM to maintain a valid replica of the PVM. PVM and SVM execute in parallel and generate output of response packets for client requests according to the application semantics.

The incoming packets from the client or external network are received by the primary node, and then forwarded to the secondary node, so that Both the PVM and the SVM are stimulated with the same requests.

COLO receives the outbound packets from both the PVM and SVM and compares them before allowing the output to be sent to clients.

The SVM is qualified as a valid replica of the PVM, as long as it generates identical responses to all client requests. Once the differences in the outputs are detected between the PVM and SVM, COLO withholds transmission of the outbound packets until it has successfully synchronized the PVM state to the SVM.

 Primary Node                                                              Secondary Node
+------------+  +-----------------------+       +------------------------+  +------------+
|            |  |       HeartBeat       +<----->+       HeartBeat        |  |            |
| Primary VM |  +-----------+-----------+       +-----------+------------+  |Secondary VM|
|            |              |                               |               |            |
|            |  +-----------|-----------+       +-----------|------------+  |            |
|            |  |QEMU   +---v----+      |       |QEMU  +----v---+        |  |            |
|            |  |       |Failover|      |       |      |Failover|        |  |            |
|            |  |       +--------+      |       |      +--------+        |  |            |
|            |  |   +---------------+   |       |   +---------------+    |  |            |
|            |  |   | VM Checkpoint +-------------->+ VM Checkpoint |    |  |            |
|            |  |   +---------------+   |       |   +---------------+    |  |            |
|Requests<--------------------------\ /-----------------\ /--------------------->Requests|
|            |  |                   ^ ^ |       |       | |              |  |            |
|Responses+---------------------\ /-|-|------------\ /-------------------------+Responses|
|            |  |               | | | | |       |  | |  | |              |  |            |
|            |  | +-----------+ | | | | |       |  | |  | | +----------+ |  |            |
|            |  | | COLO disk | | | | | |       |  | |  | | | COLO disk| |  |            |
|            |  | |   Manager +---------------------------->| Manager  | |  |            |
|            |  | ++----------+ v v | | |       |  | v  v | +---------++ |  |            |
|            |  |  |+-----------+-+-+-++|       | ++-+--+-+---------+ |  |  |            |
|            |  |  ||   COLO Proxy     ||       | |   COLO Proxy    | |  |  |            |
|            |  |  || (compare packet  ||       | |(adjust sequence | |  |  |            |
|            |  |  ||and mirror packet)||       | |    and ACK)     | |  |  |            |
|            |  |  |+------------+---^-+|       | +-----------------+ |  |  |            |
+------------+  +-----------------------+       +------------------------+  +------------+
+------------+     |             |   |                                |     +------------+
| VM Monitor |     |             |   |                                |     | VM Monitor |
+------------+     |             |   |                                |     +------------+
+---------------------------------------+       +----------------------------------------+
|   Kernel         |             |   |  |       |   Kernel            |                  |
+---------------------------------------+       +----------------------------------------+
                   |             |   |                                |
    +--------------v+  +---------v---+--+       +------------------+ +v-------------+
    |   Storage     |  |External Network|       | External Network | |   Storage    |
    +---------------+  +----------------+       +------------------+ +--------------+

Components introduction

  • HeartBeat (Not yet implemented)
Runs on both the primary and secondary nodes, to periodically check platform
availability. When the primary node suffers a hardware fail-stop failure,
the heartbeat stops responding, the secondary node will trigger a failover
as soon as it determines the absence.
When primary VM writes data into image, the colo disk manger captures this data
and send it to secondary VM’s which makes sure the context of secondary VM's image is consentient with
the context of primary VM 's image.
The following is the image of block replication workflow:
       +----------------------+            +------------------------+
       |Primary Write Requests|            |Secondary Write Requests|
       +----------------------+            +------------------------+
                 |                                       |
                 |                                      (4)
                 |                                       V
                 |                              /-------------\
                 |      Copy and Forward        |             |
                 |---------(1)----------+       | Disk Buffer |
                 |                      |       |             |
                 |                     (3)      \-------------/
                 |                 speculative      ^
                 |                write through    (2)
                 |                      |           |
                 V                      V           |
          +--------------+           +----------------+
          | Primary Disk |           | Secondary Disk |
          +--------------+           +----------------+
   1) Primary write requests will be copied and forwarded to Secondary
      QEMU.
   2) Before Primary write requests are written to Secondary disk, the
      original sector content will be read from Secondary disk and
      buffered in the Disk buffer, but it will not overwrite the existing
      sector content (it could be from either "Secondary Write Requests" or
      previous COW of "Primary Write Requests") in the Disk buffer.
   3) Primary write requests will be written to Secondary disk.
   4) Secondary write requests will be buffered in the Disk buffer and it
      will overwrite the existing sector content in the buffer.
  • COLO framework: COLO Checkpoint/Failover Controller
Modifications of save/restore flow to realize continuous migration, to make sure the state of VM in Secondary side
always be consistent with VM in Primary side.
  • COLO Proxy:
Delivers packets to Primary and Seconday, and then compare the reponse from both side. Then decide whether to
start a checkpoint according to some rules.
 Primary qemu                                                           Secondary qemu
+--------------------------------------------------------------+       +----------------------------------------------------------------+
| +----------------------------------------------------------+ |       |  +-----------------------------------------------------------+ |
| |                                                          | |       |  |                                                           | |
| |                        guest                             | |       |  |                        guest                              | |
| |                                                          | |       |  |                                                           | |
| +-------^--------------------------+-----------------------+ |       |  +---------------------+--------+----------------------------+ |
|         |                          |                         |       |                        ^        |                              |
|         |                          |                         |       |                        |        |                              |
|         |  +------------------------------------------------------+  |                        |        |                              |
|netfilter|  |                       |                         |    |  |   netfilter            |        |                              |
| +----------+ +----------------------------+                  |    |  |  +-----------------------------------------------------------+ |
| |       |  |                       |      |        out       |    |  |  |                     |        |  filter excute order       | |
| |       |  |          +-----------------------------+        |    |  |  |                     |        | +------------------->      | |
| |       |  |          |            |      |         |        |    |  |  |                     |        |   TCP                      | |
| | +-----+--+-+  +-----v----+ +-----v----+ |pri +----+----+sec|    |  |  | +------------+  +---+----+---v+rewriter++  +------------+ | |
| | |          |  |          | |          | |in  |         |in |    |  |  | |            |  |        |              |  |            | | |
| | |  filter  |  |  filter  | |  filter  +------>  colo   <------+ +-------->  filter   +--> adjust |   adjust     +-->   filter   | | |
| | |  mirror  |  |redirector| |redirector| |    | compare |   |  |    |  | | redirector |  | ack    |   seq        |  | redirector | | |
| | |          |  |          | |          | |    |         |   |  |    |  | |            |  |        |              |  |            | | |
| | +----^-----+  +----+-----+ +----------+ |    +---------+   |  |    |  | +------------+  +--------+--------------+  +---+--------+ | |
| |      |   tx        |   rx           rx  |                  |  |    |  |            tx                        all       |  rx      | |
| |      |             |                    |                  |  |    |  +-----------------------------------------------------------+ |
| |      |             +--------------+     |                  |  |    |                                                   |            |
| |      |   filter excute order      |     |                  |  |    |                                                   |            |
| |      |  +---------------->        |     |                  |  +--------------------------------------------------------+            |
| +-----------------------------------------+                  |       |                                                                |
|        |                            |                        |       |                                                                |
+--------------------------------------------------------------+       +----------------------------------------------------------------+
         |guest receive               | guest send
         |                            |
+--------+----------------------------v------------------------+
|                                                              |                          NOTE: filter direction is rx/tx/all
|                         tap                                  |                          rx:receive packets sent to the netdev
|                                                              |                          tx:receive packets sent by the netdev
+--------------------------------------------------------------+
In COLO-compare, we do packet comparing job.
Packets coming from the primary char indev will be sent to outdev.
Packets coming from the secondary char dev will be dropped after comparing.
colo-comapre need two input chardev and one output chardev: primary_in=chardev1-id (source: primary send packet) secondary_in=chardev2-id (source: secondary send packet) outdev=chardev3-id
  • Note:
HeartBeat is not been realized, so you need to trigger failover process by using 'x-colo-lost-heartbeat' command.

Current Status

Have been merged in Qemu upstream (v4.0).

How to setup/test COLO

For automatically managed colo: Features/COLO/Managed HOWTO

For manual use of colo via qmp commands: Features/COLO/Manual HOWTO

Heartbeat Service

COLO support internal and external heartbeat service, they both use same qemu interface(qmp or monitor commands). For internal service, we introduce new Qemu module named Advanced Watch Dog for this job. Advanced Watch Dog is an universal monitoring module on VMM side, it can be used to detect network down(VMM to guest, VMM to VMM, VMM to another remote server) and do previously set operation. If you want to use it, please add "--enable-awd" when configure qemu. In primary node:

-monitor tcp::4445,server,nowait
-chardev socket,id=h1,host=3.3.3.3,port=9009,server,nowait
-chardev socket,id=heartbeat0,host=3.3.3.3,port=4445
-object iothread,id=iothread1
-object advanced-watchdog,id=heart1,server=on,awd_node=h1,notification_node=heartbeat0,
opt_script=colo_primary_opt_script,iothread=iothread1,pulse_interval=1000,timeout=5000

colo_primary_opt_script:

x_colo_lost_heartbeat

In secondary node:

-monitor tcp::4445,server,nowait
-chardev socket,id=h1,host=3.3.3.3,port=9009,reconnect=1
-chardev socket,id=heart1,host=3.3.3.8,port=4445
-object iothread,id=iothread1
-object advanced-watchdog,id=heart1,server=off,awd_node=h1,notification_node=he
art1,opt_script=colo_secondary_opt_script,iothread=iothread1,timeout=10000

colo_secondary_opt_script:

nbd_server_stop
x_colo_lost_heartbeat

This parts of code still under review. https://github.com/zhangckid/qemu/tree/colo-with-awd19dec1

For external service, user can write service and policy itself, it detect network down, just need notify COLO service.

Supporting documentation

The idea is presented in Xen summit 2012, 2013 and 2019 and academia paper in SOCC 2013.

It is also presented in KVM forum 2013, KVM forum 2015 and KVM forum2016

Future works

1. Support continuously VM replication.
2. Support shared storage.
3. Develop the heartbeat part.
4. Reduce checkpoint VM’s downtime while do checkpoint.

Links