Flexible guestfs_vmchannel parameter for future appliances.
[libguestfs.git] / src / guestfs.c
index bc34f60..ec7473e 100644 (file)
@@ -85,8 +85,8 @@ static void close_handles (void);
 #define UNIX_PATH_MAX 108
 
 /* Also in guestfsd.c */
-#define GUESTFWD_PORT 6666
 #define GUESTFWD_ADDR "10.0.2.4"
+#define GUESTFWD_PORT "6666"
 
 /* GuestFS handle and connection. */
 enum state { CONFIG, LAUNCHING, READY, BUSY, NO_HANDLE };
@@ -984,6 +984,7 @@ guestfs__launch (guestfs_h *g)
 
   if (r == 0) {                        /* Child (qemu). */
     char buf[256];
+    const char *vmchannel = NULL;
 
     /* Set up the full command line.  Do this in the subprocess so we
      * don't need to worry about cleaning up.
@@ -1026,8 +1027,8 @@ guestfs__launch (guestfs_h *g)
 
       snprintf (buf, sizeof buf,
                 "user,vlan=0,net=10.0.2.0/8,"
-                "guestfwd=tcp:%s:%d-chardev:guestfsvmc",
-                GUESTFWD_ADDR, GUESTFWD_PORT);
+                "guestfwd=tcp:" GUESTFWD_ADDR ":" GUESTFWD_PORT
+                "-chardev:guestfsvmc");
 
       add_cmdline (g, "-net");
       add_cmdline (g, buf);
@@ -1036,7 +1037,7 @@ guestfs__launch (guestfs_h *g)
        * syntax, or if not then we'll get a quick failure.
        */
       snprintf (buf, sizeof buf,
-                "channel,%d:unix:%s,server,nowait", GUESTFWD_PORT, unixsock);
+                "channel," GUESTFWD_PORT ":unix:%s,server,nowait", unixsock);
 
       add_cmdline (g, "-net");
       add_cmdline (g, buf);
@@ -1045,6 +1046,7 @@ guestfs__launch (guestfs_h *g)
     }
     add_cmdline (g, "-net");
     add_cmdline (g, "nic,model=" NET_IF ",vlan=0");
+    vmchannel = "guestfs_vmchannel=tcp:" GUESTFWD_ADDR ":" GUESTFWD_PORT " ";
 
 #define LINUX_CMDLINE                                                  \
     "panic=1 "         /* force kernel to panic if daemon exits */     \
@@ -1058,9 +1060,11 @@ guestfs__launch (guestfs_h *g)
     snprintf (buf, sizeof buf,
               LINUX_CMDLINE
               "%s"              /* (selinux) */
+              "%s"              /* (vmchannel) */
               "%s"              /* (verbose) */
               "%s",             /* (append) */
               g->selinux ? "selinux=1 enforcing=0 " : "selinux=0 ",
+              vmchannel ? vmchannel : "",
               g->verbose ? "guestfs_verbose=1 " : "",
               g->append ? g->append : "");