aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexandru Elisei <alexandru.elisei@arm.com>2022-02-14 16:58:28 +0000
committerWill Deacon <will@kernel.org>2022-02-16 15:59:20 +0000
commit9b681b0827d7bae692a29e10d5cc8a8b6ec85e35 (patch)
treeb1a8a9b6f7d298cdb8b9290778d55b0ea33a90af
parent2108c86d0623f32d34e4dc43ef76935e110ab1bd (diff)
downloadkvmtool-9b681b0827d7bae692a29e10d5cc8a8b6ec85e35.tar.gz
Remove initrd magic check
Linux, besides CPIO, supports 7 different compressed formats for the initrd (gzip, bzip2, LZMA, XZ, LZO, LZ4, ZSTD), but kvmtool only recognizes one of them. Remove the initrd magic check because: 1. It doesn't bring much to the end user, as the Linux kernel still complains if the initrd is in an unknown format. 2. --kernel can be used to load something that is not a Linux kernel (like a kvm-unit-tests test), in which case a format which is not supported by a Linux kernel can still be perfectly valid. For example, kvm-unit-tests load the test environment as an initrd in plain ASCII format. 3. It cuts down on the maintenance effort when new formats are added to the Linux kernel. Not a big deal, since that doesn't happen very often, but it's still an effort with very little gain (see point #1 above). Signed-off-by: Alexandru Elisei <alexandru.elisei@arm.com> Link: https://lore.kernel.org/r/20220214165830.69207-2-alexandru.elisei@arm.com Signed-off-by: Will Deacon <will@kernel.org>
-rw-r--r--kvm.c22
1 files changed, 0 insertions, 22 deletions
diff --git a/kvm.c b/kvm.c
index 5bc66c8b..952ef1fb 100644
--- a/kvm.c
+++ b/kvm.c
@@ -512,25 +512,6 @@ err:
}
core_init(kvm__init);
-/* RFC 1952 */
-#define GZIP_ID1 0x1f
-#define GZIP_ID2 0x8b
-#define CPIO_MAGIC "0707"
-/* initrd may be gzipped, or a plain cpio */
-static bool initrd_check(int fd)
-{
- unsigned char id[4];
-
- if (read_in_full(fd, id, ARRAY_SIZE(id)) < 0)
- return false;
-
- if (lseek(fd, 0, SEEK_SET) < 0)
- die_perror("lseek");
-
- return (id[0] == GZIP_ID1 && id[1] == GZIP_ID2) ||
- !memcmp(id, CPIO_MAGIC, 4);
-}
-
bool kvm__load_kernel(struct kvm *kvm, const char *kernel_filename,
const char *initrd_filename, const char *kernel_cmdline)
{
@@ -545,9 +526,6 @@ bool kvm__load_kernel(struct kvm *kvm, const char *kernel_filename,
fd_initrd = open(initrd_filename, O_RDONLY);
if (fd_initrd < 0)
die("Unable to open initrd %s", initrd_filename);
-
- if (!initrd_check(fd_initrd))
- die("%s is not an initrd", initrd_filename);
}
ret = kvm__arch_load_kernel_image(kvm, fd_kernel, fd_initrd,