On Fri, Mar 26, 2021 at 11:48:12AM -0500, Jonathon Jongsma wrote:
With mediated devices, we can now define persistent node devices
that
can be started and stopped. In order to take advantage of this, we need
an API to define new node devices.
Signed-off-by: Jonathon Jongsma <jjongsma(a)redhat.com>
---
include/libvirt/libvirt-nodedev.h | 4 ++
src/driver-nodedev.h | 6 +++
src/libvirt-nodedev.c | 42 ++++++++++++++++
src/libvirt_public.syms | 1 +
src/node_device/node_device_driver.c | 71 ++++++++++++++++++++++++++++
src/node_device/node_device_driver.h | 5 ++
src/node_device/node_device_udev.c | 1 +
src/remote/remote_driver.c | 1 +
src/remote/remote_protocol.x | 17 ++++++-
src/remote_protocol-structs | 8 ++++
src/rpc/gendispatch.pl | 1 +
11 files changed, 156 insertions(+), 1 deletion(-)
diff --git a/include/libvirt/libvirt-nodedev.h b/include/libvirt/libvirt-nodedev.h
index 77d814935e..33eb46b3cd 100644
--- a/include/libvirt/libvirt-nodedev.h
+++ b/include/libvirt/libvirt-nodedev.h
@@ -131,6 +131,10 @@ virNodeDevicePtr virNodeDeviceCreateXML (virConnectPtr
conn,
int virNodeDeviceDestroy (virNodeDevicePtr dev);
+virNodeDevicePtr virNodeDeviceDefineXML(virConnectPtr conn,
+ const char *xmlDesc,
+ unsigned int flags);
+
/**
* VIR_NODE_DEVICE_EVENT_CALLBACK:
*
diff --git a/src/driver-nodedev.h b/src/driver-nodedev.h
index d0fc7f19cf..64a0a7c473 100644
--- a/src/driver-nodedev.h
+++ b/src/driver-nodedev.h
@@ -74,6 +74,11 @@ typedef virNodeDevicePtr
typedef int
(*virDrvNodeDeviceDestroy)(virNodeDevicePtr dev);
+typedef virNodeDevice*
typedef virNodeDevice *
+(*virDrvNodeDeviceDefineXML)(virConnect *conn,
+ const char *xmlDesc,
+ unsigned int flags);
+
typedef int
(*virDrvConnectNodeDeviceEventRegisterAny)(virConnectPtr conn,
virNodeDevicePtr dev,
@@ -113,4 +118,5 @@ struct _virNodeDeviceDriver {
virDrvNodeDeviceListCaps nodeDeviceListCaps;
virDrvNodeDeviceCreateXML nodeDeviceCreateXML;
virDrvNodeDeviceDestroy nodeDeviceDestroy;
+ virDrvNodeDeviceDefineXML nodeDeviceDefineXML;
};
diff --git a/src/libvirt-nodedev.c b/src/libvirt-nodedev.c
index fb707b570f..cfc0c9de5b 100644
--- a/src/libvirt-nodedev.c
+++ b/src/libvirt-nodedev.c
@@ -737,6 +737,48 @@ virNodeDeviceDestroy(virNodeDevicePtr dev)
}
+/**
+ * virNodeDeviceDefineXML:
+ * @conn: pointer to the hypervisor connection
+ * @xmlDesc: string containing an XML description of the device to be defined
+ * @flags: extra flags; not used yet, so callers should always pass 0
+ *
+ * Define a new device on the VM host machine, for example, a mediated device
+ *
+ * virNodeDeviceFree should be used to free the resources after the
+ * node device object is no longer needed.
+ *
+ * Returns a node device object if successful, NULL in case of failure
+ */
+virNodeDevice*
Actually, I think we should keep the Ptr variant in the public APIs. I remember
the conclusion to the Ptr discussion was to keep the typedef wrt to public
headers and API entrypoints. This is a new API so it's a bit different, but I
think for consistency reasons we ought to keep using Ptr for public API
everywhere, even new APIs (this is the case for all the APIs you added).
My R-b still stands, ^this is not a show-stopper.
Erik