Since kernel IP autoconfiguration doesn't set up /etc/resolv.conf, we'll use the one located within the host, since this was anyway what we simulated within the DHCP offer packets. Signed-off-by: Sasha Levin <levinsasha928@xxxxxxxxx> --- tools/kvm/builtin-run.c | 2 ++ tools/kvm/builtin-setup.c | 9 +++++++++ tools/kvm/include/kvm/builtin-setup.h | 1 + 3 files changed, 12 insertions(+), 0 deletions(-) diff --git a/tools/kvm/builtin-run.c b/tools/kvm/builtin-run.c index 5dafb15..9d61088 100644 --- a/tools/kvm/builtin-run.c +++ b/tools/kvm/builtin-run.c @@ -129,6 +129,7 @@ static int img_name_parser(const struct option *opt, const char *arg, int unset) die("Unable to initialize virtio 9p"); if (virtio_9p__register(kvm, "/", "hostfs") < 0) die("Unable to initialize virtio 9p"); + kvm_setup_resolv(arg); using_rootfs = custom_rootfs = 1; return 0; } @@ -750,6 +751,7 @@ int kvm_cmd_run(int argc, const char **argv, const char *prefix) char tmp[PATH_MAX]; kvm_setup_create_new("default"); + kvm_setup_resolv("default"); snprintf(tmp, PATH_MAX, "%s%s%s", HOME_DIR, KVM_PID_FILE_PATH, "default"); if (virtio_9p__register(kvm, tmp, "/dev/root") < 0) diff --git a/tools/kvm/builtin-setup.c b/tools/kvm/builtin-setup.c index 6b8eb5b..3e569e7 100644 --- a/tools/kvm/builtin-setup.c +++ b/tools/kvm/builtin-setup.c @@ -168,6 +168,15 @@ static void make_guestfs_dir(const char *guestfs_name, const char *dir) make_dir(name); } +void kvm_setup_resolv(const char *guestfs_name) +{ + char path[PATH_MAX]; + + snprintf(path, PATH_MAX, "%s%s%s/etc/resolv.conf", HOME_DIR, KVM_PID_FILE_PATH, guestfs_name); + + copy_file("/etc/resolv.conf", path); +} + static int do_setup(const char *guestfs_name) { unsigned int i; diff --git a/tools/kvm/include/kvm/builtin-setup.h b/tools/kvm/include/kvm/builtin-setup.h index 6e183a1..f70ae78 100644 --- a/tools/kvm/include/kvm/builtin-setup.h +++ b/tools/kvm/include/kvm/builtin-setup.h @@ -4,5 +4,6 @@ int kvm_cmd_setup(int argc, const char **argv, const char *prefix); void kvm_setup_help(void); int kvm_setup_create_new(const char *guestfs_name); +void kvm_setup_resolv(const char *guestfs_name); #endif -- 1.7.6.1 -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html