xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Ian Jackson <ian.jackson@eu.citrix.com>
To: xen-devel@lists.xenproject.org
Cc: libvir-list@redhat.com, Julien Grall <julien.grall@arm.com>,
	Ian Jackson <Ian.Jackson@eu.citrix.com>,
	Jim Fehlig <jfehlig@suse.com>
Subject: [OSSTEST PATCH 1/2] libvirt: Check migration capabilities using proper XML parser
Date: Tue, 4 Oct 2016 18:02:26 +0100	[thread overview]
Message-ID: <1475600547-1009-2-git-send-email-ian.jackson@eu.citrix.com> (raw)
In-Reply-To: <1475600547-1009-1-git-send-email-ian.jackson@eu.citrix.com>

Do not grep the virsh capabilities output (!)  Instead, parse the XML
using perl's XML modules and look for the specific feature flag using
an XPATH pattern.

AFAICT from looking at the XML, that's

    <capabilities>
      <host>
	<migration_features>
	  <live/>

But the original code does not test for <live/>.

Xen could in principle (and AIUI might in the future, on ARM) support
save/restore but not live migration.  Currently it supports neither.

I don't know whether libvirt's capabilities system can capture this
distinction.  libvirt.git#1d37a4c4 "libxl: detect support for save and
restore" suggests not.

Perhaps relatedly, I am not sure whether this test should be changed
to look for the xpath
  /capabilities/host/migration_features/live
instead.  The schema (libvirt.git/docs/schemas/capability.rng) seems
to suggest that it probably should.

For now, this osstest commit has no ultimate functional change (with
libvirt output as it currently appears to be on real hosts).

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Julien Grall <julien.grall@arm.com>
CC: Jim Fehlig <jfehlig@suse.com>
---
 Osstest/Toolstack/libvirt.pm | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/Osstest/Toolstack/libvirt.pm b/Osstest/Toolstack/libvirt.pm
index 69ff0bb..b7db7af 100644
--- a/Osstest/Toolstack/libvirt.pm
+++ b/Osstest/Toolstack/libvirt.pm
@@ -21,6 +21,8 @@ use strict;
 use warnings;
 
 use Osstest::TestSupport;
+use XML::LibXML::XPathContext;
+use XML::LibXML;
 
 sub new {
     my ($class, $ho, $methname,$asset) = @_;
@@ -72,6 +74,17 @@ sub shutdown_wait ($$$) {
     guest_await_destroy($gho,$timeout);
 }
 
+sub _check_capability ($$) {
+    my ($self, $xpath) = @_;
+    my $ho = $self->{Host};
+    my $caps = target_cmd_output_root($ho, 'virsh capabilities');
+    my $stash = open_unique_stashfile('virsh-capabilities');
+    my $dom = XML::LibXML->load_xml(string => $caps);
+    my $xc = XML::LibXML::XPathContext->new($dom);
+    my @nodes = $xc->findnodes($xpath);
+    return !!@nodes;
+}
+
 sub migrate_check ($$) {
     my ($self, $local) = @_;
     my $rc;
@@ -80,9 +93,7 @@ sub migrate_check ($$) {
         # local migration is not supported
         $rc = 1;
     } else {
-	my $ho = $self->{Host};
-	my $caps = target_cmd_output_root($ho, "virsh capabilities");
-	$rc = ($caps =~ m/<migration_features>/) ? 0 : 1
+	$rc = $self->check_capability('/capabilities/host/migration_features');
     }
 
     logm("rc=$rc");
-- 
2.1.4


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

  reply	other threads:[~2016-10-04 17:03 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-04 17:02 [OSSTEST PATCH 0/2] libvirt: Fix save/restore capability check on ARM Ian Jackson
2016-10-04 17:02 ` Ian Jackson [this message]
2016-10-04 17:05   ` [OSSTEST PATCH 1/2] libvirt: Check migration capabilities using proper XML parser Ian Jackson
2016-10-05 18:36     ` Julien Grall
2016-10-06 10:00       ` Ian Jackson
2016-10-11 13:42         ` Julien Grall
2016-10-11 13:50           ` Ian Jackson
2016-10-05 23:50   ` Jim Fehlig
2016-10-04 17:02 ` [OSSTEST PATCH 2/2] libvirt: Do not attempt save/restore when migration not advertised Ian Jackson
2016-10-05  6:46   ` [libvirt] " Martin Kletzander
2016-10-06  0:06   ` Jim Fehlig
2016-10-06  9:43     ` Martin Kletzander
2016-10-06  9:59       ` Ian Jackson
2016-10-06 10:42         ` Martin Kletzander
2016-10-06 16:44           ` Ian Jackson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1475600547-1009-2-git-send-email-ian.jackson@eu.citrix.com \
    --to=ian.jackson@eu.citrix.com \
    --cc=jfehlig@suse.com \
    --cc=julien.grall@arm.com \
    --cc=libvir-list@redhat.com \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).