Implement for driving libvirt via virsh
v3 cover Implement for driving libvirt via virsh
The following series switches osstest to implement the toolstack via get_host_method_object()->method rather than toolstack()->{Command}." method" etc.
This is needed because virsh differs from xm/xl in a few commands.
It also implements partial virsh support (simple lifecycle stuff, but not e.g. migration yet). Due to the ts-migration-check logic this means that the libvirt sequence works in so far as it skips/ignores the migration/save+restore related tests. Wei has a followup series (or at least a WIP?) which adds migration support. I've dropped my WIP patch from last time in favour of that.
Since last time I've addressed all of Ian's review on v2. Lots of passing $gho to things instead of individual properties, switch to a better inheritance scheme for Osstest::Toolstack::xend,
* TestSupport: Add helper to wait for a guest to shutdown
apt: lock osstest's usages of apt-get against each other
A ts-logs-capture: Collect some libvirt logs and capabilities
A Pass host to toolstack()
A ts-rumpuserxen-demo-xenstorels: Use standard functions for things
Toolstack: use get_host_method_object() to manage toolstack selection
TestSupport: always use xl for generic operations.
TestSupport: guest_create and guest_destroy take only a $gho.
Toolstack: Refactor guest lifecycle.
Toolstack: Refactor consolecmd handling
Toolstack: Refactor shutdown support
A Toolstack: Refactor migration support check.
Toolstack: Refactor migration support.
Toolstack: Refactor save/restore support
libvirt: Implement initscript restart which has some hope of working.
A libvirt: Implement shutdown_wait
A Toolstack: Remove Command field for all toolstacks.
A ts-guest-start: Use guest_create
N Toolstack: Pass $gho to create method
* == "TestSupport: Add helper to wait for a guest to shutdown") wasn't posted last time, it was actually part of the "add distro domU testing flight" series, but it is needed here too and I expect this one to land first.
N == New
A == Acked
Ian.
PATCH v3 1/19 TestSupport: Add helper to wait for a guest to shutdown
Refactor the guts of guest_await_reboot into a helper and use for both shutdown and reboot handling.
---
v3: Refactor common code with guest_await_reboot.
--- Osstest/TestSupport.pm | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-)
Osstest/TestSupport.pm +18 -6
@@ -92,7 +92,8 @@ BEGIN { guest_umount_lv guest_await guest_await_dhcp_tcp guest_checkrunning guest_check_ip guest_find_ether guest_find_domid guest_check_up guest_check_up_quick - guest_get_state guest_await_reboot guest_destroy + guest_get_state guest_await_reboot + guest_await_shutdown guest_destroy guest_vncsnapshot_begin guest_vncsnapshot_stash guest_check_remus_ok guest_editconfig host_involves_pcipassthrough host_get_pcipassthrough_devs
@@ -1295,17 +1296,28 @@ sub report_once ($$$) { $ho->{$k}= $msg; } -sub guest_await_reboot ($$$) { - my ($ho,$gho, $timeout) = @_; - poll_loop($timeout, 30, "await reboot request from $gho->{Guest}", sub { +sub guest_await_state ($$$$$) { + my ($ho,$gho, $what,$wait_st,$timeout) = @_; + + poll_loop($timeout, 30, "await $what request from $gho->{Guest}", sub { my $st= guest_get_state($ho,$gho); - return undef if $st eq 'sr'; + return undef if $st eq $wait_st; fail("guest unexpectedly shutdown; state is '$st'") if $st =~ m/^s/ || $st eq ''; - return "guest state is $st"; + return "guest state is \"$st\""; }); } +sub guest_await_reboot ($$$) { + my ($ho,$gho, $timeout) = @_; + return guest_await_state($ho,$gho, "reboot", "sr", $timeout); +} + +sub guest_await_shutdown ($$$) { + my ($ho,$gho, $timeout) = @_; + return guest_await_state($ho,$gho, "shutdown", "s", $timeout); +} + sub guest_destroy ($$) { my ($ho,$gho) = @_; target_cmd_root($ho, toolstack()->{Command}." destroy $gho->{Name}", 40);
Signature · 1 line
2.1.4
Re: [PATCH v3 01/19] TestSupport: Add helper to wait for a guest to shutdown
Ian Campbell writes ("[PATCH v3 01/19] TestSupport: Add helper to wait for a guest to shutdown"):
Quoted 2 lines
Refactor the guts of
guest_await_rebootinto a helper and use for both shutdown and reboot handling.
PATCH v3 2/19 apt: lock osstest's usages of apt-get against each other
In reply to Ian CampbellCurrently we rely on all apt-get invocations being in a single ts-xen-build-prep job which can't run on a shared host.
That is a bit inflexible so instead use our own lock. We wait indefinitely and rely on osstest's existing command timeout infrastructure to catch problems.
target_install_packages*() previous estimated the time taken to install the packages based on the number of packages. This no longer applies because the install might get stuck behind some other large install. Use a 3000s (nearly an hour) timeout instead (I expect failures here to be unusual so erred on the big side)
---
v3: Drop timeout parameter to target_run_apt
Reindent target_run_apt more sensibly
--- Osstest/Debian.pm | 2 +- Osstest/TestSupport.pm | 12 +++++------- 2 files changed, 6 insertions(+), 8 deletions(-)
Osstest/Debian.pm +1 -1
@@ -492,7 +492,7 @@ d-i apt-setup/another boolean false d-i apt-setup/non-free boolean false d-i apt-setup/contrib boolean false -d-i pkgsel/include string openssh-server, ntp, ntpdate, ethtool, $extra_packages +d-i pkgsel/include string openssh-server, ntp, ntpdate, ethtool, chiark-utils-bin, $extra_packages $xopts{ExtraPreseed}
Osstest/TestSupport.pm +5 -7
@@ -434,20 +434,18 @@ sub target_putfile_root ($$$$;$) { tputfileex('root', @_); } sub target_run_apt { - my ($ho, $timeout, @aptopts) = @_; + my ($ho, @aptopts) = @_; target_cmd_root($ho, - "DEBIAN_PRIORITY=critical UCF_FORCE_CONFFOLD=y apt-get @aptopts", - $timeout); + "DEBIAN_PRIORITY=critical UCF_FORCE_CONFFOLD=y \ + with-lock-ex -w /var/lock/osstest-apt apt-get @aptopts", 3000); } sub target_install_packages { my ($ho, @packages) = @_; - target_run_apt($ho, 300 + 100 * @packages, - qw(-y install), @packages); + target_run_apt($ho, qw(-y install), @packages); } sub target_install_packages_norec { my ($ho, @packages) = @_; - target_run_apt($ho, 300 + 100 * @packages, - qw(--no-install-recommends -y install), @packages); + target_run_apt($ho, qw(--no-install-recommends -y install), @packages); } sub target_somefile_getleaf ($$$) {
Signature · 1 line
2.1.4
Re: [PATCH v3 02/19] apt: lock osstest's usages of apt-get against each other
Ian Campbell writes ("[PATCH v3 02/19] apt: lock osstest's usages of apt-get against each other"):
Quoted 2 lines
Currently we rely on all apt-get invocations being in a single ts-xen-build-prep job which can't run on a shared host.
PATCH v3 3/19 ts-logs-capture: Collect some libvirt logs and capabilities
In reply to Ian Campbell--- ts-logs-capture | 4 ++++ 1 file changed, 4 insertions(+)
ts-logs-capture +4 -0
@@ -117,6 +117,9 @@ sub fetch_logs_host_guests () { /var/log/xen/osstest* /var/log/xen/xenstored* + /var/log/libvirt/libvirtd.log + /var/log/libvirt/libxl/* + /var/run/xenstored* /var/log/xenstored*
@@ -161,6 +164,7 @@ sub fetch_logs_host_guests () { 'lspci -vvv', 'lspci -tv', 'cat /proc/partitions', + 'virsh capabilities', ) { try_cmd_output_save($cmd); }
Signature · 1 line
2.1.4
PATCH v3 4/19 Pass host to toolstack()
In reply to Ian CampbellThis will be needed in a future patch.
Everywhere already has a $ho in hand. Also cache the answer as $ho->{Toolstack}.
I scanned the source with:
find -name \*.pm -exec perl -c {} \;
for i in ts-* ; do perl -c $i; done
which reported "Not enough arguments for Osstest::TestSupport::toolstack" for each callsite which needed changing.
Also don't pass the toolstack command name directly to host_get_free_memory(). Look it up instead.
--- Osstest/TestSupport.pm | 16 ++++++++++------ ts-debian-fixup | 2 +- ts-debian-hvm-install | 4 ++-- ts-guest-localmigrate | 2 +- ts-guest-migrate | 2 +- ts-guest-saverestore | 8 ++++---- ts-guest-start | 4 ++-- ts-guest-stop | 2 +- ts-logs-capture | 2 +- ts-migrate-support-check | 4 ++-- ts-redhat-install | 2 +- ts-rumpuserxen-demo-xenstorels | 4 ++-- ts-windows-install | 2 +- ts-xen-install | 10 +++++----- 14 files changed, 34 insertions(+), 30 deletions(-)
Osstest/TestSupport.pm +10 -6
@@ -954,8 +954,9 @@ END }); } -sub host_get_free_memory($$) { - my ($ho,$toolstack) = @_; +sub host_get_free_memory($) { + my ($ho) = @_; + my $toolstack = toolstack($ho)->{Command}; # The line is as followed: # free_memory : XXXX my $info = target_cmd_output_root($ho, "$toolstack info", 10);
@@ -1318,7 +1319,7 @@ sub guest_await_shutdown ($$$) { sub guest_destroy ($$) { my ($ho,$gho) = @_; - target_cmd_root($ho, toolstack()->{Command}." destroy $gho->{Name}", 40); + target_cmd_root($ho, toolstack($ho)->{Command}." destroy $gho->{Name}", 40); } sub guest_create ($$) {
@@ -1611,7 +1612,7 @@ sub guest_check_up ($) { sub guest_get_state ($$) { my ($ho,$gho) = @_; - my $domains= target_cmd_output_root($ho, toolstack()->{Command}." list"); + my $domains= target_cmd_output_root($ho, toolstack($ho)->{Command}." list"); $domains =~ s/^Name.*\n//; foreach my $l (split /\n/, $domains) { $l =~ m/^(\S+) (?: \s+ \d+ ){3} \s+ ([-a-z]+) \s/x or die "$l ?";
@@ -1816,7 +1817,7 @@ sub guest_find_domid ($$) { my ($ho,$gho) = @_; return if defined $gho->{Domid}; my $list= target_cmd_output_root($ho, - toolstack()->{Command}." list $gho->{Name}"); + toolstack($ho)->{Command}." list $gho->{Name}"); $list =~ m/^(?!Name\s)(\S+)\s+(\d+)\s+(\d+)+(\d+)\s.*$/m or die "domain list: $list"; $1 eq $gho->{Name} or die "domain list name $1 expected $gho->{Name}";
@@ -1886,7 +1887,9 @@ our %toolstacks= }, ); -sub toolstack () { +sub toolstack ($) { + my ($ho) = @_; + return $ho->{Toolstack} if $ho->{Toolstack}; my $tsname= $r{toolstack}; $tsname= 'xend' if !defined $tsname; my $ts= $toolstacks{$tsname};
@@ -1895,6 +1898,7 @@ sub toolstack () { logm("toolstack $tsname"); $ts->{Name}= $tsname; } + $ho->{Toolstack} = $ts; return $ts; }
ts-debian-fixup +1 -1
@@ -148,7 +148,7 @@ sub otherfixupcfg () { if (@pcipt) { logm("checking passthrough device(s) are assignable: @pcipt"); my @assignables= split /\n/, - target_cmd_output_root($ho, toolstack()->{Command}. + target_cmd_output_root($ho, toolstack($ho)->{Command}. " pci-assignable-list"); foreach my $pcipt (@pcipt) { die "not assignable: $pcipt (not in: @assignables)"
ts-debian-hvm-install +2 -2
@@ -41,7 +41,7 @@ our $disk_mb= 10000; our $guesthost= "$gn.guest.osstest"; our $gho; -our $toolstack= toolstack()->{Command}; +our $toolstack= toolstack($ho)->{Command}; sub preseed () {
@@ -171,7 +171,7 @@ sub prep () { # If host has >8G free memory, create a guest with 4G memory to catch # any error that triggers cross 4G boundary -my $host_freemem_mb = host_get_free_memory($ho, $toolstack); +my $host_freemem_mb = host_get_free_memory($ho); my $ram_minslop = 100; my $ram_lots = 5000; if ($host_freemem_mb > $ram_lots * 2 + $ram_minslop) {
ts-guest-localmigrate +1 -1
@@ -33,7 +33,7 @@ our ($ho,$gho) = ts_get_host_guest(@ARGV); sub migrate () { guest_checkrunning($ho,$gho) or die $gho->{Name}; target_cmd_root($ho, - toolstack()->{Command} + toolstack($ho)->{Command} ." migrate $gho->{Name} localhost", $timeout{Migrate}); }
ts-guest-migrate +1 -1
@@ -32,7 +32,7 @@ sub migrate () { guest_checkrunning($sho,$gho) or die $gho->{Name}; my $err= guest_check_ip($gho); die "$err $gho->{Name}" if defined $err; target_cmd_root($sho, - toolstack()->{Command} + toolstack($sho)->{Command} ." migrate $gho->{Name} $dho->{Name}", $timeout{Migrate}); }
ts-guest-saverestore +4 -4
@@ -28,17 +28,17 @@ sub save () { guest_checkrunning($ho,$gho) or die $gho->{Name}; my $err= guest_check_ip($gho); die "$err $gho->{Name}" if defined $err; target_cmd_root($ho, - toolstack()->{Command} + toolstack($ho)->{Command} ." save $gho->{Name} image", 200); target_ping_check_down($gho); } sub restore () { target_cmd_root($ho, - toolstack()->{Command} + toolstack($ho)->{Command} ." restore " - .(toolstack()->{RestoreNeedsConfig} ? - $r{ $gho->{Guest}.'_'. toolstack()->{CfgPathVar} } : '') + .(toolstack($ho)->{RestoreNeedsConfig} ? + $r{ $gho->{Guest}.'_'. toolstack($ho)->{CfgPathVar} } : '') ." image", 200); target_ping_check_up($gho); }
ts-guest-start +2 -2
@@ -26,8 +26,8 @@ our ($ho,$gho) = ts_get_host_guest(@ARGV); sub start () { guest_umount_lv($ho, $gho); - my $cmd= toolstack()->{Command}." create ". - $r{ $gho->{Guest}.'_'. toolstack()->{CfgPathVar} }; + my $cmd= toolstack($ho)->{Command}." create ". + $r{ $gho->{Guest}.'_'. toolstack($ho)->{CfgPathVar} }; target_cmd_root($ho, $cmd, 30); }
ts-guest-stop +1 -1
@@ -27,7 +27,7 @@ our ($ho,$gho) = ts_get_host_guest(@ARGV); sub stop () { guest_checkrunning($ho, $gho) or die "$gho->{Name} not running"; target_cmd_root($ho, - toolstack()->{Command} + toolstack($ho)->{Command} ." shutdown -w " .$gho->{Name}, 200); guest_checkrunning($ho, $gho) and die $gho->{Name};
ts-logs-capture +1 -1
@@ -195,7 +195,7 @@ sub fetch_logs_guest ($) { logm("cannot find domid: $@"); return; } - my $consolecmd= toolstack()->{Command}." console $gho->{Name}"; + my $consolecmd= toolstack($ho)->{Command}." console $gho->{Name}"; try_cmd_output_save("sleep 1 | $consolecmd | cat", "guest-$gho->{Name}-console");
ts-migrate-support-check +2 -2
@@ -25,9 +25,9 @@ tsreadconfig(); our $ho = selecthost($ARGV[0]); # all xend/xm platforms support migration -exit(0) if toolstack()->{Command} eq "xm"; +exit(0) if toolstack($ho)->{Command} eq "xm"; -my $help = target_cmd_output_root($ho, toolstack()->{Command}." help"); +my $help = target_cmd_output_root($ho, toolstack($ho)->{Command}." help"); my $rc = ($help =~ m/^\s*migrate/m) ? 0 : 1;
ts-redhat-install +1 -1
@@ -37,7 +37,7 @@ our $disk_mb= 50000; our $guesthost= "$gn.guest.osstest"; our $gho; -our $xl= toolstack()->{Command}; +our $xl= toolstack($ho)->{Command}; sub kickstart () {
ts-rumpuserxen-demo-xenstorels +2 -2
@@ -40,8 +40,8 @@ sub arrangepreserve () { } sub start () { - my $cmd= toolstack()->{Command}." create ". - $r{ $gho->{Guest}.'_'. toolstack()->{CfgPathVar} }; + my $cmd= toolstack($ho)->{Command}." create ". + $r{ $gho->{Guest}.'_'. toolstack($ho)->{CfgPathVar} }; target_cmd_root($ho, $cmd, 30); $domid = target_cmd_output_root($ho,"xl domid $gho->{Guest}");
ts-windows-install +1 -1
@@ -50,7 +50,7 @@ END } sub start () { - target_cmd_root($ho, toolstack()->{Command}. + target_cmd_root($ho, toolstack($ho)->{Command}. " create $gho->{CfgPath}", 100); }
ts-xen-install +5 -5
@@ -60,8 +60,8 @@ sub packages () { if ($r{arch} eq 'i386') { target_install_packages($ho, 'libc6-xen'); } - target_install_packages($ho, @{toolstack()->{ExtraPackages}}) - if toolstack()->{ExtraPackages}; + target_install_packages($ho, @{toolstack($ho)->{ExtraPackages}}) + if toolstack($ho)->{ExtraPackages}; } sub extract () {
@@ -101,7 +101,7 @@ sub adjustconfig () { } } print EO $extra or die $!; - }) if toolstack()->{Name} eq "xend"; + }) if toolstack($ho)->{Name} eq "xend"; my $trace_config_file; foreach my $try (qw(/etc/default/xencommons
@@ -147,7 +147,7 @@ sub setupboot () { } else { logm("No Xen console device defined for host"); } - if (toolstack()->{Dom0MemFixed}) { + if (toolstack($ho)->{Dom0MemFixed}) { $xenhopt .= " dom0_mem=512M,max:512M"; } my $append= $r{xen_boot_append};
@@ -179,7 +179,7 @@ sub setupboot () { our $initscripts_nobridge; sub setupinitd () { - my $ts= toolstack(); + my $ts= toolstack($ho); my $xencommons= '/etc/init.d/xencommons'; my $have_xencommons= !!target_cmd_output_root($ho, <<END);
Signature · 1 line
2.1.4
PATCH v3 5/19 ts-rumpuserxen-demo-xenstorels: Use standard functions for things
In reply to Ian CampbellSpecifically guest_create and guest_find_domid.
--- ts-rumpuserxen-demo-xenstorels | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
ts-rumpuserxen-demo-xenstorels +2 -4
@@ -40,11 +40,9 @@ sub arrangepreserve () { } sub start () { - my $cmd= toolstack($ho)->{Command}." create ". - $r{ $gho->{Guest}.'_'. toolstack($ho)->{CfgPathVar} }; - target_cmd_root($ho, $cmd, 30); + guest_create($gho,toolstack($ho)); - $domid = target_cmd_output_root($ho,"xl domid $gho->{Guest}"); + $domid = guest_find_domid($ho, $gho); } sub await_end () {
Signature · 1 line
2.1.4
PATCH v3 6/19 Toolstack: use get_host_method_object() to manage toolstack selection
In reply to Ian CampbellThis will allow us to more easily have per-toolstack methods etc.
The previous hash of toolstack parameters is now a blessed object. For now the callers don't need to change but over the following patches we will refactor things to use method calls. In particular we will be aiming to remove Command from the hash and use method calls for everything.
---
v3: Use "use parent" to pull in xl baseline for xend.
--- Osstest/TestSupport.pm | 37 ++++--------------------------------- Osstest/Toolstack/libvirt.pm | 34 ++++++++++++++++++++++++++++++++++ Osstest/Toolstack/xend.pm | 38 ++++++++++++++++++++++++++++++++++++++ Osstest/Toolstack/xl.pm | 35 +++++++++++++++++++++++++++++++++++ 4 files changed, 111 insertions(+), 33 deletions(-) create mode 100644 Osstest/Toolstack/libvirt.pm create mode 100644 Osstest/Toolstack/xend.pm create mode 100644 Osstest/Toolstack/xl.pm
Osstest/TestSupport.pm +4 -33
@@ -1864,42 +1864,13 @@ sub guest_vncsnapshot_stash ($$$$) { target_getfile_root($ho,100, "$rfile", "$stash/$leaf"); } -our %toolstacks= - ('xend' => { - NewDaemons => [qw(xend)], - OldDaemonInitd => 'xend', - Command => 'xm', - CfgPathVar => 'cfgpath', - Dom0MemFixed => 1, - }, - 'xl' => { - NewDaemons => [], - Dom0MemFixed => 1, - Command => 'xl', - CfgPathVar => 'cfgpath', - RestoreNeedsConfig => 1, - }, - 'libvirt' => { - NewDaemons => [qw(libvirtd)], - Dom0MemFixed => 1, - Command => 'virsh', - ExtraPackages => [qw(libnl1 libavahi-client3)], - }, - ); - sub toolstack ($) { my ($ho) = @_; return $ho->{Toolstack} if $ho->{Toolstack}; - my $tsname= $r{toolstack}; - $tsname= 'xend' if !defined $tsname; - my $ts= $toolstacks{$tsname}; - die "$tsname ?" unless defined $ts; - if (!exists $ts->{Name}) { - logm("toolstack $tsname"); - $ts->{Name}= $tsname; - } - $ho->{Toolstack} = $ts; - return $ts; + + my $tsname= $r{toolstack} || 'xend'; + $ho->{Toolstack}= get_host_method_object($ho, 'Toolstack', $tsname); + return $ho->{Toolstack}; } sub authorized_keys () {
Osstest/Toolstack/libvirt.pm new file +34 -0
@@ -0,0 +1,34 @@ +# This is part of "osstest", an automated testing framework for Xen. +# Copyright (C) 2014 Citrix Inc. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + + +package Osstest::Toolstack::libvirt; + +use strict; +use warnings; + +sub new { + my ($class, $ho, $methname,$asset) = @_; + return bless { Name => "libvirt", + Host => $ho, + NewDaemons => [qw(libvirtd)], + Dom0MemFixed => 1, + Command => 'virsh', + ExtraPackages => [qw(libnl1 libavahi-client3)], + }, $class; +} + +1;
Osstest/Toolstack/xend.pm new file +38 -0
@@ -0,0 +1,38 @@ +# This is part of "osstest", an automated testing framework for Xen. +# Copyright (C) 2014 Citrix Inc. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + + +package Osstest::Toolstack::xend; + +use strict; +use warnings; + +# Defer to xl driver for most things +use parent qw(Osstest::Toolstack::xl); + +sub new { + my ($class, $ho, $methname,$asset) = @_; + return bless { Name => "xend", + Host => $ho, + NewDaemons => [qw(xend)], + OldDaemonInitd => 'xend', + Command => 'xm', + CfgPathVar => 'cfgpath', + Dom0MemFixed => 1, + }, $class; +} + +1;
Osstest/Toolstack/xl.pm new file +35 -0
@@ -0,0 +1,35 @@ +# This is part of "osstest", an automated testing framework for Xen. +# Copyright (C) 2014 Citrix Inc. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + + +package Osstest::Toolstack::xl; + +use strict; +use warnings; + +sub new { + my ($class, $ho, $methname,$asset) = @_; + return bless { Name => "xl", + Host => $ho, + NewDaemons => [], + Dom0MemFixed => 1, + Command => 'xl', + CfgPathVar => 'cfgpath', + RestoreNeedsConfig => 1, + }, $class; +} + +1;
Signature · 1 line
2.1.4
PATCH v3 7/19 TestSupport: always use xl for generic operations.
In reply to Ian CampbellUnless the toolstack is xend (for compatibility with pre-xl Xen versions), when we use xm.
For several operations in TestSupport.pm the actual toolstack isn't really relevant, since we want info straight from Xen. For simplicity just use xl (or xm) in these cases, to avoid needing to implement the following specially for each toolstack:
- host_get_free_memory
- guest_get_state
- guest_find_domid
- listing assignable pci devices
---
v3: common_toolstack() takes a $ho and checks if toolstack($ho) is
xend.
--- Osstest/TestSupport.pm | 14 +++++++++++--- ts-debian-fixup | 2 +- 2 files changed, 12 insertions(+), 4 deletions(-)
Osstest/TestSupport.pm +11 -3
@@ -936,6 +936,14 @@ sub compress_stashed($) { #---------- other stuff ---------- +sub common_toolstack ($) { + my ($ho) = @_; + my $tsname = toolstack($ho); + my $ts = 'xl'; + $ts = 'xm' if $tsname eq 'xend'; + return $ts; +} + sub host_reboot ($) { my ($ho) = @_; target_reboot($ho);
@@ -956,7 +964,7 @@ END sub host_get_free_memory($) { my ($ho) = @_; - my $toolstack = toolstack($ho)->{Command}; + my $toolstack = common_toolstack($ho); # The line is as followed: # free_memory : XXXX my $info = target_cmd_output_root($ho, "$toolstack info", 10);
@@ -1612,7 +1620,7 @@ sub guest_check_up ($) { sub guest_get_state ($$) { my ($ho,$gho) = @_; - my $domains= target_cmd_output_root($ho, toolstack($ho)->{Command}." list"); + my $domains= target_cmd_output_root($ho, common_toolstack($ho)." list"); $domains =~ s/^Name.*\n//; foreach my $l (split /\n/, $domains) { $l =~ m/^(\S+) (?: \s+ \d+ ){3} \s+ ([-a-z]+) \s/x or die "$l ?";
@@ -1817,7 +1825,7 @@ sub guest_find_domid ($$) { my ($ho,$gho) = @_; return if defined $gho->{Domid}; my $list= target_cmd_output_root($ho, - toolstack($ho)->{Command}." list $gho->{Name}"); + common_toolstack($ho)." list $gho->{Name}"); $list =~ m/^(?!Name\s)(\S+)\s+(\d+)\s+(\d+)+(\d+)\s.*$/m or die "domain list: $list"; $1 eq $gho->{Name} or die "domain list name $1 expected $gho->{Name}";
ts-debian-fixup +1 -1
@@ -148,7 +148,7 @@ sub otherfixupcfg () { if (@pcipt) { logm("checking passthrough device(s) are assignable: @pcipt"); my @assignables= split /\n/, - target_cmd_output_root($ho, toolstack($ho)->{Command}. + target_cmd_output_root($ho, common_toolstack($ho). " pci-assignable-list"); foreach my $pcipt (@pcipt) { die "not assignable: $pcipt (not in: @assignables)"
Signature · 1 line
2.1.4
Re: [PATCH v3 07/19] TestSupport: always use xl for generic operations.
Ian Campbell writes ("[PATCH v3 07/19] TestSupport: always use xl for generic operations."):
Quoted 2 lines
Unless the toolstack is xend (for compatibility with pre-xl Xen versions), when we use xm.
Quoted 8 lines
For several operations in TestSupport.pm the actual toolstack isn't really relevant, since we want info straight from Xen. For simplicity just use xl (or xm) in these cases, to avoid needing to implement the following specially for each toolstack:
-host_get_free_memory
-guest_get_state
-guest_find_domid
- listing assignable pci devices
I think at the very least "guest_get_state" should be implemented per-toolstack to exercise the toolstack's query functionality. But that's not a blocker for this series.
Ian.
Re: [PATCH v3 07/19] TestSupport: always use xl for generic operations.
Quoted 5 lines · Ian Jackson
Ian Campbell writes ("[PATCH v3 07/19] TestSupport: always use xl for generic operations."):
Quoted 2 lines
Unless the toolstack is xend (for compatibility with pre-xl Xen versions), when we use xm.
Acked-by Ian Jackson <[email protected]>
Thanks.
Quoted 9 lines
Quoted 8 lines
For several operations in TestSupport.pm the actual toolstack isn't really relevant, since we want info straight from Xen. For simplicity just use xl (or xm) in these cases, to avoid needing to implement the following specially for each toolstack:
-host_get_free_memory
-guest_get_state
-guest_find_domid
- listing assignable pci devices
Quoted 3 lines
I think at the very least "
guest_get_state" should be implemented per-toolstack to exercise the toolstack's query functionality. But that's not a blocker for this series.
True. I'll see if I can make that happen for v4.
Ian.
Re: [PATCH v3 07/19] TestSupport: always use xl for generic operations.
Quoted 18 lines · Ian Campbell
Quoted 5 lines · Ian Jackson
Ian Campbell writes ("[PATCH v3 07/19] TestSupport: always use xl for generic operations."):
Quoted 2 lines
Unless the toolstack is xend (for compatibility with pre-xl Xen versions), when we use xm.
Acked-by Ian Jackson <[email protected]>Thanks.
Quoted 9 lines
Quoted 8 lines
For several operations in TestSupport.pm the actual toolstack isn't really relevant, since we want info straight from Xen. For simplicity just use xl (or xm) in these cases, to avoid needing to implement the following specially for each toolstack:
-host_get_free_memory
-guest_get_state
-guest_find_domid
- listing assignable pci devices
Quoted 5 lines
Quoted 3 lines
I think at the very least "
guest_get_state" should be implemented per-toolstack to exercise the toolstack's query functionality. But that's not a blocker for this series.True. I'll see if I can make that happen for v4.
... I didn't.
I've just looked now and I don't see a way to extract the necessary granularity info via virsh needed to replicate the interface which the callers expect. I can just get running or not.
Possibly with some refactoring the callers could be made to ask questions which virsh can answer, but I don't propose to work on that right now.
Ian.
PATCH v3 8/19 TestSupport: guest_create and guest_destroy take only a $gho.
In reply to Ian CampbellThe host can be looked up from $gho->{Host} and the toolstack can be looked up from the host.
---
v3: This replaces "TestSupport: guest_create takes a $ho"
--- Osstest/TestSupport.pm | 12 +++++++----- ts-debian-hvm-install | 9 +++------ ts-guest-destroy | 2 +- ts-guest-destroy-hard | 2 +- ts-redhat-install | 9 +++------ ts-rumpuserxen-demo-xenstorels | 2 +- 6 files changed, 16 insertions(+), 20 deletions(-)
Osstest/TestSupport.pm +7 -5
@@ -1325,14 +1325,16 @@ sub guest_await_shutdown ($$$) { return guest_await_state($ho,$gho, "shutdown", "s", $timeout); } -sub guest_destroy ($$) { - my ($ho,$gho) = @_; +sub guest_destroy ($) { + my ($gho) = @_; + my $ho = $gho->{Host}; target_cmd_root($ho, toolstack($ho)->{Command}." destroy $gho->{Name}", 40); } -sub guest_create ($$) { - my ($gho,$toolstack) = @_; - target_cmd_root($gho->{Host}, "$toolstack create $gho->{CfgPath}", 100); +sub guest_create ($) { + my ($gho) = @_; + my $ho = $gho->{Host}; + target_cmd_root($ho, toolstack($ho)->{Command}." create $gho->{CfgPath}", 100); }
ts-debian-hvm-install +3 -6
@@ -41,9 +41,6 @@ our $disk_mb= 10000; our $guesthost= "$gn.guest.osstest"; our $gho; -our $toolstack= toolstack($ho)->{Command}; - - sub preseed () { my $preseed_file = preseed_base('wheezy','',());
@@ -183,16 +180,16 @@ logm("Host has $host_freemem_mb MB free memory, setting guest memory size to $ra if (!$stage) { prep(); - guest_create($gho,$toolstack); + guest_create($gho); } else { $gho= selectguest($gn,$gho); } if ($stage<2) { guest_await_reboot($ho,$gho,2000); - guest_destroy($ho,$gho); + guest_destroy($gho); } guest_editconfig_nocd($gho,$emptyiso); -guest_create($gho,$toolstack); +guest_create($gho); guest_await_dhcp_tcp($gho,300); guest_check_up($gho);
ts-guest-destroy +1 -1
@@ -25,7 +25,7 @@ tsreadconfig(); our ($ho,$gho) = ts_get_host_guest(@ARGV); sub destroy () { - guest_destroy($ho, $gho); + guest_destroy($gho); guest_checkrunning($ho, $gho) and die $gho->{Name}; }
ts-guest-destroy-hard +1 -1
@@ -24,4 +24,4 @@ tsreadconfig(); our ($ho,$gho) = ts_get_host_guest(@ARGV); -guest_destroy($ho, $gho); +guest_destroy($gho);
ts-redhat-install +3 -6
@@ -37,9 +37,6 @@ our $disk_mb= 50000; our $guesthost= "$gn.guest.osstest"; our $gho; -our $xl= toolstack($ho)->{Command}; - - sub kickstart () { my $cryptpw= '$6$anjRJmBbJcrNJGWN$rqvGUhu8ITjvErdIA5C//w2R6b/6wAjHbaF7XF8u3lZg1XI3StthPIE6UII08scOFwASMOepCGpgtsYeCpjqb.'; my $authkeys= authorized_keys();
@@ -152,16 +149,16 @@ sub prep () { if (!$stage) { prep(); - guest_create($gho,$xl); + guest_create($gho); } else { $gho= selectguest($gn,$gho); } if ($stage<2) { guest_await_reboot($ho,$gho,2000); - guest_destroy($ho,$gho); + guest_destroy($gho); } guest_editconfig_nocd($gho,$emptyiso); -guest_create($gho,$xl); +guest_create($gho); guest_await_dhcp_tcp($gho,300); guest_check_up($gho);
ts-rumpuserxen-demo-xenstorels +1 -1
@@ -40,7 +40,7 @@ sub arrangepreserve () { } sub start () { - guest_create($gho,toolstack($ho)); + guest_create($gho); $domid = guest_find_domid($ho, $gho); }
Signature · 1 line
2.1.4
Re: [PATCH v3 08/19] TestSupport: guest_create and guest_destroy take only a $gho.
Ian Campbell writes ("[PATCH v3 08/19] TestSupport: guest_create and guest_destroy take only a $gho."):
Quoted 4 lines
The host can be looked up from $gho->{Host} and the toolstack can be looked up from the host.
Signed-off-by Ian Campbell <[email protected]>
PATCH v3 9/19 Toolstack: Refactor guest lifecycle.
In reply to Ian CampbellImplement destory/create as per toolstack methods, including implementing the libvirt version which previously didn't work. To do this we use the virsh capability to convert an xl/xm style config file into the correct XML.
xend basically calls into the xl helper since they are compatible.
xl/xm, uses ->{Command} which will eventually become private.
---
v3: Rebased of prototype changes to guest_create/destroy (only $gho)
Use xen-xl format to domxml-from-native rather than xen-xm Moved spurious change in ts-save-restore to correct home later in the series.
Suggested switch to passing $gho to ->start has been deferred to a new patch towards the end of the series
--- Osstest/TestSupport.pm | 4 ++-- Osstest/Toolstack/libvirt.pm | 20 ++++++++++++++++++++ Osstest/Toolstack/xl.pm | 13 +++++++++++++ ts-guest-start | 4 +--- ts-windows-install | 7 +------ 5 files changed, 37 insertions(+), 11 deletions(-)
Osstest/TestSupport.pm +2 -2
@@ -1328,13 +1328,13 @@ sub guest_await_shutdown ($$$) { sub guest_destroy ($) { my ($gho) = @_; my $ho = $gho->{Host}; - target_cmd_root($ho, toolstack($ho)->{Command}." destroy $gho->{Name}", 40); + toolstack($ho)->destroy($gho); } sub guest_create ($) { my ($gho) = @_; my $ho = $gho->{Host}; - target_cmd_root($ho, toolstack($ho)->{Command}." create $gho->{CfgPath}", 100); + toolstack($ho)->create($gho->{CfgPath}); }
Osstest/Toolstack/libvirt.pm +20 -0
@@ -20,15 +20,35 @@ package Osstest::Toolstack::libvirt; use strict; use warnings; +use Osstest::TestSupport; + sub new { my ($class, $ho, $methname,$asset) = @_; return bless { Name => "libvirt", Host => $ho, NewDaemons => [qw(libvirtd)], Dom0MemFixed => 1, + CfgPathVar => 'cfgpath', Command => 'virsh', ExtraPackages => [qw(libnl1 libavahi-client3)], }, $class; } +sub destroy ($$) { + my ($self,$gho) = @_; + my $gn = $gho->{Name}; + target_cmd_root($self->{Host}, "virsh destroy $gn", 40); +} + +sub create ($$) { + my ($self,$cfg) = @_; + my $ho = $self->{Host}; + my $lcfg = $cfg; + $lcfg =~ s,/,-,g; + $lcfg = "$ho->{Name}--$lcfg"; + target_cmd_root($ho, "virsh domxml-from-native xen-xl $cfg > $cfg.xml", 30); + target_getfile_root($ho,60,"$cfg.xml", "$stash/$lcfg"); + target_cmd_root($ho, "virsh create --file $cfg.xml", 100); +} + 1;
Osstest/Toolstack/xl.pm +13 -0
@@ -20,6 +20,8 @@ package Osstest::Toolstack::xl; use strict; use warnings; +use Osstest::TestSupport; + sub new { my ($class, $ho, $methname,$asset) = @_; return bless { Name => "xl",
@@ -32,4 +34,15 @@ sub new { }, $class; } +sub destroy ($$) { + my ($self,$gho) = @_; + my $gn = $gho->{Name}; + target_cmd_root($self->{Host}, $self->{Command}." destroy $gn", 40); +} + +sub create ($$) { + my ($self,$cfg) = @_; + target_cmd_root($self->{Host}, $self->{Command}." create $cfg", 100); +} + 1;
ts-guest-start +1 -3
@@ -26,9 +26,7 @@ our ($ho,$gho) = ts_get_host_guest(@ARGV); sub start () { guest_umount_lv($ho, $gho); - my $cmd= toolstack($ho)->{Command}." create ". - $r{ $gho->{Guest}.'_'. toolstack($ho)->{CfgPathVar} }; - target_cmd_root($ho, $cmd, 30); + toolstack($ho)->create($r{ $gho->{Guest}.'_'. toolstack($ho)->{CfgPathVar} }); } sub checkstart () {
ts-windows-install +1 -6
@@ -49,13 +49,8 @@ END store_runvar("$gho->{Guest}_pingbroken", 1); } -sub start () { - target_cmd_root($ho, toolstack($ho)->{Command}. - " create $gho->{CfgPath}", 100); -} - prep(); -start(); +guest_create($gho); guest_await_dhcp_tcp($gho,7000); guest_check_up($gho);
Signature · 1 line
2.1.4
Re: [PATCH v3 09/19] Toolstack: Refactor guest lifecycle.
Ian Campbell writes ("[PATCH v3 09/19] Toolstack: Refactor guest lifecycle."):
Quoted 4 lines
Implement destory/create as per toolstack methods, including implementing the libvirt version which previously didn't work. To do this we use the virsh capability to convert an xl/xm style config file into the correct XML.
PATCH v3 10/19 Toolstack: Refactor consolecmd handling
In reply to Ian Campbell--- Osstest/Toolstack/libvirt.pm | 6 ++++++ Osstest/Toolstack/xl.pm | 6 ++++++ ts-logs-capture | 2 +- 3 files changed, 13 insertions(+), 1 deletion(-)
Osstest/Toolstack/libvirt.pm +6 -0
@@ -51,4 +51,10 @@ sub create ($$) { target_cmd_root($ho, "virsh create --file $cfg.xml", 100); } +sub consolecmd ($$) { + my ($self,$gho) = @_; + my $gn = $gho->{Name}; + return "virsh console $gn"; +} + 1;
Osstest/Toolstack/xl.pm +6 -0
@@ -45,4 +45,10 @@ sub create ($$) { target_cmd_root($self->{Host}, $self->{Command}." create $cfg", 100); } +sub consolecmd ($$) { + my ($self,$gho) = @_; + my $gn = $gho->{Name}; + return $self->{Command}." console $gn"; +} + 1;
ts-logs-capture +1 -1
@@ -195,7 +195,7 @@ sub fetch_logs_guest ($) { logm("cannot find domid: $@"); return; } - my $consolecmd= toolstack($ho)->{Command}." console $gho->{Name}"; + my $consolecmd= toolstack($ho)->consolecmd($gho); try_cmd_output_save("sleep 1 | $consolecmd | cat", "guest-$gho->{Name}-console");
Signature · 1 line
2.1.4
Re: [PATCH v3 10/19] Toolstack: Refactor consolecmd handling
Ian Campbell writes ("[PATCH v3 10/19] Toolstack: Refactor consolecmd handling"):
Quoted 1 line
Signed-off-by Ian Campbell <[email protected]>
PATCH v3 11/19 Toolstack: Refactor shutdown support
In reply to Ian Campbell---
v3: Timeout is set in the caller, not the method handler. "Different
guests might take different times to shut down - but different toolstacks shouldn't."
--- Osstest/Toolstack/libvirt.pm | 6 ++++++ Osstest/Toolstack/xl.pm | 7 +++++++ ts-guest-stop | 5 +---- 3 files changed, 14 insertions(+), 4 deletions(-)
Osstest/Toolstack/libvirt.pm +6 -0
@@ -57,4 +57,10 @@ sub consolecmd ($$) { return "virsh console $gn"; } +sub shutdown_wait ($$$) { + my ($self,$gho,$timeout) = @_; + my $gn = $gho->{Name}; + die "libvirt shutdown wait not implemented yet." +} + 1;
Osstest/Toolstack/xl.pm +7 -0
@@ -51,4 +51,11 @@ sub consolecmd ($$) { return $self->{Command}." console $gn"; } +sub shutdown_wait ($$$) { + my ($self,$gho,$timeout) = @_; + my $ho = $self->{Host}; + my $gn = $gho->{Name}; + target_cmd_root($ho,"$self->{Command} shutdown -w $gn", $timeout); +} + 1;
ts-guest-stop +1 -4
@@ -26,10 +26,7 @@ our ($ho,$gho) = ts_get_host_guest(@ARGV); sub stop () { guest_checkrunning($ho, $gho) or die "$gho->{Name} not running"; - target_cmd_root($ho, - toolstack($ho)->{Command} - ." shutdown -w " - .$gho->{Name}, 200); + toolstack($ho)->shutdown_wait($gho, 200); guest_checkrunning($ho, $gho) and die $gho->{Name}; }
Signature · 1 line
2.1.4
Re: [PATCH v3 11/19] Toolstack: Refactor shutdown support
Ian Campbell writes ("[PATCH v3 11/19] Toolstack: Refactor shutdown support"):
Quoted 5 lines
Signed-off-by Ian Campbell <[email protected]>---
v3: Timeout is set in the caller, not the method handler. "Different
guests might take different times to shut down - but different toolstacks shouldn't."
PATCH v3 12/19 Toolstack: Refactor migration support check.
In reply to Ian CampbellNot implemented for libvirt (the check itself that is, the hook is present).
--- Osstest/Toolstack/libvirt.pm | 5 +++++ Osstest/Toolstack/xend.pm | 3 +++ Osstest/Toolstack/xl.pm | 9 +++++++++ ts-migrate-support-check | 10 +--------- 4 files changed, 18 insertions(+), 9 deletions(-)
Osstest/Toolstack/libvirt.pm +5 -0
@@ -63,4 +63,9 @@ sub shutdown_wait ($$$) { die "libvirt shutdown wait not implemented yet." } +sub migrate_check ($) { + my ($self) = @_; + die "Migration check is not yet supported on libvirt."; +} + 1;
Osstest/Toolstack/xend.pm +3 -0
@@ -35,4 +35,7 @@ sub new { }, $class; } +# xend always supported migration +sub migrate_check ($) { return 0; } + 1;
Osstest/Toolstack/xl.pm +9 -0
@@ -58,4 +58,13 @@ sub shutdown_wait ($$$) { target_cmd_root($ho,"$self->{Command} shutdown -w $gn", $timeout); } +sub migrate_check ($) { + my ($self) = @_; + my $ho = $self->{Host}; + my $help = target_cmd_output_root($ho, $self->{Command}." help"); + my $rc = ($help =~ m/^\s*migrate/m) ? 0 : 1; + logm("rc=$rc"); + return $rc; +} + 1;
ts-migrate-support-check +1 -9
@@ -24,12 +24,4 @@ tsreadconfig(); our $ho = selecthost($ARGV[0]); -# all xend/xm platforms support migration -exit(0) if toolstack($ho)->{Command} eq "xm"; - -my $help = target_cmd_output_root($ho, toolstack($ho)->{Command}." help"); - -my $rc = ($help =~ m/^\s*migrate/m) ? 0 : 1; - -logm("rc=$rc"); -exit($rc); +exit(toolstack($ho)->migrate_check());
Signature · 1 line
2.1.4
PATCH v3 13/19 Toolstack: Refactor migration support.
In reply to Ian CampbellNote that since the previous patch arranges for ts-migration-support-check to continue to fail for libvirt the libvirt code is not actually called yet (and will die if it is). This patch is mainly included to reduce the number of users of toolstack()->{Command} closer to zero.
---
v3: Pass a $ho object as the destination, rather than it's name.
--- Osstest/Toolstack/libvirt.pm | 5 +++++ Osstest/Toolstack/xl.pm | 10 ++++++++++ ts-guest-localmigrate | 6 ++---- ts-guest-migrate | 5 +---- 4 files changed, 18 insertions(+), 8 deletions(-)
Osstest/Toolstack/libvirt.pm +5 -0
@@ -68,4 +68,9 @@ sub migrate_check ($) { die "Migration check is not yet supported on libvirt."; } +sub migrate ($) { + my ($self,$gho,$dst,$timeout) = @_; + die "Migration is not yet supported on libvirt."; +} + 1;
Osstest/Toolstack/xl.pm +10 -0
@@ -67,4 +67,14 @@ sub migrate_check ($) { return $rc; } +sub migrate ($$$$) { + my ($self,$gho,$dho,$timeout) = @_; + my $sho = $self->{Host}; + my $dst = $dho->{Name}; + my $gn = $gho->{Name}; + target_cmd_root($sho, + $self->{Command}." migrate $gn $dst", + $timeout); +} + 1;
ts-guest-localmigrate +2 -4
@@ -32,10 +32,8 @@ our ($ho,$gho) = ts_get_host_guest(@ARGV); sub migrate () { guest_checkrunning($ho,$gho) or die $gho->{Name}; - target_cmd_root($ho, - toolstack($ho)->{Command} - ." migrate $gho->{Name} localhost", - $timeout{Migrate}); + # Migrate to same host, via localhost interface. + toolstack($ho)->migrate($gho, { %$ho, Name => "localhost" }, $timeout{Migrate}); } guest_await_dhcp_tcp($gho, 5);
ts-guest-migrate +1 -4
@@ -31,10 +31,7 @@ our $gho = selectguest($ARGV[2],$sho); sub migrate () { guest_checkrunning($sho,$gho) or die $gho->{Name}; my $err= guest_check_ip($gho); die "$err $gho->{Name}" if defined $err; - target_cmd_root($sho, - toolstack($sho)->{Command} - ." migrate $gho->{Name} $dho->{Name}", - $timeout{Migrate}); + toolstack($sho)->migrate($gho, $dho, $timeout{Migrate}); } guest_await_dhcp_tcp($gho, 5);
Signature · 1 line
2.1.4
Re: [PATCH v3 13/19] Toolstack: Refactor migration support.
Ian Campbell writes ("[PATCH v3 13/19] Toolstack: Refactor migration support."):
Quoted 5 lines
Note that since the previous patch arranges for ts-migration-support-check to continue to fail for libvirt the libvirt code is not actually called yet (and will die if it is). This patch is mainly included to reduce the number of users of toolstack()->{Command} closer to zero.
...
Quoted 2 lines
+++ b/ts-guest-localmigrate
(quoted diff) +0
-0@@ -32,10 +32,8 @@ our ($ho,$gho) = ts_get_host_guest(@ARGV);
...
ts-guest-localmigrate our ($ho,$gho) = ts_get_host_guest(@ARGV); · line 36
Quoted 2 lines
ts-guest-localmigrate +2
-0+ # Migrate to same host, via localhost interface. + toolstack($ho)->migrate($gho, { %$ho, Name => "localhost" }, $timeout{Migrate});
Can you wrap this line please ? With that done,
Thanks,
Ian.
PATCH v3 14/19 Toolstack: Refactor save/restore support
In reply to Ian CampbellUse $gho->{CfgPath} rather than constructing it again.
Still stubbed out for libvirt.
---
v3: Switch to CfgPath defered from incorrect home in earlier patch to
here.
RestoreNeedsConfig is an xl/xm ism, not relevant to libvirt, so remove $cfg parameter from restore method.
--- Osstest/Toolstack/libvirt.pm | 10 ++++++++++ Osstest/Toolstack/xl.pm | 19 +++++++++++++++++++ ts-guest-saverestore | 12 ++---------- 3 files changed, 31 insertions(+), 10 deletions(-)
Osstest/Toolstack/libvirt.pm +10 -0
@@ -73,4 +73,14 @@ sub migrate ($) { die "Migration is not yet supported on libvirt."; } +sub save ($$$$) { + my ($self,$gho,$f,$timeout) = @_; + die "Save is not yet supported on libvirt."; +} + +sub restore ($$$$) { + my ($self,$gho,$f,$timeout) = @_; + die "Restore is not yet supported on libvirt."; +} + 1;
Osstest/Toolstack/xl.pm +19 -0
@@ -77,4 +77,23 @@ sub migrate ($$$$) { $timeout); } +sub save ($$$$) { + my ($self,$gho,$f,$timeout) = @_; + my $ho = $self->{Host}; + my $gn = $gho->{Name}; + target_cmd_root($ho,$self->{Command}." save $gn $f", $timeout); +} + +sub restore ($$$$) { + my ($self,$gho,$f,$timeout) = @_; + my $ho = $self->{Host}; + my $gn = $gho->{Name}; + my $cfg = $self->{RestoreNeedsConfig} ? $gho->{CfgPath} : ''; + target_cmd_root($ho, + $self->{Command} + ." restore " + .$cfg + ." $f", $timeout); +} + 1;
ts-guest-saverestore +2 -10
@@ -27,19 +27,11 @@ our ($ho,$gho) = ts_get_host_guest(@ARGV); sub save () { guest_checkrunning($ho,$gho) or die $gho->{Name}; my $err= guest_check_ip($gho); die "$err $gho->{Name}" if defined $err; - target_cmd_root($ho, - toolstack($ho)->{Command} - ." save $gho->{Name} image", - 200); + toolstack($ho)->save($gho,"image",200); target_ping_check_down($gho); } sub restore () { - target_cmd_root($ho, - toolstack($ho)->{Command} - ." restore " - .(toolstack($ho)->{RestoreNeedsConfig} ? - $r{ $gho->{Guest}.'_'. toolstack($ho)->{CfgPathVar} } : '') - ." image", 200); + toolstack($ho)->restore($gho,"image", 200); target_ping_check_up($gho); }
Signature · 1 line
2.1.4
Re: [PATCH v3 14/19] Toolstack: Refactor save/restore support
Ian Campbell writes ("[PATCH v3 14/19] Toolstack: Refactor save/restore support"):
Quoted 3 lines
Use $gho->{CfgPath} rather than constructing it again.
Still stubbed out for libvirt.
PATCH v3 15/19 libvirt: Implement initscript restart which has some hope of working.
In reply to Ian Campbell... by refactoring start/stop actions into the functions which are expected by restart.
---
v3: Refactor into start/stop functions
--- ts-libvirt-build | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-)
ts-libvirt-build +15 -5
@@ -128,22 +128,32 @@ test -x $DAEMON || exit 0 PIDFILE=/var/run/$NAME.pid +start() { + start-stop-daemon --start --pidfile $PIDFILE \ + --exec $DAEMON $@ -- -d $libvirtd_opts +} + +stop() { + start-stop-daemon --stop --pidfile $PIDFILE \ + --exec $DAEMON $@ +} + case "$1" in start) [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME" - start-stop-daemon --start --pidfile $PIDFILE \ - --exec $DAEMON -- -d $libvirtd_opts + start [ "$VERBOSE" != no ] && log_end_msg $? ;; stop) [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME" - start-stop-daemon --stop --pidfile $PIDFILE \ - --exec $DAEMON + stop [ "$VERBOSE" != no ] && log_end_msg $? ;; restart) - stop + [ "$VERBOSE" != no ] && log_daemon_msg "Restarting $DESC" "$DAEMON" + stop --oknodo start + [ "$VERBOSE" != no ] && log_end_msg $? ;; reload|force-reload) start-stop-daemon --stop --signal 1 --quiet --pidfile \
Signature · 1 line
2.1.4
Re: [PATCH v3 15/19] libvirt: Implement initscript restart which has some hope of working.
Ian Campbell writes ("[PATCH v3 15/19] libvirt: Implement initscript restart which has some hope of working."):
Quoted 2 lines
... by refactoring start/stop actions into the functions which are expected by restart.
PATCH v3 16/19 libvirt: Implement shutdown_wait
In reply to Ian Campbellvirsh does not include a --wait option to shutdown as xl and xm do, so we implement it by hand.
Needs new guest_await_destroy helper. Note the guest_await_shutdown requires on_shutdown='preserve'
---
v3: Drop $ho parameter frm guest_await_destroy, for consistency with
changes to guest_destroy.
--- Osstest/TestSupport.pm | 8 +++++++- Osstest/Toolstack/libvirt.pm | 4 +++- 2 files changed, 10 insertions(+), 2 deletions(-)
Osstest/TestSupport.pm +7 -1
@@ -93,7 +93,7 @@ BEGIN { guest_checkrunning guest_check_ip guest_find_ether guest_find_domid guest_check_up guest_check_up_quick guest_get_state guest_await_reboot - guest_await_shutdown guest_destroy + guest_await_shutdown guest_await_destroy guest_destroy guest_vncsnapshot_begin guest_vncsnapshot_stash guest_check_remus_ok guest_editconfig host_involves_pcipassthrough host_get_pcipassthrough_devs
@@ -1331,6 +1331,12 @@ sub guest_destroy ($) { toolstack($ho)->destroy($gho); } +sub guest_await_destroy ($$) { + my ($gho, $timeout) = @_; + my $ho = $gho->{Host}; + return guest_await_state($ho,$gho, "destroy", "", $timeout); +} + sub guest_create ($) { my ($gho) = @_; my $ho = $gho->{Host};
Osstest/Toolstack/libvirt.pm +3 -1
@@ -59,8 +59,10 @@ sub consolecmd ($$) { sub shutdown_wait ($$$) { my ($self,$gho,$timeout) = @_; + my $ho = $self->{Host}; my $gn = $gho->{Name}; - die "libvirt shutdown wait not implemented yet." + target_cmd_root($ho, "virsh shutdown $gn", 30); + guest_await_destroy($gho,$timeout); } sub migrate_check ($) {
Signature · 1 line
2.1.4
PATCH v3 17/19 Toolstack: Remove Command field for all toolstacks.
In reply to Ian CampbellNothing in generic code uses this now, so remove.
xl+xend retain as _Command for internal use only.
--- Osstest/Toolstack/libvirt.pm | 1 - Osstest/Toolstack/xend.pm | 2 +- Osstest/Toolstack/xl.pm | 18 +++++++++--------- 3 files changed, 10 insertions(+), 11 deletions(-)
Osstest/Toolstack/libvirt.pm +0 -1
@@ -29,7 +29,6 @@ sub new { NewDaemons => [qw(libvirtd)], Dom0MemFixed => 1, CfgPathVar => 'cfgpath', - Command => 'virsh', ExtraPackages => [qw(libnl1 libavahi-client3)], }, $class; }
Osstest/Toolstack/xend.pm +1 -1
@@ -29,7 +29,7 @@ sub new { Host => $ho, NewDaemons => [qw(xend)], OldDaemonInitd => 'xend', - Command => 'xm', + _Command => 'xm', CfgPathVar => 'cfgpath', Dom0MemFixed => 1, }, $class;
Osstest/Toolstack/xl.pm +9 -9
@@ -28,7 +28,7 @@ sub new { Host => $ho, NewDaemons => [], Dom0MemFixed => 1, - Command => 'xl', + _Command => 'xl', CfgPathVar => 'cfgpath', RestoreNeedsConfig => 1, }, $class;
@@ -37,31 +37,31 @@ sub new { sub destroy ($$) { my ($self,$gho) = @_; my $gn = $gho->{Name}; - target_cmd_root($self->{Host}, $self->{Command}." destroy $gn", 40); + target_cmd_root($self->{Host}, $self->{_Command}." destroy $gn", 40); } sub create ($$) { my ($self,$cfg) = @_; - target_cmd_root($self->{Host}, $self->{Command}." create $cfg", 100); + target_cmd_root($self->{Host}, $self->{_Command}." create $cfg", 100); } sub consolecmd ($$) { my ($self,$gho) = @_; my $gn = $gho->{Name}; - return $self->{Command}." console $gn"; + return $self->{_Command}." console $gn"; } sub shutdown_wait ($$$) { my ($self,$gho,$timeout) = @_; my $ho = $self->{Host}; my $gn = $gho->{Name}; - target_cmd_root($ho,"$self->{Command} shutdown -w $gn", $timeout); + target_cmd_root($ho,"$self->{_Command} shutdown -w $gn", $timeout); } sub migrate_check ($) { my ($self) = @_; my $ho = $self->{Host}; - my $help = target_cmd_output_root($ho, $self->{Command}." help"); + my $help = target_cmd_output_root($ho, $self->{_Command}." help"); my $rc = ($help =~ m/^\s*migrate/m) ? 0 : 1; logm("rc=$rc"); return $rc;
@@ -73,7 +73,7 @@ sub migrate ($$$$) { my $dst = $dho->{Name}; my $gn = $gho->{Name}; target_cmd_root($sho, - $self->{Command}." migrate $gn $dst", + $self->{_Command}." migrate $gn $dst", $timeout); }
@@ -81,7 +81,7 @@ sub save ($$$$) { my ($self,$gho,$f,$timeout) = @_; my $ho = $self->{Host}; my $gn = $gho->{Name}; - target_cmd_root($ho,$self->{Command}." save $gn $f", $timeout); + target_cmd_root($ho,$self->{_Command}." save $gn $f", $timeout); } sub restore ($$$$) {
@@ -90,7 +90,7 @@ sub restore ($$$$) { my $gn = $gho->{Name}; my $cfg = $self->{RestoreNeedsConfig} ? $gho->{CfgPath} : ''; target_cmd_root($ho, - $self->{Command} + $self->{_Command} ." restore " .$cfg ." $f", $timeout);
Signature · 1 line
2.1.4
PATCH v3 18/19 ts-guest-start: Use guest_create
In reply to Ian CampbellThis allows us to abolish CfgPathVar which was inconsistently used, appears redundant with $gho->{CfgPath} and in any case never set to anything other than 'cfgpath'.
I suppose it was intended to deal with toolstacks with a cfg format completely dissimilar to xm/xl's. I think if this arises in a future toolstack this functionality could be reintroduced pretty trivially via the toolstack abstraction which is added by this series.
---
v3: Adjust for dropping $ho param to guest_create
--- Osstest/Toolstack/libvirt.pm | 1 - Osstest/Toolstack/xend.pm | 1 - Osstest/Toolstack/xl.pm | 1 - ts-guest-start | 2 +- 4 files changed, 1 insertion(+), 4 deletions(-)
Osstest/Toolstack/libvirt.pm +0 -1
@@ -28,7 +28,6 @@ sub new { Host => $ho, NewDaemons => [qw(libvirtd)], Dom0MemFixed => 1, - CfgPathVar => 'cfgpath', ExtraPackages => [qw(libnl1 libavahi-client3)], }, $class; }
Osstest/Toolstack/xend.pm +0 -1
@@ -30,7 +30,6 @@ sub new { NewDaemons => [qw(xend)], OldDaemonInitd => 'xend', _Command => 'xm', - CfgPathVar => 'cfgpath', Dom0MemFixed => 1, }, $class; }
Osstest/Toolstack/xl.pm +0 -1
@@ -29,7 +29,6 @@ sub new { NewDaemons => [], Dom0MemFixed => 1, _Command => 'xl', - CfgPathVar => 'cfgpath', RestoreNeedsConfig => 1, }, $class; }
ts-guest-start +1 -1
@@ -26,7 +26,7 @@ our ($ho,$gho) = ts_get_host_guest(@ARGV); sub start () { guest_umount_lv($ho, $gho); - toolstack($ho)->create($r{ $gho->{Guest}.'_'. toolstack($ho)->{CfgPathVar} }); + guest_create($gho); } sub checkstart () {
Signature · 1 line
2.1.4
Re: [PATCH v3 18/19] ts-guest-start: Use guest_create
Ian Campbell writes ("[PATCH v3 18/19] ts-guest-start: Use guest_create"):
Quoted 4 lines
I suppose it was intended to deal with toolstacks with a cfg format completely dissimilar to xm/xl's. I think if this arises in a future toolstack this functionality could be reintroduced pretty trivially via the toolstack abstraction which is added by this series.
It was intended to deal with precisely that. Early versions of xl did not understand xm config files as generated by Debian's xen-create-image, so they had to be converted.
Ian.
Re: [PATCH v3 18/19] ts-guest-start: Use guest_create
Quoted 9 lines · Ian Jackson
Ian Campbell writes ("[PATCH v3 18/19] ts-guest-start: Use
guest_create"):Quoted 4 lines
I suppose it was intended to deal with toolstacks with a cfg format completely dissimilar to xm/xl's. I think if this arises in a future toolstack this functionality could be reintroduced pretty trivially via the toolstack abstraction which is added by this series.
It was intended to deal with precisely that. Early versions of xl did not understand xm config files as generated by Debian's xen-create-image, so they had to be converted.
I think you told me that last time too and I just forgot to update the changelog, sorry.
I shall replace the first sentence with "This was intended to deal with toolstacks with a different cfg format (such as very early versions of xl) but is no longer relevant".
Ian.
PATCH v3 19/19 Toolstack: Pass $gho to create method
In reply to Ian CampbellThe cfg file can be obtained from $gho->{CfgPath}. This is more consistent with other methods.
---
v3: New patch, implementing suggesting from review of "Toolstack:
Refactor guest lifecycle."
--- Osstest/TestSupport.pm | 2 +- Osstest/Toolstack/libvirt.pm | 3 ++- Osstest/Toolstack/xl.pm | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-)
Osstest/TestSupport.pm +1 -1
@@ -1340,7 +1340,7 @@ sub guest_await_destroy ($$) { sub guest_create ($) { my ($gho) = @_; my $ho = $gho->{Host}; - toolstack($ho)->create($gho->{CfgPath}); + toolstack($ho)->create($gho); }
Osstest/Toolstack/libvirt.pm +2 -1
@@ -39,8 +39,9 @@ sub destroy ($$) { } sub create ($$) { - my ($self,$cfg) = @_; + my ($self,$gho) = @_; my $ho = $self->{Host}; + my $cfg = $gho->{CfgPath}; my $lcfg = $cfg; $lcfg =~ s,/,-,g; $lcfg = "$ho->{Name}--$lcfg";
Osstest/Toolstack/xl.pm +2 -1
@@ -40,7 +40,8 @@ sub destroy ($$) { } sub create ($$) { - my ($self,$cfg) = @_; + my ($self,$gho) = @_; + my $cfg = $gho->{CfgPath}; target_cmd_root($self->{Host}, $self->{_Command}." create $cfg", 100); }
Signature · 1 line
2.1.4
Re: [PATCH v3 19/19] Toolstack: Pass $gho to create method
Ian Campbell writes ("[PATCH v3 19/19] Toolstack: Pass $gho to create method"):
Quoted 2 lines
The cfg file can be obtained from $gho->{CfgPath}. This is more consistent with other methods.
Quoted 1 line · Ian Campbell
Since last time I've addressed all of Ian's review on v2.
You have now acked all of this series. I don't think it needs a resend for the minor changes you asked for.
Once the series which supports the new ARM hardware passes the push gate are you OK with this going in the next batch?
Ian.
Ian Campbell writes ("Re: [Xen-devel] [PATCH v3 OSSTEST 0/19] Implement for driving libvirt via virsh"):
Quoted 8 lines · Ian Campbell
Quoted 1 line
Since last time I've addressed all of Ian's review on v2.
You have now acked all of this series. I don't think it needs a resend for the minor changes you asked for.
Once the series which supports the new ARM hardware passes the push gate are you OK with this going in the next batch?
Yes. Would you care to pick up my short linux-3.16 series too ?
I've pushed it to
xenbits.xen.org:/home/iwj/ext/osstest.git#wip.branch-setup
and you can rebase it as appropriate.
Thanks,
Ian.
Quoted 11 lines · Ian Jackson
Ian Campbell writes ("Re: [Xen-devel] [PATCH v3 OSSTEST 0/19] Implement for driving libvirt via virsh"):
Quoted 8 lines · Ian Campbell
Quoted 1 line
Since last time I've addressed all of Ian's review on v2.
You have now acked all of this series. I don't think it needs a resend for the minor changes you asked for.
Once the series which supports the new ARM hardware passes the push gate are you OK with this going in the next batch?
Yes. Would you care to pick up my short linux-3.16 series too ?
Sure.
Is there anything else lurking around? What about Wei's XSM stuff?
Quoted 7 lines
I've pushed it to
xenbits.xen.org:/home/iwj/ext/osstest.git#wip.branch-setup
and you can rebase it as appropriate.Thanks,
Ian.
Ian Campbell writes ("Re: [Xen-devel] [PATCH v3 OSSTEST 0/19] Implement for driving libvirt via virsh"):
Quoted 6 lines · Ian Jackson
Quoted 1 line
Yes. Would you care to pick up my short linux-3.16 series too ?
Sure.
Is there anything else lurking around? What about Wei's XSM stuff?
That's a whole series and is awaiting a review from me.
Ian.