From patchwork Tue Dec 6 03:40:55 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matt Evans X-Patchwork-Id: 129510 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 7C94A1007D6 for ; Tue, 6 Dec 2011 14:40:19 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932913Ab1LFDkM (ORCPT ); Mon, 5 Dec 2011 22:40:12 -0500 Received: from ozlabs.org ([203.10.76.45]:57060 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932871Ab1LFDkK (ORCPT ); Mon, 5 Dec 2011 22:40:10 -0500 Received: from [10.61.2.183] (ibmaus65.lnk.telstra.net [165.228.126.9]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPSA id 671231007D4; Tue, 6 Dec 2011 14:40:08 +1100 (EST) Message-ID: <4EDD8EC7.5010603@ozlabs.org> Date: Tue, 06 Dec 2011 14:40:55 +1100 From: Matt Evans User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.23) Gecko/20110921 Thunderbird/3.1.15 MIME-Version: 1.0 To: kvm@vger.kernel.org, kvm-ppc@vger.kernel.org Subject: [PATCH 15/28] kvm tools: Allow initrd_check() to match a cpio References: In-Reply-To: Sender: kvm-ppc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm-ppc@vger.kernel.org cpios are valid as initrds too, so allow them through the check. Signed-off-by: Matt Evans --- tools/kvm/kvm.c | 8 +++++--- 1 files changed, 5 insertions(+), 3 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/tools/kvm/kvm.c b/tools/kvm/kvm.c index 33243f1..457de1a 100644 --- a/tools/kvm/kvm.c +++ b/tools/kvm/kvm.c @@ -317,10 +317,11 @@ struct kvm *kvm__init(const char *kvm_dev, u64 ram_size, const char *name) /* 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[2]; + unsigned char id[4]; if (read_in_full(fd, id, ARRAY_SIZE(id)) < 0) return false; @@ -328,7 +329,8 @@ static bool initrd_check(int fd) if (lseek(fd, 0, SEEK_SET) < 0) die_perror("lseek"); - return id[0] == GZIP_ID1 && id[1] == GZIP_ID2; + 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,