From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sasha Levin Subject: [PATCH] kvm tools: Improve init within a custom filesystem Date: Wed, 24 Aug 2011 19:19:32 +0300 Message-ID: <1314202772-16252-1-git-send-email-levinsasha928@gmail.com> Cc: kvm@vger.kernel.org, mingo@elte.hu, asias.hejun@gmail.com, gorcunov@gmail.com, Sasha Levin To: penberg@kernel.org Return-path: Received: from mail-ww0-f44.google.com ([74.125.82.44]:36909 "EHLO mail-ww0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751360Ab1HXQTo (ORCPT ); Wed, 24 Aug 2011 12:19:44 -0400 Received: by wwf5 with SMTP id 5so1396183wwf.1 for ; Wed, 24 Aug 2011 09:19:43 -0700 (PDT) Sender: kvm-owner@vger.kernel.org List-ID: 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 --- 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