From 4ec6ee5acef8092ec64e183694aba2a1cfce8d80 Mon Sep 17 00:00:00 2001 From: Igor Mammedov Date: Tue, 8 Jul 2014 15:29:46 +0200 Subject: [PATCH 1/7] pc: fix qemu exiting with error when -m X < 128 with old machines types If machine doesn't support memory hotplug then staring QEMU with initial memory less than default will make QEMU exit with following error message: $QEMU -m 16 -M isapc qemu-system-i386: "-memory 'slots|maxmem'" is not supported by: isapc Set maxram_size to initial memory value before parsing 'maxmem' option allows to keep maxmem in sync with initial memory size if no maxmem option was specified. Signed-off-by: Igor Mammedov CC: Bruce Rogers Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- vl.c | 1 + 1 file changed, 1 insertion(+) diff --git a/vl.c b/vl.c index 6e084c2da2..6abedcfae7 100644 --- a/vl.c +++ b/vl.c @@ -3315,6 +3315,7 @@ int main(int argc, char **argv, char **envp) error_report("ram size too large"); exit(EXIT_FAILURE); } + maxram_size = ram_size; maxmem_str = qemu_opt_get(opts, "maxmem"); slots_str = qemu_opt_get(opts, "slots"); From faab4597973573852bbddadef21c9e788ce732b3 Mon Sep 17 00:00:00 2001 From: Eduardo Habkost Date: Mon, 7 Jul 2014 15:30:52 -0300 Subject: [PATCH 2/7] pc_piix: Reuse pc_compat_1_2() for pc-0.1[0123] pc-0.13 and older were missing some compat code that was present on newer machine-types: * x86_cpu_compat_disable_kvm_features(FEAT_1_ECX, CPUID_EXT_X2APIC); (pc-i440fx-1.7 and older) (added by commit ef02ef5f4536dba090b12360a6c862ef0e57e3bc) * x86_cpu_compat_set_features("n270", FEAT_1_ECX, 0, CPUID_EXT_MOVBE); (pc-i440fx-1.4 and older) (added by commit 4458c23672904fa131e69897007eeb7c953be7e5 * x86_cpu_compat_set_features("Westmere", FEAT_1_ECX, 0, CPUID_EXT_PCLMULQDQ); (pc-i440fx-1.4 and older) (added by commit 56383703c060777fd01aaf8d63d5f46d660e9fb9) Instead of duplicating the code from the previous pc_compat_*() functions, we can now reuse pc_compat_1_2() and fix those issues. Signed-off-by: Eduardo Habkost Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/i386/pc_piix.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index 2dccb3401b..ec8ccdb673 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -386,19 +386,10 @@ static void pc_init_pci_1_2(MachineState *machine) pc_init_pci(machine); } -/* PC init function for pc-0.10 to pc-0.13, and reused by xenfv */ +/* PC init function for pc-0.10 to pc-0.13 */ static void pc_init_pci_no_kvmclock(MachineState *machine) { - has_pci_info = false; - has_acpi_build = false; - smbios_defaults = false; - gigabyte_align = false; - smbios_legacy_mode = true; - has_reserved_memory = false; - option_rom_has_mr = true; - rom_file_has_mr = false; - x86_cpu_compat_disable_kvm_features(FEAT_KVM, KVM_FEATURE_PV_EOI); - enable_compat_apic_id_mode(); + pc_compat_1_2(machine); pc_init1(machine, 1, 0); } From 75902802c26267b7d1d6948d81c907e2432f0a94 Mon Sep 17 00:00:00 2001 From: Hu Tao Date: Thu, 13 Jun 2013 18:51:48 +0800 Subject: [PATCH 3/7] fix typo: apci -> acpi MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Hu Tao Reviewed-by: Andreas Färber Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin MST: rebase --- hw/acpi/ich9.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/acpi/ich9.c b/hw/acpi/ich9.c index e7d6c77b34..7b14bbbee1 100644 --- a/hw/acpi/ich9.c +++ b/hw/acpi/ich9.c @@ -232,11 +232,11 @@ void ich9_pm_init(PCIDevice *lpc_pci, ICH9LPCPMRegs *pm, acpi_gpe_init(&pm->acpi_regs, ICH9_PMIO_GPE0_LEN); memory_region_init_io(&pm->io_gpe, OBJECT(lpc_pci), &ich9_gpe_ops, pm, - "apci-gpe0", ICH9_PMIO_GPE0_LEN); + "acpi-gpe0", ICH9_PMIO_GPE0_LEN); memory_region_add_subregion(&pm->io, ICH9_PMIO_GPE0_STS, &pm->io_gpe); memory_region_init_io(&pm->io_smi, OBJECT(lpc_pci), &ich9_smi_ops, pm, - "apci-smi", 8); + "acpi-smi", 8); memory_region_add_subregion(&pm->io, ICH9_PMIO_SMI_EN, &pm->io_smi); pm->irq = sci_irq; From 0e3cd8334aa800b947e2511720a8dcb792f68871 Mon Sep 17 00:00:00 2001 From: Nikolay Nikolaev Date: Wed, 9 Jul 2014 18:06:32 +0300 Subject: [PATCH 4/7] qtest: fix vhost-user-test compilation with old GLib Mising G_TIME_SPAN_SECOND definition breaks the RHEL6 compilation as GLib version before 2.26 does not have it. In such case just define it. Reported-by: Kevin Wolf Signed-off-by: Nikolay Nikolaev Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/vhost-user-test.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/vhost-user-test.c b/tests/vhost-user-test.c index 2af2381a1d..406ba70941 100644 --- a/tests/vhost-user-test.c +++ b/tests/vhost-user-test.c @@ -22,6 +22,10 @@ #include /* GLIB version compatibility flags */ +#if !GLIB_CHECK_VERSION(2, 26, 0) +#define G_TIME_SPAN_SECOND (G_GINT64_CONSTANT(1000000)) +#endif + #if GLIB_CHECK_VERSION(2, 28, 0) #define HAVE_MONOTONIC_TIME #endif From f69a28051f856e906bd9c2f9f27b3106a47e18f6 Mon Sep 17 00:00:00 2001 From: Nikolay Nikolaev Date: Sat, 12 Jul 2014 04:42:35 +0300 Subject: [PATCH 5/7] vhost-user: Fix VHOST_SET_MEM_TABLE processing qemu_get_ram_fd doesn't accept a guest physical address. ram_addr_t are opaque values that are assigned in qemu_ram_alloc. Find the ram_addr_t corresponding to the userspace_addr using qemu_ram_addr_from_host, and then call qemu_get_ram_fd on it. Thanks to Paolo Bonzini Signed-off-by: Nikolay Nikolaev Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Paolo Bonzini --- hw/virtio/vhost-user.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index 38e580642f..3d2321865b 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -216,7 +216,9 @@ static int vhost_user_call(struct vhost_dev *dev, unsigned long int request, case VHOST_SET_MEM_TABLE: for (i = 0; i < dev->mem->nregions; ++i) { struct vhost_memory_region *reg = dev->mem->regions + i; - fd = qemu_get_ram_fd(reg->guest_phys_addr); + ram_addr_t ram_addr; + qemu_ram_addr_from_host((void *)reg->userspace_addr, &ram_addr); + fd = qemu_get_ram_fd(ram_addr); if (fd > 0) { msg.memory.regions[fd_num].userspace_addr = reg->userspace_addr; msg.memory.regions[fd_num].memory_size = reg->memory_size; From d6970e3b004a5b339abfe8adb0d70585dc8b7d6d Mon Sep 17 00:00:00 2001 From: Nikolay Nikolaev Date: Sat, 12 Jul 2014 04:43:19 +0300 Subject: [PATCH 6/7] qtest: Adapt vhost-user-test to latest vhost-user changes A new field mmap_offset was added in the vhost-user message, we need to reflect this change in the test too. Signed-off-by: Nikolay Nikolaev Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/vhost-user-test.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tests/vhost-user-test.c b/tests/vhost-user-test.c index 406ba70941..75fedf0977 100644 --- a/tests/vhost-user-test.c +++ b/tests/vhost-user-test.c @@ -76,6 +76,7 @@ typedef struct VhostUserMemoryRegion { uint64_t guest_phys_addr; uint64_t memory_size; uint64_t userspace_addr; + uint64_t mmap_offset; } VhostUserMemoryRegion; typedef struct VhostUserMemory { @@ -205,6 +206,7 @@ static void read_guest_mem(void) uint32_t *guest_mem; gint64 end_time; int i, j; + size_t size; g_mutex_lock(data_mutex); @@ -231,8 +233,13 @@ static void read_guest_mem(void) g_assert_cmpint(memory.regions[i].memory_size, >, 1024); - guest_mem = mmap(0, memory.regions[i].memory_size, - PROT_READ | PROT_WRITE, MAP_SHARED, fds[i], 0); + size = memory.regions[i].memory_size + memory.regions[i].mmap_offset; + + guest_mem = mmap(0, size, PROT_READ | PROT_WRITE, + MAP_SHARED, fds[i], 0); + + g_assert(guest_mem != MAP_FAILED); + guest_mem += (memory.regions[i].mmap_offset / sizeof(*guest_mem)); for (j = 0; j < 256; j++) { uint32_t a = readl(memory.regions[i].guest_phys_addr + j*4); From cd98639f673d92836b6b5fd60279b411748f2f1e Mon Sep 17 00:00:00 2001 From: "Michael S. Tsirkin" Date: Fri, 18 Jul 2014 02:22:24 +0300 Subject: [PATCH 7/7] vhost-user: minor cleanups assert to verify cast does not discard information minor style fixup. Signed-off-by: Michael S. Tsirkin --- hw/virtio/vhost-user.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index 3d2321865b..4e88d9c5e9 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -217,7 +217,9 @@ static int vhost_user_call(struct vhost_dev *dev, unsigned long int request, for (i = 0; i < dev->mem->nregions; ++i) { struct vhost_memory_region *reg = dev->mem->regions + i; ram_addr_t ram_addr; - qemu_ram_addr_from_host((void *)reg->userspace_addr, &ram_addr); + + assert((uintptr_t)reg->userspace_addr == reg->userspace_addr); + qemu_ram_addr_from_host((void *)(uintptr_t)reg->userspace_addr, &ram_addr); fd = qemu_get_ram_fd(ram_addr); if (fd > 0) { msg.memory.regions[fd_num].userspace_addr = reg->userspace_addr;