]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
kvm tools: Use host's resolv.conf within the guest
authorSasha Levin <levinsasha928@gmail.com>
Wed, 14 Sep 2011 16:28:26 +0000 (19:28 +0300)
committerSasha Levin <levinsasha928@gmail.com>
Fri, 16 Sep 2011 08:53:06 +0000 (11:53 +0300)
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@gmail.com>
tools/kvm/builtin-run.c
tools/kvm/builtin-setup.c
tools/kvm/include/kvm/builtin-setup.h

index b5c63cab2e7b05da4434be634495dccd8adfc394..28dc95aef54c3644ae57d8fae77aba26dfa31846 100644 (file)
@@ -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;
        }
@@ -762,6 +763,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)
index 6b8eb5b13849d59cf451cefdbbece80498787d91..3e569e7b14a2c7ea389cb74f7833dd23aa493b3c 100644 (file)
@@ -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;
index 6e183a1761d7720f36de48d7c2fde9695f4d9fa0..f70ae78190223e9658a017168360ca133847e67f 100644 (file)
@@ -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