diff options
-rw-r--r-- | .reviewboardrc | 2 | ||||
-rw-r--r-- | mof/60_LMI_Hardware.mof | 20 | ||||
-rw-r--r-- | mof/70_LMI_SoftwareIndicationFilters.mof | 10 | ||||
-rwxr-xr-x | openlmi-mof-register | 6 | ||||
-rw-r--r-- | src/hardware/LMI_MemoryProvider.c | 25 | ||||
-rw-r--r-- | src/hardware/dmidecode.c | 4 | ||||
-rw-r--r-- | src/hardware/sysfs.c | 107 | ||||
-rw-r--r-- | src/hardware/sysfs.h | 36 | ||||
-rw-r--r-- | src/python/openlmi/common/JobManager.py | 2 | ||||
-rw-r--r-- | src/realmd/LMI_HostedRealmdServiceProvider.c | 2 | ||||
-rw-r--r-- | src/realmd/LMI_RealmdKerberosRealmProvider.c | 2 | ||||
-rw-r--r-- | src/realmd/LMI_RealmdRealmProvider.c | 2 | ||||
-rw-r--r-- | src/realmd/LMI_RealmdServiceProvider.c | 2 | ||||
-rw-r--r-- | src/realmd/LMI_ServiceAffectsRealmdRealmProvider.c | 2 | ||||
-rw-r--r-- | src/realmd/rdcp_dbus.c | 137 |
15 files changed, 204 insertions, 155 deletions
diff --git a/.reviewboardrc b/.reviewboardrc new file mode 100644 index 0000000..b95918c --- /dev/null +++ b/.reviewboardrc @@ -0,0 +1,2 @@ +REVIEWBOARD_URL = 'https://reviewboard-openlmi.rhcloud.com' +REPOSITORY = 'openlmi-providers' diff --git a/mof/60_LMI_Hardware.mof b/mof/60_LMI_Hardware.mof index 63c1a74..cba6459 100644 --- a/mof/60_LMI_Hardware.mof +++ b/mof/60_LMI_Hardware.mof @@ -169,6 +169,26 @@ class LMI_ProcessorChipRealizes: CIM_Realizes [ Provider("cmpi:cmpiLMI_Memory") ] class LMI_Memory: CIM_Memory { + [ Description("Indicates whether memory has NUMA layout.") ] + boolean HasNUMA; + + [ Description("Standard memory page size in kB."), + Units("Kilobytes"), PUnit("kilobyte")] + uint32 StandardMemoryPageSize; + + [ Description("All supported huge memory page sizes in currently " + "running kernel in kB."), + Units("Kilobytes"), PUnit("kilobyte")] + uint32 SupportedHugeMemoryPageSizes[]; + + [ Description ("Current state of the transparent huge memory pages. The " + "state can be \"Unsupported\", what means that the feature is not " + "available on the system, \"Never\" when the feature is disabled, " + "\"Madvise\" when huge pages are used only in marked memory area or " + "\"Always\" when this feature is used all the time. "), + ValueMap { "0", "1", "2", "3" }, + Values { "Unsupported", "Never", "Madvise", "Always" } ] + uint16 TransparentHugeMemoryPageStatus; }; [ Provider("cmpi:cmpiLMI_PhysicalMemory") ] diff --git a/mof/70_LMI_SoftwareIndicationFilters.mof b/mof/70_LMI_SoftwareIndicationFilters.mof index b79917d..6b36190 100644 --- a/mof/70_LMI_SoftwareIndicationFilters.mof +++ b/mof/70_LMI_SoftwareIndicationFilters.mof @@ -26,7 +26,7 @@ instance of CIM_IndicationFilter { CreationClassName = "CIM_IndicationFilter"; SystemCreationClassName = "CIM_ComputerSystem"; - SystemName = "kvm-fedora18"; + SystemName = "HOSTNAME"; Name = "LMI:LMI_SoftwareInstallationJob:PercentUpdated"; Query = "SELECT * FROM LMI_SoftwareInstModification WHERE " "SourceInstance ISA LMI_SoftwareInstallationJob AND " @@ -44,7 +44,7 @@ instance of CIM_IndicationFilter { instance of CIM_IndicationFilter { CreationClassName = "CIM_IndicationFilter"; SystemCreationClassName = "CIM_ComputerSystem"; - SystemName = "kvm-fedora18"; + SystemName = "HOSTNAME"; Name = "LMI:LMI_SoftwareInstallationJob:Succeeded"; QueryLanguage = "CIM:CQL"; Query = "SELECT * FROM LMI_SoftwareInstModification WHERE " @@ -59,7 +59,7 @@ instance of CIM_IndicationFilter { instance of CIM_IndicationFilter { CreationClassName = "CIM_IndicationFilter"; SystemCreationClassName = "CIM_ComputerSystem"; - SystemName = "kvm-fedora18"; + SystemName = "HOSTNAME"; Name = "LMI:LMI_SoftwareInstallationJob:Failed"; Query = "SELECT * FROM LMI_SoftwareInstModification WHERE " "SourceInstance ISA LMI_SoftwareInstallationJob AND " @@ -76,7 +76,7 @@ instance of CIM_IndicationFilter { instance of CIM_IndicationFilter { CreationClassName = "CIM_IndicationFilter"; SystemCreationClassName = "CIM_ComputerSystem"; - SystemName = "kvm-fedora18"; + SystemName = "HOSTNAME"; Name = "LMI:LMI_SoftwareInstallationJob:Changed"; Query = "SELECT * FROM LMI_SoftwareInstModification WHERE " "SourceInstance ISA LMI_SoftwareInstallationJob AND " @@ -91,7 +91,7 @@ instance of CIM_IndicationFilter { instance of CIM_IndicationFilter { CreationClassName = "CIM_IndicationFilter"; SystemCreationClassName = "CIM_ComputerSystem"; - SystemName = "kvm-fedora18"; + SystemName = "HOSTNAME"; Name = "LMI:LMI_SoftwareInstallationJob:Created"; Query = "SELECT * FROM LMI_SoftwareInstCreation WHERE" " SourceInstance ISA LMI_SoftwareInstallationJob"; diff --git a/openlmi-mof-register b/openlmi-mof-register index b2b1790..a912e0a 100755 --- a/openlmi-mof-register +++ b/openlmi-mof-register @@ -127,7 +127,7 @@ while getopts "$optspec" optchar; do JUST_MOFS=1 ;; *) - if [ "$OPTERR" = 1 ] && [ "${optspec:0:1}" != ":" ]; then + if [ "$OPTERR" != 1 ] || [ "${optspec:0:1}" = ":" ]; then echo "Unknown option --${OPTARG}" >&2 exit 1 fi @@ -172,7 +172,7 @@ then HAS_SFCBD=1 else HAS_SFCBD=0 - if [ $cimom != "sfcbd" ]; then + if [ $cimom = "sfcbd" ]; then echo "Sfcbd not detected on system!" >&2 exit 1 fi @@ -183,7 +183,7 @@ then HAS_PEGASUS=1 else HAS_PEGASUS=0 - if [ $cimom != "tog-pegasus" ]; then + if [ $cimom = "tog-pegasus" ]; then echo "Pegasus not detected on system!" >&2 exit 1 fi diff --git a/src/hardware/LMI_MemoryProvider.c b/src/hardware/LMI_MemoryProvider.c index 0d77c17..4f2ab7f 100644 --- a/src/hardware/LMI_MemoryProvider.c +++ b/src/hardware/LMI_MemoryProvider.c @@ -19,11 +19,15 @@ */ #include <konkret/konkret.h> +#include <stdio.h> +#include <unistd.h> +#include <limits.h> #include "LMI_Memory.h" #include "LMI_Hardware.h" #include "globals.h" #include "dmidecode.h" #include "procfs.h" +#include "sysfs.h" static const CMPIBroker* _cb = NULL; @@ -59,8 +63,10 @@ static CMPIStatus LMI_MemoryEnumInstances( LMI_Memory lmi_mem; const char *ns = KNameSpace(cop), *name = "System Memory"; char *error_msg = NULL; + long page_size; unsigned long fallback_memory_size = 0; DmiMemory dmi_memory; + unsigned i, *huge_page_sizes = NULL, huge_page_sizes_nb; if (dmi_get_memory(&dmi_memory) != 0) { fallback_memory_size = meminfo_get_memory_size(); @@ -70,6 +76,9 @@ static CMPIStatus LMI_MemoryEnumInstances( } } + page_size = sysconf(_SC_PAGESIZE); + sysfs_get_sizes_of_hugepages(&huge_page_sizes, &huge_page_sizes_nb); + LMI_Memory_Init(&lmi_mem, _cb, ns); LMI_Memory_Set_SystemCreationClassName(&lmi_mem, @@ -107,10 +116,26 @@ static CMPIStatus LMI_MemoryEnumInstances( LMI_Memory_Set_NumberOfBlocks(&lmi_mem, fallback_memory_size); } + LMI_Memory_Set_HasNUMA(&lmi_mem, sysfs_has_numa()); + if (page_size > 0) { + LMI_Memory_Set_StandardMemoryPageSize(&lmi_mem, page_size / 1024); + } + if (huge_page_sizes_nb > 0) { + LMI_Memory_Init_SupportedHugeMemoryPageSizes(&lmi_mem, + huge_page_sizes_nb); + for (i = 0; i < huge_page_sizes_nb; i++) { + LMI_Memory_Set_SupportedHugeMemoryPageSizes(&lmi_mem, i, + huge_page_sizes[i]); + } + } + LMI_Memory_Set_TransparentHugeMemoryPageStatus(&lmi_mem, + sysfs_get_transparent_hugepages_status()); + KReturnInstance(cr, lmi_mem); done: dmi_free_memory(&dmi_memory); + free(huge_page_sizes); if (error_msg) { KReturn2(_cb, ERR_FAILED, error_msg); diff --git a/src/hardware/dmidecode.c b/src/hardware/dmidecode.c index f034b56..dfff7e3 100644 --- a/src/hardware/dmidecode.c +++ b/src/hardware/dmidecode.c @@ -439,7 +439,7 @@ void dmi_free_processors(DmiProcessor **cpus, unsigned *cpus_nb) free((*cpus)[i].part_number); (*cpus)[i].part_number = NULL; } - free (*cpus); + free(*cpus); } *cpus_nb = 0; @@ -686,7 +686,7 @@ void dmi_free_cpu_caches(DmiCpuCache **caches, unsigned *caches_nb) free((*caches)[i].associativity); (*caches)[i].associativity = NULL; } - free (*caches); + free(*caches); } *caches_nb = 0; diff --git a/src/hardware/sysfs.c b/src/hardware/sysfs.c index d07df71..80d360e 100644 --- a/src/hardware/sysfs.c +++ b/src/hardware/sysfs.c @@ -149,11 +149,11 @@ short sysfs_get_cpu_caches(SysfsCpuCache **caches, unsigned *caches_nb) short ret = -1; unsigned i, level; char *buf = NULL, *format_str, path[PATH_MAX]; - DIR *dir; *caches_nb = 0; /* count caches */ + DIR *dir; char *cache_dir = SYSFS_CPU_PATH "/cpu0/cache"; dir = opendir(cache_dir); if (!dir) { @@ -285,3 +285,108 @@ void sysfs_free_cpu_caches(SysfsCpuCache **caches, unsigned *caches_nb) *caches_nb = 0; *caches = NULL; } + +short sysfs_has_numa() +{ + struct stat st; + + if (stat(SYSFS_PATH "/node/node0", &st) == 0) { + return 1; + } + + return 0; +} + +short sysfs_get_sizes_of_hugepages(unsigned **sizes, unsigned *sizes_nb) +{ + short ret = -1; + DIR *dir; + + *sizes_nb = 0; + *sizes = NULL; + + /* count all sizes */ + char *sizes_dir = SYSFS_KERNEL_MM "/hugepages"; + dir = opendir(sizes_dir); + if (!dir) { + warn("Failed to read directory: \"%s\"; Error: %s", + sizes_dir, strerror(errno)); + ret = -2; + goto done; + } + while (readdir(dir)) { + (*sizes_nb)++; + } + + /* do not count . and .. */ + *sizes_nb -= 2; + + /* if no size was found */ + if (*sizes_nb < 1) { + warn("Looks like kernel doesn't support huge memory pages."); + ret = -3; + goto done; + } + + /* allocate memory for sizes */ + *sizes = (unsigned *)calloc(*sizes_nb, sizeof(unsigned)); + if (!(*sizes)) { + warn("Failed to allocate memory."); + ret = -4; + goto done; + } + + /* get sizes */ + struct dirent *d; + unsigned i = 0; + rewinddir(dir); + while ((d = readdir(dir)) && i < *sizes_nb) { + if (strcmp(d->d_name, ".") == 0 || strcmp(d->d_name, "..") == 0) { + continue; + } + if (strlen(d->d_name) > 11) { + /* read page size from the dirname, which looks like: hugepages-2048kB */ + if (sscanf(d->d_name + 10, "%u", &(*sizes)[i]) == 1) { + i++; + } + } + } + + ret = 0; + +done: + if (dir) { + closedir(dir); + } + + if (ret != 0) { + *sizes_nb = 0; + free(*sizes); + *sizes = NULL; + } + + return ret; +} + +ThpStatus sysfs_get_transparent_hugepages_status() +{ + ThpStatus ret = thp_unsupported; + char *val = NULL; + + if (path_get_string(SYSFS_KERNEL_MM "/transparent_hugepage/enabled", &val) != 0) { + goto done; + } + + if (strstr(val, "[always]")) { + ret = thp_always; + } else if (strstr(val, "[madvise]")) { + ret = thp_madvise; + } else if (strstr(val, "[never]")) { + ret = thp_never; + } + +done: + free(val); + + return ret; +} diff --git a/src/hardware/sysfs.h b/src/hardware/sysfs.h index 028b559..297a1a7 100644 --- a/src/hardware/sysfs.h +++ b/src/hardware/sysfs.h @@ -27,9 +27,23 @@ #include <dirent.h> #include <errno.h> #include <limits.h> +#include <sys/stat.h> +#include <sys/types.h> #include "utils.h" -#define SYSFS_CPU_PATH "/sys/devices/system/cpu" +#define SYSFS_PATH "/sys/devices/system" +#define SYSFS_CPU_PATH SYSFS_PATH "/cpu" +#define SYSFS_KERNEL_MM "/sys/kernel/mm" + + +/* Transparent memory huge pages statuses. */ +typedef enum _ThpStatus { + thp_unsupported = 0, + thp_never, + thp_madvise, + thp_always +} ThpStatus; + /* Processor cache from sysfs. */ typedef struct _SysfsCpuCache { @@ -59,5 +73,25 @@ short sysfs_get_cpu_caches(SysfsCpuCache **caches, unsigned *caches_nb); */ void sysfs_free_cpu_caches(SysfsCpuCache **caches, unsigned *caches_nb); +/* + * Detects whether system has NUMA memory layout. + * @return 0 if no, 1 if yes + */ +short sysfs_has_numa(); + +/* + * Get all supported sizes of memory huge pages in kB + * @param sizes array of all supported sizes if huge pages + * @param sizes_nb number of items in array + * @return 0 if success, negative value otherwise + */ +short sysfs_get_sizes_of_hugepages(unsigned **sizes, unsigned *sizes_nb); + +/* + * Get current status of transparent memory huge pages. + * @return ThpStatus + */ +ThpStatus sysfs_get_transparent_hugepages_status(); + #endif /* SYSFS_H_ */ diff --git a/src/python/openlmi/common/JobManager.py b/src/python/openlmi/common/JobManager.py index 3a845fd..fc12d7e 100644 --- a/src/python/openlmi/common/JobManager.py +++ b/src/python/openlmi/common/JobManager.py @@ -1145,7 +1145,7 @@ class LMI_ConcreteJob(CIMProvider2): errors = [err, ] out_params = [ pywbem.CIMParameter( - name='errors', + name='Errors', value=errors, type='instance', is_array=True, diff --git a/src/realmd/LMI_HostedRealmdServiceProvider.c b/src/realmd/LMI_HostedRealmdServiceProvider.c index 08732c1..1a9f399 100644 --- a/src/realmd/LMI_HostedRealmdServiceProvider.c +++ b/src/realmd/LMI_HostedRealmdServiceProvider.c @@ -230,4 +230,4 @@ KONKRET_REGISTRATION( "root/cimv2", "LMI_HostedRealmdService", "LMI_HostedRealmdService", - "instance association"); + "instance association") diff --git a/src/realmd/LMI_RealmdKerberosRealmProvider.c b/src/realmd/LMI_RealmdKerberosRealmProvider.c index 5dc90d2..aa43ba1 100644 --- a/src/realmd/LMI_RealmdKerberosRealmProvider.c +++ b/src/realmd/LMI_RealmdKerberosRealmProvider.c @@ -624,4 +624,4 @@ KONKRET_REGISTRATION( "root/cimv2", "LMI_RealmdKerberosRealm", "LMI_RealmdKerberosRealm", - "instance method"); + "instance method") diff --git a/src/realmd/LMI_RealmdRealmProvider.c b/src/realmd/LMI_RealmdRealmProvider.c index d8e0a18..13e0471 100644 --- a/src/realmd/LMI_RealmdRealmProvider.c +++ b/src/realmd/LMI_RealmdRealmProvider.c @@ -323,4 +323,4 @@ KONKRET_REGISTRATION( "root/cimv2", "LMI_RealmdRealm", "LMI_RealmdRealm", - "instance method"); + "instance method") diff --git a/src/realmd/LMI_RealmdServiceProvider.c b/src/realmd/LMI_RealmdServiceProvider.c index 01fc0b8..8bc1b79 100644 --- a/src/realmd/LMI_RealmdServiceProvider.c +++ b/src/realmd/LMI_RealmdServiceProvider.c @@ -628,4 +628,4 @@ KONKRET_REGISTRATION( "root/cimv2", "LMI_RealmdService", "LMI_RealmdService", - "instance method"); + "instance method") diff --git a/src/realmd/LMI_ServiceAffectsRealmdRealmProvider.c b/src/realmd/LMI_ServiceAffectsRealmdRealmProvider.c index 70d65f4..a80ab01 100644 --- a/src/realmd/LMI_ServiceAffectsRealmdRealmProvider.c +++ b/src/realmd/LMI_ServiceAffectsRealmdRealmProvider.c @@ -249,4 +249,4 @@ KONKRET_REGISTRATION( "root/cimv2", "LMI_ServiceAffectsRealmdRealm", "LMI_ServiceAffectsRealmdRealm", - "instance association"); + "instance association") diff --git a/src/realmd/rdcp_dbus.c b/src/realmd/rdcp_dbus.c index b05e5c9..75ee439 100644 --- a/src/realmd/rdcp_dbus.c +++ b/src/realmd/rdcp_dbus.c @@ -47,15 +47,6 @@ static gboolean append_g_variant_to_dbus_message(DBusMessage *message, GVariant *g_variant, GError **g_error); static gboolean -dbus_method_append_args_tuple(DBusMessage *message, GVariant *args, GError **g_error); - -static gboolean -marshal_dbus_string_variant(DBusMessageIter *iter, const char *value, GError **g_error); - -static gboolean -marshal_dbus_dict_string_entry(DBusMessageIter *array, const char *name, const char *value, GError **g_error); - -static gboolean dbus_iter_to_variant(DBusMessageIter *iter, GVariant **g_variant_return, GError **g_error); static gboolean @@ -681,134 +672,6 @@ append_g_variant_to_dbus_message(DBusMessage *message, GVariant *g_variant, GEr return TRUE; } -/** - * dbus_method_append_args_tuple: - * @message DBus message currently being built - * @args A GVariant tuple containing the method parameters to - * be appended to @message - * @g_error initialized to error info when FALSE is returned. - * - * Append the method parameters to a DBus method message. @args - * is a GVariant tuple representing the parameter list. - * - * Returns: return TRUE if successful, FALSE if error with @g_error initialized. - */ -static gboolean -dbus_method_append_args_tuple(DBusMessage *message, GVariant *args, GError **g_error) -{ - DBusMessageIter iter; - gsize n, i; - GVariant *arg; - - g_return_val_if_fail (message != NULL, FALSE); - g_return_val_if_fail (args != NULL && g_variant_is_of_type(args, G_VARIANT_TYPE_TUPLE), FALSE); - g_return_val_if_fail (g_error == NULL || *g_error == NULL, FALSE); - - if ((n = g_variant_n_children(args))) { - - dbus_message_iter_init_append(message, &iter); - - for (i = 0; i < n; i++) { - arg = g_variant_get_child_value(args, i); - if (!append_g_variant_to_dbus_msg_iter(&iter, arg, g_error)) { - G_VARIANT_FREE(arg); - return FALSE; - } - G_VARIANT_FREE(arg); - } - } - - return TRUE; -} - -/** - * marshal_dbus_string_variant: - * @iter iterator into which the string variant will be inserted - * @value string value to insert as variant - * @g_error initialized to error info when FALSE is returned. - * - * Add a string variant while marshaling DBus protocol. - * - * Returns: return TRUE if successful, FALSE if error with @g_error initialized. - */ -static gboolean -marshal_dbus_string_variant(DBusMessageIter *iter, const char *value, GError **g_error) -{ - DBusMessageIter variant; - - g_return_val_if_fail (iter != NULL, FALSE); - g_return_val_if_fail (value != NULL, FALSE); - g_return_val_if_fail (g_error == NULL || *g_error == NULL, FALSE); - - if (!dbus_message_iter_open_container(iter, DBUS_TYPE_VARIANT, "s", &variant)) { - g_set_error(g_error, RDCP_ERROR, RDCP_ERROR_DBUS, - "cannot open dbus variant string container, value=\"%s\"", value); - return FALSE; - } - - if (!dbus_message_iter_append_basic(&variant, DBUS_TYPE_STRING, &value)) { - g_set_error(g_error, RDCP_ERROR, RDCP_ERROR_DBUS, - "cannot append dbus variant string value, value=\"%s\"", value); - return FALSE; - } - - if (!dbus_message_iter_close_container(iter, &variant)) { - g_set_error(g_error, RDCP_ERROR, RDCP_ERROR_DBUS, - "cannot close dbus variant container, value=\"%s\"", value); - return FALSE; - } - - return TRUE; -} - -/** - * marshal_dbus_dict_string_entry: - * @array dictionary array into which entry is inserted - * @name entry's key - * @value entry's value - * @g_error initialized to error info when FALSE is returned. - * - * Adds a dictionary entry into an dictionary array whose key is a - * string and whose value is also a string while marshaling DBus protocol. - * - * Returns: return TRUE if successful, FALSE if error with @g_error initialized. - */ -static gboolean -marshal_dbus_dict_string_entry(DBusMessageIter *array, const char *name, const char *value, GError **g_error) -{ - DBusMessageIter entry; - - g_return_val_if_fail (array != NULL, FALSE); - g_return_val_if_fail (name != NULL, FALSE); - g_return_val_if_fail (value != NULL, FALSE); - g_return_val_if_fail (g_error == NULL || *g_error == NULL, FALSE); - - if (!dbus_message_iter_open_container(array, DBUS_TYPE_DICT_ENTRY, NULL, &entry)) { - g_set_error(g_error, RDCP_ERROR, RDCP_ERROR_DBUS, - "cannot open dbus dict entry container for option <%s=%s>", name, value); - return FALSE; - } - - if (!dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &name)) { - g_set_error(g_error, RDCP_ERROR, RDCP_ERROR_DBUS, - "cannot append option name for option <%s=%s>", name, value); - return FALSE; - } - - if (!marshal_dbus_string_variant(&entry, value, g_error)) { - return FALSE; - } - - if (!dbus_message_iter_close_container(array, &entry)) { - g_set_error(g_error, RDCP_ERROR, RDCP_ERROR_DBUS, - "cannot close dbus dict entry container for option <%s=%s>", name, value); - return FALSE; - } - - return TRUE; -} - - /*----------------------------------------------------------------------------*/ |