We can now use the -k command line option to specify a file from which to get the command line arguments. Now vmrunkernel doesn't need to be modified every time you try to run a different kernel.
Change-Id: Ib4e60dbb03e0040cd2268234e080ba302cdc9ce3 Signed-off-by: Kyle Milka <[email protected]> --- kern/kfs/master_linux_cmdline | 14 +++++++++++++ kern/kfs/tinycore_cmdline | 15 ++++++++++++++ kern/kfs/vmimage_cmdline | 13 ++++++++++++ tests/vmm/vmrunkernel.c | 47 ++++++++++++++++++++++++++++--------------- 4 files changed, 73 insertions(+), 16 deletions(-) create mode 100644 kern/kfs/master_linux_cmdline create mode 100644 kern/kfs/tinycore_cmdline create mode 100644 kern/kfs/vmimage_cmdline diff --git a/kern/kfs/master_linux_cmdline b/kern/kfs/master_linux_cmdline new file mode 100644 index 0000000..17a9e06 --- /dev/null +++ b/kern/kfs/master_linux_cmdline @@ -0,0 +1,14 @@ +earlyprintk=vmcall,keep + console=hvc0 + nosmp + maxcpus=1 + acpi.debug_layer=0x2 + acpi.debug_level=0xffffffff + apic=debug + noexec=off + nohlt + init=/bin/launcher + lapic=notscdeadline + lapictimerfreq=1000000 + pit=none + noinvpcid diff --git a/kern/kfs/tinycore_cmdline b/kern/kfs/tinycore_cmdline new file mode 100644 index 0000000..92dd1ec --- /dev/null +++ b/kern/kfs/tinycore_cmdline @@ -0,0 +1,15 @@ +earlyprintk=vmcall,keep + console=hvc0 + nosmp + maxcpus=1 + acpi.debug_layer=0x2 + acpi.debug_level=0xffffffff + apic=debug + noexec=off + nohlt + init=/bin/launcher + lapic=notscdeadline + lapictimerfreq=1000000 + pit=none + nortc + nozswap diff --git a/kern/kfs/vmimage_cmdline b/kern/kfs/vmimage_cmdline new file mode 100644 index 0000000..b54cffa --- /dev/null +++ b/kern/kfs/vmimage_cmdline @@ -0,0 +1,13 @@ +earlyprintk=vmcall,keep + console=hvc0 + maxcpus=1 + acpi.debug_layer=0x2 + acpi.debug_level=0xffffffff + apic=debug + noexec=off + nohlt + init=/bin/sh + lapic=notscdeadline + lapictimerfreq=1000000 + pit=none + root=/dev/vda1 diff --git a/tests/vmm/vmrunkernel.c b/tests/vmm/vmrunkernel.c index 609f7d2..c32c22b 100644 --- a/tests/vmm/vmrunkernel.c +++ b/tests/vmm/vmrunkernel.c @@ -337,20 +337,7 @@ static void pir_dump() int main(int argc, char **argv) { struct boot_params *bp; - char *cmdline_default = "earlyprintk=vmcall,keep" - " console=hvc0" - " nosmp" - " maxcpus=1" - " acpi.debug_layer=0x2" - " acpi.debug_level=0xffffffff" - " apic=debug" - " noexec=off" - " nohlt" - " init=/bin/launcher" - " lapic=notscdeadline" - " lapictimerfreq=1000000" - " pit=none" - " noinvpcid"; + char cmdline_default[512] = {0}; char *cmdline_extra = "\0"; char *cmdline; uint64_t *p64; @@ -376,7 +363,7 @@ int main(int argc, char **argv) struct vm_trapframe *vm_tf; uint64_t tsc_freq_khz; char *cmdlinep; - int cmdlinesz, len; + int cmdlinesz, len, cmdline_fd; char *disk_image_file = NULL; fprintf(stderr, "%p %p %p %p\n", PGSIZE, PGSHIFT, PML1_SHIFT, @@ -444,12 +431,41 @@ int main(int argc, char **argv) argc--; argv++; disk_image_file = *argv; break; + case 'k': /* specify file to get cmdline args from */ + argc--; argv++; + cmdline_fd = open(*argv, O_RDONLY); + if (cmdline_fd < 0) { + fprintf(stderr, "failed to open file: %s\n", *argv); + exit(1); + } + struct stat stat_result; + if (stat(*argv, &stat_result) == -1) { + fprintf(stderr, "stat of %s failed\n", *argv); + exit(1); + } + len = stat_result.st_size; + if (len > 512) { + fprintf(stderr, "command line options exceed 512 bytes!"); + exit(1); + } + int num_read = read(cmdline_fd, cmdline_default, len); + if (num_read != len) { + fprintf(stderr, "read failed len was : %d," + "num_read was: %d\n", len, num_read); + exit(1); + } + close(cmdline_fd); + break; default: fprintf(stderr, "BMAFR\n"); break; } argc--, argv++; } + if (strlen(cmdline_default) == 0) { + fprintf(stderr, "No command line parameter file specified.\n"); + exit(1); + } if (argc < 1) { fprintf(stderr, "Usage: %s vmimage [-n (no vmcall printf)] [coreboot_tables [loadaddress [entrypoint]]]\n", argv[0]); exit(1); @@ -644,7 +660,6 @@ int main(int argc, char **argv) vm->virtio_mmio_devices[VIRTIO_MMIO_BLOCK_DEV] = &blk_mmio_dev; blk_init_fn(&blk_vqdev, disk_image_file); } - net_init_fn(&net_vqdev, default_nic); /* Set the kernel command line parameters */ -- 2.8.0.rc3.226.g39d4020 -- You received this message because you are subscribed to the Google Groups "Akaros" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. For more options, visit https://groups.google.com/d/optout.
