From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40314) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1beQ2x-0007wj-Nq for qemu-devel@nongnu.org; Mon, 29 Aug 2016 13:08:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1beQ2n-0007XL-Vy for qemu-devel@nongnu.org; Mon, 29 Aug 2016 13:08:30 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52760) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1beQ2n-0007XB-Pq for qemu-devel@nongnu.org; Mon, 29 Aug 2016 13:08:21 -0400 References: <1472120105-29235-1-git-send-email-chao.p.peng@linux.intel.com> <1472120105-29235-13-git-send-email-chao.p.peng@linux.intel.com> From: Paolo Bonzini Message-ID: <2edd9e99-555b-ab59-1baf-c38d37b4e6f3@redhat.com> Date: Mon, 29 Aug 2016 19:08:14 +0200 MIME-Version: 1.0 In-Reply-To: <1472120105-29235-13-git-send-email-chao.p.peng@linux.intel.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [RFC PATCH v2 12/12] pc: skip firmware List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Chao Peng , qemu-devel@nongnu.org Cc: "Michael S. Tsirkin" , gor Mammedov , Xiao Guangrong , Richard Henderson , Eduardo Habkost , Haozhong Zhang On 25/08/2016 12:15, Chao Peng wrote: > -static void load_linux(PCMachineState *pcms, > - FWCfgState *fw_cfg) > +static void load_linux_efi(PCMachineState *pcms) ELF, not EFI. Paolo > +{ > + unsigned char class; > + MachineState *machine = MACHINE(pcms); > + FILE *file = fopen(machine->kernel_filename, "rb"); > + > + if (!file) { > + goto err; > + } > + > + if (fseek(file, EI_CLASS, 0) || fread(&class, 1, 1, file) != 1) { > + fclose(file); > + goto err; > + } > + fclose(file); > + > + if (load_elf(machine->kernel_filename, NULL, NULL, &boot_info.entry, > + NULL, NULL, 0, EM_X86_64, 0, 0) < 0) { > + goto err; > + } > + > + if (class == ELFCLASS64) { > + boot_info.long_mode = true; > + } else if (class != ELFCLASS32) { > + goto err; > + } > + > + boot_info.protected_mode = true; > + return; > + > +err: > + fprintf(stderr, "qemu: could not load kernel '%s'\n", > + machine->kernel_filename); > + exit(1); > +}