mirror of
https://github.com/SoftEtherVPN/SoftEtherVPN.git
synced 2024-11-22 17:39:53 +03:00
Mayaqua/Unix: Make VM detection work on FreeBSD
This is just a cosmetic problem in the result of "Caps" command which gets the list of server functions/capability. There's no behavioural change in SoftEtherVPN whether running on VM so far.
This commit is contained in:
parent
2b7b728077
commit
bedf1cd7e9
@ -295,16 +295,25 @@ void UnixDisableInterfaceOffload(char *name)
|
|||||||
#endif // UNIX_LINUX
|
#endif // UNIX_LINUX
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate whether the UNIX is running in a VM
|
// Validate whether the Linux/FreeBSD is running in a VM
|
||||||
|
// Not implemented yet on other OS
|
||||||
bool UnixIsInVmMain()
|
bool UnixIsInVmMain()
|
||||||
{
|
{
|
||||||
TOKEN_LIST *t = NULL;
|
TOKEN_LIST *t = NULL;
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
|
#if defined(UNIX_LINUX)
|
||||||
char *vm_str_list = "Hypervisor detected,VMware Virtual Platform,VMware Virtual USB,qemu,xen,paravirtualized,virtual hd,virtualhd,virtual pc,virtualpc,kvm,oracle vm,oraclevm,parallels,xvm,bochs";
|
char *vm_str_list = "Hypervisor detected,VMware Virtual Platform,VMware Virtual USB,qemu,xen,paravirtualized,virtual hd,virtualhd,virtual pc,virtualpc,kvm,oracle vm,oraclevm,parallels,xvm,bochs";
|
||||||
|
#elif defined(__FreeBSD__)
|
||||||
|
char *vm_str_list = "generic,xen,hv,vmware,kvm,bhyve";
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef UNIX_LINUX
|
#if defined(UNIX_LINUX)
|
||||||
t = UnixExec("/bin/dmesg");
|
t = UnixExec("/bin/dmesg");
|
||||||
|
#elif defined(__FreeBSD__)
|
||||||
|
t = UnixExec("/sbin/sysctl -n kern.vm_guest");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(UNIX_LINUX) || defined(__FreeBSD__)
|
||||||
if (t != NULL)
|
if (t != NULL)
|
||||||
{
|
{
|
||||||
BUF *b = NewBuf();
|
BUF *b = NewBuf();
|
||||||
@ -327,10 +336,11 @@ bool UnixIsInVmMain()
|
|||||||
FreeBuf(b);
|
FreeBuf(b);
|
||||||
FreeToken(t);
|
FreeToken(t);
|
||||||
}
|
}
|
||||||
#endif // UNIX_LINUX
|
#endif // defined(UNIX_LINUX) || defined(__FreeBSD)
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UnixIsInVm()
|
bool UnixIsInVm()
|
||||||
{
|
{
|
||||||
static bool is_in_vm_flag = false;
|
static bool is_in_vm_flag = false;
|
||||||
|
Loading…
Reference in New Issue
Block a user