Skip to content

Commit 0c7af1a

Browse files
raolei-inteljasowang
authored andcommitted
Add the function of colo_compare_cleanup
This patch fixes the following: #0 __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50 qemu#1 0x00007f6ae4559859 in __GI_abort () at abort.c:79 qemu#2 0x0000559aaa386720 in error_exit (err=16, msg=0x559aaa5973d0 <__func__.16227> "qemu_mutex_destroy") at util/qemu-thread-posix.c:36 qemu#3 0x0000559aaa3868c5 in qemu_mutex_destroy (mutex=0x559aabffe828) at util/qemu-thread-posix.c:69 qemu#4 0x0000559aaa2f93a8 in char_finalize (obj=0x559aabffe800) at chardev/char.c:285 qemu#5 0x0000559aaa23318a in object_deinit (obj=0x559aabffe800, type=0x559aabfd7d20) at qom/object.c:606 qemu#6 0x0000559aaa2331b8 in object_deinit (obj=0x559aabffe800, type=0x559aabfd9060) at qom/object.c:610 qemu#7 0x0000559aaa233200 in object_finalize (data=0x559aabffe800) at qom/object.c:620 qemu#8 0x0000559aaa234202 in object_unref (obj=0x559aabffe800) at qom/object.c:1074 qemu#9 0x0000559aaa2356b6 in object_finalize_child_property (obj=0x559aac0dac10, name=0x559aac778760 "compare0-0", opaque=0x559aabffe800) at qom/object.c:1584 qemu#10 0x0000559aaa232f70 in object_property_del_all (obj=0x559aac0dac10) at qom/object.c:557 qemu#11 0x0000559aaa2331ed in object_finalize (data=0x559aac0dac10) at qom/object.c:619 qemu#12 0x0000559aaa234202 in object_unref (obj=0x559aac0dac10) at qom/object.c:1074 qemu#13 0x0000559aaa2356b6 in object_finalize_child_property (obj=0x559aac0c75c0, name=0x559aac0dadc0 "chardevs", opaque=0x559aac0dac10) at qom/object.c:1584 qemu#14 0x0000559aaa233071 in object_property_del_child (obj=0x559aac0c75c0, child=0x559aac0dac10, errp=0x0) at qom/object.c:580 qemu#15 0x0000559aaa233155 in object_unparent (obj=0x559aac0dac10) at qom/object.c:599 qemu#16 0x0000559aaa2fb721 in qemu_chr_cleanup () at chardev/char.c:1159 qemu#17 0x0000559aa9f9b110 in main (argc=54, argv=0x7ffeb62fa998, envp=0x7ffeb62fab50) at vl.c:4539 When chardev is cleaned up, chr_write_lock needs to be destroyed. But the colo-compare module is not cleaned up normally before it when the guest poweroff. It is holding chr_write_lock at this time. This will cause qemu crash.So we add the function of colo_compare_cleanup() before qemu_chr_cleanup() to fix the bug. Signed-off-by: Lei Rao <[email protected]> Reviewed-by: Zhang Chen <[email protected]> Reviewed-by: Lukas Straub <[email protected]> Tested-by: Lukas Straub <[email protected]> Signed-off-by: Zhang Chen <[email protected]> Signed-off-by: Jason Wang <[email protected]>
1 parent 9b49271 commit 0c7af1a

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

net/colo-compare.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1402,6 +1402,16 @@ static void colo_compare_init(Object *obj)
14021402
compare_set_vnet_hdr);
14031403
}
14041404

1405+
void colo_compare_cleanup(void)
1406+
{
1407+
CompareState *tmp = NULL;
1408+
CompareState *n = NULL;
1409+
1410+
QTAILQ_FOREACH_SAFE(tmp, &net_compares, next, n) {
1411+
object_unparent(OBJECT(tmp));
1412+
}
1413+
}
1414+
14051415
static void colo_compare_finalize(Object *obj)
14061416
{
14071417
CompareState *s = COLO_COMPARE(obj);

net/colo-compare.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,6 @@
2020
void colo_notify_compares_event(void *opaque, int event, Error **errp);
2121
void colo_compare_register_notifier(Notifier *notify);
2222
void colo_compare_unregister_notifier(Notifier *notify);
23+
void colo_compare_cleanup(void);
2324

2425
#endif /* QEMU_COLO_COMPARE_H */

net/net.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
#include "qapi/error.h"
5353
#include "qapi/opts-visitor.h"
5454
#include "sysemu/runstate.h"
55+
#include "net/colo-compare.h"
5556
#include "net/filter.h"
5657
#include "qapi/string-output-visitor.h"
5758

@@ -1402,6 +1403,9 @@ void net_cleanup(void)
14021403
{
14031404
NetClientState *nc;
14041405

1406+
/*cleanup colo compare module for COLO*/
1407+
colo_compare_cleanup();
1408+
14051409
/* We may del multiple entries during qemu_del_net_client(),
14061410
* so QTAILQ_FOREACH_SAFE() is also not safe here.
14071411
*/

0 commit comments

Comments
 (0)