xen: Add xenfv machine

Introduce the Xen FV (Fully Virtualized) machine to Qemu, some more Xen
specific call will be added in further patches.

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
This commit is contained in:
Anthony PERARD 2010-06-30 12:58:34 +01:00 committed by Alexander Graf
parent e0e7e67b45
commit 29d3ccde82
3 changed files with 69 additions and 2 deletions

View file

@ -38,6 +38,10 @@
#include "arch_init.h"
#include "blockdev.h"
#include "smbus.h"
#include "xen.h"
#ifdef CONFIG_XEN
# include <xen/hvm/hvm_info_table.h>
#endif
#define MAX_IDE_BUS 2
@ -101,8 +105,10 @@ static void pc_init1(ram_addr_t ram_size,
}
/* allocate ram and load rom/bios */
pc_memory_init(kernel_filename, kernel_cmdline, initrd_filename,
below_4g_mem_size, above_4g_mem_size);
if (!xen_enabled()) {
pc_memory_init(kernel_filename, kernel_cmdline, initrd_filename,
below_4g_mem_size, above_4g_mem_size);
}
cpu_irq = pc_allocate_cpu_irq();
i8259 = i8259_init(cpu_irq[0]);
@ -221,6 +227,24 @@ static void pc_init_isa(ram_addr_t ram_size,
initrd_filename, cpu_model, 0, 1);
}
#ifdef CONFIG_XEN
static void pc_xen_hvm_init(ram_addr_t ram_size,
const char *boot_device,
const char *kernel_filename,
const char *kernel_cmdline,
const char *initrd_filename,
const char *cpu_model)
{
if (xen_hvm_init() != 0) {
hw_error("xen hardware virtual machine initialisation failed");
}
pc_init_pci_no_kvmclock(ram_size, boot_device,
kernel_filename, kernel_cmdline,
initrd_filename, cpu_model);
xen_vcpu_init();
}
#endif
static QEMUMachine pc_machine = {
.name = "pc-0.14",
.alias = "pc",
@ -385,6 +409,16 @@ static QEMUMachine isapc_machine = {
.max_cpus = 1,
};
#ifdef CONFIG_XEN
static QEMUMachine xenfv_machine = {
.name = "xenfv",
.desc = "Xen Fully-virtualized PC",
.init = pc_xen_hvm_init,
.max_cpus = HVM_MAX_VCPUS,
.default_machine_opts = "accel=xen",
};
#endif
static void pc_machine_init(void)
{
qemu_register_machine(&pc_machine);
@ -393,6 +427,9 @@ static void pc_machine_init(void)
qemu_register_machine(&pc_machine_v0_11);
qemu_register_machine(&pc_machine_v0_10);
qemu_register_machine(&isapc_machine);
#ifdef CONFIG_XEN
qemu_register_machine(&xenfv_machine);
#endif
}
machine_init(pc_machine_init);

View file

@ -30,5 +30,11 @@ static inline int xen_enabled(void)
}
int xen_init(void);
int xen_hvm_init(void);
void xen_vcpu_init(void);
#if defined(CONFIG_XEN) && CONFIG_XEN_CTRL_INTERFACE_VERSION < 400
# define HVM_MAX_VCPUS 32
#endif
#endif /* QEMU_HW_XEN_H */

View file

@ -9,6 +9,25 @@
#include "hw/xen_common.h"
#include "hw/xen_backend.h"
/* VCPU Operations, MMIO, IO ring ... */
static void xen_reset_vcpu(void *opaque)
{
CPUState *env = opaque;
env->halted = 1;
}
void xen_vcpu_init(void)
{
CPUState *first_cpu;
if ((first_cpu = qemu_get_cpu(0))) {
qemu_register_reset(xen_reset_vcpu, first_cpu);
xen_reset_vcpu(first_cpu);
}
}
/* Initialise Xen */
int xen_init(void)
@ -21,3 +40,8 @@ int xen_init(void)
return 0;
}
int xen_hvm_init(void)
{
return 0;
}