From nobody Sat Apr 27 10:43:34 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=huawei.com Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1630311787284722.5433107265201; Mon, 30 Aug 2021 01:23:07 -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-196-UZnET0RDOVKS_boq8nerqg-1; Mon, 30 Aug 2021 04:23:04 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B21F6801B3C; Mon, 30 Aug 2021 08:22:58 +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 A01235D9CA; Mon, 30 Aug 2021 08:22:57 +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 307894A7C8; Mon, 30 Aug 2021 08:22:54 +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 17U8JsOt002508 for ; Mon, 30 Aug 2021 04:19:54 -0400 Received: by smtp.corp.redhat.com (Postfix) id 245CB1006110; Mon, 30 Aug 2021 08:19:54 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast01.extmail.prod.ext.rdu2.redhat.com [10.11.55.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2059D1111A6A for ; Mon, 30 Aug 2021 08:19:47 +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-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8D598866DF1 for ; Mon, 30 Aug 2021 08:19:47 +0000 (UTC) Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-590-Z0yP3sOzMkSykWZP452G6Q-1; Mon, 30 Aug 2021 04:19:45 -0400 Received: from dggemv703-chm.china.huawei.com (unknown [172.30.72.55]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4GyjV04cvkz8Bx8; Mon, 30 Aug 2021 16:02:32 +0800 (CST) Received: from dggema771-chm.china.huawei.com (10.1.198.213) by dggemv703-chm.china.huawei.com (10.3.19.46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2176.2; Mon, 30 Aug 2021 16:02:52 +0800 Received: from localhost (10.174.151.225) by dggema771-chm.china.huawei.com (10.1.198.213) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.8; Mon, 30 Aug 2021 16:02:52 +0800 X-MC-Unique: UZnET0RDOVKS_boq8nerqg-1 X-MC-Unique: Z0yP3sOzMkSykWZP452G6Q-1 From: Wang Xin To: Subject: [PATCH] qemu: fix iothread residual when qemuProcessSetupIOThread failed Date: Mon, 30 Aug 2021 16:02:50 +0800 Message-ID: <20210830080250.1063-1-wangxinxin.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.174.151.225] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggema771-chm.china.huawei.com (10.1.198.213) X-CFilter-Loop: Reflected X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 17U8JsOt002508 X-loop: libvir-list@redhat.com Cc: mprivozn@redhat.com, Wang Xin , hogan.wang@huawei.com, Lei Yang 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.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1630311864679100001 Content-Type: text/plain; charset="utf-8" From: Lei Yang In process of iothread hotplug, qemuDomainHotplugAddIOThread() calls qemuProcessSetupIOThread(). When qemuProcessSetupIOThread() returned a failure, only the cgroup directory 'iothread' was cleaned up within the function. Right after that qemuDomainHotplugAddIOThread() would return failure directly without rolling back the livedef and iothread process that created previously. Further, when 'virsh schedinfo domain --live' requires schedinfo of such machine, the interface will always return a failure print as follows: 'Failed to create v1 controller cpu for group: No such file or directory'. The reason is qemuGetIOThreadsBWLive() using member vm->def->iothreadids[0]->iothread_id to findout the corresponding cgroup dircetory. In case mentioned previously, iothreadids[0] was not been cleaned up while whose cgroup directroy has already been removed. This patch rolls back the livedef and iothread process after qemuProcessSetupIOThread() returned a failure. Of course we are not limited to this function, we also perform the same rolling back after any exception proecss in qemuDomainHotplugAddIOThread(). Signed-off-by: Lei Yang Signed-off-by: Wang Xin diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c old mode 100644 new mode 100755 index f1f961c51c..4f09e82a13 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -5293,6 +5293,7 @@ qemuDomainHotplugAddIOThread(virQEMUDriver *driver, qemuMonitorIOThreadInfo **new_iothreads =3D NULL; virDomainIOThreadIDDef *iothrid; virJSONValue *props =3D NULL; + bool objectHasAdded =3D false; =20 if (!(alias =3D g_strdup_printf("iothread%u", iothread_id))) return -1; @@ -5305,6 +5306,8 @@ qemuDomainHotplugAddIOThread(virQEMUDriver *driver, if (qemuMonitorAddObject(priv->mon, &props, NULL) < 0) goto exit_monitor; =20 + objectHasAdded =3D true; + exp_niothreads++; =20 /* After hotplugging the IOThreads we need to re-detect the @@ -5352,6 +5355,13 @@ qemuDomainHotplugAddIOThread(virQEMUDriver *driver, ret =3D 0; =20 cleanup: + if (ret < 0 && objectHasAdded) { + qemuDomainObjEnterMonitor(driver, vm); + if (qemuMonitorDelObject(priv->mon, alias, true) < 0) + VIR_WARN("del iothread %d of %s failed when cleanup", iothread= _id, vm->def->name); + ignore_value(qemuDomainObjExitMonitor(driver, vm)); + } + if (new_iothreads) { for (idx =3D 0; idx < new_niothreads; idx++) VIR_FREE(new_iothreads[idx]); @@ -5360,6 +5370,8 @@ qemuDomainHotplugAddIOThread(virQEMUDriver *driver, virDomainAuditIOThread(vm, orig_niothreads, new_niothreads, "update", ret =3D=3D 0); virJSONValueFree(props); + if (ret < 0) + virDomainIOThreadIDDel(vm->def, iothread_id); return ret; =20 exit_monitor: --=20 2.26.0.windows.1