diff --git a/daemon/debug.c b/daemon/debug.c index dca6edb8d..9fe57fc9e 100644 --- a/daemon/debug.c +++ b/daemon/debug.c @@ -751,6 +751,14 @@ do_debug_upload (const char *filename, int mode) return 0; } +/* This function is identical to debug_upload. */ +/* Has one FileIn parameter. */ +int +do_internal_upload (const char *filename, int mode) +{ + return do_debug_upload (filename, mode); +} + /* Internal function used only when testing * https://bugzilla.redhat.com/show_bug.cgi?id=914931 */ diff --git a/generator/actions.ml b/generator/actions.ml index 60fd658bc..43a1e2a17 100644 --- a/generator/actions.ml +++ b/generator/actions.ml @@ -11607,6 +11607,16 @@ The label (name of the last element) of the Augeas path expression C is returned. C must match exactly one node, else this function returns an error." }; + { defaults with + name = "internal_upload"; + style = RErr, [FileIn "filename"; String "tmpname"; Int "mode"], []; + proc_nr = Some 413; + visibility = VInternal; + cancellable = true; + shortdesc = "upload a file to the appliance (internal use only)"; + longdesc = "\ +This function is used internally when setting up the appliance." }; + ] (* Non-API meta-commands available only in guestfish. diff --git a/src/MAX_PROC_NR b/src/MAX_PROC_NR index ddabef86a..36352541c 100644 --- a/src/MAX_PROC_NR +++ b/src/MAX_PROC_NR @@ -1 +1 @@ -412 +413 diff --git a/src/launch.c b/src/launch.c index 48db1bf26..ab19a483a 100644 --- a/src/launch.c +++ b/src/launch.c @@ -83,7 +83,17 @@ guestfs__launch (guestfs_h *g) } /* Launch the appliance. */ - return g->backend_ops->launch (g, g->backend_data, g->backend_arg); + if (g->backend_ops->launch (g, g->backend_data, g->backend_arg) == -1) + return -1; + + /* If network is enabled, upload /etc/resolv.conf from the host so + * the guest will know how to reach the nameservers. + */ + if (g->enable_network && access ("/etc/resolv.conf", F_OK) == 0) { + guestfs_internal_upload (g, "/etc/resolv.conf", "/etc/resolv.conf", 0644); + } + + return 0; } /* launch (of the appliance) generates approximate progress