qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Max Reitz <mreitz@redhat.com>
To: qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Markus Armbruster <armbru@redhat.com>,
	Max Reitz <mreitz@redhat.com>
Subject: [Qemu-devel] [PATCH for-2.4 2/5] chardev/irc: Add sockfd option
Date: Wed,  1 Apr 2015 14:09:14 +0200	[thread overview]
Message-ID: <1427890157-18639-3-git-send-email-mreitz@redhat.com> (raw)
In-Reply-To: <1427890157-18639-1-git-send-email-mreitz@redhat.com>

IRC being well on the way to deprecate other character devices, it must
be exposed to management tools as well. These often prefer to pass a
socket FD instead of a host and port to connect to, so this patch adds
an appropriate option.

Signed-off-by: Max Reitz <mreitz@redhat.com>
---
 qemu-char.c | 29 +++++++++++++++++++++++------
 1 file changed, 23 insertions(+), 6 deletions(-)

diff --git a/qemu-char.c b/qemu-char.c
index a68fef3..4507e5f 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -3937,19 +3937,26 @@ static void qemu_chr_parse_udp(QemuOpts *opts, ChardevBackend *backend,
 static void qemu_chr_parse_irc(QemuOpts *opts, ChardevBackend *backend,
                                Error **errp)
 {
-    const char *host, *port, *nick, *channel;
+    const char *host, *port, *nick, *channel, *sockfd;
     SocketAddress *addr;
 
     host    = qemu_opt_get(opts, "host");
     port    = qemu_opt_get(opts, "port") ?: "6667";
+    sockfd  = qemu_opt_get(opts, "sockfd");
     nick    = qemu_opt_get(opts, "nick");
     channel = qemu_opt_get(opts, "channel");
 
-    if (!host || !nick || !channel) {
+    if ((!host && !sockfd) || !nick || !channel) {
         error_setg(errp, "chardev: irc: Missing options");
         return;
     }
 
+    if ((host || port) && sockfd) {
+        error_setg(errp,
+                   "chardev: irc: Both sockfd and host and/or port specified");
+        return;
+    }
+
     if (strlen(nick) > 64 || strlen(channel) > 64) {
         error_setg(errp, "chardev: irc: Nick or channel too long");
         return;
@@ -3958,10 +3965,17 @@ static void qemu_chr_parse_irc(QemuOpts *opts, ChardevBackend *backend,
     backend->irc = g_new0(ChardevIrc, 1);
 
     addr = g_new0(SocketAddress, 1);
-    addr->kind = SOCKET_ADDRESS_KIND_INET;
-    addr->inet = g_new0(InetSocketAddress, 1);
-    addr->inet->host = g_strdup(host);
-    addr->inet->port = g_strdup(port);
+    if (host) {
+        addr->kind = SOCKET_ADDRESS_KIND_INET;
+        addr->inet = g_new0(InetSocketAddress, 1);
+        addr->inet->host = g_strdup(host);
+        addr->inet->port = g_strdup(port);
+    } else {
+        addr->kind = SOCKET_ADDRESS_KIND_FD;
+        addr->fd = g_new(String, 1);
+        addr->fd->str = g_strdup(sockfd);
+    }
+
     backend->irc->addr = addr;
 
     backend->irc->nick = g_strdup(nick);
@@ -4332,6 +4346,9 @@ QemuOptsList qemu_chardev_opts = {
         },{
             .name = "channel",
             .type = QEMU_OPT_STRING,
+        },{
+            .name = "sockfd",
+            .type = QEMU_OPT_STRING,
         },
         { /* end of list */ }
     },
-- 
2.3.4

  parent reply	other threads:[~2015-04-01 12:09 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-01 12:09 [Qemu-devel] [PATCH for-2.4 0/5] chardev: Add IRC char driver Max Reitz
2015-04-01 12:09 ` [Qemu-devel] [PATCH for-2.4 1/5] " Max Reitz
2015-04-01 12:09 ` Max Reitz [this message]
2015-04-01 12:09 ` [Qemu-devel] [PATCH for-2.4 3/5] chardev/irc: Add SSL support Max Reitz
2015-04-01 12:09 ` [Qemu-devel] [PATCH for-2.4 4/5] chardev/irc: Add end-to-end encryption Max Reitz
2015-04-01 12:09 ` [Qemu-devel] [PATCH for-2.4 5/5] Documentation: Document IRC char driver Max Reitz
2015-04-02  8:57 ` [Qemu-devel] [PATCH for-2.4 0/5] chardev: Add " Stefan Hajnoczi
2015-04-02 14:04   ` Max Reitz
2015-04-02 19:19 ` Markus Armbruster

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=1427890157-18639-3-git-send-email-mreitz@redhat.com \
    --to=mreitz@redhat.com \
    --cc=armbru@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /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).