From 9359d0e65e68551f10f74d0c827f9c8fdb5d799d Mon Sep 17 00:00:00 2001 From: Anthony Liguori Date: Thu, 16 Jul 2009 18:10:53 -0500 Subject: Update version for 0.11.0-rc0 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 02daa1b60..40a85edc3 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.10.50 +0.10.90 -- cgit v1.2.3 From 3b72617c9a8039fb6a08dd0b212bb916cc597d54 Mon Sep 17 00:00:00 2001 From: Aurelien Jarno Date: Sat, 18 Jul 2009 11:15:40 +0200 Subject: tcg: Fix tcg_gen_rotr_i64 Reported-by: Laurent Desnogues Signed-off-by: Aurelien Jarno --- tcg/tcg-op.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tcg/tcg-op.h b/tcg/tcg-op.h index daeb025a6..f3f2f711f 100644 --- a/tcg/tcg-op.h +++ b/tcg/tcg-op.h @@ -1749,7 +1749,7 @@ static inline void tcg_gen_rotr_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) t0 = tcg_temp_new_i64(); t1 = tcg_temp_new_i64(); - tcg_gen_shl_i64(t0, arg1, arg2); + tcg_gen_shr_i64(t0, arg1, arg2); tcg_gen_subfi_i64(t1, 64, arg2); tcg_gen_shl_i64(t1, arg1, t1); tcg_gen_or_i64(ret, t0, t1); -- cgit v1.2.3 From 6f40c941bd9782fec6af7759f031b49b939009b1 Mon Sep 17 00:00:00 2001 From: malc Date: Fri, 17 Jul 2009 05:57:04 +0400 Subject: Ignore -Waddress for alsaaudio.c /usr/include/alsa/pcm.h contains: #define snd_pcm_sw_params_alloca(ptr) do { assert(ptr); *ptr = (snd_pcm_sw_params_t *) alloca(snd_pcm_sw_params_sizeof()); memset(*ptr, 0, snd_pcm_sw_params_sizeof()); } while (0) The assert generates: "error: the address of 'sw_params' will always evaluate as 'true'" which combined with -Werror prevents alsaaudio.o from being built with certain versions of GCC. --- audio/alsaaudio.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/audio/alsaaudio.c b/audio/alsaaudio.c index f1d573a8f..d0b7cd0bd 100644 --- a/audio/alsaaudio.c +++ b/audio/alsaaudio.c @@ -25,6 +25,10 @@ #include "qemu-common.h" #include "audio.h" +#if QEMU_GNUC_PREREQ(4, 3) +#pragma GCC diagnostic ignored "-Waddress" +#endif + #define AUDIO_CAP "alsa" #include "audio_int.h" -- cgit v1.2.3 From 1eebab9835c1700cf52eef5886edab931bb1226e Mon Sep 17 00:00:00 2001 From: Anthony Liguori Date: Thu, 16 Jul 2009 21:33:48 -0500 Subject: Initialize cpuid variables This causes a build break when !KVM. Signed-off-by: Anthony Liguori --- target-i386/helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target-i386/helper.c b/target-i386/helper.c index 690d7735e..5f335331b 100644 --- a/target-i386/helper.c +++ b/target-i386/helper.c @@ -297,7 +297,7 @@ static void host_cpuid(uint32_t function, uint32_t count, uint32_t *eax, static int cpu_x86_fill_model_id(char *str) { - uint32_t eax, ebx, ecx, edx; + uint32_t eax = 0, ebx = 0, ecx = 0, edx = 0; int i; for (i = 0; i < 3; i++) { -- cgit v1.2.3 From 8fe7911401747e3687e7215140a81d671d7f789a Mon Sep 17 00:00:00 2001 From: Anthony Liguori Date: Thu, 16 Jul 2009 22:20:22 -0500 Subject: Only allow -cpu host when KVM is enabled -cpu host is not at all useful when using tcg. Signed-off-by: Anthony Liguori --- target-i386/helper.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/target-i386/helper.c b/target-i386/helper.c index 5f335331b..dd898852c 100644 --- a/target-i386/helper.c +++ b/target-i386/helper.c @@ -358,11 +358,10 @@ static int cpu_x86_find_by_name(x86_def_t *x86_cpu_def, const char *cpu_model) break; } } - if (!def) { - if (strcmp(name, "host") != 0) { - goto error; - } + if (kvm_enabled() && strcmp(name, "host") == 0) { cpu_x86_fill_host(x86_cpu_def); + } else if (!def) { + goto error; } else { memcpy(x86_cpu_def, def, sizeof(*def)); } -- cgit v1.2.3 From 22528739c959b461955501bdfe04c6a1ff756ed0 Mon Sep 17 00:00:00 2001 From: Paul Brook Date: Fri, 17 Jul 2009 11:21:12 +0100 Subject: ARM host fixes Minor TCG cleanups and warning fixes for ARM hosts. Signed-off-by: Paul Brook --- tcg/arm/tcg-target.c | 2 +- tcg/arm/tcg-target.h | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tcg/arm/tcg-target.c b/tcg/arm/tcg-target.c index 8139da10c..1edcd103f 100644 --- a/tcg/arm/tcg-target.c +++ b/tcg/arm/tcg-target.c @@ -1567,7 +1567,7 @@ static inline void tcg_out_st(TCGContext *s, TCGType type, int arg, tcg_out_st32(s, COND_AL, arg, arg1, arg2); } -void tcg_out_addi(TCGContext *s, int reg, tcg_target_long val) +static void tcg_out_addi(TCGContext *s, int reg, tcg_target_long val) { if (val > 0) if (val < 0x100) diff --git a/tcg/arm/tcg-target.h b/tcg/arm/tcg-target.h index 8f5016fc4..78ab8fd3e 100644 --- a/tcg/arm/tcg-target.h +++ b/tcg/arm/tcg-target.h @@ -51,9 +51,10 @@ enum { TCG_REG_R12, TCG_REG_R13, TCG_REG_R14, - TCG_TARGET_NB_REGS }; +#define TCG_TARGET_NB_REGS 15 + /* used for function call generation */ #define TCG_REG_CALL_STACK TCG_REG_R13 #define TCG_TARGET_STACK_ALIGN 8 @@ -69,8 +70,7 @@ enum { static inline void flush_icache_range(unsigned long start, unsigned long stop) { #if QEMU_GNUC_PREREQ(4, 1) - void __clear_cache(char *beg, char *end); - __clear_cache((char *) start, (char *) stop); + __builtin___clear_cache((char *) start, (char *) stop); #else register unsigned long _beg __asm ("a1") = start; register unsigned long _end __asm ("a2") = stop; -- cgit v1.2.3 From e93d914384e3d37fa7965dea95b51cc7459832a0 Mon Sep 17 00:00:00 2001 From: Blue Swirl Date: Fri, 17 Jul 2009 11:01:45 +0000 Subject: Fix OpenBSD build The header sys-queue.h must be #included early, otherwise at some point OS queue macros will be used. On OpenBSD, those don't define TAILQ_FOREACH_SAFE. Signed-off-by: Blue Swirl --- vl.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/vl.c b/vl.c index f4756931c..ce213c2cd 100644 --- a/vl.c +++ b/vl.c @@ -31,6 +31,8 @@ /* Needed early for HOST_BSD etc. */ #include "config-host.h" +/* Needed early to override system queue definitions on BSD */ +#include "sys-queue.h" #ifndef _WIN32 #include -- cgit v1.2.3 From 0412e2bab12656d007d926ce6dd869c12eab5c81 Mon Sep 17 00:00:00 2001 From: Blue Swirl Date: Fri, 17 Jul 2009 11:01:47 +0000 Subject: Fix sparc-softmmu breakage by ee6847d19be16c789b8bd4e553b7cd6701ba1245 Move the qdev_init(dev); call after the setting of d->size. Thanks to Filip Navara. Signed-off-by: Blue Swirl --- hw/sun4m.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/sun4m.c b/hw/sun4m.c index 4954ba37d..c810b3598 100644 --- a/hw/sun4m.c +++ b/hw/sun4m.c @@ -510,11 +510,11 @@ static void ram_init(target_phys_addr_t addr, ram_addr_t RAM_size, exit(1); } dev = qdev_create(NULL, "memory"); - qdev_init(dev); s = sysbus_from_qdev(dev); d = FROM_SYSBUS(RamDevice, s); d->size = RAM_size; + qdev_init(dev); sysbus_mmio_map(s, 0, addr); } -- cgit v1.2.3 From 8149632ad0e411a8977a650594357a384bfc60ef Mon Sep 17 00:00:00 2001 From: Blue Swirl Date: Fri, 17 Jul 2009 11:01:48 +0000 Subject: Sparc32: fix fdc io_base On some Sparc32 machines, fdc is located above 4G limit, so uint32_t is not appropriate type for io_base. Signed-off-by: Blue Swirl --- hw/fdc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/fdc.c b/hw/fdc.c index fa154a30c..4ad5e5ee8 100644 --- a/hw/fdc.c +++ b/hw/fdc.c @@ -33,6 +33,7 @@ #include "qemu-timer.h" #include "isa.h" #include "sysbus.h" +#include "qdev-addr.h" /********************************************************/ /* debug Floppy devices */ @@ -1972,7 +1973,7 @@ static SysBusDeviceInfo fdc_info = { .qdev.props = (Property[]) { { .name = "io_base", - .info = &qdev_prop_uint32, + .info = &qdev_prop_taddr, .offset = offsetof(fdctrl_t, io_base), }, { -- cgit v1.2.3 From 462eb7f81e5e4c76c9bfae800322dbd09ddd4771 Mon Sep 17 00:00:00 2001 From: Blue Swirl Date: Fri, 17 Jul 2009 11:01:49 +0000 Subject: Sparc32: fix escc devices broken by ee6847d19be16c789b8bd4e553b7cd6701ba1245 The logic of Zilog makes channel B the first device and channel A the second one. Signed-off-by: Blue Swirl --- hw/escc.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hw/escc.c b/hw/escc.c index 9abd092ae..2264f5d3a 100644 --- a/hw/escc.c +++ b/hw/escc.c @@ -970,22 +970,22 @@ static SysBusDeviceInfo escc_info = { { .name = "chrB", .info = &qdev_prop_ptr, - .offset = offsetof(SerialState, chn[1].chr), + .offset = offsetof(SerialState, chn[0].chr), }, { .name = "chrA", .info = &qdev_prop_ptr, - .offset = offsetof(SerialState, chn[0].chr), + .offset = offsetof(SerialState, chn[1].chr), }, { .name = "chnBtype", .info = &qdev_prop_uint32, - .offset = offsetof(SerialState, chn[1].type), + .offset = offsetof(SerialState, chn[0].type), }, { .name = "chnAtype", .info = &qdev_prop_uint32, - .offset = offsetof(SerialState, chn[0].type), + .offset = offsetof(SerialState, chn[1].type), }, {/* end of list */} } -- cgit v1.2.3 From 344a1d16f2530ddfdbc49333308a48f6d7db656a Mon Sep 17 00:00:00 2001 From: Blue Swirl Date: Fri, 17 Jul 2009 11:01:50 +0000 Subject: Sparc32: use hex for version numbers 0x10000000 looks better than 268435456. Signed-off-by: Blue Swirl --- hw/eccmemctl.c | 2 +- hw/iommu.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/eccmemctl.c b/hw/eccmemctl.c index c5d644908..dca397d1c 100644 --- a/hw/eccmemctl.c +++ b/hw/eccmemctl.c @@ -358,7 +358,7 @@ static SysBusDeviceInfo ecc_info = { .qdev.props = (Property[]) { { .name = "version", - .info = &qdev_prop_uint32, + .info = &qdev_prop_hex32, .offset = offsetof(ECCState, version), .defval = (uint32_t[]) { -1 }, }, diff --git a/hw/iommu.c b/hw/iommu.c index abf517f1d..d73dad3e1 100644 --- a/hw/iommu.c +++ b/hw/iommu.c @@ -406,7 +406,7 @@ static SysBusDeviceInfo iommu_info = { .qdev.props = (Property[]) { { .name = "version", - .info = &qdev_prop_uint32, + .info = &qdev_prop_hex32, .offset = offsetof(IOMMUState, version), }, {/* end of property list */} -- cgit v1.2.3 From 0d0e17cf2572ec5f87cb300436ad8d94461b7ccf Mon Sep 17 00:00:00 2001 From: Blue Swirl Date: Fri, 17 Jul 2009 11:18:53 +0000 Subject: Suppress a Sparse warning Move the export to a file used by both qdev.c and sysbus.c. Signed-off-by: Blue Swirl --- hw/qdev.c | 1 - hw/qdev.h | 3 +++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/hw/qdev.c b/hw/qdev.c index 001c74ce0..faecc767a 100644 --- a/hw/qdev.c +++ b/hw/qdev.c @@ -32,7 +32,6 @@ /* This is a nasty hack to allow passing a NULL bus to qdev_create. */ static BusState *main_system_bus; -extern struct BusInfo system_bus_info; static DeviceInfo *device_info_list; diff --git a/hw/qdev.h b/hw/qdev.h index 11744fa53..59ac8dc51 100644 --- a/hw/qdev.h +++ b/hw/qdev.h @@ -162,4 +162,7 @@ void qdev_prop_set_defaults(DeviceState *dev, Property *props); void qdev_prop_register_compat(CompatProperty *props); void qdev_prop_set_compat(DeviceState *dev); +/* This is a nasty hack to allow passing a NULL bus to qdev_create. */ +extern struct BusInfo system_bus_info; + #endif -- cgit v1.2.3 From c3862e8d082327d32c72a5188ea0629ab56c09ec Mon Sep 17 00:00:00 2001 From: Christoph Egger Date: Fri, 17 Jul 2009 17:48:01 +0000 Subject: fix build warnings Hi! Attached patch fixes build warnings due to use of different pointer signedness. Signed-off-by: Christoph Egger -- ---to satisfy European Law for business letters: Advanced Micro Devices GmbH Karl-Hammerschmidt-Str. 34, 85609 Dornach b. Muenchen Geschaeftsfuehrer: Thomas M. McCoy, Giuliano Meroni Sitz: Dornach, Gemeinde Aschheim, Landkreis Muenchen Registergericht Muenchen, HRB Nr. 43632 --- bsd-user/elfload.c | 2 +- bsd-user/uaccess.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bsd-user/elfload.c b/bsd-user/elfload.c index de7b4de7d..ed25e8519 100644 --- a/bsd-user/elfload.c +++ b/bsd-user/elfload.c @@ -1295,7 +1295,7 @@ int load_elf_binary(struct linux_binprm * bprm, struct target_pt_regs * regs, } if (interp_elf_ex.e_ident[0] != 0x7f || - strncmp(&interp_elf_ex.e_ident[1], "ELF",3) != 0) { + strncmp((char *)&interp_elf_ex.e_ident[1], "ELF",3) != 0) { interpreter_type &= ~INTERPRETER_ELF; } diff --git a/bsd-user/uaccess.c b/bsd-user/uaccess.c index 9ec1b2343..677f19c26 100644 --- a/bsd-user/uaccess.c +++ b/bsd-user/uaccess.c @@ -51,7 +51,7 @@ abi_long target_strlen(abi_ulong guest_addr1) ptr = lock_user(VERIFY_READ, guest_addr, max_len, 1); if (!ptr) return -TARGET_EFAULT; - len = qemu_strnlen(ptr, max_len); + len = qemu_strnlen((char *)ptr, max_len); unlock_user(ptr, guest_addr, 0); guest_addr += len; /* we don't allow wrapping or integer overflow */ -- cgit v1.2.3 From b19bb78c2fa4d388b6c0d89bf6f9ad3e450b8d12 Mon Sep 17 00:00:00 2001 From: Christoph Egger Date: Fri, 17 Jul 2009 17:48:02 +0000 Subject: isxdigit -> qemu_isxdigit Hi! Attached patch uses qemu_isxdigit() instead of isxdigit(). Fixes build warning on NetBSD. Signed-off-by: Christoph Egger -- ---to satisfy European Law for business letters: Advanced Micro Devices GmbH Karl-Hammerschmidt-Str. 34, 85609 Dornach b. Muenchen Geschaeftsfuehrer: Thomas M. McCoy, Giuliano Meroni Sitz: Dornach, Gemeinde Aschheim, Landkreis Muenchen Registergericht Muenchen, HRB Nr. 43632 --- hw/qdev-properties.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c index 06c25aff7..76699b08b 100644 --- a/hw/qdev-properties.c +++ b/hw/qdev-properties.c @@ -117,9 +117,9 @@ static int parse_mac(DeviceState *dev, Property *prop, const char *str) char *p; for (i = 0, pos = 0; i < 6; i++, pos += 3) { - if (!isxdigit(str[pos])) + if (!qemu_isxdigit(str[pos])) return -1; - if (!isxdigit(str[pos+1])) + if (!qemu_isxdigit(str[pos+1])) return -1; if (i == 5 && str[pos+2] != '\0') return -1; -- cgit v1.2.3 From b2b2d9dd2d07993fb92f2aebdce4f4729be7b6c1 Mon Sep 17 00:00:00 2001 From: Blue Swirl Date: Mon, 20 Jul 2009 10:37:51 +0000 Subject: Fix build with DEBUG_PCI in pci_host.h enabled Signed-off-by: Blue Swirl --- hw/ppce500_pci.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/hw/ppce500_pci.c b/hw/ppce500_pci.c index 1a8a6c995..5b4673a82 100644 --- a/hw/ppce500_pci.c +++ b/hw/ppce500_pci.c @@ -89,8 +89,8 @@ static uint32_t pcie500_cfgaddr_readl(void *opaque, target_phys_addr_t addr) { PPCE500PCIState *pci = opaque; - pci_debug("%s: (addr:%Lx) -> value:%x\n", __func__, addr, - pci->pci_state.config_reg); + pci_debug("%s: (addr:" TARGET_FMT_plx ") -> value:%x\n", __func__, addr, + pci->pci_state.config_reg); return pci->pci_state.config_reg; } @@ -105,7 +105,8 @@ static void pcie500_cfgaddr_writel(void *opaque, target_phys_addr_t addr, { PPCE500PCIState *controller = opaque; - pci_debug("%s: value:%x -> (addr%Lx)\n", __func__, value, addr); + pci_debug("%s: value:%x -> (addr:" TARGET_FMT_plx ")\n", __func__, value, + addr); controller->pci_state.config_reg = value & ~0x3; } @@ -169,7 +170,8 @@ static uint32_t pci_reg_read4(void *opaque, target_phys_addr_t addr) break; } - pci_debug("%s: win:%lx(addr:%Lx) -> value:%x\n",__func__,win,addr,value); + pci_debug("%s: win:%lx(addr:" TARGET_FMT_plx ") -> value:%x\n", __func__, + win, addr, value); return value; } @@ -187,7 +189,8 @@ static void pci_reg_write4(void *opaque, target_phys_addr_t addr, win = addr & 0xfe0; - pci_debug("%s: value:%x -> win:%lx(addr:%Lx)\n",__func__,value,win,addr); + pci_debug("%s: value:%x -> win:%lx(addr:" TARGET_FMT_plx ")\n", + __func__, value, win, addr); switch (win) { case PPCE500_PCI_OW1: -- cgit v1.2.3 From dd500a9241f4b7ac12c737fe5f929a53bd965e47 Mon Sep 17 00:00:00 2001 From: Blue Swirl Date: Mon, 20 Jul 2009 17:19:25 +0000 Subject: Fix most warnings (errors with -Werror) when debugging is enabled I used the following command to enable debugging: perl -p -i -e 's/^\/\/#define DEBUG/#define DEBUG/g' * */* */*/* Signed-off-by: Blue Swirl --- block/qcow2-refcount.c | 4 ++-- block/raw-posix.c | 1 + buffered_file.c | 4 ++-- exec.c | 25 +++---------------------- hw/cirrus_vga.c | 5 +++-- hw/i8259.c | 1 + hw/openpic.c | 31 +++++++++++++++---------------- hw/ppc_prep.c | 3 ++- hw/scsi-disk.c | 12 ++++++------ hw/slavio_timer.c | 8 ++++---- hw/sun4c_intctl.c | 7 +++---- hw/usb-ohci.c | 4 ++-- hw/usb-uhci.c | 2 +- hw/vga.c | 12 ++++++------ linux-user/mmap.c | 16 +++++++++------- linux-user/signal.c | 4 ++-- linux-user/syscall.c | 2 +- qemu-tool.c | 3 +++ target-ppc/helper.c | 20 ++++++++++---------- target-sparc/helper.c | 20 ++++++++++---------- target-sparc/op_helper.c | 14 +++++++++----- 21 files changed, 95 insertions(+), 103 deletions(-) diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index e6c857e08..0aac2edee 100644 --- a/block/qcow2-refcount.c +++ b/block/qcow2-refcount.c @@ -277,7 +277,7 @@ static int update_refcount(BlockDriverState *bs, int first_index = -1, last_index = -1; #ifdef DEBUG_ALLOC2 - printf("update_refcount: offset=%lld size=%lld addend=%d\n", + printf("update_refcount: offset=%" PRId64 " size=%" PRId64 " addend=%d\n", offset, length, addend); #endif if (length <= 0) @@ -380,7 +380,7 @@ retry: goto retry; } #ifdef DEBUG_ALLOC2 - printf("alloc_clusters: size=%lld -> %lld\n", + printf("alloc_clusters: size=%" PRId64 " -> %" PRId64 "\n", size, (s->free_cluster_index - nb_clusters) << s->cluster_bits); #endif diff --git a/block/raw-posix.c b/block/raw-posix.c index 389903e44..3e1a87532 100644 --- a/block/raw-posix.c +++ b/block/raw-posix.c @@ -24,6 +24,7 @@ #include "qemu-common.h" #include "qemu-timer.h" #include "qemu-char.h" +#include "qemu-log.h" #include "block_int.h" #include "module.h" #ifdef CONFIG_AIO diff --git a/buffered_file.c b/buffered_file.c index 364b912f2..63de17d8f 100644 --- a/buffered_file.c +++ b/buffered_file.c @@ -113,7 +113,7 @@ static int buffered_put_buffer(void *opaque, const uint8_t *buf, int64_t pos, in int offset = 0; ssize_t ret; - dprintf("putting %ld bytes at %Ld\n", size, pos); + dprintf("putting %d bytes at %" PRId64 "\n", size, pos); if (s->has_error) { dprintf("flush when error, bailing\n"); @@ -151,7 +151,7 @@ static int buffered_put_buffer(void *opaque, const uint8_t *buf, int64_t pos, in } if (offset >= 0) { - dprintf("buffering %ld bytes\n", size - offset); + dprintf("buffering %d bytes\n", size - offset); buffered_append(s, buf + offset, size - offset); offset = size; } diff --git a/exec.c b/exec.c index 65c89b08b..7d3eb1ada 100644 --- a/exec.c +++ b/exec.c @@ -655,7 +655,8 @@ static void tb_invalidate_check(target_ulong address) for(tb = tb_phys_hash[i]; tb != NULL; tb = tb->phys_hash_next) { if (!(address + TARGET_PAGE_SIZE <= tb->pc || address >= tb->pc + tb->size)) { - printf("ERROR invalidate: address=%08lx PC=%08lx size=%04x\n", + printf("ERROR invalidate: address=" TARGET_FMT_lx + " PC=%08lx size=%04x\n", address, (long)tb->pc, tb->size); } } @@ -680,26 +681,6 @@ static void tb_page_check(void) } } -static void tb_jmp_check(TranslationBlock *tb) -{ - TranslationBlock *tb1; - unsigned int n1; - - /* suppress any remaining jumps to this TB */ - tb1 = tb->jmp_first; - for(;;) { - n1 = (long)tb1 & 3; - tb1 = (TranslationBlock *)((long)tb1 & ~3); - if (n1 == 2) - break; - tb1 = tb1->jmp_next[n1]; - } - /* check end of list */ - if (tb1 != tb) { - printf("ERROR: jmp_list from 0x%08lx\n", (long)tb); - } -} - #endif /* invalidate one TB */ @@ -2939,7 +2920,7 @@ static int subpage_register (subpage_t *mmio, uint32_t start, uint32_t end, idx = SUBPAGE_IDX(start); eidx = SUBPAGE_IDX(end); #if defined(DEBUG_SUBPAGE) - printf("%s: %p start %08x end %08x idx %08x eidx %08x mem %d\n", __func__, + printf("%s: %p start %08x end %08x idx %08x eidx %08x mem %ld\n", __func__, mmio, start, end, idx, eidx, memory); #endif memory >>= IO_MEM_SHIFT; diff --git a/hw/cirrus_vga.c b/hw/cirrus_vga.c index 902b3ee82..0460f9713 100644 --- a/hw/cirrus_vga.c +++ b/hw/cirrus_vga.c @@ -2029,7 +2029,7 @@ static uint32_t cirrus_vga_mem_readb(void *opaque, target_phys_addr_t addr) } else { val = 0xff; #ifdef DEBUG_CIRRUS - printf("cirrus: mem_readb %06x\n", addr); + printf("cirrus: mem_readb " TARGET_FMT_plx "\n", addr); #endif } return val; @@ -2124,7 +2124,8 @@ static void cirrus_vga_mem_writeb(void *opaque, target_phys_addr_t addr, } } else { #ifdef DEBUG_CIRRUS - printf("cirrus: mem_writeb %06x value %02x\n", addr, mem_value); + printf("cirrus: mem_writeb " TARGET_FMT_plx " value %02x\n", addr, + mem_value); #endif } } diff --git a/hw/i8259.c b/hw/i8259.c index adabd2b72..0b9fab5b4 100644 --- a/hw/i8259.c +++ b/hw/i8259.c @@ -25,6 +25,7 @@ #include "pc.h" #include "isa.h" #include "monitor.h" +#include "qemu-timer.h" /* debug PIC */ //#define DEBUG_PIC diff --git a/hw/openpic.c b/hw/openpic.c index baa7ecc28..f50031dd5 100644 --- a/hw/openpic.c +++ b/hw/openpic.c @@ -592,7 +592,7 @@ static void openpic_gbl_write (void *opaque, target_phys_addr_t addr, uint32_t v IRQ_dst_t *dst; int idx; - DPRINTF("%s: addr %08x <= %08x\n", __func__, addr, val); + DPRINTF("%s: addr " TARGET_FMT_plx " <= %08x\n", __func__, addr, val); if (addr & 0xF) return; #if defined TARGET_WORDS_BIGENDIAN @@ -651,7 +651,7 @@ static uint32_t openpic_gbl_read (void *opaque, target_phys_addr_t addr) openpic_t *opp = opaque; uint32_t retval; - DPRINTF("%s: addr %08x\n", __func__, addr); + DPRINTF("%s: addr " TARGET_FMT_plx "\n", __func__, addr); retval = 0xFFFFFFFF; if (addr & 0xF) return retval; @@ -824,7 +824,7 @@ static void openpic_cpu_write (void *opaque, target_phys_addr_t addr, uint32_t v IRQ_dst_t *dst; int idx, s_IRQ, n_IRQ; - DPRINTF("%s: addr %08x <= %08x\n", __func__, addr, val); + DPRINTF("%s: addr " TARGET_FMT_plx " <= %08x\n", __func__, addr, val); if (addr & 0xF) return; #if defined TARGET_WORDS_BIGENDIAN @@ -886,7 +886,7 @@ static uint32_t openpic_cpu_read (void *opaque, target_phys_addr_t addr) uint32_t retval; int idx, n_IRQ; - DPRINTF("%s: addr %08x\n", __func__, addr); + DPRINTF("%s: addr " TARGET_FMT_plx "\n", __func__, addr); retval = 0xFFFFFFFF; if (addr & 0xF) return retval; @@ -1264,8 +1264,7 @@ qemu_irq *openpic_init (PCIBus *bus, int *pmem_index, int nb_cpus, static void mpic_irq_raise(openpic_t *mpp, int n_CPU, IRQ_src_t *src) { int n_ci = IDR_CI0 - n_CPU; - DPRINTF("%s: cpu:%d irq:%d (testbit idr:%x ci:%d)\n", __func__, - n_CPU, n_IRQ, mpp->src[n_IRQ].ide, n_ci); + if(test_bit(&src->ide, n_ci)) { qemu_irq_raise(mpp->dst[n_CPU].irqs[OPENPIC_OUTPUT_CINT]); } @@ -1313,7 +1312,7 @@ static void mpic_timer_write (void *opaque, target_phys_addr_t addr, uint32_t va openpic_t *mpp = opaque; int idx, cpu; - DPRINTF("%s: addr %08x <= %08x\n", __func__, addr, val); + DPRINTF("%s: addr " TARGET_FMT_plx " <= %08x\n", __func__, addr, val); if (addr & 0xF) return; addr &= 0xFFFF; @@ -1347,7 +1346,7 @@ static uint32_t mpic_timer_read (void *opaque, target_phys_addr_t addr) uint32_t retval; int idx, cpu; - DPRINTF("%s: addr %08x\n", __func__, addr); + DPRINTF("%s: addr " TARGET_FMT_plx "\n", __func__, addr); retval = 0xFFFFFFFF; if (addr & 0xF) return retval; @@ -1382,7 +1381,7 @@ static void mpic_src_ext_write (void *opaque, target_phys_addr_t addr, openpic_t *mpp = opaque; int idx = MPIC_EXT_IRQ; - DPRINTF("%s: addr %08x <= %08x\n", __func__, addr, val); + DPRINTF("%s: addr " TARGET_FMT_plx " <= %08x\n", __func__, addr, val); if (addr & 0xF) return; @@ -1405,7 +1404,7 @@ static uint32_t mpic_src_ext_read (void *opaque, target_phys_addr_t addr) uint32_t retval; int idx = MPIC_EXT_IRQ; - DPRINTF("%s: addr %08x\n", __func__, addr); + DPRINTF("%s: addr " TARGET_FMT_plx "\n", __func__, addr); retval = 0xFFFFFFFF; if (addr & 0xF) return retval; @@ -1432,7 +1431,7 @@ static void mpic_src_int_write (void *opaque, target_phys_addr_t addr, openpic_t *mpp = opaque; int idx = MPIC_INT_IRQ; - DPRINTF("%s: addr %08x <= %08x\n", __func__, addr, val); + DPRINTF("%s: addr " TARGET_FMT_plx " <= %08x\n", __func__, addr, val); if (addr & 0xF) return; @@ -1455,7 +1454,7 @@ static uint32_t mpic_src_int_read (void *opaque, target_phys_addr_t addr) uint32_t retval; int idx = MPIC_INT_IRQ; - DPRINTF("%s: addr %08x\n", __func__, addr); + DPRINTF("%s: addr " TARGET_FMT_plx "\n", __func__, addr); retval = 0xFFFFFFFF; if (addr & 0xF) return retval; @@ -1482,7 +1481,7 @@ static void mpic_src_msg_write (void *opaque, target_phys_addr_t addr, openpic_t *mpp = opaque; int idx = MPIC_MSG_IRQ; - DPRINTF("%s: addr %08x <= %08x\n", __func__, addr, val); + DPRINTF("%s: addr " TARGET_FMT_plx " <= %08x\n", __func__, addr, val); if (addr & 0xF) return; @@ -1505,7 +1504,7 @@ static uint32_t mpic_src_msg_read (void *opaque, target_phys_addr_t addr) uint32_t retval; int idx = MPIC_MSG_IRQ; - DPRINTF("%s: addr %08x\n", __func__, addr); + DPRINTF("%s: addr " TARGET_FMT_plx "\n", __func__, addr); retval = 0xFFFFFFFF; if (addr & 0xF) return retval; @@ -1532,7 +1531,7 @@ static void mpic_src_msi_write (void *opaque, target_phys_addr_t addr, openpic_t *mpp = opaque; int idx = MPIC_MSI_IRQ; - DPRINTF("%s: addr %08x <= %08x\n", __func__, addr, val); + DPRINTF("%s: addr " TARGET_FMT_plx " <= %08x\n", __func__, addr, val); if (addr & 0xF) return; @@ -1554,7 +1553,7 @@ static uint32_t mpic_src_msi_read (void *opaque, target_phys_addr_t addr) uint32_t retval; int idx = MPIC_MSI_IRQ; - DPRINTF("%s: addr %08x\n", __func__, addr); + DPRINTF("%s: addr " TARGET_FMT_plx "\n", __func__, addr); retval = 0xFFFFFFFF; if (addr & 0xF) return retval; diff --git a/hw/ppc_prep.c b/hw/ppc_prep.c index 7181181be..7a219778c 100644 --- a/hw/ppc_prep.c +++ b/hw/ppc_prep.c @@ -60,7 +60,8 @@ do { \ } \ } while (0) #elif defined (DEBUG_PPC_IO) -#define PPC_IO_DPRINTF(fmt, ...) qemu_log_mask(CPU_LOG_IOPORT, ## __VA_ARGS__) +#define PPC_IO_DPRINTF(fmt, ...) \ +qemu_log_mask(CPU_LOG_IOPORT, fmt, ## __VA_ARGS__) #else #define PPC_IO_DPRINTF(fmt, ...) do { } while (0) #endif diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c index a0485dbeb..8b6426fd8 100644 --- a/hw/scsi-disk.c +++ b/hw/scsi-disk.c @@ -172,7 +172,7 @@ static void scsi_read_complete(void * opaque, int ret) scsi_command_complete(r, STATUS_CHECK_CONDITION, SENSE_NO_SENSE); return; } - DPRINTF("Data ready tag=0x%x len=%d\n", r->tag, r->iov.iov_len); + DPRINTF("Data ready tag=0x%x len=%" PRId64 "\n", r->tag, r->iov.iov_len); s->completion(s->opaque, SCSI_REASON_DATA, r->tag, r->iov.iov_len); } @@ -192,7 +192,7 @@ static void scsi_read_data(SCSIDevice *d, uint32_t tag) return; } if (r->sector_count == (uint32_t)-1) { - DPRINTF("Read buf_len=%d\n", r->iov.iov_len); + DPRINTF("Read buf_len=%" PRId64 "\n", r->iov.iov_len); r->sector_count = 0; s->completion(s->opaque, SCSI_REASON_DATA, r->tag, r->iov.iov_len); return; @@ -777,7 +777,7 @@ static int32_t scsi_send_command(SCSIDevice *d, uint32_t tag, case 0x08: case 0x28: case 0x88: - DPRINTF("Read (sector %lld, count %d)\n", lba, len); + DPRINTF("Read (sector %" PRId64 ", count %d)\n", lba, len); if (lba > s->max_lba) goto illegal_lba; r->sector = lba * s->cluster_size; @@ -786,7 +786,7 @@ static int32_t scsi_send_command(SCSIDevice *d, uint32_t tag, case 0x0a: case 0x2a: case 0x8a: - DPRINTF("Write (sector %lld, count %d)\n", lba, len); + DPRINTF("Write (sector %" PRId64 ", count %d)\n", lba, len); if (lba > s->max_lba) goto illegal_lba; r->sector = lba * s->cluster_size; @@ -794,7 +794,7 @@ static int32_t scsi_send_command(SCSIDevice *d, uint32_t tag, is_write = 1; break; case 0x35: - DPRINTF("Synchronise cache (sector %d, count %d)\n", lba, len); + DPRINTF("Synchronise cache (sector %" PRId64 ", count %d)\n", lba, len); bdrv_flush(s->bdrv); break; case 0x43: @@ -896,7 +896,7 @@ static int32_t scsi_send_command(SCSIDevice *d, uint32_t tag, r->iov.iov_len = 16; break; case 0x2f: - DPRINTF("Verify (sector %d, count %d)\n", lba, len); + DPRINTF("Verify (sector %" PRId64 ", count %d)\n", lba, len); break; default: DPRINTF("Unknown SCSI command (%2.2x)\n", buf[0]); diff --git a/hw/slavio_timer.c b/hw/slavio_timer.c index 21924f871..69c9f3b67 100644 --- a/hw/slavio_timer.c +++ b/hw/slavio_timer.c @@ -197,8 +197,8 @@ static void slavio_timer_mem_writel(void *opaque, target_phys_addr_t addr, s->counthigh = val & (TIMER_MAX_COUNT64 >> 32); s->reached = 0; count = ((uint64_t)s->counthigh << 32) | s->count; - DPRINTF("processor %d user timer set to %016llx\n", s->slave_index, - count); + DPRINTF("processor %d user timer set to %016" PRIx64 "\n", + s->slave_index, count); if (s->timer) ptimer_set_count(s->timer, LIMIT_TO_PERIODS(s->limit - count)); } else { @@ -223,8 +223,8 @@ static void slavio_timer_mem_writel(void *opaque, target_phys_addr_t addr, s->count = val & TIMER_MAX_COUNT64; s->reached = 0; count = ((uint64_t)s->counthigh) << 32 | s->count; - DPRINTF("processor %d user timer set to %016llx\n", s->slave_index, - count); + DPRINTF("processor %d user timer set to %016" PRIx64 "\n", + s->slave_index, count); if (s->timer) ptimer_set_count(s->timer, LIMIT_TO_PERIODS(s->limit - count)); } else diff --git a/hw/sun4c_intctl.c b/hw/sun4c_intctl.c index 7eb84596b..1273213b4 100644 --- a/hw/sun4c_intctl.c +++ b/hw/sun4c_intctl.c @@ -107,9 +107,9 @@ void sun4c_irq_info(Monitor *mon, void *opaque) int64_t count; monitor_printf(mon, "IRQ statistics:\n"); - count = s->irq_count[i]; + count = s->irq_count; if (count > 0) - monitor_printf(mon, "%2d: %" PRId64 "\n", i, count); + monitor_printf(mon, " %" PRId64 "\n", count); #endif } @@ -121,7 +121,6 @@ static void sun4c_check_interrupts(void *opaque) uint32_t pil_pending; unsigned int i; - DPRINTF("pending %x disabled %x\n", pending, s->intregm_disabled); pil_pending = 0; if (s->pending && !(s->reg & 0x80000000)) { for (i = 0; i < 8; i++) { @@ -156,7 +155,7 @@ static void sun4c_set_irq(void *opaque, int irq, int level) if (pil > 0) { if (level) { #ifdef DEBUG_IRQ_COUNT - s->irq_count[pil]++; + s->irq_count++; #endif s->pending |= mask; } else { diff --git a/hw/usb-ohci.c b/hw/usb-ohci.c index 28ab3a915..4c42ec0de 100644 --- a/hw/usb-ohci.c +++ b/hw/usb-ohci.c @@ -905,7 +905,7 @@ static int ohci_service_td(OHCIState *ohci, struct ohci_ed *ed) flag_r = (td.flags & OHCI_TD_R) != 0; #ifdef DEBUG_PACKET - dprintf(" TD @ 0x%.8x %u bytes %s r=%d cbp=0x%.8x be=0x%.8x\n", + dprintf(" TD @ 0x%.8x %" PRId64 " bytes %s r=%d cbp=0x%.8x be=0x%.8x\n", addr, len, str, flag_r, td.cbp, td.be); if (len > 0 && dir != OHCI_TD_DIR_IN) { @@ -1677,7 +1677,7 @@ static void usb_ohci_init(OHCIState *ohci, int num_ports, int devfn, usb_bit_time = 1; } #endif - dprintf("usb-ohci: usb_bit_time=%lli usb_frame_time=%lli\n", + dprintf("usb-ohci: usb_bit_time=%" PRId64 " usb_frame_time=%" PRId64 "\n", usb_frame_time, usb_bit_time); } diff --git a/hw/usb-uhci.c b/hw/usb-uhci.c index 7b74207b5..a61887b44 100644 --- a/hw/usb-uhci.c +++ b/hw/usb-uhci.c @@ -72,7 +72,7 @@ #ifdef DEBUG #define dprintf printf -const char *pid2str(int pid) +static const char *pid2str(int pid) { switch (pid) { case USB_TOKEN_SETUP: return "SETUP"; diff --git a/hw/vga.c b/hw/vga.c index 403f6ff80..91a6852f2 100644 --- a/hw/vga.c +++ b/hw/vga.c @@ -799,7 +799,7 @@ void vga_mem_writeb(void *opaque, target_phys_addr_t addr, uint32_t val) uint32_t write_mask, bit_mask, set_mask; #ifdef DEBUG_VGA_MEM - printf("vga: [0x%x] = 0x%02x\n", addr, val); + printf("vga: [0x" TARGET_FMT_plx "] = 0x%02x\n", addr, val); #endif /* convert to VGA memory offset */ memory_map_mode = (s->gr[6] >> 2) & 3; @@ -832,7 +832,7 @@ void vga_mem_writeb(void *opaque, target_phys_addr_t addr, uint32_t val) if (s->sr[2] & mask) { s->vram_ptr[addr] = val; #ifdef DEBUG_VGA_MEM - printf("vga: chain4: [0x%x]\n", addr); + printf("vga: chain4: [0x" TARGET_FMT_plx "]\n", addr); #endif s->plane_updated |= mask; /* only used to detect font change */ cpu_physical_memory_set_dirty(s->vram_offset + addr); @@ -845,7 +845,7 @@ void vga_mem_writeb(void *opaque, target_phys_addr_t addr, uint32_t val) addr = ((addr & ~1) << 1) | plane; s->vram_ptr[addr] = val; #ifdef DEBUG_VGA_MEM - printf("vga: odd/even: [0x%x]\n", addr); + printf("vga: odd/even: [0x" TARGET_FMT_plx "]\n", addr); #endif s->plane_updated |= mask; /* only used to detect font change */ cpu_physical_memory_set_dirty(s->vram_offset + addr); @@ -919,10 +919,10 @@ void vga_mem_writeb(void *opaque, target_phys_addr_t addr, uint32_t val) (((uint32_t *)s->vram_ptr)[addr] & ~write_mask) | (val & write_mask); #ifdef DEBUG_VGA_MEM - printf("vga: latch: [0x%x] mask=0x%08x val=0x%08x\n", - addr * 4, write_mask, val); + printf("vga: latch: [0x" TARGET_FMT_plx "] mask=0x%08x val=0x%08x\n", + addr * 4, write_mask, val); #endif - cpu_physical_memory_set_dirty(s->vram_offset + (addr << 2)); + cpu_physical_memory_set_dirty(s->vram_offset + (addr << 2)); } } diff --git a/linux-user/mmap.c b/linux-user/mmap.c index 79cb4e605..e05caa0a1 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -145,8 +145,8 @@ int target_mprotect(abi_ulong start, abi_ulong len, int prot) int prot1, ret; #ifdef DEBUG_MMAP - printf("mprotect: start=0x" TARGET_FMT_lx - "len=0x" TARGET_FMT_lx " prot=%c%c%c\n", start, len, + printf("mprotect: start=0x" TARGET_ABI_FMT_lx + "len=0x" TARGET_ABI_FMT_lx " prot=%c%c%c\n", start, len, prot & PROT_READ ? 'r' : '-', prot & PROT_WRITE ? 'w' : '-', prot & PROT_EXEC ? 'x' : '-'); @@ -331,8 +331,8 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int prot, mmap_lock(); #ifdef DEBUG_MMAP { - printf("mmap: start=0x" TARGET_FMT_lx - " len=0x" TARGET_FMT_lx " prot=%c%c%c flags=", + printf("mmap: start=0x" TARGET_ABI_FMT_lx + " len=0x" TARGET_ABI_FMT_lx " prot=%c%c%c flags=", start, len, prot & PROT_READ ? 'r' : '-', prot & PROT_WRITE ? 'w' : '-', @@ -352,7 +352,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int prot, printf("[MAP_TYPE=0x%x] ", flags & MAP_TYPE); break; } - printf("fd=%d offset=" TARGET_FMT_lx "\n", fd, offset); + printf("fd=%d offset=" TARGET_ABI_FMT_lx "\n", fd, offset); } #endif @@ -523,7 +523,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int prot, page_set_flags(start, start + len, prot | PAGE_VALID); the_end: #ifdef DEBUG_MMAP - printf("ret=0x" TARGET_FMT_lx "\n", start); + printf("ret=0x" TARGET_ABI_FMT_lx "\n", start); page_dump(stdout); printf("\n"); #endif @@ -540,7 +540,9 @@ int target_munmap(abi_ulong start, abi_ulong len) int prot, ret; #ifdef DEBUG_MMAP - printf("munmap: start=0x%lx len=0x%lx\n", start, len); + printf("munmap: start=0x" TARGET_ABI_FMT_lx " len=0x" + TARGET_ABI_FMT_lx "\n", + start, len); #endif if (start & ~TARGET_PAGE_MASK) return -EINVAL; diff --git a/linux-user/signal.c b/linux-user/signal.c index 93c2ebe1e..1aa9eabee 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -584,8 +584,8 @@ int do_sigaction(int sig, const struct target_sigaction *act, return -EINVAL; k = &sigact_table[sig - 1]; #if defined(DEBUG_SIGNAL) - fprintf(stderr, "sigaction sig=%d act=0x%08x, oact=0x%08x\n", - sig, (int)act, (int)oact); + fprintf(stderr, "sigaction sig=%d act=0x%p, oact=0x%p\n", + sig, act, oact); #endif if (oact) { oact->_sa_handler = tswapl(k->_sa_handler); diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 8b0a5fa3f..7b5732388 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -6977,7 +6977,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, } fail: #ifdef DEBUG - gemu_log(" = %ld\n", ret); + gemu_log(" = " TARGET_ABI_FMT_ld "\n", ret); #endif if(do_strace) print_syscall_ret(num, ret); diff --git a/qemu-tool.c b/qemu-tool.c index c08f061be..ba24aa2a1 100644 --- a/qemu-tool.c +++ b/qemu-tool.c @@ -15,11 +15,14 @@ #include "monitor.h" #include "sysemu.h" #include "qemu-timer.h" +#include "qemu-log.h" #include QEMUClock *rt_clock; +FILE *logfile; + struct QEMUBH { QEMUBHFunc *cb; diff --git a/target-ppc/helper.c b/target-ppc/helper.c index bd9bc8a87..b7162dfe5 100644 --- a/target-ppc/helper.c +++ b/target-ppc/helper.c @@ -558,18 +558,18 @@ static always_inline int get_bat (CPUState *env, mmu_ctx_t *ctx, } if (ret < 0) { #if defined(DEBUG_BATS) - if (IS_LOGGING) { - QEMU_LOG0("no BAT match for " ADDRX ":\n", virtual); + if (qemu_log_enabled()) { + LOG_BATS("no BAT match for " ADDRX ":\n", virtual); for (i = 0; i < 4; i++) { BATu = &BATut[i]; BATl = &BATlt[i]; BEPIu = *BATu & 0xF0000000; BEPIl = *BATu & 0x0FFE0000; bl = (*BATu & 0x00001FFC) << 15; - QEMU_LOG0("%s: %cBAT%d v " ADDRX " BATu " ADDRX - " BATl " ADDRX " \n\t" ADDRX " " ADDRX " " ADDRX "\n", - __func__, type == ACCESS_CODE ? 'I' : 'D', i, virtual, - *BATu, *BATl, BEPIu, BEPIl, bl); + LOG_BATS("%s: %cBAT%d v " ADDRX " BATu " ADDRX + " BATl " ADDRX " \n\t" ADDRX " " ADDRX " " ADDRX "\n", + __func__, type == ACCESS_CODE ? 'I' : 'D', i, virtual, + *BATu, *BATl, BEPIu, BEPIl, bl); } } #endif @@ -860,8 +860,8 @@ void ppc_store_slb (CPUPPCState *env, target_ulong rb, target_ulong rs) slb->tmp = (vsid << 8) | (flags << 3); LOG_SLB("%s: %d " ADDRX " - " ADDRX " => %016" PRIx64 - " %08" PRIx32 "\n", __func__, - slb_nr, rb, rs, tmp64, tmp); + " %08" PRIx32 "\n", __func__, + slb_nr, rb, rs, slb->tmp64, slb->tmp); slb_set_entry(env, slb_nr, slb); } @@ -2445,7 +2445,7 @@ static always_inline void powerpc_excp (CPUState *env, tlb_miss: #if defined (DEBUG_SOFTWARE_TLB) if (qemu_log_enabled()) { - const unsigned char *es; + const char *es; target_ulong *miss, *cmp; int en; if (excp == POWERPC_EXCP_IFTLB) { @@ -2478,7 +2478,7 @@ static always_inline void powerpc_excp (CPUState *env, tlb_miss_74xx: #if defined (DEBUG_SOFTWARE_TLB) if (qemu_log_enabled()) { - const unsigned char *es; + const char *es; target_ulong *miss, *cmp; int en; if (excp == POWERPC_EXCP_IFTLB) { diff --git a/target-sparc/helper.c b/target-sparc/helper.c index 04513f82d..5951e6b5c 100644 --- a/target-sparc/helper.c +++ b/target-sparc/helper.c @@ -583,15 +583,15 @@ void dump_mmu(CPUState *env) break; } if ((env->dtlb_tte[i] & 0x8000000000000000ULL) != 0) { - printf("VA: " TARGET_FMT_lx ", PA: " TARGET_FMT_lx + printf("VA: %" PRIx64 ", PA: %" PRIx64 ", %s, %s, %s, %s, ctx %" PRId64 "\n", - env->dtlb_tag[i] & ~0x1fffULL, - env->dtlb_tte[i] & 0x1ffffffe000ULL, + env->dtlb_tag[i] & (uint64_t)~0x1fffULL, + env->dtlb_tte[i] & (uint64_t)0x1ffffffe000ULL, mask, env->dtlb_tte[i] & 0x4? "priv": "user", env->dtlb_tte[i] & 0x2? "RW": "RO", env->dtlb_tte[i] & 0x40? "locked": "unlocked", - env->dtlb_tag[i] & 0x1fffULL); + env->dtlb_tag[i] & (uint64_t)0x1fffULL); } } } @@ -616,14 +616,14 @@ void dump_mmu(CPUState *env) break; } if ((env->itlb_tte[i] & 0x8000000000000000ULL) != 0) { - printf("VA: " TARGET_FMT_lx ", PA: " TARGET_FMT_lx + printf("VA: %" PRIx64 ", PA: %" PRIx64 ", %s, %s, %s, ctx %" PRId64 "\n", - env->itlb_tag[i] & ~0x1fffULL, - env->itlb_tte[i] & 0x1ffffffe000ULL, + env->itlb_tag[i] & (uint64_t)~0x1fffULL, + env->itlb_tte[i] & (uint64_t)0x1ffffffe000ULL, mask, env->itlb_tte[i] & 0x4? "priv": "user", env->itlb_tte[i] & 0x40? "locked": "unlocked", - env->itlb_tag[i] & 0x1fffULL); + env->itlb_tag[i] & (uint64_t)0x1fffULL); } } } @@ -1314,7 +1314,7 @@ static int cpu_sparc_find_by_name(sparc_def_t *cpu_def, const char *cpu_model) } cpu_def->fpu_version = fpu_version; #ifdef DEBUG_FEATURES - fprintf(stderr, "fpu_version %llx\n", fpu_version); + fprintf(stderr, "fpu_version %x\n", fpu_version); #endif } else if (!strcmp(featurestr, "mmu_version")) { char *err; @@ -1326,7 +1326,7 @@ static int cpu_sparc_find_by_name(sparc_def_t *cpu_def, const char *cpu_model) } cpu_def->mmu_version = mmu_version; #ifdef DEBUG_FEATURES - fprintf(stderr, "mmu_version %llx\n", mmu_version); + fprintf(stderr, "mmu_version %x\n", mmu_version); #endif } else if (!strcmp(featurestr, "nwindows")) { char *err; diff --git a/target-sparc/op_helper.c b/target-sparc/op_helper.c index d25b642c0..739ed9abd 100644 --- a/target-sparc/op_helper.c +++ b/target-sparc/op_helper.c @@ -1212,11 +1212,14 @@ GEN_FCMP(fcmpeq_fcc3, float128, QT0, QT1, 26, 1); defined(DEBUG_MXCC) static void dump_mxcc(CPUState *env) { - printf("mxccdata: %016llx %016llx %016llx %016llx\n", + printf("mxccdata: %016" PRIx64 " %016" PRIx64 " %016" PRIx64 " %016" PRIx64 + "\n", env->mxccdata[0], env->mxccdata[1], env->mxccdata[2], env->mxccdata[3]); - printf("mxccregs: %016llx %016llx %016llx %016llx\n" - " %016llx %016llx %016llx %016llx\n", + printf("mxccregs: %016" PRIx64 " %016" PRIx64 " %016" PRIx64 " %016" PRIx64 + "\n" + " %016" PRIx64 " %016" PRIx64 " %016" PRIx64 " %016" PRIx64 + "\n", env->mxccregs[0], env->mxccregs[1], env->mxccregs[2], env->mxccregs[3], env->mxccregs[4], env->mxccregs[5], @@ -1455,7 +1458,8 @@ uint64_t helper_ld_asi(target_ulong addr, int asi, int size, int sign) env->mmubpregs[reg] = 0ULL; break; } - DPRINTF_MMU("read breakpoint reg[%d] 0x%016llx\n", reg, ret); + DPRINTF_MMU("read breakpoint reg[%d] 0x%016" PRIx64 "\n", reg, + ret); } break; case 8: /* User code access, XXX */ @@ -1808,7 +1812,7 @@ void helper_st_asi(target_ulong addr, uint64_t val, int asi, int size) env->mmubpregs[reg] = (val & 0xfULL); break; } - DPRINTF_MMU("write breakpoint reg[%d] 0x%016llx\n", reg, + DPRINTF_MMU("write breakpoint reg[%d] 0x%016x\n", reg, env->mmuregs[reg]); } break; -- cgit v1.2.3 From 3f5cb28d9e458a29e1da1a9ba0a1499a57872d49 Mon Sep 17 00:00:00 2001 From: Nolan Date: Mon, 20 Jul 2009 14:01:25 -0700 Subject: Handle BH's queued by AIO completions in qemu_aio_flush() Without this, the call to qemu_aio_flush during migration doesn't actually flush all in-flight SCSI IOs. Signed-off-by: Nolan Leake sigbus.net> Signed-off-by: Anthony Liguori --- aio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aio.c b/aio.c index dc9b85d16..efc63fd9a 100644 --- a/aio.c +++ b/aio.c @@ -112,7 +112,7 @@ void qemu_aio_flush(void) LIST_FOREACH(node, &aio_handlers, node) { ret |= node->io_flush(node->opaque); } - } while (ret > 0); + } while (qemu_bh_poll() || ret > 0); } void qemu_aio_wait(void) -- cgit v1.2.3 From a57ac1d342a32875bd5a835ea01925980e2f90b4 Mon Sep 17 00:00:00 2001 From: Nolan Date: Mon, 20 Jul 2009 14:11:35 -0700 Subject: Add save/restore support to the LSI logic SCSI device model. This patch requires "Handle BH's queued by AIO completions in qemu_aio_flush()" to work reliably. The combination of those two patches survived 300+ migrations with heavy IO load running in the guest. Signed-off-by: Nolan Leake sigbus.net> Signed-off-by: Anthony Liguori --- hw/lsi53c895a.c | 172 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 172 insertions(+) diff --git a/hw/lsi53c895a.c b/hw/lsi53c895a.c index 516a46842..f749a45f6 100644 --- a/hw/lsi53c895a.c +++ b/hw/lsi53c895a.c @@ -10,6 +10,8 @@ /* ??? Need to check if the {read,write}[wl] routines work properly on big-endian targets. */ +#include \ + #include "hw.h" #include "pci.h" #include "scsi-disk.h" @@ -1981,6 +1983,174 @@ void lsi_scsi_attach(DeviceState *host, BlockDriverState *bd, int id) bd->private = &s->pci_dev; } +static void lsi_scsi_save(QEMUFile *f, void *opaque) +{ + LSIState *s = opaque; + + assert(s->dma_buf == NULL); + assert(s->current_dma_len == 0); + assert(s->active_commands == 0); + + pci_device_save(&s->pci_dev, f); + + qemu_put_sbe32s(f, &s->carry); + qemu_put_sbe32s(f, &s->sense); + qemu_put_sbe32s(f, &s->msg_action); + qemu_put_sbe32s(f, &s->msg_len); + qemu_put_buffer(f, s->msg, sizeof (s->msg)); + qemu_put_sbe32s(f, &s->waiting); + + qemu_put_be32s(f, &s->dsa); + qemu_put_be32s(f, &s->temp); + qemu_put_be32s(f, &s->dnad); + qemu_put_be32s(f, &s->dbc); + qemu_put_8s(f, &s->istat0); + qemu_put_8s(f, &s->istat1); + qemu_put_8s(f, &s->dcmd); + qemu_put_8s(f, &s->dstat); + qemu_put_8s(f, &s->dien); + qemu_put_8s(f, &s->sist0); + qemu_put_8s(f, &s->sist1); + qemu_put_8s(f, &s->sien0); + qemu_put_8s(f, &s->sien1); + qemu_put_8s(f, &s->mbox0); + qemu_put_8s(f, &s->mbox1); + qemu_put_8s(f, &s->dfifo); + qemu_put_8s(f, &s->ctest2); + qemu_put_8s(f, &s->ctest3); + qemu_put_8s(f, &s->ctest4); + qemu_put_8s(f, &s->ctest5); + qemu_put_8s(f, &s->ccntl0); + qemu_put_8s(f, &s->ccntl1); + qemu_put_be32s(f, &s->dsp); + qemu_put_be32s(f, &s->dsps); + qemu_put_8s(f, &s->dmode); + qemu_put_8s(f, &s->dcntl); + qemu_put_8s(f, &s->scntl0); + qemu_put_8s(f, &s->scntl1); + qemu_put_8s(f, &s->scntl2); + qemu_put_8s(f, &s->scntl3); + qemu_put_8s(f, &s->sstat0); + qemu_put_8s(f, &s->sstat1); + qemu_put_8s(f, &s->scid); + qemu_put_8s(f, &s->sxfer); + qemu_put_8s(f, &s->socl); + qemu_put_8s(f, &s->sdid); + qemu_put_8s(f, &s->ssid); + qemu_put_8s(f, &s->sfbr); + qemu_put_8s(f, &s->stest1); + qemu_put_8s(f, &s->stest2); + qemu_put_8s(f, &s->stest3); + qemu_put_8s(f, &s->sidl); + qemu_put_8s(f, &s->stime0); + qemu_put_8s(f, &s->respid0); + qemu_put_8s(f, &s->respid1); + qemu_put_be32s(f, &s->mmrs); + qemu_put_be32s(f, &s->mmws); + qemu_put_be32s(f, &s->sfs); + qemu_put_be32s(f, &s->drs); + qemu_put_be32s(f, &s->sbms); + qemu_put_be32s(f, &s->dbms); + qemu_put_be32s(f, &s->dnad64); + qemu_put_be32s(f, &s->pmjad1); + qemu_put_be32s(f, &s->pmjad2); + qemu_put_be32s(f, &s->rbc); + qemu_put_be32s(f, &s->ua); + qemu_put_be32s(f, &s->ia); + qemu_put_be32s(f, &s->sbc); + qemu_put_be32s(f, &s->csbc); + qemu_put_buffer(f, (uint8_t *)s->scratch, sizeof (s->scratch)); + qemu_put_8s(f, &s->sbr); + + qemu_put_buffer(f, (uint8_t *)s->script_ram, sizeof (s->script_ram)); +} + +static int lsi_scsi_load(QEMUFile *f, void *opaque, int version_id) +{ + LSIState *s = opaque; + int ret; + + if (version_id > 0) { + return -EINVAL; + } + + if ((ret = pci_device_load(&s->pci_dev, f)) < 0) + return ret; + + qemu_get_sbe32s(f, &s->carry); + qemu_get_sbe32s(f, &s->sense); + qemu_get_sbe32s(f, &s->msg_action); + qemu_get_sbe32s(f, &s->msg_len); + qemu_get_buffer(f, s->msg, sizeof (s->msg)); + qemu_get_sbe32s(f, &s->waiting); + + qemu_get_be32s(f, &s->dsa); + qemu_get_be32s(f, &s->temp); + qemu_get_be32s(f, &s->dnad); + qemu_get_be32s(f, &s->dbc); + qemu_get_8s(f, &s->istat0); + qemu_get_8s(f, &s->istat1); + qemu_get_8s(f, &s->dcmd); + qemu_get_8s(f, &s->dstat); + qemu_get_8s(f, &s->dien); + qemu_get_8s(f, &s->sist0); + qemu_get_8s(f, &s->sist1); + qemu_get_8s(f, &s->sien0); + qemu_get_8s(f, &s->sien1); + qemu_get_8s(f, &s->mbox0); + qemu_get_8s(f, &s->mbox1); + qemu_get_8s(f, &s->dfifo); + qemu_get_8s(f, &s->ctest2); + qemu_get_8s(f, &s->ctest3); + qemu_get_8s(f, &s->ctest4); + qemu_get_8s(f, &s->ctest5); + qemu_get_8s(f, &s->ccntl0); + qemu_get_8s(f, &s->ccntl1); + qemu_get_be32s(f, &s->dsp); + qemu_get_be32s(f, &s->dsps); + qemu_get_8s(f, &s->dmode); + qemu_get_8s(f, &s->dcntl); + qemu_get_8s(f, &s->scntl0); + qemu_get_8s(f, &s->scntl1); + qemu_get_8s(f, &s->scntl2); + qemu_get_8s(f, &s->scntl3); + qemu_get_8s(f, &s->sstat0); + qemu_get_8s(f, &s->sstat1); + qemu_get_8s(f, &s->scid); + qemu_get_8s(f, &s->sxfer); + qemu_get_8s(f, &s->socl); + qemu_get_8s(f, &s->sdid); + qemu_get_8s(f, &s->ssid); + qemu_get_8s(f, &s->sfbr); + qemu_get_8s(f, &s->stest1); + qemu_get_8s(f, &s->stest2); + qemu_get_8s(f, &s->stest3); + qemu_get_8s(f, &s->sidl); + qemu_get_8s(f, &s->stime0); + qemu_get_8s(f, &s->respid0); + qemu_get_8s(f, &s->respid1); + qemu_get_be32s(f, &s->mmrs); + qemu_get_be32s(f, &s->mmws); + qemu_get_be32s(f, &s->sfs); + qemu_get_be32s(f, &s->drs); + qemu_get_be32s(f, &s->sbms); + qemu_get_be32s(f, &s->dbms); + qemu_get_be32s(f, &s->dnad64); + qemu_get_be32s(f, &s->pmjad1); + qemu_get_be32s(f, &s->pmjad2); + qemu_get_be32s(f, &s->rbc); + qemu_get_be32s(f, &s->ua); + qemu_get_be32s(f, &s->ia); + qemu_get_be32s(f, &s->sbc); + qemu_get_be32s(f, &s->csbc); + qemu_get_buffer(f, (uint8_t *)s->scratch, sizeof (s->scratch)); + qemu_get_8s(f, &s->sbr); + + qemu_get_buffer(f, (uint8_t *)s->script_ram, sizeof (s->script_ram)); + + return 0; +} + static int lsi_scsi_uninit(PCIDevice *d) { LSIState *s = (LSIState *) d; @@ -2033,6 +2203,8 @@ static void lsi_scsi_init(PCIDevice *dev) lsi_soft_reset(s); scsi_bus_new(&dev->qdev, lsi_scsi_attach); + + register_savevm("lsiscsi", -1, 0, lsi_scsi_save, lsi_scsi_load, s); } static PCIDeviceInfo lsi_info = { -- cgit v1.2.3 From e88802852d0e5201e21dad0d773a6bff478594b5 Mon Sep 17 00:00:00 2001 From: Kevin Wolf Date: Fri, 17 Jul 2009 08:20:41 +0200 Subject: vmdk: Fix backing file handling Instead of storing the backing file in its own BlockDriverState, VMDK uses the BlockDriverState of the raw image file it opened. This is wrong and breaks functions that access the backing file or protocols. This fix replaces all occurrences of s->hd->backing_* with bs->backing_*. This fixes qemu-iotests failure in 020 (Commit changes to backing file). Signed-off-by: Kevin Wolf Signed-off-by: Anthony Liguori --- block/vmdk.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/block/vmdk.c b/block/vmdk.c index f21f02bc5..4e486225b 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -170,7 +170,7 @@ static int vmdk_is_cid_valid(BlockDriverState *bs) { #ifdef CHECK_CID BDRVVmdkState *s = bs->opaque; - BlockDriverState *p_bs = s->hd->backing_hd; + BlockDriverState *p_bs = bs->backing_hd; uint32_t cur_pcid; if (p_bs) { @@ -338,26 +338,26 @@ static int vmdk_parent_open(BlockDriverState *bs, const char * filename) p_name += sizeof("parentFileNameHint") + 1; if ((end_name = strchr(p_name,'\"')) == NULL) return -1; - if ((end_name - p_name) > sizeof (s->hd->backing_file) - 1) + if ((end_name - p_name) > sizeof (bs->backing_file) - 1) return -1; - pstrcpy(s->hd->backing_file, end_name - p_name + 1, p_name); - if (stat(s->hd->backing_file, &file_buf) != 0) { + pstrcpy(bs->backing_file, end_name - p_name + 1, p_name); + if (stat(bs->backing_file, &file_buf) != 0) { path_combine(parent_img_name, sizeof(parent_img_name), - filename, s->hd->backing_file); + filename, bs->backing_file); } else { pstrcpy(parent_img_name, sizeof(parent_img_name), - s->hd->backing_file); + bs->backing_file); } - s->hd->backing_hd = bdrv_new(""); - if (!s->hd->backing_hd) { + bs->backing_hd = bdrv_new(""); + if (!bs->backing_hd) { failure: bdrv_close(s->hd); return -1; } parent_open = 1; - if (bdrv_open(s->hd->backing_hd, parent_img_name, BDRV_O_RDONLY) < 0) + if (bdrv_open(bs->backing_hd, parent_img_name, BDRV_O_RDONLY) < 0) goto failure; parent_open = 0; } @@ -464,13 +464,14 @@ static int get_whole_cluster(BlockDriverState *bs, uint64_t cluster_offset, // we will be here if it's first write on non-exist grain(cluster). // try to read from parent image, if exist - if (s->hd->backing_hd) { - BDRVVmdkState *ps = s->hd->backing_hd->opaque; + if (bs->backing_hd) { + BDRVVmdkState *ps = bs->backing_hd->opaque; if (!vmdk_is_cid_valid(bs)) return -1; - parent_cluster_offset = get_cluster_offset(s->hd->backing_hd, NULL, offset, allocate); + parent_cluster_offset = get_cluster_offset(bs->backing_hd, NULL, + offset, allocate); if (parent_cluster_offset) { BDRVVmdkState *act_s = activeBDRV.hd->opaque; @@ -621,10 +622,10 @@ static int vmdk_read(BlockDriverState *bs, int64_t sector_num, n = nb_sectors; if (!cluster_offset) { // try to read from parent image, if exist - if (s->hd->backing_hd) { + if (bs->backing_hd) { if (!vmdk_is_cid_valid(bs)) return -1; - ret = bdrv_read(s->hd->backing_hd, sector_num, buf, n); + ret = bdrv_read(bs->backing_hd, sector_num, buf, n); if (ret < 0) return -1; } else { -- cgit v1.2.3 From ca95814efb88e29a5c33824b7dd1b3218ca22b9d Mon Sep 17 00:00:00 2001 From: Akkarit Sangpetch Date: Fri, 17 Jul 2009 10:02:15 +0200 Subject: qmu-img: fix qemu-img convert to generate a valid image when the source referenced a backing file Make 'qemu-img convert' copies unallocated parts of the source image when -B option was not specified. Signed-off-by: Akkarit Sangpetch Signed-off-by: Kevin Wolf Signed-off-by: Anthony Liguori --- qemu-img.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/qemu-img.c b/qemu-img.c index d806cfa19..070fe2e22 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -747,14 +747,20 @@ static int img_convert(int argc, char **argv) n = bs_offset + bs_sectors - sector_num; if (strcmp(drv->format_name, "host_device")) { - if (!bdrv_is_allocated(bs[bs_i], sector_num - bs_offset, - n, &n1)) { - sector_num += n1; - continue; + /* If the output image is being created as a copy on write image, + assume that sectors which are unallocated in the input image + are present in both the output's and input's base images (no + need to copy them). */ + if (out_baseimg) { + if (!bdrv_is_allocated(bs[bs_i], sector_num - bs_offset, + n, &n1)) { + sector_num += n1; + continue; + } + /* The next 'n1' sectors are allocated in the input image. Copy + only those as they may be followed by unallocated sectors. */ + n = n1; } - /* The next 'n1' sectors are allocated in the input image. Copy - only those as they may be followed by unallocated sectors. */ - n = n1; } else { n1 = n; } -- cgit v1.2.3 From 96046435baa8f43f247d2fb22222ca44e35a7f9f Mon Sep 17 00:00:00 2001 From: Christoph Egger Date: Fri, 17 Jul 2009 15:23:51 +0200 Subject: signrom.sh: portability fix Attached patch makes signrom.sh working on NetBSD. The output of the 'od' command leads to a syntax error which breaks the build. Signed-off-by: Christoph Egger Signed-off-by: Anthony Liguori --- pc-bios/optionrom/signrom.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pc-bios/optionrom/signrom.sh b/pc-bios/optionrom/signrom.sh index 263ba5ffc..432281137 100755 --- a/pc-bios/optionrom/signrom.sh +++ b/pc-bios/optionrom/signrom.sh @@ -31,9 +31,10 @@ x=`dd if="$1" bs=1 count=1 skip=2 2>/dev/null | od -t u1 -A n` size=$(( $x * 512 - 1 )) # now get the checksum -for i in `od -A n -t u1 -v "$1"`; do +nums=`od -A n -t u1 -v "$1"` +for i in ${nums}; do # add each byte's value to sum - sum=$(( $sum + $i )) + sum=`expr $sum + $i` done sum=$(( $sum % 256 )) -- cgit v1.2.3 From cc234b83c6bca8a79fa4e385b520155f2d1d3ba7 Mon Sep 17 00:00:00 2001 From: Sebastian Herbszt Date: Sun, 19 Jul 2009 15:16:09 +0200 Subject: qemu-thread: use pthread_equal Fixes qemu-thread.c: In function `qemu_thread_equal': qemu-thread.c:161: error: invalid operands to binary == Use of pthread_equal suggested by Filip Navara. Signed-off-by: Sebastian Herbszt Signed-off-by: Anthony Liguori --- qemu-thread.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qemu-thread.c b/qemu-thread.c index 719cfcddd..3923db74e 100644 --- a/qemu-thread.c +++ b/qemu-thread.c @@ -158,6 +158,6 @@ void qemu_thread_self(QemuThread *thread) int qemu_thread_equal(QemuThread *thread1, QemuThread *thread2) { - return (thread1->thread == thread2->thread); + return pthread_equal(thread1->thread, thread2->thread); } -- cgit v1.2.3 From b0dc78730e54bd3ef96f56466890aa2509a328c3 Mon Sep 17 00:00:00 2001 From: Jan Kiszka Date: Wed, 22 Jul 2009 17:03:52 +0200 Subject: slirp: Fix guestfwd for incoming data Unless a virtual server address was explicitly defined (which is impossible with the legacy -net channel format), guestfwd did not properly forwarded host->guest packets. This patch fixes it. Signed-off-by: Jan Kiszka Signed-off-by: Anthony Liguori --- net.c | 11 ++++++----- slirp/libslirp.h | 2 +- slirp/slirp.c | 14 +++++++------- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/net.c b/net.c index 90cf91237..1c2c7d06a 100644 --- a/net.c +++ b/net.c @@ -1150,7 +1150,7 @@ static void slirp_smb(SlirpState* s, Monitor *mon, const char *exported_dir, snprintf(smb_cmdline, sizeof(smb_cmdline), "%s -s %s", SMBD_COMMAND, smb_conf); - if (slirp_add_exec(s->slirp, 0, smb_cmdline, vserver_addr, 139) < 0) { + if (slirp_add_exec(s->slirp, 0, smb_cmdline, &vserver_addr, 139) < 0) { slirp_smb_cleanup(s); config_error(mon, "conflicting/invalid smbserver address\n"); } @@ -1239,16 +1239,17 @@ static void slirp_guestfwd(SlirpState *s, Monitor *mon, const char *config_str, qemu_free(fwd); return; } - fwd->server = server; - fwd->port = port; - fwd->slirp = s->slirp; - if (slirp_add_exec(s->slirp, 3, fwd->hd, server, port) < 0) { + if (slirp_add_exec(s->slirp, 3, fwd->hd, &server, port) < 0) { config_error(mon, "conflicting/invalid host:port in guest forwarding " "rule '%s'\n", config_str); qemu_free(fwd); return; } + fwd->server = server; + fwd->port = port; + fwd->slirp = s->slirp; + qemu_chr_add_handlers(fwd->hd, guestfwd_can_read, guestfwd_read, NULL, fwd); return; diff --git a/slirp/libslirp.h b/slirp/libslirp.h index 3bcc3923f..93087ed74 100644 --- a/slirp/libslirp.h +++ b/slirp/libslirp.h @@ -33,7 +33,7 @@ int slirp_add_hostfwd(Slirp *slirp, int is_udp, int slirp_remove_hostfwd(Slirp *slirp, int is_udp, struct in_addr host_addr, int host_port); int slirp_add_exec(Slirp *slirp, int do_pty, const void *args, - struct in_addr guest_addr, int guest_port); + struct in_addr *guest_addr, int guest_port); void slirp_connection_info(Slirp *slirp, Monitor *mon); diff --git a/slirp/slirp.c b/slirp/slirp.c index 0ce62a37a..9be855313 100644 --- a/slirp/slirp.c +++ b/slirp/slirp.c @@ -794,19 +794,19 @@ int slirp_add_hostfwd(Slirp *slirp, int is_udp, struct in_addr host_addr, } int slirp_add_exec(Slirp *slirp, int do_pty, const void *args, - struct in_addr guest_addr, int guest_port) + struct in_addr *guest_addr, int guest_port) { - if (!guest_addr.s_addr) { - guest_addr.s_addr = slirp->vnetwork_addr.s_addr | + if (!guest_addr->s_addr) { + guest_addr->s_addr = slirp->vnetwork_addr.s_addr | (htonl(0x0204) & ~slirp->vnetwork_mask.s_addr); } - if ((guest_addr.s_addr & slirp->vnetwork_mask.s_addr) != + if ((guest_addr->s_addr & slirp->vnetwork_mask.s_addr) != slirp->vnetwork_addr.s_addr || - guest_addr.s_addr == slirp->vhost_addr.s_addr || - guest_addr.s_addr == slirp->vnameserver_addr.s_addr) { + guest_addr->s_addr == slirp->vhost_addr.s_addr || + guest_addr->s_addr == slirp->vnameserver_addr.s_addr) { return -1; } - return add_exec(&slirp->exec_list, do_pty, (char *)args, guest_addr, + return add_exec(&slirp->exec_list, do_pty, (char *)args, *guest_addr, htons(guest_port)); } -- cgit v1.2.3 From b87d79698d04bc472d2847d9a1d209985b99f8a4 Mon Sep 17 00:00:00 2001 From: Beth Kon Date: Fri, 24 Jul 2009 12:26:59 -0400 Subject: HPET fixes for reg writes This patch addresses the problems found by Andriy Gapon: - The code was incorrectly overwriting the high order 32 bits of the timer and hpet config registers. This didn't show up in testing because linux and windows use hpet in legacy mode, where the high order 32 bits (advertising available interrupts) of the timer config register are ignored, and the high order 32 bits of the hpet config register are reserved and unused. - The mask for level-triggered interrupts was off by a bit. (hpet doesn't currently support level-triggered interrupts). In addition, I removed some unused #defines, and corrected the ioapic interrupt values advertised. I'd set this up early in hpet development and never went back to correct it, and no bugs resulted since linux and windows use hpet in legacy mode where available interrupts are ignored. Signed-off-by: Beth Kon Signed-off-by: Anthony Liguori --- hw/hpet.c | 14 +++++++------- hw/hpet_emul.h | 7 +------ 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/hw/hpet.c b/hw/hpet.c index 24aee6a2c..01b10aa59 100644 --- a/hw/hpet.c +++ b/hw/hpet.c @@ -371,7 +371,7 @@ static void hpet_ram_writel(void *opaque, target_phys_addr_t addr, { int i; HPETState *s = (HPETState *)opaque; - uint64_t old_val, new_val, index; + uint64_t old_val, new_val, val, index; dprintf("qemu: Enter hpet_ram_writel at %" PRIx64 " = %#x\n", addr, value); index = addr; @@ -387,8 +387,8 @@ static void hpet_ram_writel(void *opaque, target_phys_addr_t addr, switch ((addr - 0x100) % 0x20) { case HPET_TN_CFG: dprintf("qemu: hpet_ram_writel HPET_TN_CFG\n"); - timer->config = hpet_fixup_reg(new_val, old_val, - HPET_TN_CFG_WRITE_MASK); + val = hpet_fixup_reg(new_val, old_val, HPET_TN_CFG_WRITE_MASK); + timer->config = (timer->config & 0xffffffff00000000ULL) | val; if (new_val & HPET_TN_32BIT) { timer->cmp = (uint32_t)timer->cmp; timer->period = (uint32_t)timer->period; @@ -456,8 +456,8 @@ static void hpet_ram_writel(void *opaque, target_phys_addr_t addr, case HPET_ID: return; case HPET_CFG: - s->config = hpet_fixup_reg(new_val, old_val, - HPET_CFG_WRITE_MASK); + val = hpet_fixup_reg(new_val, old_val, HPET_CFG_WRITE_MASK); + s->config = (s->config & 0xffffffff00000000ULL) | val; if (activating_bit(old_val, new_val, HPET_CFG_ENABLE)) { /* Enable main counter and interrupt generation. */ s->hpet_offset = ticks_to_ns(s->hpet_counter) @@ -541,8 +541,8 @@ static void hpet_reset(void *opaque) { timer->tn = i; timer->cmp = ~0ULL; timer->config = HPET_TN_PERIODIC_CAP | HPET_TN_SIZE_CAP; - /* advertise availability of irqs 5,10,11 */ - timer->config |= 0x00000c20ULL << 32; + /* advertise availability of ioapic inti2 */ + timer->config |= 0x00000004ULL << 32; timer->state = s; timer->period = 0ULL; timer->wrap_flag = 0; diff --git a/hw/hpet_emul.h b/hw/hpet_emul.h index 60893b65d..3258d8bde 100644 --- a/hw/hpet_emul.h +++ b/hw/hpet_emul.h @@ -18,12 +18,7 @@ #define FS_PER_NS 1000000 #define HPET_NUM_TIMERS 3 -#define HPET_TIMER_TYPE_LEVEL 1 -#define HPET_TIMER_TYPE_EDGE 0 -#define HPET_TIMER_DELIVERY_APIC 0 -#define HPET_TIMER_DELIVERY_FSB 1 -#define HPET_TIMER_CAP_FSB_INT_DEL (1 << 15) -#define HPET_TIMER_CAP_PER_INT (1 << 4) +#define HPET_TIMER_TYPE_LEVEL 0x002 #define HPET_CFG_ENABLE 0x001 #define HPET_CFG_LEGACY 0x002 -- cgit v1.2.3 From 8568d307a7db11a176a5b97270cc905a20feafa3 Mon Sep 17 00:00:00 2001 From: "Michael S. Tsirkin" Date: Wed, 22 Jul 2009 18:51:14 +0300 Subject: qemu: msix nit: clear msix_entries_nr on error I don't think it's critical to do this, but it's best to keep uninit and error recovery consistent. Signed-off-by: Michael S. Tsirkin Signed-off-by: Anthony Liguori --- hw/msix.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/msix.c b/hw/msix.c index 3420ce9b2..c954d471c 100644 --- a/hw/msix.c +++ b/hw/msix.c @@ -255,6 +255,7 @@ int msix_init(struct PCIDevice *dev, unsigned short nentries, return 0; err_config: + dev->msix_entries_nr = 0; cpu_unregister_io_memory(dev->msix_mmio_index); err_index: qemu_free(dev->msix_table_page); -- cgit v1.2.3 From f833ef2133d8f80bc236e98467d6baf43b377a8c Mon Sep 17 00:00:00 2001 From: Ed Swierk Date: Thu, 23 Jul 2009 14:13:34 -0700 Subject: slirp: Use monotonic clock if available (v2) Calling gettimeofday() to compute a time interval can cause problems if the system clock jumps forwards or backwards; replace updtime() with qemu_get_clock(rt_clock), which calls clock_gettime(CLOCK_MONOTONIC) if it is available. Also remove some useless macros. Signed-off-by: Ed Swierk Signed-off-by: Anthony Liguori --- slirp/slirp.c | 27 ++------------------------- slirp/slirp.h | 4 ---- slirp/slirp_config.h | 3 --- 3 files changed, 2 insertions(+), 32 deletions(-) diff --git a/slirp/slirp.c b/slirp/slirp.c index 9be855313..e883f8263 100644 --- a/slirp/slirp.c +++ b/slirp/slirp.c @@ -22,6 +22,7 @@ * THE SOFTWARE. */ #include "qemu-common.h" +#include "qemu-timer.h" #include "qemu-char.h" #include "slirp.h" #include "hw/hw.h" @@ -244,29 +245,6 @@ void slirp_cleanup(Slirp *slirp) #define CONN_CANFRCV(so) (((so)->so_state & (SS_FCANTRCVMORE|SS_ISFCONNECTED)) == SS_ISFCONNECTED) #define UPD_NFDS(x) if (nfds < (x)) nfds = (x) -/* - * curtime kept to an accuracy of 1ms - */ -#ifdef _WIN32 -static void updtime(void) -{ - struct _timeb tb; - - _ftime(&tb); - - curtime = tb.time * 1000 + tb.millitm; -} -#else -static void updtime(void) -{ - struct timeval tv; - - gettimeofday(&tv, NULL); - - curtime = tv.tv_sec * 1000 + tv.tv_usec / 1000; -} -#endif - void slirp_select_fill(int *pnfds, fd_set *readfds, fd_set *writefds, fd_set *xfds) { @@ -405,8 +383,7 @@ void slirp_select_poll(fd_set *readfds, fd_set *writefds, fd_set *xfds, global_writefds = writefds; global_xfds = xfds; - /* Update time */ - updtime(); + curtime = qemu_get_clock(rt_clock); TAILQ_FOREACH(slirp, &slirp_instances, entry) { /* diff --git a/slirp/slirp.h b/slirp/slirp.h index 22058cd05..020412caf 100644 --- a/slirp/slirp.h +++ b/slirp/slirp.h @@ -108,10 +108,6 @@ typedef unsigned char u_int8_t; #include #endif -#ifdef GETTIMEOFDAY_ONE_ARG -#define gettimeofday(x, y) gettimeofday(x) -#endif - /* Systems lacking strdup() definition in . */ #if defined(ultrix) char *strdup(const char *); diff --git a/slirp/slirp_config.h b/slirp/slirp_config.h index dbc8dfd42..5a0e6c113 100644 --- a/slirp/slirp_config.h +++ b/slirp/slirp_config.h @@ -190,9 +190,6 @@ #define NO_UNIX_SOCKETS #endif -/* Define if gettimeofday only takes one argument */ -#undef GETTIMEOFDAY_ONE_ARG - /* Define if you have revoke() */ #undef HAVE_REVOKE -- cgit v1.2.3 From 1d600827f6980d29f1d513daffa59714e10041f0 Mon Sep 17 00:00:00 2001 From: Glauber Costa Date: Fri, 24 Jul 2009 16:20:23 -0400 Subject: fix broken migration While fixing migration with -S, commit 89befdd1a6b18215153b8976682d57b7d03d5782 broke the rest of us. Poor glommer, with a poor family, spare him his life from this monstruosity. Since the unconditional vm_start, not autostart was the villain, I'm putting back autostart. Let me know if you prefer other solutions, it doesn't really matter, doesn't really matter to me. Any way the wind blows... Signed-off-by: Glauber Costa CC: Paolo Bonzini Signed-off-by: Anthony Liguori --- vl.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/vl.c b/vl.c index ce213c2cd..015f63131 100644 --- a/vl.c +++ b/vl.c @@ -6075,8 +6075,10 @@ int main(int argc, char **argv, char **envp) if (loadvm) do_loadvm(cur_mon, loadvm); - if (incoming) + if (incoming) { + autostart = 0; qemu_start_incoming_migration(incoming); + } if (autostart) vm_start(); -- cgit v1.2.3 From 583b6d0c043b6f91c12a686c483a076cb0e12cb6 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Mon, 27 Jul 2009 10:02:01 -0500 Subject: tap-win32: Use correct headers. Replace the usage of DDK headers with the SDK counterpart "winioctl.h". Signed-off-by: Filip Navara Signed-off-by: Anthony Liguori --- tap-win32.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/tap-win32.c b/tap-win32.c index 44f96e537..2c02ce301 100644 --- a/tap-win32.c +++ b/tap-win32.c @@ -30,13 +30,7 @@ #include "sysemu.h" #include #include - -/* NOTE: PCIBus is redefined in winddk.h */ -#define PCIBus _PCIBus -#include -#include -#include -#undef PCIBus +#include //============= // TAP IOCTLs -- cgit v1.2.3 From 58cc6b7a5a664b83022f234458b50a0f263a6e03 Mon Sep 17 00:00:00 2001 From: Mark McLoughlin Date: Wed, 22 Jul 2009 09:11:38 +0100 Subject: Make tcp_chr_read() use recvmsg() Split out tcp_chr_recv() out of tcp_chr_read() and implement it on non-win32 using recvmsg(). This is needed for a subsequent patch which implements SCM_RIGHTS support. Signed-off-by: Mark McLoughlin Signed-off-by: Anthony Liguori --- qemu-char.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/qemu-char.c b/qemu-char.c index 287e0cd32..988622815 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -1907,6 +1907,29 @@ static void tcp_chr_process_IAC_bytes(CharDriverState *chr, *size = j; } +#ifndef WIN32 +static ssize_t tcp_chr_recv(CharDriverState *chr, char *buf, size_t len) +{ + TCPCharDriver *s = chr->opaque; + struct msghdr msg = { 0, }; + struct iovec iov[1]; + + iov[0].iov_base = buf; + iov[0].iov_len = len; + + msg.msg_iov = iov; + msg.msg_iovlen = 1; + + return recvmsg(s->fd, &msg, 0); +} +#else +static ssize_t tcp_chr_recv(CharDriverState *chr, char *buf, size_t len) +{ + TCPCharDriver *s = chr->opaque; + return recv(s->fd, buf, len, 0); +} +#endif + static void tcp_chr_read(void *opaque) { CharDriverState *chr = opaque; @@ -1919,7 +1942,7 @@ static void tcp_chr_read(void *opaque) len = sizeof(buf); if (len > s->max_size) len = s->max_size; - size = recv(s->fd, (void *)buf, len, 0); + size = tcp_chr_recv(chr, (void *)buf, len); if (size == 0) { /* connection closed */ s->connected = 0; -- cgit v1.2.3 From 9fc1babd959abeb01001a5a507c515c34209fe84 Mon Sep 17 00:00:00 2001 From: Mark McLoughlin Date: Wed, 22 Jul 2009 10:02:50 +0100 Subject: Add machine type aliases Add an 'alias' field to QEMUMachine and display it in the output of 'qemu -M ?' with an '(aliased to foo)' suffix. Aliases can change targets in newer versions of qemu, so management tools may choose canonicalize machine types to ensure that if a user chooses an alias, that the actual machine type used will remain compatible in future. This is intended to mimic a symlink to a machine description file. Signed-off-by: Mark McLoughlin Signed-off-by: Anthony Liguori --- hw/boards.h | 1 + vl.c | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/hw/boards.h b/hw/boards.h index 11acb89fc..d8893413d 100644 --- a/hw/boards.h +++ b/hw/boards.h @@ -14,6 +14,7 @@ typedef void QEMUMachineInitFunc(ram_addr_t ram_size, typedef struct QEMUMachine { const char *name; + const char *alias; const char *desc; QEMUMachineInitFunc *init; int use_scsi; diff --git a/vl.c b/vl.c index 015f63131..0d03fd6f7 100644 --- a/vl.c +++ b/vl.c @@ -3359,6 +3359,8 @@ static QEMUMachine *find_machine(const char *name) for(m = first_machine; m != NULL; m = m->next) { if (!strcmp(m->name, name)) return m; + if (m->alias && !strcmp(m->alias, name)) + return m; } return NULL; } @@ -4995,6 +4997,9 @@ int main(int argc, char **argv, char **envp) QEMUMachine *m; printf("Supported machines are:\n"); for(m = first_machine; m != NULL; m = m->next) { + if (m->alias) + printf("%-10s %s (alias of %s)\n", + m->alias, m->desc, m->name); printf("%-10s %s%s\n", m->name, m->desc, m->is_default ? " (default)" : ""); -- cgit v1.2.3 From f8f8e7e6ddd1928f9c75f989728afb4c2dc27bea Mon Sep 17 00:00:00 2001 From: Mark McLoughlin Date: Wed, 22 Jul 2009 09:11:39 +0100 Subject: Add SCM_RIGHTS support to unix socket character devices If a file descriptor is passed via a message with SCM_RIGHTS ancillary data on a unix socket, store the file descriptor for use in the chr_read() handler. Close the file descriptor if it was not used. The qemu_chr_get_msgfd() API provides access to the passed descriptor. Signed-off-by: Mark McLoughlin Signed-off-by: Anthony Liguori --- qemu-char.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- qemu-char.h | 2 ++ 2 files changed, 56 insertions(+), 1 deletion(-) diff --git a/qemu-char.c b/qemu-char.c index 988622815..6e2cd315a 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -168,6 +168,11 @@ void qemu_chr_read(CharDriverState *s, uint8_t *buf, int len) s->chr_read(s->handler_opaque, buf, len); } +int qemu_chr_get_msgfd(CharDriverState *s) +{ + return s->get_msgfd ? s->get_msgfd(s) : -1; +} + void qemu_chr_accept_input(CharDriverState *s) { if (s->chr_accept_input) @@ -1832,6 +1837,7 @@ typedef struct { int do_telnetopt; int do_nodelay; int is_unix; + int msgfd; } TCPCharDriver; static void tcp_chr_accept(void *opaque); @@ -1907,20 +1913,61 @@ static void tcp_chr_process_IAC_bytes(CharDriverState *chr, *size = j; } +static int tcp_get_msgfd(CharDriverState *chr) +{ + TCPCharDriver *s = chr->opaque; + + return s->msgfd; +} + #ifndef WIN32 +static void unix_process_msgfd(CharDriverState *chr, struct msghdr *msg) +{ + TCPCharDriver *s = chr->opaque; + struct cmsghdr *cmsg; + + for (cmsg = CMSG_FIRSTHDR(msg); cmsg; cmsg = CMSG_NXTHDR(msg, cmsg)) { + int fd; + + if (cmsg->cmsg_len != CMSG_LEN(sizeof(int)) || + cmsg->cmsg_level != SOL_SOCKET || + cmsg->cmsg_type != SCM_RIGHTS) + continue; + + fd = *((int *)CMSG_DATA(cmsg)); + if (fd < 0) + continue; + + if (s->msgfd != -1) + close(s->msgfd); + s->msgfd = fd; + } +} + static ssize_t tcp_chr_recv(CharDriverState *chr, char *buf, size_t len) { TCPCharDriver *s = chr->opaque; struct msghdr msg = { 0, }; struct iovec iov[1]; + union { + struct cmsghdr cmsg; + char control[CMSG_SPACE(sizeof(int))]; + } msg_control; + ssize_t ret; iov[0].iov_base = buf; iov[0].iov_len = len; msg.msg_iov = iov; msg.msg_iovlen = 1; + msg.msg_control = &msg_control; + msg.msg_controllen = sizeof(msg_control); + + ret = recvmsg(s->fd, &msg, 0); + if (ret > 0 && s->is_unix) + unix_process_msgfd(chr, &msg); - return recvmsg(s->fd, &msg, 0); + return ret; } #else static ssize_t tcp_chr_recv(CharDriverState *chr, char *buf, size_t len) @@ -1957,6 +2004,10 @@ static void tcp_chr_read(void *opaque) tcp_chr_process_IAC_bytes(chr, s, buf, &size); if (size > 0) qemu_chr_read(chr, buf, size); + if (s->msgfd != -1) { + close(s->msgfd); + s->msgfd = -1; + } } } @@ -2118,12 +2169,14 @@ static CharDriverState *qemu_chr_open_tcp(const char *host_str, s->connected = 0; s->fd = -1; s->listen_fd = -1; + s->msgfd = -1; s->is_unix = is_unix; s->do_nodelay = do_nodelay && !is_unix; chr->opaque = s; chr->chr_write = tcp_chr_write; chr->chr_close = tcp_chr_close; + chr->get_msgfd = tcp_get_msgfd; if (is_listen) { s->listen_fd = fd; diff --git a/qemu-char.h b/qemu-char.h index e1aa8dbaf..77d4edaae 100644 --- a/qemu-char.h +++ b/qemu-char.h @@ -51,6 +51,7 @@ struct CharDriverState { int (*chr_write)(struct CharDriverState *s, const uint8_t *buf, int len); void (*chr_update_read_handler)(struct CharDriverState *s); int (*chr_ioctl)(struct CharDriverState *s, int cmd, void *arg); + int (*get_msgfd)(struct CharDriverState *s); IOEventHandler *chr_event; IOCanRWHandler *chr_can_read; IOReadHandler *chr_read; @@ -81,6 +82,7 @@ void qemu_chr_reset(CharDriverState *s); void qemu_chr_initial_reset(void); int qemu_chr_can_read(CharDriverState *s); void qemu_chr_read(CharDriverState *s, uint8_t *buf, int len); +int qemu_chr_get_msgfd(CharDriverState *s); void qemu_chr_accept_input(CharDriverState *s); void qemu_chr_info(Monitor *mon); -- cgit v1.2.3 From 9bab7711ca7c3a0daaaaf7d645caa9722bfe7be1 Mon Sep 17 00:00:00 2001 From: Mark McLoughlin Date: Wed, 22 Jul 2009 09:11:41 +0100 Subject: Add monitor_get_fd() command for fetching named fds Signed-off-by: Mark McLoughlin Signed-off-by: Anthony Liguori --- monitor.c | 24 ++++++++++++++++++++++++ monitor.h | 2 ++ 2 files changed, 26 insertions(+) diff --git a/monitor.c b/monitor.c index 817e4b7ed..6ad2e14af 100644 --- a/monitor.c +++ b/monitor.c @@ -1774,6 +1774,30 @@ static void do_closefd(Monitor *mon, const char *fdname) fdname); } +int monitor_get_fd(Monitor *mon, const char *fdname) +{ + mon_fd_t *monfd; + + LIST_FOREACH(monfd, &mon->fds, next) { + int fd; + + if (strcmp(monfd->name, fdname) != 0) { + continue; + } + + fd = monfd->fd; + + /* caller takes ownership of fd */ + LIST_REMOVE(monfd, next); + qemu_free(monfd->name); + qemu_free(monfd); + + return fd; + } + + return -1; +} + static const mon_cmd_t mon_cmds[] = { #include "qemu-monitor.h" { NULL, NULL, }, diff --git a/monitor.h b/monitor.h index 13e8cc764..f6a43c018 100644 --- a/monitor.h +++ b/monitor.h @@ -20,6 +20,8 @@ void monitor_read_bdrv_key_start(Monitor *mon, BlockDriverState *bs, BlockDriverCompletionFunc *completion_cb, void *opaque); +int monitor_get_fd(Monitor *mon, const char *fdname); + void monitor_vprintf(Monitor *mon, const char *fmt, va_list ap); void monitor_printf(Monitor *mon, const char *fmt, ...) __attribute__ ((__format__ (__printf__, 2, 3))); -- cgit v1.2.3 From ad6ee8fe97b2a07275cab1fe15ca6dbbddc77860 Mon Sep 17 00:00:00 2001 From: Mark McLoughlin Date: Wed, 22 Jul 2009 10:02:51 +0100 Subject: Add a pc-0.11 machine type and make the pc type an alias The pc-0.11 type allows users of qemu-0.11 to use a machine type which they know will remain compatible when the upgrade to qemu-0.12. Management tools may choose to canonicalize the 'pc' machine type to 'pc-0.11' so that if the 'pc' alias changes target in future versions of qemu, the machine type used will remain compatible. Signed-off-by: Mark McLoughlin Signed-off-by: Anthony Liguori --- hw/pc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/pc.c b/hw/pc.c index a50f23d42..c55c303bc 100644 --- a/hw/pc.c +++ b/hw/pc.c @@ -1512,7 +1512,8 @@ void cmos_set_s3_resume(void) } static QEMUMachine pc_machine = { - .name = "pc", + .name = "pc-0.11", + .alias = "pc", .desc = "Standard PC", .init = pc_init_pci, .max_cpus = 255, -- cgit v1.2.3 From dedd9ecaf96a3b35491bf24e55aafe04a69ec863 Mon Sep 17 00:00:00 2001 From: Mark McLoughlin Date: Wed, 22 Jul 2009 09:11:40 +0100 Subject: Add getfd and closefd monitor commands Add monitor commands to support passing file descriptors via SCM_RIGHTS. getfd assigns the passed file descriptor a name for use with other monitor commands. closefd allows passed file descriptors to be closed. If a monitor command actually uses a named file descriptor, closefd will not be required. Signed-off-by: Mark McLoughlin Signed-off-by: Anthony Liguori --- monitor.c | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ qemu-monitor.hx | 18 +++++++++++++++ 2 files changed, 87 insertions(+) diff --git a/monitor.c b/monitor.c index e38c86e1a..817e4b7ed 100644 --- a/monitor.c +++ b/monitor.c @@ -70,6 +70,14 @@ typedef struct mon_cmd_t { const char *help; } mon_cmd_t; +/* file descriptors passed via SCM_RIGHTS */ +typedef struct mon_fd_t mon_fd_t; +struct mon_fd_t { + char *name; + int fd; + LIST_ENTRY(mon_fd_t) next; +}; + struct Monitor { CharDriverState *chr; int flags; @@ -80,6 +88,7 @@ struct Monitor { CPUState *mon_cpu; BlockDriverCompletionFunc *password_completion_cb; void *password_opaque; + LIST_HEAD(,mon_fd_t) fds; LIST_ENTRY(Monitor) entry; }; @@ -1705,6 +1714,66 @@ static void do_inject_mce(Monitor *mon, } #endif +static void do_getfd(Monitor *mon, const char *fdname) +{ + mon_fd_t *monfd; + int fd; + + fd = qemu_chr_get_msgfd(mon->chr); + if (fd == -1) { + monitor_printf(mon, "getfd: no file descriptor supplied via SCM_RIGHTS\n"); + return; + } + + if (qemu_isdigit(fdname[0])) { + monitor_printf(mon, "getfd: monitor names may not begin with a number\n"); + return; + } + + fd = dup(fd); + if (fd == -1) { + monitor_printf(mon, "Failed to dup() file descriptor: %s\n", + strerror(errno)); + return; + } + + LIST_FOREACH(monfd, &mon->fds, next) { + if (strcmp(monfd->name, fdname) != 0) { + continue; + } + + close(monfd->fd); + monfd->fd = fd; + return; + } + + monfd = qemu_mallocz(sizeof(mon_fd_t)); + monfd->name = qemu_strdup(fdname); + monfd->fd = fd; + + LIST_INSERT_HEAD(&mon->fds, monfd, next); +} + +static void do_closefd(Monitor *mon, const char *fdname) +{ + mon_fd_t *monfd; + + LIST_FOREACH(monfd, &mon->fds, next) { + if (strcmp(monfd->name, fdname) != 0) { + continue; + } + + LIST_REMOVE(monfd, next); + close(monfd->fd); + qemu_free(monfd->name); + qemu_free(monfd); + return; + } + + monitor_printf(mon, "Failed to find file descriptor named %s\n", + fdname); +} + static const mon_cmd_t mon_cmds[] = { #include "qemu-monitor.h" { NULL, NULL, }, diff --git a/qemu-monitor.hx b/qemu-monitor.hx index 70e24758c..11bdb2c2d 100644 --- a/qemu-monitor.hx +++ b/qemu-monitor.hx @@ -626,6 +626,24 @@ ETEXI STEXI @item mce @var{cpu} @var{bank} @var{status} @var{mcgstatus} @var{addr} @var{misc} Inject an MCE on the given CPU (x86 only). +ETEXI + + { "getfd", "s", do_getfd, "getfd name", + "receive a file descriptor via SCM rights and assign it a name" }, +STEXI +@item getfd @var{fdname} +If a file descriptor is passed alongside this command using the SCM_RIGHTS +mechanism on unix sockets, it is stored using the name @var{fdname} for +later use by other monitor commands. +ETEXI + + { "closefd", "s", do_closefd, "closefd name", + "close a file descriptor previously passed via SCM rights" }, +STEXI +@item closefd @var{fdname} +Close the file descriptor previously assigned to @var{fdname} using the +@code{getfd} command. This is only needed if the file descriptor was never +used by another monitor command. ETEXI STEXI -- cgit v1.2.3 From 413fb2412d1ff956099e1b1a76ee9a7e41c69e4a Mon Sep 17 00:00:00 2001 From: Mark McLoughlin Date: Wed, 22 Jul 2009 09:11:42 +0100 Subject: Add support for fd=name to tap and socket networking This allows a program to initialize a host networking device using a file descriptor passed over a unix monitor socket. The program must first pass the file descriptor using SCM_RIGHTS ancillary data with the getfd monitor command. It then may do "host_net_add tap fd=name" to use the named file descriptor. Signed-off-by: Mark McLoughlin Signed-off-by: Anthony Liguori --- net.c | 42 +++++++++++++++++++++++++++++++++++------- 1 file changed, 35 insertions(+), 7 deletions(-) diff --git a/net.c b/net.c index 1c2c7d06a..cf6b0337e 100644 --- a/net.c +++ b/net.c @@ -2411,6 +2411,23 @@ void qemu_check_nic_model_list(NICInfo *nd, const char * const *models, exit(exit_status); } +static int net_handle_fd_param(Monitor *mon, const char *param) +{ + if (!qemu_isdigit(param[0])) { + int fd; + + fd = monitor_get_fd(mon, param); + if (fd == -1) { + config_error(mon, "No file descriptor named %s found", param); + return -1; + } + + return fd; + } else { + return strtol(param, NULL, 0); + } +} + int net_client_init(Monitor *mon, const char *device, const char *p) { char buf[1024]; @@ -2651,14 +2668,20 @@ int net_client_init(Monitor *mon, const char *device, const char *p) static const char * const fd_params[] = { "vlan", "name", "fd", "sndbuf", NULL }; + ret = -1; if (check_params(chkbuf, sizeof(chkbuf), fd_params, p) < 0) { config_error(mon, "invalid parameter '%s' in '%s'\n", chkbuf, p); - ret = -1; goto out; } - fd = strtol(buf, NULL, 0); + fd = net_handle_fd_param(mon, buf); + if (fd == -1) { + goto out; + } fcntl(fd, F_SETFL, O_NONBLOCK); s = net_tap_fd_init(vlan, device, name, fd); + if (!s) { + close(fd); + } } else { static const char * const tap_params[] = { "vlan", "name", "ifname", "script", "downscript", "sndbuf", NULL @@ -2698,15 +2721,20 @@ int net_client_init(Monitor *mon, const char *device, const char *p) "vlan", "name", "fd", NULL }; int fd; + ret = -1; if (check_params(chkbuf, sizeof(chkbuf), fd_params, p) < 0) { config_error(mon, "invalid parameter '%s' in '%s'\n", chkbuf, p); - ret = -1; goto out; } - fd = strtol(buf, NULL, 0); - ret = -1; - if (net_socket_fd_init(vlan, device, name, fd, 1)) - ret = 0; + fd = net_handle_fd_param(mon, buf); + if (fd == -1) { + goto out; + } + if (!net_socket_fd_init(vlan, device, name, fd, 1)) { + close(fd); + goto out; + } + ret = 0; } else if (get_param_value(buf, sizeof(buf), "listen", p) > 0) { static const char * const listen_params[] = { "vlan", "name", "listen", NULL -- cgit v1.2.3 From 355b84933d2adf031850456491aaf6fd4af23f38 Mon Sep 17 00:00:00 2001 From: Anthony Liguori Date: Thu, 16 Jul 2009 22:02:43 -0500 Subject: Move CLOCKLIBS and PTHREADLIBS out of CONFIG_LINUX_USER_ONLY Otherwise, -lrt doesn't get added to the softmmu build. Signed-off-by: Anthony Liguori --- Makefile.target | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Makefile.target b/Makefile.target index 327b03b33..f9cd42a94 100644 --- a/Makefile.target +++ b/Makefile.target @@ -262,8 +262,6 @@ endif obj-y = main.o syscall.o strace.o mmap.o signal.o path.o thunk.o \ elfload.o linuxload.o uaccess.o envlist.o gdbstub.o gdbstub-xml.o \ ioport-user.o -LIBS+= $(PTHREADLIBS) -LIBS+= $(CLOCKLIBS) obj-$(TARGET_HAS_BFLT) += flatload.o ifdef TARGET_HAS_ELFLOAD32 @@ -289,6 +287,9 @@ signal.o: CFLAGS += $(HELPER_CFLAGS) ARLIBS=../libqemu_user.a libqemu.a endif #CONFIG_LINUX_USER +LIBS+= $(PTHREADLIBS) +LIBS+= $(CLOCKLIBS) + ######################################################### # Darwin user emulator target -- cgit v1.2.3 From 8be3691a9adcf8e75b77dffedd76837504e54c46 Mon Sep 17 00:00:00 2001 From: Anthony Liguori Date: Wed, 29 Jul 2009 11:47:31 -0500 Subject: Update Changelog and VERSION for 0.11.0-rc1 release Signed-off-by: Anthony Liguori --- Changelog | 89 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ VERSION | 2 +- 2 files changed, 90 insertions(+), 1 deletion(-) diff --git a/Changelog b/Changelog index 2a3e37d2b..47e20ec47 100644 --- a/Changelog +++ b/Changelog @@ -1,3 +1,92 @@ +version 0.11.0-rc1 + - add machine aliasing support (Mark McLoughlin) + - add getfd/closefd monitor commands (Mark McLoughlin) + - use correct headers for tap-win32 (Filip Navara) + - fix live migration (Glauber Costa) + - slirp: use monotonic clock if available (Ed Swierk) + - clear msix_entries_nr on error (Michael Tsirkin) + - HPET: fix reg writes (Beth Kon) + - slirp: fix guestfwd for incoming data (Jan Kiszka) + - fix build of qemu-thread.c on win32 (Sebastian Herbszt) + - improve signrom.sh portability (Christoph Egger) + - fix qemu-img convert to copy unallocated parts of the image + (Akkarit Sangpetch) + - vmdk: fix backing file handling (Kevin Wolf) + - scsi: add save/restore support (Nolan Leake) + - fix live migration for SCSI (Nolan Leake) + - various sparc build fixes (Blue Swirl) + - fix OpenBSD build (Blue Swirl) + - only allow -cpu host when using KVM (Anthony Liguori) + - fix build breakage when !KVM (Anthony Liguori) + +version 0.10.6: + - e1000: ignore reset command (Kevin Wolf) + - fix VNC memory allocation (Stefan Weil) + - fix raw_pread_aligned return value (Christoph Hellwig) + - allow monitor interaction when using -incoming exec: (Chris Lalancette) + - fix -net socket,listen (Jan Kiszka) + - live migration: don't send gratuitous packets all at once (Gleb Natapov) + - serial: fix lost characters after sysrq (Jason Wessel) + - Fix prototype of zfree (Stefan Weil) + - Handle EINTR with exec: migration (Uri Lublin) + - Delete io-handler before closing fd after migration (Uri Lublin) + - Fix qemu_aio_flush (Andrea Arcangeli) + - lsi53c895a: Implement additional registers (Sebastian Herbszt) + - virtio-blk: fix warning (Gerd Hoffman) + - i386: fix cpu reset (Nitin Kamble) + - kvm: fix irq injection into full queue (Jan Kiszka) + - Prevent CD-ROM eject while device is locked (Mark McLoughlin) + - Fix screen dump with blank screen (Eduardo Habkost) + - Fix memory leak with cpu_unregister_map_client (Isaku Yamahata) + - Fix memory leak in SDL (Jan Kiszka) + - Fix build on OS X 10.4 (John Arbuckle) + - Fix leak of vlan clients after hot remove (Mark McLoughlin) + - Fix migration after hot remove with eepro100 (Mark McLoughlin) + - Don't start a VM after failed migration if stopped (Anthony Liguori) + - Fix live migration under heavy IO load (Glauber Costa) + - Honor -S on incoming migration (Paolo Bonzini) + - Reset HPET config register on reset (Beth Kon) + - Reset PS2 keyboard/mouse on reset (Dinesh Subraveti) + +version 0.10.5: + - kvm: trim unsupported cpu features from cpuid (Avi Kivity) + - kvm: provide a better error message for -smp > 1 (Mark McLoughlin) + - Remove initrd printfs (Richard Jones) + - Initial variables found by valgrind (Jean-Christophe Dubois) + - Fix -initrd with > 4GB guests (Glauber Costa) + - Fix busy loop on live migration for certain platforms (Uri Lublin) + - Remove GCC 3.x requirements from docs (Hollis Blanchard) + - ETRAX: fixes for kernel command line, ethernet address, bmi (Edgar Iglesias) + - CRIS: Fix bmi (Edgar Iglesias) + - Fix bounce buffer errors (Avi Kivity) + - Fix regression in -kernel (Anthony Liguori) + +version 0.10.4: + - Improve block range checks to remove integer overflow (Kevin Wolf) + - e1000: do not re-init PCI config space 0 (Amit Shah) + - fix AIO deletion race (Alex Graf) + - reset option roms on reboot (Glauber Costa) + - fix qcow2 corruption in cluster freeing (Gleb Natapov) + - Enable power button event generation (Gleb Natapov) + +version 0.10.3: + - fix AIO cancellations (Avi Kivity) + - fix live migration error path on incoming + - avoid SEGV on pci hotplug failure (Chris Wright) + - fix serial option in -drive + - support DDIM for option roms (Glauber Costa) + - avoid fork/exec on pre-2.6.27 kernels with KVM (Jan Kiszka) + - block-vpc: don't silently create smaller images than requested (Kevin Wolf) + - Fix non-ACPI timer interrupt routing (Beth Kon) + - hpet: fix emulation of HPET_TN_SETVAL (Jan Kiszka) + - kvm: fix cpuid initialization (Jan Kiszka) + - qcow2: fix corruption on little endian hosts (Kevin Wolf) + - avoid leaing memory on hot unplug (Mark McLoughlin) + - fix savevm/migration after hot unplug (Mark McLoughlin) + - Fix keyboard mapping on newer Xords with non-default keymaps (balrog) + - Make PCI config status register read-only (Anthony Liguori) + - Fix crash on resolution change -> screen dump -> vga redraw (Avi Kivity) + version 0.10.2: - fix savevm/loadvm (Anthony Liguori) diff --git a/VERSION b/VERSION index 40a85edc3..3117e0c4e 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.10.90 +0.10.91 -- cgit v1.2.3