On Wed, Feb 03, 2021 at 11:39:08AM -0600, Jonathon Jongsma wrote:
Use the new <uuid> element in the mdev caps to define and start
devices
with a specific UUID.
Signed-off-by: Jonathon Jongsma <jjongsma(a)redhat.com>
---
src/node_device/node_device_driver.c | 18 +++++++++++++++---
...019_36ea_4111_8f0a_8c9a70e21366-define.argv | 3 ++-
...d019_36ea_4111_8f0a_8c9a70e21366-start.argv | 3 ++-
...ev_d069d019_36ea_4111_8f0a_8c9a70e21366.xml | 1 +
4 files changed, 20 insertions(+), 5 deletions(-)
diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_device_driver.c
index d5cdf2b097..bf97291041 100644
--- a/src/node_device/node_device_driver.c
+++ b/src/node_device/node_device_driver.c
@@ -728,6 +728,10 @@ nodeDeviceGetMdevctlDefineStartCommand(virNodeDeviceDefPtr def,
NULL);
virCommandSetInputBuffer(cmd, json);
+
+ if (def->caps->data.mdev.uuid)
+ virCommandAddArgPair(cmd, "--uuid", def->caps->data.mdev.uuid);
+
virCommandSetOutputBuffer(cmd, uuid_out);
return cmd;
@@ -806,8 +810,12 @@ nodeDeviceCreateXMLMdev(virConnectPtr conn,
_("Unable to start mediated device"));
return NULL;
}
+ if (uuid) {
mdevctl returns an empty string when UUID was provided, so this has to become
'if (uuid && uuid[0])'
+ g_free(def->caps->data.mdev.uuid);
+ def->caps->data.mdev.uuid = g_steal_pointer(&uuid);
+ }
- return nodeDeviceFindNewMediatedDevice(conn, uuid);
+ return nodeDeviceFindNewMediatedDevice(conn, def->caps->data.mdev.uuid);
}
@@ -1213,9 +1221,13 @@ nodeDeviceDefineXML(virConnectPtr conn,
return NULL;
}
- def->caps->data.mdev.uuid = g_strdup(uuid);
+ if (uuid) {
^Here too...
Erik
+ g_free(def->caps->data.mdev.uuid);
+ def->caps->data.mdev.uuid = g_steal_pointer(&uuid);
+ }
+
mdevGenerateDeviceName(def);
- device = nodeDeviceFindNewMediatedDevice(conn, uuid);
+ device = nodeDeviceFindNewMediatedDevice(conn, def->caps->data.mdev.uuid);