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
/* 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);
#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"
*/
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);
}
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");
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;
}