detect-virt: do not try to read all of /proc/cpuinfo
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 13 Sep 2018 07:24:36 +0000 (09:24 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 18 Sep 2018 14:53:36 +0000 (16:53 +0200)
commit6058516a14ada1748313af6783f5b4e7e3006654
tree4de218e9b74245ae5f81509ab5f2659495218d22
parent010d436e020ab4af57a8b9fc38918f551acc875b
detect-virt: do not try to read all of /proc/cpuinfo

Quoting https://github.com/systemd/systemd/issues/10074:
> detect_vm_uml() reads /proc/cpuinfo with read_full_file()
> read_full_file() has a file max limit size of READ_FULL_BYTES_MAX=(4U*1024U*1024U)
> Unfortunately, the size of my /proc/cpuinfo is bigger, approximately:
> echo $(( 4* $(cat /proc/cpuinfo | wc -c)))
> 9918072
> This causes read_full_file() to fail and the Condition test fallout.

Let's just read line by line until we find an intersting line. This also
helps if not running under UML, because we avoid reading as much data.
src/basic/virt.c