From patchwork Tue Oct 17 14:06:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1850252 X-Patchwork-Delegate: sbabic@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20230601 header.b=xB/oWK0c; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::13d; helo=mail-lf1-x13d.google.com; envelope-from=swupdate+bncbaabbb5kxkuqmgqettsszlq@googlegroups.com; receiver=patchwork.ozlabs.org) Received: from mail-lf1-x13d.google.com (mail-lf1-x13d.google.com [IPv6:2a00:1450:4864:20::13d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4S8wld1qsWz23k9 for ; Wed, 18 Oct 2023 01:07:08 +1100 (AEDT) Received: by mail-lf1-x13d.google.com with SMTP id 2adb3069b0e04-50318e9067esf5402746e87.0 for ; Tue, 17 Oct 2023 07:07:08 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1697551624; cv=pass; d=google.com; s=arc-20160816; b=TtZWz4NseMTpkqRROJwKNKftiTu2aj8AZ5dOe1qemVSi/T2Obv4LEAALPkPTJ7E1Fa T1cxGwx0Gm15zt7nACFQ4gG9dbn5EtugPoD6JlgfSxVLEVN+N2dBTQ1FAwuxugG3YpBV SAMmGuXCbAWBOD3Ht7EZHH8qDH62cJJKBhK2iq1Gv2g9oMys962zyAYa8O4BEfnYy4A5 0jQZAqsXwbwdECadDi8NCyYU1Kp2pTt9pqLxXNaC/nbf+thADEtkE/y55gy2C063RMhb aGO+lynP/Ljq8Uu6fBIWbQVLoeqnCveGbpF9MJEDkAJ49nT07YzUbQGuyLH0YaANTf9B R+0Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:ui-outboundreport:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from:sender :dkim-signature; bh=Kfc00G6A+mf7+P56qIUhnadLloBqLliHwCtqClXfRSk=; fh=TiEWcqMcKpHk5s7uErzpntoONrNfOXwKpI5P8bIlggk=; b=JzXup/QcblBqRIxN38ANS2ZEptzsGwSVB1SFWN1lNq8pwPicBzVMaYeRJZWIYin1ye hDluHBS5jU2Z2UblQfbp0FkiIx6Ae+/k5l+Zc9PpX7zM2i+eRIVgBNCbxK2MiL8GOR/g rN6IKg4vbIYEnq0ZjfMUaez28C0ELhgY+6VxjXdXfdTEtBNOJbC727geivo2EvFBWm/Q Smc3uK4dIQmERr+i3kSNoONByF98Z/DIw/f9BsbtjVMr41jQ0fq+ZMYF9awW0WVX6Zh7 IBP4ApyBY/HfM5sujNugd+SPX1I3Ub4VyHAQDt4hx/GL9Ju4sUAAm99QLDwT5qec24gT zU/g== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.17.10 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20230601; t=1697551624; x=1698156424; darn=patchwork.ozlabs.org; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:x-original-authentication-results :x-original-sender:ui-outboundreport:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:sender:from:to:cc :subject:date:message-id:reply-to; bh=Kfc00G6A+mf7+P56qIUhnadLloBqLliHwCtqClXfRSk=; b=xB/oWK0cJorVwa+iLnl7rQ2gTMF9RpyfIpD1w9YXhDeGpXI/Fgfe2fYj9BTO9v5wD1 /q8X9NQ+FOu4jlCn49nUTIqYFfcGugpYJVYDMEu6115Nw9IAFpQbrnoQ5Th11GMdYpE8 Vv2h05jCRWB9/aewuAqyEkuyLz04y027SCjYgsXjm19IzkimQP4OX8BAKHSIc9smNaAF 4D4PwO9BaMLXw9aJYzzTcVFEknCoGCcv9Xs6VEJSlYrxMykG3OKnF/DQQAZ12MnCPgvm 9oDYcfpBYrYgFNKyI2VrMyRjHi7MEcKcfkm8ZkBZx5vkF7biIHQN6F3F8Oc3FihJ1cMr dRng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697551624; x=1698156424; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence :x-original-authentication-results:x-original-sender :ui-outboundreport:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:x-beenthere:x-gm-message-state:sender:from :to:cc:subject:date:message-id:reply-to; bh=Kfc00G6A+mf7+P56qIUhnadLloBqLliHwCtqClXfRSk=; b=KPktReASR/OQo9eUa4O91rT5Y+dnbi1npq6bxDOP2zSxD/sPYV+zryuU7pkMTEp2Ah qDom5vtA4njG2oLkZHLpE7EYxzWtYq3J/nHuwKYJwUYZoGBlgvzJkudK+HbYuAi+aJTQ vyUK+bbOYMiljZwAywaScVbEI3bPkt00OjJonCAknkqAxYQNRBl75mzbaer1cul1nuH5 T0GWlPwzLrRMMDwys5G8RmcDrxvq0POVaAmPbz7vo/6Vjkch2t5KSpKc4rwO/8ckhTG8 JBM5/4NmYqU38GQXhD5rA6BUTjS/k2eEZpRvLTomBrbNxQwUDqSY4H+OqUZfpjI8gP5J Qv2w== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOJu0Yx+Zc3XUqIFzIOfKyQrrqCXVHhwssWpS2T5V/Ade3E4gSHMfV8/ lL1KR4PXPTIqXtsRVfTMTM0= X-Google-Smtp-Source: AGHT+IGExJkRKyy2FV61Jj13aY2QzaDFr7bkkBBTGT81gdOBuinNSxfL9RJOxSZtNwo03ekSJBB/eQ== X-Received: by 2002:ac2:48ab:0:b0:507:a908:4a93 with SMTP id u11-20020ac248ab000000b00507a9084a93mr1813099lfg.61.1697551623786; Tue, 17 Oct 2023 07:07:03 -0700 (PDT) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a05:6512:3d0c:b0:507:999e:6d6a with SMTP id d12-20020a0565123d0c00b00507999e6d6als274065lfv.2.-pod-prod-06-eu; Tue, 17 Oct 2023 07:07:01 -0700 (PDT) X-Received: by 2002:a05:651c:2cf:b0:2c2:9e5c:2c82 with SMTP id f15-20020a05651c02cf00b002c29e5c2c82mr1638127ljo.46.1697551621860; Tue, 17 Oct 2023 07:07:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697551621; cv=none; d=google.com; s=arc-20160816; b=PxFGemK3dcOqrSUID/K8s5tlRyLSUlipXTTG9LNQOGh8a+R6jNBsV35Sq9dy2gcdhO e4t02HA4vuUoAFcrg1OfkRDP0zX/4eXejR+A3M+Ezx6C18voGYXotPa6QiL2v9O7RgGF +nPgnagbwt5SqqIiQrvcI3E+UHN0VIV2UzTk7kAo+TPg71bsZLOtHSaOvDGmhhIbxJdh U6X8rkVe0RDUOUUXcVrp/8vwZlu6nrPLtJw7VVKO6Pf3ciBPxXk0tLz80QVZxwlitUjk hdDUjS8FyxGfVVDpcBnM91euw1TKAI19IFKy2W6mQJE9gNJPrPQwEM7MXhG4eD7JEwAO o1/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=ui-outboundreport:content-transfer-encoding:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from; bh=EipCcx2MMEQLUULCtH/gmz6fG7i+zyUrvHhNbEY3FKc=; fh=TiEWcqMcKpHk5s7uErzpntoONrNfOXwKpI5P8bIlggk=; b=an8Nw4pV1JImKQDT1oFbJyCbSbZeUfKbbGNZWkclHq2MFT9JYM6otRTODPIEdxh2dN /DrZjjOBdjw88NPGhzxWUblGPHyiu2sJMOKaziyhHGyTR8cH2ic/v+C9NSX0Gpoezzzt SOfxvKr8r9FdPTNQXPORfQQd5E0iC5OKv/dy9RhcpQ/bJnmSptUqj6GQUC4wn+C6bgK4 pFEh+TMWmQ954pgsFGn39prEqMEiaze/jkAOYdjjxd96GLB+sy4sKFEFma34HKUREd78 CsdgG20+XRU/FG2oZJqaAPQGrXinKXrM+wZ3DjcBsEWjKbR+vGAeVsYR5VPO8ecvvUzj 3Yxw== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.17.10 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org Received: from mout.kundenserver.de (mout.kundenserver.de. [212.227.17.10]) by gmr-mx.google.com with ESMTPS id h19-20020a2e9013000000b002c29b97d5f2si62164ljg.1.2023.10.17.07.07.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Oct 2023 07:07:01 -0700 (PDT) Received-SPF: pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.17.10 as permitted sender) client-ip=212.227.17.10; Received: from paperino.fritz.box ([88.217.136.221]) by mrelayeu.kundenserver.de (mreue108 [213.165.67.113]) with ESMTPSA (Nemesis) id 1MxUjv-1rlwkO0KQz-00xwH0; Tue, 17 Oct 2023 16:07:01 +0200 From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH V2 09/11] Send information to backend in case of on the fly updates Date: Tue, 17 Oct 2023 16:06:55 +0200 Message-Id: <20231017140657.95860-10-stefano.babic@swupdate.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231017140657.95860-1-stefano.babic@swupdate.org> References: <20231017140657.95860-1-stefano.babic@swupdate.org> MIME-Version: 1.0 X-Provags-ID: V03:K1:wVY46siuVJIIolRLGGCzKHzoVQpcC/DcBLpqRg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E/m0ZMwMQ7S7ww1I81AhoeXHOZ4e7m5nsMfsxSY k8DbDXUIXmAgWhg== X-Original-Sender: stefano.babic@swupdate.org X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.17.10 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org Precedence: list Mailing-list: list swupdate@googlegroups.com; contact swupdate+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: swupdate@googlegroups.com X-Google-Group-Id: 605343134186 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , Not all updates require a reboot. In many cases, some parts of the system are updated and a reboot is not necessary (on the fly update). However, communication with the backend stops because software was already installed successfully and to close the transaction, SWUpdate had to be restarted. To better support on on-the-fly updates, a new attribute "no-reboot" is added. This is just to inform all processes registered with the progress interface that a reboot at the end of the update is not necessary. SWUpdate registers this attribute, and sends via IPC a message to the suricatta module (currently, only Hawkbit is supported) to inform that the update was successfully executed and the transaction can be closed. After that, the suricatta module exits from the wait process and it is able to receive further updates, too. Signed-off-by: Stefano Babic --- core/stream_interface.c | 41 +++++++++++++++++++++++++++++++++++++++++ include/swupdate.h | 1 + parser/parser.c | 13 +++++++++++++ 3 files changed, 55 insertions(+) diff --git a/core/stream_interface.c b/core/stream_interface.c index d9afa4af..0b783291 100644 --- a/core/stream_interface.c +++ b/core/stream_interface.c @@ -660,6 +660,15 @@ void *network_initializer(void *data) update_transaction_state(software, STATE_IN_PROGRESS); notify(RUN, RECOVERY_NO_ERROR, INFOLEVEL, "Installation in progress"); + + /* + * if this update is signalled to be without reboot (On the Fly), + * send a notification via progress for processes responsible for booting + */ + if (!software->reboot_required) { + swupdate_progress_info(RUN, CAUSE_REBOOT_MODE , "{ \"reboot-mode\" : \"no-reboot\"}"); + } + ret = install_images(software); if (ret != 0) { update_transaction_state(software, STATE_FAILED); @@ -704,6 +713,38 @@ void *network_initializer(void *data) pthread_mutex_unlock(&stream_mutex); TRACE("Main thread sleep again !"); notify(IDLE, RECOVERY_NO_ERROR, INFOLEVEL, "Waiting for requests..."); + + /* + * Last step, if no restart is required, + * SWUpdate can send automatically the feedback. + * They are running on separate processes and should first + * know that the update is completed. + * It seems safe enough to wait uncoditionally for some + * time, enough to let all SWUpdate's processes to be scheduled, + * before sending the IPC message + */ + if (req->source == SOURCE_SURICATTA && + /*simple check without JSON */ strstr(req->info, "hawkbit") && + !software->reboot_required) { + ipc_message msg; + size_t size = sizeof(msg.data.procmsg.buf); + char *buf = msg.data.procmsg.buf; + memset(&msg, 0, sizeof(msg)); + msg.magic = IPC_MAGIC; + msg.data.procmsg.source = SOURCE_SURICATTA; + msg.data.procmsg.cmd = CMD_ACTIVATION; + msg.type = SWUPDATE_SUBPROCESS; + snprintf(buf, size, "{ \"status\" : \"%s\", \"finished\" : \"%s\" ,\"execution\" : \"%s\" ,\"details\" : [ ]}", + "1", + inst.last_install == SUCCESS ? "success" : "failure", + "closed" + ); + sleep(2); + TRACE("SEND CONCLUSION TO HAWKBIT"); + ipc_send_cmd(&msg); + } + + } pthread_exit((void *)0); diff --git a/include/swupdate.h b/include/swupdate.h index 8f768a72..c1f86b36 100644 --- a/include/swupdate.h +++ b/include/swupdate.h @@ -70,6 +70,7 @@ struct swupdate_cfg { bool no_reinstalling; bool no_transaction_marker; bool no_state_marker; + bool reboot_required; bool check_max_version; int verbose; int loglevel; diff --git a/parser/parser.c b/parser/parser.c index cbb11962..46642a4d 100644 --- a/parser/parser.c +++ b/parser/parser.c @@ -214,6 +214,19 @@ static bool get_common_fields(parsertype p, void *cfg, struct swupdate_cfg *swcf } } + /* + * As default, reboot is initiated + */ + swcfg->reboot_required = true; + if((setting = find_node(p, cfg, "reboot", swcfg)) != NULL) { + get_field(p, setting, NULL, &swcfg->reboot_required); + } + + TRACE("rebot_required %d", swcfg->reboot_required); + + /* + * Check if SWU should be cached + */ if ((setting = find_node(p, cfg, "output", swcfg)) != NULL) { if (!strlen(swcfg->output)) { TRACE("Output file set but not enabled with -o, ignored");