Skip to contentSkip to conversation

scripts: Search the entire string for the correct accelerator

PATCH Superseded Sean Christopherson 2 participants 5 messages Apr 25, 2025 – May 2, 2025 KVM

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Sean Christopherson

author reviewer
#0 lore raw

PATCH 1/1 scripts: Search the entire string for the correct accelerator

Search the entire ACCEL string for the required accelerator as searching for an exact match incorrectly rejects ACCEL when additional accelerator specific options are provided, e.g.

SKIP pmu (kvm only, but ACCEL=kvm,kernel_irqchip=on)

---
 scripts/runtime.bash | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/runtime.bash +1 -1
index 4b9c7d6b..59d1727c 100644
@@ -126,7 +126,7 @@ function run()
         machine="$MACHINE"
     fi
 
-    if [ -n "$accel" ] && [ -n "$ACCEL" ] && [ "$accel" != "$ACCEL" ]; then
+    if [ -n "$accel" ] && [ -n "$ACCEL" ] && [[ ! "$ACCEL" =~ $accel ]]; then
         print_result "SKIP" $testname "" "$accel only, but ACCEL=$ACCEL"
         return 2
     elif [ -n "$ACCEL" ]; then

base-commit: 0d3cb7dd56ec255a71af867c2d76c8f4b22cd420

Signature · 1 line
2.49.0.850.g28803427d3-goog
#1 lore raw
Quoted 16 lines · Sean Christopherson

Search the entire ACCEL string for the required accelerator as searching for an exact match incorrectly rejects ACCEL when additional accelerator specific options are provided, e.g.

SKIP pmu (kvm only, but ACCEL=kvm,kernel_irqchip=on)

---
 scripts/runtime.bash | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/runtime.bash +0 -0
index 4b9c7d6b..59d1727c 100644

scripts/runtime.bash function run() · line 129

Quoted 5 lines
scripts/runtime.bash +1 -1
@@ -126,7 +126,7 @@ function run()
         machine="$MACHINE"
     fi
 
-    if [ -n "$accel" ] && [ -n "$ACCEL" ] && [ "$accel" != "$ACCEL" ]; then
+    if [ -n "$accel" ] && [ -n "$ACCEL" ] && [[ ! "$ACCEL" =~ $accel ]]; then

Let's use

[[ ! $ACCEL =~ ^$accel(,.*|$) ]]

to be a bit more precise.

Thanks,
drew

Quoted 8 lines
scripts/runtime.bash +0 -0
         print_result "SKIP" $testname "" "$accel only, but ACCEL=$ACCEL"
         return 2
     elif [ -n "$ACCEL" ]; then

base-commit: 0d3cb7dd56ec255a71af867c2d76c8f4b22cd420

Signature · 1 line
2.49.0.850.g28803427d3-goog
author reviewer
#2 lore raw
Quoted 20 lines · Andrew Jones
Quoted 19 lines · Sean Christopherson

Search the entire ACCEL string for the required accelerator as searching for an exact match incorrectly rejects ACCEL when additional accelerator specific options are provided, e.g.

SKIP pmu (kvm only, but ACCEL=kvm,kernel_irqchip=on)

---
 scripts/runtime.bash | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/runtime.bash +0 -0
index 4b9c7d6b..59d1727c 100644
@@ -126,7 +126,7 @@ function run()
         machine="$MACHINE"
     fi
 
Quoted 8 lines

scripts/runtime.bash function run() · line 129

Quoted 2 lines
scripts/runtime.bash +1 -1
-    if [ -n "$accel" ] && [ -n "$ACCEL" ] && [ "$accel" != "$ACCEL" ]; then
+    if [ -n "$accel" ] && [ -n "$ACCEL" ] && [[ ! "$ACCEL" =~ $accel ]]; then

Let's use

[[ ! $ACCEL =~ ^$accel(,.*|$) ]]

to be a bit more precise.

Sadist. :-)

Why the ".*"? Isn't that the same as:

[[ ! "$ACCEL" =~ ^$accel(,|$) ]]

Or are my regex skills worse than I realize (and I fully realize they're really, really bad)?

#3 lore raw
Quoted 26 lines · Sean Christopherson
Quoted 25 lines · Andrew Jones
Quoted 16 lines · Sean Christopherson

Search the entire ACCEL string for the required accelerator as searching for an exact match incorrectly rejects ACCEL when additional accelerator specific options are provided, e.g.

SKIP pmu (kvm only, but ACCEL=kvm,kernel_irqchip=on)

---
 scripts/runtime.bash | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/runtime.bash +0 -0
index 4b9c7d6b..59d1727c 100644

scripts/runtime.bash function run() · line 129

Quoted 5 lines
scripts/runtime.bash +1 -1
@@ -126,7 +126,7 @@ function run()
         machine="$MACHINE"
     fi
 
-    if [ -n "$accel" ] && [ -n "$ACCEL" ] && [ "$accel" != "$ACCEL" ]; then
+    if [ -n "$accel" ] && [ -n "$ACCEL" ] && [[ ! "$ACCEL" =~ $accel ]]; then

Let's use

Quoted 5 lines
Quoted 3 lines

[[ ! $ACCEL =~ ^$accel(,.*|$) ]]

to be a bit more precise.

Sadist. :-)

Hehe

Quoted 7 lines

Why the ".*"? Isn't that the same as:

[[ ! "$ACCEL" =~ ^$accel(,|$) ]]

Or are my regex skills worse than I realize (and I fully realize they're really, really bad)?

Oops, that ".*" should have been a ".+" since the intention was to avoid accepting 'kvm,', but, of course you're right, that .* still allows it, making it equivalent to nothing at all.

We can either just drop the .* and accept 'kvm,' (because why not) or change that * to +.

Thanks,
drew

author reviewer
#4 lore raw
Quoted 43 lines · Andrew Jones
Quoted 26 lines · Sean Christopherson
Quoted 25 lines · Andrew Jones
Quoted 16 lines · Sean Christopherson

Search the entire ACCEL string for the required accelerator as searching for an exact match incorrectly rejects ACCEL when additional accelerator specific options are provided, e.g.

SKIP pmu (kvm only, but ACCEL=kvm,kernel_irqchip=on)

---
 scripts/runtime.bash | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/runtime.bash +0 -0
index 4b9c7d6b..59d1727c 100644

scripts/runtime.bash function run() · line 129

Quoted 5 lines
scripts/runtime.bash +1 -1
@@ -126,7 +126,7 @@ function run()
         machine="$MACHINE"
     fi
 
-    if [ -n "$accel" ] && [ -n "$ACCEL" ] && [ "$accel" != "$ACCEL" ]; then
+    if [ -n "$accel" ] && [ -n "$ACCEL" ] && [[ ! "$ACCEL" =~ $accel ]]; then

Let's use

Quoted 5 lines
Quoted 3 lines

[[ ! $ACCEL =~ ^$accel(,.*|$) ]]

to be a bit more precise.

Sadist. :-)

Hehe

Quoted 7 lines

Why the ".*"? Isn't that the same as:

[[ ! "$ACCEL" =~ ^$accel(,|$) ]]

Or are my regex skills worse than I realize (and I fully realize they're really, really bad)?

Quoted 6 lines

Oops, that ".*" should have been a ".+" since the intention was to avoid accepting 'kvm,', but, of course you're right, that .* still allows it, making it equivalent to nothing at all.

We can either just drop the .* and accept 'kvm,' (because why not) or change that * to +.

I'll drop the .*, as QEMU accepts "kvm,", i.e. it actually works.