scripts/arch-run.bash: Drop the dependency on "jq"
PATCH v2 1/1 scripts/arch-run.bash: Drop the dependency on "jq"
From: Thomas Huth <[email protected]>
For checking whether a panic event occurred, a simple "grep" for the related text in the output is enough - it's very unlikely that the output of QEMU will change. This way we can drop the dependency on the program "jq" which might not be installed on some systems.
---
v2: Change the regular expression according to Claudio's suggestion
scripts/arch-run.bash | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)
scripts/arch-run.bash +1 -7
@@ -296,11 +296,6 @@ do_migration () run_panic () { - if ! command -v jq >/dev/null 2>&1; then - echo "${FUNCNAME[0]} needs jq" >&2 - return 77 - fi - trap 'trap - TERM ; kill 0 ; exit 2' INT TERM trap 'rm -f ${qmp}.in ${qmp}.out' RETURN EXIT
@@ -312,8 +307,7 @@ run_panic () -mon chardev=mon,mode=control -S & echo '{ "execute": "qmp_capabilities" }{ "execute": "cont" }' > ${qmp}.in - panic_event_count=$(jq -c 'select(.event == "GUEST_PANICKED")' < ${qmp}.out | wc -l) - if [ "$panic_event_count" -lt 1 ]; then + if ! grep -E -q '"event"[[:blank:]]*:[[:blank:]]*"GUEST_PANICKED"' ${qmp}.out ; then echo "FAIL: guest did not panic" ret=3 else
Signature · 1 line
2.51.0
Quoted 9 lines · On Tue, 9 Sep 2025 06:58:55 +0200 Thomas Huth <[email protected]> wrote:
From: Thomas Huth <[email protected]>
For checking whether a panic event occurred, a simple "grep" for the related text in the output is enough - it's very unlikely that the output of QEMU will change. This way we can drop the dependency on the program "jq" which might not be installed on some systems.
Signed-off-by Thomas Huth <[email protected]>
Quoted 32 lines
---
v2: Change the regular expression according to Claudio's suggestionscripts/arch-run.bash | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)scripts/arch-run.bash +1
-7@@ -296,11 +296,6 @@ do_migration () run_panic () { - if ! command -v jq >/dev/null 2>&1; then - echo "${FUNCNAME[0]} needs jq" >&2 - return 77 - fi - trap 'trap - TERM ; kill 0 ; exit 2' INT TERM trap 'rm -f ${qmp}.in ${qmp}.out' RETURN EXIT@@ -312,8 +307,7 @@ run_panic () -mon chardev=mon,mode=control -S & echo '{ "execute": "qmp_capabilities" }{ "execute": "cont" }' > ${qmp}.in - panic_event_count=$(jq -c 'select(.event == "GUEST_PANICKED")' < ${qmp}.out | wc -l) - if [ "$panic_event_count" -lt 1 ]; then + if ! grep -E -q '"event"[[:blank:]]*:[[:blank:]]*"GUEST_PANICKED"' ${qmp}.out ; then echo "FAIL: guest did not panic" ret=3 else
Quoted 44 lines · Thomas Huth
From: Thomas Huth <[email protected]>
For checking whether a panic event occurred, a simple "grep" for the related text in the output is enough - it's very unlikely that the output of QEMU will change. This way we can drop the dependency on the program "jq" which might not be installed on some systems.
Signed-off-by Thomas Huth <[email protected]>---
v2: Change the regular expression according to Claudio's suggestionscripts/arch-run.bash | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)scripts/arch-run.bash +1
-7@@ -296,11 +296,6 @@ do_migration () run_panic () { - if ! command -v jq >/dev/null 2>&1; then - echo "${FUNCNAME[0]} needs jq" >&2 - return 77 - fi - trap 'trap - TERM ; kill 0 ; exit 2' INT TERM trap 'rm -f ${qmp}.in ${qmp}.out' RETURN EXIT@@ -312,8 +307,7 @@ run_panic () -mon chardev=mon,mode=control -S & echo '{ "execute": "qmp_capabilities" }{ "execute": "cont" }' > ${qmp}.in - panic_event_count=$(jq -c 'select(.event == "GUEST_PANICKED")' < ${qmp}.out | wc -l) - if [ "$panic_event_count" -lt 1 ]; then + if ! grep -E -q '"event"[[:blank:]]*:[[:blank:]]*"GUEST_PANICKED"' ${qmp}.out ; then echo "FAIL: guest did not panic" ret=3 elseSignature · 1 line
2.51.0
Quoted 5 lines · Thomas Huth
For checking whether a panic event occurred, a simple "grep" for the related text in the output is enough - it's very unlikely that the output of QEMU will change. This way we can drop the dependency on the program "jq" which might not be installed on some systems.
Trying to understand which problem you're trying to solve here.
Is there any major distribution which doesn't have jq in its repos? Or any reason why you wouldn't install it?
Quoted 8 lines
scripts/arch-run.bash +0
-0@@ -296,11 +296,6 @@ do_migration () run_panic () {
[...]
scripts/arch-run.bash run_panic () · line 310
Quoted 3 lines
scripts/arch-run.bash +1
-2- panic_event_count=$(jq -c 'select(.event == "GUEST_PANICKED")' < ${qmp}.out | wc -l) - if [ "$panic_event_count" -lt 1 ]; then + if ! grep -E -q '"event"[[:blank:]]*:[[:blank:]]*"GUEST_PANICKED"' ${qmp}.out ; then
This changes behaviour.
Now "event" can be arbitrarily deep nested in the JSON. It could even be completely invalid JSON.
Not saying we shouldn't do this, it just comes with a cost and we need to see if it's worth paying that.
Quoted 11 lines · On Wed, 10 Sep 2025 09:57:17 +0200 "Nico Boehr" <[email protected]> wrote:
Quoted 5 lines · Thomas Huth
For checking whether a panic event occurred, a simple "grep" for the related text in the output is enough - it's very unlikely that the output of QEMU will change. This way we can drop the dependency on the program "jq" which might not be installed on some systems.
Trying to understand which problem you're trying to solve here.
Is there any major distribution which doesn't have jq in its repos? Or any reason why you wouldn't install it?
I think it's just a matter of trying to avoid too many dependencies, especially for something this trivial
Quoted 10 lines
Quoted 9 lines
scripts/arch-run.bash +0
-0@@ -296,11 +296,6 @@ do_migration () run_panic () {[...]
Quoted 8 lines
scripts/arch-run.bash run_panic () · line 310
Quoted 3 lines
scripts/arch-run.bash +1
-2- panic_event_count=$(jq -c 'select(.event == "GUEST_PANICKED")' < ${qmp}.out | wc -l) - if [ "$panic_event_count" -lt 1 ]; then + if ! grep -E -q '"event"[[:blank:]]*:[[:blank:]]*"GUEST_PANICKED"' ${qmp}.out ; thenThis changes behaviour.
Now "event" can be arbitrarily deep nested in the JSON. It could even be completely invalid JSON.
in that case we have other issues
Quoted 3 lines
Not saying we shouldn't do this, it just comes with a cost and we need to see if it's worth paying that.
I don't have a strong opinion on this, but in general I like the idea of having fewer dependencies
Quoted 10 lines · Claudio Imbrenda
Quoted 7 lines · On Wed, 10 Sep 2025 09:57:17 +0200 "Nico Boehr" <[email protected]> wrote:
Quoted 5 lines · Thomas Huth
For checking whether a panic event occurred, a simple "grep" for the related text in the output is enough - it's very unlikely that the output of QEMU will change. This way we can drop the dependency on the program "jq" which might not be installed on some systems.
Quoted 7 lines
Quoted 4 lines
Trying to understand which problem you're trying to solve here.
Is there any major distribution which doesn't have jq in its repos? Or any reason why you wouldn't install it?
I think it's just a matter of trying to avoid too many dependencies, especially for something this trivial
Yes ... actually, a while ago, I noticed that I was never running this test on fresh installations since "jq" is not there by default. I guess it's the same for many other people, too, since we don't really tell them to install "jq" first.
So let's give this patch a try for a while, and if we run into problems, we can still revert it.
Thomas
Nico Boehr
Acked-byQuoted 19 lines · Thomas Huth
Quoted 10 lines · Claudio Imbrenda
Quoted 7 lines · On Wed, 10 Sep 2025 09:57:17 +0200 "Nico Boehr" <[email protected]> wrote:
Quoted 5 lines · Thomas Huth
For checking whether a panic event occurred, a simple "grep" for the related text in the output is enough - it's very unlikely that the output of QEMU will change. This way we can drop the dependency on the program "jq" which might not be installed on some systems.
Quoted 7 lines
Quoted 4 lines
Trying to understand which problem you're trying to solve here.
Is there any major distribution which doesn't have jq in its repos? Or any reason why you wouldn't install it?
I think it's just a matter of trying to avoid too many dependencies, especially for something this trivial
Quoted 7 lines
Yes ... actually, a while ago, I noticed that I was never running this test on fresh installations since "jq" is not there by default. I guess it's the same for many other people, too, since we don't really tell them to install "jq" first.
So let's give this patch a try for a while, and if we run into problems, we can still revert it.