File qemu-support-xen-hvm-direct-kernel-boot.patch of Package xen.4507
From dd708897cc5b21bc374cd44b6d58c1e74b04bd6e Mon Sep 17 00:00:00 2001
From: Chunyan Liu <cyliu@suse.com>
Date: Wed, 28 May 2014 14:31:35 +0800
Subject: [PATCH 2/2] qemu: support xen hvm direct kernel boot
qemu side patch to support xen HVM direct kernel boot:
if -kernel exists, calls xen_load_linux(), which will read kernel/initrd
and add a linuxboot.bin or multiboot.bin option rom. The
linuxboot.bin/multiboot.bin will load kernel/initrd and jump to execute
kernel directly. It's working when xen uses seabios.
Signed-off-by: Chunyan Liu <cyliu@suse.com>
Index: xen-4.4.0-testing/tools/qemu-xen-dir-remote/hw/i386/pc.c
===================================================================
--- xen-4.4.0-testing.orig/tools/qemu-xen-dir-remote/hw/i386/pc.c
+++ xen-4.4.0-testing/tools/qemu-xen-dir-remote/hw/i386/pc.c
@@ -1105,6 +1105,35 @@ void pc_acpi_init(const char *default_ds
}
}
+FWCfgState *xen_load_linux(const char *kernel_filename,
+ const char *kernel_cmdline,
+ const char *initrd_filename,
+ ram_addr_t below_4g_mem_size,
+ PcGuestInfo *guest_info)
+{
+ int i;
+ FWCfgState *fw_cfg;
+
+ assert(kernel_filename != NULL);
+
+ fw_cfg = fw_cfg_init(BIOS_CFG_IOPORT, BIOS_CFG_IOPORT + 1, 0, 0);
+ rom_set_fw(fw_cfg);
+
+ load_linux(fw_cfg, kernel_filename, initrd_filename, kernel_cmdline, below_4g_mem_size);
+ for (i = 0; i < nb_option_roms; i++) {
+ /* For xen, we only want to add the linuxboot.bin/multiboot.bin option rom.
+ * But in option_rom, there is still kvmvapic.bin. We don't want to add it.
+ */
+ if (strcmp(option_rom[i].name, "linuxboot.bin") &&
+ strcmp(option_rom[i].name, "multiboot.bin")) {
+ continue;
+ }
+ rom_add_option(option_rom[i].name, option_rom[i].bootindex);
+ }
+ guest_info->fw_cfg = fw_cfg;
+ return fw_cfg;
+}
+
FWCfgState *pc_memory_init(MemoryRegion *system_memory,
const char *kernel_filename,
const char *kernel_cmdline,
Index: xen-4.4.0-testing/tools/qemu-xen-dir-remote/hw/i386/pc_piix.c
===================================================================
--- xen-4.4.0-testing.orig/tools/qemu-xen-dir-remote/hw/i386/pc_piix.c
+++ xen-4.4.0-testing/tools/qemu-xen-dir-remote/hw/i386/pc_piix.c
@@ -135,6 +135,13 @@ static void pc_init1(MemoryRegion *syste
kernel_filename, kernel_cmdline, initrd_filename,
below_4g_mem_size, above_4g_mem_size,
rom_memory, &ram_memory, guest_info);
+ } else if (kernel_filename != NULL) {
+ /* For xen HVM direct kernel boot, load linux here */
+ fw_cfg = xen_load_linux(kernel_filename,
+ kernel_cmdline,
+ initrd_filename,
+ below_4g_mem_size,
+ guest_info);
}
gsi_state = g_malloc0(sizeof(*gsi_state));
Index: xen-4.4.0-testing/tools/qemu-xen-dir-remote/include/hw/i386/pc.h
===================================================================
--- xen-4.4.0-testing.orig/tools/qemu-xen-dir-remote/include/hw/i386/pc.h
+++ xen-4.4.0-testing/tools/qemu-xen-dir-remote/include/hw/i386/pc.h
@@ -120,6 +120,11 @@ static inline uint64_t pci_host_get_hole
void pc_init_pci64_hole(PcPciInfo *pci_info, uint64_t pci_hole64_start,
uint64_t pci_hole64_size);
+FWCfgState *xen_load_linux(const char *kernel_filename,
+ const char *kernel_cmdline,
+ const char *initrd_filename,
+ ram_addr_t below_4g_mem_size,
+ PcGuestInfo *guest_info);
FWCfgState *pc_memory_init(MemoryRegion *system_memory,
const char *kernel_filename,
const char *kernel_cmdline,