提交 2601e0f2 编写于 作者: D Daniel P. Berrange

Ensure driver method names match public API names

Ensure that the virDrvXXX method names exactly match
the public APIs virYYY method names. ie XXX == YYY.
Add a test case to prevent any regressions.
Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
上级 bb036368
......@@ -154,7 +154,7 @@ close FILE;
# Some special things which aren't public APIs,
# but we want to report
$apis{virConnectDrvSupportsFeature} = "0.3.2";
$apis{virConnectSupportsFeature} = "0.3.2";
$apis{virDomainMigratePrepare} = "0.3.2";
$apis{virDomainMigratePerform} = "0.3.2";
$apis{virDomainMigrateFinish} = "0.3.2";
......
......@@ -427,7 +427,18 @@ else !WITH_REMOTE
check-protocol:
endif
EXTRA_DIST += $(PROTOCOL_STRUCTS)
check-local: check-protocol check-symfile check-symsorting
check-drivername:
$(AM_V_GEN)$(PERL) $(srcdir)/check-drivername.pl \
$(srcdir)/driver.h \
$(srcdir)/libvirt_public.syms \
$(srcdir)/libvirt_qemu.syms \
$(srcdir)/libvirt_lxc.syms
EXTRA_DIST += check-drivername.pl
check-local: check-protocol check-symfile check-symsorting \
check-drivername
.PHONY: check-protocol $(PROTOCOL_STRUCTS:structs=struct)
# Mock driver, covering domains, storage, networks, etc
......
#!/usr/bin/perl
#
# Copyright (C) 2013 Red Hat, Inc.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library 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
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library. If not, see
# <http://www.gnu.org/licenses/>.
#
use strict;
use warnings;
my $drvfile = shift;
my @symfiles = @ARGV;
my %symbols;
foreach my $symfile (@symfiles) {
open SYMFILE, "<", $symfile
or die "cannot read $symfile: $!";
while (<SYMFILE>) {
if (/^\s*(vir\w+)\s*;\s*$/) {
$symbols{$1} = 1;
}
}
close SYMFILE;
}
open DRVFILE, "<", $drvfile
or die "cannot read $drvfile: $!";
my $status = 0;
while (<DRVFILE>) {
next if /virDrvConnectSupportsFeature/;
if (/\*(virDrv\w+)\s*\)/) {
my $drv = $1;
next if $drv =~ /virDrvState/;
next if $drv =~ /virDrvDomainMigrate(Prepare|Perform|Confirm|Begin|Finish)/;
my $sym = $drv;
$sym =~ s/virDrv/vir/;
unless (exists $symbols{$sym}) {
print "Driver method name $drv doesn't match public API name\n";
$status = 1;
}
} elsif (/^\*(vir\w+)\s*\)/) {
my $name = $1;
print "Bogus name $1\n";
$status = 1;
}
}
close DRVFILE;
exit $status;
此差异已折叠。
......@@ -93,9 +93,9 @@ extern int xenRegister (void);
* structure with direct calls in xen_unified.c.
*/
struct xenUnifiedDriver {
virDrvClose xenClose; /* Only mandatory callback; all others may be NULL */
virDrvGetVersion xenVersion;
virDrvGetHostname xenGetHostname;
virDrvConnectClose xenClose; /* Only mandatory callback; all others may be NULL */
virDrvConnectGetVersion xenVersion;
virDrvConnectGetHostname xenGetHostname;
virDrvDomainSuspend xenDomainSuspend;
virDrvDomainResume xenDomainResume;
virDrvDomainShutdown xenDomainShutdown;
......@@ -108,8 +108,8 @@ struct xenUnifiedDriver {
virDrvDomainGetInfo xenDomainGetInfo;
virDrvDomainPinVcpu xenDomainPinVcpu;
virDrvDomainGetVcpus xenDomainGetVcpus;
virDrvListDefinedDomains xenListDefinedDomains;
virDrvNumOfDefinedDomains xenNumOfDefinedDomains;
virDrvConnectListDefinedDomains xenListDefinedDomains;
virDrvConnectNumOfDefinedDomains xenNumOfDefinedDomains;
virDrvDomainCreate xenDomainCreate;
virDrvDomainDefineXML xenDomainDefineXML;
virDrvDomainUndefine xenDomainUndefine;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册