首页 > 其他分享 >qemu-kvm-ev-2.12.0-44.1.el7_8.1 线上热迁移qemu-kvm coredump问题分析

qemu-kvm-ev-2.12.0-44.1.el7_8.1 线上热迁移qemu-kvm coredump问题分析

时间:2023-03-14 22:58:07浏览次数:44  
标签:8.1 __ 0x0 int kvm chr Chardev qemu class

配置libvirt coredumo后(https://www.cnblogs.com/maojun1998/p/17215214.html)

让测试一直迁移vm,一段时间后出现coredump

root 错误码: coredump.sh 严重错误,进程 coredump,dumpfile:/run/fs_mount//hdd/core.26956

  1  
  2 qemu关于这块代码非常绕最后core在object_get_class
  3 
  4  Chardev *s = be->chr;
  5  src = CHARDEV_GET_CLASS(s)->chr_add_watch(s, cond);
  6  
  7  
  8  #define CHARDEV_GET_CLASS(obj) \
  9     OBJECT_GET_CLASS(ChardevClass, (obj), TYPE_CHARDEV)
 10 
 11 #define OBJECT_GET_CLASS(class, obj, name) \
 12     OBJECT_CLASS_CHECK(class, object_get_class(OBJECT(obj)), name)
 13     
 14 #define OBJECT(obj) \
 15     ((Object *)(obj))
 16 #define OBJECT_CLASS_CHECK(class_type, class, name) \
 17     ((class_type *)object_class_dynamic_cast_assert(OBJECT_CLASS(class), (name), \
 18                                                __FILE__, __LINE__, __func__))
 19 #define OBJECT_CLASS(class) \
 20     ((ObjectClass *)(class))
 21     
 22 ObjectClass *object_get_class(Object *obj)
 23 {
 24     return obj->class;
 25 }
 26 struct Chardev {
 27     Object parent_obj;
 28 
 29     QemuMutex chr_write_lock;
 30     CharBackend *be;
 31     char *label;
 32     char *filename;
 33     int logfd;
 34     int be_open;
 35     GSource *gsource;
 36     GMainContext *gcontext;
 37     DECLARE_BITMAP(features, QEMU_CHAR_FEATURE_LAST);
 38 };
 39 struct Object
 40 {
 41     /*< private >*/
 42     ObjectClass *class;
 43     ObjectFree *free;
 44     GHashTable *properties;
 45     uint32_t ref;
 46     Object *parent;
 47 };
 48 struct ObjectClass
 49 {
 50     /*< private >*/
 51     Type type;
 52     GSList *interfaces;
 53 
 54     const char *object_cast_cache[OBJECT_CLASS_CAST_CACHE];
 55     const char *class_cast_cache[OBJECT_CLASS_CAST_CACHE];
 56 
 57     ObjectUnparent *unparent;
 58 
 59     GHashTable *properties;
 60 };
 61 typedef struct ChardevClass {
 62     ObjectClass parent_class;
 63 
 64     bool internal; /* TODO: eventually use TYPE_USER_CREATABLE */
 65     void (*parse)(QemuOpts *opts, ChardevBackend *backend, Error **errp);
 66 
 67     void (*open)(Chardev *chr, ChardevBackend *backend,
 68                  bool *be_opened, Error **errp);
 69 
 70     int (*chr_write)(Chardev *s, const uint8_t *buf, int len);
 71     int (*chr_sync_read)(Chardev *s, const uint8_t *buf, int len);
 72     GSource *(*chr_add_watch)(Chardev *s, GIOCondition cond);
 73     void (*chr_update_read_handler)(Chardev *s);
 74     int (*chr_ioctl)(Chardev *s, int cmd, void *arg);
 75     int (*get_msgfds)(Chardev *s, int* fds, int num);
 76     int (*set_msgfds)(Chardev *s, int *fds, int num);
 77     int (*chr_add_client)(Chardev *chr, int fd);
 78     int (*chr_wait_connected)(Chardev *chr, Error **errp);
 79     void (*chr_disconnect)(Chardev *chr);
 80     void (*chr_accept_input)(Chardev *chr);
 81     void (*chr_set_echo)(Chardev *chr, bool echo);
 82     void (*chr_set_fe_open)(Chardev *chr, int fe_open);
 83     void (*chr_be_event)(Chardev *s, int event);
 84     /* Return 0 if succeeded, 1 if failed */
 85     int (*chr_machine_done)(Chardev *chr);
 86 } ChardevClass;
 87 =========================================================================
 88 print *((CharBackend *)0x55873895f4c0)->chr
 89 $32 = {
 90   parent_obj = {
 91     class = 0x5587353beb40,
 92     free = 0x7f59ebf707e0 <g_free>,
 93 Python Exception <class 'gdb.error'> There is no member named keys.:
 94     properties = 0x558735469b00,
 95     ref = 1,
 96     parent = 0x558735470960
 97   },
 98   chr_write_lock = {
 99     lock = {
100       __data = {
101         __lock = 0,
102         __count = 0,
103         __owner = 0,
104         __nusers = 0,
105         __kind = 0,
106         __spins = 0,
107         __elision = 0,
108         __list = {
109           __prev = 0x0,
110           __next = 0x0
111         }
112       },
113       __size = '\000' <repeats 39 times>,
114       __align = 0
115     },
116     initialized = true
117   },
118   be = 0x55873895f4c0,
119   label = 0x5587353af7b0 "charserial0",
120   filename = 0x55873543fea0 "disconnected:unix:/dev/shm/kvm_unix_ch/dev-8f0d86,server",
121   logfd = -1,
122   be_open = 0,
123   gsource = 0x0,
124   gcontext = 0x0,
125   features = {1}
126 }
127 
128 
129 print ((CharBackend *)0x55873895f4c0)->chr
130 $27 = (Chardev *) 0x5587354645a0
131 
132 print  ((Object *)(0x5587354645a0))->class
133 $29 = (ObjectClass *) 0x5587353beb40
134 
135 print (ChardevClass *)0x5587353beb40
136 (gdb) print *(ChardevClass *)0x5587353beb40
137 $31 = {
138   parent_class = {
139     type = 0x558735406300,
140     interfaces = 0x0,
141     object_cast_cache = {0x0, 0x0, 0x0, 0x0},
142     class_cast_cache = {0x0, 0x0, 0x0, 0x0},
143     unparent = 0x0,
144 Python Exception <class 'gdb.error'> There is no member named keys.:
145     properties = 0x558735444aa0
146   },
147   internal = false,
148   parse = 0x55873293a120 <qemu_chr_parse_socket>,
149   open = 0x55873293b210 <qmp_chardev_open_socket>,
150   chr_write = 0x55873293b130 <tcp_chr_write>,
151   chr_sync_read = 0x55873293b080 <tcp_chr_sync_read>,
152   chr_add_watch = 0x558732939860 <tcp_chr_add_watch>,
153   chr_update_read_handler = 0x55873293b740 <tcp_chr_update_read_handler>,
154   chr_ioctl = 0x0,
155   get_msgfds = 0x55873293a750 <tcp_get_msgfds>,
156   set_msgfds = 0x558732939f50 <tcp_set_msgfds>,
157   chr_add_client = 0x55873293bb10 <tcp_chr_add_client>,
158   chr_wait_connected = 0x55873293bb60 <tcp_chr_wait_connected>,
159   chr_disconnect = 0x55873293a9d0 <tcp_chr_disconnect>,
160   chr_accept_input = 0x0,
161   chr_set_echo = 0x0,
162   chr_set_fe_open = 0x0,
163   chr_be_event = 0x5587329333a0 <chr_be_event>,
164   chr_machine_done = 0x55873293b010 <tcp_chr_machine_done_hook>
165 }
166 
167 ================================================================
168 static GSource *tcp_chr_add_watch(Chardev *chr, GIOCondition cond)
169 {
170     SocketChardev *s = SOCKET_CHARDEV(chr);
171     return qio_channel_create_watch(s->ioc, cond);
172 }
173 
174 
175 
176 
177 guint qemu_chr_fe_add_watch(CharBackend *be, GIOCondition cond,
178                             GIOFunc func, void *user_data)
179 {
180     Chardev *s = be->chr;
181     GSource *src;
182     guint tag;
183 
184     if (!s || CHARDEV_GET_CLASS(s)->chr_add_watch == NULL) {
185         return 0;
186     }
187 
188     src = CHARDEV_GET_CLASS(s)->chr_add_watch(s, cond);
189     if (!src) {
190         return 0;
191     }
192 
193     g_source_set_callback(src, (GSourceFunc)func, user_data, NULL);
194     tag = g_source_attach(src, s->gcontext);
195     g_source_unref(src);
196 
197     return tag;
198 }
199 (gdb) bt
200 #0  0x00005587328b34b0 in object_get_class (obj=obj@entry=0x0) at qom/object.c:759
201 #1  0x0000558732946440 in qio_channel_create_watch (ioc=0x0, condition=(G_IO_OUT | G_IO_HUP)) at io/channel.c:280
202 #2  0x0000558732936577 in qemu_chr_fe_add_watch (be=be@entry=0x55873895f4c0, cond=cond@entry=(G_IO_OUT | G_IO_HUP), func=func@entry=
203     0x5587327b7700 <serial_watch_cb>, user_data=user_data@entry=0x55873895f4a0) at chardev/char-fe.c:355
204 #3  0x00005587327b7a97 in serial_post_load (opaque=0x55873895f4a0, version_id=<optimized out>) at hw/char/serial.c:679
205 #4  0x000055873285eb47 in vmstate_load_state (f=f@entry=0x558738c26000, vmsd=0x558732ff4d40 <vmstate_serial>, opaque=0x55873895f4a0, version_id=3) at migration/vmstate.c:165
206 #5  0x000055873285ec5c in vmstate_load_state (f=0x558738c26000, vmsd=0x558732ff50c0 <vmstate_isa_serial>, opaque=0x55873895f400, version_id=3) at migration/vmstate.c:137
207 #6  0x000055873285abf5 in qemu_loadvm_state_main (mis=<optimized out>, f=0x558738c26000) at migration/savevm.c:1970
208 #7  0x000055873285abf5 in qemu_loadvm_state_main (f=f@entry=0x558738c26000, mis=0x55873320dc00 <mis_current.30332>) at migration/savevm.c:2078
209 #8  0x000055873285ca2e in qemu_loadvm_state (f=0x558738c26000) at migration/savevm.c:2162
210 #9  0x0000558732856bf2 in process_incoming_migration_co (opaque=<optimized out>) at migration/migration.c:388
211 #10 0x00005587329a944a in coroutine_trampoline (i0=<optimized out>, i1=<optimized out>) at util/coroutine-ucontext.c:116
212 #11 0x00007f59d3086190 in __start_context () at /lib64/libc.so.6
213 #12 0x00007ffecf01f990 in  ()
214 #13 0x0000000000000000 in  ()
215 
216 修复办法:
217 
218 diff  -Nuar a/chardev/char-socket.c  b/chardev/char-socket.c
219 --- a/chardev/char-socket.c     2023-03-14 20:36:09.910360722 +0800
220 +++ b/chardev/char-socket.c     2023-03-14 20:36:34.551591389 +0800
221 @@ -348,6 +348,9 @@
222  static GSource *tcp_chr_add_watch(Chardev *chr, GIOCondition cond)
223  {
224      SocketChardev *s = SOCKET_CHARDEV(chr);
225 +    if (!s->ioc) {
226 +        return NULL;
227 +    }
228      return qio_channel_create_watch(s->ioc, cond);
229  }
230  
231 =============================================================
232 重新编译rpm包后测试,需要测试配合迁移测试

 参考补丁:版本5.20修复

https://gitlab.com/qemu-project/qemu/-/commit/6585b1627899a3fcaf1cf62bfb659b04371ca9ec

https://gitlab.com/qemu-project/qemu/-/tree/6585b1627899a3fcaf1cf62bfb659b04371ca9ec

标签:8.1,__,0x0,int,kvm,chr,Chardev,qemu,class
From: https://www.cnblogs.com/maojun1998/p/17216763.html

相关文章

  • Linux Mint 18.1″Serena”首个Beta版本发布
    ​​Linux​​ Mint18.1Serena的首个beta版本已经于今天正式开放下载。LinuxMint基于LTS版本的Ubuntu系统,这意味着系统能够获得长期支持。创始人ClementLefebvre表示......
  • Linux Mint 18.1″Serena”首个Beta版本发布
    ​​Linux​​ Mint18.1Serena的首个beta版本已经于今天正式开放下载。LinuxMint基于LTS版本的Ubuntu系统,这意味着系统能够获得长期支持。创始人ClementLefebvre表示......
  • 自己动手从零写桌面操作系统GrapeOS系列教程——12.QEMU+GDB调试
    学习操作系统原理最好的方法是自己写一个简单的操作系统。写程序不免需要调试,写不同的程序调试方式也不同。如果做应用软件开发,相应的程序调试方式是建立在有操作系统......
  • 配置KVM虚拟化​
    推荐步骤:​安装KVM虚拟化服务器控制KVM服务​KVM管理控制台安装虚拟机​使用命令行管理KVM虚拟机​实验步骤:​一.安装KVM虚拟化服务器控制KVM服务​1.配置centos01支持虚拟......
  • qemu-system-x86_64 ---- Unable to init server: Could not connect: Connection ref
    报错如下: Unabletoinitserver:Couldnotconnect:Connectionrefusedgtkinitializationfailed 原因很可能是你没有连接VGA可以使用echo$DISPLAY来看看是......
  • Linux Kernel 4.8.11版本发布
    在感恩节的周末,Linux Kernel4.8稳定版分支和4.4LTS分支都获得了维护版本更新。今天发布的LinuxKernel4.8.11和此前的4.8.10版本相隔5天时间,根据短日志主要对77......
  • Linux Kernel 4.8.11版本发布
    在感恩节的周末,​​Linux​​ Kernel4.8稳定版分支和4.4LTS分支都获得了维护版本更新。今天发布的LinuxKernel4.8.11和此前的4.8.10版本相隔5天时间,根据短日志主要对77......
  • 8.1 宋明新儒学:“性即理”与“心即理”
    宋明新儒家的思想运动心就是人心,性就是人性,心与性的关系,是宋明新儒家学问的主体。为什么会有这样一个主体?这个主体的真实内涵是什么?宋明新儒家的思想运动,这个思想运动......
  • KVM之virsh管理命令
    1.Virsh简介virsh是用来管理客户端及其管理程序的命令行界面工具。virsh工具是构建在libvirt管理API上,可作为xm命令和图形客户端管理程序(virt-manager)的替代工......
  • KVM虚机扩容
    最近遇到一个新的需求,原来分配给虚拟机容量50G,后面业务需要拓展,发现存储不够了,需要扩容。准备了两个方案,新建一个虚拟硬盘直接堆上去virshattach-disk虚拟主机名称(域)......