From nobody Thu Apr 25 22:46:57 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=1595556705; cv=none; d=zohomail.com; s=zohoarc; b=kHsP2h5Vi2nJSbf6cwZUOw6JZOJRsJMRWQFZQwLw560B9GyBsVPqppeS7xNYIEXQ4YBMtpLKaquWgJtdgd/0QGKU+e60MGFdjrA3yK5a3uX01J/1Sp67cvdRi2FYBXMSD4QdLhpgGyJ/GwY8GVDoDNy/cazajazG8/RDEuuddFE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1595556705; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=9JH2jWLIerd9dwkhWZ9G6iAphEoWIg8GWIVLM1i1TwU=; b=dUNJFOekGY85V7Or6k4wSc3a3RZjFCn0fSExkU8cmYXrlNyro7AEkrysPz2XIePbiPPqbPVXUdXBFYxwBHggvyOYYaknARZexBrfris4WDpi9ukDEHz6tBr/nmamAfB0dIv4HZjKYxLYQvopJh9V93bhwcB3ldzL6n+Qh22SWXA= 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 1595556705288581.1250718684477; Thu, 23 Jul 2020 19:11:45 -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-295-Xt8zynaeOHGvWFMf6o8Llw-1; Thu, 23 Jul 2020 22:11:41 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1FB56100CCC2; Fri, 24 Jul 2020 02:11:35 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2C1CF2C724; Fri, 24 Jul 2020 02:11:31 +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 E6B9E730C0; Fri, 24 Jul 2020 02:11:27 +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 06O2BPLa030058 for ; Thu, 23 Jul 2020 22:11:26 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9CBB5101D582; Fri, 24 Jul 2020 02:11:25 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast02.extmail.prod.ext.rdu2.redhat.com [10.11.55.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 980E91018E5F for ; Fri, 24 Jul 2020 02:11:23 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (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 533888007A4 for ; Fri, 24 Jul 2020 02:11:23 +0000 (UTC) Received: from huawei.com (szxga05-in.huawei.com [45.249.212.191]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-92-Ne4seXD2PguWR_kxtQLhfA-1; Thu, 23 Jul 2020 22:11:20 -0400 Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 77F8657677E3962C8480; Fri, 24 Jul 2020 10:11:15 +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; Fri, 24 Jul 2020 10:11:07 +0800 X-MC-Unique: Xt8zynaeOHGvWFMf6o8Llw-1 X-MC-Unique: Ne4seXD2PguWR_kxtQLhfA-1 Subject: [PATCH] qemu: clear residual QMP caps processes during QEMU driver initialization From: Bihong Yu To: "libvir-list@redhat.com" , "alex.chen@huawei.com" , "zhengchuan@huawei.com" , "zhang.zhanghailiang@huawei.com" , "xuyandong2@huawei.com" , References: Message-ID: Date: Fri, 24 Jul 2020 10:11:07 +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 In-Reply-To: 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.16 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable >From c328ff62b11d58553fd2032a85fd3295e009b3d3 Mon Sep 17 00:00:00 2001 From: Bihong Yu Date: Fri, 17 Jul 2020 16:55:12 +0800 Subject: [PATCH] qemu: clear residual QMP caps processes during QEMU driver initialization In some cases, the QMP capabilities processes possible residue. So we need = to clear the residual QMP caps processes during starting libvirt. Signed-off-by:Bihong Yu --- src/qemu/qemu_driver.c | 2 ++ src/qemu/qemu_process.c | 40 ++++++++++++++++++++++++++++++++++++++++ src/qemu/qemu_process.h | 2 ++ 3 files changed, 44 insertions(+) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index d185666..d627fd7 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -889,6 +889,8 @@ qemuStateInitialize(bool privileged, run_gid =3D cfg->group; } + qemuProcessQMPClear(cfg->libDir); + qemu_driver->qemuCapsCache =3D virQEMUCapsCacheNew(cfg->libDir, cfg->cacheDir, run_uid, diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 70fc24b..d545e3e 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -8312,6 +8312,46 @@ static qemuMonitorCallbacks callbacks =3D { }; +/** + * qemuProcessQMPClear + * + * Try to kill residual QMP caps processes + */ +void +qemuProcessQMPClear(const char *libDir) +{ + virErrorPtr orig_err; + DIR *dirp =3D NULL; + struct dirent *dp; + + if (!virFileExists(libDir)) + return; + + if (virDirOpen(&dirp, libDir) < 0) + return; + + virErrorPreserveLast(&orig_err); + while (virDirRead(dirp, &dp, libDir) > 0) { + g_autofree char *qmp_uniqDir =3D NULL; + g_autofree char *qmp_pidfile =3D NULL; + + if (!STRPREFIX(dp->d_name, "qmp-")) + continue; + + qmp_uniqDir =3D g_strdup_printf("%s/%s", libDir, dp->d_name); + qmp_pidfile =3D g_strdup_printf("%s/%s", qmp_uniqDir, "qmp.pid"); + + ignore_value(virPidFileForceCleanupPath(qmp_pidfile)); + + if (qmp_uniqDir) + rmdir(qmp_uniqDir); + } + virErrorRestore(&orig_err); + + VIR_DIR_CLOSE(dirp); +} + + static void qemuProcessQMPStop(qemuProcessQMPPtr proc) { diff --git a/src/qemu/qemu_process.h b/src/qemu/qemu_process.h index 15e67b9..b039e6c 100644 --- a/src/qemu/qemu_process.h +++ b/src/qemu/qemu_process.h @@ -233,6 +233,8 @@ qemuProcessQMPPtr qemuProcessQMPNew(const char *binary, gid_t runGid, bool forceTCG); +void qemuProcessQMPClear(const char *libDir); + void qemuProcessQMPFree(qemuProcessQMPPtr proc); int qemuProcessQMPStart(qemuProcessQMPPtr proc); --=20 1.8.3.1