[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [RFC Patch v2 14/16] add callback to configure network for colo
In colo mode, we will compare the output packets from PVM and SVM, and decide whether a new checkpoint is needed. We should configure network for colo. For example: copy and forward input packets to SVM, forward output packets from SVM to master. All these works will be auto done in a script. This patch only adds a callback to execute this script. Signed-off-by: Ye Wei <wei.ye1987@xxxxxxxxx> Signed-off-by: Jiang Yunhong <yunhong.jiang@xxxxxxxxx> Signed-off-by: Wen Congyang <wency@xxxxxxxxxxxxxx> --- tools/python/xen/lowlevel/checkpoint/checkpoint.c | 20 ++++++++++++++++++-- tools/python/xen/remus/save.py | 8 +++++--- tools/remus/remus | 11 ++++++++++- 3 files changed, 33 insertions(+), 6 deletions(-) diff --git a/tools/python/xen/lowlevel/checkpoint/checkpoint.c b/tools/python/xen/lowlevel/checkpoint/checkpoint.c index c5cdd83..ec14b27 100644 --- a/tools/python/xen/lowlevel/checkpoint/checkpoint.c +++ b/tools/python/xen/lowlevel/checkpoint/checkpoint.c @@ -22,6 +22,7 @@ typedef struct { PyObject* suspend_cb; PyObject* postcopy_cb; PyObject* checkpoint_cb; + PyObject* setup_cb; PyThreadState* threadstate; } CheckpointObject; @@ -91,6 +92,8 @@ static PyObject* pycheckpoint_close(PyObject* obj, PyObject* args) self->postcopy_cb = NULL; Py_XDECREF(self->checkpoint_cb); self->checkpoint_cb = NULL; + Py_XDECREF(self->setup_cb); + self->setup_cb = NULL; Py_INCREF(Py_None); return Py_None; @@ -103,6 +106,7 @@ static PyObject* pycheckpoint_start(PyObject* obj, PyObject* args) { PyObject* suspend_cb = NULL; PyObject* postcopy_cb = NULL; PyObject* checkpoint_cb = NULL; + PyObject* setup_cb = NULL; unsigned int interval = 0; unsigned int flags = 0; @@ -110,8 +114,8 @@ static PyObject* pycheckpoint_start(PyObject* obj, PyObject* args) { struct save_callbacks callbacks; int rc; - if (!PyArg_ParseTuple(args, "O|OOOII", &iofile, &suspend_cb, &postcopy_cb, - &checkpoint_cb, &interval, &flags)) + if (!PyArg_ParseTuple(args, "O|OOOOII", &iofile, &suspend_cb, &postcopy_cb, + &checkpoint_cb, &setup_cb, &interval, &flags)) return NULL; self->interval = interval; @@ -120,6 +124,7 @@ static PyObject* pycheckpoint_start(PyObject* obj, PyObject* args) { Py_XINCREF(suspend_cb); Py_XINCREF(postcopy_cb); Py_XINCREF(checkpoint_cb); + Py_XINCREF(setup_cb); fd = PyObject_AsFileDescriptor(iofile); Py_DECREF(iofile); @@ -155,6 +160,15 @@ static PyObject* pycheckpoint_start(PyObject* obj, PyObject* args) { } else self->checkpoint_cb = NULL; + if (setup_cb && setup_cb != Py_None) { + if (!PyCallable_Check(setup_cb)) { + PyErr_SetString(PyExc_TypeError, "setup callback not callable"); + return NULL; + } + self->setup_cb = setup_cb; + } else + self->setup_cb = NULL; + memset(&callbacks, 0, sizeof(callbacks)); callbacks.suspend = suspend_trampoline; callbacks.postcopy = postcopy_trampoline; @@ -180,6 +194,8 @@ static PyObject* pycheckpoint_start(PyObject* obj, PyObject* args) { Py_XDECREF(postcopy_cb); self->checkpoint_cb = NULL; Py_XDECREF(checkpoint_cb); + self->setup_cb = NULL; + Py_XDECREF(self->setup_cb); return NULL; } diff --git a/tools/python/xen/remus/save.py b/tools/python/xen/remus/save.py index 2193061..81e05b9 100644 --- a/tools/python/xen/remus/save.py +++ b/tools/python/xen/remus/save.py @@ -133,7 +133,7 @@ class Keepalive(object): class Saver(object): def __init__(self, domid, fd, suspendcb=None, resumecb=None, - checkpointcb=None, interval=0, flags=0): + checkpointcb=None, setupcb=None, interval=0, flags=0): """Create a Saver object for taking guest checkpoints. domid: name, number or UUID of a running domain fd: a stream to which checkpoint data will be written. @@ -142,6 +142,7 @@ class Saver(object): checkpointcb: callback invoked when a checkpoint is complete. Return True to take another checkpoint, or False to stop. flags: Remus flags to be passed to xc_domain_save + setupcb: callback invoked to configure network for colo """ self.fd = fd self.suspendcb = suspendcb @@ -149,6 +150,7 @@ class Saver(object): self.checkpointcb = checkpointcb self.interval = interval self.flags = flags + self.setupcb = setupcb self.vm = vm.VM(domid) @@ -166,8 +168,8 @@ class Saver(object): try: self.checkpointer.open(self.vm.domid) self.checkpointer.start(self.fd, self.suspendcb, self.resumecb, - self.checkpointcb, self.interval, - self.flags) + self.checkpointcb, self.setupcb, + self.interval, self.flags) except xen.lowlevel.checkpoint.error, e: raise CheckpointError(e) finally: diff --git a/tools/remus/remus b/tools/remus/remus index d5178cd..7be7fdd 100644 --- a/tools/remus/remus +++ b/tools/remus/remus @@ -164,6 +164,15 @@ def run(cfg): if closure.cmd == 'r2': die() + def setup(): + 'setup network' + if cfg.colo: + for vif in dom.vifs: + print "setup %s" % vif.dev + print util.runcmd(['/etc/xen/scripts/network-colo', 'master', 'install', vif.dev, 'eth0']) + return True + return False + def commit(): 'commit network buffer' if closure.cmd == 'c': @@ -199,7 +208,7 @@ def run(cfg): rc = 0 checkpointer = save.Saver(cfg.domid, fd, postsuspend, preresume, commit, - interval, cfg.flags) + setup, interval, cfg.flags) try: checkpointer.start() -- 1.7.4 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |