aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--modules/benchmark.c1
-rw-r--r--modules/benchmark/bench_results.c36
-rw-r--r--modules/computer.c6
3 files changed, 28 insertions, 15 deletions
diff --git a/modules/benchmark.c b/modules/benchmark.c
index aa88e7df..ed7e9ff1 100644
--- a/modules/benchmark.c
+++ b/modules/benchmark.c
@@ -850,6 +850,7 @@ static gchar *get_benchmark_results(gsize *len)
ADD_JSON_VALUE(string, "MemoryTypes", this_machine->ram_types);
ADD_JSON_VALUE(int, "MachineDataVersion",
this_machine->machine_data_version);
+ ADD_JSON_VALUE(string, "MachineType", this_machine->machine_type);
ADD_JSON_VALUE(boolean, "Legacy", FALSE);
ADD_JSON_VALUE(string, "ExtraInfo", bench_results[i].extra);
diff --git a/modules/benchmark/bench_results.c b/modules/benchmark/bench_results.c
index 3ebd93d3..cd8cc6e8 100644
--- a/modules/benchmark/bench_results.c
+++ b/modules/benchmark/bench_results.c
@@ -46,6 +46,7 @@ typedef struct {
uint64_t memory_phys_MiB; /* from DMI/SPD/DTree/Table/Blocks, etc. */
char *ram_types;
int machine_data_version;
+ char *machine_type;
} bench_machine;
typedef struct {
@@ -156,11 +157,7 @@ static void gen_machine_id(bench_machine *m)
bench_machine *bench_machine_new()
{
- bench_machine *m = NULL;
- m = malloc(sizeof(bench_machine));
- if (m)
- memset(m, 0, sizeof(bench_machine));
- return m;
+ return calloc(1, sizeof(bench_machine));
}
bench_machine *bench_machine_this()
@@ -183,6 +180,7 @@ bench_machine *bench_machine_this()
m->memory_kiB = strtoull(tmp, NULL, 10);
m->memory_phys_MiB = memory_devices_get_system_memory_MiB();
m->ram_types = memory_devices_get_system_memory_types_str();
+ m->machine_type = module_call_method("computer::getMachineType");
free(tmp);
cpu_procs_cores_threads(&m->processors, &m->cores, &m->threads);
@@ -200,6 +198,8 @@ void bench_machine_free(bench_machine *s)
free(s->cpu_config);
free(s->mid);
free(s->ram_types);
+ free(s->machine_type);
+ free(s);
}
}
@@ -208,6 +208,7 @@ void bench_result_free(bench_result *s)
if (s) {
free(s->name);
bench_machine_free(s->machine);
+ g_free(s);
}
}
@@ -372,6 +373,7 @@ bench_result *bench_result_benchmarkjson(const gchar *bench_name,
.memory_phys_MiB = json_get_int(machine, "PhysicalMemoryInMiB"),
.ram_types = json_get_string_dup(machine, "MemoryTypes"),
.machine_data_version = json_get_int(machine, "MachineDataVersion"),
+ .machine_type = json_get_string_dup(machine, "MachineType"),
};
return b;
@@ -563,6 +565,7 @@ static char *bench_result_more_info_less(bench_result *b)
/* legacy */ "%s%s=%s\n"
"[%s]\n"
/* board */ "%s=%s\n"
+ /* machine_type */ "%s=%s\n"
/* cpu */ "%s=%s\n"
/* cpudesc */ "%s=%s\n"
/* cpucfg */ "%s=%s\n"
@@ -582,15 +585,15 @@ static char *bench_result_more_info_less(bench_result *b)
"might not be comparable to current version. Some "
"details are missing.")
: "",
- _("Machine"), _("Board"),
- (b->machine->board != NULL) ? b->machine->board : _(unk), _("CPU Name"),
- b->machine->cpu_name, _("CPU Description"),
- (b->machine->cpu_desc != NULL) ? b->machine->cpu_desc : _(unk),
- _("CPU Config"), b->machine->cpu_config, _("Threads Available"),
- b->machine->threads, _("GPU"),
- (b->machine->gpu_desc != NULL) ? b->machine->gpu_desc : _(unk),
- _("OpenGL Renderer"),
- (b->machine->ogl_renderer != NULL) ? b->machine->ogl_renderer : _(unk),
+ _("Machine"),
+ _("Board"), (b->machine->board != NULL) ? b->machine->board : _(unk),
+ _("Machine Type"), (b->machine->machine_type != NULL) ? b->machine->machine_type : _(unk),
+ _("CPU Name"), b->machine->cpu_name,
+ _("CPU Description"), (b->machine->cpu_desc != NULL) ? b->machine->cpu_desc : _(unk),
+ _("CPU Config"), b->machine->cpu_config,
+ _("Threads Available"), b->machine->threads,
+ _("GPU"), (b->machine->gpu_desc != NULL) ? b->machine->gpu_desc : _(unk),
+ _("OpenGL Renderer"), (b->machine->ogl_renderer != NULL) ? b->machine->ogl_renderer : _(unk),
_("Memory"), memory,
b->machine->ptr_bits ? _("Pointer Size") : "#AddySize", bits);
free(memory);
@@ -619,6 +622,7 @@ static char *bench_result_more_info_complete(bench_result *b)
/* legacy */ "%s%s=%s\n"
"[%s]\n"
/* board */ "%s=%s\n"
+ /* machine_type */ "%s=%s\n"
/* cpu */ "%s=%s\n"
/* cpudesc */ "%s=%s\n"
/* cpucfg */ "%s=%s\n"
@@ -645,7 +649,9 @@ static char *bench_result_more_info_complete(bench_result *b)
"details are missing.")
: "",
_("Machine"), _("Board"),
- (b->machine->board != NULL) ? b->machine->board : _(unk), _("CPU Name"),
+ (b->machine->board != NULL) ? b->machine->board : _(unk),
+ _("Machine Type"), (b->machine->machine_type != NULL) ? b->machine->machine_type : _(unk),
+ _("CPU Name"),
b->machine->cpu_name, _("CPU Description"),
(b->machine->cpu_desc != NULL) ? b->machine->cpu_desc : _(unk),
_("CPU Config"), b->machine->cpu_config, _("Threads Available"),
diff --git a/modules/computer.c b/modules/computer.c
index 281fcaf1..9bb69f78 100644
--- a/modules/computer.c
+++ b/modules/computer.c
@@ -953,6 +953,11 @@ const gchar *get_memory_desc(void) // [1] const (as to say "don't free")
return (gchar*)idle_free(avail); // [1] idle_free()
}
+static gchar *get_machine_type(void)
+{
+ return computer_get_virtualization();
+}
+
const ShellModuleMethod *hi_exported_methods(void)
{
static const ShellModuleMethod m[] = {
@@ -964,6 +969,7 @@ const ShellModuleMethod *hi_exported_methods(void)
{"getKernelModuleDescription", get_kernel_module_description},
{"getMemoryTotal", get_memory_total},
{"getMemoryDesc", get_memory_desc},
+ {"getMachineType", get_machine_type},
{NULL},
};