On 11/4/20 6:38 PM, Ján Tomko wrote:
On a Friday in 2020, Boris Fiuczynski wrote:
Extract virPCIGetMdevTypes from PCI as virMediatedDeviceGetMdevTypes
into mdev for later reuse.
Signed-off-by: Boris Fiuczynski <fiuczy@xxxxxxxxxxxxx>
Reviewed-by: Bjoern Walk <bwalk@xxxxxxxxxxxxx>
---
src/conf/node_device_conf.c |Â 2 +-
src/libvirt_private.syms   | 2 +-
src/util/virmdev.c         | 65 +++++++++++++++++++++++++++++++++++++
src/util/virmdev.h         | 4 +++
src/util/virpci.c          | 60 ----------------------------------
src/util/virpci.h          | 3 --
6 files changed, 71 insertions(+), 65 deletions(-)
diff --git a/src/util/virpci.c b/src/util/virpci.c
index 1f679a7b45..2086a4270b 100644
--- a/src/util/virpci.c
+++ b/src/util/virpci.c
@@ -2528,57 +2528,6 @@ virPCIGetVirtualFunctionInfo(const char
*vf_sysfs_device_path,
   return 0;
}
-
-ssize_t
-virPCIGetMdevTypes(const char *sysfspath,
-Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â virMediatedDeviceTypePtr **types)
-{
-Â Â Â ssize_t ret = -1;
-Â Â Â int dirret = -1;
-Â Â Â DIR *dir = NULL;
commit c0ae4919e386cda6e21d3ba022ee187e8b09793b
   change DIR* int g_autoptr(DIR) where appropriate
touched this code so it no longer applies cleanly.
yes, correct. Laine's change was commited after I sent this series.
-Â Â Â struct dirent *entry;
-Â Â Â g_autofree char *types_path = NULL;
-Â Â Â g_autoptr(virMediatedDeviceType) mdev_type = NULL;
-Â Â Â virMediatedDeviceTypePtr *mdev_types = NULL;
-Â Â Â size_t ntypes = 0;
-Â Â Â size_t i;
-
-Â Â Â types_path = g_strdup_printf("%s/mdev_supported_types", sysfspath);
-
-Â Â Â if ((dirret = virDirOpenIfExists(&dir, types_path)) < 0)
-Â Â Â Â Â Â Â goto cleanup;
-
-Â Â Â if (dirret == 0) {
-Â Â Â Â Â Â Â ret = 0;
-Â Â Â Â Â Â Â goto cleanup;
-Â Â Â }
-
-Â Â Â while ((dirret = virDirRead(dir, &entry, types_path)) > 0) {
-Â Â Â Â Â Â Â g_autofree char *tmppath = NULL;
-Â Â Â Â Â Â Â /* append the type id to the path and read the attributes
from there */
-Â Â Â Â Â Â Â tmppath = g_strdup_printf("%s/%s", types_path, entry->d_name);
-
-Â Â Â Â Â Â Â if (virMediatedDeviceTypeReadAttrs(tmppath, &mdev_type) < 0)
-Â Â Â Â Â Â Â Â Â Â Â goto cleanup;
-
-Â Â Â Â Â Â Â if (VIR_APPEND_ELEMENT(mdev_types, ntypes, mdev_type) < 0)
-Â Â Â Â Â Â Â Â Â Â Â goto cleanup;
-Â Â Â }
-
-Â Â Â if (dirret < 0)
-Â Â Â Â Â Â Â goto cleanup;
-
-Â Â Â *types = g_steal_pointer(&mdev_types);
-Â Â Â ret = ntypes;
-Â Â Â ntypes = 0;
- cleanup:
-Â Â Â for (i = 0; i < ntypes; i++)
-Â Â Â Â Â Â Â virMediatedDeviceTypeFree(mdev_types[i]);
-Â Â Â VIR_FREE(mdev_types);
-Â Â Â VIR_DIR_CLOSE(dir);
-Â Â Â return ret;
-}
-
#else
static const char *unsupported = N_("not supported on non-linux
platforms");
This also needs to be copied to the new file...
Sorry for missing this.
@@ -2653,15 +2602,6 @@ virPCIGetVirtualFunctionInfo(const char
*vf_sysfs_device_path G_GNUC_UNUSED,
   virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _(unsupported));
   return -1;
}
-
-
-ssize_t
-virPCIGetMdevTypes(const char *sysfspath G_GNUC_UNUSED,
-Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â virMediatedDeviceTypePtr **types G_GNUC_UNUSED)
-{
-Â Â Â virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _(unsupported));
otherwise this won't compile.
Yes, that is correct.
I did my checks on a supported platform only and therefore did not catch
this.
-Â Â Â return -1;
-}
#endif /* __linux__ */
With that fixed (no need to resend - this is a refactor so I'll push it
regardless of the rest of the series):
Reviewed-by: Ján Tomko <jtomko@xxxxxxxxxx>
Jano
Thanks for fixing this and also for your review of this and the other
refactoring patches ... and for pushing them. :-)
--
Mit freundlichen Grüßen/Kind regards
Boris Fiuczynski
IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Gregor Pillen
Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294