COLO-compare: Make COLO-compare support remote COLO-frame
v2 cover COLO-compare: Make COLO-compare support remote COLO-frame
This series focus on COLO-proxy remote colo-frame support. Xen COLO-frame is the first user. We add a new chardev socket in colo-compare as the way of communicate with remote COLO-frame. And remote COLO-frame notify colo-proxy part depend on this serise:
https://lists.nongnu.org/archive/html/qemu-devel/2017-04/msg03904.html
I will send another part of this series after depend patchset have been merged.
V2:
- Rename this series.
- Change communication way to remote colo-frame.
- Some bugfix.
- Split the main function, anther part wait depend patchset.
Zhang Chen (3):
COLO-compare: Add new parameter for communicate with remote colo-frame
COLO-compare: Add remote checkpoint notify chardev socket handler
frame
COLO-compare: Add remote initialization and checkpoint notification
net/colo-compare.c | 91 ++++++++++++++++++++++++++++++++++++++++++++++++++++-- qemu-options.hx | 41 ++++++++++++++++++++---- 2 files changed, 124 insertions(+), 8 deletions(-)
Signature · 1 line
2.7.4
PATCH v2 1/3 COLO-compare: Add new parameter for communicate with remote colo-frame
We add the "notify_dev=chardevID" parameter. colo-compare can connect with remote colo-frame through chardev socket, Xen colo-frame is the first user. We can notify colo-frame do checkpoint events.
--- net/colo-compare.c | 20 ++++++++++++++++++++ qemu-options.hx | 41 +++++++++++++++++++++++++++++++++++------ 2 files changed, 55 insertions(+), 6 deletions(-)
net/colo-compare.c +20 -0
@@ -68,6 +68,7 @@ typedef struct CompareState {char *pri_indev;char *sec_indev;char *outdev; +char *notify_dev;CharBackend chr_pri_in;CharBackend chr_sec_in;CharBackend chr_out;
@@ -653,6 +654,21 @@ static void compare_set_outdev(Object *obj, const char *value, Error **errp) s->outdev =g_strdup (value); } +static char *compare_get_notify_dev (Object *obj,Error **errp) +{ +CompareState *s =COLO_COMPARE (obj); + +return g_strdup (s->notify_dev); +} + +static void compare_set_notify_dev (Object *obj,const char *value,Error **errp) +{ +CompareState *s =COLO_COMPARE (obj); + +g_free (s->notify_dev); + s->notify_dev =g_strdup (value); +} +static void compare_pri_rs_finalize (SocketReadState *pri_rs) {CompareState *s =container_of (pri_rs, CompareState, pri_rs);
@@ -795,6 +811,9 @@ static void colo_compare_init(Object *obj)object_property_add_str (obj,"outdev" , compare_get_outdev, compare_set_outdev,NULL ); +object_property_add_str (obj,"notify_dev" , + compare_get_notify_dev, compare_set_notify_dev, +NULL ); }static void colo_compare_finalize (Object *obj)
@@ -819,6 +838,7 @@ static void colo_compare_finalize(Object *obj)g_free (s->pri_indev);g_free (s->sec_indev);g_free (s->outdev); +g_free (s->notify_dev); }static const TypeInfo colo_compare_info = {
qemu-options.hx +35 -6
64 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v2 2/3 COLO-compare: Add remote checkpoint notify chardev socket handler frame
In reply to Zhang ChenAdd chardev handler to get remote colo-frame's notify, Xen colo is the first user.
--- net/colo-compare.c | 41 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 3 deletions(-)
net/colo-compare.c +38 -3
@@ -72,8 +72,10 @@ typedef struct CompareState {CharBackend chr_pri_in;CharBackend chr_sec_in;CharBackend chr_out; +CharBackend chr_notify_dev;SocketReadState pri_rs;SocketReadState sec_rs; +SocketReadState notify_rs;/* connection list: the connections belonged to this NIC could be found * in this list.
@@ -567,6 +569,19 @@ static void compare_sec_chr_in(void *opaque, const uint8_t *buf, int size) } } +static void compare_notify_chr (void *opaque,const uint8_t *buf,int size) +{ +CompareState *s =COLO_COMPARE (opaque); +int ret; + + ret =net_fill_rstate (&s->notify_rs, buf, size); +if (ret ==-1 ) { +qemu_chr_fe_set_handlers (&s->chr_notify_dev,NULL ,NULL ,NULL , +NULL ,NULL , true); +error_report ("colo-compare notify_dev error" ); + } +} +/* * Check old packet regularly so it can watch for any packets * that the secondary hasn't produced equivalents of.
@@ -589,9 +604,11 @@ static void *colo_compare_thread(void *opaque) s->worker_context =g_main_context_new ();qemu_chr_fe_set_handlers (&s->chr_pri_in, compare_chr_can_read, - compare_pri_chr_in,NULL , s, s->worker_context, true); + compare_pri_chr_in,NULL , s, s->worker_context, true);qemu_chr_fe_set_handlers (&s->chr_sec_in, compare_chr_can_read, - compare_sec_chr_in,NULL , s, s->worker_context, true); + compare_sec_chr_in,NULL , s, s->worker_context, true); +qemu_chr_fe_set_handlers (&s->chr_notify_dev, compare_chr_can_read, + compare_notify_chr,NULL , s, s->worker_context, true); s->compare_loop =g_main_loop_new (s->worker_context, FALSE);
@@ -694,6 +711,10 @@ static void compare_sec_rs_finalize(SocketReadState *sec_rs) } } +static void compare_notify_rs_finalize (SocketReadState *notify_rs) +{ +/* Get remote colo-frame's notify and handle the message */ +}/* * Return 0 is success.
@@ -757,6 +778,15 @@ static void colo_compare_complete(UserCreatable *uc, Error **errp)return ; } +/* This parameter is Optional, Remote checkpoint notify need it */ +if (s->notify_dev) { +if (find_and_check_chardev (&chr, s->notify_dev, errp) || + !qemu_chr_fe_init (&s->chr_notify_dev, chr, errp)) { +return ; + } +net_socket_rs_init (&s->notify_dev, compare_notify_rs_finalize); + } +net_socket_rs_init (&s->pri_rs, compare_pri_rs_finalize);net_socket_rs_init (&s->sec_rs, compare_sec_rs_finalize);
@@ -825,6 +855,7 @@ static void colo_compare_finalize(Object *obj)qemu_chr_fe_set_handlers (&s->chr_sec_in,NULL ,NULL ,NULL ,NULL , s->worker_context, true);qemu_chr_fe_deinit (&s->chr_out); +qemu_chr_fe_deinit (&s->chr_notify_dev);g_main_loop_quit (s->compare_loop);qemu_thread_join (&s->thread);
@@ -838,7 +869,11 @@ static void colo_compare_finalize(Object *obj)g_free (s->pri_indev);g_free (s->sec_indev);g_free (s->outdev); -g_free (s->notify_dev); + +/* This parameter is Optional */ +if (s->notify_dev) { +g_free (s->notify_dev); + } }static const TypeInfo colo_compare_info = {
Signature · 1 line
2.7.4
PATCH v2 3/3 COLO-compare: Add remote initialization and checkpoint notification
In reply to Zhang ChenInitialize remote communication socket and make a handshack with remote colo-frame. Then use this way to notify remote colo-frame do checkpoint.
--- net/colo-compare.c | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-)
net/colo-compare.c +33 -1
@@ -100,6 +100,12 @@ enum { SECONDARY_IN, }; +typedef enum ProxyRemoteRequest { +USERSPACE_PROXY_INIT =0 , +USERSPACE_PROXY_GET_REMOTE_INIT =1 , +USERSPACE_PROXY_NOTIFY_CHECKPOINT =2 +}ProxyRemoteRequest ; +static int compare_chr_send (CharBackend *out,const uint8_t *buf,uint32_t size);
@@ -498,6 +504,18 @@ static void colo_compare_connection(void *opaque, void *user_data)trace_colo_compare_main ("packet different" );g_queue_push_tail (&conn->primary_list, pkt);/* TODO: colo_notify_checkpoint();*/ +/* +* If we have notify_dev that means COLO didn't running on KVM, +* So we use remote checkpoint notify, Xen is the first user. +*/ +if (s->notify_dev) { +ProxyRemoteRequest msg =USERSPACE_PROXY_NOTIFY_CHECKPOINT ; + ret =compare_chr_send (&s->chr_notify_dev, (uint8_t *)msg, +sizeof (msg)); +if (ret <0 ) { +error_report ("Notify remote COLO-frame failed" ); + } + }break ; } }
@@ -713,7 +731,21 @@ static void compare_sec_rs_finalize(SocketReadState *sec_rs)static void compare_notify_rs_finalize (SocketReadState *notify_rs) { +CompareState *s =container_of (notify_rs, CompareState, notify_rs); +/* Get remote colo-frame's notify and handle the message */ +char *data =g_memdup (notify_rs->buf, notify_rs->packet_len); +ProxyRemoteRequest msg =USERSPACE_PROXY_GET_REMOTE_INIT ; +ProxyRemoteRequest msg_recv = *data; +int ret; + +if (msg_recv ==USERSPACE_PROXY_INIT ) { + ret =compare_chr_send (&s->chr_notify_dev, (uint8_t *)msg, +sizeof (msg)); +if (ret <0 ) { +error_report ("Notify remote COLO-frame INIT failed" ); + } + } }/*
@@ -784,7 +816,7 @@ static void colo_compare_complete(UserCreatable *uc, Error **errp) !qemu_chr_fe_init(&s->chr_notify_dev, chr, errp)) {return ; } -net_socket_rs_init (&s->notify_dev, compare_notify_rs_finalize); +net_socket_rs_init (&s->notify_rs, compare_notify_rs_finalize); }net_socket_rs_init (&s->pri_rs, compare_pri_rs_finalize);
Signature · 1 line
2.7.4
This series seems to have some coding style problems. See output below for more information:
Hi,
This series seems to have some coding style problems. See output below for more information:
Type: series
Message-id: [email protected]
Subject: [Qemu-devel] [PATCH V2 0/3] COLO-compare: Make COLO-compare support remote COLO-frame
=== TEST SCRIPT BEGIN ===
#!/bin/bash
BASE=base
n=1
total=$(git log --oneline $BASE.. | wc -l)
failed=0
git config --local diff.renamelimit 0
git config --local diff.renames True
commits="$(git log --format=%H --reverse $BASE..)" for c in $commits; do
echo "Checking PATCH $n/$total: $(git log -n 1 --format=%s $c)..."
if ! git show $c --format=email | ./scripts/checkpatch.pl --mailback -; then
failed=1
echo
fi
n=$((n+1))done
exit $failed
=== TEST SCRIPT END ===
Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu
* [new tag] patchew/19feea44a3f4010645a1b829b504481f1b574b9a.1495797845.git.maozy.fnst@cn.fujitsu.com -> patchew/19feea44a3f4010645a1b829b504481f1b574b9a.1495797845.git.maozy.fnst@cn.fujitsu.com
Switched to a new branch 'test'
ac41f91 COLO-compare: Add remote initialization and checkpoint notification a0a428f COLO-compare: Add remote checkpoint notify chardev socket handler frame e976476 COLO-compare: Add new parameter for communicate with remote colo-frame
=== OUTPUT BEGIN ===
Checking PATCH 1/3: COLO-compare: Add new parameter for communicate with remote colo-frame... Checking PATCH 2/3: COLO-compare: Add remote checkpoint notify chardev socket handler frame...
WARNING: line over 80 characters
#52: FILE: net/colo-compare.c:607:
+ compare_pri_chr_in, NULL, s, s->worker_context, true);
WARNING: line over 80 characters
#55: FILE: net/colo-compare.c:609:
+ compare_sec_chr_in, NULL, s, s->worker_context, true);
WARNING: line over 80 characters
#57: FILE: net/colo-compare.c:611:
+ compare_notify_chr, NULL, s, s->worker_context, true);
ERROR: g_free(NULL) is safe this check is probably not required #104: FILE: net/colo-compare.c:875:
+ if (s->notify_dev) {
+ g_free(s->notify_dev);
total: 1 errors, 3 warnings, 86 lines checked
Your patch has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
Checking PATCH 3/3: COLO-compare: Add remote initialization and checkpoint notification... === OUTPUT END ===
Test command exited with code: 1
---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to [email protected]