diff mbox series

[v8,12/21] exec: keep ram block across fork when using qtest

Message ID 20200129053357.27454-13-alxndr@bu.edu (mailing list archive)
State New, archived
Headers show
Series Add virtual device fuzzing support | expand

Commit Message

Alexander Bulekov Jan. 29, 2020, 5:34 a.m. UTC
Ram blocks were marked MADV_DONTFORK breaking fuzzing-tests which
execute each test-input in a forked process.

Signed-off-by: Alexander Bulekov <alxndr@bu.edu>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 exec.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

Comments

Darren Kenny Feb. 5, 2020, 1 p.m. UTC | #1
On Wed, Jan 29, 2020 at 05:34:21AM +0000, Bulekov, Alexander wrote:
>Ram blocks were marked MADV_DONTFORK breaking fuzzing-tests which
>execute each test-input in a forked process.
>
>Signed-off-by: Alexander Bulekov <alxndr@bu.edu>
>Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>

Reviewed-by: Darren Kenny <darren.kenny@oracle.com>

>---
> exec.c | 12 ++++++++++--
> 1 file changed, 10 insertions(+), 2 deletions(-)
>
>diff --git a/exec.c b/exec.c
>index d4b769d0d4..99368f175b 100644
>--- a/exec.c
>+++ b/exec.c
>@@ -35,6 +35,7 @@
> #include "sysemu/kvm.h"
> #include "sysemu/sysemu.h"
> #include "sysemu/tcg.h"
>+#include "sysemu/qtest.h"
> #include "qemu/timer.h"
> #include "qemu/config-file.h"
> #include "qemu/error-report.h"
>@@ -2306,8 +2307,15 @@ static void ram_block_add(RAMBlock *new_block, Error **errp, bool shared)
>     if (new_block->host) {
>         qemu_ram_setup_dump(new_block->host, new_block->max_length);
>         qemu_madvise(new_block->host, new_block->max_length, QEMU_MADV_HUGEPAGE);
>-        /* MADV_DONTFORK is also needed by KVM in absence of synchronous MMU */
>-        qemu_madvise(new_block->host, new_block->max_length, QEMU_MADV_DONTFORK);
>+        /*
>+         * MADV_DONTFORK is also needed by KVM in absence of synchronous MMU
>+         * Configure it unless the machine is a qtest server, in which case
>+         * KVM is not used and it may be forked (eg for fuzzing purposes).
>+         */
>+        if (!qtest_enabled()) {
>+            qemu_madvise(new_block->host, new_block->max_length,
>+                         QEMU_MADV_DONTFORK);
>+        }
>         ram_block_notify_add(new_block->host, new_block->max_length);
>     }
> }
>-- 
>2.23.0
>
>
diff mbox series

Patch

diff --git a/exec.c b/exec.c
index d4b769d0d4..99368f175b 100644
--- a/exec.c
+++ b/exec.c
@@ -35,6 +35,7 @@ 
 #include "sysemu/kvm.h"
 #include "sysemu/sysemu.h"
 #include "sysemu/tcg.h"
+#include "sysemu/qtest.h"
 #include "qemu/timer.h"
 #include "qemu/config-file.h"
 #include "qemu/error-report.h"
@@ -2306,8 +2307,15 @@  static void ram_block_add(RAMBlock *new_block, Error **errp, bool shared)
     if (new_block->host) {
         qemu_ram_setup_dump(new_block->host, new_block->max_length);
         qemu_madvise(new_block->host, new_block->max_length, QEMU_MADV_HUGEPAGE);
-        /* MADV_DONTFORK is also needed by KVM in absence of synchronous MMU */
-        qemu_madvise(new_block->host, new_block->max_length, QEMU_MADV_DONTFORK);
+        /*
+         * MADV_DONTFORK is also needed by KVM in absence of synchronous MMU
+         * Configure it unless the machine is a qtest server, in which case
+         * KVM is not used and it may be forked (eg for fuzzing purposes).
+         */
+        if (!qtest_enabled()) {
+            qemu_madvise(new_block->host, new_block->max_length,
+                         QEMU_MADV_DONTFORK);
+        }
         ram_block_notify_add(new_block->host, new_block->max_length);
     }
 }