summaryrefslogtreecommitdiff
path: root/src/conf/virnodedeviceobj.c
Commit message (Collapse)AuthorAgeFilesLines
* conf: Update format strings in translated messagesJiri Denemark2023-04-011-5/+4
| | | | | Signed-off-by: Jiri Denemark <jdenemar@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
* util: remove virObjectUnref() adaptersJonathon Jongsma2022-07-151-1/+1
| | | | | | | | | | These wrapper functions were used to adapt the virObjectUnref() function signature for different callbacks. But in commit 0d184072, the virObjectUnref() function was changed to return a void instead of a bool, so these adapters are no longer necessary. Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com> Reviewed-by: Erik Skultety <eskultet@redhat.com>
* conf: Remove unused includesPeng Liang2022-06-161-1/+0
| | | | | Signed-off-by: Peng Liang <tcx4c70@gmail.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
* virnodedeviceobj: export virNodeDeviceObjHasCapBoris Fiuczynski2022-03-171-2/+1
| | | | | | | | The function will be reused in the nodedev drivers udev handling. Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
* conf: remove misleading comments about access being 'lockless'Daniel P. Berrangé2022-03-101-1/+1
| | | | | | | | | For the various structs storing lists of objects, the access to the hash tables is not lockless. The mutex on the object owning the hash table must be held. Reviewed-by: Ján Tomko <jtomko@redhat.com> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
* lib: Use g_clear_pointer() moreMichal Privoznik2022-02-081-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This change was generated using the following spatch: @ rule1 @ expression a; identifier f; @@ <... - f(*a); ... when != a; - *a = NULL; + g_clear_pointer(a, f); ...> @ rule2 @ expression a; identifier f; @@ <... - f(a); ... when != a; - a = NULL; + g_clear_pointer(&a, f); ...> Then, I left some of the changes out, like tools/nss/ (which doesn't link with glib) and put back a comment in qemuBlockJobProcessEventCompletedActiveCommit() which coccinelle decided to remove (I have no idea why). Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
* virnodedeviceobj: Don't unlock virNodeDeviceObj in virNodeDeviceObjListRemove()Michal Privoznik2022-02-031-1/+1
| | | | | | | | | | | | When virNodeDeviceObjListRemove() is called, the passed virNodeDeviceObj is removed from internal list of node devices and then unrefed and unlocked. While the former is warranted (the object was refed at the beginning of the function) the unlock is not. In fact, it's wrong from conceptual POV. We still want threads working on the object tu mutually exclude each other. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
* Switch away from virHashFreePeter Krempa2021-12-011-1/+1
| | | | | | | | | | | Use 'g_clear_pointer(&ptr, g_hash_table_unref)' instead. In few instances it allows us to also remove explicit clearing of pointers. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com> Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
* Use virNodeDeviceObjEndAPI() moreMichal Privoznik2021-11-111-2/+1
| | | | | | | | Instead of explicit virObjectUnlock(obj) + virObjectUnref(obj) combo the virNodeDeviceObjEndAPI() can be used. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
* Add PCI VPD Capability SupportDmitrii Shcherbakov2021-10-211-1/+6
| | | | | | | | | * 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 virNodeDevice(Get|Set)Autostart()Jonathon Jongsma2021-09-141-0/+16
| | | | | | | 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-4/+15
| | | | | | | | | | 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: add internal virNodeDeviceObjListFind()Jonathon Jongsma2021-08-061-8/+45
| | | | | | | | | This is a generic function that you can provide your own predicate function to search for a particular device. It will be used in an upcoming commit. Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
* virNodeDeviceObjListNew: `virHashNew` cannot return NULLTim Wiederhake2021-07-231-4/+1
| | | | | Signed-off-by: Tim Wiederhake <twiederh@redhat.com> Reviewed-by: Peter Krempa <pkrempa@redhat.com>
* lib: Drop internal virXXXPtr typedefsMichal Privoznik2021-04-131-79/+78
| | | | | | | | | | | | | | | | | | | | | | Historically, we declared pointer type to our types: typedef struct _virXXX virXXX; typedef virXXX *virXXXPtr; But usefulness of such declaration is questionable, at best. Unfortunately, we can't drop every such declaration - we have to carry some over, because they are part of public API (e.g. virDomainPtr). But for internal types - we can do drop them and use what every other C project uses 'virXXX *'. This change was generated by a very ugly shell script that generated sed script which was then called over each file in the repository. For the shell script refer to the cover letter: https://listman.redhat.com/archives/libvir-list/2021-March/msg00537.html Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Peter Krempa <pkrempa@redhat.com>
* nodedev: add helper functions to remove node devicesJonathon Jongsma2021-04-071-4/+54
| | | | | | | | | | | | When a mediated device is stopped or undefined by an application outside of libvirt, we need to remove it from our list of node devices within libvirt. This patch introduces virNodeDeviceObjListRemoveLocked() and virNodeDeviceObjListForEachRemove() (which are analogous to other types of object lists in libvirt) to facilitate that. They will be used in coming commits. Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com> Reviewed-by: Erik Skultety <eskultet@redhat.com>
* nodedev: add persistence to virNodeDeviceObjJonathon Jongsma2021-04-071-0/+16
| | | | | | | | Consistent with other objects (e.g. virDomainObj), add a field to indicate whether the node device is persistent or transient. Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com> Reviewed-by: Erik Skultety <eskultet@redhat.com>
* nodedev: Add ability to filter by active stateJonathon Jongsma2021-04-071-23/+34
| | | | | | | | Add two flag values for virConnectListAllNodeDevices() so that we can list only node devices that are active or inactive. Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com> Reviewed-by: Erik Skultety <eskultet@redhat.com>
* nodedev: introduce concept of 'active' node devicesJonathon Jongsma2021-04-071-0/+16
| | | | | | | | | we will be able to define mediated devices that can be started or stopped, so we need to be able to indicate whether the device is active or not, similar to other resources (storage pools, domains, etc.) Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com> Reviewed-by: Erik Skultety <eskultet@redhat.com>
* Do not check return value of VIR_REALLOC_NJiri Denemark2021-03-221-1/+1
| | | | | Signed-off-by: Jiri Denemark <jdenemar@redhat.com> Reviewed-by: Erik Skultety <eskultet@redhat.com>
* node_device: detecting mdev_types capability on ap_matrix deviceBoris Fiuczynski2020-12-091-1/+6
| | | | | | | | | | Add detection of mdev_types capability to Adjunct Processor Matrix device. Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com> Reviewed-by: Shalini Chellathurai Saroja <shalini@linux.ibm.com> Reviewed-by: Jonathon Jongsma<jjongsma@redhat.com> Signed-off-by: Shalini Chellathurai Saroja <shalini@linux.ibm.com> Reviewed-by: Erik Skultety <eskultet@redhat.com>
* virsh: nodedev: filter by AP Matrix capabilityShalini Chellathurai Saroja2020-12-091-1/+2
| | | | | | | | | Add support to filter by 'ap_matrix' capability. Signed-off-by: Shalini Chellathurai Saroja <shalini@linux.ibm.com> Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com> Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com> Reviewed-by: Erik Skultety <eskultet@redhat.com>
* nodedev: detect AP matrix deviceShalini Chellathurai Saroja2020-12-091-0/+1
| | | | | | | | | | | Add support for AP matrix device in libvirt node device driver. https://www.kernel.org/doc/html/latest/s390/vfio-ap.html#the-design Signed-off-by: Shalini Chellathurai Saroja <shalini@linux.ibm.com> Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com> Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com> Reviewed-by: Erik Skultety <eskultet@redhat.com>
* virsh: nodedev: Filter by AP card and AP queue capabilitiesFarhan Ali2020-12-091-1/+3
| | | | | | | | | | Add support to filter by 'ap_card' and 'ap_queue' capabilities. Signed-off-by: Farhan Ali <alifm@linux.ibm.com> Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com> Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com> Signed-off-by: Shalini Chellathurai Saroja <shalini@linux.ibm.com> Reviewed-by: Erik Skultety <eskultet@redhat.com>
* nodedev: detect AP queuesShalini Chellathurai Saroja2020-12-091-0/+1
| | | | | | | | | | | | | Each AP card device can support upto 256 AP queues. AP queues are also detected by udev, so add support for libvirt nodedev driver. https://www.kernel.org/doc/html/latest/s390/vfio-ap.html#ap-architectural-overview Signed-off-by: Farhan Ali <alifm@linux.ibm.com> Signed-off-by: Shalini Chellathurai Saroja <shalini@linux.ibm.com> Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com> Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com> Reviewed-by: Erik Skultety <eskultet@redhat.com>
* nodedev: detect AP card deviceShalini Chellathurai Saroja2020-12-091-0/+1
| | | | | | | | | | | | | | Introduce support for the Adjunct Processor (AP) crypto card device. Udev already detects the device, so add support for libvirt nodedev driver. https://www.kernel.org/doc/html/latest/s390/vfio-ap.html#ap-architectural-overview Signed-off-by: Farhan Ali <alifm@linux.ibm.com> Signed-off-by: Shalini Chellathurai Saroja <shalini@linux.ibm.com> Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com> Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com> Reviewed-by: Erik Skultety <eskultet@redhat.com>
* node_device: detecting mdev_types capability on CSS devicesBoris Fiuczynski2020-11-111-1/+6
| | | | | | | | Add detection of mdev_types capability to channel subsystem devices. Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com> Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com> Reviewed-by: Erik Skultety <eskultet@redhat.com>
* util: hash: Retire 'virHashTable' in favor of 'GHashTable'Peter Krempa2020-11-061-1/+1
| | | | | | | | | Don't hide our use of GHashTable behind our typedef. This will also promote the use of glibs hash function directly. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com> Reviewed-by: Matt Coleman <matt@datto.com>
* Include vdpa devices in node device listJonathon Jongsma2020-10-261-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The current udev node device driver ignores all events related to vdpa devices. Since libvirt now supports vDPA network devices, include these devices in the device list. Example output: virsh # nodedev-list [...ommitted long list of nodedevs...] vdpa_vdpa0 virsh # nodedev-dumpxml vdpa_vdpa0 <device> <name>vdpa_vdpa0</name> <path>/sys/devices/vdpa0</path> <parent>computer</parent> <driver> <name>vhost_vdpa</name> </driver> <capability type='vdpa'> <chardev>/dev/vhost-vdpa-0</chardev> </capability> </device> NOTE: normally the 'parent' would be a PCI device instead of 'computer', but this example output is from the vdpa_sim kernel module, so it doesn't have a normal parent device. Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
* util: hash: Change type of hash table name/key to 'char'Peter Krempa2020-10-221-9/+9
| | | | | | | | | | | All users of virHashTable pass strings as the name/key of the entry. Make this an official requirement by turning the variables to 'const char *'. For any other case it's better to use glib's GHashTable. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
* Replace all instances of 'virHashCreate' with 'virHashNew'Peter Krempa2020-10-221-1/+1
| | | | | | | | | | It doesn't make much sense to configure the bucket count in the hash table for each case specifically. Replace all calls of virHashCreate with virHashNew which has a pre-set size and remove virHashCreate completely. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
* conf: fix g_new0 allocationPavel Hrdina2020-10-131-1/+1
| | | | | | | | | Fixes commit <a5d88ffe0ad9b5d5314ab0058c5b363f9f79b8ee> which changed allocation from VIR_ALLOC_N to g_new0 but missed some +1 on number of allocated elements. Signed-off-by: Pavel Hrdina <phrdina@redhat.com> Reviewed-by: Laine Stump <laine@redhat.com>
* conf: use g_new0Ján Tomko2020-10-081-5/+2
| | | | | | Signed-off-by: Ján Tomko <jtomko@redhat.com> Reviewed-by: Neal Gompa <ngompa13@gmail.com> Reviewed-by: Erik Skultety <eskultet@redhat.com>
* virsh: nodedev: ability to filter CSS capabilitiesBoris Fiuczynski2020-09-151-1/+2
| | | | | | | | Allow to filter for CSS devices. Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com> Reviewed-by: Erik Skultety <eskultet@redhat.com> Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
* node_device: detect CSS devicesBoris Fiuczynski2020-09-151-0/+1
| | | | | | | | | | | | | | | | | | | Make channel subsystem (CSS) devices available in the node_device driver. The CCS devices reside in the computer system and provide CCW devices, e.g.: +- css_0_0_003a | +- ccw_0_0_1a2b | +- scsi_host0 | +- scsi_target0_0_0 | +- scsi_0_0_0_0 Reviewed-by: Erik Skultety <eskultet@redhat.com> Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com> Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
* nodedev: add mdev support to virNodeDeviceCreateXML()Jonathon Jongsma2020-06-191-0/+34
| | | | | | | | | | | | | | | | | With recent additions to the node device xml schema, an xml schema can now describe a mdev device sufficiently for libvirt to create and start the device using the mdevctl utility. Note that some of the the configuration for a mediated device must be passed to mdevctl as a JSON-formatted file. In order to avoid creating and cleaning up temporary files, the JSON is instead fed to stdin and we pass the filename /dev/stdin to mdevctl. While this may not be portable, neither are mediated devices, so I don't believe it should cause any problems. Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com> Reviewed-by: Erik Skultety <eskultet@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
* conf: use g_strdup instead of VIR_STRDUPJán Tomko2019-10-211-7/+3
| | | | | | | | | | | Replace all occurrences of if (VIR_STRDUP(a, b) < 0) /* effectively dead code */ with: a = g_strdup(b); Signed-off-by: Ján Tomko <jtomko@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
* conf: use G_GNUC_UNUSEDJán Tomko2019-10-151-8/+8
| | | | | | | Use G_GNUC_UNUSED from GLib instead of ATTRIBUTE_UNUSED. Signed-off-by: Ján Tomko <jtomko@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
* Require a semicolon for VIR_ONCE_GLOBAL_INIT callsCole Robinson2019-02-031-1/+1
| | | | | | | | | | | | | Missing semicolon at the end of macros can confuse some analyzers (like cppcheck <filename>). VIR_ONCE_GLOBAL_INIT is almost exclusively called without an ending semicolon, but let's standardize on using one like the other macros. Add a dummy struct definition at the end of the macro, so the compiler will require callers to add a semicolon. Reviewed-by: John Ferlan <jferlan@redhat.com> Signed-off-by: Cole Robinson <crobinso@redhat.com>
* conf: Add check to avoid a NULL compare for SysfsPathCheng Lin2019-01-241-1/+2
| | | | | | | | | | | | | | | | | | | If the two sysfs_path are both NULL, there may be an incorrect object returned for virNodeDeviceObjListFindBySysfsPath(). This check exists in old interface virNodeDeviceFindBySysfsPath(). e.g. virNodeDeviceFindBySysfsPath(virNodeDeviceObjListPtr devs, const char *sysfs_path) { ... if ((devs->objs[i]->def->sysfs_path != NULL) && (STREQ(devs->objs[i]->def->sysfs_path, sysfs_path))) { ... } Reviewed-by: Cole Robinson <crobinso@redhat.com> Signed-off-by: Cheng Lin <cheng.lin130@zte.com.cn>
* conf: rename Match functionsAnya Harter2018-08-141-3/+3
| | | | | | | | | | name match functions to be the vir prefix and interface name followed by ObjMatch ex. for virNetworkObjListExport, the match function is named virNetworkObjMatch Signed-off-by: Anya Harter <aharter@redhat.com> Reviewed-by: Andrea Bolognani <abologna@redhat.com>
* conf: rename structs used by Export functionAnya Harter2018-08-141-3/+5
| | | | | | | | | | | | | | name structs to be the name of the Export function followed by Data also tweak definitions to follow standard struct definition pattern ex. for virInterfaceObjListExport, the struct is defined as follows: typedef struct _virInterfaceObjListExportData virInterfaceObjListExportData; typedef virInterfaceObjListExportData *virInterfaceObjListExportDataPtr; struct _virInterfaceObjListExportData {...}; Signed-off-by: Anya Harter <aharter@redhat.com> Reviewed-by: Andrea Bolognani <abologna@redhat.com>
* conf: nodedev: Don't refresh host caps in testdriverCole Robinson2018-07-171-1/+12
| | | | | | | | Add a 'skipUpdateCaps' bool that we set for test_driver.c nodedevs which will skip accessing host resources via virNodeDeviceUpdateCaps Reviewed-by: Erik Skultety <eskultet@redhat.com> Signed-off-by: Cole Robinson <crobinso@redhat.com>
* virobject: Introduce VIR_CLASS_NEW() macroMichal Privoznik2018-04-181-8/+2
| | | | | | | | | | | | | | | | | | | | | | So far we are repeating the following lines over and over: if (!(virSomeObjectClass = virClassNew(virClassForObject(), "virSomeObject", sizeof(virSomeObject), virSomeObjectDispose))) return -1; While this works, it is impossible to do some checking. Firstly, the class name (the 2nd argument) doesn't match the name in the code in all cases (the 3rd argument). Secondly, the current style is needlessly verbose. This commit turns example into following: if (!(VIR_CLASS_NEW(virSomeObject, virClassForObject))) return -1; Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
* datatypes: Rename @parent to @parentName in virNodeDeviceMichal Privoznik2018-04-181-1/+1
| | | | | | | | | In next patches this name will be needed for a different memeber. Also, it makes sense to rename the variable because it does not contain reference to parent device, just its name. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
* conf: nodedev: Refresh capabilities before touching themErik Skultety2018-01-291-0/+4
| | | | | | | | | Most of them are static, however in case of PCI and SCSI_HOST devices, the nested capabilities can change dynamically, e.g. due to a driver change (from host_pci_driver -> vfio_pci). Signed-off-by: Erik Skultety <eskultet@redhat.com> Suggested-by: Wu Zongyong <cordius.wu@huawei.com>
* conf: nodedev: Convert virNodeDevObjHasCapStr to a simple wrapperErik Skultety2018-01-291-47/+4
| | | | | | | | This patch drops the capability matching redundancy by simply converting the string input to our internal types which are then in turn used for the actual capability matching. Signed-off-by: Erik Skultety <eskultet@redhat.com>
* conf: nodedev: Rename virNodeDeviceCapMatch to virNodeDevObjHasCapErik Skultety2018-01-291-5/+4
| | | | | | | | We currently have 2 methods that do the capability matching. This should be condensed to a single function and all the derivates should just call into that using a proper type conversion. Signed-off-by: Erik Skultety <eskultet@redhat.com>
* conf: nodedev: Rename virNodeDevObjHasCap to virNodeDevObjHasCapStrErik Skultety2018-01-291-5/+7
| | | | | | | | We currently have 2 methods that do the capability matching. This should be condensed to a single function and all the derivates should just call into that using a proper type conversion. Signed-off-by: Erik Skultety <eskultet@redhat.com>
* conf: honor maxnames in nodeListDevices APIPavel Hrdina2018-01-021-0/+3
| | | | | | | | Introduced by commit <4ae9dbea99c>. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1528572 Signed-off-by: Pavel Hrdina <phrdina@redhat.com>