* [kvm-unit-tests PATCH v2] scripts/arch-run.bash: Drop the dependency on "jq"
@ 2025-07-31 11:05 Thomas Huth
0 siblings, 0 replies; 8+ messages in thread
From: Thomas Huth @ 2025-07-31 11:05 UTC (permalink / raw)
To: kvm, Nico Böhr, Claudio Imbrenda; +Cc: Janosch Frank, David Hildenbrand
From: Thomas Huth <thuth@redhat.com>
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 <thuth@redhat.com>
---
v2: Use [[:blank:]]* as suggested by Claudio
scripts/arch-run.bash | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)
diff --git a/scripts/arch-run.bash b/scripts/arch-run.bash
index 58e4f93f..4642cf95 100644
--- a/scripts/arch-run.bash
+++ b/scripts/arch-run.bash
@@ -287,11 +287,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
@@ -303,8 +298,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
--
2.50.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [kvm-unit-tests PATCH v2] scripts/arch-run.bash: Drop the dependency on "jq"
@ 2025-09-09 4:58 Thomas Huth
2025-09-09 13:49 ` Claudio Imbrenda
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Thomas Huth @ 2025-09-09 4:58 UTC (permalink / raw)
To: kvm, Claudio Imbrenda; +Cc: Andrew Jones, Janosch Frank, Nico Böhr
From: Thomas Huth <thuth@redhat.com>
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 <thuth@redhat.com>
---
v2: Change the regular expression according to Claudio's suggestion
scripts/arch-run.bash | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)
diff --git a/scripts/arch-run.bash b/scripts/arch-run.bash
index 36222355..16417a1e 100644
--- a/scripts/arch-run.bash
+++ b/scripts/arch-run.bash
@@ -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
--
2.51.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [kvm-unit-tests PATCH v2] scripts/arch-run.bash: Drop the dependency on "jq"
2025-09-09 4:58 [kvm-unit-tests PATCH v2] scripts/arch-run.bash: Drop the dependency on "jq" Thomas Huth
@ 2025-09-09 13:49 ` Claudio Imbrenda
2025-09-09 16:05 ` Andrew Jones
2025-09-10 7:57 ` Nico Boehr
2 siblings, 0 replies; 8+ messages in thread
From: Claudio Imbrenda @ 2025-09-09 13:49 UTC (permalink / raw)
To: Thomas Huth; +Cc: kvm, Andrew Jones, Janosch Frank, Nico Böhr
On Tue, 9 Sep 2025 06:58:55 +0200
Thomas Huth <thuth@redhat.com> wrote:
> From: Thomas Huth <thuth@redhat.com>
>
> 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 <thuth@redhat.com>
Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
> ---
> v2: Change the regular expression according to Claudio's suggestion
>
> scripts/arch-run.bash | 8 +-------
> 1 file changed, 1 insertion(+), 7 deletions(-)
>
> diff --git a/scripts/arch-run.bash b/scripts/arch-run.bash
> index 36222355..16417a1e 100644
> --- a/scripts/arch-run.bash
> +++ b/scripts/arch-run.bash
> @@ -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
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [kvm-unit-tests PATCH v2] scripts/arch-run.bash: Drop the dependency on "jq"
2025-09-09 4:58 [kvm-unit-tests PATCH v2] scripts/arch-run.bash: Drop the dependency on "jq" Thomas Huth
2025-09-09 13:49 ` Claudio Imbrenda
@ 2025-09-09 16:05 ` Andrew Jones
2025-09-10 7:57 ` Nico Boehr
2 siblings, 0 replies; 8+ messages in thread
From: Andrew Jones @ 2025-09-09 16:05 UTC (permalink / raw)
To: Thomas Huth; +Cc: kvm, Claudio Imbrenda, Janosch Frank, Nico Böhr
On Tue, Sep 09, 2025 at 06:58:55AM +0200, Thomas Huth wrote:
> From: Thomas Huth <thuth@redhat.com>
>
> 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 <thuth@redhat.com>
> ---
> v2: Change the regular expression according to Claudio's suggestion
>
> scripts/arch-run.bash | 8 +-------
> 1 file changed, 1 insertion(+), 7 deletions(-)
>
> diff --git a/scripts/arch-run.bash b/scripts/arch-run.bash
> index 36222355..16417a1e 100644
> --- a/scripts/arch-run.bash
> +++ b/scripts/arch-run.bash
> @@ -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
> --
> 2.51.0
>
Reviewed-by: Andrew Jones <andrew.jones@linux.dev>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [kvm-unit-tests PATCH v2] scripts/arch-run.bash: Drop the dependency on "jq"
2025-09-09 4:58 [kvm-unit-tests PATCH v2] scripts/arch-run.bash: Drop the dependency on "jq" Thomas Huth
2025-09-09 13:49 ` Claudio Imbrenda
2025-09-09 16:05 ` Andrew Jones
@ 2025-09-10 7:57 ` Nico Boehr
2025-09-10 9:00 ` Claudio Imbrenda
2 siblings, 1 reply; 8+ messages in thread
From: Nico Boehr @ 2025-09-10 7:57 UTC (permalink / raw)
To: Thomas Huth, kvm, Claudio Imbrenda; +Cc: Andrew Jones, Janosch Frank
On Tue Sep 9, 2025 at 6:58 AM CEST, Thomas Huth wrote:
> 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?
> diff --git a/scripts/arch-run.bash b/scripts/arch-run.bash
> index 36222355..16417a1e 100644
> --- a/scripts/arch-run.bash
> +++ b/scripts/arch-run.bash
> @@ -296,11 +296,6 @@ do_migration ()
>
> run_panic ()
> {
[...]
> - 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.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [kvm-unit-tests PATCH v2] scripts/arch-run.bash: Drop the dependency on "jq"
2025-09-10 7:57 ` Nico Boehr
@ 2025-09-10 9:00 ` Claudio Imbrenda
2025-09-10 9:06 ` Thomas Huth
0 siblings, 1 reply; 8+ messages in thread
From: Claudio Imbrenda @ 2025-09-10 9:00 UTC (permalink / raw)
To: Nico Boehr; +Cc: Thomas Huth, kvm, Andrew Jones, Janosch Frank
On Wed, 10 Sep 2025 09:57:17 +0200
"Nico Boehr" <nrb@linux.ibm.com> wrote:
> On Tue Sep 9, 2025 at 6:58 AM CEST, Thomas Huth wrote:
> > 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
>
> > diff --git a/scripts/arch-run.bash b/scripts/arch-run.bash
> > index 36222355..16417a1e 100644
> > --- a/scripts/arch-run.bash
> > +++ b/scripts/arch-run.bash
> > @@ -296,11 +296,6 @@ do_migration ()
> >
> > run_panic ()
> > {
> [...]
> > - 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.
in that case we have other issues
>
> 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
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [kvm-unit-tests PATCH v2] scripts/arch-run.bash: Drop the dependency on "jq"
2025-09-10 9:00 ` Claudio Imbrenda
@ 2025-09-10 9:06 ` Thomas Huth
2025-09-10 11:36 ` Nico Boehr
0 siblings, 1 reply; 8+ messages in thread
From: Thomas Huth @ 2025-09-10 9:06 UTC (permalink / raw)
To: Claudio Imbrenda, Nico Boehr; +Cc: kvm, Andrew Jones, Janosch Frank
On 10/09/2025 11.00, Claudio Imbrenda wrote:
> On Wed, 10 Sep 2025 09:57:17 +0200
> "Nico Boehr" <nrb@linux.ibm.com> wrote:
>
>> On Tue Sep 9, 2025 at 6:58 AM CEST, Thomas Huth wrote:
>>> 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
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
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [kvm-unit-tests PATCH v2] scripts/arch-run.bash: Drop the dependency on "jq"
2025-09-10 9:06 ` Thomas Huth
@ 2025-09-10 11:36 ` Nico Boehr
0 siblings, 0 replies; 8+ messages in thread
From: Nico Boehr @ 2025-09-10 11:36 UTC (permalink / raw)
To: Thomas Huth, Claudio Imbrenda; +Cc: kvm, Andrew Jones, Janosch Frank
On Wed Sep 10, 2025 at 11:06 AM CEST, Thomas Huth wrote:
> On 10/09/2025 11.00, Claudio Imbrenda wrote:
>> On Wed, 10 Sep 2025 09:57:17 +0200
>> "Nico Boehr" <nrb@linux.ibm.com> wrote:
>>
>>> On Tue Sep 9, 2025 at 6:58 AM CEST, Thomas Huth wrote:
>>>> 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
>
> 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.
Acked-by: Nico Boehr <nrb@linux.ibm.com>
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2025-09-10 11:36 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-09 4:58 [kvm-unit-tests PATCH v2] scripts/arch-run.bash: Drop the dependency on "jq" Thomas Huth
2025-09-09 13:49 ` Claudio Imbrenda
2025-09-09 16:05 ` Andrew Jones
2025-09-10 7:57 ` Nico Boehr
2025-09-10 9:00 ` Claudio Imbrenda
2025-09-10 9:06 ` Thomas Huth
2025-09-10 11:36 ` Nico Boehr
-- strict thread matches above, loose matches on Subject: below --
2025-07-31 11:05 Thomas Huth
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox