qemu-kvm.git uq/master queue
The following changes since commit cf4dc461a4cfc3e056ee24edb26154f4d34a6278:
Restore consistent formatting (2012-02-07 22:11:04 +0400)
are available in the git repository at:
git://git.kernel.org/pub/scm/virt/kvm/qemu-kvm.git uq/master
Jan Kiszka (3):
kvm: Allow to set shadow MMU size
kvm: Implement kvm_irqchip_in_kernel like kvm_enabled
apic: Fix legacy vmstate loading for KVM
hw/apic_common.c | 7 ++++++- hw/pc.c | 4 ++-- hw/pc_piix.c | 6 +++--- kvm-all.c | 13 ++++--------- kvm-stub.c | 5 ----- kvm.h | 8 +++++--- qemu-config.c | 4 ++++ qemu-options.hx | 5 ++++- target-i386/kvm.c | 17 +++++++++++++++-- 9 files changed, 43 insertions(+), 26 deletions(-)
PATCH 1/3 kvm: Allow to set shadow MMU size
From: Jan Kiszka <[email protected]>
Introduce the KVM-specific machine option kvm_shadow_mem. It allows to set a custom shadow MMU size for the virtual machine. This is useful for stress testing e.g.
Only x86 supports this for now, but it is in principle a generic concept for all targets with shadow MMUs.
--- qemu-config.c | 4 ++++ qemu-options.hx | 5 ++++- target-i386/kvm.c | 13 +++++++++++++ 3 files changed, 21 insertions(+), 1 deletions(-)
qemu-config.c +4 -0
@@ -535,6 +535,10 @@ static QemuOptsList qemu_machine_opts = { .name = "kernel_irqchip", .type = QEMU_OPT_BOOL, .help = "use KVM in-kernel irqchip", + }, { + .name = "kvm_shadow_mem", + .type = QEMU_OPT_SIZE, + .help = "KVM shadow MMU size", }, {/* End of list */ } },
qemu-options.hx +4 -1
@@ -32,7 +32,8 @@ DEF("machine", HAS_ARG, QEMU_OPTION_machine, \ " selects emulated machine (-machine ? for list)\n" " property accel=accel1[:accel2[:...]] selects accelerator\n" " supported accelerators are kvm, xen, tcg (default: tcg)\n" - " kernel_irqchip=on|off controls accelerated irqchip support\n", + " kernel_irqchip=on|off controls accelerated irqchip support\n" + " kvm_shadow_mem=size of KVM shadow MMU\n", QEMU_ARCH_ALL) STEXI @item -machine [type=]@var{name}[,prop=@var{value}[,...]]
@@ -47,6 +48,8 @@ than one accelerator specified, the next one is used if the previous one fails to initialize. @item kernel_irqchip=on|off Enables in-kernel irqchip support for the chosen accelerator when available. +@item kvm_shadow_mem=size +Defines the size of the KVM shadow MMU. @end table ETEXI
target-i386/kvm.c +13 -0
@@ -646,7 +646,9 @@ static int kvm_get_supported_msrs(KVMState *s)int kvm_arch_init (KVMState *s) { +QemuOptsList *list =qemu_find_opts ("machine" );uint64_t identity_base =0xfffbc000 ; +uint64_t shadow_mem;int ret;struct utsname utsname;
@@ -693,6 +695,17 @@ int kvm_arch_init(KVMState *s) }qemu_register_reset (kvm_unpoison_all,NULL ); +if (!QTAILQ_EMPTY (&list->head)) { + shadow_mem =qemu_opt_get_size (QTAILQ_FIRST (&list->head), +"kvm_shadow_mem" ,-1 ); +if (shadow_mem !=-1 ) { + shadow_mem /=4096 ; + ret =kvm_vm_ioctl (s,KVM_SET_NR_MMU_PAGES , shadow_mem); +if (ret <0 ) { +return ret; + } + } + }return 0 ; }
Signature · 1 line
1.7.6.4
PATCH 2/3 kvm: Implement kvm_irqchip_in_kernel like kvm_enabled
In reply to Marcelo TosattiFrom: Jan Kiszka <[email protected]>
To both avoid that kvm_irqchip_in_kernel always has to be paired with kvm_enabled and that the former ends up in a function call, implement it like the latter. This means keeping the state in a global variable and defining kvm_irqchip_in_kernel as a preprocessor macro.
--- hw/pc.c | 4 ++-- hw/pc_piix.c | 6 +++--- kvm-all.c | 13 ++++--------- kvm-stub.c | 5 ----- kvm.h | 8 +++++--- target-i386/kvm.c | 4 ++-- 6 files changed, 16 insertions(+), 24 deletions(-)
hw/pc.c +2 -2
@@ -889,7 +889,7 @@ static DeviceState *apic_init(void *env, uint8_t apic_id)DeviceState *dev;static int apic_mapped; -if (kvm_enabled () &&kvm_irqchip_in_kernel ()) { +if (kvm_irqchip_in_kernel ()) { dev =qdev_create (NULL ,"kvm-apic" ); }else { dev =qdev_create (NULL ,"apic" );
@@ -908,7 +908,7 @@ static DeviceState *apic_init(void *env, uint8_t apic_id) }/* KVM does not support MSI yet. */ -if (!kvm_enabled () || !kvm_irqchip_in_kernel ()) { +if (!kvm_irqchip_in_kernel ()) { msi_supported = true; }
hw/pc_piix.c +3 -3
@@ -104,7 +104,7 @@ static void ioapic_init(GSIState *gsi_state)SysBusDevice *d;unsigned int i; -if (kvm_enabled () &&kvm_irqchip_in_kernel ()) { +if (kvm_irqchip_in_kernel ()) { dev =qdev_create (NULL ,"kvm-ioapic" ); }else { dev =qdev_create (NULL ,"ioapic" );
@@ -183,7 +183,7 @@ static void pc_init1(MemoryRegion *system_memory, } gsi_state =g_malloc0 (sizeof (*gsi_state)); -if (kvm_enabled () &&kvm_irqchip_in_kernel ()) { +if (kvm_irqchip_in_kernel ()) {kvm_piix3_setup_irq_routing (pci_enabled); gsi =qemu_allocate_irqs (kvm_piix3_gsi_handler, gsi_state,GSI_NUM_PINS );
@@ -209,7 +209,7 @@ static void pc_init1(MemoryRegion *system_memory, }isa_bus_irqs (isa_bus, gsi); -if (kvm_enabled () &&kvm_irqchip_in_kernel ()) { +if (kvm_irqchip_in_kernel ()) { i8259 =kvm_i8259_init (isa_bus); }else if (xen_enabled ()) { i8259 =xen_interrupt_controller_init ();
kvm-all.c +4 -9
@@ -74,7 +74,6 @@ struct KVMState#ifdef KVM_CAP_SET_GUEST_DEBUG struct kvm_sw_breakpoint_head kvm_sw_breakpoints;#endif -int irqchip_in_kernel;int pit_in_kernel;int xsave, xcrs;int many_ioeventfds;
@@ -88,6 +87,7 @@ struct KVMState };KVMState *kvm_state; +bool kvm_kernel_irqchip;static const KVMCapabilityInfo kvm_required_capabilites[] = {KVM_CAP_INFO (USER_MEMORY ),
@@ -193,11 +193,6 @@ static void kvm_reset_vcpu(void *opaque)kvm_arch_reset_vcpu (env); } -int kvm_irqchip_in_kernel (void ) -{ -return kvm_state->irqchip_in_kernel; -} -int kvm_pit_in_kernel (void ) {return kvm_state->pit_in_kernel;
@@ -742,7 +737,7 @@ int kvm_irqchip_set_irq(KVMState *s, int irq, int level)struct kvm_irq_level event;int ret; -assert (s->irqchip_in_kernel); +assert (kvm_irqchip_in_kernel ()); event.level = level; event.irq = irq;
@@ -862,7 +857,7 @@ static int kvm_irqchip_create(KVMState *s)if (kvm_check_extension (s,KVM_CAP_IRQ_INJECT_STATUS )) { s->irqchip_inject_ioctl =KVM_IRQ_LINE_STATUS ; } - s->irqchip_in_kernel =1 ; + kvm_kernel_irqchip = true;kvm_init_irq_routing (s);
@@ -1315,7 +1310,7 @@ int kvm_has_gsi_routing(void)int kvm_allows_irq0_override (void ) { -return !kvm_enabled () || !kvm_irqchip_in_kernel () ||kvm_has_gsi_routing (); +return !kvm_irqchip_in_kernel () ||kvm_has_gsi_routing (); }void kvm_setup_guest_memory (void *start,size_t size)
kvm-stub.c +0 -5
@@ -16,11 +16,6 @@#include "gdbstub.h" #include "kvm.h" -int kvm_irqchip_in_kernel (void ) -{ -return 0 ; -} -int kvm_pit_in_kernel (void ) {return 0 ;
kvm.h +5 -3
@@ -23,11 +23,14 @@#endif extern int kvm_allowed; +extern bool kvm_kernel_irqchip;#if definedCONFIG_KVM || !definedNEED_CPU_H -#define kvm_enabled () (kvm_allowed) +#define kvm_enabled () (kvm_allowed) +#define kvm_irqchip_in_kernel () (kvm_kernel_irqchip)#else -#define kvm_enabled () (0) +#define kvm_enabled () (0) +#define kvm_irqchip_in_kernel () (false)#endif struct kvm_run ;
@@ -80,7 +83,6 @@ int kvm_set_signal_mask(CPUState *env, const sigset_t *sigset);#endif int kvm_pit_in_kernel (void ); -int kvm_irqchip_in_kernel (void );int kvm_on_sigbus_vcpu (CPUState *env,int code,void *addr);int kvm_on_sigbus (int code,void *addr);
target-i386/kvm.c +2 -2
@@ -1356,7 +1356,7 @@ static int kvm_get_apic(CPUState *env)struct kvm_lapic_state kapic;int ret; -if (apic &&kvm_enabled () &&kvm_irqchip_in_kernel ()) { +if (apic &&kvm_irqchip_in_kernel ()) { ret =kvm_vcpu_ioctl (env,KVM_GET_LAPIC , &kapic);if (ret <0 ) {return ret;
@@ -1372,7 +1372,7 @@ static int kvm_put_apic(CPUState *env)DeviceState *apic = env->apic_state;struct kvm_lapic_state kapic; -if (apic &&kvm_enabled () &&kvm_irqchip_in_kernel ()) { +if (apic &&kvm_irqchip_in_kernel ()) {kvm_put_apic_state (apic, &kapic);return kvm_vcpu_ioctl (env,KVM_SET_LAPIC , &kapic);
Signature · 1 line
1.7.6.4
PATCH 3/3 apic: Fix legacy vmstate loading for KVM
In reply to Marcelo TosattiFrom: Jan Kiszka <[email protected]>
Also in case of loading pre-vmstate machines, we also need to open-code the reading of the timer expires value and instead call the post_load callback to apply it (or not). This fixes loading of legacy states into the KVM APIC.
--- hw/apic_common.c | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-)
hw/apic_common.c +6 -1
@@ -188,6 +188,7 @@ static void apic_reset_common(DeviceState *d)static int apic_load_old (QEMUFile *f,void *opaque,int version_id) {APICCommonState *s = opaque; +APICCommonClass *info =APIC_COMMON_GET_CLASS (s);int i;if (version_id >2 ) {
@@ -220,7 +221,11 @@ static int apic_load_old(QEMUFile *f, void *opaque, int version_id) s->next_time =qemu_get_be64 (f);if (version_id >=2 ) { -qemu_get_timer (f, s->timer); + s->timer_expiry =qemu_get_be64 (f); + } + +if (info->post_load) { + info->post_load (s); }return 0 ; }
Signature · 1 line
1.7.6.4
Quoted 6 lines · Marcelo Tosatti
The following changes since commit
cf4dc461a4cfc3e056ee24edb26154f4d34a6278:Restore consistent formatting (2012-02-07 22:11:04 +0400)are available in the git repository at:
git://git.kernel.org/pub/scm/virt/kvm/qemu-kvm.gituq/master
Pulled. Thanks.
Regards,
Anthony Liguori
Quoted 18 lines
Jan Kiszka (3):
kvm: Allow to set shadow MMU size
kvm: Implementkvm_irqchip_in_kernellikekvm_enabled
apic: Fix legacy vmstate loading for KVMhw/apic_common.c | 7 ++++++- hw/pc.c | 4 ++-- hw/pc_piix.c | 6 +++--- kvm-all.c | 13 ++++--------- kvm-stub.c | 5 ----- kvm.h | 8 +++++--- qemu-config.c | 4 ++++ qemu-options.hx | 5 ++++- target-i386/kvm.c | 17 +++++++++++++++-- 9 files changed, 43 insertions(+), 26 deletions(-)