提交 ba78d2cf 编写于 作者: E Eric Blake

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.
上级 833fe8ab
/*
* 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);
......
......@@ -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;
......
......@@ -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;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册