summaryrefslogtreecommitdiff
path: root/src/node_device
Commit message (Collapse)AuthorAgeFilesLines
* meson: Use initconfdirAndrea Bolognani2023-05-051-1/+1
| | | | | Signed-off-by: Andrea Bolognani <abologna@redhat.com> Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
* node_device: Update format strings in translated messagesJiri Denemark2023-04-012-44/+42
| | | | | Signed-off-by: Jiri Denemark <jdenemar@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
* util: remove waitForLock from virPidFileAcquireJán Tomko2023-03-081-1/+1
| | | | | | | | | | | The parameter was added for consistency with virPidFileAcquirePath. However, all callers of virPidFileAcquire pass false. Remove the argument. Partially-reverts: 2250a2b5d21c3b3529727f38a99cba22f84024f7 Signed-off-by: Ján Tomko <jtomko@redhat.com> Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
* nodedev: ignore EINVAL from libudev in udevEventHandleThreadChristian Ehrhardt2022-11-101-2/+4
| | | | | | | | | | | | | | | | | | | | | | Certain udev entries might be of a size that makes libudev emit EINVAL which right now leads to udevEventHandleThread exiting. Due to no more handling events other elements of libvirt will start pushing for events to be consumed which never happens causing a busy loop burning a cpu without any gain. After evaluation of the example case discussed in in #245 and a test run ignoring EINVAL it was considered safe to add EINVAL to the ignored errnos to not exit udevEventHandleThread giving it more resilience. The root cause is in systemd and by now was discussed and fixed via https://github.com/systemd/systemd/issues/24987, but hardening libvirt to be able to better deal with EINVAL returned still is the right thing to avoid the reported busy loops on systemd with older systemd versions. Fixes: https://gitlab.com/libvirt/libvirt/-/issues/245 Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
* nodedev|test: Implement support for validating node device XMLsPeter Krempa2022-11-011-4/+6
| | | | | Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
* conf: node_device: Add 'validate' argument to virNodeDeviceDefParsePeter Krempa2022-11-011-2/+2
| | | | | | | | Allow callers to request XML validation against the schema. All callers for now pass 'false'. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
* node_device_driver.h: Drop nodeDeviceLock() and nodeDeviceUnlock() fwd ↵Michal Privoznik2022-10-261-6/+0
| | | | | | | | | | | | declarations The node_device_driver.h declares nodeDeviceLock() and nodeDeviceUnlock() functions which used to exist, but after rework to automatic mutex management they exist no more. Their last use was removed in v8.1.0-rc1~122. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
* node_device: Move fwd declaration of udevNodeRegister() into correct header fileMichal Privoznik2022-10-263-6/+6
| | | | | | | | | | Currently, udevNodeRegister() is forward declared in node_device_driver.h even though the function is implemented in node_device_udev.c which warrants node_device_udev.h header file. Move the declaration into the correct file. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
* node_device_udev.h: Drop include of libudev.hMichal Privoznik2022-10-261-2/+0
| | | | | | | | Nothing in the header file requires the include of libudev.h, as the former header file is now empty. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
* node_device: Move DMI_DEVPATH into node_device_udev.cMichal Privoznik2022-10-262-2/+2
| | | | | | | | The DMI_DEVPATH macro is used exclusively within node_device_udev.c. There's no need to expose it. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
* node_device_udev.h: Drop unused macroMichal Privoznik2022-10-261-1/+0
| | | | | | | | The SYSFS_DATA_SIZE macro is Unused since its introduction in v0.7.3~48. Sorry Dave. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
* conf: nodedev: Provide only virNodeDeviceDefParsePeter Krempa2022-10-061-4/+4
| | | | | | | | Replace the thin wrappers virNodeDeviceDefParseString/File by directly calling the main parser. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
* virStateInitialize: Propagate whether running in monolithic daemon mode to ↵Peter Krempa2022-09-131-0/+1
| | | | | | | | | | | | | stateful driver init Upcoming patch which is fixing the opening of drivers in monolithic mode needs to know whether we are inside 'libvirtd' but the code where the decision needs to happen is not re-compiled per daemon. Thus we need to pass this information to the stateful driver init function so that it can be remebered. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
* nodedev: wait a bit longer for new node devicesJonathon Jongsma2022-08-251-1/+1
| | | | | | | | | | | | | | | | | | | | | Openstack developers reported that newly-created mdevs were not recognized by libvirt until after a libvirt daemon restart. The source of the problem appears to be that when libvirt gets the udev 'add' event, the sysfs tree for that device might not be ready and so libvirt waits 100ms for it to appear (max 100 waits of 1ms each). But in the OpenStack environment, the sysfs tree for new mediated devices was taking closer to 250ms to appear and therefore libvirt gave up waiting and didn't add these new devices to its list of nodedevs. By changing the wait time to 1 second (max 100 waits of 10ms each), this should provide enough time to enable these deployments to recognize newly-created mediated devices, but it shouldn't increase the delay for more traditional deployments too much. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2109450 Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com> Reviewed-by: Erik Skultety <eskultet@redhat.com>
* nodedev: support 'mtty' device for testingJonathon Jongsma2022-08-102-1/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | It would be nice to be able to test the mediated device capabilities without having physical hardware which supports it. The 'mtty' kernel module presents a virtual parent device which is capable of creating 'fake' mediated devices, and as such it would be useful for testing. However, the 'mtty' device is not part of an existing device subsystem (e.g. PCI, etc), so libvirt ignores it and it does not get added to the node device list. And because it does not get added to the node device list, it cannot be used to create child mdevs using `virsh nodedev-create`. There is already a node device type capability VIR_NODE_DEV_CAP_MDEV_TYPES that indicates whether a device supports creating child mediated devices, but libvirt assumes that this is a nested capability (in other words, it assumes that the primary capability of a device is something like PCI). If we allow this MDEV_TYPES capability to be a primary device capability, then we can support virtual devices like 'mtty' as a parent for mediated devices. See https://bugzilla.redhat.com/show_bug.cgi?id=2107031 Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
* node_device: Remove unused includesPeng Liang2022-06-162-6/+0
| | | | | Signed-off-by: Peng Liang <tcx4c70@gmail.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
* nodedev: prevent internal error on dev_busid parseBoris Fiuczynski2022-05-241-1/+1
| | | | | | | | | As "none" is a legal value represented in the sysfs attribute dev_busid this patch prevents libvirt from incorrectly reporting an internal error. Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com> Suggested-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
* nodedev: add optional device address of channel device to css deviceBoris Fiuczynski2022-05-231-0/+8
| | | | | | | | | | | | Add the new introduced sysfs attribute dev_busid which provides the address of the device in the subchannel independent from the bound device driver. It is added if available in the sysfs as optional channel_dev_addr element into the css device capabilty providing the ccw deivce address attributes cssid, ssid and devno. Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com> Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
* util: add ccw device address parsing into virccwBoris Fiuczynski2022-05-231-3/+5
| | | | | | | Add virCCWDeviceAddressParseFromString and use it in nodedev udev. Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
* util: refactor virDomainCCWAddressAsString into virccwBoris Fiuczynski2022-05-231-1/+1
| | | | | | | | Move virDomainCCWAddressAsString into virccw and rename method as virCCWDeviceAddressAsString. Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
* util: refactor virDomainDeviceCCWAddress into virccw.hBoris Fiuczynski2022-05-231-1/+1
| | | | | | | | Refactor ccw data structure virDomainDeviceCCWAddress into util virccw.h and rename it as virCCWDeviceAddress. Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
* node_device_udev: Use automatic mutex managementTim Wiederhake2022-04-051-41/+35
| | | | | Signed-off-by: Tim Wiederhake <twiederh@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
* node_device_driver: Use automatic mutex managementTim Wiederhake2022-04-051-8/+4
| | | | | Signed-off-by: Tim Wiederhake <twiederh@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
* nodedev: trigger mdev device definition update on udev add and removeBoris Fiuczynski2022-03-171-0/+9
| | | | | | | | | | When nodedev objects are added and removed if possible check if mdev-types is supported by the object and trigger a mdev device definition update to correct the associated parent nodedevs. Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
* nodedev: update mdevs on parent changeBoris Fiuczynski2022-03-171-2/+4
| | | | | | | | | | The parent of the mdev definition can change due to the existance of the parent device. The parents existance can e.g. depend on the device driver load state. Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
* nodedev: fix typo in mdevctl update warningBoris Fiuczynski2022-03-171-1/+1
| | | | | | Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com> Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
* src: Initialize stack allocated virPCIDeviceAddress variablesMichal Privoznik2022-02-111-1/+1
| | | | | | | | | | | | | | | | | | | | | | There are few places where a virPCIDeviceAddress typed variable is allocated on the stack but it's not initialized. This can lead to random values of its members which in turn can lead to a random behaviour. Generated with help of the following spatch: @@ identifier I; @@ - virPCIDeviceAddress I; + virPCIDeviceAddress I = { 0 }; And then fixing bhyveAssignDevicePCISlots() which does declare the variable and then explicitly zero it by calling memset() only to set a specific member afterwards. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
* node_device: Use automatic mutex managementTim Wiederhake2022-02-112-49/+26
| | | | | Signed-off-by: Tim Wiederhake <twiederh@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
* meson: Add missing virt_install_dirsAndrea Bolognani2022-02-021-0/+4
| | | | | | | | | | We recently started listing these in the spec file and, since we were not creating them during the installation phase, that broke RPM builds. Fixes: 4b43da0bff9b78dcf1189388d4c89e524238b41d Signed-off-by: Andrea Bolognani <abologna@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
* systemd: Use correct man page name in modular daemon service filesPeter Krempa2022-02-011-1/+1
| | | | | | | | | The service files were copied out of the service file for libvirtd and the name of the corresponding manpage was not fixed. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2045959 Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
* node_device: Treat NVMe disks as regular disksMichal Privoznik2022-01-271-0/+5
| | | | | | | | | | Unfortunately, udev doesn't set ID_TYPE attribute for NVMe disks, therefore we have to add another case into udevKludgeStorageType() to treat /dev/nvme* devlinks as any other disk. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2045953 Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Peter Krempa <pkrempa@redhat.com>
* node_device: Rework udevKludgeStorageType()Michal Privoznik2022-01-271-20/+23
| | | | | | | | | | | The udevKludgeStorageType() function looks at devlink name (/dev/XXX) and guesses the type of the (storage) device using a series of STRPREFIX() calls. Well those can be turn into an array and a for() loop, especially if we are about to add a new case (in the next commit). Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Peter Krempa <pkrempa@redhat.com>
* remove sysconfig filesOlaf Hering2022-01-173-8/+1
| | | | | | | | | | | | | | | | | | | | sysconfig files are owned by the admin of the host. They have the liberty to put anything they want into these files. This makes it difficult to provide different built-in defaults. Remove the sysconfig file and place the current desired default into the service file. Local customizations can now go either into /etc/sysconfig/name or /etc/systemd/system/name.service.d/my-knobs.conf Attempt to handle upgrades in libvirt.spec. Dirty files which are marked as %config will be renamed to file.rpmsave. To restore them automatically, move stale .rpmsave files away, and catch any new rpmsave files in %posttrans. Signed-off-by: Olaf Hering <olaf@aepfle.de> Reviewed-by: Andrea Bolognani <abologna@redhat.com>
* node_device: Fix memory leak in udevProcessMediatedDeviceJiri Denemark2021-10-261-11/+6
| | | | | | | | One of the paths returned -1 directly without going through the cleanup section. Signed-off-by: Jiri Denemark <jdenemar@redhat.com> Reviewed-by: Laine Stump <laine@redhat.com>
* Add PCI VPD Capability SupportDmitrii Shcherbakov2021-10-212-0/+4
| | | | | | | | | * XML serialization and deserialization of PCI VPD; * PCI VPD capability flags added and used in relevant places; * XML to XML tests for the added capability. Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Signed-off-by: Dmitrii Shcherbakov <dmitrii.shcherbakov@canonical.com>
* nodedev: Implement virNodeDeviceIsPersistent()/IsActive()Jonathon Jongsma2021-09-143-3/+63
| | | | | | | Implement these new API functions in the nodedev driver. Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
* nodedev: implement virNodeDevice(Get|Set)Autostart()Jonathon Jongsma2021-09-143-4/+160
| | | | | | | Implement autostart functionality for mediated devices. Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
* nodedev: look up mdevs by UUID and parentJonathon Jongsma2021-08-061-8/+16
| | | | | | | | | | Since UUID is not guaranteed to be unique by mdevctl, we may have more than one nodedev with the same UUID. Therefore, we need to disambiguate when looking up mdevs by specifying the UUID and parent address, which mdevctl guarantees to be a unique combination. Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
* nodedev: Handle inactive mdevs with the same UUIDJonathon Jongsma2021-08-062-2/+3
| | | | | | | | | | | | | | | | | | Unfortunately, mdevctl supports defining more than one mdev with the same UUID as long as they have different parent devices. (Only one of these devices can be active at any given time). This means that we can't use the UUID alone as a way to uniquely identify mdev node devices. Append the parent address to ensure uniqueness. For example: Before: mdev_88a6b868_46bd_4015_8e5b_26107f82da38 After: mdev_88a6b868_46bd_4015_8e5b_26107f82da38_0000_00_02_0 Related: https://bugzilla.redhat.com/show_bug.cgi?id=1979440 Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
* nodedev: add PostParse callback for nodedev parsingJonathon Jongsma2021-08-063-11/+38
| | | | | | | | | | | This can be used similarly to other postparse callbacks in libvirt -- filling in additional information that can be determined by using the information provided in the XML. In this case, we determine the address of the parent device and cache it in the mdev caps so that we can use it for generating a unique name and interacting with mdevctl. Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
* nodedev: Add parser validation for node devicesJonathon Jongsma2021-08-063-2/+71
| | | | | | | | | | At the moment, this is only for mediated devices. When a new mediated device is created or defined, the xml is expected specify the nodedev name of an existing device as its parent. We were not previously validating this and were simply accepting any string here. Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
* nodedev: cache parent address in mdev capsJonathon Jongsma2021-08-062-0/+17
| | | | | | | | | | | | | | | | | | | | | | mdevctl can report multiple defined devices with the same UUID but different parents, including parents that don't actually exist on the host machine. Libvirt sets the parent to the 'computer' device for all of the mdevs that have nonexistent parents. Because of this, it's possible that there are multiple devices with the same UUID and the same 'computer' device as their parent, so the combination of uuid and parent nodedev name is not guaranteed to be a unique name. We need to ensure that each nodedev has a unique name. If we can't use the UUID as a unique nodedev name, and we can't use the combination of UUID and nodedev parent name, we need to find another solution. By caching and using the parent name reported by mdevctl in combination with the UUID, we can achieve a unique name. mdevctl guarantees that its uuid/parent combination is unique. This value will be used to set the mdev nodedev name in a following commit. Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
* nodedev: fix xml output for mdev parents in test suiteJonathon Jongsma2021-08-061-26/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | Commit 51fbbfdce8 attempted to get the proper nodedev name for the parent of an defined mdev by traversing the filesystem and looking for a device that had the appropriate sysfs path. This works, but it would be cleaner to to avoid mucking around in the filesystem and instead just just examine the list of devices we have in memory. We already had a function nodeDeviceFindAddressByName() which constructs an address for parent device in a format that can be used with mdevctl. So if we refactor this function into a a function that simply formats an address for an arbitrary virNodeDeviceObj*, then we can use this function as a predicate for our new virNodeDeviceObjListFind() function from the previous commit. This will search our list of devices for one whose address matches the address we get from mdevctl. One nice benefit of this approach is that our test cases will now display xml output with the proper parent name for mdevs (assuming that we've added the appropriate mock parent devices to the test driver). Previously they just displayed 'computer' for the parent because the alternative would have required specially constructing a mock filesystem environment with a sysfs that mapped to the appropriate parent. Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
* util: alloc: Reimplement VIR_APPEND_ELEMENT using virAppendElementPeter Krempa2021-08-061-2/+1
| | | | | | | | | | Use virAppendElement instead of virInsertElementsN to implement VIR_APPEND_ELEMENT which allows us to remove error handling as the only relevant errors were removed when switching to aborting memory allocation functions. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
* nodedev: fix internal error when no defined mdevs existBoris Fiuczynski2021-07-221-0/+6
| | | | | | | | | | | | | | | | | 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 causes the following error messages 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@linux.ibm.com> Reviewed-by: Shalini Chellathurai Saroja <shalini@linux.ibm.com> Reviewed-by: Martin Kletzander <mkletzan@redhat.com> Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
* nodedev: fix parent device of inactive mdevsJonathon Jongsma2021-07-191-1/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | Inactive mdevs were simply formatting their parent name as the value received from mdevctl rather than looking up the libvirt nodedev name of the parent device. This resulted in a parent value of e.g. '0000:5b:00.0' instead of 'pci_0000_5b_00_0'. This prevented defining a new mdev device from the output of nodedev-dumpxml. Unfortunately, it's not simple to fix this comprehensively due to the fact that mdevctl supports defining (inactive) mdevs for parent devices that do not actually exist on the host (yet). So for those persistent mdev definitions that do not have a valid parent in the device list, the parent device will be set to the root "computer" device. Unfortunately, because the value of the 'parent' field now depends on the configuration of the host, the mdevctl parsing test will output 'computer' for all test devices. Fixing this would require a more extensive mock test environment. Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1979761 Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com> Reviewed-by: Shalini Chellathurai Saroja <shalini@linux.ibm.com> Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
* nodedev: improve error message when destroying an inactive deviceJonathon Jongsma2021-07-011-4/+10
| | | | | | | | | | | | | | | | | | When trying to destroy a node device that is not active, we end up with a confusing error message: # nodedev-destroy mdev_88a6b868_46bd_4015_8e5b_26107f82da38 error: Failed to destroy node device 'mdev_88a6b868_46bd_4015_8e5b_26107f82da38' error: failed to access '/sys/bus/mdev/devices/88a6b868-46bd-4015-8e5b-26107f82da38/iommu_group': No such file or directory With this patch, the error is more clear: # nodedev-destroy mdev_88a6b868_46bd_4015_8e5b_26107f82da38 error: Failed to destroy node device 'mdev_88a6b868_46bd_4015_8e5b_26107f82da38' error: Requested operation is not valid: Device 'mdev_88a6b868_46bd_4015_8e5b_26107f82da38' is not active Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com> Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
* nodedev: handle mdevctl errors consistentlyJonathon Jongsma2021-07-011-49/+65
| | | | | | | | | | | | | | | | | | | | | | | | | | Currently, we have three different types of mdevctl errors: 1. the command cannot be constructed ecause of unsatisfied preconditions 2. the command cannot be executed due to some error 3. the command is executed, but returns an error status These different failures are handled differently. Some cases set an error and return and error status, and some return a error message but do not set an error. This means that the caller has to check both whether the return value is negative and whether the errmsg parameter is non-NULL before deciding whether to report the error or not. The situation is further complicated by the fact that there are occasional instances where mdevctl exits with an error status but does not print an error message. This results in errmsg being an empty string "" (i.e. non-NULL). Simplify the situation by ensuring that virReportError() is called for all error conditions rather than returning an error message back to the calling function. Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com> Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
* nodedev: add macro to handle command errorsJonathon Jongsma2021-07-011-2/+5
| | | | | | | | | | This macro will be utilized in the following patch. Since mdevctl commands can fail with or without an error message, this macro makes it easy to print a fallback error in the case that the error message is not set. Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com> Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
* nodedev: Handle NULL command variableJonathon Jongsma2021-07-011-0/+16
| | | | | | | | | | | | | | | | | | | | | | 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>