Patchwork [v8,1/6] sockets: publish dummy_opts

login
register
mail settings
Submitter Bharata B Rao
Date Sept. 24, 2012, 8:52 a.m.
Message ID <20120924085225.GD18470@in.ibm.com>
Download mbox | patch
Permalink /patch/186316/
State New
Headers show

Comments

Bharata B Rao - Sept. 24, 2012, 8:52 a.m.
sockets: publish dummy_opts

From: Paolo Bonzini <pbonzini@redhat.com>

This is needed so that we can set up a QemuOpts instance from QMP
parameters.  The way to go here is to and move qemu-sockets.c away from
QemuOpts and use Laszlo's QemuOptsVisitor whenever *_opts functions are
called now.  This can be done later, however.

This would also enable block backends like gluster to make use of
inet_parse() for inet address parsing.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Bharata B Rao <bharata@linux.vnet.ibm.com>
---

 qemu-sockets.c |   14 +++++++-------
 qemu_socket.h  |    2 ++
 2 files changed, 9 insertions(+), 7 deletions(-)

Patch

diff --git a/qemu-sockets.c b/qemu-sockets.c
index 361d890..b292311 100644
--- a/qemu-sockets.c
+++ b/qemu-sockets.c
@@ -32,9 +32,9 @@ 
 static const int on=1, off=0;
 
 /* used temporarely until all users are converted to QemuOpts */
-static QemuOptsList dummy_opts = {
-    .name = "dummy",
-    .head = QTAILQ_HEAD_INITIALIZER(dummy_opts.head),
+QemuOptsList socket_opts = {
+    .name = "socket",
+    .head = QTAILQ_HEAD_INITIALIZER(socket_opts.head),
     .desc = {
         {
             .name = "path",
@@ -469,7 +469,7 @@  int inet_listen(const char *str, char *ostr, int olen,
     char *optstr;
     int sock = -1;
 
-    opts = qemu_opts_create(&dummy_opts, NULL, 0, NULL);
+    opts = qemu_opts_create(&socket_opts, NULL, 0, NULL);
     if (inet_parse(opts, str) == 0) {
         sock = inet_listen_opts(opts, port_offset, errp);
         if (sock != -1 && ostr) {
@@ -498,7 +498,7 @@  int inet_connect(const char *str, bool block, bool *in_progress, Error **errp)
     QemuOpts *opts;
     int sock = -1;
 
-    opts = qemu_opts_create(&dummy_opts, NULL, 0, NULL);
+    opts = qemu_opts_create(&socket_opts, NULL, 0, NULL);
     if (inet_parse(opts, str) == 0) {
         if (block) {
             qemu_opt_set(opts, "block", "on");
@@ -597,7 +597,7 @@  int unix_listen(const char *str, char *ostr, int olen)
     char *path, *optstr;
     int sock, len;
 
-    opts = qemu_opts_create(&dummy_opts, NULL, 0, NULL);
+    opts = qemu_opts_create(&socket_opts, NULL, 0, NULL);
 
     optstr = strchr(str, ',');
     if (optstr) {
@@ -625,7 +625,7 @@  int unix_connect(const char *path)
     QemuOpts *opts;
     int sock;
 
-    opts = qemu_opts_create(&dummy_opts, NULL, 0, NULL);
+    opts = qemu_opts_create(&socket_opts, NULL, 0, NULL);
     qemu_opt_set(opts, "path", path);
     sock = unix_connect_opts(opts);
     qemu_opts_del(opts);
diff --git a/qemu_socket.h b/qemu_socket.h
index 30ae6af..c87ee57 100644
--- a/qemu_socket.h
+++ b/qemu_socket.h
@@ -30,6 +30,8 @@  int inet_aton(const char *cp, struct in_addr *ia);
 #include "error.h"
 #include "qerror.h"
 
+extern QemuOptsList socket_opts;
+
 /* misc helpers */
 int qemu_socket(int domain, int type, int protocol);
 int qemu_accept(int s, struct sockaddr *addr, socklen_t *addrlen);