From nobody Fri Dec 19 22:03:55 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=eu.citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1589915418; cv=none; d=zohomail.com; s=zohoarc; b=WLGFmrRPwgUDl6vLwpf96XLyBumbAbHE8WRNI3IiHPADjmiTzcsNwfYZTTjpAGFhAWpCq6y4t3PmbNd1uZiJ2rr0LW+XLgetE25CfH3QaD5PvxxqVtL+SZImpXpdP/dkF77ivOX3aIaDd9zo0AHbwNdyfFTdCxtEaTxzLae5kaE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589915418; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=tz//tWL619IS8spYvzVvndLnhAavn5PvwHheMBWsepU=; b=gdW7vRjMthNW433hQbkTPTxuIKmKnbNjvqk4eyhHkksFmvhLvmceyVh4kMrL+dQ7Gj9wjoAIsTqnjYqQbVM8P9Z3QX3MoV0Nw0gbLGeKTuZziPdoR0gz6VLzsYSgkblO9nuGug3sQyOHtYutr3p0+TdWpSy01GWFQmzYuSrSk8A= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1589915418096473.97381969732135; Tue, 19 May 2020 12:10:18 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jb7cq-0006PT-Ig; Tue, 19 May 2020 19:10:04 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jb7cp-0006FG-IF for xen-devel@lists.xenproject.org; Tue, 19 May 2020 19:10:03 +0000 Received: from chiark.greenend.org.uk (unknown [2001:ba8:1e3::3]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 46d66bc4-9a04-11ea-b9cf-bc764e2007e4; Tue, 19 May 2020 19:09:35 +0000 (UTC) Received: from [172.18.45.5] (helo=zealot.relativity.greenend.org.uk) by chiark.greenend.org.uk (Debian Exim 4.84_2 #1) with esmtp (return-path ijackson@chiark.greenend.org.uk) id 1jb7Vj-0001da-Fu; Tue, 19 May 2020 20:02:43 +0100 X-Inumbo-ID: 46d66bc4-9a04-11ea-b9cf-bc764e2007e4 From: Ian Jackson To: xen-devel@lists.xenproject.org Subject: [OSSTEST PATCH 30/38] overlay-initrd-buster/sbin/reopen-console: Copy from Debian Date: Tue, 19 May 2020 20:02:22 +0100 Message-Id: <20200519190230.29519-31-ian.jackson@eu.citrix.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200519190230.29519-1-ian.jackson@eu.citrix.com> References: <20200519190230.29519-1-ian.jackson@eu.citrix.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Ian Jackson Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Content-Type: text/plain; charset="utf-8" We are going to patch this file to work around a bug, using the new overlay mechanism. The first step is to include the file in our overlay so we overwrite it. Currently, this is a no-op, so no functional change. Signed-off-by: Ian Jackson --- overlay-initrd-buster/sbin/reopen-console | 94 +++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100755 overlay-initrd-buster/sbin/reopen-console diff --git a/overlay-initrd-buster/sbin/reopen-console b/overlay-initrd-bus= ter/sbin/reopen-console new file mode 100755 index 00000000..dd354deb --- /dev/null +++ b/overlay-initrd-buster/sbin/reopen-console @@ -0,0 +1,94 @@ +#!/bin/sh + +# First find the enabled consoles from the kernel, noting if one is 'prefe= rred' +# Record these. +# Run the startup scripts on the preferred console + +# In order to have D-I appear on all consoles, modify the inittab to +# add one entry for each console, running debian-installer. +# Finally HUP init so that it runs those installers +# (but doesn't rerun the sysinit startup stuff, including this script) + + +NL=3D" +" + +LOGGER_UP=3D0 +LOG_FILE=3D/var/log/reopen-console + +log() { + # In very early startup we don't have syslog. Log to file that + # we can flush out later so we can at least see what happened + # at early startup + if [ $LOGGER_UP -eq 1 ]; then + logger -t reopen-console "$@" + else + echo "$@" >> $LOG_FILE + fi +} + +flush_logger () { + cat $LOG_FILE | logger -t reopen-console + rm $LOG_FILE +} + +consoles=3D +preferred=3D +# Retrieve all enabled consoles from kernel; ignore those +# for which no device file exists + +kernelconsoles=3D"$(cat /proc/consoles)" +for cons in $(echo "$kernelconsoles" | sed -n -r -e 's/(^.*) .*\((.*)\).*= $/\1/p' ) +do + log "Looking at console $cons from /proc/consoles" + status=3D$(echo "$kernelconsoles" | grep $cons | sed -n -r -e 's/(^.*) *.= *\((.*)\).*$/\2/p' ) + if [ -e "/dev/$cons" ] && [ $(echo "$status" | grep -o 'E') ]; then + consoles=3D"${consoles:+$consoles$NL}$cons" + log " Adding $cons to consoles list" + fi + # 'C' console is 'most prefered'. + if [ $(echo "$status" | grep -o 'C') ]; then + preferred=3D"$cons" + log " $cons is preferred" + fi +done + +if [ -z "$consoles" ]; then + # Nothing found? Default to /dev/console. + log "Found no consoles! Defaulting to /dev/console" + consoles=3Dconsole +fi +if [ -z "$preferred" ]; then + #None marked preferred? Use the first one + preferred=3D$(echo "$consoles" | head -n 1) + log "Found no preferred console. Picking $preferred" +fi + +for cons in $consoles +do + echo "/dev/$cons " >> /var/run/console-devices +done +echo "/dev/$preferred " > /var/run/console-preferred + + +# Add debian-installer lines into inittab - one per console +for cons in $consoles +do + log "Adding inittab entry for $cons" + echo "$cons::respawn:/sbin/debian-installer" >> /etc/inittab +done + +# Run the startup scripts once, using the preferred console +cons=3D$(cat /var/run/console-preferred) +# Some other session may have that console as ctty. Steal it from them +/sbin/steal-ctty $cons "$@" + +# Now we should have syslog running, so flush our log entries +LOGGER_UP=3D1 +flush_logger + +# Finally restart init to run debian-installer on discovered consoles +log "Restarting init to start d-i on the consoles we found" +kill -HUP 1 + +exit 0 --=20 2.20.1