]> xenbits.xensource.com Git - osstest.git/commitdiff
Prefix guest LV names with the job name
authorIan Jackson <iwj@xenproject.org>
Mon, 19 Oct 2020 11:41:27 +0000 (12:41 +0100)
committerIan Jackson <iwj@xenproject.org>
Thu, 22 Oct 2020 16:40:22 +0000 (17:40 +0100)
This means that a subsequent test which reuses the same host will not
use the same LVs.  This is a good idea because reusing the same LV
names in a subsequent job means relying on the "ad hoc run" cleanup
code.  This is a bad idea because that code is rarely tested.

And because, depending on the situation, the old LVs may even still be
in use.  For example, in a pair test, the guest's LVs will still be
set up for use with nbd.

It seems better to fix this by using a fresh LV rather than adding
more teardown code.

The "wear limit" on host reuse is what prevents the disk filling up
with LVs from old guests.

ts-debian-fixup needs special handling, because Debian's xen-tools'
xen-create-image utility hardcodes its notion of LV name construction.
We need to rename the actual LVs (perhaps overwriting old ones from a
previous ad-hoc run) and also update the config.

Signed-off-by: Ian Jackson <iwj@xenproject.org>
Osstest/TestSupport.pm
ts-debian-fixup

index 12aaba792255987e51400a5c17ee0accb4cc3230..9362a865f14cec6816d36a1ab48ece4f2d07617c 100644 (file)
@@ -2179,7 +2179,7 @@ sub guest_var_commalist ($$) {
 
 sub guest_mk_lv_name ($$) {
     my ($gho, $suffix) = @_;
-    return "$gho->{Name}".$suffix;
+    return $job."_$gho->{Name}".$suffix;
 }
 
 sub prepareguest ($$$$$$) {
index a878fe507a04673b82c2055a597f49f9c0ce88d2..810b3aba8abf8485ef70bdb0c98f766eac006619 100755 (executable)
@@ -37,6 +37,27 @@ sub savecfg () {
     $cfg= get_filecontents("$cfgstash.orig");
 }
 
+sub lvnames () {
+    my $lvs = target_cmd_output_root($ho, "lvdisplay --colon", 30);
+    foreach my $suffix (qw(disk swap)) {
+       my $old = "$gho->{Name}-$suffix";
+       my $new = "${job}_${old}";
+       my $full_old = "/dev/$gho->{Vg}/$old";
+       my $full_new = "/dev/$gho->{Vg}/$new";
+       $cfg =~ s{\Q$full_old\E(?![0-9a-zA-Z/_.-])}{
+            logm "Replacing in domain config \`$&' with \`$full_new'";
+            $full_new;
+        }ge;
+       if ($lvs =~ m{^ *\Q$full_old\E}m) {
+           if ($lvs =~ m{^ *\Q$full_new\E}m) {
+               # In case we are re-running (eg, adhoc)
+               target_cmd_root($ho, "lvremove -f $full_new", 30);
+           }
+           target_cmd_root($ho, "lvrename $full_old $new", 30);
+       }
+    }
+}
+
 sub ether () {
 #    $cfg =~ s/^ [ \t]*
 #        ( vif [ \t]* \= [ \t]* \[ [ \t]* [\'\"]
@@ -207,6 +228,7 @@ sub writecfg () {
 }
 
 savecfg();
+lvnames();
 ether();
 access();
 $console = target_setup_rootdev_console_inittab($ho,$gho,"$mountpoint");