From: Cyril Hrubis <chrubis@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH 2/2] lib/tst_virt: support IBM/Z LPAR and z/VM virtualization environments
Date: Mon, 9 Nov 2020 15:42:49 +0100 [thread overview]
Message-ID: <20201109144249.GA25892@yuki.lan> (raw)
In-Reply-To: <20201106130624.454614-3-egorenar@linux.ibm.com>
Hi!
> +static int is_ibmz_lpar(void)
> +{
> + FILE *cpuinfo;
> + char line[64];
> + int found_lpar, found_zvm;
> +
> + if (access("/proc/sysinfo", F_OK) != 0)
> + return 0;
> +
> + cpuinfo = SAFE_FOPEN(NULL, "/proc/sysinfo", "r");
> + found_lpar = 0;
> + found_zvm = 0;
> + while (fgets(line, sizeof(line), cpuinfo) != NULL) {
> + if (strstr(line, "LPAR"))
> + found_lpar = 1;
> + else if (strstr(line, "z/VM"))
> + found_zvm = 1;
> + }
> +
> + SAFE_FCLOSE(NULL, cpuinfo);
> + return found_lpar && !found_zvm;
> +}
> +
> +static int is_ibmz_zvm(void)
> +{
> + FILE *cpuinfo;
> + char line[64];
> + int found_lpar, found_zvm;
> +
> + if (access("/proc/sysinfo", F_OK) != 0)
> + return 0;
> +
> + cpuinfo = SAFE_FOPEN(NULL, "/proc/sysinfo", "r");
> + found_lpar = 0;
> + found_zvm = 0;
> + while (fgets(line, sizeof(line), cpuinfo) != NULL) {
> + if (strstr(line, "LPAR"))
> + found_lpar = 1;
> + else if (strstr(line, "z/VM"))
> + found_zvm = 1;
> + }
> +
> + SAFE_FCLOSE(NULL, cpuinfo);
> + return found_lpar && found_zvm;
> +}
These two function are nearly identical apart from the last line, I
guess that it would be cleaner to have one function and pass the
VIRT_IBMZ_LPAR and VIRT_IBMZ_ZVM constants to select which result we
want.
Other than this, the rest looks good.
--
Cyril Hrubis
chrubis@suse.cz
prev parent reply other threads:[~2020-11-09 14:42 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-06 13:06 [LTP] [PATCH 0/2] lib/tst_virt: support IBM/Z LPAR and z/VM virtualization environments Alexander Egorenkov
2020-11-06 13:06 ` [LTP] [PATCH 1/2] lib/tst_virt: fix detection when systemd-detect-virt returns 1 Alexander Egorenkov
2020-11-09 14:31 ` Cyril Hrubis
2020-11-06 13:06 ` [LTP] [PATCH 2/2] lib/tst_virt: support IBM/Z LPAR and z/VM virtualization environments Alexander Egorenkov
2020-11-09 14:42 ` Cyril Hrubis [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201109144249.GA25892@yuki.lan \
--to=chrubis@suse.cz \
--cc=ltp@lists.linux.it \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox