Richard W.M. Jones
2010-May-04 15:15 UTC
[Libguestfs] [PATCH 0/2] Use link-local addresses when communicating between appliance and host (RHBZ#588763)
Couple of notes: (1) You may need to 'make clean' after applying this patch. There is some missing dep so it seems the appliance isn't fully rebuilt. (2) [Comment mainly directed to Matt] This is not a candidate to be automatically added to the stable 1.2 branch. It's far too large of a change for a stable release. Since this change may be required for V2V, please clone #588763 for any branches where you need the fix. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming blog: http://rwmj.wordpress.com Fedora now supports 80 OCaml packages (the OPEN alternative to F#) http://cocan.org/getting_started_with_ocaml_on_red_hat_and_fedora
Richard W.M. Jones
2010-May-04 15:16 UTC
[Libguestfs] [PATCH 1/2] Change network configuration to use macros.
-- Richard Jones, Virtualization Group, Red Hat http://people.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 8a9f2ca65521d093ac14307aca4370d9497ac840 Mon Sep 17 00:00:00 2001From: Richard Jones <rjones at redhat.com> Date: Tue, 4 May 2010 15:06:09 +0100 Subject: [PATCH 1/2] Change network configuration to use macros. Change the network configuration so everything is set using some macros at the top of src/guestfs.c. Also, rename the macros used in the daemon so they are not the same. It was a very long time since these sets of macros had to match the ones defined in src/guestfs.c, despite what the comment said. Note that this commit should not change the semantics of the program at all. --- daemon/guestfsd.c | 13 +++++++++---- src/guestfs.c | 30 +++++++++++++++++++++++++----- 2 files changed, 34 insertions(+), 9 deletions(-) diff --git a/daemon/guestfsd.c b/daemon/guestfsd.c index 06ad702..03a975a 100644 --- a/daemon/guestfsd.c +++ b/daemon/guestfsd.c @@ -55,9 +55,14 @@ static char *read_cmdline (void); -/* Also in guestfs.c */ -#define GUESTFWD_ADDR "10.0.2.4" -#define GUESTFWD_PORT "6666" +/* This is the default address we connect to for very old libraries + * which didn't specify the address and port number explicitly on the + * kernel command line. It's now recommended to always specify the + * address and port number on the command line, so this will not be + * used any more. + */ +#define OLD_GUESTFWD_ADDR "10.0.2.4" +#define OLD_GUESTFWD_PORT "6666" /* This is only a hint. If not defined, ignore it. */ #ifndef AI_ADDRCONFIG @@ -285,7 +290,7 @@ main (int argc, char *argv[]) /* Default vmchannel. */ if (vmchannel == NULL) { - vmchannel = strdup ("tcp:" GUESTFWD_ADDR ":" GUESTFWD_PORT); + vmchannel = strdup ("tcp:" OLD_GUESTFWD_ADDR ":" OLD_GUESTFWD_PORT); if (!vmchannel) { perror ("strdup"); exit (EXIT_FAILURE); diff --git a/src/guestfs.c b/src/guestfs.c index fe08cb5..d68f12b 100644 --- a/src/guestfs.c +++ b/src/guestfs.c @@ -110,7 +110,26 @@ static int qemu_supports (guestfs_h *g, const char *option); #define xdr_uint32_t xdr_u_int32_t #endif -/* Also in guestfsd.c */ +/* Network configuration of the appliance. Note these addresses are + * only meaningful within the context of the running appliance. QEMU + * translates network connections to these magic addresses into + * userspace calls on the host (eg. connect(2)). qemu-doc has a nice + * diagram which is also useful to refer to. + * + * NETWORK: The network. + * + * ROUTER: The address of the "host", ie. this library. + * + * [Note: If you change NETWORK and ROUTER then you also have to + * change the network configuration in appliance/init]. + * + * GUESTFWD_ADDR, GUESTFWD_PORT: The guestfwd feature of qemu + * magically connects this pseudo-address to the guestfwd channel. In + * typical Linux configurations of libguestfs, guestfwd is not + * actually used any more. + */ +#define NETWORK "10.0.2.0/8" +#define ROUTER "10.0.2.2" #define GUESTFWD_ADDR "10.0.2.4" #define GUESTFWD_PORT "6666" @@ -1189,10 +1208,11 @@ guestfs__launch (guestfs_h *g) */ if (null_vmchannel_sock) { add_cmdline (g, "-net"); - add_cmdline (g, "user,vlan=0,net=10.0.2.0/8"); + add_cmdline (g, "user,vlan=0,net=" NETWORK); snprintf (buf, sizeof buf, - "guestfs_vmchannel=tcp:10.0.2.2:%d", null_vmchannel_sock); + "guestfs_vmchannel=tcp:" ROUTER ":%d", + null_vmchannel_sock); vmchannel = strdup (buf); } @@ -1215,7 +1235,7 @@ guestfs__launch (guestfs_h *g) add_cmdline (g, buf); snprintf (buf, sizeof buf, - "user,vlan=0,net=10.0.2.0/8," + "user,vlan=0,net=" NETWORK "," "guestfwd=tcp:" GUESTFWD_ADDR ":" GUESTFWD_PORT "-chardev:guestfsvmc"); @@ -1235,7 +1255,7 @@ guestfs__launch (guestfs_h *g) add_cmdline (g, "-net"); add_cmdline (g, buf); add_cmdline (g, "-net"); - add_cmdline (g, "user,vlan=0,net=10.0.2.0/8"); + add_cmdline (g, "user,vlan=0,net=" NETWORK); vmchannel = "guestfs_vmchannel=tcp:" GUESTFWD_ADDR ":" GUESTFWD_PORT; } -- 1.6.6.1
Richard W.M. Jones
2010-May-04 15:16 UTC
[Libguestfs] [PATCH 2/2] Use link-local addresses between appliance and host (RHBZ#588763).
-- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones virt-df lists disk usage of guests without needing to install any software inside the virtual machine. Supports Linux and Windows. http://et.redhat.com/~rjones/virt-df/ -------------- next part -------------->From e196ba2788886987f4b6d3ad4d86e31d1259e2a8 Mon Sep 17 00:00:00 2001From: Richard Jones <rjones at redhat.com> Date: Tue, 4 May 2010 16:06:58 +0100 Subject: [PATCH 2/2] Use link-local addresses between appliance and host (RHBZ#588763). --- appliance/init | 4 ++-- src/guestfs.c | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/appliance/init b/appliance/init index 15dab61..98538de 100755 --- a/appliance/init +++ b/appliance/init @@ -52,8 +52,8 @@ hwclock -u -s # Set up the network. ifconfig lo 127.0.0.1 -ifconfig eth0 10.0.2.10 -route add default gw 10.0.2.2 +ifconfig eth0 169.254.2.10 +route add default gw 169.254.2.2 # Scan for LVM. modprobe dm_mod ||: diff --git a/src/guestfs.c b/src/guestfs.c index d68f12b..958bf19 100644 --- a/src/guestfs.c +++ b/src/guestfs.c @@ -128,9 +128,9 @@ static int qemu_supports (guestfs_h *g, const char *option); * typical Linux configurations of libguestfs, guestfwd is not * actually used any more. */ -#define NETWORK "10.0.2.0/8" -#define ROUTER "10.0.2.2" -#define GUESTFWD_ADDR "10.0.2.4" +#define NETWORK "169.254.2.0/16" +#define ROUTER "169.254.2.2" +#define GUESTFWD_ADDR "169.254.2.4" #define GUESTFWD_PORT "6666" /* GuestFS handle and connection. */ -- 1.6.6.1
Possibly Parallel Threads
- [PATCH] Enable new-style -chardev ... guestfwd command line
- [PATCH] Remove explicit guestfs=10.0.2.4:6666 kernel command line parameter.
- [PATCH 0/3] RFC: Allow use of external QEMU process with libguestfs
- [PATCH v2 0/4] launch: libvirt: Use qemu-bridge-helper to implement a full network (RHBZ#1148012).
- [PATCH v3 0/4] launch: libvirt: Use qemu-bridge-helper to implement a