[libvirt PATCH v6 26/30] nodedev: add ability to specify UUID for new mdevs

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

 



Use the new <uuid> element in the mdev caps to define and start devices
with a specific UUID.

Signed-off-by: Jonathon Jongsma <jjongsma@xxxxxxxxxx>
---
 src/node_device/node_device_driver.c          | 19 ++++++++++++++++---
 ...19_36ea_4111_8f0a_8c9a70e21366-define.argv |  3 ++-
 ...019_36ea_4111_8f0a_8c9a70e21366-start.argv |  3 ++-
 ...v_d069d019_36ea_4111_8f0a_8c9a70e21366.xml |  1 +
 4 files changed, 21 insertions(+), 5 deletions(-)

diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_device_driver.c
index cd7677633a..b1b3217afb 100644
--- a/src/node_device/node_device_driver.c
+++ b/src/node_device/node_device_driver.c
@@ -729,6 +729,10 @@ nodeDeviceGetMdevctlDefineStartCommand(virNodeDeviceDef *def,
                                NULL);
 
     virCommandSetInputBuffer(cmd, json);
+
+    if (def->caps->data.mdev.uuid)
+        virCommandAddArgPair(cmd, "--uuid", def->caps->data.mdev.uuid);
+
     virCommandSetOutputBuffer(cmd, uuid_out);
     virCommandSetErrorBuffer(cmd, errmsg);
 
@@ -816,7 +820,12 @@ nodeDeviceCreateXMLMdev(virConnectPtr conn,
         return NULL;
     }
 
-    return nodeDeviceFindNewMediatedDevice(conn, uuid);
+    if (uuid && uuid[0]) {
+        g_free(def->caps->data.mdev.uuid);
+        def->caps->data.mdev.uuid = g_steal_pointer(&uuid);
+    }
+
+    return nodeDeviceFindNewMediatedDevice(conn, def->caps->data.mdev.uuid);
 }
 
 
@@ -1230,9 +1239,13 @@ nodeDeviceDefineXML(virConnect *conn,
         return NULL;
     }
 
-    def->caps->data.mdev.uuid = g_strdup(uuid);
+    if (uuid && uuid[0]) {
+        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);
 
     return device;
 }
diff --git a/tests/nodedevmdevctldata/mdev_d069d019_36ea_4111_8f0a_8c9a70e21366-define.argv b/tests/nodedevmdevctldata/mdev_d069d019_36ea_4111_8f0a_8c9a70e21366-define.argv
index 773e98b963..118ec7a8da 100644
--- a/tests/nodedevmdevctldata/mdev_d069d019_36ea_4111_8f0a_8c9a70e21366-define.argv
+++ b/tests/nodedevmdevctldata/mdev_d069d019_36ea_4111_8f0a_8c9a70e21366-define.argv
@@ -1 +1,2 @@
-$MDEVCTL_BINARY$ define -p 0000:00:02.0 --jsonfile /dev/stdin
+$MDEVCTL_BINARY$ define -p 0000:00:02.0 --jsonfile /dev/stdin \
+--uuid=d069d019-36ea-4111-8f0a-8c9a70e21366
diff --git a/tests/nodedevmdevctldata/mdev_d069d019_36ea_4111_8f0a_8c9a70e21366-start.argv b/tests/nodedevmdevctldata/mdev_d069d019_36ea_4111_8f0a_8c9a70e21366-start.argv
index eb7262035e..129f438e4a 100644
--- a/tests/nodedevmdevctldata/mdev_d069d019_36ea_4111_8f0a_8c9a70e21366-start.argv
+++ b/tests/nodedevmdevctldata/mdev_d069d019_36ea_4111_8f0a_8c9a70e21366-start.argv
@@ -1 +1,2 @@
-$MDEVCTL_BINARY$ start -p 0000:00:02.0 --jsonfile /dev/stdin
+$MDEVCTL_BINARY$ start -p 0000:00:02.0 --jsonfile /dev/stdin \
+--uuid=d069d019-36ea-4111-8f0a-8c9a70e21366
diff --git a/tests/nodedevschemadata/mdev_d069d019_36ea_4111_8f0a_8c9a70e21366.xml b/tests/nodedevschemadata/mdev_d069d019_36ea_4111_8f0a_8c9a70e21366.xml
index d6a2e99edc..605d8f63a1 100644
--- a/tests/nodedevschemadata/mdev_d069d019_36ea_4111_8f0a_8c9a70e21366.xml
+++ b/tests/nodedevschemadata/mdev_d069d019_36ea_4111_8f0a_8c9a70e21366.xml
@@ -3,5 +3,6 @@
   <parent>pci_0000_00_02_0</parent>
   <capability type='mdev'>
     <type id='i915-GVTg_V5_8'/>
+    <uuid>d069d019-36ea-4111-8f0a-8c9a70e21366</uuid>
   </capability>
 </device>
-- 
2.26.3




[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]

  Powered by Linux