qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [RFC Patch 2/3] chardev: save the passed in 'fd' parame


From: Wei Xu
Subject: Re: [Qemu-devel] [RFC Patch 2/3] chardev: save the passed in 'fd' parameter during parsing
Date: Thu, 2 Jun 2016 00:20:18 +0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0

On 2016年06月01日 01:26, Eric Blake wrote:
On 05/31/2016 10:30 AM, address@hidden wrote:
From: Wei Xu <address@hidden>

Save the 'fd' paramter as unix socket 'sockfd' member.

Signed-off-by: Wei Xu <address@hidden>
---
  qemu-char.c | 7 +++++++
  1 file changed, 7 insertions(+)

diff --git a/qemu-char.c b/qemu-char.c
index ea9c02e..8d20494 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -3664,6 +3664,7 @@ static void qemu_chr_parse_socket(QemuOpts *opts, 
ChardevBackend *backend,
      bool is_telnet      = qemu_opt_get_bool(opts, "telnet", false);
      bool do_nodelay     = !qemu_opt_get_bool(opts, "delay", true);
      int64_t reconnect   = qemu_opt_get_number(opts, "reconnect", 0);
+    const int32_t fd = (int32_t)qemu_opt_get_number(opts, "sockfd", 0);
      const char *path = qemu_opt_get(opts, "path");
      const char *host = qemu_opt_get(opts, "host");
      const char *port = qemu_opt_get(opts, "port");
@@ -3708,6 +3709,12 @@ static void qemu_chr_parse_socket(QemuOpts *opts, 
ChardevBackend *backend,
          addr->type = SOCKET_ADDRESS_KIND_UNIX;
          q_unix = addr->u.q_unix.data = g_new0(UnixSocketAddress, 1);
          q_unix->path = g_strdup(path);
+
+        if (fd) {
+            q_unix->sockfd = fd;
+        } else {
+            q_unix->sockfd = 0;

0 is a valid fd number; this risks accidentally closing stdin later on.
  Please use -1 for unset, if you must store an fd number.  But given my
comments on patch 1, I'm not sure that you need this addition.
Thanks for your comment, i just wonder what's the motivation of qemu_open(), seems it's more like an regular file consideration, is it?
can it be easily expended to socket file?




reply via email to

[Prev in Thread] Current Thread [Next in Thread]