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

[Libguestfs] [PATCH] Enable virtio-serial in the daemon



Update the daemon to recognise a guestfs_vmchannel argument of the form
"virtio-serial:<name>". The daemon will expect a virtio-serial device to be
available locally at /dev/virtio-ports/<name>.
---
 daemon/guestfsd.c |   32 ++++++++++++++++++++++++++++++--
 1 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/daemon/guestfsd.c b/daemon/guestfsd.c
index 49aca08..1417e50 100644
--- a/daemon/guestfsd.c
+++ b/daemon/guestfsd.c
@@ -345,10 +345,38 @@ main (int argc, char *argv[])
       }
     }
     freeaddrinfo (res);
-  } else {
+  }
+
+#define VSPREFIX "virtio-serial:"
+#define VSPREFIX_LEN sizeof(VSPREFIX)
+
+  else if (STREQLEN (vmchannel, VSPREFIX, VSPREFIX_LEN)) {
+      char *name;
+
+      if (asprintf(&name, "/dev/virtio-ports/%s", vmchannel + VSPREFIX_LEN) < 0)
+      {
+          perror ("malloc");
+          exit (EXIT_FAILURE);
+      }
+
+      fprintf (stderr, "Attempting to open virtio-serial device %s\n", name);
+      sock = open (name, O_RDWR);
+      if (sock == -1) {
+          fprintf (stderr, "open %s: %m\n", name);
+      }
+
+      free(name);
+  }
+
+#undef VSPREFIX
+#undef VSPREFIX_LEN
+  
+  else {
     fprintf (stderr,
              "unknown vmchannel connection type: %s\n"
-             "expecting \"tcp:<ip>:<port>\"\n",
+             "expecting one of:\n"
+             "\"tcp:<ip>:<port>\"\n"
+             "\"virtio-serial:<name>\"\n",
              vmchannel);
     exit (EXIT_FAILURE);
   }
-- 
1.7.2.2


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