Patchwork [10/12] qemu-sockets: move block from QemuOpts to arguments

login
register
mail settings
Submitter Paolo Bonzini
Date Sept. 19, 2012, 2:31 p.m.
Message ID <1348065078-5139-11-git-send-email-pbonzini@redhat.com>
Download mbox | patch
Permalink /patch/185069/
State New
Headers show

Comments

Paolo Bonzini - Sept. 19, 2012, 2:31 p.m.
This option is not accessible from anywhere in the command-line, so it
need not be a QemuOpt.  Make it a separate argument, which will be the
same convention used by socket_connect.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 qemu-char.c    |  2 +-
 qemu-sockets.c | 12 ++----------
 qemu_socket.h  |  2 +-
 3 file modificati, 4 inserzioni(+), 12 rimozioni(-)

Patch

diff --git a/qemu-char.c b/qemu-char.c
index b886f3b..b33bdaa 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -2459,7 +2459,7 @@  static CharDriverState *qemu_chr_open_socket(QemuOpts *opts)
         if (is_listen) {
             fd = inet_listen_opts(opts, 0, NULL);
         } else {
-            fd = inet_connect_opts(opts, NULL, NULL);
+            fd = inet_connect_opts(opts, false, NULL, NULL);
         }
     }
     if (fd < 0) {
diff --git a/qemu-sockets.c b/qemu-sockets.c
index c213cc8..8a7c5d4 100644
--- a/qemu-sockets.c
+++ b/qemu-sockets.c
@@ -54,9 +54,6 @@  static QemuOptsList dummy_opts = {
         },{
             .name = "ipv6",
             .type = QEMU_OPT_BOOL,
-        },{
-            .name = "block",
-            .type = QEMU_OPT_BOOL,
         },
         { /* end if list */ }
     },
@@ -209,7 +206,7 @@  listen:
     return slisten;
 }
 
-int inet_connect_opts(QemuOpts *opts, bool *in_progress, Error **errp)
+int inet_connect_opts(QemuOpts *opts, bool block, bool *in_progress, Error **errp)
 {
     struct addrinfo ai,*res,*e;
     const char *addr;
@@ -217,7 +214,6 @@  int inet_connect_opts(QemuOpts *opts, bool *in_progress, Error **errp)
     char uaddr[INET6_ADDRSTRLEN+1];
     char uport[33];
     int sock,rc;
-    bool block;
 
     memset(&ai,0, sizeof(ai));
     ai.ai_flags = AI_CANONNAME | AI_ADDRCONFIG;
@@ -230,7 +226,6 @@  int inet_connect_opts(QemuOpts *opts, bool *in_progress, Error **errp)
 
     addr = qemu_opt_get(opts, "host");
     port = qemu_opt_get(opts, "port");
-    block = qemu_opt_get_bool(opts, "block", 0);
     if (addr == NULL || port == NULL) {
         fprintf(stderr, "inet_connect: host and/or port not specified\n");
         error_set(errp, QERR_SOCKET_CREATE_FAILED);
@@ -536,10 +531,7 @@  int inet_connect(const char *str, bool block, bool *in_progress, Error **errp)
         opts = qemu_opts_create(&dummy_opts, NULL, 0, NULL);
         inet_addr_to_opts(opts, addr);
         qapi_free_IPSocketAddress(addr);
-        if (block) {
-            qemu_opt_set(opts, "block", "on");
-        }
-        sock = inet_connect_opts(opts, in_progress, errp);
+        sock = inet_connect_opts(opts, block, in_progress, errp);
         qemu_opts_del(opts);
     }
     return sock;
diff --git a/qemu_socket.h b/qemu_socket.h
index 6e06982..ad9e342 100644
--- a/qemu_socket.h
+++ b/qemu_socket.h
@@ -42,7 +42,7 @@  int send_all(int fd, const void *buf, int len1);
 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_opts(QemuOpts *opts, bool block, bool *in_progress, Error **errp);
 int inet_connect(const char *str, bool block, bool *in_progress, Error **errp);
 int inet_dgram_opts(QemuOpts *opts);
 const char *inet_strfamily(int family);