KVM guest is on top of QEMU, It's necessary that figure out
the difference between the two.

Signed-off-by: Wei,Jiangang <weijg.f...@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 */
        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?
+             */
+            if (cpu_sign(&sig[0]) == 0) {
+                if (strcmp(sig, "KVMKVMKVM") == 0) {
+                    found = 1;
+                } else {
+                    // QEMU Guest
+                }
+            } else {
+                found = 1;
+            }
                        break;
                }
        }
-- 
1.9.3


------------------------------------------------------------------------------
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

Reply via email to