[PATCH] kvm tools: Improve init within a custom filesystem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This patch adds the following improvements:

 * Automatically start dhcpcd. Since we provide usermode netowrking
we should make it fully transparent to the user.

 * Mount more kernel filesystems such as debugfs and shm.

Signed-off-by: Sasha Levin <levinsasha928@xxxxxxxxx>
---
 tools/kvm/builtin-setup.c |    4 ++++
 tools/kvm/guest/init.c    |    7 +++++++
 2 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/tools/kvm/builtin-setup.c b/tools/kvm/builtin-setup.c
index 3c6ad48..347398d 100644
--- a/tools/kvm/builtin-setup.c
+++ b/tools/kvm/builtin-setup.c
@@ -100,12 +100,16 @@ error_close_in:
 
 static const char *guestfs_dirs[] = {
 	"/dev",
+	"/dev/pts",
+	"/dev/shm",
 	"/etc",
 	"/home",
 	"/host",
 	"/proc",
 	"/root",
 	"/sys",
+	"/sys/kernel",
+	"/sys/kernel/debug",
 	"/var",
 	"/var/lib",
 	"/virt",
diff --git a/tools/kvm/guest/init.c b/tools/kvm/guest/init.c
index 837acfb..caa671d 100644
--- a/tools/kvm/guest/init.c
+++ b/tools/kvm/guest/init.c
@@ -22,6 +22,9 @@ static void do_mounts(void)
 	mount("", "/sys", "sysfs", 0, NULL);
 	mount("proc", "/proc", "proc", 0, NULL);
 	mount("devtmpfs", "/dev", "devtmpfs", 0, NULL);
+	mount("debugfs", "/sys/kernel/debug", "debugfs", 0, NULL);
+	mount("shm", "/dev/shm", "tmpfs", 0, NULL);
+	mount("devpts", "/dev/pts", "devpts", 0, NULL);
 }
 
 int main(int argc, char *argv[])
@@ -30,6 +33,10 @@ int main(int argc, char *argv[])
 
 	do_mounts();
 
+	puts("Running dhcpcd...");
+
+	system("dhcpcd -z eth* -A");
+
 	puts("Starting '/bin/sh'...");
 
 	run_process("/bin/sh");
-- 
1.7.6

--
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


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux