]> git.ipfire.org Git - thirdparty/libvirt.git/commit
nodedev: Handle NULL command variable
authorJonathon Jongsma <jjongsma@redhat.com>
Tue, 22 Jun 2021 19:53:33 +0000 (14:53 -0500)
committerMichal Privoznik <mprivozn@redhat.com>
Thu, 1 Jul 2021 14:34:03 +0000 (16:34 +0200)
commit2a615af38fdcde269229bc57f1ded8209f0b5b7e
tree3867922f29fd53e9c44269e2010fefdf354816ba
parenta96df6424fba66c25be996ca624f3e5660f25821
nodedev: Handle NULL command variable

In commit 68580a51, I removed the checks for NULL cmd variables because
virCommandRun() already handles the case where it is called with a NULL
cmd. Unfortunately, it handles this case by raising a generic error
which is both unhelpful and overwrites our existing error message. So
for example, when I attempt to create a mediated device with an invalid
parent, I get the following output:

    virsh # nodedev-create mdev-test.xml
    error: Failed to create node device from mdev-test.xml
    error: internal error: invalid use of command API

With this patch, I now get a useful error message again:

    virsh # nodedev-create mdev-test.xml
    error: Failed to create node device from mdev-test.xml
    error: internal error: unable to find parent device 'pci_0000_00_03_0'

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
src/node_device/node_device_driver.c