All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] kvm tools: Improve init within a custom filesystem
@ 2011-08-24 16:19 Sasha Levin
  2011-08-24 17:30 ` Avi Kivity
  0 siblings, 1 reply; 6+ messages in thread
From: Sasha Levin @ 2011-08-24 16:19 UTC (permalink / raw)
  To: penberg; +Cc: kvm, mingo, asias.hejun, gorcunov, Sasha Levin

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@gmail.com>
---
 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


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] kvm tools: Improve init within a custom filesystem
  2011-08-24 16:19 [PATCH] kvm tools: Improve init within a custom filesystem Sasha Levin
@ 2011-08-24 17:30 ` Avi Kivity
  2011-08-24 17:41   ` Sasha Levin
  0 siblings, 1 reply; 6+ messages in thread
From: Avi Kivity @ 2011-08-24 17:30 UTC (permalink / raw)
  To: Sasha Levin; +Cc: penberg, kvm, mingo, asias.hejun, gorcunov

On 08/24/2011 07:19 PM, Sasha Levin wrote:
> This patch adds the following improvements:
>
>   * Automatically start dhcpcd. Since we provide usermode netowrking
> we should make it fully transparent to the user.

On my hosts, I have dhclient instead of dhcpd.

>
> +	puts("Running dhcpcd...");
> +
> +	system("dhcpcd -z eth* -A");
> +
>   	puts("Starting '/bin/sh'...");
>

Better not  depend on interface names, instead get the interface names 
from the kernel.

-- 
I have a truly marvellous patch that fixes the bug which this
signature is too narrow to contain.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] kvm tools: Improve init within a custom filesystem
  2011-08-24 17:30 ` Avi Kivity
@ 2011-08-24 17:41   ` Sasha Levin
  2011-08-24 18:17     ` Pekka Enberg
  2011-08-24 18:51     ` Avi Kivity
  0 siblings, 2 replies; 6+ messages in thread
From: Sasha Levin @ 2011-08-24 17:41 UTC (permalink / raw)
  To: Avi Kivity; +Cc: penberg, kvm, mingo, asias.hejun, gorcunov

On Wed, 2011-08-24 at 20:30 +0300, Avi Kivity wrote:
> On 08/24/2011 07:19 PM, Sasha Levin wrote:
> > This patch adds the following improvements:
> >
> >   * Automatically start dhcpcd. Since we provide usermode netowrking
> > we should make it fully transparent to the user.
> 
> On my hosts, I have dhclient instead of dhcpd.
> 

I was wondering if we should bring our own tiny dhcp client instead of
assuming the host has one.

Would it be better than assuming the host has it and then trying to
figure out which one?

> >
> > +	puts("Running dhcpcd...");
> > +
> > +	system("dhcpcd -z eth* -A");
> > +
> >   	puts("Starting '/bin/sh'...");
> >
> 
> Better not  depend on interface names, instead get the interface names 
> from the kernel.
> 

Will do.

-- 

Sasha.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] kvm tools: Improve init within a custom filesystem
  2011-08-24 17:41   ` Sasha Levin
@ 2011-08-24 18:17     ` Pekka Enberg
  2011-08-24 18:51     ` Avi Kivity
  1 sibling, 0 replies; 6+ messages in thread
From: Pekka Enberg @ 2011-08-24 18:17 UTC (permalink / raw)
  To: Sasha Levin; +Cc: Avi Kivity, kvm, mingo, asias.hejun, gorcunov

On Wed, Aug 24, 2011 at 8:41 PM, Sasha Levin <levinsasha928@gmail.com> wrote:
>> On my hosts, I have dhclient instead of dhcpd.
>
> I was wondering if we should bring our own tiny dhcp client instead of
> assuming the host has one.
>
> Would it be better than assuming the host has it and then trying to
> figure out which one?

That'd be awesome if we can keep it small and clean.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] kvm tools: Improve init within a custom filesystem
  2011-08-24 17:41   ` Sasha Levin
  2011-08-24 18:17     ` Pekka Enberg
@ 2011-08-24 18:51     ` Avi Kivity
  2011-08-24 18:59       ` Pekka Enberg
  1 sibling, 1 reply; 6+ messages in thread
From: Avi Kivity @ 2011-08-24 18:51 UTC (permalink / raw)
  To: Sasha Levin; +Cc: penberg, kvm, mingo, asias.hejun, gorcunov

On 08/24/2011 08:41 PM, Sasha Levin wrote:
> On Wed, 2011-08-24 at 20:30 +0300, Avi Kivity wrote:
> >  On 08/24/2011 07:19 PM, Sasha Levin wrote:
> >  >  This patch adds the following improvements:
> >  >
> >  >    * Automatically start dhcpcd. Since we provide usermode netowrking
> >  >  we should make it fully transparent to the user.
> >
> >  On my hosts, I have dhclient instead of dhcpd.
> >
>
> I was wondering if we should bring our own tiny dhcp client instead of
> assuming the host has one.
>
> Would it be better than assuming the host has it and then trying to
> figure out which one?
>

You don't really need a dhcp client, since you already have a 
communication channel - the kernel command line.  Read the IP address 
and other info from there, and poke it into the interface.

There is also the ip= kernel parameter, but I don't know if it works 
with a modular network driver.

I suggest something like "kvmtool.nic.$macaddr=$ip/$netmask 
kvmtool.defaultroute=$gateway" - this is interface name agnostic.

-- 
I have a truly marvellous patch that fixes the bug which this
signature is too narrow to contain.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] kvm tools: Improve init within a custom filesystem
  2011-08-24 18:51     ` Avi Kivity
@ 2011-08-24 18:59       ` Pekka Enberg
  0 siblings, 0 replies; 6+ messages in thread
From: Pekka Enberg @ 2011-08-24 18:59 UTC (permalink / raw)
  To: Avi Kivity; +Cc: Sasha Levin, kvm, mingo, asias.hejun, gorcunov

On Wed, Aug 24, 2011 at 9:51 PM, Avi Kivity <avi@redhat.com> wrote:
> On 08/24/2011 08:41 PM, Sasha Levin wrote:
>>
>> On Wed, 2011-08-24 at 20:30 +0300, Avi Kivity wrote:
>> >  On 08/24/2011 07:19 PM, Sasha Levin wrote:
>> >  >  This patch adds the following improvements:
>> >  >
>> >  >    * Automatically start dhcpcd. Since we provide usermode netowrking
>> >  >  we should make it fully transparent to the user.
>> >
>> >  On my hosts, I have dhclient instead of dhcpd.
>> >
>>
>> I was wondering if we should bring our own tiny dhcp client instead of
>> assuming the host has one.
>>
>> Would it be better than assuming the host has it and then trying to
>> figure out which one?
>>
>
> You don't really need a dhcp client, since you already have a communication
> channel - the kernel command line.  Read the IP address and other info from
> there, and poke it into the interface.
>
> There is also the ip= kernel parameter, but I don't know if it works with a
> modular network driver.
>
> I suggest something like "kvmtool.nic.$macaddr=$ip/$netmask
> kvmtool.defaultroute=$gateway" - this is interface name agnostic.

We had "ip=dhcp" enabled for a while:

https://github.com/penberg/linux-kvm/commit/f0aec23a91368e916a53e6072f2173bb481b1544

Unfortunately the option makes nfsroot override the 9p rootfs. I guess
we could just fix that.

                         Pekka

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-08-24 18:59 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-24 16:19 [PATCH] kvm tools: Improve init within a custom filesystem Sasha Levin
2011-08-24 17:30 ` Avi Kivity
2011-08-24 17:41   ` Sasha Levin
2011-08-24 18:17     ` Pekka Enberg
2011-08-24 18:51     ` Avi Kivity
2011-08-24 18:59       ` Pekka Enberg

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.