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

Dan Horák dan at danny.cz
Fri Jul 4 08:45:44 PDT 2014


On Fri, 4 Jul 2014 15:07:18 +0200 (CEST)
Thomas Blume <Thomas.Blume at suse.com> 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__)

shouldn't __s390__ be checked instead? It covers both s390 and s390x
and would make both 32 and 64 bit builds to include the same
functionality.


		Dan

> +        /* First layer virtualization (PR/SM) is always present on
> s390x */
> +        _id = "PR/SM";
> +        r = 1;
> +
> +        /* 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;
> +                        }
> +                }
> +        }
> +
> +        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
> 
> -- 
> SUSE LINUX Products GmbH GF: Jeff Hawn, Jennifer Guild, Felix
> Imendörffer, HRB 16746 (AG Nürnberg) Maxfeldstr. 5 / D-90409
> Nürnberg / Phone: +49-911-740 53 - 0 GPG 1024D/91614BBC B226 E3DA
> 37B0 2170 7403  D19C 18AF E579 9161 4BBC


More information about the systemd-devel mailing list