From: Orit Wasserman <owasserm@redhat.com>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com, aliguori@us.ibm.com, quintela@redhat.com,
armbru@redhat.com, mst@redhat.com, mdroth@linux.vnet.ibm.com,
lcapitulino@redhat.com, Orit Wasserman <owasserm@redhat.com>,
pbonzini@redhat.com, akong@redhat.com
Subject: [Qemu-devel] [PATCH v2 2/3] Separate inet_connect into inet_connect (blocking) and inet_nonblocking_connect
Date: Wed, 12 Sep 2012 14:12:57 +0300 [thread overview]
Message-ID: <1347448378-23915-3-git-send-email-owasserm@redhat.com> (raw)
In-Reply-To: <1347448378-23915-1-git-send-email-owasserm@redhat.com>
No need to add non blocking parameters to the blocking inet_connect
Signed-off-by: Orit Wasserman <owasserm@redhat.com>
---
migration-tcp.c | 2 +-
nbd.c | 2 +-
qemu-sockets.c | 24 ++++++++++++++++++++----
qemu_socket.h | 4 +++-
ui/vnc.c | 2 +-
5 files changed, 26 insertions(+), 8 deletions(-)
diff --git a/migration-tcp.c b/migration-tcp.c
index ac891c3..7f6ad98 100644
--- a/migration-tcp.c
+++ b/migration-tcp.c
@@ -88,7 +88,7 @@ int tcp_start_outgoing_migration(MigrationState *s, const char *host_port,
s->write = socket_write;
s->close = tcp_close;
- s->fd = inet_connect(host_port, false, &in_progress, errp);
+ s->fd = inet_nonblocking_connect(host_port, &in_progress, errp);
if (error_is_set(errp)) {
migrate_fd_error(s);
return -1;
diff --git a/nbd.c b/nbd.c
index 0dd60c5..206f75c 100644
--- a/nbd.c
+++ b/nbd.c
@@ -162,7 +162,7 @@ int tcp_socket_outgoing(const char *address, uint16_t port)
int tcp_socket_outgoing_spec(const char *address_and_port)
{
- return inet_connect(address_and_port, true, NULL, NULL);
+ return inet_connect(address_and_port, NULL);
}
int tcp_socket_incoming(const char *address, uint16_t port)
diff --git a/qemu-sockets.c b/qemu-sockets.c
index 68e4d30..4f5eca8 100644
--- a/qemu-sockets.c
+++ b/qemu-sockets.c
@@ -518,16 +518,32 @@ int inet_listen(const char *str, char *ostr, int olen,
return sock;
}
-int inet_connect(const char *str, bool block, bool *in_progress, Error **errp)
+int inet_connect(const char *str, Error **errp)
{
QemuOpts *opts;
int sock = -1;
opts = qemu_opts_create(&dummy_opts, NULL, 0, NULL);
if (inet_parse(opts, str) == 0) {
- if (block) {
- qemu_opt_set(opts, "block", "on");
- }
+ qemu_opt_set(opts, "block", "on");
+ sock = inet_connect_opts(opts, NULL, errp);
+ } else {
+ error_set(errp, QERR_SOCKET_CREATE_FAILED);
+ }
+ qemu_opts_del(opts);
+ return sock;
+}
+
+
+int inet_nonblocking_connect(const char *str, bool *in_progress,
+ Error **errp)
+{
+ QemuOpts *opts;
+ int sock = -1;
+
+ opts = qemu_opts_create(&dummy_opts, NULL, 0, NULL);
+ if (inet_parse(opts, str) == 0) {
+ qemu_opt_set(opts, "block", "off");
sock = inet_connect_opts(opts, in_progress, errp);
} else {
error_set(errp, QERR_SOCKET_CREATE_FAILED);
diff --git a/qemu_socket.h b/qemu_socket.h
index 30ae6af..c47f2b0 100644
--- a/qemu_socket.h
+++ b/qemu_socket.h
@@ -43,7 +43,9 @@ int inet_listen_opts(QemuOpts *opts, int port_offset, Error **errp);
int inet_listen(const char *str, char *ostr, int olen,
int socktype, int port_offset, Error **errp);
int inet_connect_opts(QemuOpts *opts, bool *in_progress, Error **errp);
-int inet_connect(const char *str, bool block, bool *in_progress, Error **errp);
+int inet_connect(const char *str, Error **errp);
+int inet_nonblocking_connect(const char *str, bool *in_progress,
+ Error **errp);
int inet_dgram_opts(QemuOpts *opts);
const char *inet_strfamily(int family);
diff --git a/ui/vnc.c b/ui/vnc.c
index 385e345..01b2daf 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -3061,7 +3061,7 @@ int vnc_display_open(DisplayState *ds, const char *display)
if (strncmp(display, "unix:", 5) == 0)
vs->lsock = unix_connect(display+5);
else
- vs->lsock = inet_connect(display, true, NULL, NULL);
+ vs->lsock = inet_connect(display, NULL);
if (-1 == vs->lsock) {
g_free(vs->display);
vs->display = NULL;
--
1.7.7.6
next prev parent reply other threads:[~2012-09-12 11:14 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-12 11:12 [Qemu-devel] [PATCH v2 0/3] nonblocking connect address handling cleanup Orit Wasserman
2012-09-12 11:12 ` [Qemu-devel] [PATCH v2 1/3] Refactor inet_connect_opts function Orit Wasserman
2012-09-13 12:35 ` Markus Armbruster
2012-09-13 16:44 ` Orit Wasserman
2012-09-13 16:52 ` Orit Wasserman
2012-09-14 7:37 ` Michael S. Tsirkin
2012-09-13 13:14 ` Markus Armbruster
2012-09-13 16:44 ` Orit Wasserman
2012-09-12 11:12 ` Orit Wasserman [this message]
2012-09-13 12:44 ` [Qemu-devel] [PATCH v2 2/3] Separate inet_connect into inet_connect (blocking) and inet_nonblocking_connect Markus Armbruster
2012-09-13 16:40 ` Orit Wasserman
2012-09-12 11:12 ` [Qemu-devel] [PATCH v2 3/3] Fix address handling in inet_nonblocking_connect Orit Wasserman
2012-09-13 13:22 ` Markus Armbruster
2012-09-13 13:32 ` Michael S. Tsirkin
2012-09-13 14:23 ` Orit Wasserman
2012-09-13 17:27 ` Orit Wasserman
2012-09-12 14:16 ` [Qemu-devel] [PATCH v2 0/3] nonblocking connect address handling cleanup Amos Kong
2012-09-12 20:37 ` Michael S. Tsirkin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1347448378-23915-3-git-send-email-owasserm@redhat.com \
--to=owasserm@redhat.com \
--cc=akong@redhat.com \
--cc=aliguori@us.ibm.com \
--cc=armbru@redhat.com \
--cc=kwolf@redhat.com \
--cc=lcapitulino@redhat.com \
--cc=mdroth@linux.vnet.ibm.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=quintela@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).