Richard W.M. Jones
2009-Sep-21 15:04 UTC
[Libguestfs] [PATCH 00/10] Remove the need for vmchannel
This set of 10 patches removes the need for any vmchannel implementation, although we can still choose to use vmchannel if we want. In this so-called "null vmchannel" configuration, the appliance connects directly to a port on the library. The exact method is described in patch 9/10. This method still requires SLIRP (user mode networking) so it is not a panacea, because recent versions of qemu allow SLIRP to be removed. We therefore need to continue along the path of exploring alternate vmchannel implementations. [PATCH 01/10] Rearrange qemu command line order (no functional change). [PATCH 02/10] Combine temporary buffers. - General code cleanups. [PATCH 03/10] Remove guestfs_wait_ready (turn it into a no-op). - guestfs_wait_ready is no longer helpful. Since vmchannel and null vmchannel are fundamentally different, we need to remove the split between launch and wait_ready and make launch into a single large function that can handle both cases. [PATCH 04/10] Remove unnecessary extra space from qemu command line. [PATCH 05/10] Make GUESTFWD_PORT into a string. [PATCH 06/10] Rearrange and tidy up code in guestfsd.c - More code cleanups. [PATCH 07/10] Flexible guestfs_vmchannel parameter for future appliances. - Add guestfs_vmchannel=(tcp:<ip>:<port>|...) parameter to the appliance, and make it backwards compatible with older library version. [PATCH 08/10] configure.ac: Check for <netinet/in.h> and <arpa/inet.h> [PATCH 09/10] Implement "null vmchannel" - no vmchannel needed! [PATCH 10/10] Update documentation of qemu / vmchannel. - The implementation of null vmchannel.
Richard W.M. Jones
2009-Sep-21 15:04 UTC
[Libguestfs] [PATCH 01/10] Rearrange qemu command line order (no functional change).
From: Richard Jones <rjones at trick.home.annexia.org> --- src/guestfs.c | 59 +++++++++++++++++++++++++++++---------------------------- 1 files changed, 30 insertions(+), 29 deletions(-) diff --git a/src/guestfs.c b/src/guestfs.c index c735c1c..bc4fe4e 100644 --- a/src/guestfs.c +++ b/src/guestfs.c @@ -992,39 +992,22 @@ guestfs__launch (guestfs_h *g) */ g->cmdline[0] = g->qemu; -#define LINUX_CMDLINE \ - "panic=1 " /* force kernel to panic if daemon exits */ \ - "console=ttyS0 " /* serial console */ \ - "udevtimeout=300 " /* good for very slow systems (RHBZ#480319) */ \ - "noapic " /* workaround for RHBZ#502058 - ok if not SMP */ \ - "acpi=off " /* we don't need ACPI, turn it off */ \ - "cgroup_disable=memory " /* saves us about 5 MB of RAM */ - - /* Linux kernel command line. */ - snprintf (append, sizeof append, - LINUX_CMDLINE - "%s" /* (selinux) */ - "%s" /* (verbose) */ - "%s", /* (append) */ - g->selinux ? "selinux=1 enforcing=0 " : "selinux=0 ", - g->verbose ? "guestfs_verbose=1 " : " ", - g->append ? g->append : ""); - snprintf (memsize_str, sizeof memsize_str, "%d", g->memsize); add_cmdline (g, "-m"); add_cmdline (g, memsize_str); add_cmdline (g, "-no-reboot"); /* Force exit instead of reboot on panic */ - add_cmdline (g, "-kernel"); - add_cmdline (g, (char *) kernel); - add_cmdline (g, "-initrd"); - add_cmdline (g, (char *) initrd); - add_cmdline (g, "-append"); - add_cmdline (g, append); add_cmdline (g, "-nographic"); add_cmdline (g, "-serial"); add_cmdline (g, "stdio"); + /* These options recommended by KVM developers to improve reliability. */ + if (qemu_supports (g, "-no-hpet")) + add_cmdline (g, "-no-hpet"); + + if (qemu_supports (g, "-rtc-td-hack")) + add_cmdline (g, "-rtc-td-hack"); + if (qemu_supports (g, "-chardev") && qemu_supports (g, "guestfwd")) { /* New-style -net user,guestfwd=... syntax for guestfwd. See: * @@ -1065,12 +1048,30 @@ guestfs__launch (guestfs_h *g) add_cmdline (g, "-net"); add_cmdline (g, "nic,model=" NET_IF ",vlan=0"); - /* These options recommended by KVM developers to improve reliability. */ - if (qemu_supports (g, "-no-hpet")) - add_cmdline (g, "-no-hpet"); +#define LINUX_CMDLINE \ + "panic=1 " /* force kernel to panic if daemon exits */ \ + "console=ttyS0 " /* serial console */ \ + "udevtimeout=300 " /* good for very slow systems (RHBZ#480319) */ \ + "noapic " /* workaround for RHBZ#502058 - ok if not SMP */ \ + "acpi=off " /* we don't need ACPI, turn it off */ \ + "cgroup_disable=memory " /* saves us about 5 MB of RAM */ - if (qemu_supports (g, "-rtc-td-hack")) - add_cmdline (g, "-rtc-td-hack"); + /* Linux kernel command line. */ + snprintf (append, sizeof append, + LINUX_CMDLINE + "%s" /* (selinux) */ + "%s" /* (verbose) */ + "%s", /* (append) */ + g->selinux ? "selinux=1 enforcing=0 " : "selinux=0 ", + g->verbose ? "guestfs_verbose=1 " : " ", + g->append ? g->append : ""); + + add_cmdline (g, "-kernel"); + add_cmdline (g, (char *) kernel); + add_cmdline (g, "-initrd"); + add_cmdline (g, (char *) initrd); + add_cmdline (g, "-append"); + add_cmdline (g, append); /* Finish off the command line. */ incr_cmdline_size (g); -- 1.6.2.5
Richard W.M. Jones
2009-Sep-21 15:04 UTC
[Libguestfs] [PATCH 02/10] Combine temporary buffers.
From: Richard Jones <rjones at trick.home.annexia.org> buf[], append[] and memsize_str[] were all temporary buffers used in non-overlapping code. Combine them to use a single buffer (buf[]). --- src/guestfs.c | 12 +++++------- 1 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/guestfs.c b/src/guestfs.c index bc4fe4e..17d812a 100644 --- a/src/guestfs.c +++ b/src/guestfs.c @@ -984,18 +984,16 @@ guestfs__launch (guestfs_h *g) if (r == 0) { /* Child (qemu). */ char buf[256]; - char append[256]; - char memsize_str[256]; /* Set up the full command line. Do this in the subprocess so we * don't need to worry about cleaning up. */ g->cmdline[0] = g->qemu; - snprintf (memsize_str, sizeof memsize_str, "%d", g->memsize); - + snprintf (buf, sizeof buf, "%d", g->memsize); add_cmdline (g, "-m"); - add_cmdline (g, memsize_str); + add_cmdline (g, buf); + add_cmdline (g, "-no-reboot"); /* Force exit instead of reboot on panic */ add_cmdline (g, "-nographic"); add_cmdline (g, "-serial"); @@ -1057,7 +1055,7 @@ guestfs__launch (guestfs_h *g) "cgroup_disable=memory " /* saves us about 5 MB of RAM */ /* Linux kernel command line. */ - snprintf (append, sizeof append, + snprintf (buf, sizeof buf, LINUX_CMDLINE "%s" /* (selinux) */ "%s" /* (verbose) */ @@ -1071,7 +1069,7 @@ guestfs__launch (guestfs_h *g) add_cmdline (g, "-initrd"); add_cmdline (g, (char *) initrd); add_cmdline (g, "-append"); - add_cmdline (g, append); + add_cmdline (g, buf); /* Finish off the command line. */ incr_cmdline_size (g); -- 1.6.2.5