From: Jiri Jaburek <jjaburek@redhat.com>
To: "Wei,Jiangang" <weijg.fnst@cn.fujitsu.com>
Cc: ltp-list@lists.sourceforge.net
Subject: Re: [LTP] [PATCH 2/2] lib/tst_virt.c: distinguish between KVM and QEMU
Date: Tue, 24 Feb 2015 12:36:10 +0100 [thread overview]
Message-ID: <54EC622A.7040106@redhat.com> (raw)
In-Reply-To: <1424766459-22439-2-git-send-email-weijg.fnst@cn.fujitsu.com>
Hello and thanks for the patch. Aside from indent issues (please use
tabs, Linux kernel style), I have some comments/questions:
On 02/24/2015 09:27 AM, Wei,Jiangang wrote:
> KVM guest is on top of QEMU, It's necessary that figure out
> the difference between the two.
>
> Signed-off-by: Wei,Jiangang <weijg.fnst@cn.fujitsu.com>
> ---
> lib/tst_virt.c | 16 +++++++++++++---
> 1 file changed, 13 insertions(+), 3 deletions(-)
>
> diff --git a/lib/tst_virt.c b/lib/tst_virt.c
> index eb3b487..1d9960e 100644
> --- a/lib/tst_virt.c
> +++ b/lib/tst_virt.c
> @@ -100,14 +100,24 @@ static int is_kvm(void)
> FILE *cpuinfo;
> char line[64];
> int found;
> + char sig[SIG_MAX_LEN];
>
> - /* this doesn't work with custom -cpu values, since there's
> - * no easy, reasonable or reliable way to work around those */
When writing this, I was well aware of virt-what, which is exactly
why I wrote that comment the way I did - the code used by virt-what
is not easy, reliable or (IMO) reasonable to copy/paste into LTP.
Specifically with kvm, the KVMKVMKVM detection used to fail (IIRC)
with some specific hosts and qemu versions. It can also be easily
bypassed with -cpu host,kvm=off (which doesn't disable kvm accel).
> cpuinfo = SAFE_FOPEN(NULL, "/proc/cpuinfo", "r");
> found = 0;
> while (fgets(line, sizeof(line), cpuinfo) != NULL) {
> if (strstr(line, "QEMU Virtual CPU")) {
> - found = 1;
> + /*
> + * Is it an KVM(on top of QEMU) or Only a QEMU?
> + */
Well, yes, I'm aware that "KVM" is really just QEMU + accel, which
is why my original series actually had VIRT_QEMU instead of VIRT_KVM,
but then it was pointed out to me that VIRT_KVM would make sense to
most people not knowledgeable enough in this area.
I'm not against renaming it, but I'm a bit baffled by the separation.
> + if (cpu_sign(&sig[0]) == 0) {
> + if (strcmp(sig, "KVMKVMKVM") == 0) {
> + found = 1;
> + } else {
> + // QEMU Guest
This leads me to ask why did you create the patches - why should the
default QEMU with TCG be any different w.r.t. the only test that
currently uses the tst_is_virt() function?
Again, I'm not against renaming VIRT_KVM to VIRT_QEMU as it would be
technically more correct, but why separate accel=kvm from accel=tcg?
What about accel=xen?
> + }
> + } else {
> + found = 1;
> + }
> break;
> }
> }
>
Thanks,
Jiri
------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
next prev parent reply other threads:[~2015-02-24 11:36 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-24 8:27 [LTP] [PATCH 1/2] lib: provide a way to detect if we are running on KVM or Xen Wei,Jiangang
2015-02-24 8:27 ` [LTP] [PATCH 2/2] lib/tst_virt.c: distinguish between KVM and QEMU Wei,Jiangang
2015-02-24 11:36 ` Jiri Jaburek [this message]
2015-02-25 3:31 ` [LTP] 答复: " Wei, Jiangang
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=54EC622A.7040106@redhat.com \
--to=jjaburek@redhat.com \
--cc=ltp-list@lists.sourceforge.net \
--cc=weijg.fnst@cn.fujitsu.com \
/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