node_device: reject unknown flags

* src/node_device/node_device_driver.c (nodeNumOfDevices)
(nodeListDevices, nodeDeviceGetXMLDesc, nodeDeviceCreateXML):
Reject unknown flags.
* src/node_device/node_device_hal.c (halNodeDrvOpen): Likewise.
* src/node_device/node_device_udev.c (udevNodeDrvOpen): Likewise.
This commit is contained in:
Eric Blake 2011-07-06 16:21:23 -06:00
parent 833fe8abec
commit ba78d2cf89
3 changed files with 19 additions and 7 deletions

View File

@ -1,7 +1,7 @@
/*
* node_device.c: node device enumeration
*
* Copyright (C) 2010 Red Hat, Inc.
* Copyright (C) 2010-2011 Red Hat, Inc.
* Copyright (C) 2008 Virtual Iron Software, Inc.
* Copyright (C) 2008 David F. Lively
*
@ -125,12 +125,14 @@ void nodeDeviceUnlock(virDeviceMonitorStatePtr driver)
int
nodeNumOfDevices(virConnectPtr conn,
const char *cap,
unsigned int flags ATTRIBUTE_UNUSED)
unsigned int flags)
{
virDeviceMonitorStatePtr driver = conn->devMonPrivateData;
int ndevs = 0;
unsigned int i;
virCheckFlags(0, -1);
nodeDeviceLock(driver);
for (i = 0; i < driver->devs.count; i++) {
virNodeDeviceObjLock(driver->devs.objs[i]);
@ -148,12 +150,14 @@ int
nodeListDevices(virConnectPtr conn,
const char *cap,
char **const names, int maxnames,
unsigned int flags ATTRIBUTE_UNUSED)
unsigned int flags)
{
virDeviceMonitorStatePtr driver = conn->devMonPrivateData;
int ndevs = 0;
unsigned int i;
virCheckFlags(0, -1);
nodeDeviceLock(driver);
for (i = 0; i < driver->devs.count && ndevs < maxnames; i++) {
virNodeDeviceObjLock(driver->devs.objs[i]);
@ -254,12 +258,14 @@ out:
char *
nodeDeviceGetXMLDesc(virNodeDevicePtr dev,
unsigned int flags ATTRIBUTE_UNUSED)
unsigned int flags)
{
virDeviceMonitorStatePtr driver = dev->conn->devMonPrivateData;
virNodeDeviceObjPtr obj;
char *ret = NULL;
virCheckFlags(0, NULL);
nodeDeviceLock(driver);
obj = virNodeDeviceFindByName(&driver->devs, dev->name);
nodeDeviceUnlock(driver);
@ -545,7 +551,7 @@ find_new_device(virConnectPtr conn, const char *wwnn, const char *wwpn)
virNodeDevicePtr
nodeDeviceCreateXML(virConnectPtr conn,
const char *xmlDesc,
unsigned int flags ATTRIBUTE_UNUSED)
unsigned int flags)
{
virDeviceMonitorStatePtr driver = conn->devMonPrivateData;
virNodeDeviceDefPtr def = NULL;
@ -553,6 +559,8 @@ nodeDeviceCreateXML(virConnectPtr conn,
int parent_host = -1;
virNodeDevicePtr dev = NULL;
virCheckFlags(0, NULL);
nodeDeviceLock(driver);
def = virNodeDeviceDefParseString(xmlDesc, CREATE_DEVICE);

View File

@ -862,8 +862,10 @@ static int halDeviceMonitorActive(void)
static virDrvOpenStatus halNodeDrvOpen(virConnectPtr conn,
virConnectAuthPtr auth ATTRIBUTE_UNUSED,
unsigned int flags ATTRIBUTE_UNUSED)
unsigned int flags)
{
virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR);
if (driverState == NULL)
return VIR_DRV_OPEN_DECLINED;

View File

@ -1721,8 +1721,10 @@ static int udevDeviceMonitorActive(void)
static virDrvOpenStatus udevNodeDrvOpen(virConnectPtr conn,
virConnectAuthPtr auth ATTRIBUTE_UNUSED,
unsigned int flags ATTRIBUTE_UNUSED)
unsigned int flags)
{
virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR);
if (driverState == NULL) {
return VIR_DRV_OPEN_DECLINED;
}