Annotate the ESX device driver dummy.
Refactor the udev and hal device driver strcuts to match the
common annotation pattern.
---
This is post-0.9.2.
docs/hvsupport.pl | 22 +++++++++++++----
src/esx/esx_device_monitor.c | 15 ++---------
src/node_device/node_device_driver.c | 45 +++++++++++++---------------------
src/node_device/node_device_driver.h | 14 +++++++++-
src/node_device/node_device_hal.c | 22 +++++++++++-----
src/node_device/node_device_udev.c | 22 +++++++++++-----
6 files changed, 79 insertions(+), 61 deletions(-)
diff --git a/docs/hvsupport.pl b/docs/hvsupport.pl
index 8a0fa7a..b0d1f0f 100755
--- a/docs/hvsupport.pl
+++ b/docs/hvsupport.pl
@@ -27,7 +27,7 @@ my %groupheaders = (
my @srcs;
find({
wanted => sub {
- if (m!$srcdir/.*/\w+_(driver|tmpl)\.c$!) {
+ if (m!$srcdir/.*/\w+_(driver|tmpl|monitor|hal|udev)\.c$!) {
push @srcs, $_ if $_ !~ /vbox_driver\.c/;
}
}, no_chdir => 1}, $srcdir);
@@ -142,7 +142,7 @@ open FILE, "<$drivertable"
my %groups;
my $ingrp;
while (defined($line = <FILE>)) {
- if ($line =~ /struct _(vir\w*Driver)/) {
+ if ($line =~ /struct _(vir\w*(?:Driver|Monitor))/) {
my $grp = $1;
if ($grp ne "virStateDriver" &&
$grp ne "virStreamDriver") {
@@ -150,7 +150,7 @@ while (defined($line = <FILE>)) {
$groups{$ingrp} = { apis => {}, drivers => {} };
}
} elsif ($ingrp) {
- if ($line =~ /^\s*virDrv(\w+)\s+(\w+);\s*$/) {
+ if ($line =~ /^\s*vir(?:Drv|DevMon)(\w+)\s+(\w+);\s*$/) {
my $field = $2;
my $name = $1;
@@ -159,6 +159,8 @@ while (defined($line = <FILE>)) {
$api = "vir$name";
} elsif (exists $apis{"virConnect$name"}) {
$api = "virConnect$name";
+ } elsif (exists $apis{"virNode$name"}) {
+ $api = "virNode$name";
} else {
die "driver $name does not have a public API";
}
@@ -188,7 +190,17 @@ foreach my $src (@srcs) {
$line =~ /^\s*(?:static\s+)?$grp\s+NAME\(\w+\)\s*=\s*{/) {
$ingrp = $grp;
$impl = $src;
- $impl =~ s,.*/(\w+?)_((\w+)_)?(\w+)\.c,$1,;
+
+ if ($impl =~ m,.*/node_device_(\w+)\.c,) {
+ $impl = $1;
+ } else {
+ $impl =~ s,.*/(\w+?)_((\w+)_)?(\w+)\.c,$1,;
+ }
+
+ if ($groups{$ingrp}->{drivers}->{$impl}) {
+ die "Group $ingrp already contains $impl";
+ }
+
$groups{$ingrp}->{drivers}->{$impl} = {};
}
}
@@ -206,7 +218,7 @@ foreach my $src (@srcs) {
die "Driver method for $api is NULL in $src" if $meth eq "NULL";
if (!exists($groups{$ingrp}->{apis}->{$api})) {
- die "Found unexpected driver $api in $ingrp\n";
+ die "Found unexpected method $api in $ingrp\n";
}
$groups{$ingrp}->{drivers}->{$impl}->{$api} = $vers;
diff --git a/src/esx/esx_device_monitor.c b/src/esx/esx_device_monitor.c
index 3fa63d5..4bc8e7f 100644
--- a/src/esx/esx_device_monitor.c
+++ b/src/esx/esx_device_monitor.c
@@ -66,18 +66,9 @@ esxDeviceClose(virConnectPtr conn)
static virDeviceMonitor esxDeviceMonitor = {
- "ESX", /* name */
- esxDeviceOpen, /* open */
- esxDeviceClose, /* close */
- NULL, /* numOfDevices */
- NULL, /* listDevices */
- NULL, /* deviceLookupByName */
- NULL, /* deviceGetXMLDesc */
- NULL, /* deviceGetParent */
- NULL, /* deviceNumOfCaps */
- NULL, /* deviceListCaps */
- NULL, /* deviceCreateXML */
- NULL, /* deviceDestroy */
+ .name = "ESX",
+ .open = esxDeviceOpen, /* 0.7.6 */
+ .close = esxDeviceClose, /* 0.7.6 */
};
diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_device_driver.c
index 8ec3e44..842f903 100644
--- a/src/node_device/node_device_driver.c
+++ b/src/node_device/node_device_driver.c
@@ -122,9 +122,10 @@ void nodeDeviceUnlock(virDeviceMonitorStatePtr driver)
virMutexUnlock(&driver->lock);
}
-static int nodeNumOfDevices(virConnectPtr conn,
- const char *cap,
- unsigned int flags ATTRIBUTE_UNUSED)
+int
+nodeNumOfDevices(virConnectPtr conn,
+ const char *cap,
+ unsigned int flags ATTRIBUTE_UNUSED)
{
virDeviceMonitorStatePtr driver = conn->devMonPrivateData;
int ndevs = 0;
@@ -143,7 +144,7 @@ static int nodeNumOfDevices(virConnectPtr conn,
return ndevs;
}
-static int
+int
nodeListDevices(virConnectPtr conn,
const char *cap,
char **const names, int maxnames,
@@ -179,8 +180,8 @@ nodeListDevices(virConnectPtr conn,
}
-static virNodeDevicePtr nodeDeviceLookupByName(virConnectPtr conn,
- const char *name)
+virNodeDevicePtr
+nodeDeviceLookupByName(virConnectPtr conn, const char *name)
{
virDeviceMonitorStatePtr driver = conn->devMonPrivateData;
virNodeDeviceObjPtr obj;
@@ -251,8 +252,9 @@ out:
}
-static char *nodeDeviceGetXMLDesc(virNodeDevicePtr dev,
- unsigned int flags ATTRIBUTE_UNUSED)
+char *
+nodeDeviceGetXMLDesc(virNodeDevicePtr dev,
+ unsigned int flags ATTRIBUTE_UNUSED)
{
virDeviceMonitorStatePtr driver = dev->conn->devMonPrivateData;
virNodeDeviceObjPtr obj;
@@ -281,7 +283,8 @@ cleanup:
}
-static char *nodeDeviceGetParent(virNodeDevicePtr dev)
+char *
+nodeDeviceGetParent(virNodeDevicePtr dev)
{
virDeviceMonitorStatePtr driver = dev->conn->devMonPrivateData;
virNodeDeviceObjPtr obj;
@@ -314,7 +317,8 @@ cleanup:
}
-static int nodeDeviceNumOfCaps(virNodeDevicePtr dev)
+int
+nodeDeviceNumOfCaps(virNodeDevicePtr dev)
{
virDeviceMonitorStatePtr driver = dev->conn->devMonPrivateData;
virNodeDeviceObjPtr obj;
@@ -344,7 +348,7 @@ cleanup:
}
-static int
+int
nodeDeviceListCaps(virNodeDevicePtr dev, char **const names, int maxnames)
{
virDeviceMonitorStatePtr driver = dev->conn->devMonPrivateData;
@@ -538,7 +542,7 @@ find_new_device(virConnectPtr conn, const char *wwnn, const char
*wwpn)
return dev;
}
-static virNodeDevicePtr
+virNodeDevicePtr
nodeDeviceCreateXML(virConnectPtr conn,
const char *xmlDesc,
unsigned int flags ATTRIBUTE_UNUSED)
@@ -591,7 +595,7 @@ cleanup:
}
-static int
+int
nodeDeviceDestroy(virNodeDevicePtr dev)
{
int ret = -1;
@@ -651,21 +655,6 @@ out:
return ret;
}
-
-void registerCommonNodeFuncs(virDeviceMonitorPtr driver)
-{
- driver->numOfDevices = nodeNumOfDevices;
- driver->listDevices = nodeListDevices;
- driver->deviceLookupByName = nodeDeviceLookupByName;
- driver->deviceGetXMLDesc = nodeDeviceGetXMLDesc;
- driver->deviceGetParent = nodeDeviceGetParent;
- driver->deviceNumOfCaps = nodeDeviceNumOfCaps;
- driver->deviceListCaps = nodeDeviceListCaps;
- driver->deviceCreateXML = nodeDeviceCreateXML;
- driver->deviceDestroy = nodeDeviceDestroy;
-}
-
-
int nodedevRegister(void) {
#if defined(HAVE_HAL) && defined(HAVE_UDEV)
/* Register only one of these two - they conflict */
diff --git a/src/node_device/node_device_driver.h b/src/node_device/node_device_driver.h
index e583c2b..08779b1 100644
--- a/src/node_device/node_device_driver.h
+++ b/src/node_device/node_device_driver.h
@@ -53,8 +53,6 @@ int udevNodeRegister(void);
void nodeDeviceLock(virDeviceMonitorStatePtr driver);
void nodeDeviceUnlock(virDeviceMonitorStatePtr driver);
-void registerCommonNodeFuncs(virDeviceMonitorPtr mon);
-
int nodedevRegister(void);
# ifdef __linux__
@@ -86,4 +84,16 @@ int read_wwn_linux(int host, const char *file, char **wwn);
# endif /* __linux__ */
+int nodeNumOfDevices(virConnectPtr conn, const char *cap, unsigned int flags);
+int nodeListDevices(virConnectPtr conn, const char *cap, char **const names,
+ int maxnames, unsigned int flags);
+virNodeDevicePtr nodeDeviceLookupByName(virConnectPtr conn, const char *name);
+char *nodeDeviceGetXMLDesc(virNodeDevicePtr dev, unsigned int flags);
+char *nodeDeviceGetParent(virNodeDevicePtr dev);
+int nodeDeviceNumOfCaps(virNodeDevicePtr dev);
+int nodeDeviceListCaps(virNodeDevicePtr dev, char **const names, int maxnames);
+virNodeDevicePtr nodeDeviceCreateXML(virConnectPtr conn,
+ const char *xmlDesc, unsigned int flags);
+int nodeDeviceDestroy(virNodeDevicePtr dev);
+
#endif /* __VIR_NODE_DEVICE_H__ */
diff --git a/src/node_device/node_device_hal.c b/src/node_device/node_device_hal.c
index 8df2875..a90e777 100644
--- a/src/node_device/node_device_hal.c
+++ b/src/node_device/node_device_hal.c
@@ -881,22 +881,30 @@ static int halNodeDrvClose(virConnectPtr conn ATTRIBUTE_UNUSED)
static virDeviceMonitor halDeviceMonitor = {
.name = "halDeviceMonitor",
- .open = halNodeDrvOpen,
- .close = halNodeDrvClose,
+ .open = halNodeDrvOpen, /* 0.5.0 */
+ .close = halNodeDrvClose, /* 0.5.0 */
+ .numOfDevices = nodeNumOfDevices, /* 0.5.0 */
+ .listDevices = nodeListDevices, /* 0.5.0 */
+ .deviceLookupByName = nodeDeviceLookupByName, /* 0.5.0 */
+ .deviceGetXMLDesc = nodeDeviceGetXMLDesc, /* 0.5.0 */
+ .deviceGetParent = nodeDeviceGetParent, /* 0.5.0 */
+ .deviceNumOfCaps = nodeDeviceNumOfCaps, /* 0.5.0 */
+ .deviceListCaps = nodeDeviceListCaps, /* 0.5.0 */
+ .deviceCreateXML = nodeDeviceCreateXML, /* 0.6.5 */
+ .deviceDestroy = nodeDeviceDestroy, /* 0.6.5 */
};
static virStateDriver halStateDriver = {
.name = "HAL",
- .initialize = halDeviceMonitorStartup,
- .cleanup = halDeviceMonitorShutdown,
- .reload = halDeviceMonitorReload,
- .active = halDeviceMonitorActive,
+ .initialize = halDeviceMonitorStartup, /* 0.5.0 */
+ .cleanup = halDeviceMonitorShutdown, /* 0.5.0 */
+ .reload = halDeviceMonitorReload, /* 0.5.0 */
+ .active = halDeviceMonitorActive, /* 0.5.0 */
};
int halNodeRegister(void)
{
- registerCommonNodeFuncs(&halDeviceMonitor);
if (virRegisterDeviceMonitor(&halDeviceMonitor) < 0)
return -1;
return virRegisterStateDriver(&halStateDriver);
diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c
index 29e4bac..8b9694e 100644
--- a/src/node_device/node_device_udev.c
+++ b/src/node_device/node_device_udev.c
@@ -1741,23 +1741,31 @@ static int udevNodeDrvClose(virConnectPtr conn)
static virDeviceMonitor udevDeviceMonitor = {
.name = "udevDeviceMonitor",
- .open = udevNodeDrvOpen,
- .close = udevNodeDrvClose,
+ .open = udevNodeDrvOpen, /* 0.7.3 */
+ .close = udevNodeDrvClose, /* 0.7.3 */
+ .numOfDevices = nodeNumOfDevices, /* 0.7.3 */
+ .listDevices = nodeListDevices, /* 0.7.3 */
+ .deviceLookupByName = nodeDeviceLookupByName, /* 0.7.3 */
+ .deviceGetXMLDesc = nodeDeviceGetXMLDesc, /* 0.7.3 */
+ .deviceGetParent = nodeDeviceGetParent, /* 0.7.3 */
+ .deviceNumOfCaps = nodeDeviceNumOfCaps, /* 0.7.3 */
+ .deviceListCaps = nodeDeviceListCaps, /* 0.7.3 */
+ .deviceCreateXML = nodeDeviceCreateXML, /* 0.7.3 */
+ .deviceDestroy = nodeDeviceDestroy, /* 0.7.3 */
};
static virStateDriver udevStateDriver = {
.name = "udev",
- .initialize = udevDeviceMonitorStartup,
- .cleanup = udevDeviceMonitorShutdown,
- .reload = udevDeviceMonitorReload,
- .active = udevDeviceMonitorActive,
+ .initialize = udevDeviceMonitorStartup, /* 0.7.3 */
+ .cleanup = udevDeviceMonitorShutdown, /* 0.7.3 */
+ .reload = udevDeviceMonitorReload, /* 0.7.3 */
+ .active = udevDeviceMonitorActive, /* 0.7.3 */
};
int udevNodeRegister(void)
{
VIR_DEBUG("Registering udev node device backend");
- registerCommonNodeFuncs(&udevDeviceMonitor);
if (virRegisterDeviceMonitor(&udevDeviceMonitor) < 0) {
return -1;
}
--
1.7.0.4