Message ID | 1403018809-25509-6-git-send-email-ian.campbell@citrix.com |
---|---|
State | New |
Headers | show |
On mar, 2014-06-17 at 16:26 +0100, Ian Campbell wrote: > 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. > > xend basically calls into the xl helper since they are compatible. > > Signed-off-by: Ian Campbell <ian.campbell@citrix.com> > --- > +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-xm $cfg > $cfg.xml", 30); > + target_getfile_root($ho,60,"$cfg.xml", "$stash/$lcfg"); > + target_cmd_root($ho, "virsh create --file $cfg.xml", 100); > +} > + I agree that domxml-from-native would be the best thing to do here. However, we need to double check how well it works, and probably commit to improve that, as, last time I checked, it was doing a pretty poor job. :-( Jim, what's the status of that thing? Dario
On Tue, 2014-06-17 at 18:45 +0200, Dario Faggioli wrote: > On mar, 2014-06-17 at 16:26 +0100, Ian Campbell wrote: > > 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. > > > > xend basically calls into the xl helper since they are compatible. > > > > Signed-off-by: Ian Campbell <ian.campbell@citrix.com> > > --- > > > +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-xm $cfg > $cfg.xml", 30); > > + target_getfile_root($ho,60,"$cfg.xml", "$stash/$lcfg"); > > + target_cmd_root($ho, "virsh create --file $cfg.xml", 100); > > +} > > + > I agree that domxml-from-native would be the best thing to do here. > > However, we need to double check how well it works, and probably commit > to improve that, as, last time I checked, it was doing a pretty poor > job. :-( > > Jim, what's the status of that thing? It worked well enough for osstest to start a guest with its usual config, with the libvirt bugfix I sent out a few hours ago. But the whole point of the tests is to find bugs, so I don't see the fact that this may or may not be buggy as a reason for osstest not to use it. If that shows that it is buggy then we should fix it. Ian.
Ian Campbell wrote: > On Tue, 2014-06-17 at 18:45 +0200, Dario Faggioli wrote: > >> On mar, 2014-06-17 at 16:26 +0100, Ian Campbell wrote: >> >>> 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. >>> >>> xend basically calls into the xl helper since they are compatible. >>> >>> Signed-off-by: Ian Campbell <ian.campbell@citrix.com> >>> --- >>> >>> +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-xm $cfg > $cfg.xml", 30); >>> + target_getfile_root($ho,60,"$cfg.xml", "$stash/$lcfg"); >>> + target_cmd_root($ho, "virsh create --file $cfg.xml", 100); >>> +} >>> + >>> >> I agree that domxml-from-native would be the best thing to do here. >> >> However, we need to double check how well it works, and probably commit >> to improve that, as, last time I checked, it was doing a pretty poor >> job. :-( >> >> Jim, what's the status of that thing? >> > > It worked well enough for osstest to start a guest with its usual > config, with the libvirt bugfix I sent out a few hours ago. > I'm not aware of any issues with the xen-xm conversion, but then again haven't tested all possible configs. Ian found one such untested config (root=) just last week. Conversion of xl config is another matter. Currently, libvirt doesn't support 'virsh domxml-{from,to}-native xen-xl ...'. David Kiarie is going to look at this as part of his GSoC work on the libvirt libxl driver. > But the whole point of the tests is to find bugs, so I don't see the > fact that this may or may not be buggy as a reason for osstest not to > use it. If that shows that it is buggy then we should fix it. > Agreed. Regards, Jim
diff --git a/Osstest/TestSupport.pm b/Osstest/TestSupport.pm index 1444629..e93687b 100644 --- a/Osstest/TestSupport.pm +++ b/Osstest/TestSupport.pm @@ -1274,13 +1274,12 @@ sub guest_await_reboot ($$$) { sub guest_destroy ($$) { my ($ho,$gho) = @_; - target_cmd_root($ho, toolstack($ho)->{Command}." destroy $gho->{Name}", 40); + toolstack($ho)->destroy($gho->{Name}); } sub guest_create ($$) { my ($ho,$gho) = @_; - my $ts= toolstack($ho); - target_cmd_root($ho, $ts->{Command}." create $gho->{CfgPath}", 100); + toolstack($ho)->create($gho->{CfgPath}); } diff --git a/Osstest/Toolstack/libvirt.pm b/Osstest/Toolstack/libvirt.pm index 90fe434..c1d2b09 100644 --- a/Osstest/Toolstack/libvirt.pm +++ b/Osstest/Toolstack/libvirt.pm @@ -20,15 +20,34 @@ 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,$gn) = @_; + 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-xm $cfg > $cfg.xml", 30); + target_getfile_root($ho,60,"$cfg.xml", "$stash/$lcfg"); + target_cmd_root($ho, "virsh create --file $cfg.xml", 100); +} + 1; diff --git a/Osstest/Toolstack/xend.pm b/Osstest/Toolstack/xend.pm index 881417d..4f093bc 100644 --- a/Osstest/Toolstack/xend.pm +++ b/Osstest/Toolstack/xend.pm @@ -19,6 +19,7 @@ package Osstest::Toolstack::xend; use strict; use warnings; +use Osstest::Toolstack::xl; sub new { my ($class, $ho, $methname,$asset) = @_; @@ -32,4 +33,7 @@ sub new { }, $class; } +sub destroy { return Osstest::Toolstack::xl::destroy(@_); } +sub create { return Osstest::Toolstack::xl::create(@_); } + 1; diff --git a/Osstest/Toolstack/xl.pm b/Osstest/Toolstack/xl.pm index 0b66201..ca46094 100644 --- a/Osstest/Toolstack/xl.pm +++ b/Osstest/Toolstack/xl.pm @@ -32,4 +32,14 @@ sub new { }, $class; } +sub destroy ($$) { + my ($self,$gn) = @_; + 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; diff --git a/ts-guest-saverestore b/ts-guest-saverestore index 9e04ae9..8911aed 100755 --- a/ts-guest-saverestore +++ b/ts-guest-saverestore @@ -38,7 +38,7 @@ sub restore () { toolstack($ho)->{Command} ." restore " .(toolstack($ho)->{RestoreNeedsConfig} ? - $r{ $gho->{Guest}.'_'. toolstack($ho)->{CfgPathVar} } : '') + $gho->{CfgPath} : '') ." image", 200); target_ping_check_up($gho); } diff --git a/ts-guest-start b/ts-guest-start index bfbb734..fb6a174 100755 --- a/ts-guest-start +++ b/ts-guest-start @@ -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 () { diff --git a/ts-windows-install b/ts-windows-install index 4b06310..f12a4f4 100755 --- a/ts-windows-install +++ b/ts-windows-install @@ -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($ho,$gho); guest_await_dhcp_tcp($gho,7000); guest_check_up($gho);
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. xend basically calls into the xl helper since they are compatible. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> --- Osstest/TestSupport.pm | 5 ++--- Osstest/Toolstack/libvirt.pm | 19 +++++++++++++++++++ Osstest/Toolstack/xend.pm | 4 ++++ Osstest/Toolstack/xl.pm | 10 ++++++++++ ts-guest-saverestore | 2 +- ts-guest-start | 4 +--- ts-windows-install | 7 +------ 7 files changed, 38 insertions(+), 13 deletions(-)