Skip to content
  • Daniel P. Berrangé's avatar
    6cbde91a
    tests/qtest: use prctl(PR_SET_PDEATHSIG) as fallback to kill QEMU · 6cbde91a
    Daniel P. Berrangé authored
    
    
    Although we register a ABRT handler to kill off QEMU when g_assert()
    triggers, we want an extra safety net. The QEMU process might be
    non-functional and thus not have responded to SIGTERM. The test script
    might also have crashed with SEGV, in which case the cleanup handlers
    won't ever run.
    
    Using the Linux specific prctl(PR_SET_PDEATHSIG) syscall, we
    can ensure that QEMU gets sent SIGKILL as soon as the controlling
    qtest exits, if nothing else has correctly told it to quit.
    
    Note, technically the death signal is sent when the *thread* that
    called fork() exits. IOW, if you are calling qtest_init() in one
    thread, letting that thread exit, and then expecting to run
    qtest_quit() in a different thread, things are not going to work
    out. Fortunately that is not a scenario that exists in qtests,
    as pairs of qtest_init and qtest_quit are always called from the
    same thread.
    
    Signed-off-by: default avatarDaniel P. Berrangé <berrange@redhat.com>
    Message-Id: <20220513154906.206715-3-berrange@redhat.com>
    Reviewed-by: default avatarThomas Huth <thuth@redhat.com>
    Signed-off-by: default avatarThomas Huth <thuth@redhat.com>
    6cbde91a
    tests/qtest: use prctl(PR_SET_PDEATHSIG) as fallback to kill QEMU
    Daniel P. Berrangé authored
    
    
    Although we register a ABRT handler to kill off QEMU when g_assert()
    triggers, we want an extra safety net. The QEMU process might be
    non-functional and thus not have responded to SIGTERM. The test script
    might also have crashed with SEGV, in which case the cleanup handlers
    won't ever run.
    
    Using the Linux specific prctl(PR_SET_PDEATHSIG) syscall, we
    can ensure that QEMU gets sent SIGKILL as soon as the controlling
    qtest exits, if nothing else has correctly told it to quit.
    
    Note, technically the death signal is sent when the *thread* that
    called fork() exits. IOW, if you are calling qtest_init() in one
    thread, letting that thread exit, and then expecting to run
    qtest_quit() in a different thread, things are not going to work
    out. Fortunately that is not a scenario that exists in qtests,
    as pairs of qtest_init and qtest_quit are always called from the
    same thread.
    
    Signed-off-by: default avatarDaniel P. Berrangé <berrange@redhat.com>
    Message-Id: <20220513154906.206715-3-berrange@redhat.com>
    Reviewed-by: default avatarThomas Huth <thuth@redhat.com>
    Signed-off-by: default avatarThomas Huth <thuth@redhat.com>
Loading