summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rwxr-xr-xsrc/generator.ml19
-rw-r--r--src/guestfs-internal.h1
-rw-r--r--src/guestfs.c13
-rw-r--r--src/guestfs.pod5
-rw-r--r--src/launch.c8
5 files changed, 46 insertions, 0 deletions
diff --git a/src/generator.ml b/src/generator.ml
index 233f8bd2..00caa6a4 100755
--- a/src/generator.ml
+++ b/src/generator.ml
@@ -1289,6 +1289,25 @@ for a filesystem to be shared between operating systems.
Please read L<guestfs(3)/INSPECTION> for more details.
See also C<guestfs_inspect_get_mountpoints>.");
+ ("set_network", (RErr, [Bool "network"]), -1, [FishAlias "network"],
+ [],
+ "set enable network flag",
+ "\
+If C<network> is true, then the network is enabled in the
+libguestfs appliance. The default is false.
+
+This affects whether commands are able to access the network
+(see L<guestfs(3)/RUNNING COMMANDS>).
+
+You must call this before calling C<guestfs_launch>, otherwise
+it has no effect.");
+
+ ("get_network", (RBool "network", []), -1, [],
+ [],
+ "get enable network flag",
+ "\
+This returns the enable network flag.");
+
]
(* daemon_functions are any functions which cause some action
diff --git a/src/guestfs-internal.h b/src/guestfs-internal.h
index b534b6a6..e37c9c26 100644
--- a/src/guestfs-internal.h
+++ b/src/guestfs-internal.h
@@ -98,6 +98,7 @@ struct guestfs_h
int autosync;
int direct;
int recovery_proc;
+ int enable_network;
char *path; /* Path to kernel, initrd. */
char *qemu; /* Qemu binary. */
diff --git a/src/guestfs.c b/src/guestfs.c
index 74de38cc..eaacd395 100644
--- a/src/guestfs.c
+++ b/src/guestfs.c
@@ -601,6 +601,19 @@ guestfs__get_recovery_proc (guestfs_h *g)
return g->recovery_proc;
}
+int
+guestfs__set_network (guestfs_h *g, int v)
+{
+ g->enable_network = !!v;
+ return 0;
+}
+
+int
+guestfs__get_network (guestfs_h *g)
+{
+ return g->enable_network;
+}
+
void
guestfs_set_log_message_callback (guestfs_h *g,
guestfs_log_message_cb cb, void *opaque)
diff --git a/src/guestfs.pod b/src/guestfs.pod
index 4dafb074..590c768d 100644
--- a/src/guestfs.pod
+++ b/src/guestfs.pod
@@ -358,6 +358,11 @@ The command will be running in limited memory.
=item *
+The network may not be available unless you enable it
+(see L</guestfs_set_network>).
+
+=item *
+
Only supports Linux guests (not Windows, BSD, etc).
=item *
diff --git a/src/launch.c b/src/launch.c
index 1e1ea8ec..9262cc5c 100644
--- a/src/launch.c
+++ b/src/launch.c
@@ -410,6 +410,14 @@ guestfs__launch (guestfs_h *g)
add_cmdline (g, "-device");
add_cmdline (g, "virtserialport,chardev=channel0,name=org.libguestfs.channel.0");
+ /* Enable user networking. */
+ if (g->enable_network) {
+ add_cmdline (g, "-netdev");
+ add_cmdline (g, "user,id=usernet");
+ add_cmdline (g, "-device");
+ add_cmdline (g, NET_IF ",netdev=usernet");
+ }
+
#define LINUX_CMDLINE \
"panic=1 " /* force kernel to panic if daemon exits */ \
"console=ttyS0 " /* serial console */ \