[Libguestfs] [PATCH] Enable new-style -chardev ... guestfwd command line
Richard W.M. Jones
rjones at redhat.com
Fri Sep 18 13:09:25 UTC 2009
This also changes the name of the "vmchannel" buffer to just "buf",
reflecting the fact that it's just used as a temporary buffer, and
that the word vmchannel is overloaded.
Rich.
--
Richard Jones, Emerging Technologies, Red Hat http://et.redhat.com/~rjones
libguestfs lets you edit virtual machines. Supports shell scripting,
bindings from many languages. http://et.redhat.com/~rjones/libguestfs/
See what it can do: http://et.redhat.com/~rjones/libguestfs/recipes.html
-------------- next part --------------
>From 27374fa479368a15e3c50ea17343be1397b29a10 Mon Sep 17 00:00:00 2001
From: Richard Jones <rjones at trick.home.annexia.org>
Date: Fri, 18 Sep 2009 14:06:07 +0100
Subject: [PATCH] Enable new-style -chardev ... guestfwd command line.
Newer versions of qemu have changed the command line format
(again). '-net channel' is now deprecated. Instead we use:
-chardev socket,id=guestfsvmc,path=/path/to/sock,server,nowait
-net user,vlan=0,net=10.0.2.0/8,guestfwd=tcp:10.0.2.4:6666-chardev:guestfsvmc
-net nic,model=ne2k_pci,vlan=0
The old style format is still used if the new style is not
detected at runtime.
---
src/guestfs.c | 46 ++++++++++++++++++++++++++--------------------
1 files changed, 26 insertions(+), 20 deletions(-)
diff --git a/src/guestfs.c b/src/guestfs.c
index 069de45..c735c1c 100644
--- a/src/guestfs.c
+++ b/src/guestfs.c
@@ -86,7 +86,7 @@ static void close_handles (void);
/* Also in guestfsd.c */
#define GUESTFWD_PORT 6666
-//#define GUESTFWD_ADDR "10.0.2.4"
+#define GUESTFWD_ADDR "10.0.2.4"
/* GuestFS handle and connection. */
enum state { CONFIG, LAUNCHING, READY, BUSY, NO_HANDLE };
@@ -983,7 +983,7 @@ guestfs__launch (guestfs_h *g)
}
if (r == 0) { /* Child (qemu). */
- char vmchannel[256];
+ char buf[256];
char append[256];
char memsize_str[256];
@@ -1025,37 +1025,43 @@ guestfs__launch (guestfs_h *g)
add_cmdline (g, "-serial");
add_cmdline (g, "stdio");
-#if 0
- /* Doesn't work. See:
- * http://lists.gnu.org/archive/html/qemu-devel/2009-07/threads.html
- * Subject "guestfwd option doesn't allow supplementary ,server,nowait"
- */
- if (qemu_supports (g, "guestfwd")) {
- /* New-style -net user,guestfwd=... syntax for vmchannel. See:
+ if (qemu_supports (g, "-chardev") && qemu_supports (g, "guestfwd")) {
+ /* New-style -net user,guestfwd=... syntax for guestfwd. See:
+ *
* http://git.savannah.gnu.org/cgit/qemu.git/commit/?id=c92ef6a22d3c71538fcc48fb61ad353f7ba03b62
+ *
+ * The original suggested format doesn't work, see:
+ *
+ * http://lists.gnu.org/archive/html/qemu-devel/2009-07/msg01654.html
+ *
+ * However Gerd Hoffman privately suggested to me using -chardev
+ * instead, which does work.
*/
- snprintf (vmchannel, sizeof vmchannel,
- "user,vlan=0,net=10.0.2.0/8,guestfwd=tcp:%s:%d-unix:%s,server,nowait",
- GUESTFWD_ADDR, GUESTFWD_PORT, unixsock);
+ snprintf (buf, sizeof buf,
+ "socket,id=guestfsvmc,path=%s,server,nowait", unixsock);
+
+ add_cmdline (g, "-chardev");
+ add_cmdline (g, buf);
+
+ snprintf (buf, sizeof buf,
+ "user,vlan=0,net=10.0.2.0/8,"
+ "guestfwd=tcp:%s:%d-chardev:guestfsvmc",
+ GUESTFWD_ADDR, GUESTFWD_PORT);
add_cmdline (g, "-net");
- add_cmdline (g, vmchannel);
+ add_cmdline (g, buf);
} else {
-#endif
/* Not guestfwd. HOPEFULLY this qemu uses the older -net channel
* syntax, or if not then we'll get a quick failure.
*/
- snprintf (vmchannel, sizeof vmchannel,
- "channel,%d:unix:%s,server,nowait",
- GUESTFWD_PORT, unixsock);
+ snprintf (buf, sizeof buf,
+ "channel,%d:unix:%s,server,nowait", GUESTFWD_PORT, unixsock);
add_cmdline (g, "-net");
- add_cmdline (g, vmchannel);
+ add_cmdline (g, buf);
add_cmdline (g, "-net");
add_cmdline (g, "user,vlan=0,net=10.0.2.0/8");
-#if 0
}
-#endif
add_cmdline (g, "-net");
add_cmdline (g, "nic,model=" NET_IF ",vlan=0");
--
1.6.2.5
More information about the Libguestfs
mailing list