[PATCHv2 06/27] node_device: reject unknown flags

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



* 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.
---
 src/node_device/node_device_driver.c |   18 +++++++++++++-----
 src/node_device/node_device_hal.c    |    4 +++-
 src/node_device/node_device_udev.c   |    4 +++-
 3 files changed, 19 insertions(+), 7 deletions(-)

diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_device_driver.c
index 842f903..681655e 100644
--- a/src/node_device/node_device_driver.c
+++ b/src/node_device/node_device_driver.c
@@ -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);
diff --git a/src/node_device/node_device_hal.c b/src/node_device/node_device_hal.c
index d1dedfe..421f5ad 100644
--- a/src/node_device/node_device_hal.c
+++ b/src/node_device/node_device_hal.c
@@ -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;

diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c
index db26c6b..a6b5b2e 100644
--- a/src/node_device/node_device_udev.c
+++ b/src/node_device/node_device_udev.c
@@ -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;
     }
-- 
1.7.4.4

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]