diff options
author | Peter Maydell <peter.maydell@linaro.org> | 2016-10-24 15:03:09 +0100 |
---|---|---|
committer | Peter Maydell <peter.maydell@linaro.org> | 2016-10-24 15:03:09 +0100 |
commit | a3ae21ec3fe036f536dc94cad735931777143103 (patch) | |
tree | b8110b4ad3a2a21f68f9273acfb704c2c49ceb19 /net/colo-compare.c | |
parent | 4387f5671f9676336c87b68f5e87ba54fbea3714 (diff) | |
parent | 8360668e6988736bf621d8f3a3bae5d9f1a30bc5 (diff) | |
download | qemu-a3ae21ec3fe036f536dc94cad735931777143103.zip qemu-a3ae21ec3fe036f536dc94cad735931777143103.tar.gz qemu-a3ae21ec3fe036f536dc94cad735931777143103.tar.bz2 |
Merge remote-tracking branch 'remotes/bonzini/tags/for-upstream' into staging
* KVM run_on_cpu fix (Alex)
* atomic usage fixes (Emilio, me)
* hugetlbfs alignment fix (Haozhong)
* CharBackend refactoring (Marc-André)
* test-i386 fixes (me)
* MemoryListener optimizations (me)
* Miscellaneous bugfixes (me)
* iSER support (Roy)
* --version formatting (Thomas)
# gpg: Signature made Mon 24 Oct 2016 14:46:19 BST
# gpg: using RSA key 0xBFFBD25F78C7AE83
# gpg: Good signature from "Paolo Bonzini <bonzini@gnu.org>"
# gpg: aka "Paolo Bonzini <pbonzini@redhat.com>"
# Primary key fingerprint: 46F5 9FBD 57D6 12E7 BFD4 E2F7 7E15 100C CD36 69B1
# Subkey fingerprint: F133 3857 4B66 2389 866C 7682 BFFB D25F 78C7 AE83
* remotes/bonzini/tags/for-upstream: (50 commits)
exec.c: workaround regression caused by alignment change in d2f39ad
char: remove explicit_be_open from CharDriverState
char: use common error path in qmp_chardev_add
char: replace avail_connections
char: remove unused qemu_chr_fe_event
char: use an enum for CHR_EVENT
char: remove unused CHR_EVENT_FOCUS
char: move fe_open in CharBackend
char: remove explicit_fe_open, use a set_handlers argument
char: rename chr_close/chr_free
char: move front end handlers in CharBackend
tests: start chardev unit tests
char: make some qemu_chr_fe skip if no driver
char: replace qemu_chr_claim/release with qemu_chr_fe_init/deinit
vhost-user: only initialize queue 0 CharBackend
char: fold qemu_chr_set_handlers in qemu_chr_fe_set_handlers
char: use qemu_chr_fe* functions with CharBackend argument
colo: claim in find_and_check_chardev
char: rename some frontend functions
char: remaining switch to CharBackend in frontend
...
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'net/colo-compare.c')
-rw-r--r-- | net/colo-compare.c | 59 |
1 files changed, 26 insertions, 33 deletions
diff --git a/net/colo-compare.c b/net/colo-compare.c index 47703c5..109990f 100644 --- a/net/colo-compare.c +++ b/net/colo-compare.c @@ -68,9 +68,9 @@ typedef struct CompareState { char *pri_indev; char *sec_indev; char *outdev; - CharDriverState *chr_pri_in; - CharDriverState *chr_sec_in; - CharDriverState *chr_out; + CharBackend chr_pri_in; + CharBackend chr_sec_in; + CharBackend chr_out; SocketReadState pri_rs; SocketReadState sec_rs; @@ -101,7 +101,7 @@ enum { SECONDARY_IN, }; -static int compare_chr_send(CharDriverState *out, +static int compare_chr_send(CharBackend *out, const uint8_t *buf, uint32_t size); @@ -385,7 +385,7 @@ static void colo_compare_connection(void *opaque, void *user_data) } if (result) { - ret = compare_chr_send(s->chr_out, pkt->data, pkt->size); + ret = compare_chr_send(&s->chr_out, pkt->data, pkt->size); if (ret < 0) { error_report("colo_send_primary_packet failed"); } @@ -408,7 +408,7 @@ static void colo_compare_connection(void *opaque, void *user_data) } } -static int compare_chr_send(CharDriverState *out, +static int compare_chr_send(CharBackend *out, const uint8_t *buf, uint32_t size) { @@ -451,7 +451,8 @@ static void compare_pri_chr_in(void *opaque, const uint8_t *buf, int size) ret = net_fill_rstate(&s->pri_rs, buf, size); if (ret == -1) { - qemu_chr_add_handlers(s->chr_pri_in, NULL, NULL, NULL, NULL); + qemu_chr_fe_set_handlers(&s->chr_pri_in, NULL, NULL, NULL, + NULL, NULL, true); error_report("colo-compare primary_in error"); } } @@ -467,7 +468,8 @@ static void compare_sec_chr_in(void *opaque, const uint8_t *buf, int size) ret = net_fill_rstate(&s->sec_rs, buf, size); if (ret == -1) { - qemu_chr_add_handlers(s->chr_sec_in, NULL, NULL, NULL, NULL); + qemu_chr_fe_set_handlers(&s->chr_sec_in, NULL, NULL, NULL, + NULL, NULL, true); error_report("colo-compare secondary_in error"); } } @@ -480,10 +482,10 @@ static void *colo_compare_thread(void *opaque) worker_context = g_main_context_new(); - qemu_chr_add_handlers_full(s->chr_pri_in, compare_chr_can_read, - compare_pri_chr_in, NULL, s, worker_context); - qemu_chr_add_handlers_full(s->chr_sec_in, compare_chr_can_read, - compare_sec_chr_in, NULL, s, worker_context); + qemu_chr_fe_set_handlers(&s->chr_pri_in, compare_chr_can_read, + compare_pri_chr_in, NULL, s, worker_context, true); + qemu_chr_fe_set_handlers(&s->chr_sec_in, compare_chr_can_read, + compare_sec_chr_in, NULL, s, worker_context, true); compare_loop = g_main_loop_new(worker_context, FALSE); @@ -545,7 +547,7 @@ static void compare_pri_rs_finalize(SocketReadState *pri_rs) if (packet_enqueue(s, PRIMARY_IN)) { trace_colo_compare_main("primary: unsupported packet in"); - compare_chr_send(s->chr_out, pri_rs->buf, pri_rs->packet_len); + compare_chr_send(&s->chr_out, pri_rs->buf, pri_rs->packet_len); } else { /* compare connection */ g_queue_foreach(&s->conn_list, colo_compare_connection, s); @@ -589,6 +591,7 @@ static int find_and_check_chardev(CharDriverState **chr, chr_name); return 1; } + return 0; } @@ -619,6 +622,7 @@ static void check_old_packet_regular(void *opaque) static void colo_compare_complete(UserCreatable *uc, Error **errp) { CompareState *s = COLO_COMPARE(uc); + CharDriverState *chr; char thread_name[64]; static int compare_id; @@ -634,24 +638,21 @@ static void colo_compare_complete(UserCreatable *uc, Error **errp) return; } - if (find_and_check_chardev(&s->chr_pri_in, s->pri_indev, errp)) { + if (find_and_check_chardev(&chr, s->pri_indev, errp) || + !qemu_chr_fe_init(&s->chr_pri_in, chr, errp)) { return; } - if (find_and_check_chardev(&s->chr_sec_in, s->sec_indev, errp)) { + if (find_and_check_chardev(&chr, s->sec_indev, errp) || + !qemu_chr_fe_init(&s->chr_sec_in, chr, errp)) { return; } - if (find_and_check_chardev(&s->chr_out, s->outdev, errp)) { + if (find_and_check_chardev(&chr, s->outdev, errp) || + !qemu_chr_fe_init(&s->chr_out, chr, errp)) { return; } - qemu_chr_fe_claim_no_fail(s->chr_pri_in); - - qemu_chr_fe_claim_no_fail(s->chr_sec_in); - - qemu_chr_fe_claim_no_fail(s->chr_out); - net_socket_rs_init(&s->pri_rs, compare_pri_rs_finalize); net_socket_rs_init(&s->sec_rs, compare_sec_rs_finalize); @@ -702,17 +703,9 @@ static void colo_compare_finalize(Object *obj) { CompareState *s = COLO_COMPARE(obj); - if (s->chr_pri_in) { - qemu_chr_add_handlers(s->chr_pri_in, NULL, NULL, NULL, NULL); - qemu_chr_fe_release(s->chr_pri_in); - } - if (s->chr_sec_in) { - qemu_chr_add_handlers(s->chr_sec_in, NULL, NULL, NULL, NULL); - qemu_chr_fe_release(s->chr_sec_in); - } - if (s->chr_out) { - qemu_chr_fe_release(s->chr_out); - } + qemu_chr_fe_deinit(&s->chr_pri_in); + qemu_chr_fe_deinit(&s->chr_sec_in); + qemu_chr_fe_deinit(&s->chr_out); g_queue_free(&s->conn_list); |