[PATCH 1/2] qemu_process: Be nicer to killing QEMU when probing caps

Martin Kletzander mkletzan at redhat.com
Thu Mar 17 16:12:28 UTC 2022


On Wed, Mar 16, 2022 at 04:39:35PM +0100, Michal Privoznik wrote:
>The qemuProcessQMPStop() function is intended to kill this dummy
>QEMU process we started only for querying capabilities.
>Nevertheless, it may be not plain QEMU binary we executed, but
>in fact it may be a memcheck tool (e.g. valgrind) that executes
>QEMU later. By switching to virProcessKillPainfully() we allow
>this wrapper tool to exit gracefully.
>
>Another up side is that virProcessKillPainfully() reports an
>error so no need for us to VIR_ERROR() ourselves.
>
>Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
>---
> src/qemu/qemu_process.c | 6 +-----
> 1 file changed, 1 insertion(+), 5 deletions(-)
>
>diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
>index b19a6218d0..2e149699b0 100644
>--- a/src/qemu/qemu_process.c
>+++ b/src/qemu/qemu_process.c
>@@ -9132,11 +9132,7 @@ qemuProcessQMPStop(qemuProcessQMP *proc)
>
>     if (proc->pid != 0) {
>         VIR_DEBUG("Killing QMP caps process %lld", (long long)proc->pid);
>-        if (virProcessKill(proc->pid, SIGKILL) < 0 && errno != ESRCH)
>-            VIR_ERROR(_("Failed to kill process %lld: %s"),
>-                      (long long)proc->pid,
>-                      g_strerror(errno));
>-
>+        virProcessKillPainfully(proc->pid, true);

Unfortunately this uses virReportError(), so shouldn't we clear the
error since this function is void?  If yes and you add the reset here,
then

Reviewed-by: Martin Kletzander <mkletzan at redhat.com>

>         proc->pid = 0;
>     }
>
>-- 
>2.34.1
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20220317/0cd3ea3f/attachment.sig>


More information about the libvir-list mailing list