Skip to contentSkip to conversation

runqemu: Use correct kvm CPU options for qemux86* with kvm

PATCH In review Richard Purdie 4 participants 8 messages Sep 25, 2013 – Sep 26, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 runqemu: Use correct kvm CPU options for qemux86* with kvm

The existing -cpu host option caused kernel panics when people attempted to use the kvm option. After research and discussion, the best options appear to be the kvm32/kvm64 cpu types so lets use these instead. These resolve the kernel issues for me.

[YOCTO #3908]

---

scripts/runqemu +5 -1
index efab1a2..12c58d9 100755
@@ -265,7 +265,11 @@ if [ "x$KVM_ENABLED" = "xyes" ]; then
         exit 1;
     fi
     if [ -w /dev/kvm -a -r /dev/kvm ]; then
-        SCRIPT_QEMU_OPT="$SCRIPT_QEMU_OPT -enable-kvm -cpu host"
+        if [ "x$MACHINE" = "xqemux86" ]; then
+            SCRIPT_QEMU_OPT="$SCRIPT_QEMU_OPT -enable-kvm -cpu kvm32"
+        elif [ "x$MACHINE" = "xqemux86-64" ]; then
+            SCRIPT_QEMU_OPT="$SCRIPT_QEMU_OPT -enable-kvm -cpu kvm64"
+        fi
         KVM_ACTIVE="yes"
     else
         echo "You have no rights on /dev/kvm."
Acked-by on v1 1/1
#1 lore raw
Quoted 8 lines · Richard Purdie

The existing -cpu host option caused kernel panics when people attempted to use the kvm option. After research and discussion, the best options appear to be the kvm32/kvm64 cpu types so lets use these instead. These resolve the kernel issues for me.

[YOCTO #3908]

Makes a lot of sense to me:

Quoted 6 lines

---

scripts/runqemu +0 -0
index efab1a2..12c58d9 100755

scripts/runqemu if [ "x$KVM_ENABLED" = "xyes" ]; then · line 272

Quoted 9 lines
scripts/runqemu +5 -1
@@ -265,7 +265,11 @@ if [ "x$KVM_ENABLED" = "xyes" ]; then
         exit 1;
     fi
     if [ -w /dev/kvm -a -r /dev/kvm ]; then
-        SCRIPT_QEMU_OPT="$SCRIPT_QEMU_OPT -enable-kvm -cpu host"
+        if [ "x$MACHINE" = "xqemux86" ]; then
+            SCRIPT_QEMU_OPT="$SCRIPT_QEMU_OPT -enable-kvm -cpu kvm32"
+        elif [ "x$MACHINE" = "xqemux86-64" ]; then
+            SCRIPT_QEMU_OPT="$SCRIPT_QEMU_OPT -enable-kvm -cpu kvm64"
+        fi

The above is fine, but it does raise the question of dealing with non oe-core BSPs with runqemu. For instance, there would be value in testing genericx86 and genericx86_64 in the same way. We can deal with that separately though I think as this solves an immediate problem and doesn't make it any worse for the case I mention.

Signature · 3 lines
Darren Hart
Intel Open Source Technology Center
Yocto Project - Linux Kernel
#2 lore raw
Quoted 27 lines · Darren Hart
Quoted 8 lines · Richard Purdie

The existing -cpu host option caused kernel panics when people attempted to use the kvm option. After research and discussion, the best options appear to be the kvm32/kvm64 cpu types so lets use these instead. These resolve the kernel issues for me.

[YOCTO #3908]

Makes a lot of sense to me:

Quoted 13 lines

---

scripts/runqemu +3 -1
index efab1a2..12c58d9 100755
@@ -265,7 +265,11 @@ if [ "x$KVM_ENABLED" = "xyes" ]; then
         exit 1;
     fi
     if [ -w /dev/kvm -a -r /dev/kvm ]; then
-        SCRIPT_QEMU_OPT="$SCRIPT_QEMU_OPT -enable-kvm -cpu host"
+        if [ "x$MACHINE" = "xqemux86" ]; then
+            SCRIPT_QEMU_OPT="$SCRIPT_QEMU_OPT -enable-kvm -cpu kvm32"
+        elif [ "x$MACHINE" = "xqemux86-64" ]; then
Quoted 8 lines

scripts/runqemu if [ "x$KVM_ENABLED" = "xyes" ]; then · line 272

Quoted 2 lines
scripts/runqemu +2 -0
+            SCRIPT_QEMU_OPT="$SCRIPT_QEMU_OPT -enable-kvm -cpu kvm64"
+        fi

The above is fine, but it does raise the question of dealing with non oe-core BSPs with runqemu. For instance, there would be value in testing genericx86 and genericx86_64 in the same way. We can deal with that separately though I think as this solves an immediate problem and doesn't make it any worse for the case I mention.

There is an explicit check for qemux86* just above this block so whilst I like the idea, its something for another patch and likely 1.6 material. Could be worth an enhancement bug though.

Cheers,

Richard

#3 lore raw
Quoted 37 lines · Richard Purdie
Quoted 27 lines · Darren Hart
Quoted 8 lines · Richard Purdie

The existing -cpu host option caused kernel panics when people attempted to use the kvm option. After research and discussion, the best options appear to be the kvm32/kvm64 cpu types so lets use these instead. These resolve the kernel issues for me.

[YOCTO #3908]

Makes a lot of sense to me:

Quoted 13 lines

---

scripts/runqemu +3 -1
index efab1a2..12c58d9 100755
@@ -265,7 +265,11 @@ if [ "x$KVM_ENABLED" = "xyes" ]; then
         exit 1;
     fi
     if [ -w /dev/kvm -a -r /dev/kvm ]; then
-        SCRIPT_QEMU_OPT="$SCRIPT_QEMU_OPT -enable-kvm -cpu host"
+        if [ "x$MACHINE" = "xqemux86" ]; then
+            SCRIPT_QEMU_OPT="$SCRIPT_QEMU_OPT -enable-kvm -cpu kvm32"
+        elif [ "x$MACHINE" = "xqemux86-64" ]; then
Quoted 8 lines

scripts/runqemu if [ "x$KVM_ENABLED" = "xyes" ]; then · line 272

Quoted 2 lines
scripts/runqemu +2 -0
+            SCRIPT_QEMU_OPT="$SCRIPT_QEMU_OPT -enable-kvm -cpu kvm64"
+        fi

The above is fine, but it does raise the question of dealing with non oe-core BSPs with runqemu. For instance, there would be value in testing genericx86 and genericx86_64 in the same way. We can deal with that separately though I think as this solves an immediate problem and doesn't make it any worse for the case I mention.

Quoted 3 lines

There is an explicit check for qemux86* just above this block so whilst I like the idea, its something for another patch and likely 1.6 material. Could be worth an enhancement bug though.

Agreed, i think that is basically covered by:

Bug 2025 - runqemu scripts should attempt sane defaults for unkown machines

Quoted 6 lines

Cheers,

Richard

Signature · 3 lines
Darren Hart
Intel Open Source Technology Center
Yocto Project - Linux Kernel
#4 lore raw
In reply to Richard Purdie
Quoted 14 lines · Richard Purdie

The existing -cpu host option caused kernel panics when people attempted to use the kvm option. After research and discussion, the best options appear to be the kvm32/kvm64 cpu types so lets use these instead. These resolve the kernel issues for me.

[YOCTO #3908]

---

scripts/runqemu +0 -0
index efab1a2..12c58d9 100755

scripts/runqemu if [ "x$KVM_ENABLED" = "xyes" ]; then · line 272

Quoted 9 lines
scripts/runqemu +5 -1
@@ -265,7 +265,11 @@ if [ "x$KVM_ENABLED" = "xyes" ]; then
         exit 1;
     fi
     if [ -w /dev/kvm -a -r /dev/kvm ]; then
-        SCRIPT_QEMU_OPT="$SCRIPT_QEMU_OPT -enable-kvm -cpu host"
+        if [ "x$MACHINE" = "xqemux86" ]; then
+            SCRIPT_QEMU_OPT="$SCRIPT_QEMU_OPT -enable-kvm -cpu kvm32"
+        elif [ "x$MACHINE" = "xqemux86-64" ]; then
+            SCRIPT_QEMU_OPT="$SCRIPT_QEMU_OPT -enable-kvm -cpu kvm64"
+        fi

may be leave the original in the else clause at the end so it covers the non x86 cases too

Quoted 9 lines
scripts/runqemu +0 -0
         KVM_ACTIVE="yes"
     else
         echo "You have no rights on /dev/kvm."

_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core

#5 lore raw
Quoted 20 lines · Khem Raj
Quoted 18 lines · Richard Purdie

The existing -cpu host option caused kernel panics when people attempted to use the kvm option. After research and discussion, the best options appear to be the kvm32/kvm64 cpu types so lets use these instead. These resolve the kernel issues for me.

[YOCTO #3908]

---

scripts/runqemu +0 -1
index efab1a2..12c58d9 100755
@@ -265,7 +265,11 @@ if [ "x$KVM_ENABLED" = "xyes" ]; then
         exit 1;
     fi
     if [ -w /dev/kvm -a -r /dev/kvm ]; then
-        SCRIPT_QEMU_OPT="$SCRIPT_QEMU_OPT -enable-kvm -cpu host"
Quoted 8 lines

scripts/runqemu if [ "x$KVM_ENABLED" = "xyes" ]; then · line 272

Quoted 5 lines
scripts/runqemu +5 -0
+        if [ "x$MACHINE" = "xqemux86" ]; then
+            SCRIPT_QEMU_OPT="$SCRIPT_QEMU_OPT -enable-kvm -cpu kvm32"
+        elif [ "x$MACHINE" = "xqemux86-64" ]; then
+            SCRIPT_QEMU_OPT="$SCRIPT_QEMU_OPT -enable-kvm -cpu kvm64"
+        fi

may be leave the original in the else clause at the end so it covers the non x86 cases too

There is no non x86 case for kvm. Its already guarded against by code above here which errors if its not one of these two machines...

Cheers,

Richard

#6 lore raw
Quoted 30 lines · Richard Purdie
Quoted 20 lines · Khem Raj
Quoted 18 lines · Richard Purdie

The existing -cpu host option caused kernel panics when people attempted to use the kvm option. After research and discussion, the best options appear to be the kvm32/kvm64 cpu types so lets use these instead. These resolve the kernel issues for me.

[YOCTO #3908]

---

scripts/runqemu +0 -1
index efab1a2..12c58d9 100755
@@ -265,7 +265,11 @@ if [ "x$KVM_ENABLED" = "xyes" ]; then
         exit 1;
     fi
     if [ -w /dev/kvm -a -r /dev/kvm ]; then
-        SCRIPT_QEMU_OPT="$SCRIPT_QEMU_OPT -enable-kvm -cpu host"
Quoted 8 lines

scripts/runqemu if [ "x$KVM_ENABLED" = "xyes" ]; then · line 272

Quoted 5 lines
scripts/runqemu +5 -0
+        if [ "x$MACHINE" = "xqemux86" ]; then
+            SCRIPT_QEMU_OPT="$SCRIPT_QEMU_OPT -enable-kvm -cpu kvm32"
+        elif [ "x$MACHINE" = "xqemux86-64" ]; then
+            SCRIPT_QEMU_OPT="$SCRIPT_QEMU_OPT -enable-kvm -cpu kvm64"
+        fi

may be leave the original in the else clause at the end so it covers the non x86 cases too

Quoted 3 lines

There is no non x86 case for kvm. Its already guarded against by code above here which errors if its not one of these two machines...

thats fine then

Quoted 4 lines

Cheers,

Richard

#7 lore raw
In reply to Richard Purdie
Quoted 4 lines · Richard Purdie

The existing -cpu host option caused kernel panics when people attempted to use the kvm option. After research and discussion, the best options appear to be the kvm32/kvm64 cpu types so lets use these instead. These resolve the kernel issues for me.

Late to the party, and discussion, but agreed. This change looks good for this point in 1.5.

Cheers,

Bruce

Quoted 24 lines

[YOCTO #3908]

---

scripts/runqemu +5 -1
index efab1a2..12c58d9 100755
@@ -265,7 +265,11 @@ if [ "x$KVM_ENABLED" = "xyes" ]; then
          exit 1;
      fi
      if [ -w /dev/kvm -a -r /dev/kvm ]; then
-        SCRIPT_QEMU_OPT="$SCRIPT_QEMU_OPT -enable-kvm -cpu host"
+        if [ "x$MACHINE" = "xqemux86" ]; then
+            SCRIPT_QEMU_OPT="$SCRIPT_QEMU_OPT -enable-kvm -cpu kvm32"
+        elif [ "x$MACHINE" = "xqemux86-64" ]; then
+            SCRIPT_QEMU_OPT="$SCRIPT_QEMU_OPT -enable-kvm -cpu kvm64"
+        fi
          KVM_ACTIVE="yes"
      else
          echo "You have no rights on /dev/kvm."