[PATCH] nodedev: update transient mdevs

Boris Fiuczynski posted 1 patch 11 months, 1 week ago
Failed in applying to current master (apply log)
src/node_device/node_device_driver.c | 31 ++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
[PATCH] nodedev: update transient mdevs
Posted by Boris Fiuczynski 11 months, 1 week ago
Instead of updating defined mdevs only add another update for active
devices as well to cover transient mdev devices as well.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2143158
Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
---
 src/node_device/node_device_driver.c | 31 ++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_device_driver.c
index 3cac25a10c..a2d0600560 100644
--- a/src/node_device/node_device_driver.c
+++ b/src/node_device/node_device_driver.c
@@ -1636,6 +1636,24 @@ virMdevctlListDefined(virNodeDeviceDef ***devs, char **errmsg)
 }
 
 
+static int
+virMdevctlListActive(virNodeDeviceDef ***devs, char **errmsg)
+{
+    int status;
+    g_autofree char *output = NULL;
+    g_autoptr(virCommand) cmd = nodeDeviceGetMdevctlListCommand(false, &output, errmsg);
+
+    if (virCommandRun(cmd, &status) < 0 || status != 0) {
+        return -1;
+    }
+
+    if (!output)
+        return -1;
+
+    return nodeDeviceParseMdevctlJSON(output, devs);
+}
+
+
 typedef struct _virMdevctlForEachData virMdevctlForEachData;
 struct _virMdevctlForEachData {
     int ndefs;
@@ -1699,6 +1717,8 @@ int
 nodeDeviceUpdateMediatedDevices(void)
 {
     g_autofree virNodeDeviceDef **defs = NULL;
+    g_autofree virNodeDeviceDef **act_defs = NULL;
+    int act_ndefs = 0;
     g_autofree char *errmsg = NULL;
     g_autofree char *mdevctl = NULL;
     virMdevctlForEachData data = { 0, };
@@ -1725,6 +1745,17 @@ nodeDeviceUpdateMediatedDevices(void)
         if (nodeDeviceUpdateMediatedDevice(defs[i]) < 0)
             return -1;
 
+    /* Update active/transient mdev devices */
+    if ((act_ndefs = virMdevctlListActive(&act_defs, &errmsg)) < 0) {
+        virReportError(VIR_ERR_INTERNAL_ERROR,
+                       _("failed to query mdevs from mdevctl: %1$s"), errmsg);
+        return -1;
+    }
+
+    for (i = 0; i < act_ndefs; i++)
+        if (nodeDeviceUpdateMediatedDevice(act_defs[i]) < 0)
+            return -1;
+
     return 0;
 }
 
-- 
2.39.0
Re: [PATCH] nodedev: update transient mdevs
Posted by Boris Fiuczynski 10 months, 3 weeks ago
Polite ping.

On 5/8/23 7:10 PM, Boris Fiuczynski wrote:
> Instead of updating defined mdevs only add another update for active
> devices as well to cover transient mdev devices as well.
> 
> Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2143158
> Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
> ---
>   src/node_device/node_device_driver.c | 31 ++++++++++++++++++++++++++++
>   1 file changed, 31 insertions(+)
> 
> diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_device_driver.c
> index 3cac25a10c..a2d0600560 100644
> --- a/src/node_device/node_device_driver.c
> +++ b/src/node_device/node_device_driver.c
> @@ -1636,6 +1636,24 @@ virMdevctlListDefined(virNodeDeviceDef ***devs, char **errmsg)
>   }
>   
>   
> +static int
> +virMdevctlListActive(virNodeDeviceDef ***devs, char **errmsg)
> +{
> +    int status;
> +    g_autofree char *output = NULL;
> +    g_autoptr(virCommand) cmd = nodeDeviceGetMdevctlListCommand(false, &output, errmsg);
> +
> +    if (virCommandRun(cmd, &status) < 0 || status != 0) {
> +        return -1;
> +    }
> +
> +    if (!output)
> +        return -1;
> +
> +    return nodeDeviceParseMdevctlJSON(output, devs);
> +}
> +
> +
>   typedef struct _virMdevctlForEachData virMdevctlForEachData;
>   struct _virMdevctlForEachData {
>       int ndefs;
> @@ -1699,6 +1717,8 @@ int
>   nodeDeviceUpdateMediatedDevices(void)
>   {
>       g_autofree virNodeDeviceDef **defs = NULL;
> +    g_autofree virNodeDeviceDef **act_defs = NULL;
> +    int act_ndefs = 0;
>       g_autofree char *errmsg = NULL;
>       g_autofree char *mdevctl = NULL;
>       virMdevctlForEachData data = { 0, };
> @@ -1725,6 +1745,17 @@ nodeDeviceUpdateMediatedDevices(void)
>           if (nodeDeviceUpdateMediatedDevice(defs[i]) < 0)
>               return -1;
>   
> +    /* Update active/transient mdev devices */
> +    if ((act_ndefs = virMdevctlListActive(&act_defs, &errmsg)) < 0) {
> +        virReportError(VIR_ERR_INTERNAL_ERROR,
> +                       _("failed to query mdevs from mdevctl: %1$s"), errmsg);
> +        return -1;
> +    }
> +
> +    for (i = 0; i < act_ndefs; i++)
> +        if (nodeDeviceUpdateMediatedDevice(act_defs[i]) < 0)
> +            return -1;
> +
>       return 0;
>   }
>   
> 


-- 
Mit freundlichen Grüßen/Kind regards
    Boris Fiuczynski

IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Gregor Pillen
Geschäftsführung: David Faller
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294
Re: [PATCH] nodedev: update transient mdevs
Posted by Jonathon Jongsma 10 months, 3 weeks ago
Sorry for the delay

Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>

On 5/22/23 5:56 AM, Boris Fiuczynski wrote:
> Polite ping.
> 
> On 5/8/23 7:10 PM, Boris Fiuczynski wrote:
>> Instead of updating defined mdevs only add another update for active
>> devices as well to cover transient mdev devices as well.
>>
>> Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2143158
>> Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
>> ---
>>   src/node_device/node_device_driver.c | 31 ++++++++++++++++++++++++++++
>>   1 file changed, 31 insertions(+)
>>
>> diff --git a/src/node_device/node_device_driver.c 
>> b/src/node_device/node_device_driver.c
>> index 3cac25a10c..a2d0600560 100644
>> --- a/src/node_device/node_device_driver.c
>> +++ b/src/node_device/node_device_driver.c
>> @@ -1636,6 +1636,24 @@ virMdevctlListDefined(virNodeDeviceDef ***devs, 
>> char **errmsg)
>>   }
>> +static int
>> +virMdevctlListActive(virNodeDeviceDef ***devs, char **errmsg)
>> +{
>> +    int status;
>> +    g_autofree char *output = NULL;
>> +    g_autoptr(virCommand) cmd = 
>> nodeDeviceGetMdevctlListCommand(false, &output, errmsg);
>> +
>> +    if (virCommandRun(cmd, &status) < 0 || status != 0) {
>> +        return -1;
>> +    }
>> +
>> +    if (!output)
>> +        return -1;
>> +
>> +    return nodeDeviceParseMdevctlJSON(output, devs);
>> +}
>> +
>> +
>>   typedef struct _virMdevctlForEachData virMdevctlForEachData;
>>   struct _virMdevctlForEachData {
>>       int ndefs;
>> @@ -1699,6 +1717,8 @@ int
>>   nodeDeviceUpdateMediatedDevices(void)
>>   {
>>       g_autofree virNodeDeviceDef **defs = NULL;
>> +    g_autofree virNodeDeviceDef **act_defs = NULL;
>> +    int act_ndefs = 0;
>>       g_autofree char *errmsg = NULL;
>>       g_autofree char *mdevctl = NULL;
>>       virMdevctlForEachData data = { 0, };
>> @@ -1725,6 +1745,17 @@ nodeDeviceUpdateMediatedDevices(void)
>>           if (nodeDeviceUpdateMediatedDevice(defs[i]) < 0)
>>               return -1;
>> +    /* Update active/transient mdev devices */
>> +    if ((act_ndefs = virMdevctlListActive(&act_defs, &errmsg)) < 0) {
>> +        virReportError(VIR_ERR_INTERNAL_ERROR,
>> +                       _("failed to query mdevs from mdevctl: %1$s"), 
>> errmsg);
>> +        return -1;
>> +    }
>> +
>> +    for (i = 0; i < act_ndefs; i++)
>> +        if (nodeDeviceUpdateMediatedDevice(act_defs[i]) < 0)
>> +            return -1;
>> +
>>       return 0;
>>   }
>>
> 
>