[PATCH v2] nodedev: fix internal error when no defined mdevs exist
Martin Kletzander
mkletzan at redhat.com
Thu Jul 15 12:16:11 UTC 2021
On Wed, Jul 14, 2021 at 06:40:57PM +0200, Boris Fiuczynski wrote:
>Commit e9b534905f4 introduced an error when parsing an empty list
>returned from mdevctl.
>
>This occurs e.g. if nodedev-undefine is used to undefine the last
>defined mdev which cuases the following error messages
>
causes
> libvirtd[33143]: internal error: Unexpected format for mdevctl response
> libvirtd[33143]: internal error: failed to query mdevs from mdevctl:
> libvirtd[33143]: mdevctl failed to updated mediated devices
>
>Signed-off-by: Boris Fiuczynski <fiuczy at linux.ibm.com>
>---
> src/node_device/node_device_driver.c | 5 +++++
> tests/nodedevmdevctldata/mdevctl-list-empty.json | 1 +
> tests/nodedevmdevctldata/mdevctl-list-empty.out.xml | 0
> tests/nodedevmdevctltest.c | 1 +
> 4 files changed, 7 insertions(+)
> create mode 100644 tests/nodedevmdevctldata/mdevctl-list-empty.json
> create mode 100644 tests/nodedevmdevctldata/mdevctl-list-empty.out.xml
>
>diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_device_driver.c
>index b4dd57e5f4..b16b05f9b2 100644
>--- a/src/node_device/node_device_driver.c
>+++ b/src/node_device/node_device_driver.c
>@@ -1120,6 +1120,11 @@ nodeDeviceParseMdevctlJSON(const char *jsonstring,
> goto error;
> }
>
>+ if (virJSONValueArraySize(json_devicelist) == 0) {
>+ *devs = outdevs;
>+ return 0;
It would be more clear if you just did:
*devs = NULL;
And I, personally, would also add a VIR_DEBUG here.
Other than that
Reviewed-by: Martin Kletzander <mkletzan at redhat.com>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20210715/a7776de7/attachment-0001.sig>
More information about the libvir-list
mailing list