xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [Xen-devel] [OSSTEST PATCH 1/3] mg-hosts mknetbootdir: Improve sub-option parser
@ 2019-08-29  9:17 Ian Jackson
  2019-08-29  9:17 ` [Xen-devel] [OSSTEST PATCH 2/3] host properties: Firmware: Move default to selecthost Ian Jackson
  2019-08-29  9:17 ` [Xen-devel] [OSSTEST PATCH 3/3] mg-hosts mknetbootdir: Introduce and require -F<firmware> Ian Jackson
  0 siblings, 2 replies; 3+ messages in thread
From: Ian Jackson @ 2019-08-29  9:17 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson

No semantic change.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
---
 mg-hosts | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/mg-hosts b/mg-hosts
index 58b4acc3..d68f7b4e 100755
--- a/mg-hosts
+++ b/mg-hosts
@@ -121,7 +121,14 @@ sub l ($) { return split /,/, $_[0]; }
 
 sub cmd_mknetbootdir () {
     my $dryrun = 0;
-    if (@ARGV && $ARGV[0] eq '-n') { shift @ARGV; $dryrun= 1; }
+    while (@ARGV && $ARGV[0] =~ m/^-/) {
+	$_ = shift @ARGV;
+	last if $_ =~ m/^--?$/;
+	while (m/^-./) {
+	    if (s/^-n/-/) { $dryrun= 1; }
+	    else { die "unknown mknetbootdir option $_"; }
+	}
+    }
     die unless @ARGV>=1;
     my $sudo = $ENV{'OSSTEST_SUDO'} // 'sudo';
     foreach my $hn (@ARGV) {
-- 
2.11.0


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* [Xen-devel] [OSSTEST PATCH 2/3] host properties: Firmware: Move default to selecthost
  2019-08-29  9:17 [Xen-devel] [OSSTEST PATCH 1/3] mg-hosts mknetbootdir: Improve sub-option parser Ian Jackson
@ 2019-08-29  9:17 ` Ian Jackson
  2019-08-29  9:17 ` [Xen-devel] [OSSTEST PATCH 3/3] mg-hosts mknetbootdir: Introduce and require -F<firmware> Ian Jackson
  1 sibling, 0 replies; 3+ messages in thread
From: Ian Jackson @ 2019-08-29  9:17 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson

Drop the explicit default from all the call sites.  This centralises
the default.  This is going to be the new scheme for host properties
in general.

(Two of the call sites had a different default, "", which in their
context was semantically equivalent to "bios".)

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
---
 Osstest/Debian.pm      |  4 ++--
 Osstest/TestSupport.pm | 13 +++++++++----
 ts-xen-install         |  2 +-
 3 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/Osstest/Debian.pm b/Osstest/Debian.pm
index 911d8905..79aa2d24 100644
--- a/Osstest/Debian.pm
+++ b/Osstest/Debian.pm
@@ -443,7 +443,7 @@ sub setupboot_grub2 ($$$$) {
 
     # Grub2 on jessie/stretch ARM* doesn't do multiboot, so we must chainload.
     my $need_uefi_chainload =
-        get_host_property($ho, "firmware", "") eq "uefi" &&
+        get_host_property($ho, "firmware") eq "uefi" &&
         $ho->{Suite} =~ m/jessie|stretch/ && $ho->{Arch} =~ m/^arm/;
 
     my $parsemenu= sub {
@@ -1498,7 +1498,7 @@ END
 
     preseed_microcode($ho,$sfx);
 
-    if (get_host_property($ho, "firmware",'') eq "uefi") {
+    if (get_host_property($ho, "firmware") eq "uefi") {
 	die unless $ho->{Suite} =~ m/jessie|stretch/;
 	# Prevent grub-install from making a new Debian boot entry, so
 	# we always reboot from the network. Debian bug #789798 proposes a
diff --git a/Osstest/TestSupport.pm b/Osstest/TestSupport.pm
index e554af38..b629fb7d 100644
--- a/Osstest/TestSupport.pm
+++ b/Osstest/TestSupport.pm
@@ -1218,7 +1218,10 @@ sub selecthost ($;$) {
 
     #----- calculation of the host's properties -----
 
-    $ho->{Properties} = { };
+    # Firstly, hardcoded defaults
+    $ho->{Properties} = {
+        Firmware => 'bios',
+    };
     my $setprop = sub {
 	my ($pn,$val) = @_;
 	$ho->{Properties}{$pn} = $val;
@@ -1363,6 +1366,8 @@ sub propname_check ($) {
 
 # It is fine to call this on a guest object too, in which case it will
 # always return $defval.
+# Ideally all uses of $defval would be replaced by defaults in the
+# initial array in selecthost.
 sub get_host_property ($$;$) {
     my ($ho, $prop, $defval) = @_;
     return $defval unless $ho->{Properties};
@@ -2811,7 +2816,7 @@ sub host_netboot_file ($;$) {
     # in array context, returns (dir, pathtail)
     #  where dir does not depend on $templatekeytail
     my %v = %r;
-    my $firmware = get_host_property($ho, "firmware", "bios");
+    my $firmware = get_host_property($ho, "firmware");
     my $templatekeybase = $firmware eq 'uefi' ? 'NetGrub' : 'Pxe';
     $templatekeytail //= 'Templates';
     my $templatekey = $templatekeybase.$templatekeytail;
@@ -2937,7 +2942,7 @@ END
 
 sub setup_netboot_local ($) {
     my ($ho) = @_;
-    my $firmware = get_host_property($ho, "firmware", "bios");
+    my $firmware = get_host_property($ho, "firmware");
     $firmware =~ s/-/_/g;
     no strict qw(refs);
     return &{"setup_netboot_local_${firmware}"}($ho);
@@ -2945,7 +2950,7 @@ sub setup_netboot_local ($) {
 
 sub setup_netboot_di ($$$$$;%) {
     my ($ho,$kern,$initrd,$dicmd,$hocmd,%xopts) = @_;
-    my $firmware = get_host_property($ho, "firmware", "bios");
+    my $firmware = get_host_property($ho, "firmware");
     $firmware =~ s/-/_/g;
     no strict qw(refs);
     return &{"setup_netboot_di_${firmware}"}($ho,$kern,$initrd,
diff --git a/ts-xen-install b/ts-xen-install
index 2d3c644d..154f78c7 100755
--- a/ts-xen-install
+++ b/ts-xen-install
@@ -114,7 +114,7 @@ sub extradebs () {
     some_extradebs([ 'DebianExtraPackages', $suite ]);
 
     # $c{ DebianExtraPackages_<firmware>_<arch>_<suite> }
-    my $firmware = get_host_property($ho, "firmware", "bios");
+    my $firmware = get_host_property($ho, "firmware");
     some_extradebs([ 'DebianExtraPackages', $firmware, $ho->{Arch}, $suite ]);
 }
 
-- 
2.11.0


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* [Xen-devel] [OSSTEST PATCH 3/3] mg-hosts mknetbootdir: Introduce and require -F<firmware>
  2019-08-29  9:17 [Xen-devel] [OSSTEST PATCH 1/3] mg-hosts mknetbootdir: Improve sub-option parser Ian Jackson
  2019-08-29  9:17 ` [Xen-devel] [OSSTEST PATCH 2/3] host properties: Firmware: Move default to selecthost Ian Jackson
@ 2019-08-29  9:17 ` Ian Jackson
  1 sibling, 0 replies; 3+ messages in thread
From: Ian Jackson @ 2019-08-29  9:17 UTC (permalink / raw)
  To: xen-devel; +Cc: Dominic Brekau, Ian Jackson

If one runs
  ./mg-hosts mknetbootdir HOST
before having sorted out all the host configuration, it uses the
default configuration value for the host's firmware kind, which is
"bios".  If the configuration is then changed, things don't work.
This is confusing.

So ask the user to specify one or more -F<firmware>, or -Fany.

CC: Dominic Brekau <dominic.brekau@credativ.de>
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
---
 mg-hosts | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/mg-hosts b/mg-hosts
index d68f7b4e..14f816ae 100755
--- a/mg-hosts
+++ b/mg-hosts
@@ -19,7 +19,7 @@
 
 # Usages:
 #
-#  ./mg-hosts mknetbootdir HOST...
+#  ./mg-hosts mknetbootdir -Fany | -F<firmware>... HOST...
 #               Create directories for netboot as expected by the rest
 #               of osstest.  Will use "sudo". The HOST(s) must be
 #               allocated (via mg-allocate HOST).
@@ -121,19 +121,29 @@ sub l ($) { return split /,/, $_[0]; }
 
 sub cmd_mknetbootdir () {
     my $dryrun = 0;
+    my %expect_firmware;
     while (@ARGV && $ARGV[0] =~ m/^-/) {
 	$_ = shift @ARGV;
 	last if $_ =~ m/^--?$/;
 	while (m/^-./) {
 	    if (s/^-n/-/) { $dryrun= 1; }
+	    elsif (s/^-F(.*)//) { $expect_firmware{$1} = 1 }
 	    else { die "unknown mknetbootdir option $_"; }
 	}
     }
+    die "need at least one -F<firmware> or -Fany option"
+	unless %expect_firmware;
     die unless @ARGV>=1;
     my $sudo = $ENV{'OSSTEST_SUDO'} // 'sudo';
     foreach my $hn (@ARGV) {
         my $ho= selecthost("host=$hn");
 	my ($dir, $file) = host_netboot_file($ho);
+	if (!$expect_firmware{any}) {
+	    my $got_firmware = get_host_property($ho, "firmware");
+	    die
+ "host $hn configuration says firmware \`$got_firmware', not as expected\n"
+		unless $expect_firmware{$got_firmware};
+	}
         die unless defined $dir;
 	my ($rdir, $realfile) = host_netboot_file($ho, 'TemplatesReal');
 	$realfile //= $file;
-- 
2.11.0


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

end of thread, other threads:[~2019-08-29  9:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-29  9:17 [Xen-devel] [OSSTEST PATCH 1/3] mg-hosts mknetbootdir: Improve sub-option parser Ian Jackson
2019-08-29  9:17 ` [Xen-devel] [OSSTEST PATCH 2/3] host properties: Firmware: Move default to selecthost Ian Jackson
2019-08-29  9:17 ` [Xen-devel] [OSSTEST PATCH 3/3] mg-hosts mknetbootdir: Introduce and require -F<firmware> Ian Jackson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).