From nobody Tue Nov 26 00:54:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1588754742; cv=none; d=zohomail.com; s=zohoarc; b=EEo7i9cfLjvUah1eEHvHPSOt/sD3XFwYXwBgoelI+mpZcNHdlzAcgp0O/HlChffdu7cM+DT5aEqcyMLh26KcTM1HlSMGDIIJSbSPGVBqd2MwTTwHYeSM2rHtNXXqcbzLX0s1/YLmgbt5yoWSRtbQHulKM6wtq+i7JsSNiE1+yMo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588754742; 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=GKaxaZhZ7ILYjWIK9LfcS/xgoD1/rPgvdP1qnIvAAdA=; b=lX2XbwFCn5emYmvnGOiHpf1rNGWCTG0eZ1mS/SRz9q2Uia5tIg4SkJXsKdn0pGqjYCrsBKwbU4+4RW05Zdur3P0AF/RRBiH7GhXaCKOnXTw8sKf/Bb/tX6uHELbIbKAfYiJvp56RvTwkXo7pcPXrPeCbfDTh2fNVaJt2O+j7Jig= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 158875474249780.90605369327375; Wed, 6 May 2020 01:45:42 -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-166-QtY4l2mLObGyq15A5h6SZA-1; Wed, 06 May 2020 04:45:38 -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 E4DDC107ACF2; Wed, 6 May 2020 08:45:31 +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 69A3D5C1D4; Wed, 6 May 2020 08:45: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 3891E1809543; Wed, 6 May 2020 08:45:29 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0468jRjV012952 for ; Wed, 6 May 2020 04:45:27 -0400 Received: by smtp.corp.redhat.com (Postfix) id 764525D9DA; Wed, 6 May 2020 08:45:27 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.193.44]) by smtp.corp.redhat.com (Postfix) with ESMTP id E8E2D5D9DD for ; Wed, 6 May 2020 08:45:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588754741; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=GKaxaZhZ7ILYjWIK9LfcS/xgoD1/rPgvdP1qnIvAAdA=; b=LnUMeUXysgSxo9pzM10+BwDiJmK8jeWZ1VD9pgbLL3VWnVsPqv4l9g36mwERQTR0dYQzYe 8B9fZhWs2VoLtHOBnAkdf352wFKlooqwqg5SmwRsbt1/CUe1X/IEc1PinC1mTwnYhGIzBM ptgp9G09w4omVeiBnYsMT5ZHbHyXkdk= X-MC-Unique: QtY4l2mLObGyq15A5h6SZA-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH] qemuDomainCleanupRun: Actually run cleanup callbacks in reverse order Date: Wed, 6 May 2020 10:45:19 +0200 Message-Id: <8afb786b198c7648cb3ad46928374c6f2556c05e.1588754687.git.mprivozn@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" We have a framework to register cleanup callbacks that are run when a domain is shut down. The idea is to run callbacks in reverse order than they were registered. However, looking at the code this is not the case. Fortunately, this framework is used to register a single callback and a single callback only - qemuMigrationDstPrepareCleanup() - therefore there was no problem just yet. Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_domain.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 9c629c31a3..7c71b797bc 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -8032,18 +8032,14 @@ qemuDomainCleanupRun(virQEMUDriverPtr driver, virDomainObjPtr vm) { qemuDomainObjPrivatePtr priv =3D vm->privateData; - size_t i; =20 VIR_DEBUG("driver=3D%p, vm=3D%s", driver, vm->def->name); =20 /* run cleanup callbacks in reverse order */ - for (i =3D 0; i < priv->ncleanupCallbacks; i++) { - if (priv->cleanupCallbacks[priv->ncleanupCallbacks - (i + 1)]) - priv->cleanupCallbacks[i](driver, vm); - } + while (priv->ncleanupCallbacks) + priv->cleanupCallbacks[--priv->ncleanupCallbacks](driver, vm); =20 VIR_FREE(priv->cleanupCallbacks); - priv->ncleanupCallbacks =3D 0; priv->ncleanupCallbacks_max =3D 0; } =20 --=20 2.26.2