]> git.proxmox.com Git - mirror_qemu.git/blob - net/colo-compare.c
target-sparc: Use tcg_gen_atomic_cmpxchg_tl
[mirror_qemu.git] / net / colo-compare.c
1 /*
2 * COarse-grain LOck-stepping Virtual Machines for Non-stop Service (COLO)
3 * (a.k.a. Fault Tolerance or Continuous Replication)
4 *
5 * Copyright (c) 2016 HUAWEI TECHNOLOGIES CO., LTD.
6 * Copyright (c) 2016 FUJITSU LIMITED
7 * Copyright (c) 2016 Intel Corporation
8 *
9 * Author: Zhang Chen <zhangchen.fnst@cn.fujitsu.com>
10 *
11 * This work is licensed under the terms of the GNU GPL, version 2 or
12 * later. See the COPYING file in the top-level directory.
13 */
14
15 #include "qemu/osdep.h"
16 #include "qemu/error-report.h"
17 #include "trace.h"
18 #include "qemu-common.h"
19 #include "qapi/qmp/qerror.h"
20 #include "qapi/error.h"
21 #include "net/net.h"
22 #include "net/eth.h"
23 #include "qom/object_interfaces.h"
24 #include "qemu/iov.h"
25 #include "qom/object.h"
26 #include "qemu/typedefs.h"
27 #include "net/queue.h"
28 #include "sysemu/char.h"
29 #include "qemu/sockets.h"
30 #include "qapi-visit.h"
31 #include "net/colo.h"
32
33 #define TYPE_COLO_COMPARE "colo-compare"
34 #define COLO_COMPARE(obj) \
35 OBJECT_CHECK(CompareState, (obj), TYPE_COLO_COMPARE)
36
37 #define COMPARE_READ_LEN_MAX NET_BUFSIZE
38 #define MAX_QUEUE_SIZE 1024
39
40 /* TODO: Should be configurable */
41 #define REGULAR_PACKET_CHECK_MS 3000
42
43 /*
44 + CompareState ++
45 | |
46 +---------------+ +---------------+ +---------------+
47 |conn list +--->conn +--------->conn |
48 +---------------+ +---------------+ +---------------+
49 | | | | | |
50 +---------------+ +---v----+ +---v----+ +---v----+ +---v----+
51 |primary | |secondary |primary | |secondary
52 |packet | |packet + |packet | |packet +
53 +--------+ +--------+ +--------+ +--------+
54 | | | |
55 +---v----+ +---v----+ +---v----+ +---v----+
56 |primary | |secondary |primary | |secondary
57 |packet | |packet + |packet | |packet +
58 +--------+ +--------+ +--------+ +--------+
59 | | | |
60 +---v----+ +---v----+ +---v----+ +---v----+
61 |primary | |secondary |primary | |secondary
62 |packet | |packet + |packet | |packet +
63 +--------+ +--------+ +--------+ +--------+
64 */
65 typedef struct CompareState {
66 Object parent;
67
68 char *pri_indev;
69 char *sec_indev;
70 char *outdev;
71 CharBackend chr_pri_in;
72 CharBackend chr_sec_in;
73 CharBackend chr_out;
74 SocketReadState pri_rs;
75 SocketReadState sec_rs;
76
77 /* connection list: the connections belonged to this NIC could be found
78 * in this list.
79 * element type: Connection
80 */
81 GQueue conn_list;
82 /* hashtable to save connection */
83 GHashTable *connection_track_table;
84 /* compare thread, a thread for each NIC */
85 QemuThread thread;
86 /* Timer used on the primary to find packets that are never matched */
87 QEMUTimer *timer;
88 QemuMutex timer_check_lock;
89 } CompareState;
90
91 typedef struct CompareClass {
92 ObjectClass parent_class;
93 } CompareClass;
94
95 typedef struct CompareChardevProps {
96 bool is_socket;
97 } CompareChardevProps;
98
99 enum {
100 PRIMARY_IN = 0,
101 SECONDARY_IN,
102 };
103
104 static int compare_chr_send(CharBackend *out,
105 const uint8_t *buf,
106 uint32_t size);
107
108 /*
109 * Return 0 on success, if return -1 means the pkt
110 * is unsupported(arp and ipv6) and will be sent later
111 */
112 static int packet_enqueue(CompareState *s, int mode)
113 {
114 ConnectionKey key;
115 Packet *pkt = NULL;
116 Connection *conn;
117
118 if (mode == PRIMARY_IN) {
119 pkt = packet_new(s->pri_rs.buf, s->pri_rs.packet_len);
120 } else {
121 pkt = packet_new(s->sec_rs.buf, s->sec_rs.packet_len);
122 }
123
124 if (parse_packet_early(pkt)) {
125 packet_destroy(pkt, NULL);
126 pkt = NULL;
127 return -1;
128 }
129 fill_connection_key(pkt, &key);
130
131 conn = connection_get(s->connection_track_table,
132 &key,
133 &s->conn_list);
134
135 if (!conn->processing) {
136 g_queue_push_tail(&s->conn_list, conn);
137 conn->processing = true;
138 }
139
140 if (mode == PRIMARY_IN) {
141 if (g_queue_get_length(&conn->primary_list) <=
142 MAX_QUEUE_SIZE) {
143 g_queue_push_tail(&conn->primary_list, pkt);
144 } else {
145 error_report("colo compare primary queue size too big,"
146 "drop packet");
147 }
148 } else {
149 if (g_queue_get_length(&conn->secondary_list) <=
150 MAX_QUEUE_SIZE) {
151 g_queue_push_tail(&conn->secondary_list, pkt);
152 } else {
153 error_report("colo compare secondary queue size too big,"
154 "drop packet");
155 }
156 }
157
158 return 0;
159 }
160
161 /*
162 * The IP packets sent by primary and secondary
163 * will be compared in here
164 * TODO support ip fragment, Out-Of-Order
165 * return: 0 means packet same
166 * > 0 || < 0 means packet different
167 */
168 static int colo_packet_compare(Packet *ppkt, Packet *spkt)
169 {
170 trace_colo_compare_ip_info(ppkt->size, inet_ntoa(ppkt->ip->ip_src),
171 inet_ntoa(ppkt->ip->ip_dst), spkt->size,
172 inet_ntoa(spkt->ip->ip_src),
173 inet_ntoa(spkt->ip->ip_dst));
174
175 if (ppkt->size == spkt->size) {
176 return memcmp(ppkt->data, spkt->data, spkt->size);
177 } else {
178 return -1;
179 }
180 }
181
182 /*
183 * Called from the compare thread on the primary
184 * for compare tcp packet
185 * compare_tcp copied from Dr. David Alan Gilbert's branch
186 */
187 static int colo_packet_compare_tcp(Packet *spkt, Packet *ppkt)
188 {
189 struct tcphdr *ptcp, *stcp;
190 int res;
191
192 trace_colo_compare_main("compare tcp");
193 if (ppkt->size != spkt->size) {
194 if (trace_event_get_state(TRACE_COLO_COMPARE_MISCOMPARE)) {
195 trace_colo_compare_main("pkt size not same");
196 }
197 return -1;
198 }
199
200 ptcp = (struct tcphdr *)ppkt->transport_header;
201 stcp = (struct tcphdr *)spkt->transport_header;
202
203 /*
204 * The 'identification' field in the IP header is *very* random
205 * it almost never matches. Fudge this by ignoring differences in
206 * unfragmented packets; they'll normally sort themselves out if different
207 * anyway, and it should recover at the TCP level.
208 * An alternative would be to get both the primary and secondary to rewrite
209 * somehow; but that would need some sync traffic to sync the state
210 */
211 if (ntohs(ppkt->ip->ip_off) & IP_DF) {
212 spkt->ip->ip_id = ppkt->ip->ip_id;
213 /* and the sum will be different if the IDs were different */
214 spkt->ip->ip_sum = ppkt->ip->ip_sum;
215 }
216
217 res = memcmp(ppkt->data + ETH_HLEN, spkt->data + ETH_HLEN,
218 (spkt->size - ETH_HLEN));
219
220 if (res != 0 && trace_event_get_state(TRACE_COLO_COMPARE_MISCOMPARE)) {
221 trace_colo_compare_pkt_info_src(inet_ntoa(ppkt->ip->ip_src),
222 ntohl(stcp->th_seq),
223 ntohl(stcp->th_ack),
224 res, stcp->th_flags,
225 spkt->size);
226
227 trace_colo_compare_pkt_info_dst(inet_ntoa(ppkt->ip->ip_dst),
228 ntohl(ptcp->th_seq),
229 ntohl(ptcp->th_ack),
230 res, ptcp->th_flags,
231 ppkt->size);
232
233 qemu_hexdump((char *)ppkt->data, stderr,
234 "colo-compare ppkt", ppkt->size);
235 qemu_hexdump((char *)spkt->data, stderr,
236 "colo-compare spkt", spkt->size);
237 }
238
239 return res;
240 }
241
242 /*
243 * Called from the compare thread on the primary
244 * for compare udp packet
245 */
246 static int colo_packet_compare_udp(Packet *spkt, Packet *ppkt)
247 {
248 int ret;
249
250 trace_colo_compare_main("compare udp");
251 ret = colo_packet_compare(ppkt, spkt);
252
253 if (ret) {
254 trace_colo_compare_udp_miscompare("primary pkt size", ppkt->size);
255 qemu_hexdump((char *)ppkt->data, stderr, "colo-compare", ppkt->size);
256 trace_colo_compare_udp_miscompare("Secondary pkt size", spkt->size);
257 qemu_hexdump((char *)spkt->data, stderr, "colo-compare", spkt->size);
258 }
259
260 return ret;
261 }
262
263 /*
264 * Called from the compare thread on the primary
265 * for compare icmp packet
266 */
267 static int colo_packet_compare_icmp(Packet *spkt, Packet *ppkt)
268 {
269 int network_length;
270
271 trace_colo_compare_main("compare icmp");
272 network_length = ppkt->ip->ip_hl * 4;
273 if (ppkt->size != spkt->size ||
274 ppkt->size < network_length + ETH_HLEN) {
275 return -1;
276 }
277
278 if (colo_packet_compare(ppkt, spkt)) {
279 trace_colo_compare_icmp_miscompare("primary pkt size",
280 ppkt->size);
281 qemu_hexdump((char *)ppkt->data, stderr, "colo-compare",
282 ppkt->size);
283 trace_colo_compare_icmp_miscompare("Secondary pkt size",
284 spkt->size);
285 qemu_hexdump((char *)spkt->data, stderr, "colo-compare",
286 spkt->size);
287 return -1;
288 } else {
289 return 0;
290 }
291 }
292
293 /*
294 * Called from the compare thread on the primary
295 * for compare other packet
296 */
297 static int colo_packet_compare_other(Packet *spkt, Packet *ppkt)
298 {
299 trace_colo_compare_main("compare other");
300 trace_colo_compare_ip_info(ppkt->size, inet_ntoa(ppkt->ip->ip_src),
301 inet_ntoa(ppkt->ip->ip_dst), spkt->size,
302 inet_ntoa(spkt->ip->ip_src),
303 inet_ntoa(spkt->ip->ip_dst));
304 return colo_packet_compare(ppkt, spkt);
305 }
306
307 static int colo_old_packet_check_one(Packet *pkt, int64_t *check_time)
308 {
309 int64_t now = qemu_clock_get_ms(QEMU_CLOCK_HOST);
310
311 if ((now - pkt->creation_ms) > (*check_time)) {
312 trace_colo_old_packet_check_found(pkt->creation_ms);
313 return 0;
314 } else {
315 return 1;
316 }
317 }
318
319 static void colo_old_packet_check_one_conn(void *opaque,
320 void *user_data)
321 {
322 Connection *conn = opaque;
323 GList *result = NULL;
324 int64_t check_time = REGULAR_PACKET_CHECK_MS;
325
326 result = g_queue_find_custom(&conn->primary_list,
327 &check_time,
328 (GCompareFunc)colo_old_packet_check_one);
329
330 if (result) {
331 /* do checkpoint will flush old packet */
332 /* TODO: colo_notify_checkpoint();*/
333 }
334 }
335
336 /*
337 * Look for old packets that the secondary hasn't matched,
338 * if we have some then we have to checkpoint to wake
339 * the secondary up.
340 */
341 static void colo_old_packet_check(void *opaque)
342 {
343 CompareState *s = opaque;
344
345 g_queue_foreach(&s->conn_list, colo_old_packet_check_one_conn, NULL);
346 }
347
348 /*
349 * Called from the compare thread on the primary
350 * for compare connection
351 */
352 static void colo_compare_connection(void *opaque, void *user_data)
353 {
354 CompareState *s = user_data;
355 Connection *conn = opaque;
356 Packet *pkt = NULL;
357 GList *result = NULL;
358 int ret;
359
360 while (!g_queue_is_empty(&conn->primary_list) &&
361 !g_queue_is_empty(&conn->secondary_list)) {
362 qemu_mutex_lock(&s->timer_check_lock);
363 pkt = g_queue_pop_tail(&conn->primary_list);
364 qemu_mutex_unlock(&s->timer_check_lock);
365 switch (conn->ip_proto) {
366 case IPPROTO_TCP:
367 result = g_queue_find_custom(&conn->secondary_list,
368 pkt, (GCompareFunc)colo_packet_compare_tcp);
369 break;
370 case IPPROTO_UDP:
371 result = g_queue_find_custom(&conn->secondary_list,
372 pkt, (GCompareFunc)colo_packet_compare_udp);
373 break;
374 case IPPROTO_ICMP:
375 result = g_queue_find_custom(&conn->secondary_list,
376 pkt, (GCompareFunc)colo_packet_compare_icmp);
377 break;
378 default:
379 result = g_queue_find_custom(&conn->secondary_list,
380 pkt, (GCompareFunc)colo_packet_compare_other);
381 break;
382 }
383
384 if (result) {
385 ret = compare_chr_send(&s->chr_out, pkt->data, pkt->size);
386 if (ret < 0) {
387 error_report("colo_send_primary_packet failed");
388 }
389 trace_colo_compare_main("packet same and release packet");
390 g_queue_remove(&conn->secondary_list, result->data);
391 packet_destroy(pkt, NULL);
392 } else {
393 /*
394 * If one packet arrive late, the secondary_list or
395 * primary_list will be empty, so we can't compare it
396 * until next comparison.
397 */
398 trace_colo_compare_main("packet different");
399 qemu_mutex_lock(&s->timer_check_lock);
400 g_queue_push_tail(&conn->primary_list, pkt);
401 qemu_mutex_unlock(&s->timer_check_lock);
402 /* TODO: colo_notify_checkpoint();*/
403 break;
404 }
405 }
406 }
407
408 static int compare_chr_send(CharBackend *out,
409 const uint8_t *buf,
410 uint32_t size)
411 {
412 int ret = 0;
413 uint32_t len = htonl(size);
414
415 if (!size) {
416 return 0;
417 }
418
419 ret = qemu_chr_fe_write_all(out, (uint8_t *)&len, sizeof(len));
420 if (ret != sizeof(len)) {
421 goto err;
422 }
423
424 ret = qemu_chr_fe_write_all(out, (uint8_t *)buf, size);
425 if (ret != size) {
426 goto err;
427 }
428
429 return 0;
430
431 err:
432 return ret < 0 ? ret : -EIO;
433 }
434
435 static int compare_chr_can_read(void *opaque)
436 {
437 return COMPARE_READ_LEN_MAX;
438 }
439
440 /*
441 * Called from the main thread on the primary for packets
442 * arriving over the socket from the primary.
443 */
444 static void compare_pri_chr_in(void *opaque, const uint8_t *buf, int size)
445 {
446 CompareState *s = COLO_COMPARE(opaque);
447 int ret;
448
449 ret = net_fill_rstate(&s->pri_rs, buf, size);
450 if (ret == -1) {
451 qemu_chr_fe_set_handlers(&s->chr_pri_in, NULL, NULL, NULL,
452 NULL, NULL, true);
453 error_report("colo-compare primary_in error");
454 }
455 }
456
457 /*
458 * Called from the main thread on the primary for packets
459 * arriving over the socket from the secondary.
460 */
461 static void compare_sec_chr_in(void *opaque, const uint8_t *buf, int size)
462 {
463 CompareState *s = COLO_COMPARE(opaque);
464 int ret;
465
466 ret = net_fill_rstate(&s->sec_rs, buf, size);
467 if (ret == -1) {
468 qemu_chr_fe_set_handlers(&s->chr_sec_in, NULL, NULL, NULL,
469 NULL, NULL, true);
470 error_report("colo-compare secondary_in error");
471 }
472 }
473
474 static void *colo_compare_thread(void *opaque)
475 {
476 GMainContext *worker_context;
477 GMainLoop *compare_loop;
478 CompareState *s = opaque;
479
480 worker_context = g_main_context_new();
481
482 qemu_chr_fe_set_handlers(&s->chr_pri_in, compare_chr_can_read,
483 compare_pri_chr_in, NULL, s, worker_context, true);
484 qemu_chr_fe_set_handlers(&s->chr_sec_in, compare_chr_can_read,
485 compare_sec_chr_in, NULL, s, worker_context, true);
486
487 compare_loop = g_main_loop_new(worker_context, FALSE);
488
489 g_main_loop_run(compare_loop);
490
491 g_main_loop_unref(compare_loop);
492 g_main_context_unref(worker_context);
493 return NULL;
494 }
495
496 static char *compare_get_pri_indev(Object *obj, Error **errp)
497 {
498 CompareState *s = COLO_COMPARE(obj);
499
500 return g_strdup(s->pri_indev);
501 }
502
503 static void compare_set_pri_indev(Object *obj, const char *value, Error **errp)
504 {
505 CompareState *s = COLO_COMPARE(obj);
506
507 g_free(s->pri_indev);
508 s->pri_indev = g_strdup(value);
509 }
510
511 static char *compare_get_sec_indev(Object *obj, Error **errp)
512 {
513 CompareState *s = COLO_COMPARE(obj);
514
515 return g_strdup(s->sec_indev);
516 }
517
518 static void compare_set_sec_indev(Object *obj, const char *value, Error **errp)
519 {
520 CompareState *s = COLO_COMPARE(obj);
521
522 g_free(s->sec_indev);
523 s->sec_indev = g_strdup(value);
524 }
525
526 static char *compare_get_outdev(Object *obj, Error **errp)
527 {
528 CompareState *s = COLO_COMPARE(obj);
529
530 return g_strdup(s->outdev);
531 }
532
533 static void compare_set_outdev(Object *obj, const char *value, Error **errp)
534 {
535 CompareState *s = COLO_COMPARE(obj);
536
537 g_free(s->outdev);
538 s->outdev = g_strdup(value);
539 }
540
541 static void compare_pri_rs_finalize(SocketReadState *pri_rs)
542 {
543 CompareState *s = container_of(pri_rs, CompareState, pri_rs);
544
545 if (packet_enqueue(s, PRIMARY_IN)) {
546 trace_colo_compare_main("primary: unsupported packet in");
547 compare_chr_send(&s->chr_out, pri_rs->buf, pri_rs->packet_len);
548 } else {
549 /* compare connection */
550 g_queue_foreach(&s->conn_list, colo_compare_connection, s);
551 }
552 }
553
554 static void compare_sec_rs_finalize(SocketReadState *sec_rs)
555 {
556 CompareState *s = container_of(sec_rs, CompareState, sec_rs);
557
558 if (packet_enqueue(s, SECONDARY_IN)) {
559 trace_colo_compare_main("secondary: unsupported packet in");
560 } else {
561 /* compare connection */
562 g_queue_foreach(&s->conn_list, colo_compare_connection, s);
563 }
564 }
565
566
567 /*
568 * Return 0 is success.
569 * Return 1 is failed.
570 */
571 static int find_and_check_chardev(CharDriverState **chr,
572 char *chr_name,
573 Error **errp)
574 {
575 CompareChardevProps props;
576
577 *chr = qemu_chr_find(chr_name);
578 if (*chr == NULL) {
579 error_setg(errp, "Device '%s' not found",
580 chr_name);
581 return 1;
582 }
583
584 memset(&props, 0, sizeof(props));
585
586 if (!qemu_chr_has_feature(*chr, QEMU_CHAR_FEATURE_RECONNECTABLE)) {
587 error_setg(errp, "chardev \"%s\" is not reconnectable",
588 chr_name);
589 return 1;
590 }
591
592 return 0;
593 }
594
595 /*
596 * Check old packet regularly so it can watch for any packets
597 * that the secondary hasn't produced equivalents of.
598 */
599 static void check_old_packet_regular(void *opaque)
600 {
601 CompareState *s = opaque;
602
603 timer_mod(s->timer, qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL) +
604 REGULAR_PACKET_CHECK_MS);
605 /* if have old packet we will notify checkpoint */
606 /*
607 * TODO: Make timer handler run in compare thread
608 * like qemu_chr_add_handlers_full.
609 */
610 qemu_mutex_lock(&s->timer_check_lock);
611 colo_old_packet_check(s);
612 qemu_mutex_unlock(&s->timer_check_lock);
613 }
614
615 /*
616 * Called from the main thread on the primary
617 * to setup colo-compare.
618 */
619 static void colo_compare_complete(UserCreatable *uc, Error **errp)
620 {
621 CompareState *s = COLO_COMPARE(uc);
622 CharDriverState *chr;
623 char thread_name[64];
624 static int compare_id;
625
626 if (!s->pri_indev || !s->sec_indev || !s->outdev) {
627 error_setg(errp, "colo compare needs 'primary_in' ,"
628 "'secondary_in','outdev' property set");
629 return;
630 } else if (!strcmp(s->pri_indev, s->outdev) ||
631 !strcmp(s->sec_indev, s->outdev) ||
632 !strcmp(s->pri_indev, s->sec_indev)) {
633 error_setg(errp, "'indev' and 'outdev' could not be same "
634 "for compare module");
635 return;
636 }
637
638 if (find_and_check_chardev(&chr, s->pri_indev, errp) ||
639 !qemu_chr_fe_init(&s->chr_pri_in, chr, errp)) {
640 return;
641 }
642
643 if (find_and_check_chardev(&chr, s->sec_indev, errp) ||
644 !qemu_chr_fe_init(&s->chr_sec_in, chr, errp)) {
645 return;
646 }
647
648 if (find_and_check_chardev(&chr, s->outdev, errp) ||
649 !qemu_chr_fe_init(&s->chr_out, chr, errp)) {
650 return;
651 }
652
653 net_socket_rs_init(&s->pri_rs, compare_pri_rs_finalize);
654 net_socket_rs_init(&s->sec_rs, compare_sec_rs_finalize);
655
656 g_queue_init(&s->conn_list);
657 qemu_mutex_init(&s->timer_check_lock);
658
659 s->connection_track_table = g_hash_table_new_full(connection_key_hash,
660 connection_key_equal,
661 g_free,
662 connection_destroy);
663
664 sprintf(thread_name, "colo-compare %d", compare_id);
665 qemu_thread_create(&s->thread, thread_name,
666 colo_compare_thread, s,
667 QEMU_THREAD_JOINABLE);
668 compare_id++;
669
670 /* A regular timer to kick any packets that the secondary doesn't match */
671 s->timer = timer_new_ms(QEMU_CLOCK_VIRTUAL, /* Only when guest runs */
672 check_old_packet_regular, s);
673 timer_mod(s->timer, qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL) +
674 REGULAR_PACKET_CHECK_MS);
675
676 return;
677 }
678
679 static void colo_compare_class_init(ObjectClass *oc, void *data)
680 {
681 UserCreatableClass *ucc = USER_CREATABLE_CLASS(oc);
682
683 ucc->complete = colo_compare_complete;
684 }
685
686 static void colo_compare_init(Object *obj)
687 {
688 object_property_add_str(obj, "primary_in",
689 compare_get_pri_indev, compare_set_pri_indev,
690 NULL);
691 object_property_add_str(obj, "secondary_in",
692 compare_get_sec_indev, compare_set_sec_indev,
693 NULL);
694 object_property_add_str(obj, "outdev",
695 compare_get_outdev, compare_set_outdev,
696 NULL);
697 }
698
699 static void colo_compare_finalize(Object *obj)
700 {
701 CompareState *s = COLO_COMPARE(obj);
702
703 qemu_chr_fe_deinit(&s->chr_pri_in);
704 qemu_chr_fe_deinit(&s->chr_sec_in);
705 qemu_chr_fe_deinit(&s->chr_out);
706
707 g_queue_free(&s->conn_list);
708
709 if (qemu_thread_is_self(&s->thread)) {
710 /* compare connection */
711 g_queue_foreach(&s->conn_list, colo_compare_connection, s);
712 qemu_thread_join(&s->thread);
713 }
714
715 if (s->timer) {
716 timer_del(s->timer);
717 }
718
719 qemu_mutex_destroy(&s->timer_check_lock);
720
721 g_free(s->pri_indev);
722 g_free(s->sec_indev);
723 g_free(s->outdev);
724 }
725
726 static const TypeInfo colo_compare_info = {
727 .name = TYPE_COLO_COMPARE,
728 .parent = TYPE_OBJECT,
729 .instance_size = sizeof(CompareState),
730 .instance_init = colo_compare_init,
731 .instance_finalize = colo_compare_finalize,
732 .class_size = sizeof(CompareClass),
733 .class_init = colo_compare_class_init,
734 .interfaces = (InterfaceInfo[]) {
735 { TYPE_USER_CREATABLE },
736 { }
737 }
738 };
739
740 static void register_types(void)
741 {
742 type_register_static(&colo_compare_info);
743 }
744
745 type_init(register_types);