[systemd-devel] [PATCH] systemd-detect-s390-virt: add virtualization detection on s390x

Zbigniew Jędrzejewski-Szmek zbyszek at in.waw.pl
Fri Jul 4 08:28:47 PDT 2014


On Fri, Jul 04, 2014 at 03:07:18PM +0200, Thomas Blume wrote:
> systemd was lacking the code to detect virtualization on s390x.
> The patch adds detection for the primary virtualization layer (PR/SM)
> as well as for secondary layers (z/VM and KVM).
> ---
>  src/shared/virt.c | 24 ++++++++++++++++++++++++
>  1 file changed, 24 insertions(+)
> 
> diff --git a/src/shared/virt.c b/src/shared/virt.c
> index 774915f..af38b04 100644
> --- a/src/shared/virt.c
> +++ b/src/shared/virt.c
> @@ -195,6 +195,30 @@ int detect_vm(const char **id) {
>          } else
>                  return r;
> 
> +#if defined(__s390x__)
> +        /* First layer virtualization (PR/SM) is always present on s390x */
> +        _id = "PR/SM";
> +        r = 1;
What does this mean? Is it like XEN dom0, i.e. normianally a virtuallized OS,
but one that has full access to hardware? We recently [1] started to report
that as non-virtualized, because what matters is the ability to access hardware,
and not the way that the system is built.

[1] 37287585b6ba9a5

> +
> +        /* Check for second layer virtualization */
> +        _cleanup_fclose_ FILE *f = NULL;
> +        char line[LINE_MAX];
> +        f = fopen("/proc/sysinfo", "re");
> +        if (f) {
> +                FOREACH_LINE(line, f, return -errno) {
> +                        if (startswith(line, "VM00 Control Program:")) {
> +                                if (strstr(line,"z/VM"))
> +                                        _id = "z/VM";
> +                                else if (strstr(line,"KVM/Linux"))
> +                                        _id = "KVM";
> +                                break;
> +                        }
> +                }
> +        }
Can you use get_status_field for this?

> +
> +        goto finish;
> +#endif
> +
>          /* this will set _id to "other" and return 0 for unknown hypervisors */
>          r = detect_vm_cpuid(&_id);
>          if (r != 0)
> -- 
> 1.8.4.5
> 
> 
> Thomas Blume

Zbyszek


More information about the systemd-devel mailing list