qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] fuzz: check machine, before PC-specific code
@ 2021-03-14 23:10 Alexander Bulekov
  2021-03-14 23:13 ` Alexander Bulekov
  2021-03-14 23:15 ` no-reply
  0 siblings, 2 replies; 5+ messages in thread
From: Alexander Bulekov @ 2021-03-14 23:10 UTC (permalink / raw)
  To: qemu-devel
  Cc: Laurent Vivier, Thomas Huth, Alexander Bulekov, f4bug,
	darren.kenny, Bandan Das, Stefan Hajnoczi, Paolo Bonzini,
	Philippe Mathieu-Daudé

We enumerate PCI devices on PC machines, but this breaks the fuzzer for
non-PC machines and architectures. Add checks to avoid this.

Reported-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Alexander Bulekov <alxndr@bu.edu>
---
 tests/qtest/fuzz/generic_fuzz.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/tests/qtest/fuzz/generic_fuzz.c b/tests/qtest/fuzz/generic_fuzz.c
index ee8c17a04c..d2b74028fe 100644
--- a/tests/qtest/fuzz/generic_fuzz.c
+++ b/tests/qtest/fuzz/generic_fuzz.c
@@ -784,6 +784,7 @@ static void generic_pre_fuzz(QTestState *s)
     MemoryRegion *mr;
     QPCIBus *pcibus;
     char **result;
+    const char* machine_type;
 
     if (!getenv("QEMU_FUZZ_OBJECTS")) {
         usage();
@@ -827,9 +828,13 @@ static void generic_pre_fuzz(QTestState *s)
         exit(1);
     }
 
-    pcibus = qpci_new_pc(s, NULL);
-    g_ptr_array_foreach(fuzzable_pci_devices, pci_enum, pcibus);
-    qpci_free_pc(pcibus);
+    machine_type = object_get_typename(qdev_get_machine());
+    if(fuzzable_pci_devices->len && strstr(machine_type, "pc") == machine_type)
+    {
+        pcibus = qpci_new_pc(s, NULL);
+        g_ptr_array_foreach(fuzzable_pci_devices, pci_enum, pcibus);
+        qpci_free_pc(pcibus);
+    }
 
     counter_shm_init();
 }
-- 
2.27.0



^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-03-15  1:54 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-14 23:10 [PATCH] fuzz: check machine, before PC-specific code Alexander Bulekov
2021-03-14 23:13 ` Alexander Bulekov
2021-03-14 23:31   ` Philippe Mathieu-Daudé
2021-03-15  1:53     ` Alexander Bulekov
2021-03-14 23:15 ` no-reply

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).