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);
> +}