Skip to contentSkip to conversation

system: Select HVF by default when no other accelerator is available

PATCH In review Philippe Mathieu-Daudé 4 participants 5 messages Dec 3, 2024

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 system: Select HVF by default when no other accelerator is available

When testing with a HVF-only binary, we get:

3/12 qemu:func-quick+func-aarch64 / func-aarch64-version ERROR 0.29s exit status 1
stderr:
Traceback (most recent call last):
File "tests/functional/test_version.py", line 22, in test_qmp_human_info_version
self.vm.launch()
File "machine/machine.py", line 461, in launch
raise VMLaunchFailure(
qemu.machine.machine.VMLaunchFailure: ConnectError: Failed to establish session: EOFError
Exit code: 1
Command: build/qemu-system-aarch64 -display none -vga none -chardev socket,id=mon,fd=5 -mon chardev=mon,mode=control -machine none -nodefaults
Output: qemu-system-aarch64: No accelerator selected and no default accelerator available

Fix by checking for HVF in configure_accelerators() and using it by default when no other accelerator is available.

---
v2 was https://lore.kernel.org/qemu-devel/[email protected]/

---
 system/vl.c | 3 +++
 1 file changed, 3 insertions(+)
system/vl.c +3 -0
index 54998fdbc7e..2f855d83fbb 100644
@@ -2362,6 +2362,7 @@ static void configure_accelerators(const char *progname)
             /* Select the default accelerator */
             bool have_tcg = accel_find("tcg");
             bool have_kvm = accel_find("kvm");
+            bool have_hvf = accel_find("hvf");
 
             if (have_tcg && have_kvm) {
                 if (g_str_has_suffix(progname, "kvm")) {
@@ -2374,6 +2375,8 @@ static void configure_accelerators(const char *progname)
                 accelerators = "kvm";
             } else if (have_tcg) {
                 accelerators = "tcg";
+            } else if (have_hvf) {
+                accelerators = "hvf";
             } else {
                 error_report("No accelerator selected and"
                              " no default accelerator available");
Signature · 1 line
2.45.2
Reviewed-by on v3 1/1
#1 lore raw
Quoted 37 lines · Philippe Mathieu-Daudé

When testing with a HVF-only binary, we get:

3/12 qemu:func-quick+func-aarch64 / func-aarch64-version ERROR 0.29s exit status 1
stderr:
Traceback (most recent call last):
File "tests/functional/test_version.py", line 22, in test_qmp_human_info_version
self.vm.launch()
File "machine/machine.py", line 461, in launch
raise VMLaunchFailure(
qemu.machine.machine.VMLaunchFailure: ConnectError: Failed to establish session: EOFError
Exit code: 1
Command: build/qemu-system-aarch64 -display none -vga none -chardev socket,id=mon,fd=5 -mon chardev=mon,mode=control -machine none -nodefaults
Output: qemu-system-aarch64: No accelerator selected and no default accelerator available

Fix by checking for HVF in configure_accelerators() and using it by default when no other accelerator is available.

---
v2 was https://lore.kernel.org/qemu-devel/[email protected]/

---
 system/vl.c | 3 +++
 1 file changed, 3 insertions(+)
system/vl.c +1 -0
index 54998fdbc7e..2f855d83fbb 100644
@@ -2362,6 +2362,7 @@ static void configure_accelerators(const char *progname)
             /* Select the default accelerator */
             bool have_tcg = accel_find("tcg");
             bool have_kvm = accel_find("kvm");
+            bool have_hvf = accel_find("hvf");
 
             if (have_tcg && have_kvm) {
                 if (g_str_has_suffix(progname, "kvm")) {

system/vl.c static void configure_accelerators(const char *progname) · line 2382

Quoted 8 lines
system/vl.c +2 -0
@@ -2374,6 +2375,8 @@ static void configure_accelerators(const char *progname)
                 accelerators = "kvm";
             } else if (have_tcg) {
                 accelerators = "tcg";
+            } else if (have_hvf) {
+                accelerators = "hvf";
             } else {
                 error_report("No accelerator selected and"
                              " no default accelerator available");

This is a no-brainer first step IMHO, given it passes all functional tests.

I think we should subsequently consider whether to even rank HVF above TCG, on the basis that HW acceleration is faster and should provide a host<->guest security boundary that we don't claim for TCG

With regards,
Daniel

Signature · 3 lines
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
Reviewed-by on v3 1/1
#2 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 37 lines · Philippe Mathieu-Daudé

When testing with a HVF-only binary, we get:

3/12 qemu:func-quick+func-aarch64 / func-aarch64-version ERROR 0.29s exit status 1
stderr:
Traceback (most recent call last):
File "tests/functional/test_version.py", line 22, in test_qmp_human_info_version
self.vm.launch()
File "machine/machine.py", line 461, in launch
raise VMLaunchFailure(
qemu.machine.machine.VMLaunchFailure: ConnectError: Failed to establish session: EOFError
Exit code: 1
Command: build/qemu-system-aarch64 -display none -vga none -chardev socket,id=mon,fd=5 -mon chardev=mon,mode=control -machine none -nodefaults
Output: qemu-system-aarch64: No accelerator selected and no default accelerator available

Fix by checking for HVF in configure_accelerators() and using it by default when no other accelerator is available.

---
v2 was https://lore.kernel.org/qemu-devel/[email protected]/

---
  system/vl.c | 3 +++
  1 file changed, 3 insertions(+)
system/vl.c +1 -0
index 54998fdbc7e..2f855d83fbb 100644
@@ -2362,6 +2362,7 @@ static void configure_accelerators(const char *progname)
              /* Select the default accelerator */
              bool have_tcg = accel_find("tcg");
              bool have_kvm = accel_find("kvm");
+            bool have_hvf = accel_find("hvf");
 
              if (have_tcg && have_kvm) {
                  if (g_str_has_suffix(progname, "kvm")) {

system/vl.c static void configure_accelerators(const char *progname) · line 2382

Quoted 8 lines
system/vl.c +2 -0
@@ -2374,6 +2375,8 @@ static void configure_accelerators(const char *progname)
                  accelerators = "kvm";
              } else if (have_tcg) {
                  accelerators = "tcg";
+            } else if (have_hvf) {
+                accelerators = "hvf";
              } else {
                  error_report("No accelerator selected and"
                               " no default accelerator available");
Reviewed-by on v3 1/1
#3 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 14 lines · Philippe Mathieu-Daudé

When testing with a HVF-only binary, we get:

3/12 qemu:func-quick+func-aarch64 / func-aarch64-version ERROR 0.29s exit status 1
stderr:
Traceback (most recent call last):
File "tests/functional/test_version.py", line 22, in test_qmp_human_info_version
self.vm.launch()
File "machine/machine.py", line 461, in launch
raise VMLaunchFailure(
qemu.machine.machine.VMLaunchFailure: ConnectError: Failed to establish session: EOFError
Exit code: 1
Command: build/qemu-system-aarch64 -display none -vga none -chardev socket,id=mon,fd=5 -mon chardev=mon,mode=control -machine none -nodefaults
Output: qemu-system-aarch64: No accelerator selected and no default accelerator available

Quoted 5 lines

Fix by checking for HVF in configure_accelerators() and using it by default when no other accelerator is available.

---

Quoted 18 lines

v2 was https://lore.kernel.org/qemu-devel/[email protected]/

---
  system/vl.c | 3 +++
  1 file changed, 3 insertions(+)
system/vl.c +1 -0
index 54998fdbc7e..2f855d83fbb 100644
@@ -2362,6 +2362,7 @@ static void configure_accelerators(const char *progname)
              /* Select the default accelerator */
              bool have_tcg = accel_find("tcg");
              bool have_kvm = accel_find("kvm");
+            bool have_hvf = accel_find("hvf");
 
              if (have_tcg && have_kvm) {
                  if (g_str_has_suffix(progname, "kvm")) {

system/vl.c static void configure_accelerators(const char *progname) · line 2379

Quoted 5 lines
system/vl.c +2 -0
@@ -2374,6 +2375,8 @@ static void configure_accelerators(const char *progname)
                  accelerators = "kvm";
              } else if (have_tcg) {
                  accelerators = "tcg";
+            } else if (have_hvf) {
+                accelerators = "hvf";

Nit, drop the variable and do if (accel_find("hvf")), so that accel_find is not called unless the tcg test fails.

r~

#4 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 17 lines · Philippe Mathieu-Daudé

When testing with a HVF-only binary, we get:

3/12 qemu:func-quick+func-aarch64 / func-aarch64-version ERROR 0.29s exit status 1
stderr:
Traceback (most recent call last):
File "tests/functional/test_version.py", line 22, in test_qmp_human_info_version
self.vm.launch()
File "machine/machine.py", line 461, in launch
raise VMLaunchFailure(
qemu.machine.machine.VMLaunchFailure: ConnectError: Failed to establish session: EOFError
Exit code: 1
Command: build/qemu-system-aarch64 -display none -vga none -chardev socket,id=mon,fd=5 -mon chardev=mon,mode=control -machine none -nodefaults
Output: qemu-system-aarch64: No accelerator selected and no default accelerator available

Fix by checking for HVF in configure_accelerators() and using it by default when no other accelerator is available.

Quoted 6 lines

---
v2 was https://lore.kernel.org/qemu-devel/[email protected]/

---
  system/vl.c | 3 +++
  1 file changed, 3 insertions(+)

Patch queued.