From nobody Tue May 7 14:36:44 2024 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; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmx.de 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 163839503992618.465213753934222; Wed, 1 Dec 2021 13:43:59 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-447-N-j8dEssOoO5lv7lBKzjSg-1; Wed, 01 Dec 2021 16:43:55 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1AD1783DBE3; Wed, 1 Dec 2021 21:43:50 +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 A3AC01346F; Wed, 1 Dec 2021 21:43:47 +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 DA0C64BB7C; Wed, 1 Dec 2021 21:43:43 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1B1LhfAc009224 for ; Wed, 1 Dec 2021 16:43:41 -0500 Received: by smtp.corp.redhat.com (Postfix) id 41999492C3B; Wed, 1 Dec 2021 21:43:41 +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 3DB95492C38 for ; Wed, 1 Dec 2021 21:43:41 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) (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 230BB85A5BA for ; Wed, 1 Dec 2021 21:43:41 +0000 (UTC) Received: from mout.gmx.net (mout.gmx.net [212.227.15.19]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-602-OnpxZgzZP2m0juDkB-1fWQ-1; Wed, 01 Dec 2021 16:43:39 -0500 Received: from [192.168.194.68] ([91.55.243.185]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MfpOd-1mPX8s2cnp-00gHiI; Wed, 01 Dec 2021 22:38:35 +0100 X-MC-Unique: N-j8dEssOoO5lv7lBKzjSg-1 X-MC-Unique: OnpxZgzZP2m0juDkB-1fWQ-1 X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c From: Joachim Falk Subject: [PATCH] Fix reboot command for LXC containers To: libvir-list@redhat.com Message-ID: Date: Wed, 1 Dec 2021 22:38:04 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 MIME-Version: 1.0 X-Provags-ID: V03:K1:p4ZE2PVZt2B56lvefDKclR2N/X6rp5OPwpD4G4D8Zps0/OS46PG NzajUN27070+eh6Q2sI6H0KFcNYSD6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O0TXn9YFApsKEYlNdpu2njyArEtH6ckOEVv+ tOYbBavo6BqM+mKcgg5QK1bNYjGf1mYy/RP5PPKTKhfbGY4ti7oau0MhuIrlGS60nyYW1E+mW Hs0Z39xhToINXMODfpXwbyNxnWqLtX8XIIn7xi+ZW7GacprxO4IGrhTuIlmUE75shvCEjYqgA 8Qzl68PuJkgporZIN8ZzY17T4MePuVLBf49YBa3v7tk6X6bWKEWA+hwDGdyOXh+41pagHawDr u0B1bAJfLRO2gs= 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.85 on 10.11.54.9 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 1B1LhfAc009224 X-loop: libvir-list@redhat.com Cc: Joachim Falk 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.11 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-Language: en-US Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1638395041777100001 Content-Type: text/plain; charset="utf-8" The virNetDaemonQuit(dmn) command in virLXCControllerSignalChildIO triggers= an early close of all clients of lxc_controller. Here, libvirtd itself is a cl= ient of this controller, and the client connection is used to notify libvirtd if= a reboot of the container is required. However, the client connection was clo= sed before such a status could be sent to libvirtd. To fix this bug, we will immediately send the reboot or shutdown status of the container to libvirtd, and only after client disconnect will we trigger virNetDaemonQuit. Fixes: #237 Bug: https://gitlab.com/libvirt/libvirt/-/issues/237 Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=3D991773 Signed-off-by: Joachim Falk --- src/lxc/lxc_controller.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c index 444f728af4..75107822ba 100644 --- a/src/lxc/lxc_controller.c +++ b/src/lxc/lxc_controller.c @@ -894,8 +894,10 @@ static void virLXCControllerClientCloseHook(virNetServ= erClient *client) virLXCController *ctrl =3D virNetServerClientGetPrivateData(client); VIR_DEBUG("Client %p has closed", client); - if (ctrl->client =3D=3D client) + if (ctrl->client =3D=3D client) { ctrl->client =3D NULL; + VIR_DEBUG("Client has gone away"); + } if (ctrl->inShutdown) { VIR_DEBUG("Arm timer to quit event loop"); virEventUpdateTimeout(ctrl->timerShutdown, 0); @@ -1006,6 +1008,9 @@ static int lxcControllerClearCapabilities(void) static bool wantReboot; static virMutex lock =3D VIR_MUTEX_INITIALIZER; +static int +virLXCControllerEventSendExit(virLXCController *ctrl, + int exitstatus); static void virLXCControllerSignalChildIO(virNetDaemon *dmn, siginfo_t *info G_GNUC_UNUSED, @@ -1015,10 +1020,10 @@ static void virLXCControllerSignalChildIO(virNetDae= mon *dmn, int ret; int status; + ignore_value(dmn); ret =3D waitpid(-1, &status, WNOHANG); VIR_DEBUG("Got sig child %d vs %lld", ret, (long long)ctrl->initpid); if (ret =3D=3D ctrl->initpid) { - virNetDaemonQuit(dmn); virMutexLock(&lock); if (WIFSIGNALED(status) && WTERMSIG(status) =3D=3D SIGHUP) { @@ -1026,6 +1031,7 @@ static void virLXCControllerSignalChildIO(virNetDaemo= n *dmn, wantReboot =3D true; } virMutexUnlock(&lock); + virLXCControllerEventSendExit(ctrl, wantReboot ? 1 : 0); } } @@ -2276,9 +2282,10 @@ virLXCControllerEventSendExit(virLXCController *ctr= l, VIR_DEBUG("Waiting for client to complete dispatch"); ctrl->inShutdown =3D true; virNetServerClientDelayedClose(ctrl->client); - virNetDaemonRun(ctrl->daemon); + } else { + VIR_DEBUG("Arm timer to quit event loop"); + virEventUpdateTimeout(ctrl->timerShutdown, 0); } - VIR_DEBUG("Client has gone away"); return 0; } @@ -2430,8 +2437,6 @@ virLXCControllerRun(virLXCController *ctrl) rc =3D virLXCControllerMain(ctrl); - virLXCControllerEventSendExit(ctrl, rc); - cleanup: VIR_FORCE_CLOSE(control[0]); VIR_FORCE_CLOSE(control[1]); -- 2.30.2