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 c9bda77b2e..92f58dbf7d 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 {
@@ -976,3 +977,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 583fc5800e..fecd012300 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1203,6 +1203,7 @@ virNetworkPortDefSaveStatus;
# conf/virnodedeviceobj.h
virNodeDeviceObjEndAPI;
virNodeDeviceObjGetDef;
+virNodeDeviceObjIsActive;
virNodeDeviceObjListAssignDef;
virNodeDeviceObjListExport;
virNodeDeviceObjListFindByName;
@@ -1215,6 +1216,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 55a2731681..208f256895 100644
--- a/src/node_device/node_device_udev.c
+++ b/src/node_device/node_device_udev.c
@@ -1536,6 +1536,7 @@ udevAddOneDevice(struct udev_device *device)
else
event = virNodeDeviceEventUpdateNew(objdef->name);
+ virNodeDeviceObjSetActive(obj, true);
virNodeDeviceObjEndAPI(&obj);
ret = 0;
@@ -1921,6 +1922,8 @@ udevSetupSystemDev(void)
if (!(obj = virNodeDeviceObjListAssignDef(driver->devs, def)))
goto cleanup;
+ virNodeDeviceObjSetActive(obj, true);
+
virNodeDeviceObjEndAPI(&obj);
ret = 0;
--
2.26.2