From nobody Mon Feb 9 01:06:25 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 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=1658227578; cv=none; d=zohomail.com; s=zohoarc; b=g3YoGN4TRrMk0i3ZDqty4k+Ao/zBZLHBiBGEcPHN3WSIkss8RK+jbmSBV1G+nXqMYRSI3m0xVbwA/+f5EE1nH/JDomIFqUIV3N15Ue22Xf5wEpbQPVX9RJoWCXNV9y+yvN6O8+uHsygFPeAca4aB9qyGrXiACHKls7kKfNr7sYc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1658227578; 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=p+QwlTkrzPqoXHi/NbsaH6HjgG+3imImKrR5vB0i0DY=; b=Jdi556QcgORuNGEbSTmgYkUmyKTUDBUoZ4lRk9KxUYgbpC4QhvMkVnookyMVAN/fHBZ5MwRMZH13FjjJocknYfa7Nvn7LS+/YHWPeSlfMpWHxFqJ3zY02y7JYg+u7RcZoc6QNnJP0yH0iiujWP7LFEyJLTBmsNzED4xbZ3BzJp0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1658227578967661.7567189515014; Tue, 19 Jul 2022 03:46:18 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-638-HRaxSY1hP96bQ3RNuHMVjA-1; Tue, 19 Jul 2022 06:45:53 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 878DC801585; Tue, 19 Jul 2022 10:45:51 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 710C62026D07; Tue, 19 Jul 2022 10:45:51 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 51F2A1947074; Tue, 19 Jul 2022 10:45:51 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 3B3B3194B94A for ; Tue, 19 Jul 2022 10:45:44 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 2DD20492CA5; Tue, 19 Jul 2022 10:45:44 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.32]) by smtp.corp.redhat.com (Postfix) with ESMTP id 957B9492CA4 for ; Tue, 19 Jul 2022 10:45:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1658227578; 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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=p+QwlTkrzPqoXHi/NbsaH6HjgG+3imImKrR5vB0i0DY=; b=Ute31VuHdqjCcgve21app1pwbcHeWNOiW5M6uRVlzPoDk0yPMfKQ5hxFJHZlMwCknHfGtg J6N0Z2nKhv1T91fu1/mM8KX/+txgbKA/x0XvRheNcW9oqozXXLRM6nWBTd74WZC7D+p4iJ hmZuqzMV6g0t5mfhUOq7yz7r0RhYfCM= X-MC-Unique: HRaxSY1hP96bQ3RNuHMVjA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 6/7] virLXCProcessReboot: Remove the need to re-register autodestroy callback Date: Tue, 19 Jul 2022 12:45:28 +0200 Message-Id: <343e9af05e99c0eb1645b67d1360ba4135f096dd.1658227484.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 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-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1658227579831100001 Content-Type: text/plain; charset="utf-8" Add a new flag VIR_LXC_PROCESS_CLEANUP_AUTODESTROY to virLXCProcessCleanupFlags for skipping removal of the autodestroy callback so that fake reboot of the container doesn't need to fetch the connection and re-register it. Since virLXCProcessReboot is defined before virLXCProcessCleanupFlags, this patch also moves the flag enum typedef to the beginning of the file. Signed-off-by: Peter Krempa --- src/lxc/lxc_process.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/lxc/lxc_process.c b/src/lxc/lxc_process.c index 753e9e0b9a..f9854ac138 100644 --- a/src/lxc/lxc_process.c +++ b/src/lxc/lxc_process.c @@ -56,6 +56,13 @@ VIR_LOG_INIT("lxc.lxc_process"); #define START_POSTFIX ": starting up\n" +typedef enum { + VIR_LXC_PROCESS_CLEANUP_RELEASE_SECLABEL =3D (1 << 0), + VIR_LXC_PROCESS_CLEANUP_RESTORE_SECLABEL =3D (1 << 1), + VIR_LXC_PROCESS_CLEANUP_REMOVE_TRANSIENT =3D (1 << 2), + VIR_LXC_PROCESS_CLEANUP_AUTODESTROY =3D (1 << 3), +} virLXCProcessCleanupFlags; + static void lxcProcessAutoDestroy(virDomainObj *dom, virConnectPtr conn) @@ -87,23 +94,21 @@ static int virLXCProcessReboot(virLXCDriver *driver, virDomainObj *vm) { - g_autoptr(virConnect) autoDestroyConn =3D virCloseCallbacksGetConn(dri= ver->closeCallbacks, vm); + /* we want to keep the autodestroy callback registered */ + unsigned int stopFlags =3D ~(VIR_LXC_PROCESS_CLEANUP_AUTODESTROY); int reason =3D vm->state.reason; virDomainDef *savedDef; VIR_DEBUG("Faking reboot"); - if (autoDestroyConn) - virObjectRef(autoDestroyConn); - /* In a reboot scenario, we need to make sure we continue * to use the current 'def', and not switch to 'newDef'. * So temporarily hide the newDef and then reinstate it */ savedDef =3D g_steal_pointer(&vm->newDef); - virLXCProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_SHUTDOWN, 0); + virLXCProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_SHUTDOWN, stopFlags); vm->newDef =3D savedDef; - if (virLXCProcessStart(driver, vm, 0, NULL, autoDestroyConn, reason) <= 0) { + if (virLXCProcessStart(driver, vm, 0, NULL, NULL, reason) < 0) { VIR_WARN("Unable to handle reboot of vm %s", vm->def->name); return -1; } @@ -126,12 +131,6 @@ lxcProcessRemoveDomainStatus(virLXCDriverConfig *cfg, } -typedef enum { - VIR_LXC_PROCESS_CLEANUP_RELEASE_SECLABEL =3D (1 << 0), - VIR_LXC_PROCESS_CLEANUP_RESTORE_SECLABEL =3D (1 << 1), - VIR_LXC_PROCESS_CLEANUP_REMOVE_TRANSIENT =3D (1 << 2), -} virLXCProcessCleanupFlags; - /** * virLXCProcessCleanup: * @driver: pointer to driver structure @@ -188,8 +187,9 @@ static void virLXCProcessCleanup(virLXCDriver *driver, } /* Stop autodestroy in case guest is restarted */ - virCloseCallbacksUnset(driver->closeCallbacks, vm, - lxcProcessAutoDestroy); + if (flags & VIR_LXC_PROCESS_CLEANUP_AUTODESTROY) { + virCloseCallbacksUnset(driver->closeCallbacks, vm, lxcProcessAutoD= estroy); + } if (priv->monitor) { virLXCMonitorClose(priv->monitor); --=20 2.36.1