we will be able to define mediated devices that can be started or
stopped, so we need to be able to indicate whether the device is active
or not, similar to other resources (storage pools, domains, etc.)
Signed-off-by: Jonathon Jongsma <jjongsma(a)redhat.com>
---
src/conf/virnodedeviceobj.c | 14 ++++++++++++++
src/conf/virnodedeviceobj.h | 7 +++++++
src/libvirt_private.syms | 2 ++
src/node_device/node_device_udev.c | 3 +++
4 files changed, 26 insertions(+)
diff --git a/src/conf/virnodedeviceobj.c b/src/conf/virnodedeviceobj.c
index bfd524121c..88a7746b27 100644
--- a/src/conf/virnodedeviceobj.c
+++ b/src/conf/virnodedeviceobj.c
@@ -39,6 +39,7 @@ struct _virNodeDeviceObj {
virNodeDeviceDefPtr def; /* device definition */
bool skipUpdateCaps; /* whether to skip checking host caps,
used by testdriver */
+ bool active;
};
struct _virNodeDeviceObjList {
@@ -959,3 +960,16 @@ virNodeDeviceObjSetSkipUpdateCaps(virNodeDeviceObjPtr obj,
{
obj->skipUpdateCaps = skipUpdateCaps;
}
+
+bool
+virNodeDeviceObjIsActive(virNodeDeviceObjPtr obj)
+{
+ return obj->active;
+}
+
+void
+virNodeDeviceObjSetActive(virNodeDeviceObjPtr obj,
+ bool active)
+{
+ obj->active = active;
+}
diff --git a/src/conf/virnodedeviceobj.h b/src/conf/virnodedeviceobj.h
index 6efdb23d36..c119f4c51f 100644
--- a/src/conf/virnodedeviceobj.h
+++ b/src/conf/virnodedeviceobj.h
@@ -121,3 +121,10 @@ virNodeDeviceObjSetSkipUpdateCaps(virNodeDeviceObjPtr obj,
virNodeDeviceObjPtr
virNodeDeviceObjListFindMediatedDeviceByUUID(virNodeDeviceObjListPtr devs,
const char *uuid);
+
+bool
+virNodeDeviceObjIsActive(virNodeDeviceObjPtr obj);
+
+void
+virNodeDeviceObjSetActive(virNodeDeviceObjPtr obj,
+ bool active);
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 01c2e710cd..9e102e328a 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1189,6 +1189,7 @@ virNetworkPortDefSaveStatus;
# conf/virnodedeviceobj.h
virNodeDeviceObjEndAPI;
virNodeDeviceObjGetDef;
+virNodeDeviceObjIsActive;
virNodeDeviceObjListAssignDef;
virNodeDeviceObjListExport;
virNodeDeviceObjListFindByName;
@@ -1201,6 +1202,7 @@ virNodeDeviceObjListGetParentHost;
virNodeDeviceObjListNew;
virNodeDeviceObjListNumOfDevices;
virNodeDeviceObjListRemove;
+virNodeDeviceObjSetActive;
# conf/virnwfilterbindingdef.h
diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c
index ff558efb83..bce5466131 100644
--- a/src/node_device/node_device_udev.c
+++ b/src/node_device/node_device_udev.c
@@ -1350,6 +1350,7 @@ udevAddOneDevice(struct udev_device *device)
else
event = virNodeDeviceEventUpdateNew(objdef->name);
+ virNodeDeviceObjSetActive(obj, true);
virNodeDeviceObjEndAPI(&obj);
ret = 0;
@@ -1741,6 +1742,8 @@ udevSetupSystemDev(void)
if (!(obj = virNodeDeviceObjListAssignDef(driver->devs, def)))
goto cleanup;
+ virNodeDeviceObjSetActive(obj, true);
+
virNodeDeviceObjEndAPI(&obj);
ret = 0;
--
2.26.2