1
0
mirror of https://github.com/gophernicus/gophernicus.git synced 2024-06-16 06:25:23 +00:00

Added detection for non-DMI Linux hypervisors (Xen)

This commit is contained in:
Kim Holviala 2016-01-01 11:02:10 +02:00
parent 6b02504df2
commit c6827aa9c5
3 changed files with 22 additions and 0 deletions

View File

@ -99,6 +99,7 @@
#include <errno.h>
#include <pwd.h>
#include <limits.h>
#include <ctype.h>
#ifdef HAVE_SENDFILE
#include <sys/sendfile.h>

View File

@ -152,6 +152,17 @@ void platform(state *st)
}
}
/* No DMI? Get possible hypervisor name */
if (!*st->server_description && (fp = fopen("/sys/hypervisor/type" , "r"))) {
fgets(buf, sizeof(buf), fp);
fclose(fp);
chomp(buf);
ucfirst(buf);
if (*buf) snprintf(st->server_description, sizeof(st->server_description), "%s virtual machine", buf);
}
/* Identify Gentoo */
if (!*sysname && (fp = fopen("/etc/gentoo-release", "r"))) {
fgets(sysname, sizeof(sysname), fp);

View File

@ -26,6 +26,16 @@
#include "gophernicus.h"
/*
* Make a string's first character uppercase
*/
void ucfirst(char *str)
{
if (str == NULL || !*str) return;
*str = toupper(*str);
}
/*
* Repeat a character num times and zero-terminate
*/