All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] A question about 9894dc0cdcc397ee5b26370bc53da6d360a363c2
@ 2016-07-18  8:41 Gonglei (Arei)
  2016-07-18  9:07 ` Daniel P. Berrange
  0 siblings, 1 reply; 3+ messages in thread
From: Gonglei (Arei) @ 2016-07-18  8:41 UTC (permalink / raw)
  To: berrange@redhat.com, Paolo Bonzini; +Cc: Lilijun (Jerry), qemu-devel@nongnu.org

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-07-19  8:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-07-18  8:41 [Qemu-devel] A question about 9894dc0cdcc397ee5b26370bc53da6d360a363c2 Gonglei (Arei)
2016-07-18  9:07 ` Daniel P. Berrange
2016-07-19  8:51   ` Gonglei (Arei)

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.