qemu with hax to log dma reads & writes jcs.org/2018/11/12/vfio

fix vhost_user_blk_watch crash

the G_IO_HUP is watched in tcp_chr_connect, and the callback
vhost_user_blk_watch is not needed, because tcp_chr_hup is registered as
callback. And it will close the tcp link.

Signed-off-by: Li Feng <fengli@smartx.com>
Message-Id: <20200323052924.29286-1-fengli@smartx.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>

authored by

Li Feng and committed by
Michael S. Tsirkin
9d283f85 32a2d6b1

-20
-19
hw/block/vhost-user-blk.c
··· 349 349 vhost_dev_cleanup(&s->dev); 350 350 } 351 351 352 - static gboolean vhost_user_blk_watch(GIOChannel *chan, GIOCondition cond, 353 - void *opaque) 354 - { 355 - DeviceState *dev = opaque; 356 - VirtIODevice *vdev = VIRTIO_DEVICE(dev); 357 - VHostUserBlk *s = VHOST_USER_BLK(vdev); 358 - 359 - qemu_chr_fe_disconnect(&s->chardev); 360 - 361 - return true; 362 - } 363 - 364 352 static void vhost_user_blk_event(void *opaque, QEMUChrEvent event) 365 353 { 366 354 DeviceState *dev = opaque; ··· 373 361 qemu_chr_fe_disconnect(&s->chardev); 374 362 return; 375 363 } 376 - s->watch = qemu_chr_fe_add_watch(&s->chardev, G_IO_HUP, 377 - vhost_user_blk_watch, dev); 378 364 break; 379 365 case CHR_EVENT_CLOSED: 380 366 vhost_user_blk_disconnect(dev); 381 - if (s->watch) { 382 - g_source_remove(s->watch); 383 - s->watch = 0; 384 - } 385 367 break; 386 368 case CHR_EVENT_BREAK: 387 369 case CHR_EVENT_MUX_IN: ··· 428 410 429 411 s->inflight = g_new0(struct vhost_inflight, 1); 430 412 s->vhost_vqs = g_new0(struct vhost_virtqueue, s->num_queues); 431 - s->watch = 0; 432 413 s->connected = false; 433 414 434 415 qemu_chr_fe_set_handlers(&s->chardev, NULL, NULL, vhost_user_blk_event,
-1
include/hw/virtio/vhost-user-blk.h
··· 38 38 VhostUserState vhost_user; 39 39 struct vhost_virtqueue *vhost_vqs; 40 40 VirtQueue **virtqs; 41 - guint watch; 42 41 bool connected; 43 42 } VHostUserBlk; 44 43