vhost-user: keep QIOChannelSocket for backend channel
Keep QIOChannelSocket pointer instead of more generic QIOChannel. No real difference for now, but it would be simpler to migrate socket fd in further commit. Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru> Acked-by: Raphael Norwitz <raphael.s.norwitz@gmail.com> Reviewed-by: Daniil Tatianin <d-tatianin@yandex-team.ru> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Tested-by: Lei Yang <leiyang@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Message-Id: <20260420200339.708640-10-vsementsov@yandex-team.ru>
Vladimir Sementsov-Ogievskiy committed
Apr 20, 2026 at 23:03 UTC
a00d6e75179fba5b6b4ad296ccdc251b02a1b535
1 file changed
+10
-11
hw/virtio/vhost-user.c
+10
-11
@@ -239,7 +239,7 @@ struct vhost_user {
239
struct vhost_dev *dev;
240
/* Shared between vhost devs of the same virtio device */
241
VhostUserState *user;
242
- QIOChannel *backend_ioc;
242
+ QIOChannelSocket *backend_sioc;
243
GSource *backend_src;
244
NotifierWithReturn postcopy_notifier;
245
struct PostCopyFD postcopy_fd;
@@ -1796,8 +1796,8 @@ static void close_backend_channel(struct vhost_user *u)
1796
g_source_destroy(u->backend_src);
1797
g_source_unref(u->backend_src);
1798
u->backend_src = NULL;
1799
- object_unref(OBJECT(u->backend_ioc));
1800
- u->backend_ioc = NULL;
1799
+ object_unref(OBJECT(u->backend_sioc));
1800
+ u->backend_sioc = NULL;
1801
}
1802
1803
static gboolean backend_read(QIOChannel *ioc, GIOCondition condition,
@@ -1909,7 +1909,6 @@ static int vhost_setup_backend_channel(struct vhost_dev *dev)
1909
bool reply_supported =
1910
vhost_user_has_protocol_feature(dev, VHOST_USER_PROTOCOL_F_REPLY_ACK);
1911
Error *local_err = NULL;
1912
- QIOChannel *ioc;
1912
1913
if (!vhost_user_has_protocol_feature(
1914
dev, VHOST_USER_PROTOCOL_F_BACKEND_REQ)) {
@@ -1922,15 +1921,15 @@ static int vhost_setup_backend_channel(struct vhost_dev *dev)
1921
return -saved_errno;
1922
}
1923
1925
- ioc = QIO_CHANNEL(qio_channel_socket_new_fd(sv[0], &local_err));
1926
- if (!ioc) {
1924
+ u->backend_sioc = qio_channel_socket_new_fd(sv[0], &local_err);
1925
+ if (!u->backend_sioc) {
1926
error_report_err(local_err);
1927
return -ECONNREFUSED;
1928
}
1930
- u->backend_ioc = ioc;
1931
- u->backend_src = qio_channel_add_watch_source(u->backend_ioc,
1932
- G_IO_IN | G_IO_HUP,
1933
- backend_read, dev, NULL, NULL);
1929
+ u->backend_src = qio_channel_add_watch_source(QIO_CHANNEL(u->backend_sioc),
1930
+ G_IO_IN | G_IO_HUP,
1931
+ backend_read, dev,
1932
+ NULL, NULL);
1933
1934
if (reply_supported) {
1935
msg.hdr.flags |= VHOST_USER_NEED_REPLY_MASK;
@@ -2350,7 +2349,7 @@ static int vhost_user_backend_cleanup(struct vhost_dev *dev)
2349
close(u->postcopy_fd.fd);
2350
u->postcopy_fd.handler = NULL;
2351
}
2353
- if (u->backend_ioc) {
2352
+ if (u->backend_sioc) {
2353
close_backend_channel(u);
2354
}
2355
g_free(u->region_rb);