<div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-size:small"><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Aug 24, 2023 at 10:57 AM Michal Privoznik <<a href="mailto:mprivozn@redhat.com">mprivozn@redhat.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">It is possible for 'mdevctl' to output nothing, an empty string<br>
(e.g. when no mediated devices are defined on the host). What is<br>
weird is that when passing '--defined' then 'mdevctl' outputs an<br>
empty JSON array instead. Nevertheless, we should accept both and<br>
threat them the same, i.e. as no mediated devices.<br></blockquote><div> </div><div><span class="gmail_default" style="font-size:small">*treat</span></div><div><span class="gmail_default" style="font-size:small"><br></span> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
Resolves: <a href="https://gitlab.com/libvirt/libvirt/-/issues/523" rel="noreferrer" target="_blank">https://gitlab.com/libvirt/libvirt/-/issues/523</a><br>
Signed-off-by: Michal Privoznik <<a href="mailto:mprivozn@redhat.com" target="_blank">mprivozn@redhat.com</a>><br>
---<br>
src/node_device/node_device_driver.c | 7 +++++++<br>
1 file changed, 7 insertions(+)<br>
<br>
diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_device_driver.c<br>
index 2ef9197adc..593bc64e25 100644<br>
--- a/src/node_device/node_device_driver.c<br>
+++ b/src/node_device/node_device_driver.c<br>
@@ -43,6 +43,7 @@<br>
#include "virutil.h"<br>
#include "vircommand.h"<br>
#include "virlog.h"<br>
+#include "virstring.h"<br>
<br>
#define VIR_FROM_THIS VIR_FROM_NODEDEV<br>
<br>
@@ -1176,6 +1177,12 @@ nodeDeviceParseMdevctlJSON(const char *jsonstring,<br>
size_t j;<br>
virJSONValue *obj;<br>
<br>
+ if (virStringIsEmpty(jsonstring)) {<br>
+ VIR_DEBUG("mdevctl has no defined mediated devices");<br>
+ *devs = NULL;<br>
+ return 0;<br>
+ }<br>
+<br>
json_devicelist = virJSONValueFromString(jsonstring);<br>
<br>
if (!json_devicelist || !virJSONValueIsArray(json_devicelist)) {<br>
-- <br>
2.41.0<br>
<br></blockquote><div><br></div><div><div><div><div><div style="font-size:large" class="gmail_default"><font size="2">Reviewed-by: Kristina Hanicova <<a href="mailto:khanicov@redhat.com" target="_blank">khanicov@redhat.com</a>></font></div><font color="#888888" style="--darkreader-inline-color: #b2a696;"><font color="#888888" style="--darkreader-inline-color: #b2a696;"><font color="#888888" style="--darkreader-inline-color: #b2a696;"><font color="#888888" style="--darkreader-inline-color: #b2a696;"><font color="#888888" style="--darkreader-inline-color: #b2a696;"><font color="#888888" style="--darkreader-inline-color: #b2a696;"><font color="#888888" style="--darkreader-inline-color: #b2a696;"><div style="font-size:large" class="gmail_default"><font size="2">Kristina</font></div></font></font></font></font></font></font></font></div></div></div></div></div></div>