From nobody Mon Apr 29 12:53:10 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1594696839; cv=none; d=zohomail.com; s=zohoarc; b=AcGj65tNMtw/aOjB84AruFC7WoJYC9d2i7g8/7fMWbbG75bGbcbgYtapYdJheKMM9RNji1APjJVqHJLZKFIb4et48Ws8QLfQKOF1gGx7ZcHKJ9WKt7MoJM/ro+vS8Fis7WXWIFIyu6XR3mjJPBKF+UM1cJ/u1gqY+/gAW7lkrNw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594696839; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=KSDrsz11s4jeDNVZ9Mx61AUwemj682+dBp32451xDFM=; b=N8sv7zr2KMZCO62+vn7IcK57Q9RryVhnJRdxISxYunHSnvQDGC6EuTuhja+0jAq7AVngzHAltcHcPSRFj9QJjlRT+0Fq7UuyuZAigYo5Kj+UY8FOoVEVVPaw9sae/ys+Z+omfy/HT55Axk3O/P9BzFqY8pAspAwlOJrlbN0AfiI= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1594696839443942.7525148299308; Mon, 13 Jul 2020 20:20:39 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-299-Im_w2Xv5PQuUbnlosdplrA-1; Mon, 13 Jul 2020 23:20:35 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 101E68015F4; Tue, 14 Jul 2020 03:20:29 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6DF9C710A2; Tue, 14 Jul 2020 03:20:27 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id D21701809547; Tue, 14 Jul 2020 03:20:21 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 06E3KKm3013724 for ; Mon, 13 Jul 2020 23:20:20 -0400 Received: by smtp.corp.redhat.com (Postfix) id E3D7D1004058; Tue, 14 Jul 2020 03:20:19 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast03.extmail.prod.ext.rdu2.redhat.com [10.11.55.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D1B911102E0D for ; Tue, 14 Jul 2020 03:20:17 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CF5848007CF for ; Tue, 14 Jul 2020 03:20:17 +0000 (UTC) Received: from huawei.com (szxga07-in.huawei.com [45.249.212.35]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-231-otol-Gm2Oh64XIwmo_cyyg-1; Mon, 13 Jul 2020 23:20:15 -0400 Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id C36D4E0E77DD643A5267 for ; Tue, 14 Jul 2020 11:20:09 +0800 (CST) Received: from [10.174.187.171] (10.174.187.171) by DGGEMS409-HUB.china.huawei.com (10.3.19.209) with Microsoft SMTP Server id 14.3.487.0; Tue, 14 Jul 2020 11:20:00 +0800 X-MC-Unique: Im_w2Xv5PQuUbnlosdplrA-1 X-MC-Unique: otol-Gm2Oh64XIwmo_cyyg-1 To: "libvir-list@redhat.com" , "alex.chen@huawei.com" , "zhengchuan@huawei.com" , "zhang.zhanghailiang@huawei.com" , "xuyandong2@huawei.com" From: Bihong Yu Subject: [PATCH] qemu: use a fixed directory for saving qmp capabilities process Message-ID: Date: Tue, 14 Jul 2020 11:20:00 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 MIME-Version: 1.0 Content-Language: en-US X-Originating-IP: [10.174.187.171] X-CFilter-Loop: Reflected X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable >From c7ee36417b88df7dcfe5e18d1eb72b6d7c175268 Mon Sep 17 00:00:00 2001 From: Bihong Yu Date: Tue, 14 Jul 2020 11:17:46 +0800 Subject: [PATCH] qemu: use a fixed directory for saving qmp capabilities process In some case, the qmp capabilities process possible residues. So we need to cleanup the residual process during start libvirt. For this reason, we should use a fixed directory for saving qmp capabilities process. Change-Id: I6a74a046e192eee169a0e2677ce3aed9ded5e0ed Signed-off-by:Bihong Yu --- src/qemu/qemu_process.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 70fc24b..eba14ed 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -8450,21 +8450,24 @@ static int qemuProcessQMPInit(qemuProcessQMPPtr proc) { g_autofree char *template =3D NULL; + virErrorPtr orig_err; VIR_DEBUG("proc=3D%p, emulator=3D%s", proc, proc->binary); - template =3D g_strdup_printf("%s/qmp-XXXXXX", proc->libDir); + template =3D g_strdup_printf("%s/qmp-capabilities", proc->libDir); - if (!(proc->uniqDir =3D g_mkdtemp(template))) { + if (g_mkdir_with_parents(template, 0700) < 0) { virReportSystemError(errno, _("Failed to create unique directory with " "template '%s' for probing QEMU"), template); return -1; } - /* if g_mkdtemp succeeds, proc->uniqDir is now the owner of - * the string. Set template to NULL to avoid freeing - * the memory in this case */ + /* + * if g_mkdir_with_parents succeeds, assign the template to proc->uniq= Dir. + * Then set template to NULL to avoid freeing the memory in this case. + */ + proc->uniqDir =3D template; template =3D NULL; if (qemuProcessQEMULabelUniqPath(proc) < 0) @@ -8481,6 +8484,10 @@ qemuProcessQMPInit(qemuProcessQMPPtr proc) */ proc->pidfile =3D g_strdup_printf("%s/%s", proc->uniqDir, "qmp.pid"); + virErrorPreserveLast(&orig_err); + if (virPidFileForceCleanupPath(proc->pidfile) < 0) + VIR_WARN("Unable to kill qemu QMP process"); + virErrorRestore(&orig_err); return 0; } --=20 1.8.3.1