* [PATCH] kvm tools: Boot to host /bin/sh via 9p by default
@ 2011-08-09 15:33 Pekka Enberg
2011-08-09 15:36 ` Pekka Enberg
2011-08-09 16:59 ` Avi Kivity
0 siblings, 2 replies; 8+ messages in thread
From: Pekka Enberg @ 2011-08-09 15:33 UTC (permalink / raw)
To: kvm
Cc: Pekka Enberg, Linus Torvalds, Asias He, Cyrill Gorcunov,
Ingo Molnar, Prasad Joshi, Sasha Levin
This patch updates 'kvm run' to boot to host filesystem via 9p '/bin/sh' by
default:
$ ./kvm run
# kvm run -k ../../arch/x86/boot/bzImage -m 320 -c 2 --name guest-3462
[ 0.000000] Linux version 3.1.0-rc1+ (penberg@tiger) (gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5) ) #7 SMP PREEMPT Tue Aug 9 16:39:20 EEST 2011
[ 0.000000] Command line: notsc noapic noacpi pci=conf1 reboot=k panic=1 console=ttyS0 earlyprintk=serial init=/bin/sh root=/dev/vda rw root=/dev/root rootflags=rw,trans=virtio,version=9p2000.u rootfstype=9p
[snip]
[ 1.803261] VFS: Mounted root (9p filesystem) on device 0:13.
[ 1.805153] devtmpfs: mounted
[ 1.808353] Freeing unused kernel memory: 924k freed
[ 1.810592] Write protecting the kernel read-only data: 12288k
[ 1.816268] Freeing unused kernel memory: 632k freed
[ 1.826030] Freeing unused kernel memory: 1448k freed
sh: cannot set terminal process group (-1): Inappropriate ioctl for device
sh: no job control in this shell
sh-4.1#
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Asias He <asias.hejun@gmail.com>
Cc: Cyrill Gorcunov <gorcunov@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Prasad Joshi <prasadjoshi124@gmail.com>
Cc: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
---
tools/kvm/builtin-run.c | 57 +++++-----------------------------------------
1 files changed, 7 insertions(+), 50 deletions(-)
diff --git a/tools/kvm/builtin-run.c b/tools/kvm/builtin-run.c
index fa51850..fa5de27 100644
--- a/tools/kvm/builtin-run.c
+++ b/tools/kvm/builtin-run.c
@@ -447,46 +447,6 @@ static const char *find_vmlinux(void)
return NULL;
}
-static int root_device(char *dev, long *part)
-{
- struct stat st;
-
- if (stat("/", &st) < 0)
- return -1;
-
- *part = minor(st.st_dev);
-
- sprintf(dev, "/dev/block/%u:0", major(st.st_dev));
- if (access(dev, R_OK) < 0)
- return -1;
-
- return 0;
-}
-
-static char *host_image(char *cmd_line, size_t size)
-{
- char *t;
- char device[PATH_MAX];
- long part = 0;
-
- t = malloc(PATH_MAX);
- if (!t)
- return NULL;
-
- /* check for the root file system */
- if (root_device(device, &part) < 0) {
- free(t);
- return NULL;
- }
- strncpy(t, device, PATH_MAX);
- if (!strstr(cmd_line, "root=")) {
- char tmp[PATH_MAX];
- snprintf(tmp, sizeof(tmp), "root=/dev/vda%ld rw ", part);
- strlcat(cmd_line, tmp, size);
- }
- return t;
-}
-
void kvm_run_help(void)
{
usage_with_options(run_usage, options);
@@ -500,7 +460,6 @@ int kvm_cmd_run(int argc, const char **argv, const char *prefix)
unsigned int nr_online_cpus;
int exit_code = 0;
int max_cpus, recommended_cpus;
- char *hi;
int i;
void *ret;
@@ -635,14 +594,14 @@ int kvm_cmd_run(int argc, const char **argv, const char *prefix)
if (kernel_cmdline)
strlcat(real_cmdline, kernel_cmdline, sizeof(real_cmdline));
- hi = NULL;
if (!using_rootfs && !image_filename[0]) {
- hi = host_image(real_cmdline, sizeof(real_cmdline));
- if (hi) {
- image_filename[0] = hi;
- readonly_image[0] = true;
- image_count++;
- }
+ if (virtio_9p__init(kvm, "/", "/dev/root") < 0)
+ die("Unable to initialize virtio 9p");
+
+ using_rootfs = 1;
+
+ if (!strstr(real_cmdline, "init="))
+ strlcat(real_cmdline, " init=/bin/sh ", sizeof(real_cmdline));
}
if (!strstr(real_cmdline, "root="))
@@ -660,8 +619,6 @@ int kvm_cmd_run(int argc, const char **argv, const char *prefix)
virtio_blk__init_all(kvm);
}
- free(hi);
-
printf(" # kvm run -k %s -m %Lu -c %d --name %s\n", kernel_filename, ram_size / 1024 / 1024, nrcpus, guest_name);
if (!kvm__load_kernel(kvm, kernel_filename, initrd_filename,
--
1.7.0.4
^ permalink raw reply related [flat|nested] 8+ messages in thread* Re: [PATCH] kvm tools: Boot to host /bin/sh via 9p by default
2011-08-09 15:33 [PATCH] kvm tools: Boot to host /bin/sh via 9p by default Pekka Enberg
@ 2011-08-09 15:36 ` Pekka Enberg
2011-08-09 15:37 ` Ingo Molnar
2011-08-09 16:59 ` Avi Kivity
1 sibling, 1 reply; 8+ messages in thread
From: Pekka Enberg @ 2011-08-09 15:36 UTC (permalink / raw)
To: kvm
Cc: Pekka Enberg, Linus Torvalds, Asias He, Cyrill Gorcunov,
Ingo Molnar, Prasad Joshi, Sasha Levin
On Tue, Aug 9, 2011 at 6:33 PM, Pekka Enberg <penberg@kernel.org> wrote:
> This patch updates 'kvm run' to boot to host filesystem via 9p '/bin/sh' by
> default:
Ingo, I think you're the only one that relied on the old behavior. Are
you OK with this new default?
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] kvm tools: Boot to host /bin/sh via 9p by default
2011-08-09 15:36 ` Pekka Enberg
@ 2011-08-09 15:37 ` Ingo Molnar
0 siblings, 0 replies; 8+ messages in thread
From: Ingo Molnar @ 2011-08-09 15:37 UTC (permalink / raw)
To: Pekka Enberg
Cc: kvm, Linus Torvalds, Asias He, Cyrill Gorcunov, Prasad Joshi,
Sasha Levin
* Pekka Enberg <penberg@kernel.org> wrote:
> On Tue, Aug 9, 2011 at 6:33 PM, Pekka Enberg <penberg@kernel.org> wrote:
>
> > This patch updates 'kvm run' to boot to host filesystem via 9p
> > '/bin/sh' by default:
>
> Ingo, I think you're the only one that relied on the old behavior.
> Are you OK with this new default?
It's ok i think - will be some time until i can try it out but it
looks promising ...
Thanks,
Ingo
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] kvm tools: Boot to host /bin/sh via 9p by default
2011-08-09 15:33 [PATCH] kvm tools: Boot to host /bin/sh via 9p by default Pekka Enberg
2011-08-09 15:36 ` Pekka Enberg
@ 2011-08-09 16:59 ` Avi Kivity
2011-08-09 17:33 ` Pekka Enberg
2011-08-09 20:06 ` Sasha Levin
1 sibling, 2 replies; 8+ messages in thread
From: Avi Kivity @ 2011-08-09 16:59 UTC (permalink / raw)
To: Pekka Enberg
Cc: kvm, Linus Torvalds, Asias He, Cyrill Gorcunov, Ingo Molnar,
Prasad Joshi, Sasha Levin
On 08/09/2011 06:33 PM, Pekka Enberg wrote:
> This patch updates 'kvm run' to boot to host filesystem via 9p '/bin/sh' by
> default:
>
> $ ./kvm run
> # kvm run -k ../../arch/x86/boot/bzImage -m 320 -c 2 --name guest-3462
> [ 0.000000] Linux version 3.1.0-rc1+ (penberg@tiger) (gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5) ) #7 SMP PREEMPT Tue Aug 9 16:39:20 EEST 2011
> [ 0.000000] Command line: notsc noapic noacpi pci=conf1 reboot=k panic=1 console=ttyS0 earlyprintk=serial init=/bin/sh root=/dev/vda rw root=/dev/root rootflags=rw,trans=virtio,version=9p2000.u rootfstype=9p
>
> [snip]
>
> [ 1.803261] VFS: Mounted root (9p filesystem) on device 0:13.
> [ 1.805153] devtmpfs: mounted
> [ 1.808353] Freeing unused kernel memory: 924k freed
> [ 1.810592] Write protecting the kernel read-only data: 12288k
> [ 1.816268] Freeing unused kernel memory: 632k freed
> [ 1.826030] Freeing unused kernel memory: 1448k freed
> sh: cannot set terminal process group (-1): Inappropriate ioctl for device
> sh: no job control in this shell
> sh-4.1#
>
Most kernels won't have 9p built-in, so how about building a tiny initrd
to load the needed modules?
btw, I get
# ./kvm run
# kvm run -k ../../arch/x86/boot/bzImage -m 1728 -c 24 --name guest-10193
<hang>
--
error compiling committee.c: too many arguments to function
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] kvm tools: Boot to host /bin/sh via 9p by default
2011-08-09 16:59 ` Avi Kivity
@ 2011-08-09 17:33 ` Pekka Enberg
2011-08-09 20:06 ` Sasha Levin
1 sibling, 0 replies; 8+ messages in thread
From: Pekka Enberg @ 2011-08-09 17:33 UTC (permalink / raw)
To: Avi Kivity
Cc: kvm, Linus Torvalds, Asias He, Cyrill Gorcunov, Ingo Molnar,
Prasad Joshi, Sasha Levin
On Tue, 2011-08-09 at 19:59 +0300, Avi Kivity wrote:
> On 08/09/2011 06:33 PM, Pekka Enberg wrote:
> > This patch updates 'kvm run' to boot to host filesystem via 9p '/bin/sh' by
> > default:
> >
> > $ ./kvm run
> > # kvm run -k ../../arch/x86/boot/bzImage -m 320 -c 2 --name guest-3462
> > [ 0.000000] Linux version 3.1.0-rc1+ (penberg@tiger) (gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5) ) #7 SMP PREEMPT Tue Aug 9 16:39:20 EEST 2011
> > [ 0.000000] Command line: notsc noapic noacpi pci=conf1 reboot=k panic=1 console=ttyS0 earlyprintk=serial init=/bin/sh root=/dev/vda rw root=/dev/root rootflags=rw,trans=virtio,version=9p2000.u rootfstype=9p
> >
> > [snip]
> >
> > [ 1.803261] VFS: Mounted root (9p filesystem) on device 0:13.
> > [ 1.805153] devtmpfs: mounted
> > [ 1.808353] Freeing unused kernel memory: 924k freed
> > [ 1.810592] Write protecting the kernel read-only data: 12288k
> > [ 1.816268] Freeing unused kernel memory: 632k freed
> > [ 1.826030] Freeing unused kernel memory: 1448k freed
> > sh: cannot set terminal process group (-1): Inappropriate ioctl for device
> > sh: no job control in this shell
> > sh-4.1#
> >
>
> Most kernels won't have 9p built-in, so how about building a tiny initrd
> to load the needed modules?
Sure. Can we do that in portable way across distributions? We already
support the "-i" command line option, btw, if you already have a working
initrd somewhere.
> btw, I get
>
> # ./kvm run
> # kvm run -k ../../arch/x86/boot/bzImage -m 1728 -c 24 --name guest-10193
> <hang>
Is that with or without 9p built into the kernel image? There's a full
list of required options in tools/kvm/README.
Pekka
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] kvm tools: Boot to host /bin/sh via 9p by default
2011-08-09 16:59 ` Avi Kivity
2011-08-09 17:33 ` Pekka Enberg
@ 2011-08-09 20:06 ` Sasha Levin
2011-08-09 20:15 ` Pekka Enberg
1 sibling, 1 reply; 8+ messages in thread
From: Sasha Levin @ 2011-08-09 20:06 UTC (permalink / raw)
To: Avi Kivity
Cc: Pekka Enberg, kvm, Linus Torvalds, Asias He, Cyrill Gorcunov,
Ingo Molnar, Prasad Joshi
On Tue, 2011-08-09 at 19:59 +0300, Avi Kivity wrote:
> On 08/09/2011 06:33 PM, Pekka Enberg wrote:
> > This patch updates 'kvm run' to boot to host filesystem via 9p '/bin/sh' by
> > default:
> >
> > $ ./kvm run
> > # kvm run -k ../../arch/x86/boot/bzImage -m 320 -c 2 --name guest-3462
> > [ 0.000000] Linux version 3.1.0-rc1+ (penberg@tiger) (gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5) ) #7 SMP PREEMPT Tue Aug 9 16:39:20 EEST 2011
> > [ 0.000000] Command line: notsc noapic noacpi pci=conf1 reboot=k panic=1 console=ttyS0 earlyprintk=serial init=/bin/sh root=/dev/vda rw root=/dev/root rootflags=rw,trans=virtio,version=9p2000.u rootfstype=9p
> >
> > [snip]
> >
> > [ 1.803261] VFS: Mounted root (9p filesystem) on device 0:13.
> > [ 1.805153] devtmpfs: mounted
> > [ 1.808353] Freeing unused kernel memory: 924k freed
> > [ 1.810592] Write protecting the kernel read-only data: 12288k
> > [ 1.816268] Freeing unused kernel memory: 632k freed
> > [ 1.826030] Freeing unused kernel memory: 1448k freed
> > sh: cannot set terminal process group (-1): Inappropriate ioctl for device
> > sh: no job control in this shell
> > sh-4.1#
> >
>
> Most kernels won't have 9p built-in, so how about building a tiny initrd
> to load the needed modules?
>
> btw, I get
>
> # ./kvm run
> # kvm run -k ../../arch/x86/boot/bzImage -m 1728 -c 24 --name guest-10193
> <hang>
>
This is usually the case of missing serial console support in the guest
kernel.
You can either enable these:
CONFIG_SERIAL_8250=y
CONFIG_SERIAL_8250_CONSOLE=y
Switch to virtio console using '--console virtio', or boot into a
graphical console using '--sdl' or '--vnc'.
--
Sasha.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] kvm tools: Boot to host /bin/sh via 9p by default
2011-08-09 20:06 ` Sasha Levin
@ 2011-08-09 20:15 ` Pekka Enberg
2011-08-09 20:30 ` Sasha Levin
0 siblings, 1 reply; 8+ messages in thread
From: Pekka Enberg @ 2011-08-09 20:15 UTC (permalink / raw)
To: Sasha Levin
Cc: Avi Kivity, kvm, Linus Torvalds, Asias He, Cyrill Gorcunov,
Ingo Molnar, Prasad Joshi
On Tue, Aug 9, 2011 at 11:06 PM, Sasha Levin <levinsasha928@gmail.com> wrote:
> On Tue, 2011-08-09 at 19:59 +0300, Avi Kivity wrote:
>> On 08/09/2011 06:33 PM, Pekka Enberg wrote:
>> > This patch updates 'kvm run' to boot to host filesystem via 9p '/bin/sh' by
>> > default:
>> >
>> > $ ./kvm run
>> > # kvm run -k ../../arch/x86/boot/bzImage -m 320 -c 2 --name guest-3462
>> > [ 0.000000] Linux version 3.1.0-rc1+ (penberg@tiger) (gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5) ) #7 SMP PREEMPT Tue Aug 9 16:39:20 EEST 2011
>> > [ 0.000000] Command line: notsc noapic noacpi pci=conf1 reboot=k panic=1 console=ttyS0 earlyprintk=serial init=/bin/sh root=/dev/vda rw root=/dev/root rootflags=rw,trans=virtio,version=9p2000.u rootfstype=9p
>> >
>> > [snip]
>> >
>> > [ 1.803261] VFS: Mounted root (9p filesystem) on device 0:13.
>> > [ 1.805153] devtmpfs: mounted
>> > [ 1.808353] Freeing unused kernel memory: 924k freed
>> > [ 1.810592] Write protecting the kernel read-only data: 12288k
>> > [ 1.816268] Freeing unused kernel memory: 632k freed
>> > [ 1.826030] Freeing unused kernel memory: 1448k freed
>> > sh: cannot set terminal process group (-1): Inappropriate ioctl for device
>> > sh: no job control in this shell
>> > sh-4.1#
>> >
>>
>> Most kernels won't have 9p built-in, so how about building a tiny initrd
>> to load the needed modules?
>>
>> btw, I get
>>
>> # ./kvm run
>> # kvm run -k ../../arch/x86/boot/bzImage -m 1728 -c 24 --name guest-10193
>> <hang>
>>
>
> This is usually the case of missing serial console support in the guest
> kernel.
>
> You can either enable these:
> CONFIG_SERIAL_8250=y
> CONFIG_SERIAL_8250_CONSOLE=y
>
> Switch to virtio console using '--console virtio', or boot into a
> graphical console using '--sdl' or '--vnc'.
Can we somehow sanely detect that the kernel doesn't support serial
console and switch to virtio console?
Pekka
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH] kvm tools: Boot to host /bin/sh via 9p by default
2011-08-09 20:15 ` Pekka Enberg
@ 2011-08-09 20:30 ` Sasha Levin
0 siblings, 0 replies; 8+ messages in thread
From: Sasha Levin @ 2011-08-09 20:30 UTC (permalink / raw)
To: Pekka Enberg
Cc: Avi Kivity, kvm, Linus Torvalds, Asias He, Cyrill Gorcunov,
Ingo Molnar, Prasad Joshi
On Tue, 2011-08-09 at 23:15 +0300, Pekka Enberg wrote:
> On Tue, Aug 9, 2011 at 11:06 PM, Sasha Levin <levinsasha928@gmail.com> wrote:
> > On Tue, 2011-08-09 at 19:59 +0300, Avi Kivity wrote:
> >> On 08/09/2011 06:33 PM, Pekka Enberg wrote:
> >> > This patch updates 'kvm run' to boot to host filesystem via 9p '/bin/sh' by
> >> > default:
> >> >
> >> > $ ./kvm run
> >> > # kvm run -k ../../arch/x86/boot/bzImage -m 320 -c 2 --name guest-3462
> >> > [ 0.000000] Linux version 3.1.0-rc1+ (penberg@tiger) (gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5) ) #7 SMP PREEMPT Tue Aug 9 16:39:20 EEST 2011
> >> > [ 0.000000] Command line: notsc noapic noacpi pci=conf1 reboot=k panic=1 console=ttyS0 earlyprintk=serial init=/bin/sh root=/dev/vda rw root=/dev/root rootflags=rw,trans=virtio,version=9p2000.u rootfstype=9p
> >> >
> >> > [snip]
> >> >
> >> > [ 1.803261] VFS: Mounted root (9p filesystem) on device 0:13.
> >> > [ 1.805153] devtmpfs: mounted
> >> > [ 1.808353] Freeing unused kernel memory: 924k freed
> >> > [ 1.810592] Write protecting the kernel read-only data: 12288k
> >> > [ 1.816268] Freeing unused kernel memory: 632k freed
> >> > [ 1.826030] Freeing unused kernel memory: 1448k freed
> >> > sh: cannot set terminal process group (-1): Inappropriate ioctl for device
> >> > sh: no job control in this shell
> >> > sh-4.1#
> >> >
> >>
> >> Most kernels won't have 9p built-in, so how about building a tiny initrd
> >> to load the needed modules?
> >>
> >> btw, I get
> >>
> >> # ./kvm run
> >> # kvm run -k ../../arch/x86/boot/bzImage -m 1728 -c 24 --name guest-10193
> >> <hang>
> >>
> >
> > This is usually the case of missing serial console support in the guest
> > kernel.
> >
> > You can either enable these:
> > CONFIG_SERIAL_8250=y
> > CONFIG_SERIAL_8250_CONSOLE=y
> >
> > Switch to virtio console using '--console virtio', or boot into a
> > graphical console using '--sdl' or '--vnc'.
>
> Can we somehow sanely detect that the kernel doesn't support serial
> console and switch to virtio console?
Probably, will look into it tomorrow.
--
Sasha.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2011-08-09 20:31 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-08-09 15:33 [PATCH] kvm tools: Boot to host /bin/sh via 9p by default Pekka Enberg
2011-08-09 15:36 ` Pekka Enberg
2011-08-09 15:37 ` Ingo Molnar
2011-08-09 16:59 ` Avi Kivity
2011-08-09 17:33 ` Pekka Enberg
2011-08-09 20:06 ` Sasha Levin
2011-08-09 20:15 ` Pekka Enberg
2011-08-09 20:30 ` Sasha Levin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox