|
|
6ae9ed |
From db426d18a3f337f699540943e0be1dabcaddd001 Mon Sep 17 00:00:00 2001
|
|
|
6ae9ed |
Message-Id: <db426d18a3f337f699540943e0be1dabcaddd001@dist-git>
|
|
|
6ae9ed |
From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
|
|
|
6ae9ed |
Date: Tue, 28 Jun 2016 12:37:50 +0200
|
|
|
6ae9ed |
Subject: [PATCH] hvsupport: Introduce parseSymsFile
|
|
|
6ae9ed |
|
|
|
6ae9ed |
The code for parsing the different public syms files only differs
|
|
|
6ae9ed |
in the filenames and version prefix.
|
|
|
6ae9ed |
|
|
|
6ae9ed |
Unify it to a single subroutine.
|
|
|
6ae9ed |
|
|
|
6ae9ed |
(cherry picked from commit fa0b00f94e5173fc1c609e661d74ad9f2f81126c)
|
|
|
6ae9ed |
|
|
|
6ae9ed |
https://bugzilla.redhat.com/show_bug.cgi?id=1286679
|
|
|
6ae9ed |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
6ae9ed |
---
|
|
|
6ae9ed |
docs/hvsupport.pl | 178 +++++++++++++++++-------------------------------------
|
|
|
6ae9ed |
1 file changed, 55 insertions(+), 123 deletions(-)
|
|
|
6ae9ed |
|
|
|
6ae9ed |
diff --git a/docs/hvsupport.pl b/docs/hvsupport.pl
|
|
|
6ae9ed |
index 44a30ce..7a6f1ac 100755
|
|
|
6ae9ed |
--- a/docs/hvsupport.pl
|
|
|
6ae9ed |
+++ b/docs/hvsupport.pl
|
|
|
6ae9ed |
@@ -44,136 +44,66 @@ find({
|
|
|
6ae9ed |
push @srcs, $_ if $_ !~ /vbox_driver\.c/;
|
|
|
6ae9ed |
}
|
|
|
6ae9ed |
}, no_chdir => 1}, $srcdir);
|
|
|
6ae9ed |
-my $line;
|
|
|
6ae9ed |
|
|
|
6ae9ed |
-# Get the list of all public APIs and their corresponding version
|
|
|
6ae9ed |
+sub parseSymsFile {
|
|
|
6ae9ed |
+ my $apisref = shift;
|
|
|
6ae9ed |
+ my $prefix = shift;
|
|
|
6ae9ed |
+ my $filename = shift;
|
|
|
6ae9ed |
+ my $xmlfilename = shift;
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+ my $line;
|
|
|
6ae9ed |
+ my $vers;
|
|
|
6ae9ed |
+ my $prevvers;
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+ my $apixpath = XML::XPath->new(filename => $xmlfilename);
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+ open FILE, "<$filename"
|
|
|
6ae9ed |
+ or die "cannot read $filename: $!";
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+ while (defined($line = <FILE>)) {
|
|
|
6ae9ed |
+ chomp $line;
|
|
|
6ae9ed |
+ next if $line =~ /^\s*#/;
|
|
|
6ae9ed |
+ next if $line =~ /^\s*$/;
|
|
|
6ae9ed |
+ next if $line =~ /^\s*(global|local):/;
|
|
|
6ae9ed |
+ if ($line =~ /^\s*${prefix}_(\d+\.\d+\.\d+)\s*{\s*$/) {
|
|
|
6ae9ed |
+ if (defined $vers) {
|
|
|
6ae9ed |
+ die "malformed syms file";
|
|
|
6ae9ed |
+ }
|
|
|
6ae9ed |
+ $vers = $1;
|
|
|
6ae9ed |
+ } elsif ($line =~ /\s*}\s*;\s*$/) {
|
|
|
6ae9ed |
+ if (defined $prevvers) {
|
|
|
6ae9ed |
+ die "malformed syms file";
|
|
|
6ae9ed |
+ }
|
|
|
6ae9ed |
+ $prevvers = $vers;
|
|
|
6ae9ed |
+ $vers = undef;
|
|
|
6ae9ed |
+ } elsif ($line =~ /\s*}\s*${prefix}_(\d+\.\d+\.\d+)\s*;\s*$/) {
|
|
|
6ae9ed |
+ if ($1 ne $prevvers) {
|
|
|
6ae9ed |
+ die "malformed syms file $1 != $vers";
|
|
|
6ae9ed |
+ }
|
|
|
6ae9ed |
+ $prevvers = $vers;
|
|
|
6ae9ed |
+ $vers = undef;
|
|
|
6ae9ed |
+ } elsif ($line =~ /\s*(\w+)\s*;\s*$/) {
|
|
|
6ae9ed |
+ my $file = $apixpath->find("/api/symbols/function[\@name='$1']/\@file");
|
|
|
6ae9ed |
+ $$apisref{$1} = {};
|
|
|
6ae9ed |
+ $$apisref{$1}->{vers} = $vers;
|
|
|
6ae9ed |
+ $$apisref{$1}->{file} = $file;
|
|
|
6ae9ed |
+ } else {
|
|
|
6ae9ed |
+ die "unexpected data $line\n";
|
|
|
6ae9ed |
+ }
|
|
|
6ae9ed |
+ }
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+ close FILE;
|
|
|
6ae9ed |
+}
|
|
|
6ae9ed |
|
|
|
6ae9ed |
my %apis;
|
|
|
6ae9ed |
-open FILE, "<$symslibvirt"
|
|
|
6ae9ed |
- or die "cannot read $symslibvirt: $!";
|
|
|
6ae9ed |
-
|
|
|
6ae9ed |
-my $vers;
|
|
|
6ae9ed |
-my $prevvers;
|
|
|
6ae9ed |
-my $apixpath = XML::XPath->new(filename => "$srcdir/../docs/libvirt-api.xml");
|
|
|
6ae9ed |
-while (defined($line = <FILE>)) {
|
|
|
6ae9ed |
- chomp $line;
|
|
|
6ae9ed |
- next if $line =~ /^\s*#/;
|
|
|
6ae9ed |
- next if $line =~ /^\s*$/;
|
|
|
6ae9ed |
- next if $line =~ /^\s*(global|local):/;
|
|
|
6ae9ed |
- if ($line =~ /^\s*LIBVIRT_(\d+\.\d+\.\d+)\s*{\s*$/) {
|
|
|
6ae9ed |
- if (defined $vers) {
|
|
|
6ae9ed |
- die "malformed syms file";
|
|
|
6ae9ed |
- }
|
|
|
6ae9ed |
- $vers = $1;
|
|
|
6ae9ed |
- } elsif ($line =~ /\s*}\s*;\s*$/) {
|
|
|
6ae9ed |
- if (defined $prevvers) {
|
|
|
6ae9ed |
- die "malformed syms file";
|
|
|
6ae9ed |
- }
|
|
|
6ae9ed |
- $prevvers = $vers;
|
|
|
6ae9ed |
- $vers = undef;
|
|
|
6ae9ed |
- } elsif ($line =~ /\s*}\s*LIBVIRT_(\d+\.\d+\.\d+)\s*;\s*$/) {
|
|
|
6ae9ed |
- if ($1 ne $prevvers) {
|
|
|
6ae9ed |
- die "malformed syms file $1 != $vers";
|
|
|
6ae9ed |
- }
|
|
|
6ae9ed |
- $prevvers = $vers;
|
|
|
6ae9ed |
- $vers = undef;
|
|
|
6ae9ed |
- } elsif ($line =~ /\s*(\w+)\s*;\s*$/) {
|
|
|
6ae9ed |
- my $file = $apixpath->find("/api/symbols/function[\@name='$1']/\@file");
|
|
|
6ae9ed |
- $apis{$1} = {};
|
|
|
6ae9ed |
- $apis{$1}->{vers} = $vers;
|
|
|
6ae9ed |
- $apis{$1}->{file} = $file;
|
|
|
6ae9ed |
- } else {
|
|
|
6ae9ed |
- die "unexpected data $line\n";
|
|
|
6ae9ed |
- }
|
|
|
6ae9ed |
-}
|
|
|
6ae9ed |
-
|
|
|
6ae9ed |
-close FILE;
|
|
|
6ae9ed |
-
|
|
|
6ae9ed |
+# Get the list of all public APIs and their corresponding version
|
|
|
6ae9ed |
+parseSymsFile(\%apis, "LIBVIRT", $symslibvirt, "$srcdir/../docs/libvirt-api.xml");
|
|
|
6ae9ed |
|
|
|
6ae9ed |
# And the same for the QEMU specific APIs
|
|
|
6ae9ed |
-
|
|
|
6ae9ed |
-open FILE, "<$symsqemu"
|
|
|
6ae9ed |
- or die "cannot read $symsqemu: $!";
|
|
|
6ae9ed |
-
|
|
|
6ae9ed |
-$prevvers = undef;
|
|
|
6ae9ed |
-$vers = undef;
|
|
|
6ae9ed |
-$apixpath = XML::XPath->new(filename => "$srcdir/../docs/libvirt-qemu-api.xml");
|
|
|
6ae9ed |
-while (defined($line = <FILE>)) {
|
|
|
6ae9ed |
- chomp $line;
|
|
|
6ae9ed |
- next if $line =~ /^\s*#/;
|
|
|
6ae9ed |
- next if $line =~ /^\s*$/;
|
|
|
6ae9ed |
- next if $line =~ /^\s*(global|local):/;
|
|
|
6ae9ed |
- if ($line =~ /^\s*LIBVIRT_QEMU_(\d+\.\d+\.\d+)\s*{\s*$/) {
|
|
|
6ae9ed |
- if (defined $vers) {
|
|
|
6ae9ed |
- die "malformed syms file";
|
|
|
6ae9ed |
- }
|
|
|
6ae9ed |
- $vers = $1;
|
|
|
6ae9ed |
- } elsif ($line =~ /\s*}\s*;\s*$/) {
|
|
|
6ae9ed |
- if (defined $prevvers) {
|
|
|
6ae9ed |
- die "malformed syms file";
|
|
|
6ae9ed |
- }
|
|
|
6ae9ed |
- $prevvers = $vers;
|
|
|
6ae9ed |
- $vers = undef;
|
|
|
6ae9ed |
- } elsif ($line =~ /\s*}\s*LIBVIRT_QEMU_(\d+\.\d+\.\d+)\s*;\s*$/) {
|
|
|
6ae9ed |
- if ($1 ne $prevvers) {
|
|
|
6ae9ed |
- die "malformed syms file $1 != $vers";
|
|
|
6ae9ed |
- }
|
|
|
6ae9ed |
- $prevvers = $vers;
|
|
|
6ae9ed |
- $vers = undef;
|
|
|
6ae9ed |
- } elsif ($line =~ /\s*(\w+)\s*;\s*$/) {
|
|
|
6ae9ed |
- my $file = $apixpath->find("/api/symbols/function[\@name='$1']/\@file");
|
|
|
6ae9ed |
- $apis{$1} = {};
|
|
|
6ae9ed |
- $apis{$1}->{vers} = $vers;
|
|
|
6ae9ed |
- $apis{$1}->{file} = $file;
|
|
|
6ae9ed |
- } else {
|
|
|
6ae9ed |
- die "unexpected data $line\n";
|
|
|
6ae9ed |
- }
|
|
|
6ae9ed |
-}
|
|
|
6ae9ed |
-
|
|
|
6ae9ed |
-close FILE;
|
|
|
6ae9ed |
-
|
|
|
6ae9ed |
+parseSymsFile(\%apis, "LIBVIRT_QEMU", $symsqemu, "$srcdir/../docs/libvirt-qemu-api.xml");
|
|
|
6ae9ed |
|
|
|
6ae9ed |
# And the same for the LXC specific APIs
|
|
|
6ae9ed |
-
|
|
|
6ae9ed |
-open FILE, "<$symslxc"
|
|
|
6ae9ed |
- or die "cannot read $symslxc: $!";
|
|
|
6ae9ed |
-
|
|
|
6ae9ed |
-$prevvers = undef;
|
|
|
6ae9ed |
-$vers = undef;
|
|
|
6ae9ed |
-$apixpath = XML::XPath->new(filename => "$srcdir/../docs/libvirt-lxc-api.xml");
|
|
|
6ae9ed |
-while (defined($line = <FILE>)) {
|
|
|
6ae9ed |
- chomp $line;
|
|
|
6ae9ed |
- next if $line =~ /^\s*#/;
|
|
|
6ae9ed |
- next if $line =~ /^\s*$/;
|
|
|
6ae9ed |
- next if $line =~ /^\s*(global|local):/;
|
|
|
6ae9ed |
- if ($line =~ /^\s*LIBVIRT_LXC_(\d+\.\d+\.\d+)\s*{\s*$/) {
|
|
|
6ae9ed |
- if (defined $vers) {
|
|
|
6ae9ed |
- die "malformed syms file";
|
|
|
6ae9ed |
- }
|
|
|
6ae9ed |
- $vers = $1;
|
|
|
6ae9ed |
- } elsif ($line =~ /\s*}\s*;\s*$/) {
|
|
|
6ae9ed |
- if (defined $prevvers) {
|
|
|
6ae9ed |
- die "malformed syms file";
|
|
|
6ae9ed |
- }
|
|
|
6ae9ed |
- $prevvers = $vers;
|
|
|
6ae9ed |
- $vers = undef;
|
|
|
6ae9ed |
- } elsif ($line =~ /\s*}\s*LIBVIRT_LXC_(\d+\.\d+\.\d+)\s*;\s*$/) {
|
|
|
6ae9ed |
- if ($1 ne $prevvers) {
|
|
|
6ae9ed |
- die "malformed syms file $1 != $vers";
|
|
|
6ae9ed |
- }
|
|
|
6ae9ed |
- $prevvers = $vers;
|
|
|
6ae9ed |
- $vers = undef;
|
|
|
6ae9ed |
- } elsif ($line =~ /\s*(\w+)\s*;\s*$/) {
|
|
|
6ae9ed |
- my $file = $apixpath->find("/api/symbols/function[\@name='$1']/\@file");
|
|
|
6ae9ed |
- $apis{$1} = {};
|
|
|
6ae9ed |
- $apis{$1}->{vers} = $vers;
|
|
|
6ae9ed |
- $apis{$1}->{file} = $file;
|
|
|
6ae9ed |
- } else {
|
|
|
6ae9ed |
- die "unexpected data $line\n";
|
|
|
6ae9ed |
- }
|
|
|
6ae9ed |
-}
|
|
|
6ae9ed |
-
|
|
|
6ae9ed |
-close FILE;
|
|
|
6ae9ed |
+parseSymsFile(\%apis, "LIBVIRT_LXC", $symslxc, "$srcdir/../docs/libvirt-lxc-api.xml");
|
|
|
6ae9ed |
|
|
|
6ae9ed |
|
|
|
6ae9ed |
# Some special things which aren't public APIs,
|
|
|
6ae9ed |
@@ -206,6 +136,8 @@ $apis{virDomainMigrateConfirm3Params}->{vers} = "1.1.0";
|
|
|
6ae9ed |
# and driver struct fields. This lets us later match
|
|
|
6ae9ed |
# update the driver impls with the public APis.
|
|
|
6ae9ed |
|
|
|
6ae9ed |
+my $line;
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
# Group name -> hash of APIs { fields -> api name }
|
|
|
6ae9ed |
my %groups;
|
|
|
6ae9ed |
my $ingrp;
|
|
|
6ae9ed |
--
|
|
|
6ae9ed |
2.9.2
|
|
|
6ae9ed |
|