From: Pingfan Liu <piliu@redhat.com>
To: kexec@lists.infradead.org
Cc: Dave Young <dyoung@redhat.com>, Baoquan He <bhe@redhat.com>
Subject: [PATCH 2/2] kdumpctl: verify the kernel cmdline
Date: Mon, 17 Apr 2017 14:44:36 +0800 [thread overview]
Message-ID: <1492411476-10548-2-git-send-email-piliu@redhat.com> (raw)
In-Reply-To: <1492411476-10548-1-git-send-email-piliu@redhat.com>
The invalid console param in cmdline could cause the emergency service's failure with STDIN error,
and the system can not reboot or enter the shell. This patch verify the cmdline and erase the
buggy param.
The invalid param can be reproduce by the following cmds
-1. boot up a VM with the following cmd:
qemu-kvm -name 'avocado-vt-vm1' -sandbox off -machine pc -nodefaults -vga cirrus \
-drive id=drive_image1,if=none,snapshot=off,aio=native,cache=none,format=qcow2,file=$guest_img \
-device virtio-blk-pci,id=image1,drive=drive_image1,bootindex=0,bus=pci.0,addr=04 \
-device virtio-net-pci,mac=9a:4d:4e:4f:50:51,id=id3DveCw,vectors=4,netdev=idgW5YRp,bus=pci.0,addr=05 \
-netdev tap,id=idgW5YRp \
-m 2048 \
-smp 4,maxcpus=4,cores=2,threads=1,sockets=2 \
-cpu 'SandyBridge',+kvm_pv_unhalt \
-vnc :0 \
-rtc base=utc,clock=host,driftfix=slew \
-boot order=cdn,once=c,menu=off,strict=off \
-enable-kvm \
-monitor stdio \
-qmp tcp:localhost:4444,server,nowait
-2. in kernel cmdline with the following options: console=tty0 console=ttyS0,
Because the "-nodefaults" option in qemu cmd excludes the emulation of serial port, the ttyS0 will
have no real backend device.
Signed-off-by: Pingfan Liu <piliu@redhat.com>
---
kdumpctl | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/kdumpctl b/kdumpctl
index d7f25d9..ee1b8c4 100755
--- a/kdumpctl
+++ b/kdumpctl
@@ -176,6 +176,26 @@ is_dump_to_rootfs()
grep "^default[[:space:]]dump_to_rootfs" /etc/kdump.conf >/dev/null
}
+verify_cmdline()
+{
+ condevs=$(echo $1 | tr " " "\n" | grep "console=" | awk -F "=" '{ print $2 }')
+ echo $condevs
+ verified_cmdline=$1
+ for condev in $condevs
+ do
+ echo "test $condev"
+ if [[ $condev =~ /dev/* ]]; then
+ echo "kexec-tools test $condev" > $condev
+ else
+ echo "kexec-tools test $condev" > /dev/$condev
+ fi
+ if [ $? -ne 0 ]; then
+ verified_cmdline=$(echo $verified_cmdline | sed -n "s/console=$condev/ /p")
+ fi
+ done
+ echo $verified_cmdline
+}
+
# This function performs a series of edits on the command line.
# Store the final result in global $KDUMP_COMMANDLINE.
prepare_cmdline()
@@ -211,6 +231,7 @@ prepare_cmdline()
cmdline=`append_cmdline "${cmdline}" disable_cpu_apicid ${id}`
fi
+ cmdline=`verify_cmdline "$cmdline"`
KDUMP_COMMANDLINE=$cmdline
check_kdump_cpus
--
2.7.4
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
next prev parent reply other threads:[~2017-04-17 6:52 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-17 6:44 [PATCH 1/2] kdump-lib-initramfs.sh: ignore the failure of echo Pingfan Liu
2017-04-17 6:44 ` Pingfan Liu [this message]
2017-04-17 7:46 ` Pingfan Liu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1492411476-10548-2-git-send-email-piliu@redhat.com \
--to=piliu@redhat.com \
--cc=bhe@redhat.com \
--cc=dyoung@redhat.com \
--cc=kexec@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox