]> rtime.felk.cvut.cz Git - l4.git/blob - l4/tool/bin/qemu-x86-launch
update
[l4.git] / l4 / tool / bin / qemu-x86-launch
1 #! /usr/bin/perl -W
2 #
3 # (c) 2009 Technische Universität Dresden
4 # This file is part of TUD:OS and distributed under the terms of the
5 # GNU General Public License 2.
6 # Please see the COPYING-GPL-2 file for details.
7 #
8 # Adam Lackorzynski <adam@os.inf.tu-dresden.de>
9 #
10
11 use strict;
12
13 BEGIN { unshift @INC, $ENV{L4DIR}.'/tool/lib'
14            if $ENV{L4DIR} && -d $ENV{L4DIR}.'/tool/lib/L4';}
15
16 use L4::ModList;
17 use File::Temp qw/tempdir/;
18
19 my $qemu         = $ENV{QEMU}       || 'qemu';
20 my $kernelname   = $ENV{KERNEL}     || 'bootstrap';
21 my $module_path  = $ENV{SEARCHPATH} || ".";
22 my $modulesfile  = shift;
23 my $entryname    = shift;
24 my $unzip_tmp    = tempdir(CLEANUP => 1); 
25
26 sub get_file($$)
27 {
28   my $command = shift;
29   my $cmdline = shift;
30
31   my $fp = L4::ModList::get_file_uncompressed_or_die($command, $module_path,
32                                                      $unzip_tmp);
33
34   $cmdline =~ s/^\S+\s*//;
35   $fp.' '.$cmdline;
36 }
37
38
39 die "No entry name given" unless defined $entryname;
40
41 my %entry = L4::ModList::get_module_entry($modulesfile, $entryname);
42
43 my @mods = @{$entry{mods}};
44 my $kernel = L4::ModList::search_file_or_die($entry{bootstrap}{command}, $module_path);
45 my $initrd = join(',', map { get_file($_->{command}, $_->{cmdline}) } @mods);
46
47 my $qemu_cmd =
48       "$qemu -kernel $kernel -append \"$entry{bootstrap}{cmdline}\" ".
49       "-initrd \"$initrd\" ".join(' ', @ARGV);
50
51 print "Note: At least QEmu 0.13 is required for the loading to work.\n";
52 print "$qemu_cmd\n";
53 system("$qemu_cmd");