diff options
| author | Richard Jones <rjones@redhat.com> | 2010-05-04 15:06:09 +0100 |
|---|---|---|
| committer | Richard Jones <rjones@redhat.com> | 2010-05-04 15:26:20 +0100 |
| commit | 8a9f2ca65521d093ac14307aca4370d9497ac840 (patch) | |
| tree | ff1e57378920875ac8a00e4a2ea2a7fd89031985 /src | |
| parent | 7d005a9ae820cff3274b456d99b0031d7277a61a (diff) | |
| download | libguestfs-8a9f2ca65521d093ac14307aca4370d9497ac840.tar.gz libguestfs-8a9f2ca65521d093ac14307aca4370d9497ac840.tar.xz libguestfs-8a9f2ca65521d093ac14307aca4370d9497ac840.zip | |
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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/guestfs.c | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/src/guestfs.c b/src/guestfs.c index fe08cb56..d68f12b9 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; } |
