Skip to content

Commit

Permalink
lib: Detect Microsoft Hyper-V
Browse files Browse the repository at this point in the history
Add basic detection of Microsoft Hyper-V hypervisor using systemd.
Other way would be to check for PCI devices (Microsoft Corporation
Hyper-V virtual VGA) or via DMI tables (dmidecoder).

Detection of Hyper-V is important to skip failing getrusage04 test.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
Reviewed-by: Cyril Hrubis <chrubis@suse.cz>
  • Loading branch information
krzk authored and metan-ucw committed Jun 7, 2021
1 parent 43f477c commit 454a9b9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/tst_cpu.h
Expand Up @@ -16,6 +16,7 @@ long tst_ncpus_available(void);
#define VIRT_IBMZ 3 /* ibm system z */
#define VIRT_IBMZ_LPAR 4 /* ibm system z lpar */
#define VIRT_IBMZ_ZVM 5 /* ibm system z zvm */
#define VIRT_HYPERV 6 /* Microsoft Hyper-V */
#define VIRT_OTHER 0xffff /* unrecognized hypervisor */

int tst_is_virt(int virt_type);
Expand Down
3 changes: 3 additions & 0 deletions lib/tst_virt.c
Expand Up @@ -138,6 +138,9 @@ static int try_systemd_detect_virt(void)
if (!strncmp("zvm", virt_type, 3))
return VIRT_IBMZ_ZVM;

if (!strncmp("microsoft", virt_type, 9))
return VIRT_HYPERV;

return VIRT_OTHER;
}

Expand Down

0 comments on commit 454a9b9

Please sign in to comment.