qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] A question about 9894dc0cdcc397ee5b26370bc53da6d360a363c2


From: Gonglei (Arei)
Subject: [Qemu-devel] A question about 9894dc0cdcc397ee5b26370bc53da6d360a363c2
Date: Mon, 18 Jul 2016 08:41:32 +0000

Hi Daniel & Paolo,

Commit 9894dc0c "char: convert from GIOChannel to QIOChannel", 
about the below code segment:

static bool qemu_chr_open_socket_fd(CharDriverState *chr, Error **errp)
 {
     TCPCharDriver *s = chr->opaque;
-    int fd;
+    QIOChannelSocket *sioc = qio_channel_socket_new();
 
     if (s->is_listen) {
-        fd = socket_listen(s->addr, errp);
+        if (qio_channel_socket_listen_sync(sioc, s->addr, errp) < 0) {
+            goto fail;
+        }
+        qemu_chr_finish_socket_connection(chr, sioc);
     } else if (s->reconnect_time) {
-        fd = socket_connect(s->addr, errp, qemu_chr_socket_connected, chr);
-        return fd >= 0;
+        qio_channel_socket_connect_async(sioc, s->addr,
+                                         qemu_chr_socket_connected,
+                                         chr, NULL);
     } else {
-        fd = socket_connect(s->addr, errp, NULL, NULL);
-    }
-    if (fd < 0) {
-        return false;
+        if (qio_channel_socket_connect_sync(sioc, s->addr, errp) < 0) {
+            goto fail;
+        }
+        qemu_chr_finish_socket_connection(chr, sioc);
     }
 
-    qemu_chr_finish_socket_connection(chr, fd);
     return true;
+
+ fail:
+    object_unref(OBJECT(sioc));
+    return false;
 }

Why did you change socket_connect() to qio_channel_socket_connect_async
but not qio_channel_socket_connect_sync when s->reconnect_time is ture? Thanks.
I can't get the reason from the commit message.

PS: We encountered a problem that when config vhost-user-net reconneticon 
function,
the virtio_net_get_features() didn't get a correct value after this changed, 
and it was
fixed when we change the async to sync.

[2016-07-17 21:18:55] virtio_net_get_features:551 virtio_net_get_features 5 
n->host_features=12582855, features=2042626023, nc->peer=0x7f11c4b80820
[2016-07-17 21:18:55] get_vhost_net:400 get_vhost_net nc=0x7f11c4b80820
[2016-07-17 21:18:55] get_vhost_net:405 get_vhost_net nc type=11, 
NET_CLIENT_OPTIONS_KIND_TAP=3, NET_CLIENT_OPTIONS_KIND_VHOST_USER=11
[2016-07-17 21:18:55] get_vhost_net:417 get_vhost_net vhost_net=(nil)


Regards,
-Gonglei





reply via email to

[Prev in Thread] Current Thread [Next in Thread]