From nobody Mon Apr 29 09:20:24 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.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 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1594984271; cv=none; d=zohomail.com; s=zohoarc; b=Ejo3ccBazwXIyOIYTTvU4m9g539EtlgFs6ybI5NKBcie8eYTFpal3QzWtEyjhOOaXnOva13gqJ2qRYIHnZMhZrrD0nsRO4E5SkFx1KoI+OIvdFhNXSPPaopMXxbyEX1IkBvWJQqw7jM3YbVmxoZjtOuWvnGooFIlt19WE3tnXh4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594984271; 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=9JH2jWLIerd9dwkhWZ9G6iAphEoWIg8GWIVLM1i1TwU=; b=nw+vmwppTLbdvJnduK54DZ9+Mv7zwYI5NjNdVE5OIpR0LIz7xof2X9I1EBWnvn8DplrgcgKsWFZE8sAFEpm1lR7NZAYzjGeNTENKgvCUXaZA9ClhtfYEYJKW4m4ppuU14V3RmOemhodp0uuUzpCjQXPeTl0gbN22xkE8I6cq+sI= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.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 [205.139.110.120]) by mx.zohomail.com with SMTPS id 159498427117610.773525931473046; Fri, 17 Jul 2020 04:11:11 -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-194-n_XfrLlDOeCwLpOWrHj3zQ-1; Fri, 17 Jul 2020 07:11:07 -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 B432518C63C1; Fri, 17 Jul 2020 11:11:00 +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 615A25C57D; Fri, 17 Jul 2020 11:10:59 +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 F1A071809554; Fri, 17 Jul 2020 11:10:57 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 06HBAtq8013851 for ; Fri, 17 Jul 2020 07:10:56 -0400 Received: by smtp.corp.redhat.com (Postfix) id C2C162156A4A; Fri, 17 Jul 2020 11:10:55 +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 AF3772156A3B for ; Fri, 17 Jul 2020 11:10:53 +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 83BC080CC4C for ; Fri, 17 Jul 2020 11:10:53 +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-306-cO3aAaSlM_SABV1HrKYgcw-1; Fri, 17 Jul 2020 07:10:50 -0400 Received: from DGGEMS406-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 316756DECE4AB25CA799; Fri, 17 Jul 2020 19:10:45 +0800 (CST) Received: from [10.174.187.171] (10.174.187.171) by DGGEMS406-HUB.china.huawei.com (10.3.19.206) with Microsoft SMTP Server id 14.3.487.0; Fri, 17 Jul 2020 19:10:38 +0800 X-MC-Unique: n_XfrLlDOeCwLpOWrHj3zQ-1 X-MC-Unique: cO3aAaSlM_SABV1HrKYgcw-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: clear residual QMP caps processes during QEMU driver initialization Message-ID: Date: Fri, 17 Jul 2020 19:10:38 +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.6 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