]> rtime.felk.cvut.cz Git - novaboot.git/commitdiff
AMT IDE-R implementation
authorMichal Sojka <sojkam1@fel.cvut.cz>
Thu, 17 Jul 2014 20:09:10 +0000 (22:09 +0200)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Thu, 17 Jul 2014 20:09:10 +0000 (22:09 +0200)
This change is based on work by Václav Fanfule.

README.md
novaboot

index 012f2d118f4488b8320b200045da02533dddc536..3252116dd74a5fcd61fd3964329c0fac1b8adc2b 100644 (file)
--- a/README.md
+++ b/README.md
@@ -268,6 +268,14 @@ user/instance.
     used. The _port_ specifies a TCP port for SOL. If not specified, the
     default is 16992. Default _user_ is admin.
 
+- --ider
+
+    Use Intel AMT technology for IDE redirection. This allows the target
+    machine to boot from nonvaboot created ISO image.
+
+    The experimental _amtider_ utility needed by this option can be
+    obtained from https://github.com/wentasah/amtterm.
+
 - --iprelay=_addr\[:port\]_
 
     Use TCP/IP relay and serial port to access the target's serial port
index 6f212fb6cd2fef3d2d044260c37c499b4673992a..d3cc4e774576c9cec158118eff030a1937b1261a 100755 (executable)
--- a/novaboot
+++ b/novaboot
@@ -99,7 +99,7 @@ read_config($_) foreach $cfg or reverse @cfgs;
 my $explicit_target;
 GetOptions ("target|t=s" => \$explicit_target);
 
-my ($amt, @append, $bender, @chainloaders, $concat, $config_name_opt, $dhcp_tftp, $dump_opt, $dump_config, @exiton, @expect_raw, $gen_only, $grub_config, $grub_prefix, $grub_preamble, $grub2_prolog, $grub2_config, $help, $iprelay, $iso_image, $interactive, $kernel_opt, $make, $man, $no_file_gen, $off_opt, $on_opt, $pulsar, $pulsar_root, $qemu, $qemu_append, $qemu_flags_cmd, $remote_cmd, $remote_expect, $reset_cmd, $rom_prefix, $rsync_flags, @scriptmod, $scons, $serial, $server, $stty, $tftp, $tftp_port, $uboot, @uboot_init);
+my ($amt, @append, $bender, @chainloaders, $concat, $config_name_opt, $dhcp_tftp, $dump_opt, $dump_config, @exiton, @expect_raw, $gen_only, $grub_config, $grub_prefix, $grub_preamble, $grub2_prolog, $grub2_config, $help, $ider, $iprelay, $iso_image, $interactive, $kernel_opt, $make, $man, $no_file_gen, $off_opt, $on_opt, $pulsar, $pulsar_root, $qemu, $qemu_append, $qemu_flags_cmd, $remote_cmd, $remote_expect, $reset_cmd, $rom_prefix, $rsync_flags, @scriptmod, $scons, $serial, $server, $stty, $tftp, $tftp_port, $uboot, @uboot_init);
 
 $rsync_flags = '';
 $rom_prefix = 'rom://';
@@ -145,6 +145,7 @@ my %opt_spec;
     "grub-prefix=s"  => \$grub_prefix,
     "grub2:s"       => \$grub2_config,
     "grub2-prolog=s" => \$grub2_prolog,
+    "ider"           => \$ider,
     "iprelay=s"             => \$iprelay,
     "iso:s"         => \$iso_image,
     "kernel|k=s"     => \$kernel_opt,
@@ -217,6 +218,11 @@ if ($interactive && !-t STDIN) {
 
 if (defined $config_name_opt && scalar(@ARGV) > 1) { die "You cannot use --name with multiple scripts"; }
 
+if ($ider) {
+    $iso_image //= ''; # IDE-R needs an ISO image
+    if (!defined $amt) { die "Error: --ider requires --amt"; }
+}
+
 # Default options
 if (defined $serial) {
     $serial ||= "/dev/ttyUSB0";
@@ -508,6 +514,7 @@ if (exists $variables->{WVDESC}) {
 my $exp; # Expect object to communicate with the target over serial line
 
 my ($target_reset, $target_power_on, $target_power_off);
+my ($amt_user, $amt_password, $amt_host, $amt_port);
 
 if (defined $iprelay) {
     my $IPRELAY;
@@ -658,38 +665,41 @@ END
         return sendPOST($host, $username, $password, $content);
     }
 
-    my ($user,$amt_password,$host,$port) = ($amt =~ /(?:(.*?)(?::(.*))?@)?([^:]*)(?::([0-9]*))?/);;
-    $user ||= "admin";
+    ($amt_user,$amt_password,$amt_host,$amt_port) = ($amt =~ /(?:(.*?)(?::(.*))?@)?([^:]*)(?::([0-9]*))?/);;
+    $amt_user ||= "admin";
     $amt_password ||= $ENV{'AMT_PASSWORD'} || die "AMT password not specified";
-    $host || die "AMT host not specified";
-    $port ||= 16994;
+    $amt_host || die "AMT host not specified";
+    $amt_port ||= 16994;
+
 
     $target_power_off = sub {
        $exp->close();
-       my $result = powerChange($host,$user,$amt_password, "off");
+       my $result = powerChange($amt_host,$amt_user,$amt_password, "off");
        die "AMT power off failed (ReturnValue $result)" if $result != 0;
     };
 
     $target_power_on = sub {
-       my $result = powerChange($host,$user,$amt_password, "on");
+       my $result = powerChange($amt_host,$amt_user,$amt_password, "on");
        die "AMT power on failed (ReturnValue $result)" if $result != 0;
     };
 
     $target_reset = sub {
-       my $result = powerChange($host,$user,$amt_password, "reset");
+       my $result = powerChange($amt_host,$amt_user,$amt_password, "reset");
        if ($result != 0) {
-           print STDERR "Warning: Cannot reset $host, trying power on. ";
-           $result = powerChange($host,$user,$amt_password, "on");
+           print STDERR "Warning: Cannot reset $amt_host, trying power on. ";
+           $result = powerChange($amt_host,$amt_user,$amt_password, "on");
        }
        die "AMT reset failed (ReturnValue $result)" if $result != 0;
     };
 
-    my $cmd = "amtterm -u $user -p $amt_password $host $port";
+    my $cmd = "amtterm -u $amt_user -p $amt_password $amt_host $amt_port";
     print "novaboot: Running: $cmd\n" =~ s/\Q$amt_password\E/???/r;
     $exp = Expect->spawn($cmd);
     $exp->expect(10, "RUN_SOL") || die "Expect for 'RUN_SOL' timed out";
+
 }
 
+
 if ($remote_expect) {
     $exp->expect(10, $remote_expect) || die "Expect for '$remote_expect' timed out";
 }
@@ -919,6 +929,20 @@ if (defined $dhcp_tftp || defined $tftp) {
     $SIG{INT} = sub { system_verbose('sudo pkill --pidfile=tftpd.pid'); exit(0); };
 }
 
+### AMT IDE-R
+if (defined $ider) {
+    my $ider_cmd= "amtider -c $iso_image -u $amt_user -p $amt_password $amt_host $amt_port"  ;
+    print "novaboot: Running: $ider_cmd\n" =~ s/\Q$amt_password\E/???/r;
+    my $ider_pid = fork();
+    if ($ider_pid == 0) {
+       exec($ider_cmd);
+       die "IDE redirection failed";
+    }
+    # FIXME: This collides with --tftp option. Hopefully, nobody needs
+    # to use both simultaneously.
+    $SIG{__DIE__} = sub { system_verbose('kill $ider_pid'); };
+}
+
 ### Reset target (IP relay, AMT, ...)
 
 if (defined $target_reset) {
@@ -1321,6 +1345,14 @@ I<password> is not specified, environment variable AMT_PASSWORD is
 used. The I<port> specifies a TCP port for SOL. If not specified, the
 default is 16992. Default I<user> is admin.
 
+=item --ider
+
+Use Intel AMT technology for IDE redirection. This allows the target
+machine to boot from nonvaboot created ISO image.
+
+The experimental I<amtider> utility needed by this option can be
+obtained from https://github.com/wentasah/amtterm.
+
 =item --iprelay=I<addr[:port]>
 
 Use TCP/IP relay and serial port to access the target's serial port