/* * Called from the main thread on the primary for packets * arriving over the socket from the secondary. */ static void compare_sec_chr_in(void *opaque, const uint8_t *buf, int size) { CompareState *s = COLO_COMPARE(opaque); int ret; ret = net_fill_rstate(&s->sec_rs, buf, size); if (ret == -1) { qemu_chr_fe_set_handlers(&s->chr_sec_in, NULL, NULL, NULL, NULL, NULL, NULL, true); error_report("colo-compare secondary_in error"); } }
static void redirector_to_filter(NetFilterState *nf, const uint8_t *buf, int len) { struct iovec iov = { .iov_base = (void *)buf, .iov_len = len, }; if (nf->direction == NET_FILTER_DIRECTION_ALL || nf->direction == NET_FILTER_DIRECTION_TX) { qemu_netfilter_pass_to_next(nf->netdev, 0, &iov, 1, nf); } if (nf->direction == NET_FILTER_DIRECTION_ALL || nf->direction == NET_FILTER_DIRECTION_RX) { qemu_netfilter_pass_to_next(nf->netdev->peer, 0, &iov, 1, nf); } } static int redirector_chr_can_read(void *opaque) { return REDIRECTOR_MAX_LEN; } static void redirector_chr_read(void *opaque, const uint8_t *buf, int size) { NetFilterState *nf = opaque; MirrorState *s = FILTER_REDIRECTOR(nf); int ret; ret = net_fill_rstate(&s->rs, buf, size); if (ret == -1) { qemu_chr_fe_set_handlers(&s->chr_in, NULL, NULL, NULL, NULL, NULL, true); } }