Re: [Qemu-devel] [PATCH v3 6/7] pcspk: Convert to qdev
On 2012-02-01 08:29, Paolo Bonzini wrote: On 01/31/2012 09:49 PM, Anthony Liguori wrote: +DEFINE_PROP_HEX32(iobase, PCSpkState, iobase, -1), +DEFINE_PROP_PTR(pit, PCSpkState, pit), Please don't introduce a pointer property here. They cannot be used in a meaningful way in qdev. Why not register a linkTYPE_PIT in instance_init? I'm going to clean this up, you can leave the PTR for now. OK, will then ship v4 with this property still in place and count on you. Jan -- Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux
Re: [Qemu-devel] [PATCH] block: Add support for vpc Fixed Disk type
Am 01.02.2012 00:04, schrieb Charles Arnold: Thanks Andreas, The 'TODO uuid is missing' comment in the patch is from the original sources (as well as many '//' comments). The vhd footer and header data structures contain a field for a UUID but no code was ever developed to generate one. The revised patch is below after running scripts/checkpatch.pl and fixing the 32 bit issues. - Charles The Virtual Hard Disk Image Format Specification allows for three types of hard disk formats, Fixed, Dynamic, and Differencing. Qemu currently only supports Dynamic disks. This patch adds support for the Fixed Disk format. Usage: Example 1: qemu-img create -f vpc -o type=fixed filename [size] Example 2: qemu-img convert -O vpc -o type=fixed input filename output filename While it is also allowed to specify '-o type=dynamic', the default disk type remains Dynamic and is what is used when the type is left unspecified. Signed-off-by: Charles Arnold carn...@suse.com You have a lot of trailing whitespace in your patch, to the extent that the patch is corrupted: error: block/vpc.c : does not exist in index Please consider using git send-email. diff --git a/block/vpc.c b/block/vpc.c index 89a5ee2..04db372 100644 --- a/block/vpc.c +++ b/block/vpc.c @@ -160,14 +160,25 @@ static int vpc_open(BlockDriverState *bs, int flags) struct vhd_dyndisk_header* dyndisk_header; uint8_t buf[HEADER_SIZE]; uint32_t checksum; +int disk_type = VHD_DYNAMIC; int err = -1; if (bdrv_pread(bs-file, 0, s-footer_buf, HEADER_SIZE) != HEADER_SIZE) goto fail; footer = (struct vhd_footer*) s-footer_buf; -if (strncmp(footer-creator, conectix, 8)) -goto fail; +if (strncmp(footer-creator, conectix, 8)) { +int64_t offset = bdrv_getlength(bs-file); bdrv_getlength can fail. +/* If a fixed disk, the footer is found only at the end of the file */ +if (bdrv_pread(bs-file, offset-HEADER_SIZE, s-footer_buf, HEADER_SIZE) +!= HEADER_SIZE) { +goto fail; +} +if (strncmp(footer-creator, conectix, 8)) { +goto fail; +} +disk_type = VHD_FIXED; +} checksum = be32_to_cpu(footer-checksum); footer-checksum = 0; @@ -186,6 +197,14 @@ static int vpc_open(BlockDriverState *bs, int flags) goto fail; } +/* The footer is all that is needed for fixed disks */ +if (disk_type == VHD_FIXED) { +/* The fixed disk format doesn't use footer-data_offset but it + should be initialized */ +footer-data_offset = be64_to_cpu(0xULL); Why should it be changed? s-footer_buf is only used for updating the footer, so you will change the value that is in the image file. +return 0; This leaves most of BDRVVPCState uninitialised. I can't imagine how bdrv_read/write could possibly work with an image in this state. Something essential seems to be missing here. +} +
Re: [Qemu-devel] [PATCH 1/4] i8254: Factor out base class for KVM reuse
On 01/31/2012 10:49 PM, Jan Kiszka wrote: Just make the methods that you want to override virtual with the default implementation and then make a KVMPIT that inherits from the PIT and then overrides whatever virtual functions it needs to. That doesn't sound like the proper design for this purpose. Rather, we have an abstract base class that both implementations are derived from. Absolutely! If I'm not using QOM properly to achieve this, please tell me. It looks good, besides the need to rebase to Anthony's part 3 changes. Paolo
Re: [Qemu-devel] [PATCH 1/4] i8254: Factor out base class for KVM reuse
On 2012-02-01 13:23, Paolo Bonzini wrote: On 01/31/2012 10:49 PM, Jan Kiszka wrote: Just make the methods that you want to override virtual with the default implementation and then make a KVMPIT that inherits from the PIT and then overrides whatever virtual functions it needs to. That doesn't sound like the proper design for this purpose. Rather, we have an abstract base class that both implementations are derived from. Absolutely! If I'm not using QOM properly to achieve this, please tell me. It looks good, besides the need to rebase to Anthony's part 3 changes. Given that this part is not upstream and that the relevant conversion is scripted, I would leave this to Anthony so far. Or what is the schedule? Jan -- Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux
[Qemu-devel] git bisect results: ec757c67c40a56492001487e69272f62144fd124 breaks windows boot in qemu-kvm
Hi all, first of all I'm a bit confused: What is the difference between qemu with command line option --enable-kvm and qemu-kvm? It seems to be a difference in code so far, from the performance point of view it seems to be the same... Now my issue that lead me to a git bisect on qemu-kvm: The following commit / merge breaks my windows guest boot sequence and causes resets infinitely: ec757c67c40a56492001487e69272f62144fd124 Merge branch 'upstream-merge' into next Thu, 5 Jan 2012 11:00:07 + (13:00 +0200)Avi Kivity a...@redhat.com Interesting: qemu with --enable-kvm master and the same command line options as qemu-kvm runs perfect. My command line options are: qemu-system-x86_64 -serial /dev/ttyS2 -readconfig /etc/ich9-ehci-uhci.cfg -device usb-host,bus=ehci.0 -device usb-tablet -drive file=/dev/sda2,cache=off -m 1024 -net nic,macaddr=$MACADDR -net tap,script=/etc/qemu-ifup -no-acpi -monitor stdio -L /usr/X11R6/share/qemu -boot c -localtime Best regards, Erik
Re: [Qemu-devel] [PATCH 1/4] i8254: Factor out base class for KVM reuse
On 02/01/2012 01:43 PM, Jan Kiszka wrote: It looks good, besides the need to rebase to Anthony's part 3 changes. Given that this part is not upstream and that the relevant conversion is scripted, I would leave this to Anthony so far. Or what is the schedule? By the time your series is reviewed, gets to uq/master and it is posted, it's likely that he'll get first. He said he'll post a tree soonish, been waiting for that myself so I can post virtio-scsi... :) Paolo
[Qemu-devel] [PATCH RFC v2 8/8] target-arm: Move CPU feature flags out of CPUState
The internal CPU feature flags were only ever set in cpu_reset_model_id(). Therefore move their initialization into ARMCPUClass. We might want to tweak them in the future though (e.g., -cpu cortex-r4,+fpu), so keep a copy in ARMCPU. This in turn means we need to infer features for both ARMCPUClass and ARMCPU, so move feature inference to arm_infer_features() and use macros to simplify it. Since cpu.h defines ARMCPUState, which has been incorporated into ARMCPU, and tries to use arm_feature() in cpu_get_tb_cpu_state(), move arm_feature() to cpu-core.h and add a forward declaration. Signed-off-by: Andreas Färber afaer...@suse.de Cc: Peter Maydell peter.mayd...@linaro.org --- target-arm/cpu-core.c | 159 + target-arm/cpu-core.h | 12 target-arm/cpu.h |9 +-- target-arm/helper.c | 95 - target-arm/machine.c |6 +- 5 files changed, 177 insertions(+), 104 deletions(-) diff --git a/target-arm/cpu-core.c b/target-arm/cpu-core.c index 8284418..3dac540 100644 --- a/target-arm/cpu-core.c +++ b/target-arm/cpu-core.c @@ -15,27 +15,126 @@ static void arm_cpu_reset(CPU *c) cpu_common_reset(c); } +/* CPU feature flags */ + +#define ARM_FEATURE(x) (1u ARM_FEATURE_ ## x) + +#define has_feature(x) ((*features ARM_FEATURE(x)) != 0) +#define set_feature(x) (*features |= ARM_FEATURE(x)) + +/** + * arm_infer_features: + * @features: Pointer to the feature flags of #ARMCPUClass or #ARMCPU. + * + * Some features automatically imply others. + */ +static void arm_infer_features(uint32_t *features) +{ +if (has_feature(V7)) { +set_feature(VAPA); +set_feature(THUMB2); +if (!has_feature(M)) { +set_feature(V6K); +} else { +set_feature(V6); +} +} +if (has_feature(V6K)) { +set_feature(V6); +} +if (has_feature(V6)) { +set_feature(V5); +if (!has_feature(M)) { +set_feature(AUXCR); +} +} +if (has_feature(V5)) { +set_feature(V4T); +} +if (has_feature(M)) { +set_feature(THUMB_DIV); +} +if (has_feature(ARM_DIV)) { +set_feature(THUMB_DIV); +} +if (has_feature(VFP4)) { +set_feature(VFP3); +} +if (has_feature(VFP3)) { +set_feature(VFP); +} +} + +#undef has_feature +#undef set_feature + +static inline void set_class_feature(ARMCPUClass *klass, int feature) +{ +klass-features |= 1u feature; +} + +static inline void unset_class_feature(ARMCPUClass *klass, int feature) +{ +klass-features = ~(1u feature); +} + /* CPU models */ typedef struct ARMCPUInfo { const char *name; const char *alias; uint32_t id; +uint32_t features; void (*class_init)(ARMCPUClass *klass, const struct ARMCPUInfo *info); } ARMCPUInfo; +static void arm1136_r0_class_init(ARMCPUClass *k, const ARMCPUInfo *info) +{ +ARMCPUClass *r1_class; + +r1_class = ARM_CPU_CLASS(object_class_by_name(arm1136)); + +k-features = r1_class-features; +unset_class_feature(k, ARM_FEATURE_V6K); +} + +static void sa11xx_class_init(ARMCPUClass *k, const ARMCPUInfo *info) +{ +set_class_feature(k, ARM_FEATURE_STRONGARM); +} + +static void pxa25x_class_init(ARMCPUClass *k, const ARMCPUInfo *info) +{ +set_class_feature(k, ARM_FEATURE_V5); +set_class_feature(k, ARM_FEATURE_XSCALE); +} + +static void pxa270_class_init(ARMCPUClass *k, const ARMCPUInfo *info) +{ +set_class_feature(k, ARM_FEATURE_V5); +set_class_feature(k, ARM_FEATURE_XSCALE); +set_class_feature(k, ARM_FEATURE_IWMMXT); +} + static const ARMCPUInfo arm_cpus[] = { { .name = arm926, .id = 0x41069265, +.features = ARM_FEATURE(V5) | +ARM_FEATURE(VFP), }, { .name = arm946, .id = 0x41059461, +.features = ARM_FEATURE(V5) | +ARM_FEATURE(MPU), }, { .name = arm1026, .id = 0x4106a262, +.features = ARM_FEATURE(V5) | +ARM_FEATURE(VFP) | +ARM_FEATURE(AUXCR), }, /* What QEMU calls arm1136-r2 is actually the 1136 r0p2, i.e. an * older core than plain arm1136. In particular this does not @@ -44,95 +143,150 @@ static const ARMCPUInfo arm_cpus[] = { { .name = arm1136-r2, .id = 0x4107b362, +.class_init = arm1136_r0_class_init, }, { .name = arm1136, .id = 0x4117b363, +.features = ARM_FEATURE(V6) | +ARM_FEATURE(VFP), }, { .name = arm1176, .id = 0x410fb767, +.features = ARM_FEATURE(V6K) | +ARM_FEATURE(VFP) | +ARM_FEATURE(VAPA), }, { .name = arm11mpcore, .id = 0x410fb022, +.features = ARM_FEATURE(V6K) | +ARM_FEATURE(VFP) | +ARM_FEATURE(VAPA),
Re: [Qemu-devel] [PATCH v2] arm: add device tree support
On 01/31/2012 08:40 PM, John Williams wrote: On Wed, Feb 1, 2012 at 12:37 PM, Anthony Liguorianth...@codemonkey.ws wrote: Globals are even worse! Can't you hear the kernel loader begging to be turned into a device? It's pleading with us to stop abusing other parts of QEMU and make it a first class citizen of QEMU. Is there some kind of initialisation phase where such a device can do its thing? Unless I'm missing something a loader device will be racing the rest of the VM after reset to populate the memory with the desired contents, no? How does it race? Devices normally never touch memory so a loader device will be the only thing mucking with memory. Regards, Anthony Liguori John
Re: [Qemu-devel] [PATCH 1/4] i8254: Factor out base class for KVM reuse
On 2012-02-01 13:55, Paolo Bonzini wrote: On 02/01/2012 01:43 PM, Jan Kiszka wrote: It looks good, besides the need to rebase to Anthony's part 3 changes. Given that this part is not upstream and that the relevant conversion is scripted, I would leave this to Anthony so far. Or what is the schedule? By the time your series is reviewed, gets to uq/master and it is posted, it's likely that he'll get first. This is no uq/master material. He said he'll post a tree soonish, been waiting for that myself so I can post virtio-scsi... :) Yep, once there is a tree to work against, rebasing is also possible. Jan -- Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux
Re: [Qemu-devel] [PATCH v2] arm: add device tree support
On 1 February 2012 13:04, Anthony Liguori anth...@codemonkey.ws wrote: How does it race? Devices normally never touch memory so a loader device will be the only thing mucking with memory. The obvious one is loader reset function wants to set starting PC to entry point of kernel/etc vs CPU device reset wants to set starting PC to hardware-mandated reset vector. We have this at the moment, of course, and I think we implicitly rely on reset handlers being called in order of registration... (The other irritating case is where the CPU device reset wants to read the starting PC out of memory, like the Cortex-M3, but really that one is because we don't distinguish going into reset from coming out of reset.) -- PMM
Re: [Qemu-devel] [PATCH 1/4] i8254: Factor out base class for KVM reuse
On 2012-02-01 14:10, Jan Kiszka wrote: On 2012-02-01 13:55, Paolo Bonzini wrote: On 02/01/2012 01:43 PM, Jan Kiszka wrote: It looks good, besides the need to rebase to Anthony's part 3 changes. Given that this part is not upstream and that the relevant conversion is scripted, I would leave this to Anthony so far. Or what is the schedule? By the time your series is reviewed, gets to uq/master and it is posted, it's likely that he'll get first. This is no uq/master material. Err, sorry, wrong series. It is of course. :) Jan -- Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux
[Qemu-devel] [PATCH RFC v2 1/8] qom: Allow object_class_foreach() to take additional parameters to refine search
From: Anthony Liguori aligu...@us.ibm.com Signed-off-by: Anthony Liguori aligu...@us.ibm.com Signed-off-by: Andreas Färber afaer...@suse.de --- include/qemu/object.h |1 + qom/object.c | 18 -- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/include/qemu/object.h b/include/qemu/object.h index ba37850..adbcfb1 100644 --- a/include/qemu/object.h +++ b/include/qemu/object.h @@ -431,6 +431,7 @@ const char *object_class_get_name(ObjectClass *klass); ObjectClass *object_class_by_name(const char *typename); void object_class_foreach(void (*fn)(ObjectClass *klass, void *opaque), + const char *implements_type, bool include_abstract, void *opaque); #endif diff --git a/qom/object.c b/qom/object.c index a12895f..3dabb1a 100644 --- a/qom/object.c +++ b/qom/object.c @@ -467,6 +467,8 @@ ObjectClass *object_class_by_name(const char *typename) typedef struct OCFData { void (*fn)(ObjectClass *klass, void *opaque); +const char *implements_type; +bool include_abstract; void *opaque; } OCFData; @@ -475,16 +477,28 @@ static void object_class_foreach_tramp(gpointer key, gpointer value, { OCFData *data = opaque; TypeImpl *type = value; +ObjectClass *k; type_class_init(type); +k = type-class; -data-fn(value, type-class); +if (!data-include_abstract type-abstract) { +return; +} + +if (data-implements_type +!object_class_dynamic_cast(k, data-implements_type)) { +return; +} + +data-fn(k, data-opaque); } void object_class_foreach(void (*fn)(ObjectClass *klass, void *opaque), + const char *implements_type, bool include_abstract, void *opaque) { -OCFData data = { fn, opaque }; +OCFData data = { fn, implements_type, include_abstract, opaque }; g_hash_table_foreach(type_table_get(), object_class_foreach_tramp, data); } -- 1.7.7
[Qemu-devel] [PATCH RFC v2 6/8] target-arm: Embed CPUARMState in QOM ARMCPU
We g_malloc0()'ed CPUARMState ourself, and exec.c's cpu_copy() runs through cpu_init() as well, so we are at liberty to supply the CPUState any way we see fit. Having CPUARMState as field in the QOM CPU allows both to access env from an ARMCPU object and to access the QOM Object and its ObjectClass from an env pointer, in ARM code for now. The goal is to convert all CPUs to QOM and to use CPU objects in central places, especially once we have property support for Object. This will then allow to have TCG AREG0 point to target-specific fields where small immediate offsets are desired (as pointed out by rth) while allowing for common fields at known offsets from the base class. Having the CPUID in ARMCPUClass, we can set it from the instance_init function. Same for cpu_model_str, which is now the QOM class name. Make cpu_reset() call cpu_do_reset(). Signed-off-by: Andreas Färber afaer...@suse.de Cc: Anthony Liguori anth...@codemonkey.ws Cc: Paul Brook p...@codesourcery.com Cc: Peter Maydell peter.mayd...@linaro.org Cc: Richard Henderson r...@twiddle.net --- target-arm/cpu-core.c | 13 + target-arm/cpu-core.h | 11 +++ target-arm/helper.c | 15 --- 3 files changed, 32 insertions(+), 7 deletions(-) diff --git a/target-arm/cpu-core.c b/target-arm/cpu-core.c index b255741..1caf9aa 100644 --- a/target-arm/cpu-core.c +++ b/target-arm/cpu-core.c @@ -135,6 +135,18 @@ static const ARMCPUInfo arm_cpus[] = { }, }; +static void arm_cpu_initfn(Object *obj) +{ +ARMCPU *cpu = ARM_CPU(obj); +ARMCPUClass *cpu_class = ARM_CPU_GET_CLASS(obj); + +memset(cpu-env, 0, sizeof(CPUARMState)); +cpu_exec_init(cpu-env); + +cpu-env.cpu_model_str = object_get_typename(obj); +cpu-env.cp15.c0_cpuid = cpu_class-id; +} + static void arm_cpu_class_init(ObjectClass *klass, void *data) { ARMCPUClass *k = ARM_CPU_CLASS(klass); @@ -152,6 +164,7 @@ static void cpu_register(const ARMCPUInfo *info) .name = info-name, .parent = TYPE_ARM_CPU, .instance_size = sizeof(ARMCPU), +.instance_init = arm_cpu_initfn, .class_size = sizeof(ARMCPUClass), .class_init = arm_cpu_class_init, .class_data = (void *)info, diff --git a/target-arm/cpu-core.h b/target-arm/cpu-core.h index ccc5503..cd3af77 100644 --- a/target-arm/cpu-core.h +++ b/target-arm/cpu-core.h @@ -10,6 +10,7 @@ #define QEMU_ARM_CPU_CORE_H #include qemu/cpu.h +#include cpu.h #define TYPE_ARM_CPU arm-cpu @@ -39,7 +40,17 @@ typedef struct ARMCPUClass { */ typedef struct ARMCPU { CPU parent_obj; + +/* TODO Inline this and split off common state */ +CPUARMState env; } ARMCPU; +static inline Object *arm_env_get_object(CPUARMState *env) +{ +return OBJECT((void *)(env) - offsetof(ARMCPU, env)); +} + +#define ENV_GET_OBJECT(e) arm_env_get_object(e) + #endif diff --git a/target-arm/helper.c b/target-arm/helper.c index 3f34d8d..34b1d24 100644 --- a/target-arm/helper.c +++ b/target-arm/helper.c @@ -292,6 +292,8 @@ void cpu_reset(CPUARMState *env) log_cpu_state(env, 0); } +cpu_do_reset(CPU(ENV_GET_OBJECT(env))); + id = env-cp15.c0_cpuid; tmp = env-cp15.c15_config_base_address; memset(env, 0, offsetof(CPUARMState, breakpoints)); @@ -400,7 +402,7 @@ static int vfp_gdb_set_reg(CPUState *env, uint8_t *buf, int reg) CPUARMState *cpu_arm_init(const char *cpu_model) { ObjectClass *klass; -ARMCPUClass *cpu_class; +ARMCPU *cpu; CPUARMState *env; static int inited = 0; @@ -408,16 +410,14 @@ CPUARMState *cpu_arm_init(const char *cpu_model) if (klass == NULL) { return NULL; } -cpu_class = ARM_CPU_CLASS(klass); -env = g_malloc0(sizeof(CPUARMState)); -cpu_exec_init(env); +cpu = ARM_CPU(object_new_with_type(klass-type)); +env = cpu-env; + if (tcg_enabled() !inited) { inited = 1; arm_translate_init(); } -env-cpu_model_str = cpu_model; -env-cp15.c0_cpuid = cpu_class-id; cpu_reset(env); if (arm_feature(env, ARM_FEATURE_NEON)) { gdb_register_coprocessor(env, vfp_gdb_get_reg, vfp_gdb_set_reg, @@ -459,7 +459,8 @@ void arm_cpu_list(FILE *f, fprintf_function cpu_fprintf) void cpu_arm_close(CPUARMState *env) { -g_free(env); +Object *obj = ENV_GET_OBJECT(env); +object_delete(obj); } static int bad_mode_switch(CPUState *env, int mode) -- 1.7.7
Re: [Qemu-devel] [PATCH 1/4] i8254: Factor out base class for KVM reuse
On 02/01/2012 06:43 AM, Jan Kiszka wrote: On 2012-02-01 13:23, Paolo Bonzini wrote: On 01/31/2012 10:49 PM, Jan Kiszka wrote: Just make the methods that you want to override virtual with the default implementation and then make a KVMPIT that inherits from the PIT and then overrides whatever virtual functions it needs to. That doesn't sound like the proper design for this purpose. Rather, we have an abstract base class that both implementations are derived from. Absolutely! If I'm not using QOM properly to achieve this, please tell me. It looks good, besides the need to rebase to Anthony's part 3 changes. Given that this part is not upstream and that the relevant conversion is scripted, I would leave this to Anthony so far. Or what is the schedule? I haven't run through regression testing yet so YMMV but the latest series is at: https://github.com/aliguori/qemu/tree/qom-upstream.13 Regards, Anthony Liguori Jan
[Qemu-devel] [PATCH RFC v2 5/8] target-arm: Introduce QOM CPU and use it for CPUID lookup
Create a CPU subclass, and register classes matching all CPU models. Don't name the file target-arm/cpu.c so that the user emulators can still easily pick up the base class in hw/cpu.c via VPATH. Make arm_cpu_list() enumerate CPU subclasses. Replace cpu_arm_find_by_name()'s string - CPUID lookup by storing the CPUID in the class. NB: CPUIDs were first introduced by Paul Brook in r1765 (2006). Signed-off-by: Andreas Färber afaer...@suse.de Cc: Anthony Liguori anth...@codemonkey.ws Cc: Paul Brook p...@codesourcery.com Cc: Peter Maydell peter.mayd...@linaro.org --- Makefile.target |1 + target-arm/cpu-core.c | 181 + target-arm/cpu-core.h | 45 target-arm/helper.c | 80 ++ 4 files changed, 249 insertions(+), 58 deletions(-) create mode 100644 target-arm/cpu-core.c create mode 100644 target-arm/cpu-core.h diff --git a/Makefile.target b/Makefile.target index 5d3470e..96043c4 100644 --- a/Makefile.target +++ b/Makefile.target @@ -80,6 +80,7 @@ endif libobj-$(TARGET_SPARC64) += vis_helper.o libobj-$(CONFIG_NEED_MMU) += mmu.o libobj-$(TARGET_ARM) += neon_helper.o iwmmxt_helper.o +libobj-$(TARGET_ARM) += cpu-core.o ifeq ($(TARGET_BASE_ARCH), sparc) libobj-y += fop_helper.o cc_helper.o win_helper.o mmu_helper.o ldst_helper.o libobj-y += cpu_init.o diff --git a/target-arm/cpu-core.c b/target-arm/cpu-core.c new file mode 100644 index 000..b255741 --- /dev/null +++ b/target-arm/cpu-core.c @@ -0,0 +1,181 @@ +/* + * QEMU ARM CPU core + * + * Copyright (c) 2012 SUSE LINUX Products GmbH + * + * Licensed under the terms of the GNU GPL version 2 + * or (at your option) any later version. + */ + +#include cpu-core.h +#include qemu-common.h + +static void arm_cpu_reset(CPU *c) +{ +cpu_common_reset(c); +} + +/* CPU models */ + +typedef struct ARMCPUInfo { +const char *name; +const char *alias; +uint32_t id; +} ARMCPUInfo; + +static const ARMCPUInfo arm_cpus[] = { +{ +.name = arm926, +.id = 0x41069265, +}, +{ +.name = arm946, +.id = 0x41059461, +}, +{ +.name = arm1026, +.id = 0x4106a262, +}, +/* What QEMU calls arm1136-r2 is actually the 1136 r0p2, i.e. an + * older core than plain arm1136. In particular this does not + * have the v6K features. + */ +{ +.name = arm1136-r2, +.id = 0x4107b362, +}, +{ +.name = arm1136, +.id = 0x4117b363, +}, +{ +.name = arm1176, +.id = 0x410fb767, +}, +{ +.name = arm11mpcore, +.id = 0x410fb022, +}, +{ +.name = cortex-m3, +.id = 0x410fc231, +}, +{ +.name = cortex-a8, +.id = 0x410fc080, +}, +{ +.name = cortex-a9, +.id = 0x410fc090, +}, +{ +.name = cortex-a15, +.id = 0x412fc0f1, +}, +{ +.name = ti925t, +.id = 0x54029252, +}, +{ +.name = sa1100, +.id = 0x4401A11B, +}, +{ +.name = sa1110, +.id = 0x6901B119, +}, +{ +.name = pxa250, +.id = 0x69052100, +}, +{ +.name = pxa255, +.id = 0x69052d00, +}, +{ +.name = pxa260, +.id = 0x69052903, +}, +{ +.name = pxa261, +.id = 0x69052d05, +}, +{ +.name = pxa262, +.id = 0x69052d06, +}, +{ +.name = pxa270-a0, +.alias = pxa270, +.id = 0x69054110, +}, +{ +.name = pxa270-a1, +.id = 0x69054111, +}, +{ +.name = pxa270-b0, +.id = 0x69054112, +}, +{ +.name = pxa270-b1, +.id = 0x69054113, +}, +{ +.name = pxa270-c0, +.id = 0x69054114, +}, +{ +.name = pxa270-c5, +.id = 0x69054117, +}, +{ +.name = any, +.id = 0x, +}, +}; + +static void arm_cpu_class_init(ObjectClass *klass, void *data) +{ +ARMCPUClass *k = ARM_CPU_CLASS(klass); +CPUClass *cpu_class = CPU_CLASS(klass); +const ARMCPUInfo *info = data; + +cpu_class-reset = arm_cpu_reset; + +k-id = info-id; +} + +static void cpu_register(const ARMCPUInfo *info) +{ +TypeInfo type = { +.name = info-name, +.parent = TYPE_ARM_CPU, +.instance_size = sizeof(ARMCPU), +.class_size = sizeof(ARMCPUClass), +.class_init = arm_cpu_class_init, +.class_data = (void *)info, +}; + +type_register_static(type); +} + +static TypeInfo arm_cpu_type_info = { +.name = TYPE_ARM_CPU, +.parent = TYPE_CPU, +.instance_size = sizeof(ARMCPU), +.abstract = true, +.class_size = sizeof(ARMCPUClass), +}; + +static void arm_cpu_types_init(void) +{ +int i; + +type_register_static(arm_cpu_type_info); +for (i = 0; i ARRAY_SIZE(arm_cpus); i++) { +cpu_register(arm_cpus[i]); +}
Re: [Qemu-devel] [PATCH v2] arm: add device tree support
On 02/01/2012 07:10 AM, Peter Maydell wrote: On 1 February 2012 13:04, Anthony Liguorianth...@codemonkey.ws wrote: How does it race? Devices normally never touch memory so a loader device will be the only thing mucking with memory. The obvious one is loader reset function wants to set starting PC to entry point of kernel/etc vs CPU device reset wants to set starting PC to hardware-mandated reset vector. We have this at the moment, of course, and I think we implicitly rely on reset handlers being called in order of registration... I'm a bit confused, why can't the kernel loader be implemented in terms of a firmware blob? This is what we do for x86 and it solves this problem robustly. Isn't it just a matter of a few instructions to do a jmp to a known location? Regards, Anthony Liguori (The other irritating case is where the CPU device reset wants to read the starting PC out of memory, like the Cortex-M3, but really that one is because we don't distinguish going into reset from coming out of reset.) -- PMM
[Qemu-devel] [PATCH RFC v2 3/8] qom: Add QOM support to user emulators
Link the Object base class and the module infrastructure for class registration. Call QOM module init. Signed-off-by: Andreas Färber afaer...@suse.de Cc: Anthony Liguori anth...@codemonkey.ws --- Makefile.target|6 ++ Makefile.user |1 + bsd-user/main.c|2 ++ darwin-user/main.c |3 +++ linux-user/main.c |2 ++ 5 files changed, 14 insertions(+), 0 deletions(-) diff --git a/Makefile.target b/Makefile.target index 68481a3..d1b7867 100644 --- a/Makefile.target +++ b/Makefile.target @@ -129,6 +129,8 @@ obj-m68k-y += m68k-sim.o m68k-semi.o $(obj-y) $(obj-$(TARGET_BASE_ARCH)-y): $(GENERATED_HEADERS) +obj-y += module.o +obj-y += $(addprefix ../qom/, $(qom-y)) obj-y += $(addprefix ../libuser/, $(user-obj-y)) obj-y += $(addprefix ../libdis-user/, $(libdis-y)) obj-y += $(libobj-y) @@ -156,6 +158,8 @@ obj-i386-y += ioport-user.o $(obj-y) $(obj-$(TARGET_BASE_ARCH)-y): $(GENERATED_HEADERS) +obj-y += module.o +obj-y += $(addprefix ../qom/, $(qom-y)) obj-y += $(addprefix ../libuser/, $(user-obj-y)) obj-y += $(addprefix ../libdis-user/, $(libdis-y)) obj-y += $(libobj-y) @@ -178,6 +182,8 @@ obj-i386-y += ioport-user.o $(obj-y) $(obj-$(TARGET_BASE_ARCH)-y): $(GENERATED_HEADERS) +obj-y += module.o +obj-y += $(addprefix ../qom/, $(qom-y)) obj-y += $(addprefix ../libuser/, $(user-obj-y)) obj-y += $(addprefix ../libdis-user/, $(libdis-y)) obj-y += $(libobj-y) diff --git a/Makefile.user b/Makefile.user index 2b1e4d1..72d01c1 100644 --- a/Makefile.user +++ b/Makefile.user @@ -9,6 +9,7 @@ include $(SRC_PATH)/rules.mak $(call set-vpath, $(SRC_PATH)) QEMU_CFLAGS+=-I.. +QEMU_CFLAGS+=-I$(SRC_PATH)/include include $(SRC_PATH)/Makefile.objs diff --git a/bsd-user/main.c b/bsd-user/main.c index cc7d4a3..cdb0d0a 100644 --- a/bsd-user/main.c +++ b/bsd-user/main.c @@ -748,6 +748,8 @@ int main(int argc, char **argv) if (argc = 1) usage(); +module_call_init(MODULE_INIT_QOM); + if ((envlist = envlist_create()) == NULL) { (void) fprintf(stderr, Unable to allocate envlist\n); exit(1); diff --git a/darwin-user/main.c b/darwin-user/main.c index 9b57c20..e1519c7 100644 --- a/darwin-user/main.c +++ b/darwin-user/main.c @@ -28,6 +28,7 @@ #include sys/mman.h #include qemu.h +#include qemu-common.h #define DEBUG_LOGFILE /tmp/qemu.log @@ -749,6 +750,8 @@ int main(int argc, char **argv) if (argc = 1) usage(); +module_call_init(MODULE_INIT_QOM); + optind = 1; for(;;) { if (optind = argc) diff --git a/linux-user/main.c b/linux-user/main.c index 64d2208..f55109c 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -3278,6 +3278,8 @@ int main(int argc, char **argv, char **envp) int i; int ret; +module_call_init(MODULE_INIT_QOM); + qemu_cache_utils_init(envp); if ((envlist = envlist_create()) == NULL) { -- 1.7.7
Re: [Qemu-devel] [PATCH v2] arm: add device tree support
On 01.02.2012, at 14:25, Anthony Liguori wrote: On 02/01/2012 07:10 AM, Peter Maydell wrote: On 1 February 2012 13:04, Anthony Liguorianth...@codemonkey.ws wrote: How does it race? Devices normally never touch memory so a loader device will be the only thing mucking with memory. The obvious one is loader reset function wants to set starting PC to entry point of kernel/etc vs CPU device reset wants to set starting PC to hardware-mandated reset vector. We have this at the moment, of course, and I think we implicitly rely on reset handlers being called in order of registration... I'm a bit confused, why can't the kernel loader be implemented in terms of a firmware blob? This is what we do for x86 and it solves this problem robustly. Isn't it just a matter of a few instructions to do a jmp to a known location? Only if you have non-semi-hosted modes. For e500 for example, we don't have a bios flash region mapped through mmio available. So we would have to write the jump to kernel code into ram. But where in RAM? Linux starts at address 0, so that one's taken. Alex
[Qemu-devel] [PATCH RFC v2 0/8] Introduce QOM CPU and use for ARM
Hello, Here's an updated series on incrementally converting CPUState to QOM. Patch 1 is cherry-picked from Anthony's QOM series 3/4. Patch 2 rearranges module init for QOM. Patch 3 add QOM support to the user emulators. Patch 4 introduces QOM CPU. Patch 5-8 Derive and start using a QOM CPU for ARM. Regards, Andreas Cc: Anthony Liguori anth...@codemonkey.ws Cc: Peter Maydell peter.mayd...@linaro.org v1 - v2: * Cherry-pick Anthony's object_class_foreach() patch. * Don't introduce extra early_init(), just relocate former MODULE_INIT_DEVICE. * Provide new type_init() macro to be used instead of device_init(). * Drop processor_init() and MODULE_INIT_CPU in favor of MODULE_INIT_DEVICE. * Prepare cast macros for CPU. * Add documentation. * Fix ARMCPUClass type name (arm-cpu-core - arm-cpu). * Add documentation. * Rename ARMCPUDef to ARMCPUInfo. * Use a C99-style table for initializing the classes through class_data instead of individual class_init functions (suggested by Anthony). * Prepare reset callback. * Make ENV_GET_OBJECT() use an inline function for readability. * Invoke the CPU's reset method from cpu_reset(). * Do feature initialization via table where sensible. * Add feature flags to ARMCPU as well (suggested by PMM for future tweaking, also simplifies load/save a bit) and initialize them from ARMCPUClass. * Make feature inference work for ARMCPU as well by not passing the ARMCPUClass. Use function-local macros to avoid the ugliness of deferencing the features pointer. Andreas Färber (7): qom: Register QOM infrastructure early qom: Add QOM support to user emulators qom: Introduce CPU class target-arm: Introduce QOM CPU and use it for CPUID lookup target-arm: Embed CPUARMState in QOM ARMCPU target-arm: Prepare model-specific class_init function target-arm: Move CPU feature flags out of CPUState Anthony Liguori (1): qom: Allow object_class_foreach() to take additional parameters to refine search Makefile.objs |1 + Makefile.target | 16 ++- Makefile.user |1 + bsd-user/main.c |2 + darwin-user/main.c|3 + hw/cpu.c | 39 ++ include/qemu/cpu.h| 62 + include/qemu/object.h |1 + linux-user/main.c |2 + module.h |5 +- qom/object.c | 18 +++- target-arm/cpu-core.c | 358 + target-arm/cpu-core.h | 68 ++ target-arm/cpu.h |9 +- target-arm/helper.c | 184 - target-arm/machine.c |6 +- vl.c |4 +- 17 files changed, 604 insertions(+), 175 deletions(-) create mode 100644 hw/cpu.c create mode 100644 include/qemu/cpu.h create mode 100644 target-arm/cpu-core.c create mode 100644 target-arm/cpu-core.h -- 1.7.7
[Qemu-devel] [PATCH RFC v2 7/8] target-arm: Prepare model-specific class_init function
This allows to share initialization between CPU models. Signed-off-by: Andreas Färber afaer...@suse.de --- target-arm/cpu-core.c |5 + 1 files changed, 5 insertions(+), 0 deletions(-) diff --git a/target-arm/cpu-core.c b/target-arm/cpu-core.c index 1caf9aa..8284418 100644 --- a/target-arm/cpu-core.c +++ b/target-arm/cpu-core.c @@ -21,6 +21,7 @@ typedef struct ARMCPUInfo { const char *name; const char *alias; uint32_t id; +void (*class_init)(ARMCPUClass *klass, const struct ARMCPUInfo *info); } ARMCPUInfo; static const ARMCPUInfo arm_cpus[] = { @@ -156,6 +157,10 @@ static void arm_cpu_class_init(ObjectClass *klass, void *data) cpu_class-reset = arm_cpu_reset; k-id = info-id; + +if (info-class_init != NULL) { +(*info-class_init)(k, info); +} } static void cpu_register(const ARMCPUInfo *info) -- 1.7.7
Re: [Qemu-devel] git bisect results: ec757c67c40a56492001487e69272f62144fd124 breaks windows boot in qemu-kvm
On 02/01/2012 02:52 PM, Erik Rull wrote: Hi all, first of all I'm a bit confused: What is the difference between qemu with command line option --enable-kvm and qemu-kvm? It seems to be a difference in code so far, from the performance point of view it seems to be the same... The differences are being reduced rapidly, thanks to Jan's efforts. Right now what remains is PIT performance and accuracy, device assignment, and Windows XP performance. Most guests should see the same performance. Now my issue that lead me to a git bisect on qemu-kvm: The following commit / merge breaks my windows guest boot sequence and causes resets infinitely: ec757c67c40a56492001487e69272f62144fd124 Merge branch 'upstream-merge' into next Thu, 5 Jan 2012 11:00:07 + (13:00 +0200)Avi Kivity a...@redhat.com Interesting: qemu with --enable-kvm master and the same command line options as qemu-kvm runs perfect. My command line options are: qemu-system-x86_64 -serial /dev/ttyS2 -readconfig /etc/ich9-ehci-uhci.cfg -device usb-host,bus=ehci.0 -device usb-tablet -drive file=/dev/sda2,cache=off -m 1024 -net nic,macaddr=$MACADDR -net tap,script=/etc/qemu-ifup -no-acpi -monitor stdio -L /usr/X11R6/share/qemu -boot c -localtime What version of Windows are you using? What's the contents of /etc/ich9-ehci-uhci.cfg? -- error compiling committee.c: too many arguments to function
[Qemu-devel] [PATCH RFC v2 4/8] qom: Introduce CPU class
It's abstract and derived directly from TYPE_OBJECT. Prepare a virtual reset method. Place it in hw/. Have user emulators pick it up via VPATH, building it per target since they didn't use any qdev/QOM devices so far. Signed-off-by: Andreas Färber afaer...@suse.de Cc: Anthony Liguori anth...@codemonkey.ws --- Makefile.objs |1 + Makefile.target|9 +-- hw/cpu.c | 39 include/qemu/cpu.h | 62 4 files changed, 108 insertions(+), 3 deletions(-) create mode 100644 hw/cpu.c create mode 100644 include/qemu/cpu.h diff --git a/Makefile.objs b/Makefile.objs index b942625..a4b20fa 100644 --- a/Makefile.objs +++ b/Makefile.objs @@ -189,6 +189,7 @@ user-obj-y += $(trace-obj-y) hw-obj-y = hw-obj-y += vl.o loader.o +hw-obj-y += cpu.o hw-obj-$(CONFIG_VIRTIO) += virtio-console.o hw-obj-y += usb-libhw.o hw-obj-$(CONFIG_VIRTIO_PCI) += virtio-pci.o diff --git a/Makefile.target b/Makefile.target index d1b7867..5d3470e 100644 --- a/Makefile.target +++ b/Makefile.target @@ -107,7 +107,7 @@ signal.o: QEMU_CFLAGS += $(HELPER_CFLAGS) ifdef CONFIG_LINUX_USER -$(call set-vpath, $(SRC_PATH)/linux-user:$(SRC_PATH)/linux-user/$(TARGET_ABI_DIR)) +$(call set-vpath, $(SRC_PATH)/linux-user:$(SRC_PATH)/linux-user/$(TARGET_ABI_DIR):$(SRC_PATH)/hw) QEMU_CFLAGS+=-I$(SRC_PATH)/linux-user/$(TARGET_ABI_DIR) -I$(SRC_PATH)/linux-user obj-y = main.o syscall.o strace.o mmap.o signal.o thunk.o \ @@ -130,6 +130,7 @@ obj-m68k-y += m68k-sim.o m68k-semi.o $(obj-y) $(obj-$(TARGET_BASE_ARCH)-y): $(GENERATED_HEADERS) obj-y += module.o +obj-y += cpu.o obj-y += $(addprefix ../qom/, $(qom-y)) obj-y += $(addprefix ../libuser/, $(user-obj-y)) obj-y += $(addprefix ../libdis-user/, $(libdis-y)) @@ -142,7 +143,7 @@ endif #CONFIG_LINUX_USER ifdef CONFIG_DARWIN_USER -$(call set-vpath, $(SRC_PATH)/darwin-user) +$(call set-vpath, $(SRC_PATH)/darwin-user:$(SRC_PATH)/hw) QEMU_CFLAGS+=-I$(SRC_PATH)/darwin-user -I$(SRC_PATH)/darwin-user/$(TARGET_ARCH) @@ -159,6 +160,7 @@ obj-i386-y += ioport-user.o $(obj-y) $(obj-$(TARGET_BASE_ARCH)-y): $(GENERATED_HEADERS) obj-y += module.o +obj-y += cpu.o obj-y += $(addprefix ../qom/, $(qom-y)) obj-y += $(addprefix ../libuser/, $(user-obj-y)) obj-y += $(addprefix ../libdis-user/, $(libdis-y)) @@ -171,7 +173,7 @@ endif #CONFIG_DARWIN_USER ifdef CONFIG_BSD_USER -$(call set-vpath, $(SRC_PATH)/bsd-user) +$(call set-vpath, $(SRC_PATH)/bsd-user:$(SRC_PATH)/hw) QEMU_CFLAGS+=-I$(SRC_PATH)/bsd-user -I$(SRC_PATH)/bsd-user/$(TARGET_ARCH) @@ -183,6 +185,7 @@ obj-i386-y += ioport-user.o $(obj-y) $(obj-$(TARGET_BASE_ARCH)-y): $(GENERATED_HEADERS) obj-y += module.o +obj-y += cpu.o obj-y += $(addprefix ../qom/, $(qom-y)) obj-y += $(addprefix ../libuser/, $(user-obj-y)) obj-y += $(addprefix ../libdis-user/, $(libdis-y)) diff --git a/hw/cpu.c b/hw/cpu.c new file mode 100644 index 000..1502fee --- /dev/null +++ b/hw/cpu.c @@ -0,0 +1,39 @@ +/* + * QEMU CPU model + * + * Copyright (c) 2012 SUSE LINUX Products GmbH + * + * Licensed under the terms of the GNU GPL version 2 + * or (at your option) any later version. + */ + +#include qemu/cpu.h +#include qemu-common.h + +void cpu_do_reset(CPU *cpu) +{ +CPUClass *klass = CPU_GET_CLASS(cpu); + +if (klass-reset != NULL) { +(*klass-reset)(cpu); +} +} + +void cpu_common_reset(CPU *cpu) +{ +} + +static TypeInfo cpu_type_info = { +.name = TYPE_CPU, +.parent = TYPE_OBJECT, +.instance_size = sizeof(CPU), +.abstract = true, +.class_size = sizeof(CPUClass), +}; + +static void cpu_register_types(void) +{ +type_register_static(cpu_type_info); +} + +type_init(cpu_register_types) diff --git a/include/qemu/cpu.h b/include/qemu/cpu.h new file mode 100644 index 000..cccf4a5 --- /dev/null +++ b/include/qemu/cpu.h @@ -0,0 +1,62 @@ +/* + * QEMU CPU model + * + * Copyright (c) 2012 SUSE LINUX Products GmbH + * + * Licensed under the terms of the GNU GPL version 2 + * or (at your option) any later version. + */ +#ifndef QEMU_CPU_H +#define QEMU_CPU_H + +#include qemu/object.h + +#define TYPE_CPU cpu + +#define CPU(obj) OBJECT_CHECK(CPU, (obj), TYPE_CPU) +#define CPU_CLASS(class) OBJECT_CLASS_CHECK(CPUClass, (class), TYPE_CPU) +#define CPU_GET_CLASS(obj) OBJECT_GET_CLASS(CPUClass, (obj), TYPE_CPU) + +typedef struct CPU CPU; + +/** + * CPUClass: + * @reset: Callback to reset the #CPU to its initial state. + * + * Represents a CPU family or model. + */ +typedef struct CPUClass { +ObjectClass parent_class; + +void (*reset)(CPU *cpu); +} CPUClass; + +/** + * CPU: + * + * State of one CPU core or thread. + */ +struct CPU { +Object parent_obj; + +/* TODO Move common fields from CPUState here. */ +}; + + +/* TODO Rename to cpu_reset once all CPUState is converted to QOM. */ +/** + * cpu_do_reset: + * @cpu: The CPU whose state is to be reset. + */ +void cpu_do_reset(CPU *cpu); + +/** + *
Re: [Qemu-devel] [PATCH v11 4/9] ARM: exynos4210: PWM support.
On 31 January 2012 08:31, Evgeny Voevodin e.voevo...@samsung.com wrote: On 01/30/2012 11:38 AM, Evgeny Voevodin wrote: Signed-off-by: Evgeny Voevodine.voevo...@samsung.com Reviewed-by: Peter Maydellpeter.mayd...@linaro.org --- This patch should not contain Reviewed-by: since QOM usage was added. Apologise for it. Peter, could you, please, rereview it? Reviewed-by: Peter Maydell peter.mayd...@linaro.org (based on diff between v9 and v11 patch) -- PMM
Re: [Qemu-devel] [PATCH v11 6/9] ARM: exynos4210: MCT support.
On 31 January 2012 08:32, Evgeny Voevodin e.voevo...@samsung.com wrote: On 01/30/2012 11:38 AM, Evgeny Voevodin wrote: Signed-off-by: Evgeny Voevodine.voevo...@samsung.com Reviewed-by: Peter Maydellpeter.mayd...@linaro.org This patch should not contain Reviewed-by: since QOM usage was added. Apologise for it. Peter, could you, please, rereview it? Reviewed-by: Peter Maydell peter.mayd...@linaro.org (based on diff between v9 and v11 patch) -- PMM
Re: [Qemu-devel] [PATCH v2] arm: add device tree support
On 02/01/2012 07:32 AM, Alexander Graf wrote: On 01.02.2012, at 14:25, Anthony Liguori wrote: On 02/01/2012 07:10 AM, Peter Maydell wrote: On 1 February 2012 13:04, Anthony Liguorianth...@codemonkey.ws wrote: How does it race? Devices normally never touch memory so a loader device will be the only thing mucking with memory. The obvious one is loader reset function wants to set starting PC to entry point of kernel/etc vs CPU device reset wants to set starting PC to hardware-mandated reset vector. We have this at the moment, of course, and I think we implicitly rely on reset handlers being called in order of registration... I'm a bit confused, why can't the kernel loader be implemented in terms of a firmware blob? This is what we do for x86 and it solves this problem robustly. Isn't it just a matter of a few instructions to do a jmp to a known location? Only if you have non-semi-hosted modes. For e500 for example, we don't have a bios flash region mapped through mmio available. So we would have to write the jump to kernel code into ram. But where in RAM? Linux starts at address 0, so that one's taken. The processor has to have a defined sequence where IP is fixed to a specific value, no? How else would the real hardware bootstrap software? Regards, Anthony Liguori Alex
Re: [Qemu-devel] [PATCH v11 9/9] Exynos4210: added display controller implementation
On 31 January 2012 08:33, Evgeny Voevodin e.voevo...@samsung.com wrote: On 01/30/2012 11:38 AM, Evgeny Voevodin wrote: From: Mitsyanko Igori.mitsya...@samsung.com Exynos4210 display controller (FIMD) has 5 hardware windows with alpha and chroma key blending functions. Signed-off-by: Mitsyanko Igori.mitsya...@samsung.com Reviewed-by: Peter Maydellpeter.mayd...@linaro.org Signed-off-by: Evgeny Voevodine.voevo...@samsung.com This patch should not contain Reviewed-by: since QOM usage was added. Apologise for it. Peter, could you, please, rereview it? Reviewed-by: Peter Maydell peter.mayd...@linaro.org based on diff between v9 and v11 patch. -- PMM
Re: [Qemu-devel] [PATCH v2] arm: add device tree support
On 01.02.2012, at 14:44, Anthony Liguori wrote: On 02/01/2012 07:32 AM, Alexander Graf wrote: On 01.02.2012, at 14:25, Anthony Liguori wrote: On 02/01/2012 07:10 AM, Peter Maydell wrote: On 1 February 2012 13:04, Anthony Liguorianth...@codemonkey.ws wrote: How does it race? Devices normally never touch memory so a loader device will be the only thing mucking with memory. The obvious one is loader reset function wants to set starting PC to entry point of kernel/etc vs CPU device reset wants to set starting PC to hardware-mandated reset vector. We have this at the moment, of course, and I think we implicitly rely on reset handlers being called in order of registration... I'm a bit confused, why can't the kernel loader be implemented in terms of a firmware blob? This is what we do for x86 and it solves this problem robustly. Isn't it just a matter of a few instructions to do a jmp to a known location? Only if you have non-semi-hosted modes. For e500 for example, we don't have a bios flash region mapped through mmio available. So we would have to write the jump to kernel code into ram. But where in RAM? Linux starts at address 0, so that one's taken. The processor has to have a defined sequence where IP is fixed to a specific value, no? How else would the real hardware bootstrap software? Real hardware boots u-boot which initializes lots of things and then goes into the actual booting of Linux. Today, we're doing semi-hosting though, without u-boot. We just directly boot into Linux. That's why I'm saying things don't work out all that simple with semi-hosted environments. Now you could argue that semi-hosting is a bad thing, but we'll always have to have it. On s390 for example, semi-hosting is how real hardware works. Or at least the parts that are visible to end users. Especially when you model PV machines, you'll have a hard time with fixed reset IPs too. However, couldn't we model some wiring that allows our dash-kernel-boot-device to override the reset vector on CPUs? Alex
Re: [Qemu-devel] [PATCH v2] arm: add device tree support
On 02/01/2012 07:49 AM, Alexander Graf wrote: On 01.02.2012, at 14:44, Anthony Liguori wrote: On 02/01/2012 07:32 AM, Alexander Graf wrote: On 01.02.2012, at 14:25, Anthony Liguori wrote: On 02/01/2012 07:10 AM, Peter Maydell wrote: On 1 February 2012 13:04, Anthony Liguorianth...@codemonkey.wswrote: How does it race? Devices normally never touch memory so a loader device will be the only thing mucking with memory. The obvious one is loader reset function wants to set starting PC to entry point of kernel/etc vs CPU device reset wants to set starting PC to hardware-mandated reset vector. We have this at the moment, of course, and I think we implicitly rely on reset handlers being called in order of registration... I'm a bit confused, why can't the kernel loader be implemented in terms of a firmware blob? This is what we do for x86 and it solves this problem robustly. Isn't it just a matter of a few instructions to do a jmp to a known location? Only if you have non-semi-hosted modes. For e500 for example, we don't have a bios flash region mapped through mmio available. So we would have to write the jump to kernel code into ram. But where in RAM? Linux starts at address 0, so that one's taken. The processor has to have a defined sequence where IP is fixed to a specific value, no? How else would the real hardware bootstrap software? Real hardware boots u-boot which initializes lots of things and then goes into the actual booting of Linux. Today, we're doing semi-hosting though, without u-boot. We just directly boot into Linux. Fine, but to boot u-boot, the real hardware must set IP to something that's most likely an offset into ROM flash. Why can't we bootstrap semi-hosted mode by having a ROM somewhere that just redirects IP? It doesn't have to be a full blown u-boot. That's why I'm saying things don't work out all that simple with semi-hosted environments. Now you could argue that semi-hosting is a bad thing, but we'll always have to have it. On s390 for example, semi-hosting is how real hardware works. Or at least the parts that are visible to end users. Especially when you model PV machines, you'll have a hard time with fixed reset IPs too. s390 is a special case because real hardware is not actually real hardware. It's a VM. Regards, Anthony Liguori However, couldn't we model some wiring that allows our dash-kernel-boot-device to override the reset vector on CPUs? Alex
[Qemu-devel] [PATCH RFC v2 2/8] qom: Register QOM infrastructure early
QOM TYPE_INTERFACE was registered with device_init(), whose constructors are executed rather late in vl.c's main(). Rename the module init type from DEVICE to QOM and call it very early so that QOM can safely be used for machines and CPUs. device_init() is left for legacy types. New ones should use type_init(). Signed-off-by: Andreas Färber afaer...@suse.de Cc: Anthony Liguori anth...@codemonkey.ws --- module.h |5 +++-- vl.c |4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/module.h b/module.h index ef66730..56391a5 100644 --- a/module.h +++ b/module.h @@ -21,15 +21,16 @@ static void __attribute__((constructor)) do_qemu_init_ ## function(void) { \ } typedef enum { +MODULE_INIT_QOM, MODULE_INIT_BLOCK, -MODULE_INIT_DEVICE, MODULE_INIT_MACHINE, MODULE_INIT_QAPI, MODULE_INIT_MAX } module_init_type; +#define type_init(function) module_init(function, MODULE_INIT_QOM) #define block_init(function) module_init(function, MODULE_INIT_BLOCK) -#define device_init(function) module_init(function, MODULE_INIT_DEVICE) +#define device_init(function) module_init(function, MODULE_INIT_QOM) #define machine_init(function) module_init(function, MODULE_INIT_MACHINE) #define qapi_init(function) module_init(function, MODULE_INIT_QAPI) diff --git a/vl.c b/vl.c index d88a18c..69110f2 100644 --- a/vl.c +++ b/vl.c @@ -2208,6 +2208,8 @@ int main(int argc, char **argv, char **envp) #endif } +module_call_init(MODULE_INIT_QOM); + runstate_init(); init_clocks(); @@ -3347,8 +3349,6 @@ int main(int argc, char **argv, char **envp) if (foreach_device_config(DEV_DEBUGCON, debugcon_parse) 0) exit(1); -module_call_init(MODULE_INIT_DEVICE); - /* must be after qdev registration but before machine init */ if (vga_model) { select_vgahw(vga_model); -- 1.7.7
Re: [Qemu-devel] [PATCH v2] arm: add device tree support
On 01.02.2012, at 14:52, Anthony Liguori wrote: On 02/01/2012 07:49 AM, Alexander Graf wrote: On 01.02.2012, at 14:44, Anthony Liguori wrote: On 02/01/2012 07:32 AM, Alexander Graf wrote: On 01.02.2012, at 14:25, Anthony Liguori wrote: On 02/01/2012 07:10 AM, Peter Maydell wrote: On 1 February 2012 13:04, Anthony Liguorianth...@codemonkey.ws wrote: How does it race? Devices normally never touch memory so a loader device will be the only thing mucking with memory. The obvious one is loader reset function wants to set starting PC to entry point of kernel/etc vs CPU device reset wants to set starting PC to hardware-mandated reset vector. We have this at the moment, of course, and I think we implicitly rely on reset handlers being called in order of registration... I'm a bit confused, why can't the kernel loader be implemented in terms of a firmware blob? This is what we do for x86 and it solves this problem robustly. Isn't it just a matter of a few instructions to do a jmp to a known location? Only if you have non-semi-hosted modes. For e500 for example, we don't have a bios flash region mapped through mmio available. So we would have to write the jump to kernel code into ram. But where in RAM? Linux starts at address 0, so that one's taken. The processor has to have a defined sequence where IP is fixed to a specific value, no? How else would the real hardware bootstrap software? Real hardware boots u-boot which initializes lots of things and then goes into the actual booting of Linux. Today, we're doing semi-hosting though, without u-boot. We just directly boot into Linux. Fine, but to boot u-boot, the real hardware must set IP to something that's most likely an offset into ROM flash. Why can't we bootstrap semi-hosted mode by having a ROM somewhere that just redirects IP? It doesn't have to be a full blown u-boot. That would work, yes. That's why I'm saying things don't work out all that simple with semi-hosted environments. Now you could argue that semi-hosting is a bad thing, but we'll always have to have it. On s390 for example, semi-hosting is how real hardware works. Or at least the parts that are visible to end users. Especially when you model PV machines, you'll have a hard time with fixed reset IPs too. s390 is a special case because real hardware is not actually real hardware. It's a VM. Sure, but how would we model things there? Our model needs to be flexible enough to cope with these oddballs. In fact, s390 is even more complicated. For DASD boot, the CPU is stalled at first and instead the DASD controller reads some instructions from memory that then bootstrap the bootloader. But IIUC that's only the case for DASD boot. For zfcp boot, you basically get semi-hosting. Alex
Re: [Qemu-devel] git bisect results: ec757c67c40a56492001487e69272f62144fd124 breaks windows boot in qemu-kvm
On February 1, 2012 at 2:40 PM Avi Kivity a...@redhat.com wrote: On 02/01/2012 02:52 PM, Erik Rull wrote: Hi all, first of all I'm a bit confused: What is the difference between qemu with command line option --enable-kvm and qemu-kvm? It seems to be a difference in code so far, from the performance point of view it seems to be the same... The differences are being reduced rapidly, thanks to Jan's efforts. Right now what remains is PIT performance and accuracy, device assignment, and Windows XP performance. Most guests should see the same performance. Now my issue that lead me to a git bisect on qemu-kvm: The following commit / merge breaks my windows guest boot sequence and causes resets infinitely: ec757c67c40a56492001487e69272f62144fd124 Merge branch 'upstream-merge' into next Thu, 5 Jan 2012 11:00:07 + (13:00 +0200)Avi Kivity a...@redhat.com Interesting: qemu with --enable-kvm master and the same command line options as qemu-kvm runs perfect. My command line options are: qemu-system-x86_64 -serial /dev/ttyS2 -readconfig /etc/ich9-ehci-uhci.cfg -device usb-host,bus=ehci.0 -device usb-tablet -drive file=/dev/sda2,cache=off -m 1024 -net nic,macaddr=$MACADDR -net tap,script=/etc/qemu-ifup -no-acpi -monitor stdio -L /usr/X11R6/share/qemu -boot c -localtime What version of Windows are you using? What's the contents of /etc/ich9-ehci-uhci.cfg? Hi Avi, the contents from the .cfg are located in docs/ich9-ehci-uhci.cfg I tried two versions of Windows XP: One is the default Windows XP SP3 that you get from MSDN, one is Windows Embedded Standard (embedded customized XP). Both show the same behavior: boots with qemu -enable-kvm and continuously reboots with qemu-kvm. Best regards, Erik
Re: [Qemu-devel] git bisect results: ec757c67c40a56492001487e69272f62144fd124 breaks windows boot in qemu-kvm
On 2012-02-01 15:02, Erik Rull wrote: On February 1, 2012 at 2:40 PM Avi Kivity a...@redhat.com wrote: On 02/01/2012 02:52 PM, Erik Rull wrote: Hi all, first of all I'm a bit confused: What is the difference between qemu with command line option --enable-kvm and qemu-kvm? It seems to be a difference in code so far, from the performance point of view it seems to be the same... The differences are being reduced rapidly, thanks to Jan's efforts. Right now what remains is PIT performance and accuracy, device assignment, and Windows XP performance. Most guests should see the same performance. MSI performance is expected to be worse with upstream as well, thus virtio. Now my issue that lead me to a git bisect on qemu-kvm: The following commit / merge breaks my windows guest boot sequence and causes resets infinitely: ec757c67c40a56492001487e69272f62144fd124 Merge branch 'upstream-merge' into next Thu, 5 Jan 2012 11:00:07 + (13:00 +0200)Avi Kivity a...@redhat.com Interesting: qemu with --enable-kvm master and the same command line options as qemu-kvm runs perfect. My command line options are: qemu-system-x86_64 -serial /dev/ttyS2 -readconfig /etc/ich9-ehci-uhci.cfg -device usb-host,bus=ehci.0 -device usb-tablet -drive file=/dev/sda2,cache=off -m 1024 -net nic,macaddr=$MACADDR -net tap,script=/etc/qemu-ifup -no-acpi -monitor stdio -L /usr/X11R6/share/qemu -boot c -localtime What version of Windows are you using? What's the contents of /etc/ich9-ehci-uhci.cfg? Hi Avi, the contents from the .cfg are located in docs/ich9-ehci-uhci.cfg I tried two versions of Windows XP: One is the default Windows XP SP3 that you get from MSDN, one is Windows Embedded Standard (embedded customized XP). Both show the same behavior: boots with qemu -enable-kvm and continuously reboots with qemu-kvm. What does qemu-kvm with -no-kvm-irqchip do? Jan -- Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux
Re: [Qemu-devel] [PATCH v2] arm: add device tree support
On 02/01/2012 07:55 AM, Alexander Graf wrote: On 01.02.2012, at 14:52, Anthony Liguori wrote: Fine, but to boot u-boot, the real hardware must set IP to something that's most likely an offset into ROM flash. Why can't we bootstrap semi-hosted mode by having a ROM somewhere that just redirects IP? It doesn't have to be a full blown u-boot. That would work, yes. That's why I'm saying things don't work out all that simple with semi-hosted environments. Now you could argue that semi-hosting is a bad thing, but we'll always have to have it. On s390 for example, semi-hosting is how real hardware works. Or at least the parts that are visible to end users. Especially when you model PV machines, you'll have a hard time with fixed reset IPs too. s390 is a special case because real hardware is not actually real hardware. It's a VM. Sure, but how would we model things there? Our model needs to be flexible enough to cope with these oddballs. In fact, s390 is even more complicated. For DASD boot, the CPU is stalled at first and instead the DASD controller reads some instructions from memory that then bootstrap the bootloader. But IIUC that's only the case for DASD boot. For zfcp boot, you basically get semi-hosting. Once CPUs are modeled QOM, my expectation is that we'll have something like a CPU::halted property. As part of realize, a CPU would set halted = true and that is what would trigger the CPU execution (be it through TCG or KVM). There is no reason that on s390, the CPU realize function couldn't avoid setting halted=true and instead allow another device (with a wider view of the system) to perform some additional initialization work and then set the CPU halted property to true. This is all about what causes the system to start running. Once we move to a property realize() model, it gives us a lot more flexibility to work through these types of dependency issues. Regards, Anthony Liguori Alex
Re: [Qemu-devel] [PATCH v11 3/9] ARM: exynos4210: UART support
On 30 January 2012 07:38, Evgeny Voevodin e.voevo...@samsung.com wrote: From: Maksim Kozlov m.koz...@samsung.com Add basic support of exynos4210 UART Signed-off-by: Maksim Kozlov m.koz...@samsung.com Signed-off-by: Evgeny Voevodin e.voevo...@samsung.com Reviewed-by: Peter Maydell peter.mayd...@linaro.org -- PMM
Re: [Qemu-devel] git bisect results: ec757c67c40a56492001487e69272f62144fd124 breaks windows boot in qemu-kvm
On February 1, 2012 at 3:42 PM Jan Kiszka jan.kis...@siemens.com wrote: On 2012-02-01 15:02, Erik Rull wrote: On February 1, 2012 at 2:40 PM Avi Kivity a...@redhat.com wrote: On 02/01/2012 02:52 PM, Erik Rull wrote: Hi all, first of all I'm a bit confused: What is the difference between qemu with command line option --enable-kvm and qemu-kvm? It seems to be a difference in code so far, from the performance point of view it seems to be the same... The differences are being reduced rapidly, thanks to Jan's efforts. Right now what remains is PIT performance and accuracy, device assignment, and Windows XP performance. Most guests should see the same performance. MSI performance is expected to be worse with upstream as well, thus virtio. Now my issue that lead me to a git bisect on qemu-kvm: The following commit / merge breaks my windows guest boot sequence and causes resets infinitely: ec757c67c40a56492001487e69272f62144fd124 Merge branch 'upstream-merge' into next Thu, 5 Jan 2012 11:00:07 + (13:00 +0200)Avi Kivity a...@redhat.com Interesting: qemu with --enable-kvm master and the same command line options as qemu-kvm runs perfect. My command line options are: qemu-system-x86_64 -serial /dev/ttyS2 -readconfig /etc/ich9-ehci-uhci.cfg -device usb-host,bus=ehci.0 -device usb-tablet -drive file=/dev/sda2,cache=off -m 1024 -net nic,macaddr=$MACADDR -net tap,script=/etc/qemu-ifup -no-acpi -monitor stdio -L /usr/X11R6/share/qemu -boot c -localtime What version of Windows are you using? What's the contents of /etc/ich9-ehci-uhci.cfg? Hi Avi, the contents from the .cfg are located in docs/ich9-ehci-uhci.cfg I tried two versions of Windows XP: One is the default Windows XP SP3 that you get from MSDN, one is Windows Embedded Standard (embedded customized XP). Both show the same behavior: boots with qemu -enable-kvm and continuously reboots with qemu-kvm. What does qemu-kvm with -no-kvm-irqchip do? Jan Wow - that works! Does this influence the guest performance?
Re: [Qemu-devel] git bisect results: ec757c67c40a56492001487e69272f62144fd124 breaks windows boot in qemu-kvm
On 2012-02-01 16:43, Erik Rull wrote: On February 1, 2012 at 3:42 PM Jan Kiszka jan.kis...@siemens.com wrote: On 2012-02-01 15:02, Erik Rull wrote: On February 1, 2012 at 2:40 PM Avi Kivity a...@redhat.com wrote: On 02/01/2012 02:52 PM, Erik Rull wrote: Hi all, first of all I'm a bit confused: What is the difference between qemu with command line option --enable-kvm and qemu-kvm? It seems to be a difference in code so far, from the performance point of view it seems to be the same... The differences are being reduced rapidly, thanks to Jan's efforts. Right now what remains is PIT performance and accuracy, device assignment, and Windows XP performance. Most guests should see the same performance. MSI performance is expected to be worse with upstream as well, thus virtio. Now my issue that lead me to a git bisect on qemu-kvm: The following commit / merge breaks my windows guest boot sequence and causes resets infinitely: ec757c67c40a56492001487e69272f62144fd124 Merge branch 'upstream-merge' into next So commit aad3b517a1b83561f2755dc4451596a421399c19, i.e. the last merge before that one is still fine? Thu, 5 Jan 2012 11:00:07 + (13:00 +0200)Avi Kivity a...@redhat.com Interesting: qemu with --enable-kvm master and the same command line options as qemu-kvm runs perfect. My command line options are: qemu-system-x86_64 -serial /dev/ttyS2 -readconfig /etc/ich9-ehci-uhci.cfg -device usb-host,bus=ehci.0 -device usb-tablet -drive file=/dev/sda2,cache=off -m 1024 -net nic,macaddr=$MACADDR -net tap,script=/etc/qemu-ifup -no-acpi -monitor stdio -L /usr/X11R6/share/qemu -boot c -localtime What version of Windows are you using? What's the contents of /etc/ich9-ehci-uhci.cfg? Hi Avi, the contents from the .cfg are located in docs/ich9-ehci-uhci.cfg I tried two versions of Windows XP: One is the default Windows XP SP3 that you get from MSDN, one is Windows Embedded Standard (embedded customized XP). Both show the same behavior: boots with qemu -enable-kvm and continuously reboots with qemu-kvm. What does qemu-kvm with -no-kvm-irqchip do? Jan Wow - that works! Does this influence the guest performance? Yes, how much depends on your workload. Still strange, though. We should try to understand this issue. It stays like this up to and including current qemu-kvm.git master? Jan -- Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux
[Qemu-devel] [Bug 441672] Re: Windos XP BSOD with HP Photosmart usb device attached
Please use qemu-1.0 + ehci. The UHCI layer seems to cause this problem when handling some USB 2.0 devices. I had similar problems but with EHCI + qemu-1.0 it was fixed. See docs/usb2.txt for USB 2.0 support. -- You received this bug notification because you are a member of qemu- devel-ml, which is subscribed to QEMU. https://bugs.launchpad.net/bugs/441672 Title: Windos XP BSOD with HP Photosmart usb device attached Status in QEMU: New Bug description: https://bugzilla.redhat.com/show_bug.cgi?id=524723 has all the details of the problem. I was just testing attaching a USB device to see if it really worked, and tried my HP Photosmart C5580 All-in-One printer/scanner, and the Windows XP box then started getting bluescreens and crashing at random (fairly short :-) intervals. My latest attempt was on a fedora rawhide system with pretty up to date software (qemu-kvm-0.11.0-2.fc12.x86_64), and the crashes still happen. A reply to that bugzilla recommended adding this upstream bug, so here it is. To manage notifications about this bug go to: https://bugs.launchpad.net/qemu/+bug/441672/+subscriptions
[Qemu-devel] [Bug 924943] [NEW] usb-host devices given by command line are routed incomplete to the guest
Public bug reported: affected qemus: qemu-1.0, qemu-kvm-1.0, qemu and qemu-kvm master branches (older versions not tested) affected guests: linux, windows test hardware: standard usb key (or any other piece of USB hardware) that works perfectly when plugged in after guest bootup Several Sequences have been tested: - start qemu with -readconfig /etc/ich9-ehci-uhci.cfg -device usb-tablet -device usb-host,bus=ehci.0 - start qemu with -readconfig /etc/ich9-ehci-uhci.cfg -device usb-tablet -S (to not start up the guest directly) + at the console prompt: device_add usb-host then c to start the guest. For the linux guest, I get a usb device listed and detected as /dev/sdb when plugging it in at runtime. At startup linux does NOT detect it. For the windows guest, I get a usb device listed and detected as removable media when plugging it in at runtime. At startup Windows does detect something that is listed in the device manager as Generic Mass Storage device, but with a yellow exclamation mark and there is no removable media listed in Explorer If you need further testings, just let me know. ** Affects: qemu Importance: Undecided Status: New ** Tags: linux qemu usb windows -- You received this bug notification because you are a member of qemu- devel-ml, which is subscribed to QEMU. https://bugs.launchpad.net/bugs/924943 Title: usb-host devices given by command line are routed incomplete to the guest Status in QEMU: New Bug description: affected qemus: qemu-1.0, qemu-kvm-1.0, qemu and qemu-kvm master branches (older versions not tested) affected guests: linux, windows test hardware: standard usb key (or any other piece of USB hardware) that works perfectly when plugged in after guest bootup Several Sequences have been tested: - start qemu with -readconfig /etc/ich9-ehci-uhci.cfg -device usb-tablet -device usb-host,bus=ehci.0 - start qemu with -readconfig /etc/ich9-ehci-uhci.cfg -device usb-tablet -S (to not start up the guest directly) + at the console prompt: device_add usb-host then c to start the guest. For the linux guest, I get a usb device listed and detected as /dev/sdb when plugging it in at runtime. At startup linux does NOT detect it. For the windows guest, I get a usb device listed and detected as removable media when plugging it in at runtime. At startup Windows does detect something that is listed in the device manager as Generic Mass Storage device, but with a yellow exclamation mark and there is no removable media listed in Explorer If you need further testings, just let me know. To manage notifications about this bug go to: https://bugs.launchpad.net/qemu/+bug/924943/+subscriptions
Re: [Qemu-devel] git bisect results: ec757c67c40a56492001487e69272f62144fd124 breaks windows boot in qemu-kvm
On February 1, 2012 at 5:01 PM Jan Kiszka jan.kis...@siemens.com wrote: On 2012-02-01 16:43, Erik Rull wrote: On February 1, 2012 at 3:42 PM Jan Kiszka jan.kis...@siemens.com wrote: On 2012-02-01 15:02, Erik Rull wrote: On February 1, 2012 at 2:40 PM Avi Kivity a...@redhat.com wrote: On 02/01/2012 02:52 PM, Erik Rull wrote: Hi all, first of all I'm a bit confused: What is the difference between qemu with command line option --enable-kvm and qemu-kvm? It seems to be a difference in code so far, from the performance point of view it seems to be the same... The differences are being reduced rapidly, thanks to Jan's efforts. Right now what remains is PIT performance and accuracy, device assignment, and Windows XP performance. Most guests should see the same performance. MSI performance is expected to be worse with upstream as well, thus virtio. Now my issue that lead me to a git bisect on qemu-kvm: The following commit / merge breaks my windows guest boot sequence and causes resets infinitely: ec757c67c40a56492001487e69272f62144fd124 Merge branch 'upstream-merge' into next So commit aad3b517a1b83561f2755dc4451596a421399c19, i.e. the last merge before that one is still fine? Thu, 5 Jan 2012 11:00:07 + (13:00 +0200)Avi Kivity a...@redhat.com Interesting: qemu with --enable-kvm master and the same command line options as qemu-kvm runs perfect. My command line options are: qemu-system-x86_64 -serial /dev/ttyS2 -readconfig /etc/ich9-ehci-uhci.cfg -device usb-host,bus=ehci.0 -device usb-tablet -drive file=/dev/sda2,cache=off -m 1024 -net nic,macaddr=$MACADDR -net tap,script=/etc/qemu-ifup -no-acpi -monitor stdio -L /usr/X11R6/share/qemu -boot c -localtime What version of Windows are you using? What's the contents of /etc/ich9-ehci-uhci.cfg? Hi Avi, the contents from the .cfg are located in docs/ich9-ehci-uhci.cfg I tried two versions of Windows XP: One is the default Windows XP SP3 that you get from MSDN, one is Windows Embedded Standard (embedded customized XP). Both show the same behavior: boots with qemu -enable-kvm and continuously reboots with qemu-kvm. What does qemu-kvm with -no-kvm-irqchip do? Jan Wow - that works! Does this influence the guest performance? Yes, how much depends on your workload. Still strange, though. We should try to understand this issue. It stays like this up to and including current qemu-kvm.git master? Jan Hi Jan, I didn't follow the branch, only the master between 1.0 and head. Here my bisect log: git bisect start # good: [30c044521889195f54a9f2c21310894f545994e8] Merge commit 'v1.0' into next git bisect good 30c044521889195f54a9f2c21310894f545994e8 # bad: [2793248c5427c0bc585fdf9c101680bab29f4839] Merge remote-tracking branch 'upstream' into next git bisect bad 2793248c5427c0bc585fdf9c101680bab29f4839 # good: [262db38871b9a2613761cc5f05c4cf697e246a68] qemu-nbd: asynchronous operation git bisect good 262db38871b9a2613761cc5f05c4cf697e246a68 # good: [9737383beb515a583fdb6f2aafa631fcd6797068] qerror: add check-qerror.sh to verify alphabetical order git bisect good 9737383beb515a583fdb6f2aafa631fcd6797068 # skip: [fb5458cd10a199e55e622a906b24f8085d922c0f] qmp: add query-block-jobs git bisect skip fb5458cd10a199e55e622a906b24f8085d922c0f # skip: [aa398a5c3a4c0fc29baf02aee5283a7fa0f202a3] blockdev: make image streaming safe across hotplug git bisect skip aa398a5c3a4c0fc29baf02aee5283a7fa0f202a3 # good: [506b7ddf889312659b36c667f7ae17bc9e909418] prep: Use i82378 PCI-ISA bridge for 'prep' machine git bisect good 506b7ddf889312659b36c667f7ae17bc9e909418 # good: [31841e463fc069f3370f85060fbe450b3ff664b4] Merge remote-tracking branch 'pmaydell/arm-devs.for-upstream' into staging git bisect good 31841e463fc069f3370f85060fbe450b3ff664b4 # bad: [5fc4ecdf107133914f97590c8a27144ac0852d63] Merge commit '5b4448d27d7c6ff6e18a1edc8245cb1db783e37c' into queues/qemu-merge git bisect bad 5fc4ecdf107133914f97590c8a27144ac0852d63 # bad: [289a1056a2b902e25f8d6ec5e17984aa48d201c1] pci-assign: Fix multifunction support git bisect bad 289a1056a2b902e25f8d6ec5e17984aa48d201c1 # good: [7c82a98d17a2e86ce6d933dbdd01a570c7bb4ea8] Merge commit '03ecd2c80a64d030a22fe67cc7a60f24e17ff211' into upstream-merge git bisect good 7c82a98d17a2e86ce6d933dbdd01a570c7bb4ea8 # bad: [372951014b5008ca047e4dfbfaf4003bc27a2f6b] qemu-kvm: Fix save/restore of in-kernel i8259 git bisect bad 372951014b5008ca047e4dfbfaf4003bc27a2f6b # good: [682a3c07f0e28d2532c911a44a9b6142d6299cc2] Merge commit 'c5705a7728b4a6bc9e4f2d35911adbaf28042b25' into upstream-merge git bisect good 682a3c07f0e28d2532c911a44a9b6142d6299cc2 # good: [d33666a58d6da4554e69ed6036a052f7261c9298] Merge commit 'c47f3223658119219bbe0b8d09da733d1c06e76f' into upstream-merge git bisect good d33666a58d6da4554e69ed6036a052f7261c9298 # bad: [ec757c67c40a56492001487e69272f62144fd124] Merge
Re: [Qemu-devel] [PATCH v11 1/9] ARM: exynos4210: IRQ subsystem support.
On 30 January 2012 07:38, Evgeny Voevodin e.voevo...@samsung.com wrote: Signed-off-by: Evgeny Voevodin e.voevo...@samsung.com Reviewed-by: Peter Maydell peter.mayd...@linaro.org -- PMM
Re: [Qemu-devel] [PATCH RFC v2 5/8] target-arm: Introduce QOM CPU and use it for CPUID lookup
Am 01.02.2012 13:57, schrieb Andreas Färber: +/* CPU models */ + +typedef struct ARMCPUInfo { +const char *name; +const char *alias; +uint32_t id; +} ARMCPUInfo; + +static const ARMCPUInfo arm_cpus[] = { +{ +.name = pxa270-a0, +.alias = pxa270, Er, forgot about this. This alias should have become a simple strcmp() in cpu_arm_init(), as pointed out by Anthony. +.id = 0x69054110, +}, Andreas -- SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Re: [Qemu-devel] [PATCH v11 5/9] ARM: exynos4210: basic Power Management Unit implementation
On 30 January 2012 07:38, Evgeny Voevodin e.voevo...@samsung.com wrote: From: Maksim Kozlov m.koz...@samsung.com Patch adds basic model for Exynos4210 SoC PMU. This model implements PMU registers just as a bulk of memory. Currently, the only reason this device exists is that secondary CPU boot loader uses PMU INFORM5 register as a holding pen. Your cover letter's changelog says - hw/exynos4210_pmu.c: we do not waste space for non-existing registers in PMU state anymore; non-existing registers are now RAZ/WI; ...wrong version of this patch, or is the cover letter wrong? -- PMM
Re: [Qemu-devel] [PATCH] block: Add support for vpc Fixed Disk type
On 2/1/2012 at 05:15 AM, in message 4f292cd0.20...@redhat.com, Kevin Wolf kw...@redhat.com wrote: Am 01.02.2012 00:04, schrieb Charles Arnold: Thanks Andreas, The 'TODO uuid is missing' comment in the patch is from the original sources (as well as many '//' comments). The vhd footer and header data structures contain a field for a UUID but no code was ever developed to generate one. The revised patch is below after running scripts/checkpatch.pl and fixing the 32 bit issues. - Charles The Virtual Hard Disk Image Format Specification allows for three types of hard disk formats, Fixed, Dynamic, and Differencing. Qemu currently only supports Dynamic disks. This patch adds support for the Fixed Disk format. Usage: Example 1: qemu-img create -f vpc -o type=fixed filename [size] Example 2: qemu-img convert -O vpc -o type=fixed input filename output filename While it is also allowed to specify '-o type=dynamic', the default disk type remains Dynamic and is what is used when the type is left unspecified. Signed-off-by: Charles Arnold carn...@suse.com You have a lot of trailing whitespace in your patch, to the extent that the patch is corrupted: error: block/vpc.c : does not exist in index Please consider using git send-email. Sorry about that. diff --git a/block/vpc.c b/block/vpc.c index 89a5ee2..04db372 100644 --- a/block/vpc.c +++ b/block/vpc.c @@ -160,14 +160,25 @@ static int vpc_open(BlockDriverState *bs, int flags) struct vhd_dyndisk_header* dyndisk_header; uint8_t buf[HEADER_SIZE]; uint32_t checksum; +int disk_type = VHD_DYNAMIC; int err = -1; if (bdrv_pread(bs-file, 0, s-footer_buf, HEADER_SIZE) != HEADER_SIZE) goto fail; footer = (struct vhd_footer*) s-footer_buf; -if (strncmp(footer-creator, conectix, 8)) -goto fail; +if (strncmp(footer-creator, conectix, 8)) { +int64_t offset = bdrv_getlength(bs-file); bdrv_getlength can fail. Ok, I'll fix this. +/* If a fixed disk, the footer is found only at the end of the file */ +if (bdrv_pread(bs-file, offset-HEADER_SIZE, s-footer_buf, HEADER_SIZE) +!= HEADER_SIZE) { +goto fail; +} +if (strncmp(footer-creator, conectix, 8)) { +goto fail; +} +disk_type = VHD_FIXED; +} checksum = be32_to_cpu(footer-checksum); footer-checksum = 0; @@ -186,6 +197,14 @@ static int vpc_open(BlockDriverState *bs, int flags) goto fail; } +/* The footer is all that is needed for fixed disks */ +if (disk_type == VHD_FIXED) { +/* The fixed disk format doesn't use footer-data_offset but it + should be initialized */ +footer-data_offset = be64_to_cpu(0xULL); Why should it be changed? s-footer_buf is only used for updating the footer, so you will change the value that is in the image file. The spec states the following about the data_offset field in the footer, This field is used for dynamic disks and differencing disks, but not fixed disks. For fixed disks, this field should be set to
Re: [Qemu-devel] [PATCH] block: Add support for vpc Fixed Disk type
Am 01.02.2012 17:51, schrieb Charles Arnold: On 2/1/2012 at 05:15 AM, in message4f292cd0.20...@redhat.com, Kevin Wolf kw...@redhat.com wrote: Am 01.02.2012 00:04, schrieb Charles Arnold: Thanks Andreas, The 'TODO uuid is missing' comment in the patch is from the original sources (as well as many '//' comments). The vhd footer and header data structures contain a field for a UUID but no code was ever developed to generate one. The revised patch is below after running scripts/checkpatch.pl and fixing the 32 bit issues. - Charles The Virtual Hard Disk Image Format Specification allows for three types of hard disk formats, Fixed, Dynamic, and Differencing. Qemu currently only supports Dynamic disks. This patch adds support for the Fixed Disk format. Usage: Example 1: qemu-img create -f vpc -o type=fixedfilename [size] Example 2: qemu-img convert -O vpc -o type=fixedinput filename output filename While it is also allowed to specify '-o type=dynamic', the default disk type remains Dynamic and is what is used when the type is left unspecified. Signed-off-by: Charles Arnoldcarn...@suse.com You have a lot of trailing whitespace in your patch, to the extent that the patch is corrupted: error: block/vpc.c : does not exist in index Please consider using git send-email. Sorry about that. diff --git a/block/vpc.c b/block/vpc.c index 89a5ee2..04db372 100644 --- a/block/vpc.c +++ b/block/vpc.c @@ -160,14 +160,25 @@ static int vpc_open(BlockDriverState *bs, int flags) struct vhd_dyndisk_header* dyndisk_header; uint8_t buf[HEADER_SIZE]; uint32_t checksum; +int disk_type = VHD_DYNAMIC; int err = -1; if (bdrv_pread(bs-file, 0, s-footer_buf, HEADER_SIZE) != HEADER_SIZE) goto fail; footer = (struct vhd_footer*) s-footer_buf; -if (strncmp(footer-creator, conectix, 8)) -goto fail; +if (strncmp(footer-creator, conectix, 8)) { +int64_t offset = bdrv_getlength(bs-file); bdrv_getlength can fail. Ok, I'll fix this. +/* If a fixed disk, the footer is found only at the end of the file */ +if (bdrv_pread(bs-file, offset-HEADER_SIZE, s-footer_buf, HEADER_SIZE) +!= HEADER_SIZE) { +goto fail; +} +if (strncmp(footer-creator, conectix, 8)) { +goto fail; +} +disk_type = VHD_FIXED; +} checksum = be32_to_cpu(footer-checksum); footer-checksum = 0; @@ -186,6 +197,14 @@ static int vpc_open(BlockDriverState *bs, int flags) goto fail; } +/* The footer is all that is needed for fixed disks */ +if (disk_type == VHD_FIXED) { +/* The fixed disk format doesn't use footer-data_offset but it + should be initialized */ +footer-data_offset = be64_to_cpu(0xULL); Why should it be changed? s-footer_buf is only used for updating the footer, so you will change the value that is in the image file. The spec states the following about the data_offset field in the footer, This field is used for dynamic disks and differencing disks, but not fixed disks. For fixed disks, this field should be set to 0x. (Windows initializes all 8 bytes of the field) +return 0; This leaves most of BDRVVPCState uninitialised. I can't imagine how bdrv_read/write could possibly work with an image in this state. Something essential seems to be missing here. If vpc_open is opening a fixed disk, there is no dynamic disk header from which to acquire information for filling out the BDRVVPCState structure. However, you are right about the read/write code likely not working with the structure left uninitialised. I'll look into what needs to be done here. +} + if (bdrv_pread(bs-file, be64_to_cpu(footer-data_offset), buf, HEADER_SIZE) != HEADER_SIZE) goto fail; @@ -533,10 +552,10 @@ static int calculate_geometry(int64_t total_sectors, uint16_t* cyls, return 0; } -static int vpc_create(const char *filename, QEMUOptionParameter *options) +static int vpc_create_dynamic_disk(const char *filename, int64_t total_size) { uint8_t buf[1024]; -struct vhd_footer* footer = (struct vhd_footer*) buf; +struct vhd_footer*
[Qemu-devel] [PATCH] target-arm/helper.c: tb_flush() on CPU reset
Since target-arm has some CPUState fields for which we take the approach of baking assumptions about them into translated code and then calling tb_flush() when the fields change, we must also tb_flush on CPU reset, because reset is a change of those fields. Signed-off-by: Peter Maydell peter.mayd...@linaro.org --- target-arm/helper.c |5 + 1 files changed, 5 insertions(+), 0 deletions(-) diff --git a/target-arm/helper.c b/target-arm/helper.c index ea4f35f..fb0c387 100644 --- a/target-arm/helper.c +++ b/target-arm/helper.c @@ -344,6 +344,11 @@ void cpu_reset(CPUARMState *env) set_float_detect_tininess(float_tininess_before_rounding, env-vfp.standard_fp_status); tlb_flush(env, 1); +/* Reset is a state change for some CPUState fields which we + * bake assumptions about into translated code, so we need to + * tb_flush(). + */ +tb_flush(env); } static int vfp_gdb_get_reg(CPUState *env, uint8_t *buf, int reg) -- 1.7.1
Re: [Qemu-devel] [PATCH v2] arm: add device tree support
On Tue, Jan 31, 2012 at 6:44 PM, Alexander Graf ag...@suse.de wrote: On 01.02.2012, at 02:35, Paul Brook wrote: We could also just change machine-init() and pass the dtb in there. In a QOM world these would become machine device properties anyways. machine-init(ram_size, boot_devices, kernel_filename, kernel_cmdline, initrd_filename, cpu_model); Essentially we shouldn't treat -dtb any different than -kernel or -initrd. It's also useful for more than ARM, namely embedded ppc systems. But I can easily post a follow-up patch for those. Changing machine-init means you have to touch every single board file, and clone the exact same code for every machine that uses arm_boot.c. All of which will be rewritten in the near future. Well, the dt file name would have to be passed into the generic arm_boot.c function, yes. But that's something that we need to do at one point in time either way, because machines will want to have default dtb file names. machine-init is a particularly suckiy interface to start with, we want to be using it less, not more. It's not like we're going support multiple machine instanced. At least not before machine-init is removed altogether. I do see your point on not extending legacy interfaces though and not bloating up the patch. In fact, I'm indifferent enough on the actual implementation atm, as long as the command line interface (or whatever the user sees) is reasonably sane. And it is IMHO. So if it makes everything easier, do it using a global, but keep in mind that this will need refactoring. That's certainly my expectation. My initial instinct was also to handle it the say way as initrd and kernel pointers, but as Paul pointed out it requires touching all init functions which is a dead end effort when -init() gets killed off. This patch is trivial to get the functionality into qemu without making it any more difficult for whoever creates the arm-kernel-loader device that Anthony is talking about. g.
[Qemu-devel] [Bug 685096] Re: USB Passthrough not working for Windows 7 guest
two years passed... nothihg changed qemu 0.14.1+win7(32/64) the problem persist -- You received this bug notification because you are a member of qemu- devel-ml, which is subscribed to QEMU. https://bugs.launchpad.net/bugs/685096 Title: USB Passthrough not working for Windows 7 guest Status in QEMU: New Bug description: USB Passthrough from host to guest is not working for a 32-bit Windows 7 guest, while it works perfectly for a 32-bit Windows XP guest. The device appears in the device manager of Windows 7, but with Error code 10: device cannot start. I have tried this with numerous USB thumbdrives and a USB wireless NIC, all with the same result. The device name and functionality is recognized, so at least some USB negotiation is taking place. I am trying this with the latest git-pull of QEMU-KVM. The command line to launch qemu-kvm for win7 is: sudo /home/user/local_install/bin/qemu-system-x86_64 -cpu core2duo -m 1024 -smp 2 -vga std -hda ./disk_images/win7.qcow -vnc :1 -boot c -usb -usbdevice tablet -usbdevice host:0781:5150 The command line to launch qemu-kvm for winxp is: sudo /home/user/local_install/bin/qemu-system-x86_64 -cpu core2duo -m 1024 -smp 2 -usb -vga std -hda ./winxpsp3.qcow -vnc :0 -boot c -usbdevice tablet -usbdevice host:0781:5150 Any help is appreciated. To manage notifications about this bug go to: https://bugs.launchpad.net/qemu/+bug/685096/+subscriptions
Re: [Qemu-devel] virtual pc hash table vs physical pc hash table
On Fri, Jan 20, 2012 at 08:49:56AM -0500, Xin Tong wrote: maybe one of the reasons of having the virtual pc hash table is that the pc does not need to be tranlated to a physical pc which is used in the physical pc hash table. Take context switch as an example. Before context switching, you can use process A's virtual pc to index the virtual pc hash table. After context switching, the original virtual pc hash table is no longer valid since process B has the same virtual address space. Therefore, QEMU turns to use (guest) physical pc to index the physical pc hash table. If the tb of process B is existed, QEMU refill the virtual pc hash table. Otherwise, it does the translation. Regards, chenwj -- Wei-Ren Chen (陳韋任) Computer Systems Lab, Institute of Information Science, Academia Sinica, Taiwan (R.O.C.) Tel:886-2-2788-3799 #1667 Homepage: http://people.cs.nctu.edu.tw/~chenwj
[Qemu-devel] improve your site
Hi, Let me take this opportunity to introduce myself, I'm Victoria Jacobs and as Search Engine Optimizer I manage amp; run a large selection of quality sites in different topics. While working on one of my project sites I've foundnbsp; planet-ltc.orgnbsp; and I believe that with my help you can reach higher results in terms of search engines, Page Rank, visibility and traffic. I'd really love to elaborate more about my proposal and if you're interested please do not hesitate to contact me and I will happily send you the additional details. Thanks a lot, Victoria Jacobs victoria.jac...@fieldseo.com Fieldseo.com http://www.linkedin.com/in/jacobsvictoria
Re: [Qemu-devel] [RFC] CODING_STYLE: Clarify style for enum and function type names
Ping^2 and cc'ing trivial. -- PMM On 23 January 2012 14:12, Peter Maydell peter.mayd...@linaro.org wrote: Since nobody seems to have disagreed, perhaps we should just commit this? -- PMM On 13 January 2012 20:29, Peter Maydell peter.mayd...@linaro.org wrote: Clarify that enum type names and function type names should follow the CamelCase style used for structured type names. Signed-off-by: Peter Maydell peter.mayd...@linaro.org --- During a conversation on IRC with Anthony, I realised that the coding standard isn't entirely clear about what convention should be followed for enum and function types. This patch resolves that by saying they should be CamelCase like structured type names, based on Anthony's suggestion. I've tagged this as an RFC in case anybody would rather we went the other way instead... CODING_STYLE | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/CODING_STYLE b/CODING_STYLE index 6e61c49..7c82d4d 100644 --- a/CODING_STYLE +++ b/CODING_STYLE @@ -44,7 +44,8 @@ Rationale: 3. Naming Variables are lower_case_with_underscores; easy to type and read. Structured -type names are in CamelCase; harder to type but standing out. Scalar type +type names are in CamelCase; harder to type but standing out. Enum type +names and function type names should also be in CamelCase. Scalar type names are lower_case_with_underscores_ending_with_a_t, like the POSIX uint64_t and family. Note that this last convention contradicts POSIX and is therefore likely to be changed. -- 1.7.1
Re: [Qemu-devel] [PATCH] w32: Initialise critical section before starting thread (fix #922131)
Hi, 2012/1/31 Stefan Weil s...@weilnetz.de: This patch was contributed by Bogdan Harjoc. I added some assertions. Signed-off-by: Stefan Weil s...@weilnetz.de [snip] Thanks, it starts now but I hit another crash: GNU gdb (GDB) 7.3 Copyright (C) 2011 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type show copying and show warranty for details. This GDB was configured as mingw32. For bug reporting instructions, please see: http://www.gnu.org/software/gdb/bugs/... Reading symbols from C:\msys\home\User\qemu\i386-softmmu/qemu-system-i386.exe... done. (gdb) r Starting program: C:\msys\home\User\qemu\i386-softmmu/qemu-system-i386.exe -L ..\\pc-bios -hda xp.vmdk [New Thread 13020.0x32c4] [New Thread 13020.0x2acc] [New Thread 13020.0x2f74] Program received signal SIGSEGV, Segmentation fault. [Switching to Thread 13020.0x2f74] 0x7c81071e in SwitchToFiber () from C:\WINDOWS\system32\kernel32.dll (gdb) bt #0 0x7c81071e in SwitchToFiber () from C:\WINDOWS\system32\kernel32.dll #1 0x0044790d in qemu_coroutine_switch (from_=0x1ab93fc, to_=0x1d4c5f0, action=COROUTINE_YIELD) at coroutine-win32.c:48 #2 0x0001 in ?? () #3 0x004dc753 in coroutine_swap (from=0x1e00, to=0xff0a) at qemu-coroutine.c:31 #4 0x00411a39 in bdrv_rw_co (bs=0x1ab8008, sector_num=optimized out, buf=0x22a @, nb_sectors=1, is_write=false) at block.c:1335 #5 0x004887fc in ide_sector_read (s=0x1d1ffa8) at C:/msys/home/User/qemu/hw/ide/core.c:480 #6 0x0054eafa in memory_region_iorange_write (iorange=0x1d1f670, offset=7, width=1, data=150586501200084992) at C:/msys/home/User/qemu/memory.c:431 #7 0x00549981 in ioport_writeb_thunk (opaque=0x1d1f670, addr=7680, data=32) at C:/msys/home/User/qemu/ioport.c:211 #8 0x00549b7b in ioport_write (data=optimized out, address=optimized out, index=optimized out) at C:/msys/home/User/qemu/ioport.c:82 #9 cpu_outb (addr=503, val=0 '\000') at C:/msys/home/User/qemu/ioport.c:274 #10 0x02420397 in ?? () Backtrace stopped: previous frame inner to this frame (corrupt stack?)
[Qemu-devel] [PATCH] Makefile: Remove linux-headers/asm symlink on distclean
configure creates a linux-headers/asm symlink. Remove this when doing a distclean. Signed-off-by: Peter Maydell peter.mayd...@linaro.org --- Makefile |1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/Makefile b/Makefile index d172cbf..2560b59 100644 --- a/Makefile +++ b/Makefile @@ -233,6 +233,7 @@ distclean: clean rm -f qemu-doc.log qemu-doc.pdf qemu-doc.pg qemu-doc.toc qemu-doc.tp rm -f qemu-doc.vr rm -f config.log + rm -f linux-headers/asm rm -f qemu-tech.info qemu-tech.aux qemu-tech.cp qemu-tech.dvi qemu-tech.fn qemu-tech.info qemu-tech.ky qemu-tech.log qemu-tech.pdf qemu-tech.pg qemu-tech.toc qemu-tech.tp qemu-tech.vr for d in $(TARGET_DIRS) $(QEMULIBS); do \ rm -rf $$d || exit 1 ; \ -- 1.7.1
Re: [Qemu-devel] git bisect results: ec757c67c40a56492001487e69272f62144fd124 breaks windows boot in qemu-kvm
On 2012-02-01 13:52, Erik Rull wrote: Hi all, first of all I'm a bit confused: What is the difference between qemu with command line option --enable-kvm and qemu-kvm? It seems to be a difference in code so far, from the performance point of view it seems to be the same... Now my issue that lead me to a git bisect on qemu-kvm: The following commit / merge breaks my windows guest boot sequence and causes resets infinitely: Cannot confirm yet, but I have no ACPI-free Windows installation at hand. Where does it reset, after the BIOS? ec757c67c40a56492001487e69272f62144fd124 Merge branch 'upstream-merge' into next Thu, 5 Jan 2012 11:00:07 + (13:00 +0200)Avi Kivity a...@redhat.com Interesting: qemu with --enable-kvm master and the same command line options as qemu-kvm runs perfect. My command line options are: qemu-system-x86_64 -serial /dev/ttyS2 -readconfig /etc/ich9-ehci-uhci.cfg -device usb-host,bus=ehci.0 -device usb-tablet -drive file=/dev/sda2,cache=off -m 1024 -net nic,macaddr=$MACADDR -net tap,script=/etc/qemu-ifup -no-acpi -monitor stdio -L /usr/X11R6/share/qemu -boot c -localtime Is the BIOS at /usr/X11R6/share/qemu in sync with the qemu version you try? Does leaving out options change the picture? Jan -- Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux
Re: [Qemu-devel] [PATCH 2/3] device_isolation: Support isolation on POWER p5ioc2 bridges
On Wed, 2012-02-01 at 15:46 +1100, David Gibson wrote: This patch adds code to the code for the powernv platform to create and populate isolation groups on hardware using the p5ioc2 PCI host bridge used on some IBM POWER systems. Signed-off-by: Alexey Kardashevskiy a...@ozlabs.ru Signed-off-by: David Gibson da...@gibson.dropbear.id.au --- arch/powerpc/platforms/powernv/pci-p5ioc2.c | 14 +- arch/powerpc/platforms/powernv/pci.h|3 +++ 2 files changed, 16 insertions(+), 1 deletions(-) diff --git a/arch/powerpc/platforms/powernv/pci-p5ioc2.c b/arch/powerpc/platforms/powernv/pci-p5ioc2.c index 2649677..e5bb3a6 100644 --- a/arch/powerpc/platforms/powernv/pci-p5ioc2.c +++ b/arch/powerpc/platforms/powernv/pci-p5ioc2.c @@ -20,6 +20,7 @@ #include linux/irq.h #include linux/io.h #include linux/msi.h +#include linux/device_isolation.h #include asm/sections.h #include asm/io.h @@ -88,10 +89,21 @@ static void pnv_pci_init_p5ioc2_msis(struct pnv_phb *phb) { } static void __devinit pnv_pci_p5ioc2_dma_dev_setup(struct pnv_phb *phb, struct pci_dev *pdev) { - if (phb-p5ioc2.iommu_table.it_map == NULL) + if (phb-p5ioc2.iommu_table.it_map == NULL) { iommu_init_table(phb-p5ioc2.iommu_table, phb-hose-node); +#ifdef CONFIG_DEVICE_ISOLATION + phb-p5ioc2.di_group = kzalloc(sizeof(*(phb-p5ioc2.di_group)), +GFP_KERNEL); + BUG_ON(!phb-p5ioc2.di_group || +(device_isolation_group_init(phb-p5ioc2.di_group, + p5ioc2:%llx, phb-opal_id) 0)); +#endif Hmm, it's really unfortunate that this is architected so we need to surround everything in #ifdefs even though we have stub functions defined. + } set_iommu_table_base(pdev-dev, phb-p5ioc2.iommu_table); +#ifdef CONFIG_DEVICE_ISOLATION + device_isolation_dev_add(phb-p5ioc2.di_group, pdev-dev); +#endif } static void __init pnv_pci_init_p5ioc2_phb(struct device_node *np, diff --git a/arch/powerpc/platforms/powernv/pci.h b/arch/powerpc/platforms/powernv/pci.h index 8bc4796..64ede1e 100644 --- a/arch/powerpc/platforms/powernv/pci.h +++ b/arch/powerpc/platforms/powernv/pci.h @@ -87,6 +87,9 @@ struct pnv_phb { union { struct { struct iommu_table iommu_table; +#ifdef CONFIG_DEVICE_ISOLATION + struct device_isolation_group *di_group; +#endif } p5ioc2; struct {
Re: [Qemu-devel] [PATCH 2/3] device_isolation: Support isolation on POWER p5ioc2 bridges
On Wed, 2012-02-01 at 11:58 -0700, Alex Williamson wrote: On Wed, 2012-02-01 at 15:46 +1100, David Gibson wrote: This patch adds code to the code for the powernv platform to create and populate isolation groups on hardware using the p5ioc2 PCI host bridge used on some IBM POWER systems. Signed-off-by: Alexey Kardashevskiy a...@ozlabs.ru Signed-off-by: David Gibson da...@gibson.dropbear.id.au --- arch/powerpc/platforms/powernv/pci-p5ioc2.c | 14 +- arch/powerpc/platforms/powernv/pci.h|3 +++ 2 files changed, 16 insertions(+), 1 deletions(-) diff --git a/arch/powerpc/platforms/powernv/pci-p5ioc2.c b/arch/powerpc/platforms/powernv/pci-p5ioc2.c index 2649677..e5bb3a6 100644 --- a/arch/powerpc/platforms/powernv/pci-p5ioc2.c +++ b/arch/powerpc/platforms/powernv/pci-p5ioc2.c @@ -20,6 +20,7 @@ #include linux/irq.h #include linux/io.h #include linux/msi.h +#include linux/device_isolation.h #include asm/sections.h #include asm/io.h @@ -88,10 +89,21 @@ static void pnv_pci_init_p5ioc2_msis(struct pnv_phb *phb) { } static void __devinit pnv_pci_p5ioc2_dma_dev_setup(struct pnv_phb *phb, struct pci_dev *pdev) { - if (phb-p5ioc2.iommu_table.it_map == NULL) + if (phb-p5ioc2.iommu_table.it_map == NULL) { iommu_init_table(phb-p5ioc2.iommu_table, phb-hose-node); +#ifdef CONFIG_DEVICE_ISOLATION + phb-p5ioc2.di_group = kzalloc(sizeof(*(phb-p5ioc2.di_group)), + GFP_KERNEL); + BUG_ON(!phb-p5ioc2.di_group || + (device_isolation_group_init(phb-p5ioc2.di_group, + p5ioc2:%llx, phb-opal_id) 0)); +#endif Hmm, it's really unfortunate that this is architected so we need to surround everything in #ifdefs even though we have stub functions defined. I think maybe we want: #ifdef CONFIG_DEVICE_ISOLATION struct device_isolation_group *device_isolation_create_group(void) { struct device_isolation_group *di_group; di_group = kzalloc(sizeof(*di_group), GFP_KERNEL); if (!di_group) return ERR_PTR(-ENOMEM); return di_group; } #else struct device_isolation_group *device_isolation_create_group(void) { return NULL; } #endif Then we can do: phb-p5ioc2.di_group = device_isolation_create_group(); BUG_ON(IS_ERR(phb-p5ioc2.di_group) || (device_isolation_group_init(phb-p5ioc2.di_group, ... (We pass NULL to the stubs, but that's ok) + } set_iommu_table_base(pdev-dev, phb-p5ioc2.iommu_table); +#ifdef CONFIG_DEVICE_ISOLATION + device_isolation_dev_add(phb-p5ioc2.di_group, pdev-dev); +#endif } static void __init pnv_pci_init_p5ioc2_phb(struct device_node *np, diff --git a/arch/powerpc/platforms/powernv/pci.h b/arch/powerpc/platforms/powernv/pci.h index 8bc4796..64ede1e 100644 --- a/arch/powerpc/platforms/powernv/pci.h +++ b/arch/powerpc/platforms/powernv/pci.h @@ -87,6 +87,9 @@ struct pnv_phb { union { struct { struct iommu_table iommu_table; +#ifdef CONFIG_DEVICE_ISOLATION + struct device_isolation_group *di_group; +#endif } p5ioc2; struct {
Re: [Qemu-devel] [PATCH 3/3] device_isolation: Support isolation on POWER p7ioc (IODA) bridges
On Wed, 2012-02-01 at 15:46 +1100, David Gibson wrote: This patch adds code to the code for the powernv platform to create and populate isolation groups on hardware using the p7ioc (aka IODA) PCI host bridge used on some IBM POWER systems. Signed-off-by: Alexey Kardashevskiy a...@ozlabs.ru Signed-off-by: David Gibson da...@gibson.dropbear.id.au --- arch/powerpc/platforms/powernv/pci-ioda.c | 18 -- arch/powerpc/platforms/powernv/pci.h |6 ++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c index 5e155df..4648475 100644 --- a/arch/powerpc/platforms/powernv/pci-ioda.c +++ b/arch/powerpc/platforms/powernv/pci-ioda.c @@ -20,6 +20,7 @@ #include linux/irq.h #include linux/io.h #include linux/msi.h +#include linux/device_isolation.h #include asm/sections.h #include asm/io.h @@ -877,6 +878,9 @@ static void __devinit pnv_ioda_setup_bus_dma(struct pnv_ioda_pe *pe, set_iommu_table_base(dev-dev, pe-tce32_table); if (dev-subordinate) pnv_ioda_setup_bus_dma(pe, dev-subordinate); +#ifdef CONFIG_DEVICE_ISOLATION + device_isolation_dev_add(pe-di_group, dev-dev); +#endif } } @@ -957,11 +961,21 @@ static void __devinit pnv_pci_ioda_setup_dma_pe(struct pnv_phb *phb, } iommu_init_table(tbl, phb-hose-node); - if (pe-pdev) +#ifdef CONFIG_DEVICE_ISOLATION + BUG_ON(device_isolation_group_init(pe-di_group, ioda:rid%x-pe%x, +pe-rid, pe-pe_number) 0); +#endif + + if (pe-pdev) { set_iommu_table_base(pe-pdev-dev, tbl); - else +#ifdef CONFIG_DEVICE_ISOLATION + device_isolation_dev_add(pe-di_group, pe-pdev-dev); +#endif + } else pnv_ioda_setup_bus_dma(pe, pe-pbus); Blech, #ifdefs. + + return; fail: /* XXX Failure: Try to fallback to 64-bit only ? */ diff --git a/arch/powerpc/platforms/powernv/pci.h b/arch/powerpc/platforms/powernv/pci.h index 64ede1e..3e282b7 100644 --- a/arch/powerpc/platforms/powernv/pci.h +++ b/arch/powerpc/platforms/powernv/pci.h @@ -1,6 +1,8 @@ #ifndef __POWERNV_PCI_H #define __POWERNV_PCI_H +#include linux/device_isolation.h + struct pci_dn; enum pnv_phb_type { @@ -60,6 +62,10 @@ struct pnv_ioda_pe { /* Link in list of PE#s */ struct list_headlink; + +#ifdef CONFIG_DEVICE_ISOLATION + struct device_isolation_group di_group; +#endif Embedding the struct means we need to know the size, which means we can't get rid of the #ifdef. Probably better to use a pointer if we don't mind adding a few bytes in the #ifndef case. Thanks, Alex }; struct pnv_phb {
Re: [Qemu-devel] [PATCH v11 1/9] ARM: exynos4210: IRQ subsystem support.
Am 30.01.2012 08:38, schrieb Evgeny Voevodin: Signed-off-by: Evgeny Voevodin e.voevo...@samsung.com --- diff --git a/hw/exynos4210_combiner.c b/hw/exynos4210_combiner.c new file mode 100644 index 000..4d41a1a --- /dev/null +++ b/hw/exynos4210_combiner.c +static const VMStateDescription VMState_Exynos4210CombinerGroupState = { +static const VMStateDescription VMState_Exynos4210Combiner = { Here the variable names should not be CamelCase. +static DeviceInfo exynos4210_combiner_info = { This will need to be updated to TypeInfo after Anthony's series removes DeviceInfo. diff --git a/hw/exynos4210_gic.c b/hw/exynos4210_gic.c new file mode 100644 index 000..bd37e86 --- /dev/null +++ b/hw/exynos4210_gic.c +#defineEXT_GIC_ID_TVENC 127 +#defineEXT_GIC_ID_MFC 126 +#defineEXT_GIC_ID_HDMI_I2C125 +#defineEXT_GIC_ID_HDMI124 +#defineEXT_GIC_ID_MIXER 123 +#defineEXT_GIC_ID_PCIe122 +#defineEXT_GIC_ID_2D 121 +#defineEXT_GIC_ID_JPEG120 +#defineEXT_GIC_ID_FIMC3 119 +#defineEXT_GIC_ID_FIMC2 118 +#defineEXT_GIC_ID_FIMC1 117 +#defineEXT_GIC_ID_FIMC0 116 +#defineEXT_GIC_ID_ROTATOR 115 +#defineEXT_GIC_ID_ONENAND_AUDI114 +#defineEXT_GIC_ID_MIPI_DSI_2LANE 113 +#defineEXT_GIC_ID_MIPI_CSI_2LANE 112 +#defineEXT_GIC_ID_MIPI_DSI_4LANE 111 +#defineEXT_GIC_ID_MIPI_CSI_4LANE 110 +#defineEXT_GIC_ID_SDMMC 109 +#defineEXT_GIC_ID_HSMMC3 108 +#defineEXT_GIC_ID_HSMMC2 107 +#defineEXT_GIC_ID_HSMMC1 106 +#defineEXT_GIC_ID_HSMMC0 105 +#defineEXT_GIC_ID_MODEMIF 104 +#defineEXT_GIC_ID_USB_DEVICE 103 +#defineEXT_GIC_ID_USB_HOST102 +#defineEXT_GIC_ID_MCT_G1 101 +#defineEXT_GIC_ID_SPI2100 +#defineEXT_GIC_ID_SPI199 +#defineEXT_GIC_ID_SPI098 +#defineEXT_GIC_ID_I2C797 +#defineEXT_GIC_ID_I2C696 +#defineEXT_GIC_ID_I2C595 +#defineEXT_GIC_ID_I2C494 +#defineEXT_GIC_ID_I2C393 +#defineEXT_GIC_ID_I2C292 +#defineEXT_GIC_ID_I2C191 +#defineEXT_GIC_ID_I2C090 +#defineEXT_GIC_ID_MCT_G0 89 +#defineEXT_GIC_ID_UART4 88 +#defineEXT_GIC_ID_UART3 87 +#defineEXT_GIC_ID_UART2 86 +#defineEXT_GIC_ID_UART1 85 +#defineEXT_GIC_ID_UART084 +#defineEXT_GIC_ID_NFC 83 +#defineEXT_GIC_ID_IEM_IEC 82 +#defineEXT_GIC_ID_IEM_APC 81 +#defineEXT_GIC_ID_MCT_L1 80 +#defineEXT_GIC_ID_GPIO_XA 79 +#defineEXT_GIC_ID_GPIO_XB 78 +#defineEXT_GIC_ID_RTC_TIC 77 +#defineEXT_GIC_ID_RTC_ALARM 76 +#defineEXT_GIC_ID_WDT 75 +#defineEXT_GIC_ID_MCT_L0 74 +#defineEXT_GIC_ID_TIMER4 73 +#defineEXT_GIC_ID_TIMER3 72 +#defineEXT_GIC_ID_TIMER2 71 +#defineEXT_GIC_ID_TIMER1 70 +#defineEXT_GIC_ID_TIMER0 69 +#defineEXT_GIC_ID_PDMA1 68 +#defineEXT_GIC_ID_PDMA0 67 +#defineEXT_GIC_ID_MDMA_LCD0 66 The formatting looks interesting here... copied from an external header? Since they're in descending order maybe just inverse them and use an enum (gdb in mind)? + +enum ext_int { CamelCase :) +static uint32_t +combiner_grp_to_gic_id[64-EXYNOS4210_MAX_EXT_COMBINER_OUT_IRQ][8] = { +/* int combiner groups 16-19 */ +{}, {}, {}, {}, +/* int combiner group 20 */ +{0, EXT_GIC_ID_MDMA_LCD0}, Usually we use spaces inside braces. +static const VMStateDescription VMState_Exynos4210IRQGate = { Not CamelCase ;) But seriously, I really think review makes more sense when the patches can actually be applied unmodified. Since Peter, as I understood, does not have a kernel to test these machines himself, this will need to be rebased by you guys - either onto Anthony's designated qom-upstream.X branch or wait til next week for the patches to arrive in master. Regards, Andreas -- SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Re: [Qemu-devel] [PATCH 09/23] qdev: kill of DeviceInfo
On 30 January 2012 21:08, Anthony Liguori aligu...@us.ibm.com wrote: Subject: [PATCH 09/23] qdev: kill of DeviceInfo kill off. -- PMM
Re: [Qemu-devel] [PATCH 21/23] object: sure up reference counting
Subject: [PATCH 21/23] object: sure up reference counting On 30 January 2012 21:08, Anthony Liguori aligu...@us.ibm.com wrote: Subject: [PATCH 21/23] object: sure up reference counting shore up, apparently, although I found that sufficiently unlikely in this context that it might be better to reword completely :-) -- PMM
Re: [Qemu-devel] [PATCH 22/23] container: make a decendent of Object
On 30 January 2012 21:09, Anthony Liguori aligu...@us.ibm.com wrote: Subject: [PATCH 22/23] container: make a decendent of Object descendant. -- PMM
[Qemu-devel] [PATCH 00/22] qom: use Type system to register all devices (v2)
This is the 3rd QOM series. All known issues have been resolved. This has been extensively tested (including for bisectability). I think this is ready to apply. The goal of this series is to make DeviceState a first class QOM base class. The result is that you can object_new(TYPE_E1000) and have a functioning device. qdev_create() and qdev_free() are now trivialized as QOM wrappers. Patch 8/23 is an automated touch everything patch. I decided to leave it as one big patch because this is entirely programmatic. There's no intelligence in this patch so I think it's easier to review quickly as one big change. The other notable feature of this series it that properties have been moved to the Object base class. This means that other subsystems can begin using QOM. This is the last touch every file in the tree series. b/Makefile.objs |4 b/hw/9pfs/virtio-9p-device.c | 16 b/hw/a9mpcore.c | 40 - b/hw/ac97.c | 18 b/hw/acpi_piix4.c| 20 b/hw/ads7846.c | 11 b/hw/alpha_typhoon.c | 14 b/hw/apb_pci.c | 41 - b/hw/apic.c | 10 b/hw/apic_common.c | 15 b/hw/apic_internal.h |1 b/hw/applesmc.c | 28 - b/hw/arm11mpcore.c | 28 - b/hw/arm_l2x0.c | 24 b/hw/arm_mptimer.c | 28 - b/hw/arm_sysctl.c| 18 b/hw/arm_timer.c | 35 - b/hw/armv7m.c| 14 b/hw/armv7m_nvic.c | 32 - b/hw/bitbang_i2c.c | 14 b/hw/bonito.c| 32 - b/hw/ccid-card-emulated.c| 35 - b/hw/ccid-card-passthru.c| 28 - b/hw/ccid.h |1 b/hw/cirrus_vga.c| 30 - b/hw/cs4231.c| 18 b/hw/cs4231a.c | 30 - b/hw/debugcon.c | 26 b/hw/dec_pci.c | 40 - b/hw/ds1225y.c | 16 b/hw/ds1338.c| 11 b/hw/e1000.c | 20 b/hw/eccmemctl.c | 18 b/hw/eepro100.c | 83 +-- b/hw/empty_slot.c| 11 b/hw/es1370.c| 16 b/hw/escc.c | 18 b/hw/esp.c | 18 b/hw/etraxfs_eth.c | 14 b/hw/etraxfs_pic.c | 14 b/hw/etraxfs_ser.c | 16 b/hw/etraxfs_timer.c | 11 b/hw/fdc.c | 76 +- b/hw/fw_cfg.c| 20 b/hw/g364fb.c| 20 b/hw/grackle_pci.c | 26 b/hw/grlib_apbuart.c | 14 b/hw/grlib_gptimer.c | 16 b/hw/grlib_irqmp.c | 16 b/hw/gt64xxx.c | 22 b/hw/gus.c | 32 - b/hw/hda-audio.c | 36 - b/hw/highbank.c | 18 b/hw/hpet.c | 20 b/hw/i2c.c | 23 b/hw/i2c.h |3 b/hw/i82374.c| 22 b/hw/i82378.c| 22 b/hw/i8254.c | 30 - b/hw/i8259.c | 11 b/hw/i8259_common.c | 13 b/hw/i8259_internal.h|1 b/hw/ide/ahci.c | 24 b/hw/ide/cmd646.c| 14 b/hw/ide/ich.c | 15 b/hw/ide/isa.c | 30 - b/hw/ide/piix.c | 44 - b/hw/ide/qdev.c | 95 ++- b/hw/ide/via.c | 14 b/hw/integratorcp.c | 25 b/hw/intel-hda.c | 39 - b/hw/intel-hda.h |1 b/hw/ioapic.c| 14 b/hw/ioapic_common.c | 10 b/hw/ioapic_internal.h |1 b/hw/ioh3420.c | 20 b/hw/isa-bus.c | 38 - b/hw/isa.h |2 b/hw/ivshmem.c | 16 b/hw/kvm/apic.c |5 b/hw/kvm/clock.c | 16 b/hw/kvm/i8259.c |8 b/hw/kvm/ioapic.c| 20 b/hw/lan9118.c | 18 b/hw/lance.c | 20 b/hw/lm32_juart.c| 18 b/hw/lm32_pic.c | 16 b/hw/lm32_sys.c | 18 b/hw/lm32_timer.c| 18 b/hw/lm32_uart.c | 18 b/hw/lm832x.c| 14 b/hw/lsi53c895a.c| 17 b/hw/m48t59.c| 46 - b/hw/macio.c | 11 b/hw/marvell_88w8618_audio.c | 18 b/hw/max111x.c | 22 b/hw/max7310.c | 16 b/hw/mc146818rtc.c | 34 - b/hw/milkymist-ac97.c| 16 b/hw/milkymist-hpdmc.c | 16 b/hw/milkymist-memcard.c | 16 b/hw/milkymist-minimac2.c| 18 b/hw/milkymist-pfpu.c| 16 b/hw/milkymist-softusb.c | 18 b/hw/milkymist-sysctl.c | 18 b/hw/milkymist-tmu2.c| 16 b/hw/milkymist-uart.c| 18 b/hw/milkymist-vgafb.c | 18 b/hw/mips_malta.c
[Qemu-devel] [PATCH 10/22] qdev: kill off DeviceInfo
It is no longer used in the tree since everything is done natively through QEMU Object Model. Signed-off-by: Anthony Liguori aligu...@us.ibm.com --- hw/i2c.c |2 +- hw/ide/qdev.c |2 +- hw/intel-hda.c |2 +- hw/isa-bus.c |2 +- hw/pci.c |2 +- hw/qdev.c | 70 +--- hw/qdev.h | 33 +-- hw/s390-virtio-bus.c |2 +- hw/scsi-bus.c |2 +- hw/spapr_vio.c |2 +- hw/ssi.c |2 +- hw/sysbus.c|2 +- hw/usb-bus.c |2 +- hw/usb-ccid.c |2 +- hw/virtio-serial-bus.c |2 +- 15 files changed, 15 insertions(+), 114 deletions(-) diff --git a/hw/i2c.c b/hw/i2c.c index e21a666..8ae4aaa 100644 --- a/hw/i2c.c +++ b/hw/i2c.c @@ -196,7 +196,7 @@ const VMStateDescription vmstate_i2c_slave = { } }; -static int i2c_slave_qdev_init(DeviceState *dev, DeviceInfo *base) +static int i2c_slave_qdev_init(DeviceState *dev) { I2CSlave *s = I2C_SLAVE_FROM_QDEV(dev); I2CSlaveClass *sc = I2C_SLAVE_GET_CLASS(s); diff --git a/hw/ide/qdev.c b/hw/ide/qdev.c index 1335615..1640616 100644 --- a/hw/ide/qdev.c +++ b/hw/ide/qdev.c @@ -53,7 +53,7 @@ static char *idebus_get_fw_dev_path(DeviceState *dev) return strdup(path); } -static int ide_qdev_init(DeviceState *qdev, DeviceInfo *base) +static int ide_qdev_init(DeviceState *qdev) { IDEDevice *dev = IDE_DEVICE(qdev); IDEDeviceClass *dc = IDE_DEVICE_GET_CLASS(dev); diff --git a/hw/intel-hda.c b/hw/intel-hda.c index 9e4a31f..83c42d5 100644 --- a/hw/intel-hda.c +++ b/hw/intel-hda.c @@ -47,7 +47,7 @@ void hda_codec_bus_init(DeviceState *dev, HDACodecBus *bus, bus-xfer = xfer; } -static int hda_codec_dev_init(DeviceState *qdev, DeviceInfo *base) +static int hda_codec_dev_init(DeviceState *qdev) { HDACodecBus *bus = DO_UPCAST(HDACodecBus, qbus, qdev-parent_bus); HDACodecDevice *dev = DO_UPCAST(HDACodecDevice, qdev, qdev); diff --git a/hw/isa-bus.c b/hw/isa-bus.c index a22c5c6..d03f828 100644 --- a/hw/isa-bus.c +++ b/hw/isa-bus.c @@ -110,7 +110,7 @@ void isa_register_portio_list(ISADevice *dev, uint16_t start, portio_list_add(piolist, isabus-address_space_io, start); } -static int isa_qdev_init(DeviceState *qdev, DeviceInfo *base) +static int isa_qdev_init(DeviceState *qdev) { ISADevice *dev = ISA_DEVICE(qdev); ISADeviceClass *klass = ISA_DEVICE_GET_CLASS(dev); diff --git a/hw/pci.c b/hw/pci.c index 8fd450c..1df05ae 100644 --- a/hw/pci.c +++ b/hw/pci.c @@ -1453,7 +1453,7 @@ PCIDevice *pci_find_device(PCIBus *bus, int bus_num, uint8_t devfn) return bus-devices[devfn]; } -static int pci_qdev_init(DeviceState *qdev, DeviceInfo *base) +static int pci_qdev_init(DeviceState *qdev) { PCIDevice *pci_dev = (PCIDevice *)qdev; PCIDeviceClass *pc = PCI_DEVICE_GET_CLASS(pci_dev); diff --git a/hw/qdev.c b/hw/qdev.c index a30a1c2..4f6c3a7 100644 --- a/hw/qdev.c +++ b/hw/qdev.c @@ -43,49 +43,6 @@ static BusState *qbus_find_recursive(BusState *bus, const char *name, static BusState *qbus_find(const char *path); /* Register a new device type. */ -static void qdev_subclass_init(ObjectClass *klass, void *data) -{ -DeviceClass *dc = DEVICE_CLASS(klass); -DeviceInfo *info = data; - -if (info-fw_name) { -dc-fw_name = info-fw_name; -} -if (info-alias) { -dc-alias = info-alias; -} -if (info-desc) { -dc-desc = info-desc; -} -if (info-props) { -dc-props = info-props; -} -if (info-no_user) { -dc-no_user = info-no_user; -} -if (info-reset) { -dc-reset = info-reset; -} -if (info-vmsd) { -dc-vmsd = info-vmsd; -} -if (info-init) { -dc-init = info-init; -} -if (info-unplug) { -dc-unplug = info-unplug; -} -if (info-exit) { -dc-exit = info-exit; -} -if (info-bus_info) { -dc-bus_info = info-bus_info; -} -if (info-class_init) { -info-class_init(klass, data); -} -} - const VMStateDescription *qdev_get_vmsd(DeviceState *dev) { DeviceClass *dc = DEVICE_GET_CLASS(dev); @@ -117,30 +74,6 @@ const char *qdev_fw_name(DeviceState *dev) return object_get_typename(OBJECT(dev)); } -static void qdev_do_register_subclass(DeviceInfo *info, const char *parent, - const char *name) -{ -TypeInfo type_info = {}; - -assert(info-size = sizeof(DeviceState)); - -type_info.name = name; -type_info.parent = parent; -type_info.instance_size = info-size; -type_info.class_init = qdev_subclass_init; -type_info.class_data = info; - -type_register_static(type_info); -} - -void qdev_register_subclass(DeviceInfo *info, const char *parent) -{ -qdev_do_register_subclass(info, parent, info-name); -if (info-alias) { -
[Qemu-devel] [PATCH 21/22] object: sure up reference counting
Now we have the following behavior: 1) object_new() returns an object with ref = 1 2) object_initialize() does not increase the reference count (ref may be 0). 3) object_deref() will finalize the object when ref = 0. it does not free the memory associated with the object. 4) both link and child properties correctly set the reference count. The expected usage is the following: 1) child devices should generally be created via object_initialize() using memory from the parent device. Adding the object as a child property will take ownership of the object and tie the child's life cycle to the parent. 2) If a child device is created via qdev_create() or some other form of object_new(), there must be an object_delete() call in the parent device's finalize function. Signed-off-by: Anthony Liguori aligu...@us.ibm.com --- qom/object.c | 16 ++-- 1 files changed, 14 insertions(+), 2 deletions(-) diff --git a/qom/object.c b/qom/object.c index 49addef..33217b8 100644 --- a/qom/object.c +++ b/qom/object.c @@ -337,6 +337,8 @@ void object_finalize(void *data) object_deinit(obj, ti); object_property_del_all(obj); + +g_assert(obj-ref == 0); } Object *object_new_with_type(Type type) @@ -347,6 +349,7 @@ Object *object_new_with_type(Type type) obj = g_malloc(type-instance_size); object_initialize_with_type(obj, type); +object_ref(obj); return obj; } @@ -360,7 +363,8 @@ Object *object_new(const char *typename) void object_delete(Object *obj) { -object_finalize(obj); +object_unref(obj); +g_assert(obj-ref == 0); g_free(obj); } @@ -679,6 +683,14 @@ static void object_get_child_property(Object *obj, Visitor *v, void *opaque, g_free(path); } +static void object_finalize_child_property(Object *obj, const char *name, + void *opaque) +{ +Object *child = opaque; + +object_unref(child); +} + void object_property_add_child(Object *obj, const char *name, Object *child, Error **errp) { @@ -687,7 +699,7 @@ void object_property_add_child(Object *obj, const char *name, type = g_strdup_printf(child%s, object_get_typename(OBJECT(child))); object_property_add(obj, name, type, object_get_child_property, -NULL, NULL, child, errp); +NULL, object_finalize_child_property, child, errp); object_ref(child); g_assert(child-parent == NULL); -- 1.7.4.1
[Qemu-devel] [PATCH 20/22] info qdm: do not require a parent_bus to be set
Signed-off-by: Anthony Liguori aligu...@us.ibm.com --- hw/qdev-monitor.c | 12 +++- 1 files changed, 7 insertions(+), 5 deletions(-) diff --git a/hw/qdev-monitor.c b/hw/qdev-monitor.c index a6f0e16..56a3458 100644 --- a/hw/qdev-monitor.c +++ b/hw/qdev-monitor.c @@ -163,12 +163,14 @@ int qdev_device_help(QemuOpts *opts) error_printf(%s.%s=%s\n, driver, prop-name, prop-info-legacy_name ?: prop-info-name); } -for (prop = info-bus_info-props; prop prop-name; prop++) { -if (!prop-info-parse) { -continue; /* no way to set it, don't show */ +if (info-bus_info) { +for (prop = info-bus_info-props; prop prop-name; prop++) { +if (!prop-info-parse) { +continue; /* no way to set it, don't show */ +} +error_printf(%s.%s=%s\n, driver, prop-name, + prop-info-legacy_name ?: prop-info-name); } -error_printf(%s.%s=%s\n, driver, prop-name, - prop-info-legacy_name ?: prop-info-name); } return 1; } -- 1.7.4.1
[Qemu-devel] [PATCH 22/22] container: make a decendent of Object
Signed-off-by: Anthony Liguori aligu...@us.ibm.com --- v1 - v2 - Add license (Paolo) --- Makefile.objs |2 +- hw/container.c| 29 - hw/qdev-monitor.c | 14 ++ qom/Makefile |2 +- qom/container.c | 27 +++ qom/object.c |9 - 6 files changed, 39 insertions(+), 44 deletions(-) delete mode 100644 hw/container.c create mode 100644 qom/container.c diff --git a/Makefile.objs b/Makefile.objs index 1a26349..ec35320 100644 --- a/Makefile.objs +++ b/Makefile.objs @@ -286,7 +286,7 @@ hw-obj-$(CONFIG_LSI_SCSI_PCI) += lsi53c895a.o hw-obj-$(CONFIG_ESP) += esp.o hw-obj-y += dma-helpers.o sysbus.o isa-bus.o -hw-obj-y += qdev-addr.o container.o +hw-obj-y += qdev-addr.o # VGA hw-obj-$(CONFIG_VGA_PCI) += vga-pci.o diff --git a/hw/container.c b/hw/container.c deleted file mode 100644 index 1e97031..000 --- a/hw/container.c +++ /dev/null @@ -1,29 +0,0 @@ -#include sysbus.h - -static int container_initfn(SysBusDevice *dev) -{ -return 0; -} - -static void container_class_init(ObjectClass *klass, void *data) -{ -DeviceClass *dc = DEVICE_CLASS(klass); -SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass); - -k-init = container_initfn; -dc-no_user = 1; -} - -static TypeInfo container_info = { -.name = container, -.parent= TYPE_SYS_BUS_DEVICE, -.instance_size = sizeof(SysBusDevice), -.class_init= container_class_init, -}; - -static void container_init(void) -{ -type_register_static(container_info); -} - -device_init(container_init); diff --git a/hw/qdev-monitor.c b/hw/qdev-monitor.c index 56a3458..135c2bf 100644 --- a/hw/qdev-monitor.c +++ b/hw/qdev-monitor.c @@ -177,30 +177,28 @@ int qdev_device_help(QemuOpts *opts) static Object *qdev_get_peripheral(void) { -static DeviceState *dev; +static Object *dev; if (dev == NULL) { -dev = qdev_create(NULL, container); +dev = object_new(container); object_property_add_child(object_get_root(), peripheral, OBJECT(dev), NULL); -qdev_init_nofail(dev); } -return OBJECT(dev); +return dev; } static Object *qdev_get_peripheral_anon(void) { -static DeviceState *dev; +static Object *dev; if (dev == NULL) { -dev = qdev_create(NULL, container); +dev = object_new(container); object_property_add_child(object_get_root(), peripheral-anon, OBJECT(dev), NULL); -qdev_init_nofail(dev); } -return OBJECT(dev); +return dev; } static void qbus_list_bus(DeviceState *dev) diff --git a/qom/Makefile b/qom/Makefile index a3c7892..f33f0be 100644 --- a/qom/Makefile +++ b/qom/Makefile @@ -1 +1 @@ -qom-y = object.o +qom-y = object.o container.o diff --git a/qom/container.c b/qom/container.c new file mode 100644 index 000..946cbff --- /dev/null +++ b/qom/container.c @@ -0,0 +1,27 @@ +/* + * Device Container + * + * Copyright IBM, Corp. 2012 + * + * Authors: + * Anthony Liguori aligu...@us.ibm.com + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ + +#include qemu/object.h +#include module.h + +static TypeInfo container_info = { +.name = container, +.instance_size = sizeof(Object), +.parent= TYPE_OBJECT, +}; + +static void container_init(void) +{ +type_register_static(container_info); +} + +device_init(container_init); diff --git a/qom/object.c b/qom/object.c index 33217b8..4261944 100644 --- a/qom/object.c +++ b/qom/object.c @@ -662,14 +662,13 @@ const char *object_property_get_type(Object *obj, const char *name, Error **errp Object *object_get_root(void) { -static DeviceState *object_root; +static Object *root; -if (!object_root) { -object_root = qdev_create(NULL, container); -qdev_init_nofail(object_root); +if (!root) { +root = object_new(container); } -return OBJECT(object_root); +return root; } static void object_get_child_property(Object *obj, Visitor *v, void *opaque, -- 1.7.4.1
Re: [Qemu-devel] [PATCH 00/23] qom: use Type system to register all devices
On 30 January 2012 21:16, Anthony Liguori aligu...@us.ibm.com wrote: Patch 8/23 is an automated touch everything patch. It's kind of awkward having a patch series that is both long (number of patches) and wide (patches that require touching/conversion of every device in the tree), because the length means it needs a long review time on the list, and the width means it's going to conflict with lots of other changes (and especially newly arriving device models). -- PMM
Re: [Qemu-devel] [PATCH 21/23] object: sure up reference counting
On 02/01/2012 01:47 PM, Peter Maydell wrote: Subject: [PATCH 21/23] object: sure up reference counting On 30 January 2012 21:08, Anthony Liguorialigu...@us.ibm.com wrote: Subject: [PATCH 21/23] object: sure up reference counting shore up, apparently, although I found that sufficiently unlikely in this context that it might be better to reword completely :-) After a few weeks of repetitive code conversion and rebasing the same series a million and a half times, I'm surprised I'm not speaking entirely in tongues :-) Regards, Anthony Liguori -- PMM
Re: [Qemu-devel] [PATCH 09/23] qdev: kill of DeviceInfo
On 02/01/2012 01:46 PM, Peter Maydell wrote: On 30 January 2012 21:08, Anthony Liguorialigu...@us.ibm.com wrote: Subject: [PATCH 09/23] qdev: kill of DeviceInfo kill off. Tanks! Regards, Anthony Liguori -- PMM
[Qemu-devel] [PATCH v4 3/7] i8254: Factor out interface header
Move the public interface of the PIT into its own header file and update all users. Signed-off-by: Jan Kiszka jan.kis...@siemens.com --- hw/alpha_dp264.c |1 + hw/hpet.c |1 + hw/i82378.c|1 + hw/i8254.c |1 + hw/i8254.h | 54 hw/mips_fulong2e.c |1 + hw/mips_jazz.c |1 + hw/mips_malta.c|1 + hw/mips_r4k.c |1 + hw/pc.c|1 + hw/pc.h| 25 hw/pcspk.c |1 + 12 files changed, 64 insertions(+), 25 deletions(-) create mode 100644 hw/i8254.h diff --git a/hw/alpha_dp264.c b/hw/alpha_dp264.c index 876335a..4c0efd3 100644 --- a/hw/alpha_dp264.c +++ b/hw/alpha_dp264.c @@ -14,6 +14,7 @@ #include sysemu.h #include mc146818rtc.h #include ide.h +#include i8254.h #define MAX_IDE_BUS 2 diff --git a/hw/hpet.c b/hw/hpet.c index ce981cc..884043c 100644 --- a/hw/hpet.c +++ b/hw/hpet.c @@ -31,6 +31,7 @@ #include hpet_emul.h #include sysbus.h #include mc146818rtc.h +#include i8254.h //#define HPET_DEBUG #ifdef HPET_DEBUG diff --git a/hw/i82378.c b/hw/i82378.c index 9c3efe8..eb02963 100644 --- a/hw/i82378.c +++ b/hw/i82378.c @@ -19,6 +19,7 @@ #include pci.h #include pc.h +#include i8254.h //#define DEBUG_I82378 diff --git a/hw/i8254.c b/hw/i8254.c index bfb303e..17ceba7 100644 --- a/hw/i8254.c +++ b/hw/i8254.c @@ -25,6 +25,7 @@ #include pc.h #include isa.h #include qemu-timer.h +#include i8254.h //#define DEBUG_PIT diff --git a/hw/i8254.h b/hw/i8254.h new file mode 100644 index 000..cd3111c --- /dev/null +++ b/hw/i8254.h @@ -0,0 +1,54 @@ +/* + * QEMU 8253/8254 interval timer emulation + * + * Copyright (c) 2003-2004 Fabrice Bellard + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the Software), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef HW_I8254_H +#define HW_I8254_H + +#include hw.h +#include isa.h + +#define PIT_FREQ 1193182 + +static inline ISADevice *pit_init(ISABus *bus, int base, int irq) +{ +ISADevice *dev; + +dev = isa_create(bus, isa-pit); +qdev_prop_set_uint32(dev-qdev, iobase, base); +qdev_prop_set_uint32(dev-qdev, irq, irq); +qdev_init_nofail(dev-qdev); + +return dev; +} + +void pit_set_gate(ISADevice *dev, int channel, int val); +int pit_get_gate(ISADevice *dev, int channel); +int pit_get_initial_count(ISADevice *dev, int channel); +int pit_get_mode(ISADevice *dev, int channel); +int pit_get_out(ISADevice *dev, int channel, int64_t current_time); + +void hpet_pit_disable(void); +void hpet_pit_enable(void); + +#endif /* !HW_I8254_H */ diff --git a/hw/mips_fulong2e.c b/hw/mips_fulong2e.c index 163a668..ead72ae 100644 --- a/hw/mips_fulong2e.c +++ b/hw/mips_fulong2e.c @@ -40,6 +40,7 @@ #include elf.h #include vt82c686.h #include mc146818rtc.h +#include i8254.h #include blockdev.h #include exec-memory.h diff --git a/hw/mips_jazz.c b/hw/mips_jazz.c index 63165b9..61dee4d 100644 --- a/hw/mips_jazz.c +++ b/hw/mips_jazz.c @@ -36,6 +36,7 @@ #include mips-bios.h #include loader.h #include mc146818rtc.h +#include i8254.h #include blockdev.h #include sysbus.h #include exec-memory.h diff --git a/hw/mips_malta.c b/hw/mips_malta.c index d232630..c868d90 100644 --- a/hw/mips_malta.c +++ b/hw/mips_malta.c @@ -45,6 +45,7 @@ #include loader.h #include elf.h #include mc146818rtc.h +#include i8254.h #include blockdev.h #include exec-memory.h #include sysbus.h /* SysBusDevice */ diff --git a/hw/mips_r4k.c b/hw/mips_r4k.c index 1c0615c..1b3ec2d 100644 --- a/hw/mips_r4k.c +++ b/hw/mips_r4k.c @@ -22,6 +22,7 @@ #include loader.h #include elf.h #include mc146818rtc.h +#include i8254.h #include blockdev.h #include exec-memory.h diff --git a/hw/pc.c b/hw/pc.c index 7f3aa65..4140f05 100644 --- a/hw/pc.c +++ b/hw/pc.c @@ -36,6 +36,7 @@ #include elf.h #include multiboot.h #include mc146818rtc.h +#include i8254.h #include msi.h #include sysbus.h #include sysemu.h
[Qemu-devel] [PATCH 15/22] qdev: split out UI portions into a new function
qdev-monitor.c deals with the -device, device_add, and info qdm/qtree interfaces. Signed-off-by: Anthony Liguori aligu...@us.ibm.com --- Makefile.objs |2 +- hw/qdev-monitor.c | 585 + hw/qdev.c | 572 +--- hw/qdev.h |2 + 4 files changed, 589 insertions(+), 572 deletions(-) create mode 100644 hw/qdev-monitor.c diff --git a/Makefile.objs b/Makefile.objs index b942625..1a26349 100644 --- a/Makefile.objs +++ b/Makefile.objs @@ -113,7 +113,7 @@ common-obj-y += bt-hci-csr.o common-obj-y += buffered_file.o migration.o migration-tcp.o common-obj-y += qemu-char.o #aio.o common-obj-y += msmouse.o ps2.o -common-obj-y += qdev.o qdev-properties.o +common-obj-y += qdev.o qdev-properties.o qdev-monitor.o common-obj-y += block-migration.o iohandler.o common-obj-y += pflib.o common-obj-y += bitmap.o bitops.o diff --git a/hw/qdev-monitor.c b/hw/qdev-monitor.c new file mode 100644 index 000..841e1ad --- /dev/null +++ b/hw/qdev-monitor.c @@ -0,0 +1,585 @@ +/* + * Dynamic device configuration and creation. + * + * Copyright (c) 2009 CodeSourcery + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see http://www.gnu.org/licenses/. + */ + +#include qdev.h +#include monitor.h + +/* + * Aliases were a bad idea from the start. Let's keep them + * from spreading further. + */ +typedef struct QDevAlias +{ +const char *typename; +const char *alias; +} QDevAlias; + +static const QDevAlias qdev_alias_table[] = { +{ virtio-blk-pci, virtio-blk }, +{ virtio-net-pci, virtio-net }, +{ virtio-serial-pci, virtio-serial }, +{ virtio-balloon-pci, virtio-balloon }, +{ virtio-blk-s390, virtio-blk }, +{ virtio-net-s390, virtio-net }, +{ virtio-serial-s390, virtio-serial }, +{ lsi53c895a, lsi }, +{ ich9-ahci, ahci }, +{ } +}; + +static const char *qdev_class_get_alias(DeviceClass *dc) +{ +const char *typename = object_class_get_name(OBJECT_CLASS(dc)); +int i; + +for (i = 0; qdev_alias_table[i].typename; i++) { +if (strcmp(qdev_alias_table[i].typename, typename) == 0) { +return qdev_alias_table[i].alias; +} +} + +return NULL; +} + +static bool qdev_class_has_alias(DeviceClass *dc) +{ +return (qdev_class_get_alias(dc) != NULL); +} + +static void qdev_print_devinfo(ObjectClass *klass, void *opaque) +{ +DeviceClass *dc; +bool *show_no_user = opaque; + +dc = (DeviceClass *)object_class_dynamic_cast(klass, TYPE_DEVICE); + +if (!dc || (show_no_user !*show_no_user dc-no_user)) { +return; +} + +error_printf(name \%s\, object_class_get_name(klass)); +if (dc-bus_info) { +error_printf(, bus %s, dc-bus_info-name); +} +if (qdev_class_has_alias(dc)) { +error_printf(, alias \%s\, qdev_class_get_alias(dc)); +} +if (dc-desc) { +error_printf(, desc \%s\, dc-desc); +} +if (dc-no_user) { +error_printf(, no-user); +} +error_printf(\n); +} + +static int set_property(const char *name, const char *value, void *opaque) +{ +DeviceState *dev = opaque; + +if (strcmp(name, driver) == 0) +return 0; +if (strcmp(name, bus) == 0) +return 0; + +if (qdev_prop_parse(dev, name, value) == -1) { +return -1; +} +return 0; +} + +static const char *find_typename_by_alias(const char *alias) +{ +int i; + +for (i = 0; qdev_alias_table[i].alias; i++) { +if (strcmp(qdev_alias_table[i].alias, alias) == 0) { +return qdev_alias_table[i].typename; +} +} + +return NULL; +} + +int qdev_device_help(QemuOpts *opts) +{ +const char *driver; +Property *prop; +ObjectClass *klass; +DeviceClass *info; + +driver = qemu_opt_get(opts, driver); +if (driver !strcmp(driver, ?)) { +bool show_no_user = false; +object_class_foreach(qdev_print_devinfo, TYPE_DEVICE, false, show_no_user); +return 1; +} + +if (!driver || !qemu_opt_get(opts, ?)) { +return 0; +} + +klass = object_class_by_name(driver); +if (!klass) { +const char *typename = find_typename_by_alias(driver); + +if (typename) { +driver = typename; +klass = object_class_by_name(driver); +} +} + +if (!klass) { +
Re: [Qemu-devel] [PATCH 17/23] qom: move properties from qdev to object
On 01/31/2012 01:46 AM, Paolo Bonzini wrote: On 01/30/2012 10:08 PM, Anthony Liguori wrote: This is mostly code movement although not entirely. This makes properties part of the Object base class which means that we can now start using Object in a meaningful way outside of qdev. Can we move them to an intermediate base class? I would like to use QOM refcounting for other objects, such as SCSIRequest, so it is important to have Object as a pretty light-weight class. Also (and perhaps more importantly), interface implementations are Objects too and they do not need properties. I cannot think of any better name than IntrospectableObject, which is quite a mouthful. I suppose that we could have the base class but still pass the objects to the function as Object * and use the OBJECT macro. Nothing of this is in a hot path anyway. I'm just not sure how I feel about this. The overhead of properties are small in terms of object size. It's just sizeof(void *). I think that read-only properties could be interesting for SCSIRequest. For instance, I can imagine having SCSIRequest is-a BlockRequest and having an error property associated with it. That would provide a nice way to have an info io operation that returned a list of failed I/O requests or something like that. Regards, Anthony Liguori Paolo
[Qemu-devel] [PATCH 11/22] qdev: remove baked in notion of aliases (v2)
Limit them to the device_add functionality. Device aliases were a hack based on the fact that virtio was modeled the wrong way. The mechanism for aliasing is very limited in that only one alias can exist for any device. We have to support it for the purposes of compatibility but we only need to support it in device_add so restrict it to that piece of code. Signed-off-by: Anthony Liguori aligu...@us.ibm.com --- v1 - v2 - Use a table for aliases (Paolo) --- hw/ide/ich.c |2 - hw/lsi53c895a.c |2 - hw/qdev.c| 93 ++--- hw/qdev.h|1 - hw/s390-virtio-bus.c |3 -- hw/virtio-pci.c |8 6 files changed, 87 insertions(+), 22 deletions(-) diff --git a/hw/ide/ich.c b/hw/ide/ich.c index 0e819f6..5cdaa99 100644 --- a/hw/ide/ich.c +++ b/hw/ide/ich.c @@ -158,7 +158,6 @@ static void ich_ahci_class_init(ObjectClass *klass, void *data) k-device_id = PCI_DEVICE_ID_INTEL_82801IR; k-revision = 0x02; k-class_id = PCI_CLASS_STORAGE_SATA; -dc-alias = ahci; dc-vmsd = vmstate_ahci; } @@ -172,6 +171,5 @@ static TypeInfo ich_ahci_info = { static void ich_ahci_register(void) { type_register_static(ich_ahci_info); -type_register_static_alias(ich_ahci_info, ahci); } device_init(ich_ahci_register); diff --git a/hw/lsi53c895a.c b/hw/lsi53c895a.c index 638332e..9a7ffe3 100644 --- a/hw/lsi53c895a.c +++ b/hw/lsi53c895a.c @@ -2131,7 +2131,6 @@ static void lsi_class_init(ObjectClass *klass, void *data) k-device_id = PCI_DEVICE_ID_LSI_53C895A; k-class_id = PCI_CLASS_STORAGE_SCSI; k-subsystem_id = 0x1000; -dc-alias = lsi; dc-reset = lsi_scsi_reset; dc-vmsd = vmstate_lsi_scsi; } @@ -2146,7 +2145,6 @@ static TypeInfo lsi_info = { static void lsi53c895a_register_devices(void) { type_register_static(lsi_info); -type_register_static_alias(lsi_info, lsi); } device_init(lsi53c895a_register_devices); diff --git a/hw/qdev.c b/hw/qdev.c index 4f6c3a7..5830bef 100644 --- a/hw/qdev.c +++ b/hw/qdev.c @@ -61,14 +61,56 @@ Property *qdev_get_props(DeviceState *dev) return dc-props; } +/* + * Aliases were a bad idea from the start. Let's keep them + * from spreading further. + */ +typedef struct QDevAlias +{ +const char *typename; +const char *alias; +} QDevAlias; + +static const QDevAlias qdev_alias_table[] = { +{ virtio-blk-pci, virtio-blk }, +{ virtio-net-pci, virtio-net }, +{ virtio-serial-pci, virtio-serial }, +{ virtio-balloon-pci, virtio-balloon }, +{ virtio-blk-s390, virtio-blk }, +{ virtio-net-s390, virtio-net }, +{ virtio-serial-s390, virtio-serial }, +{ lsi53c895a, lsi }, +{ ich9-ahci, ahci }, +{ } +}; + +static const char *qdev_class_get_alias(DeviceClass *dc) +{ +const char *typename = object_class_get_name(OBJECT_CLASS(dc)); +int i; + +for (i = 0; qdev_alias_table[i].typename; i++) { +if (strcmp(qdev_alias_table[i].typename, typename) == 0) { +return qdev_alias_table[i].alias; +} +} + +return NULL; +} + +static bool qdev_class_has_alias(DeviceClass *dc) +{ +return (qdev_class_get_alias(dc) != NULL); +} + const char *qdev_fw_name(DeviceState *dev) { DeviceClass *dc = DEVICE_GET_CLASS(dev); if (dc-fw_name) { return dc-fw_name; -} else if (dc-alias) { -return dc-alias; +} else if (qdev_class_has_alias(dc)) { +return qdev_class_get_alias(dc); } return object_get_typename(OBJECT(dev)); @@ -161,8 +203,8 @@ static void qdev_print_devinfo(ObjectClass *klass, void *opaque) if (dc-bus_info) { error_printf(, bus %s, dc-bus_info-name); } -if (dc-alias) { -error_printf(, alias \%s\, dc-alias); +if (qdev_class_has_alias(dc)) { +error_printf(, alias \%s\, qdev_class_get_alias(dc)); } if (dc-desc) { error_printf(, desc \%s\, dc-desc); @@ -188,6 +230,19 @@ static int set_property(const char *name, const char *value, void *opaque) return 0; } +static const char *find_typename_by_alias(const char *alias) +{ +int i; + +for (i = 0; qdev_alias_table[i].alias; i++) { +if (strcmp(qdev_alias_table[i].alias, alias) == 0) { +return qdev_alias_table[i].typename; +} +} + +return NULL; +} + int qdev_device_help(QemuOpts *opts) { const char *driver; @@ -208,6 +263,15 @@ int qdev_device_help(QemuOpts *opts) klass = object_class_by_name(driver); if (!klass) { +const char *typename = find_typename_by_alias(driver); + +if (typename) { +driver = typename; +klass = object_class_by_name(driver); +} +} + +if (!klass) { return 0; } info = DEVICE_CLASS(klass); @@ -263,6 +327,7 @@ static DeviceState *qdev_get_peripheral_anon(void) DeviceState *qdev_device_add(QemuOpts *opts) { +ObjectClass *obj;
Re: [Qemu-devel] RFC: Device isolation groups
On Wed, 2012-02-01 at 15:46 +1100, David Gibson wrote: This patch series introduces a new infrastructure to the driver core for representing device isolation groups. That is, groups of devices which can be isolated in such a way that the rest of the system can be protected from them, even in the presence of userspace or a guest OS directly driving the devices. Isolation will typically be due to an IOMMU which can safely remap DMA and interrupts coming from these devices. We need to represent whole groups, rather than individual devices, because there are a number of cases where the group can be isolated as a whole, but devices within it cannot be safely isolated from each other - this usually occurs because the IOMMU cannot reliably distinguish which device in the group initiated a transaction. In other words, isolation groups represent the minimum safe granularity for passthrough to guests or userspace. This series provides the core infraustrcture for tracking isolation groups, and example implementations initializing the groups appropriately for two PCI bridges (which include IOMMUs) found on IBM POWER systems. Actually using the group information is not included here, but David Woodhouse has expressed an interest in using a structure like this to represent operations in iommu_ops more correctly. Some tracking of groups is a prerequisite for safe passthrough of devices to guests or userspace, such as done by VFIO. Current VFIO patches use the iommu_ops-device_group mechanism for this. However, that mechanism is awkward, because without an in-kernel concrete representation of groups, enumerating a group requires traversing every device on a given bus type. It also fails to cover some very plausible IOMMU topologies, because its groups cannot span devices on multiple bus types. So far so good, but there's not much meat on the bone yet. The sysfs linking and a list of devices in a group is all pretty straight forward and obvious. I'm not sure yet how this solves the DMA quirks kind of issues though. For instance if we have the ricoh device that uses the wrong source ID for DMA from function 1 and we put functions 0 1 in an isolation group... then what? And who does device quirk grouping? Each IOMMU driver? For the iommu_device_group() interface, I had imagined that we'd have something like: struct device *device_dma_alias_quirk(struct device *dev) { if (is broken ricoh func 1) return ricoh func0; return dev; } Then iommu_device_group turns into: int iommu_device_group(struct device *dev, unsigned int *groupid) { dev = device_dma_alias_quirk(dev); if (iommu_present(dev-bus) dev-bus-iommu_ops-device_group) return dev-bus-iommu_ops-device_group(dev, groupid); return -ENODEV; } and device_dma_alias_quirk() is available for dma_ops too. So maybe a struct device_isolation_group not only needs a list of devices, but it also needs the representative device to do mappings identified. dma_ops would then just use dev-di_group-dma_dev for mappings, and I assume we call iommu_alloc() with a di_group and instead of iommu_attach/detach_device, we'd have iommu_attach/detach_group? What I'm really curious about is where you now stand on what's going to happen in device_isolation_bind(). How do we get from a device in sysfs pointing to a group to something like vfio binding to that group and creating a chardev to access it? Are we manipulating automatic driver binding or existing bound drivers once a group is bound? Do isolation groups enforce isolation, or just describe it? Thanks, Alex
Re: [Qemu-devel] [PATCH 00/23] qom: use Type system to register all devices
On 02/01/2012 01:55 PM, Peter Maydell wrote: On 30 January 2012 21:16, Anthony Liguorialigu...@us.ibm.com wrote: Patch 8/23 is an automated touch everything patch. It's kind of awkward having a patch series that is both long (number of patches) and wide (patches that require touching/conversion of every device in the tree), because the length means it needs a long review time on the list, and the width means it's going to conflict with lots of other changes (and especially newly arriving device models). I could certainly split this into three parts. But patches 0-8 aren't terribly meaningful outside of the context of patch 9. And patch 9 by itself leaves the old infrastructure around which means that you would potentially need more patches like patch 9 in a future series. So I don't think this series could really be trimmed by anything more than a couple patches and I don't see a huge advantage in doing that. This sort of changes are the exception, not the common thing. Once this series is merged, things will go back to normal patch series wise. Regards, Anthony Liguori -- PMM
[Qemu-devel] [PATCH 12/22] qom: add new command to search for types
This adds a command that allows searching for types that implement a property. This allows you to do things like search for all available PCIDevices. In the future, we'll also have a standard interface for things with a BlockDriverState property that a PCIDevice could implement. This will enable search queries like, any type that implements the BlockDevice interface which would allow management tools to present available block devices without having to hard code device names. Since an object can implement multiple interfaces, one device could act both as a BlockDevice and a NetworkDevice. Signed-off-by: Anthony Liguori aligu...@us.ibm.com --- qapi-schema.json | 33 + qerror.c |2 +- qmp-commands.hx |5 + qmp.c| 27 +++ 4 files changed, 66 insertions(+), 1 deletions(-) diff --git a/qapi-schema.json b/qapi-schema.json index 80debe6..56a4123 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -1549,3 +1549,36 @@ # Since: 1.1 ## { 'command': 'block_job_cancel', 'data': { 'device': 'str' } } + +## +# @ObjectTypeInfo: +# +# This structure describes a search result from @qom-list-types +# +# @name: the type name found in the search +# +# Since: 1.1 +# +# Notes: This command is experimental and may change syntax in future releases. +## +{ 'type': 'ObjectTypeInfo', + 'data': { 'name': 'str' } } + +## +# @qom-list-types: +# +# This command will return a list of types given search parameters +# +# @implements: if specified, only return types that implement this type name +# +# @abstract: if true, include abstract types in the results +# +# Returns: a list of @ObjectTypeInfo or an empty list if no results are found +# +# Since: 1.1 +# +# Notes: This command is experimental and may change syntax in future releases. +## +{ 'command': 'qom-list-types', + 'data': { '*implements': 'str', '*abstract': 'bool' }, + 'returns': [ 'ObjectTypeInfo' ] } diff --git a/qerror.c b/qerror.c index 637eca7..3d179c8 100644 --- a/qerror.c +++ b/qerror.c @@ -161,7 +161,7 @@ static const QErrorStringTable qerror_table[] = { }, { .error_fmt = QERR_INVALID_PARAMETER_TYPE, -.desc = Invalid parameter type, expected: %(expected), +.desc = Invalid parameter type for '%(name)', expected: %(expected), }, { .error_fmt = QERR_INVALID_PARAMETER_VALUE, diff --git a/qmp-commands.hx b/qmp-commands.hx index bd6b641..b5e2ab8 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -2042,3 +2042,8 @@ EQMP .args_type = password:s, .mhandler.cmd_new = qmp_marshal_input_change_vnc_password, }, +{ +.name = qom-list-types, +.args_type = implements:s?,abstract:b?, +.mhandler.cmd_new = qmp_marshal_input_qom_list_types, +}, diff --git a/qmp.c b/qmp.c index 1222b6c..75049ed 100644 --- a/qmp.c +++ b/qmp.c @@ -395,3 +395,30 @@ void qmp_change(const char *device, const char *target, qmp_change_blockdev(device, target, has_arg, arg, err); } } + +static void qom_list_types_tramp(ObjectClass *klass, void *data) +{ +ObjectTypeInfoList *e, **pret = data; +ObjectTypeInfo *info; + +info = g_malloc0(sizeof(*info)); +info-name = g_strdup(object_class_get_name(klass)); + +e = g_malloc0(sizeof(*e)); +e-value = info; +e-next = *pret; +*pret = e; +} + +ObjectTypeInfoList *qmp_qom_list_types(bool has_implements, + const char *implements, + bool has_abstract, + bool abstract, + Error **errp) +{ +ObjectTypeInfoList *ret = NULL; + +object_class_foreach(qom_list_types_tramp, implements, abstract, ret); + +return ret; +} -- 1.7.4.1
[Qemu-devel] [PATCH 03/22] qdev: make DeviceInfo private
Introduce accessors and remove any code that directly accesses DeviceInfo members. Signed-off-by: Anthony Liguori aligu...@us.ibm.com --- hw/pci.c | 13 - hw/qdev-properties.c |4 ++-- hw/qdev.c| 30 +- hw/qdev.h| 24 +--- 4 files changed, 48 insertions(+), 23 deletions(-) diff --git a/hw/pci.c b/hw/pci.c index 6a0b1f5..235ea00 100644 --- a/hw/pci.c +++ b/hw/pci.c @@ -1673,6 +1673,7 @@ static int pci_add_option_rom(PCIDevice *pdev, bool is_default_rom) char *path; void *ptr; char name[32]; +const VMStateDescription *vmsd; if (!pdev-romfile) return 0; @@ -1709,10 +1710,13 @@ static int pci_add_option_rom(PCIDevice *pdev, bool is_default_rom) size = 1 qemu_fls(size); } -if (qdev_get_info(pdev-qdev)-vmsd) -snprintf(name, sizeof(name), %s.rom, qdev_get_info(pdev-qdev)-vmsd-name); -else +vmsd = qdev_get_vmsd(DEVICE(pdev)); + +if (vmsd) { +snprintf(name, sizeof(name), %s.rom, vmsd-name); +} else { snprintf(name, sizeof(name), %s.rom, object_get_typename(OBJECT(pdev))); +} pdev-has_rom = true; memory_region_init_ram(pdev-rom, name, size); vmstate_register_ram(pdev-rom, pdev-qdev); @@ -1953,8 +1957,7 @@ static int pci_qdev_find_recursive(PCIBus *bus, } /* roughly check if given qdev is pci device */ -if (qdev_get_info(qdev)-init == pci_qdev_init -qdev-parent_bus-info == pci_bus_info) { +if (object_dynamic_cast(OBJECT(qdev), TYPE_PCI_DEVICE)) { *pdev = PCI_DEVICE(qdev); return 0; } diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c index c98219a..724dce5 100644 --- a/hw/qdev-properties.c +++ b/hw/qdev-properties.c @@ -966,7 +966,7 @@ static Property *qdev_prop_find(DeviceState *dev, const char *name) Property *prop; /* device properties */ -prop = qdev_prop_walk(qdev_get_info(dev)-props, name); +prop = qdev_prop_walk(qdev_get_props(dev), name); if (prop) return prop; @@ -1166,7 +1166,7 @@ void qdev_prop_set_globals(DeviceState *dev) QTAILQ_FOREACH(prop, global_props, next) { if (strcmp(object_get_typename(OBJECT(dev)), prop-driver) != 0 -strcmp(qdev_get_info(dev)-bus_info-name, prop-driver) != 0) { +strcmp(qdev_get_bus_info(dev)-name, prop-driver) != 0) { continue; } if (qdev_prop_parse(dev, prop-property, prop-value) != 0) { diff --git a/hw/qdev.c b/hw/qdev.c index a8c24de..18c5876 100644 --- a/hw/qdev.c +++ b/hw/qdev.c @@ -60,11 +60,39 @@ static void qdev_subclass_init(ObjectClass *klass, void *data) } } -DeviceInfo *qdev_get_info(DeviceState *dev) +static DeviceInfo *qdev_get_info(DeviceState *dev) { return DEVICE_GET_CLASS(dev)-info; } +const VMStateDescription *qdev_get_vmsd(DeviceState *dev) +{ +return qdev_get_info(dev)-vmsd; +} + +BusInfo *qdev_get_bus_info(DeviceState *dev) +{ +return qdev_get_info(dev)-bus_info; +} + +Property *qdev_get_props(DeviceState *dev) +{ +return qdev_get_info(dev)-props; +} + +const char *qdev_fw_name(DeviceState *dev) +{ +DeviceInfo *info = qdev_get_info(dev); + +if (info-fw_name) { +return info-fw_name; +} else if (info-alias) { +return info-alias; +} + +return object_get_typename(OBJECT(dev)); +} + void qdev_register_subclass(DeviceInfo *info, const char *parent) { TypeInfo type_info = {}; diff --git a/hw/qdev.h b/hw/qdev.h index c9572a5..dc6a6fe 100644 --- a/hw/qdev.h +++ b/hw/qdev.h @@ -398,22 +398,8 @@ void qdev_prop_set_globals(DeviceState *dev); void error_set_from_qdev_prop_error(Error **errp, int ret, DeviceState *dev, Property *prop, const char *value); -DeviceInfo *qdev_get_info(DeviceState *dev); - -static inline const char *qdev_fw_name(DeviceState *dev) -{ -DeviceInfo *info = qdev_get_info(dev); - -if (info-fw_name) { -return info-fw_name; -} else if (info-alias) { -return info-alias; -} - -return object_get_typename(OBJECT(dev)); -} - char *qdev_get_fw_dev_path(DeviceState *dev); + /* This is a nasty hack to allow passing a NULL bus to qdev_create. */ extern struct BusInfo system_bus_info; @@ -661,4 +647,12 @@ void qdev_machine_init(void); */ void device_reset(DeviceState *dev); +const VMStateDescription *qdev_get_vmsd(DeviceState *dev); + +const char *qdev_fw_name(DeviceState *dev); + +BusInfo *qdev_get_bus_info(DeviceState *dev); + +Property *qdev_get_props(DeviceState *dev); + #endif -- 1.7.4.1
[Qemu-devel] [PATCH v4 0/7] pit, hpet, pcspk: fixes preparation for KVM
Changes in V4: - rebased over qom-upstream.13 - comment on rtc_irq_level clearing on reset - fix call to isa_register_ioport by passing the pcspk device Not changed: - PIT pointer property of pcspk (Paolo will port it together with other PROP_PTR users) CC: Paolo Bonzini pbonz...@redhat.com Jan Kiszka (7): i8254: Do not raise IRQ level on reset hpet: Save/restore cached RTC IRQ level i8254: Factor out interface header i8254: Pass alternative IRQ output object on initialization i8254: Rework fix interaction with HPET in legacy mode pcspk: Convert to qdev i8254: Factor out pit_get_channel_info arch_init.c|1 + hw/alpha_dp264.c |3 +- hw/hpet.c | 68 -- hw/hpet_emul.h |3 ++ hw/i82378.c|6 ++- hw/i8254.c | 92 ++- hw/i8254.h | 57 hw/mips_fulong2e.c |3 +- hw/mips_jazz.c |6 ++- hw/mips_malta.c|3 +- hw/mips_r4k.c |3 +- hw/pc.c| 19 -- hw/pc.h| 29 hw/pcspk.c | 84 +++ hw/pcspk.h | 45 + 15 files changed, 296 insertions(+), 126 deletions(-) create mode 100644 hw/i8254.h create mode 100644 hw/pcspk.h -- 1.7.3.4
[Qemu-devel] [PATCH v4 6/7] pcspk: Convert to qdev
Convert the PC speaker device to a qdev ISA model. Move the public interface to a dedicated header file at this chance. CC: Paolo Bonzini pbonz...@redhat.com Signed-off-by: Jan Kiszka jan.kis...@siemens.com --- arch_init.c|1 + hw/i82378.c|3 +- hw/mips_jazz.c |3 +- hw/pc.c|3 +- hw/pc.h|4 --- hw/pcspk.c | 67 +++ hw/pcspk.h | 45 + 7 files changed, 109 insertions(+), 17 deletions(-) create mode 100644 hw/pcspk.h diff --git a/arch_init.c b/arch_init.c index 2366511..a45485b 100644 --- a/arch_init.c +++ b/arch_init.c @@ -42,6 +42,7 @@ #include gdbstub.h #include hw/smbios.h #include exec-memory.h +#include hw/pcspk.h #ifdef TARGET_SPARC int graphic_width = 1024; diff --git a/hw/i82378.c b/hw/i82378.c index ce64767..e01acc1 100644 --- a/hw/i82378.c +++ b/hw/i82378.c @@ -20,6 +20,7 @@ #include pci.h #include pc.h #include i8254.h +#include pcspk.h //#define DEBUG_I82378 @@ -195,7 +196,7 @@ static void i82378_init(DeviceState *dev, I82378State *s) pit = pit_init(isabus, 0x40, 0, NULL); /* speaker */ -pcspk_init(pit); +pcspk_init(isabus, pit); /* 2 82C37 (dma) */ DMA_init(1, s-out[1]); diff --git a/hw/mips_jazz.c b/hw/mips_jazz.c index b61b218..65608dc 100644 --- a/hw/mips_jazz.c +++ b/hw/mips_jazz.c @@ -37,6 +37,7 @@ #include loader.h #include mc146818rtc.h #include i8254.h +#include pcspk.h #include blockdev.h #include sysbus.h #include exec-memory.h @@ -193,7 +194,7 @@ static void mips_jazz_init(MemoryRegion *address_space, cpu_exit_irq = qemu_allocate_irqs(cpu_request_exit, NULL, 1); DMA_init(0, cpu_exit_irq); pit = pit_init(isa_bus, 0x40, 0, NULL); -pcspk_init(pit); +pcspk_init(isa_bus, pit); /* ISA IO space at 0x9000 */ isa_mmio_init(0x9000, 0x0100); diff --git a/hw/pc.c b/hw/pc.c index 571e6c3..a04f9ca 100644 --- a/hw/pc.c +++ b/hw/pc.c @@ -37,6 +37,7 @@ #include multiboot.h #include mc146818rtc.h #include i8254.h +#include pcspk.h #include msi.h #include sysbus.h #include sysemu.h @@ -1171,7 +1172,7 @@ void pc_basic_device_init(ISABus *isa_bus, qemu_irq *gsi, /* connect PIT to output control line of the HPET */ qdev_connect_gpio_out(hpet, 0, qdev_get_gpio_in(pit-qdev, 0)); } -pcspk_init(pit); +pcspk_init(isa_bus, pit); for(i = 0; i MAX_SERIAL_PORTS; i++) { if (serial_hds[i]) { diff --git a/hw/pc.h b/hw/pc.h index b08708d..1b47bbd 100644 --- a/hw/pc.h +++ b/hw/pc.h @@ -149,10 +149,6 @@ void piix4_smbus_register_device(SMBusDevice *dev, uint8_t addr); /* hpet.c */ extern int no_hpet; -/* pcspk.c */ -void pcspk_init(ISADevice *pit); -int pcspk_audio_init(ISABus *bus); - /* piix_pci.c */ struct PCII440FXState; typedef struct PCII440FXState PCII440FXState; diff --git a/hw/pcspk.c b/hw/pcspk.c index 43df818..d406c68 100644 --- a/hw/pcspk.c +++ b/hw/pcspk.c @@ -28,6 +28,7 @@ #include audio/audio.h #include qemu-timer.h #include i8254.h +#include pcspk.h #define PCSPK_BUF_LEN 1792 #define PCSPK_SAMPLE_RATE 32000 @@ -35,10 +36,13 @@ #define PCSPK_MIN_COUNT ((PIT_FREQ + PCSPK_MAX_FREQ - 1) / PCSPK_MAX_FREQ) typedef struct { +ISADevice dev; +MemoryRegion ioport; +uint32_t iobase; uint8_t sample_buf[PCSPK_BUF_LEN]; QEMUSoundCard card; SWVoiceOut *voice; -ISADevice *pit; +void *pit; unsigned int pit_count; unsigned int samples; unsigned int play_pos; @@ -47,7 +51,7 @@ typedef struct { } PCSpkState; static const char *s_spk = pcspk; -static PCSpkState pcspk_state; +static PCSpkState *pcspk_state; static inline void generate_samples(PCSpkState *s) { @@ -99,7 +103,7 @@ static void pcspk_callback(void *opaque, int free) int pcspk_audio_init(ISABus *bus) { -PCSpkState *s = pcspk_state; +PCSpkState *s = pcspk_state; struct audsettings as = {PCSPK_SAMPLE_RATE, 1, AUD_FMT_U8, 0}; AUD_register_card(s_spk, s-card); @@ -113,7 +117,8 @@ int pcspk_audio_init(ISABus *bus) return 0; } -static uint32_t pcspk_ioport_read(void *opaque, uint32_t addr) +static uint64_t pcspk_io_read(void *opaque, target_phys_addr_t addr, + unsigned size) { PCSpkState *s = opaque; int out; @@ -124,7 +129,8 @@ static uint32_t pcspk_ioport_read(void *opaque, uint32_t addr) return pit_get_gate(s-pit, 2) | (s-data_on 1) | s-dummy_refresh_clock | out; } -static void pcspk_ioport_write(void *opaque, uint32_t addr, uint32_t val) +static void pcspk_io_write(void *opaque, target_phys_addr_t addr, uint64_t val, + unsigned size) { PCSpkState *s = opaque; const int gate = val 1; @@ -138,11 +144,52 @@ static void pcspk_ioport_write(void *opaque, uint32_t addr, uint32_t val) } } -void pcspk_init(ISADevice *pit) +static const MemoryRegionOps pcspk_io_ops = { +
[Qemu-devel] [PATCH 19/22] qdev: implement cleanup logic in finalize
Signed-off-by: Anthony Liguori aligu...@us.ibm.com --- hw/qdev.c | 57 - 1 files changed, 32 insertions(+), 25 deletions(-) diff --git a/hw/qdev.c b/hw/qdev.c index 8f13e49..e3b53b7 100644 --- a/hw/qdev.c +++ b/hw/qdev.c @@ -247,31 +247,6 @@ void qdev_init_nofail(DeviceState *dev) /* Unlink device from bus and free the structure. */ void qdev_free(DeviceState *dev) { -BusState *bus; -Property *prop; -DeviceClass *dc = DEVICE_GET_CLASS(dev); - -if (dev-state == DEV_STATE_INITIALIZED) { -while (dev-num_child_bus) { -bus = QLIST_FIRST(dev-child_bus); -qbus_free(bus); -} -if (qdev_get_vmsd(dev)) { -vmstate_unregister(dev, qdev_get_vmsd(dev), dev); -} -if (dc-exit) { -dc-exit(dev); -} -if (dev-opts) { -qemu_opts_del(dev-opts); -} -} -QTAILQ_REMOVE(dev-parent_bus-children, dev, sibling); -for (prop = qdev_get_props(dev); prop prop-name; prop++) { -if (prop-info-free) { -prop-info-free(dev, prop); -} -} object_delete(OBJECT(dev)); } @@ -634,6 +609,37 @@ static void device_initfn(Object *obj) object_property_add_str(OBJECT(dev), type, qdev_get_type, NULL, NULL); } +/* Unlink device from bus and free the structure. */ +static void device_finalize(Object *obj) +{ +DeviceState *dev = DEVICE(obj); +BusState *bus; +Property *prop; +DeviceClass *dc = DEVICE_GET_CLASS(dev); + +if (dev-state == DEV_STATE_INITIALIZED) { +while (dev-num_child_bus) { +bus = QLIST_FIRST(dev-child_bus); +qbus_free(bus); +} +if (qdev_get_vmsd(dev)) { +vmstate_unregister(dev, qdev_get_vmsd(dev), dev); +} +if (dc-exit) { +dc-exit(dev); +} +if (dev-opts) { +qemu_opts_del(dev-opts); +} +} +QTAILQ_REMOVE(dev-parent_bus-children, dev, sibling); +for (prop = qdev_get_props(dev); prop prop-name; prop++) { +if (prop-info-free) { +prop-info-free(dev, prop); +} +} +} + void device_reset(DeviceState *dev) { DeviceClass *klass = DEVICE_GET_CLASS(dev); @@ -648,6 +654,7 @@ static TypeInfo device_type_info = { .parent = TYPE_OBJECT, .instance_size = sizeof(DeviceState), .instance_init = device_initfn, +.instance_finalize = device_finalize, .abstract = true, .class_size = sizeof(DeviceClass), }; -- 1.7.4.1
Re: [Qemu-devel] [PATCH 17/23] qom: move properties from qdev to object
On 02/01/2012 09:01 PM, Anthony Liguori wrote: I think that read-only properties could be interesting for SCSIRequest. For instance, I can imagine having SCSIRequest is-a BlockRequest and having an error property associated with it. That would provide a nice way to have an info io operation that returned a list of failed I/O requests or something like that. SCSIRequests can have a BlockRequest as a child; not all SCSIRequests have I/O attached to them, but I see the general concept. I'm not sure we'll be able to optimize enough, but we can certainly try... Paolo
[Qemu-devel] [PATCH 07/22] qom: allow object_class_foreach to take additional parameters to refine search
Signed-off-by: Anthony Liguori aligu...@us.ibm.com --- include/qemu/object.h |1 + qom/object.c | 18 -- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/include/qemu/object.h b/include/qemu/object.h index ba37850..adbcfb1 100644 --- a/include/qemu/object.h +++ b/include/qemu/object.h @@ -431,6 +431,7 @@ const char *object_class_get_name(ObjectClass *klass); ObjectClass *object_class_by_name(const char *typename); void object_class_foreach(void (*fn)(ObjectClass *klass, void *opaque), + const char *implements_type, bool include_abstract, void *opaque); #endif diff --git a/qom/object.c b/qom/object.c index a12895f..3dabb1a 100644 --- a/qom/object.c +++ b/qom/object.c @@ -467,6 +467,8 @@ ObjectClass *object_class_by_name(const char *typename) typedef struct OCFData { void (*fn)(ObjectClass *klass, void *opaque); +const char *implements_type; +bool include_abstract; void *opaque; } OCFData; @@ -475,16 +477,28 @@ static void object_class_foreach_tramp(gpointer key, gpointer value, { OCFData *data = opaque; TypeImpl *type = value; +ObjectClass *k; type_class_init(type); +k = type-class; -data-fn(value, type-class); +if (!data-include_abstract type-abstract) { +return; +} + +if (data-implements_type +!object_class_dynamic_cast(k, data-implements_type)) { +return; +} + +data-fn(k, data-opaque); } void object_class_foreach(void (*fn)(ObjectClass *klass, void *opaque), + const char *implements_type, bool include_abstract, void *opaque) { -OCFData data = { fn, opaque }; +OCFData data = { fn, implements_type, include_abstract, opaque }; g_hash_table_foreach(type_table_get(), object_class_foreach_tramp, data); } -- 1.7.4.1
[Qemu-devel] [PATCH v4 4/7] i8254: Pass alternative IRQ output object on initialization
HPET legacy emulation will require control over the PIT IRQ output. To enable this, add support for an alternative IRQ output object to the PIT factory function. If the isa_irq number is 0, this object will be used. This also removes the IRQ number property from the PIT class as we now use a generic GPIO output pin that is connected by the factory function. Signed-off-by: Jan Kiszka jan.kis...@siemens.com --- hw/alpha_dp264.c |2 +- hw/i82378.c|2 +- hw/i8254.c |4 +--- hw/i8254.h |6 -- hw/mips_fulong2e.c |2 +- hw/mips_jazz.c |2 +- hw/mips_malta.c|2 +- hw/mips_r4k.c |2 +- hw/pc.c|2 +- 9 files changed, 12 insertions(+), 12 deletions(-) diff --git a/hw/alpha_dp264.c b/hw/alpha_dp264.c index 4c0efd3..ea0fd95 100644 --- a/hw/alpha_dp264.c +++ b/hw/alpha_dp264.c @@ -73,7 +73,7 @@ static void clipper_init(ram_addr_t ram_size, clipper_pci_map_irq); rtc_init(isa_bus, 1980, rtc_irq); -pit_init(isa_bus, 0x40, 0); +pit_init(isa_bus, 0x40, 0, NULL); isa_create_simple(isa_bus, i8042); /* VGA setup. Don't bother loading the bios. */ diff --git a/hw/i82378.c b/hw/i82378.c index eb02963..ce64767 100644 --- a/hw/i82378.c +++ b/hw/i82378.c @@ -192,7 +192,7 @@ static void i82378_init(DeviceState *dev, I82378State *s) isa_bus_irqs(isabus, s-i8259); /* 1 82C54 (pit) */ -pit = pit_init(isabus, 0x40, 0); +pit = pit_init(isabus, 0x40, 0, NULL); /* speaker */ pcspk_init(pit); diff --git a/hw/i8254.c b/hw/i8254.c index 17ceba7..7ce27bb 100644 --- a/hw/i8254.c +++ b/hw/i8254.c @@ -57,7 +57,6 @@ typedef struct PITChannelState { typedef struct PITState { ISADevice dev; MemoryRegion ioports; -uint32_t irq; uint32_t iobase; PITChannelState channels[3]; } PITState; @@ -532,7 +531,7 @@ static int pit_initfn(ISADevice *dev) s = pit-channels[0]; /* the timer 0 is connected to an IRQ */ s-irq_timer = qemu_new_timer_ns(vm_clock, pit_irq_timer, s); -s-irq = isa_get_irq(dev, pit-irq); +qdev_init_gpio_out(dev-qdev, s-irq, 1); memory_region_init_io(pit-ioports, pit_ioport_ops, pit, pit, 4); isa_register_ioport(dev, pit-ioports, pit-iobase); @@ -543,7 +542,6 @@ static int pit_initfn(ISADevice *dev) } static Property pit_properties[] = { -DEFINE_PROP_UINT32(irq, PITState, irq, -1), DEFINE_PROP_HEX32(iobase, PITState, iobase, -1), DEFINE_PROP_END_OF_LIST(), }; diff --git a/hw/i8254.h b/hw/i8254.h index cd3111c..fc64a63 100644 --- a/hw/i8254.h +++ b/hw/i8254.h @@ -30,14 +30,16 @@ #define PIT_FREQ 1193182 -static inline ISADevice *pit_init(ISABus *bus, int base, int irq) +static inline ISADevice *pit_init(ISABus *bus, int base, int isa_irq, + qemu_irq alt_irq) { ISADevice *dev; dev = isa_create(bus, isa-pit); qdev_prop_set_uint32(dev-qdev, iobase, base); -qdev_prop_set_uint32(dev-qdev, irq, irq); qdev_init_nofail(dev-qdev); +qdev_connect_gpio_out(dev-qdev, 0, + isa_irq = 0 ? isa_get_irq(dev, isa_irq) : alt_irq); return dev; } diff --git a/hw/mips_fulong2e.c b/hw/mips_fulong2e.c index ead72ae..e3ba9dd 100644 --- a/hw/mips_fulong2e.c +++ b/hw/mips_fulong2e.c @@ -364,7 +364,7 @@ static void mips_fulong2e_init(ram_addr_t ram_size, const char *boot_device, smbus_eeprom_init(smbus, 1, eeprom_spd, sizeof(eeprom_spd)); /* init other devices */ -pit = pit_init(isa_bus, 0x40, 0); +pit = pit_init(isa_bus, 0x40, 0, NULL); cpu_exit_irq = qemu_allocate_irqs(cpu_request_exit, NULL, 1); DMA_init(0, cpu_exit_irq); diff --git a/hw/mips_jazz.c b/hw/mips_jazz.c index 61dee4d..b61b218 100644 --- a/hw/mips_jazz.c +++ b/hw/mips_jazz.c @@ -192,7 +192,7 @@ static void mips_jazz_init(MemoryRegion *address_space, isa_bus_irqs(isa_bus, i8259); cpu_exit_irq = qemu_allocate_irqs(cpu_request_exit, NULL, 1); DMA_init(0, cpu_exit_irq); -pit = pit_init(isa_bus, 0x40, 0); +pit = pit_init(isa_bus, 0x40, 0, NULL); pcspk_init(pit); /* ISA IO space at 0x9000 */ diff --git a/hw/mips_malta.c b/hw/mips_malta.c index c868d90..feae684 100644 --- a/hw/mips_malta.c +++ b/hw/mips_malta.c @@ -970,7 +970,7 @@ void mips_malta_init (ram_addr_t ram_size, isa_get_irq(NULL, 9), NULL, NULL, 0); /* TODO: Populate SPD eeprom data. */ smbus_eeprom_init(smbus, 8, NULL, 0); -pit = pit_init(isa_bus, 0x40, 0); +pit = pit_init(isa_bus, 0x40, 0, NULL); cpu_exit_irq = qemu_allocate_irqs(cpu_request_exit, NULL, 1); DMA_init(0, cpu_exit_irq); diff --git a/hw/mips_r4k.c b/hw/mips_r4k.c index 1b3ec2d..83401f0 100644 --- a/hw/mips_r4k.c +++ b/hw/mips_r4k.c @@ -270,7 +270,7 @@ void mips_r4k_init (ram_addr_t ram_size, isa_mmio_init(0x1400, 0x0001); isa_mem_base = 0x1000; -pit = pit_init(isa_bus,
[Qemu-devel] [PATCH v4 7/7] i8254: Factor out pit_get_channel_info
Instead of providing 4 individual query functions for mode, gate, output and initial counter state, introduce a service that queries all information at once. This comes with tiny additional costs for pcspk_callback but with a much cleaner interface. Also, it will simplify the implementation of the KVM in-kernel PIT model. Signed-off-by: Jan Kiszka jan.kis...@siemens.com --- hw/i8254.c | 35 ++- hw/i8254.h | 12 hw/pcspk.c | 16 +++- 3 files changed, 29 insertions(+), 34 deletions(-) diff --git a/hw/i8254.c b/hw/i8254.c index ac5432c..be39c55 100644 --- a/hw/i8254.c +++ b/hw/i8254.c @@ -90,7 +90,7 @@ static int pit_get_count(PITChannelState *s) } /* get pit output bit */ -static int pit_get_out1(PITChannelState *s, int64_t current_time) +static int pit_get_out(PITChannelState *s, int64_t current_time) { uint64_t d; int out; @@ -122,13 +122,6 @@ static int pit_get_out1(PITChannelState *s, int64_t current_time) return out; } -int pit_get_out(ISADevice *dev, int channel, int64_t current_time) -{ -PITState *pit = DO_UPCAST(PITState, dev, dev); -PITChannelState *s = pit-channels[channel]; -return pit_get_out1(s, current_time); -} - /* return -1 if no transition will occur. */ static int64_t pit_get_next_transition_time(PITChannelState *s, int64_t current_time) @@ -215,25 +208,15 @@ void pit_set_gate(ISADevice *dev, int channel, int val) s-gate = val; } -int pit_get_gate(ISADevice *dev, int channel) -{ -PITState *pit = DO_UPCAST(PITState, dev, dev); -PITChannelState *s = pit-channels[channel]; -return s-gate; -} - -int pit_get_initial_count(ISADevice *dev, int channel) +void pit_get_channel_info(ISADevice *dev, int channel, PITChannelInfo *info) { PITState *pit = DO_UPCAST(PITState, dev, dev); PITChannelState *s = pit-channels[channel]; -return s-count; -} -int pit_get_mode(ISADevice *dev, int channel) -{ -PITState *pit = DO_UPCAST(PITState, dev, dev); -PITChannelState *s = pit-channels[channel]; -return s-mode; +info-gate = s-gate; +info-mode = s-mode; +info-initial_count = s-count; +info-out = pit_get_out(s, qemu_get_clock_ns(vm_clock)); } static inline void pit_load_count(PITChannelState *s, int val) @@ -274,7 +257,9 @@ static void pit_ioport_write(void *opaque, uint32_t addr, uint32_t val) if (!(val 0x10) !s-status_latched) { /* status latch */ /* XXX: add BCD and null count */ -s-status = (pit_get_out1(s, qemu_get_clock_ns(vm_clock)) 7) | +s-status = +(pit_get_out(s, + qemu_get_clock_ns(vm_clock)) 7) | (s-rw_mode 4) | (s-mode 1) | s-bcd; @@ -381,7 +366,7 @@ static void pit_irq_timer_update(PITChannelState *s, int64_t current_time) return; } expire_time = pit_get_next_transition_time(s, current_time); -irq_level = pit_get_out1(s, current_time); +irq_level = pit_get_out(s, current_time); qemu_set_irq(s-irq, irq_level); #ifdef DEBUG_PIT printf(irq_level=%d next_delay=%f\n, diff --git a/hw/i8254.h b/hw/i8254.h index 8ad8e07..a1d2e98 100644 --- a/hw/i8254.h +++ b/hw/i8254.h @@ -30,6 +30,13 @@ #define PIT_FREQ 1193182 +typedef struct PITChannelInfo { +int gate; +int mode; +int initial_count; +int out; +} PITChannelInfo; + static inline ISADevice *pit_init(ISABus *bus, int base, int isa_irq, qemu_irq alt_irq) { @@ -45,9 +52,6 @@ static inline ISADevice *pit_init(ISABus *bus, int base, int isa_irq, } void pit_set_gate(ISADevice *dev, int channel, int val); -int pit_get_gate(ISADevice *dev, int channel); -int pit_get_initial_count(ISADevice *dev, int channel); -int pit_get_mode(ISADevice *dev, int channel); -int pit_get_out(ISADevice *dev, int channel, int64_t current_time); +void pit_get_channel_info(ISADevice *dev, int channel, PITChannelInfo *info); #endif /* !HW_I8254_H */ diff --git a/hw/pcspk.c b/hw/pcspk.c index d406c68..caa21a8 100644 --- a/hw/pcspk.c +++ b/hw/pcspk.c @@ -75,12 +75,16 @@ static inline void generate_samples(PCSpkState *s) static void pcspk_callback(void *opaque, int free) { PCSpkState *s = opaque; +PITChannelInfo ch; unsigned int n; -if (pit_get_mode(s-pit, 2) != 3) +pit_get_channel_info(s-pit, 2, ch); + +if (ch.mode != 3) { return; +} -n = pit_get_initial_count(s-pit, 2); +n = ch.initial_count; /* avoid frequencies that are not reproducible with sample rate */ if (n PCSPK_MIN_COUNT) n = 0; @@ -121,12 +125,14 @@ static uint64_t pcspk_io_read(void *opaque, target_phys_addr_t addr, unsigned size)
[Qemu-devel] [PATCH 16/22] qdev: nuke qdev_init_chardev()
I'm sure the intentions were good here, but there's no reason this should be in qdev. Move it to qemu-char where it belongs. Signed-off-by: Anthony Liguori aligu...@us.ibm.com --- hw/etraxfs_ser.c |2 +- hw/lm32_juart.c |2 +- hw/lm32_uart.c |2 +- hw/milkymist-uart.c |2 +- hw/pl011.c |2 +- hw/qdev.c|9 - hw/qdev.h|2 -- hw/xilinx_uartlite.c |2 +- qemu-char.c | 10 ++ qemu-char.h |2 ++ 10 files changed, 18 insertions(+), 17 deletions(-) diff --git a/hw/etraxfs_ser.c b/hw/etraxfs_ser.c index b8acd43..567cb8c 100644 --- a/hw/etraxfs_ser.c +++ b/hw/etraxfs_ser.c @@ -216,7 +216,7 @@ static int etraxfs_ser_init(SysBusDevice *dev) memory_region_init_io(s-mmio, ser_ops, s, etraxfs-serial, R_MAX * 4); sysbus_init_mmio(dev, s-mmio); -s-chr = qdev_init_chardev(dev-qdev); +s-chr = qemu_char_get_next_serial(); if (s-chr) qemu_chr_add_handlers(s-chr, serial_can_receive, serial_receive, diff --git a/hw/lm32_juart.c b/hw/lm32_juart.c index 023c644..38dd282 100644 --- a/hw/lm32_juart.c +++ b/hw/lm32_juart.c @@ -114,7 +114,7 @@ static int lm32_juart_init(SysBusDevice *dev) { LM32JuartState *s = FROM_SYSBUS(typeof(*s), dev); -s-chr = qdev_init_chardev(dev-qdev); +s-chr = qemu_char_get_next_serial(); if (s-chr) { qemu_chr_add_handlers(s-chr, juart_can_rx, juart_rx, juart_event, s); } diff --git a/hw/lm32_uart.c b/hw/lm32_uart.c index fc70490..630ccb7 100644 --- a/hw/lm32_uart.c +++ b/hw/lm32_uart.c @@ -252,7 +252,7 @@ static int lm32_uart_init(SysBusDevice *dev) memory_region_init_io(s-iomem, uart_ops, s, uart, R_MAX * 4); sysbus_init_mmio(dev, s-iomem); -s-chr = qdev_init_chardev(dev-qdev); +s-chr = qemu_char_get_next_serial(); if (s-chr) { qemu_chr_add_handlers(s-chr, uart_can_rx, uart_rx, uart_event, s); } diff --git a/hw/milkymist-uart.c b/hw/milkymist-uart.c index 2999b79..f9a229c 100644 --- a/hw/milkymist-uart.c +++ b/hw/milkymist-uart.c @@ -199,7 +199,7 @@ static int milkymist_uart_init(SysBusDevice *dev) milkymist-uart, R_MAX * 4); sysbus_init_mmio(dev, s-regs_region); -s-chr = qdev_init_chardev(dev-qdev); +s-chr = qemu_char_get_next_serial(); if (s-chr) { qemu_chr_add_handlers(s-chr, uart_can_rx, uart_rx, uart_event, s); } diff --git a/hw/pl011.c b/hw/pl011.c index 8db2248..752cbf9 100644 --- a/hw/pl011.c +++ b/hw/pl011.c @@ -264,7 +264,7 @@ static int pl011_init(SysBusDevice *dev, const unsigned char *id) sysbus_init_mmio(dev, s-iomem); sysbus_init_irq(dev, s-irq); s-id = id; -s-chr = qdev_init_chardev(dev-qdev); +s-chr = qemu_char_get_next_serial(); s-read_trigger = 1; s-ifl = 0x12; diff --git a/hw/qdev.c b/hw/qdev.c index e82165d..0692a21 100644 --- a/hw/qdev.c +++ b/hw/qdev.c @@ -336,15 +336,6 @@ bool qdev_machine_modified(void) return qdev_hot_added || qdev_hot_removed; } -/* Get a character (serial) device interface. */ -CharDriverState *qdev_init_chardev(DeviceState *dev) -{ -static int next_serial; - -/* FIXME: This function needs to go away: use chardev properties! */ -return serial_hds[next_serial++]; -} - BusState *qdev_get_parent_bus(DeviceState *dev) { return dev-parent_bus; diff --git a/hw/qdev.h b/hw/qdev.h index 9535e57..d1f0e19 100644 --- a/hw/qdev.h +++ b/hw/qdev.h @@ -234,8 +234,6 @@ BusState *qdev_get_child_bus(DeviceState *dev, const char *name); void qdev_init_gpio_in(DeviceState *dev, qemu_irq_handler handler, int n); void qdev_init_gpio_out(DeviceState *dev, qemu_irq *pins, int n); -CharDriverState *qdev_init_chardev(DeviceState *dev); - BusState *qdev_get_parent_bus(DeviceState *dev); /*** BUS API. ***/ diff --git a/hw/xilinx_uartlite.c b/hw/xilinx_uartlite.c index 1491bba..1c2b908 100644 --- a/hw/xilinx_uartlite.c +++ b/hw/xilinx_uartlite.c @@ -205,7 +205,7 @@ static int xilinx_uartlite_init(SysBusDevice *dev) memory_region_init_io(s-mmio, uart_ops, s, xilinx-uartlite, R_MAX * 4); sysbus_init_mmio(dev, s-mmio); -s-chr = qdev_init_chardev(dev-qdev); +s-chr = qemu_char_get_next_serial(); if (s-chr) qemu_chr_add_handlers(s-chr, uart_can_rx, uart_rx, uart_event, s); return 0; diff --git a/qemu-char.c b/qemu-char.c index 27abcb9..b1d80dd 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -2903,3 +2903,13 @@ CharDriverState *qemu_chr_find(const char *name) } return NULL; } + +/* Get a character (serial) device interface. */ +CharDriverState *qemu_char_get_next_serial(void) +{ +static int next_serial; + +/* FIXME: This function needs to go away: use chardev properties! */ +return serial_hds[next_serial++]; +} + diff --git a/qemu-char.h b/qemu-char.h index 8ca1e2d..486644b 100644 --- a/qemu-char.h +++ b/qemu-char.h @@ -248,4 +248,6 @@ void
[Qemu-devel] [PATCH 05/22] qdev: allow classes to overload qdev functions
This allows us to drop per-Device registration functions by allowing the class_init functions to overload qdev methods. Signed-off-by: Anthony Liguori aligu...@us.ibm.com --- hw/qdev.c | 53 + 1 files changed, 33 insertions(+), 20 deletions(-) diff --git a/hw/qdev.c b/hw/qdev.c index b273cd2..c9f890c 100644 --- a/hw/qdev.c +++ b/hw/qdev.c @@ -50,21 +50,39 @@ static void qdev_subclass_init(ObjectClass *klass, void *data) DeviceClass *dc = DEVICE_CLASS(klass); DeviceInfo *info = data; -dc-fw_name = info-fw_name; -dc-alias = info-alias; -dc-desc = info-desc; -dc-props = info-props; -dc-no_user = info-no_user; - -dc-reset = info-reset; - -dc-vmsd = info-vmsd; - -dc-init = info-init; -dc-unplug = info-unplug; -dc-exit = info-exit; -dc-bus_info = info-bus_info; - +if (info-fw_name) { +dc-fw_name = info-fw_name; +} +if (info-alias) { +dc-alias = info-alias; +} +if (info-desc) { +dc-desc = info-desc; +} +if (info-props) { +dc-props = info-props; +} +if (info-no_user) { +dc-no_user = info-no_user; +} +if (info-reset) { +dc-reset = info-reset; +} +if (info-vmsd) { +dc-vmsd = info-vmsd; +} +if (info-init) { +dc-init = info-init; +} +if (info-unplug) { +dc-unplug = info-unplug; +} +if (info-exit) { +dc-exit = info-exit; +} +if (info-bus_info) { +dc-bus_info = info-bus_info; +} if (info-class_init) { info-class_init(klass, data); } @@ -131,8 +149,6 @@ static DeviceInfo *qdev_find_info(BusInfo *bus_info, const char *name) /* first check device names */ for (info = device_info_list; info != NULL; info = info-next) { -if (bus_info info-bus_info != bus_info) -continue; if (strcmp(info-name, name) != 0) continue; return info; @@ -140,8 +156,6 @@ static DeviceInfo *qdev_find_info(BusInfo *bus_info, const char *name) /* failing that check the aliases */ for (info = device_info_list; info != NULL; info = info-next) { -if (bus_info info-bus_info != bus_info) -continue; if (!info-alias) continue; if (strcmp(info-alias, name) != 0) @@ -164,7 +178,6 @@ static DeviceState *qdev_create_from_info(BusState *bus, DeviceInfo *info) DeviceState *dev; Property *prop; -assert(bus-info == info-bus_info); dev = DEVICE(object_new(info-name)); dev-parent_bus = bus; qdev_prop_set_defaults(dev, qdev_get_props(dev)); -- 1.7.4.1
[Qemu-devel] [PATCH 04/22] qdev: remove info from class
Now DeviceInfo is no longer used after object construction. All of the relevant members have been moved to DeviceClass. Signed-off-by: Anthony Liguori aligu...@us.ibm.com --- hw/pci.c |4 ++- hw/qdev.c | 94 hw/qdev.h | 26 +--- 3 files changed, 80 insertions(+), 44 deletions(-) diff --git a/hw/pci.c b/hw/pci.c index 235ea00..43dc1fb 100644 --- a/hw/pci.c +++ b/hw/pci.c @@ -1467,7 +1467,9 @@ static int pci_qdev_init(DeviceState *qdev, DeviceInfo *base) } bus = FROM_QBUS(PCIBus, qdev_get_parent_bus(qdev)); -pci_dev = do_pci_register_device(pci_dev, bus, base-name, pci_dev-devfn); +pci_dev = do_pci_register_device(pci_dev, bus, + object_get_typename(OBJECT(qdev)), + pci_dev-devfn); if (pci_dev == NULL) return -1; if (qdev-hotplugged pc-no_hotplug) { diff --git a/hw/qdev.c b/hw/qdev.c index 18c5876..b273cd2 100644 --- a/hw/qdev.c +++ b/hw/qdev.c @@ -48,46 +48,54 @@ static BusState *qbus_find(const char *path); static void qdev_subclass_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); +DeviceInfo *info = data; -dc-info = data; -dc-reset = dc-info-reset; +dc-fw_name = info-fw_name; +dc-alias = info-alias; +dc-desc = info-desc; +dc-props = info-props; +dc-no_user = info-no_user; -/* Poison to try to detect future uses */ -dc-info-reset = NULL; +dc-reset = info-reset; -if (dc-info-class_init) { -dc-info-class_init(klass, data); -} -} +dc-vmsd = info-vmsd; -static DeviceInfo *qdev_get_info(DeviceState *dev) -{ -return DEVICE_GET_CLASS(dev)-info; +dc-init = info-init; +dc-unplug = info-unplug; +dc-exit = info-exit; +dc-bus_info = info-bus_info; + +if (info-class_init) { +info-class_init(klass, data); +} } const VMStateDescription *qdev_get_vmsd(DeviceState *dev) { -return qdev_get_info(dev)-vmsd; +DeviceClass *dc = DEVICE_GET_CLASS(dev); +return dc-vmsd; } BusInfo *qdev_get_bus_info(DeviceState *dev) { -return qdev_get_info(dev)-bus_info; +DeviceClass *dc = DEVICE_GET_CLASS(dev); +return dc-bus_info; } Property *qdev_get_props(DeviceState *dev) { -return qdev_get_info(dev)-props; +DeviceClass *dc = DEVICE_GET_CLASS(dev); +return dc-props; } const char *qdev_fw_name(DeviceState *dev) { -DeviceInfo *info = qdev_get_info(dev); +DeviceClass *dc = DEVICE_GET_CLASS(dev); -if (info-fw_name) { -return info-fw_name; -} else if (info-alias) { -return info-alias; +if (dc-fw_name) { +return dc-fw_name; +} else if (dc-alias) { +return dc-alias; } return object_get_typename(OBJECT(dev)); @@ -159,7 +167,7 @@ static DeviceState *qdev_create_from_info(BusState *bus, DeviceInfo *info) assert(bus-info == info-bus_info); dev = DEVICE(object_new(info-name)); dev-parent_bus = bus; -qdev_prop_set_defaults(dev, qdev_get_info(dev)-props); +qdev_prop_set_defaults(dev, qdev_get_props(dev)); qdev_prop_set_defaults(dev, dev-parent_bus-info-props); qdev_prop_set_globals(dev); QTAILQ_INSERT_HEAD(bus-children, dev, sibling); @@ -172,12 +180,12 @@ static DeviceState *qdev_create_from_info(BusState *bus, DeviceInfo *info) QTAILQ_INIT(dev-properties); dev-state = DEV_STATE_CREATED; -for (prop = qdev_get_info(dev)-props; prop prop-name; prop++) { +for (prop = qdev_get_props(dev); prop prop-name; prop++) { qdev_property_add_legacy(dev, prop, NULL); qdev_property_add_static(dev, prop, NULL); } -for (prop = qdev_get_info(dev)-bus_info-props; prop prop-name; prop++) { +for (prop = qdev_get_bus_info(dev)-props; prop prop-name; prop++) { qdev_property_add_legacy(dev, prop, NULL); qdev_property_add_static(dev, prop, NULL); } @@ -407,16 +415,19 @@ DeviceState *qdev_device_add(QemuOpts *opts) Return 0 on success. */ int qdev_init(DeviceState *dev) { +DeviceClass *dc = DEVICE_GET_CLASS(dev); int rc; assert(dev-state == DEV_STATE_CREATED); -rc = qdev_get_info(dev)-init(dev, qdev_get_info(dev)); + +/* FIXME hopefully this doesn't break anything */ +rc = dc-init(dev, NULL); if (rc 0) { qdev_free(dev); return rc; } -if (qdev_get_info(dev)-vmsd) { -vmstate_register_with_alias_id(dev, -1, qdev_get_info(dev)-vmsd, dev, +if (qdev_get_vmsd(dev)) { +vmstate_register_with_alias_id(dev, -1, qdev_get_vmsd(dev), dev, dev-instance_id_alias, dev-alias_required_for_version); } @@ -437,15 +448,17 @@ void qdev_set_legacy_instance_id(DeviceState *dev, int alias_id, int qdev_unplug(DeviceState *dev) { +DeviceClass *dc =
Re: [Qemu-devel] [PATCH 0/3] jazz-led: qdev conversion
On 01/23/2012 04:34 AM, Hervé Poussineau wrote: Following patches update jazz-led emulation to current Qemu standards: - use trace framework to report events - convert to qdev Hervé Poussineau (3): jazz-led: use trace framework jazz-led: convert to qdev jazz-led: compile it only twice This is going to need to be rebased. I'd suggest waiting until next week when the next qom round goes in. But if you resend before Friday, I'll make sure to take it in before I push in the next round of qom. Regards, Anthony Liguori Makefile.objs|1 + Makefile.target |1 - default-configs/mips-softmmu.mak |1 + default-configs/mips64-softmmu.mak |1 + default-configs/mips64el-softmmu.mak |1 + default-configs/mipsel-softmmu.mak |1 + hw/jazz_led.c| 171 ++ hw/mips.h|3 - hw/mips_jazz.c |2 +- trace-events |4 + 10 files changed, 79 insertions(+), 107 deletions(-)
[Qemu-devel] [PATCH v4 5/7] i8254: Rework fix interaction with HPET in legacy mode
When the HPET enters legacy mode, the IRQ output of the PIT is suppressed and replaced by the HPET timer 0. But the current code to emulate this was broken in many ways. It reset the PIT state after re-enabling, it worked against a stale static PIT structure, and it did not properly saved/restored the IRQ output mask in the PIT vmstate. This patch solves the PIT IRQ control in a different way. On x86, it both redirects the PIT IRQ to the HPET, just like the RTC. But it also keeps the control line from the HPET to the PIT. This allows to disable the PIT QEMU timer when it is not needed. The PIT's view on the control line state is now saved in the same format that qemu-kvm is already using. Note that, in contrast to the suppressed RTC IRQ line, we do not need to save/restore the PIT line state in the HPET. As we trigger a PIT IRQ update via the control line, the line state is reconstructed on mode switch. Signed-off-by: Jan Kiszka jan.kis...@siemens.com --- hw/hpet.c | 38 -- hw/hpet_emul.h |3 +++ hw/i8254.c | 46 ++ hw/i8254.h |3 --- hw/pc.c| 15 --- 5 files changed, 57 insertions(+), 48 deletions(-) diff --git a/hw/hpet.c b/hw/hpet.c index 884043c..4636d50 100644 --- a/hw/hpet.c +++ b/hw/hpet.c @@ -65,6 +65,7 @@ typedef struct HPETState { qemu_irq irqs[HPET_NUM_IRQ_ROUTES]; uint32_t flags; uint8_t rtc_irq_level; +qemu_irq pit_enabled; uint8_t num_timers; HPETTimer timer[HPET_MAX_TIMERS]; @@ -573,12 +574,15 @@ static void hpet_ram_write(void *opaque, target_phys_addr_t addr, hpet_del_timer(s-timer[i]); } } -/* i8254 and RTC are disabled when HPET is in legacy mode */ +/* i8254 and RTC output pins are disabled + * when HPET is in legacy mode */ if (activating_bit(old_val, new_val, HPET_CFG_LEGACY)) { -hpet_pit_disable(); +qemu_set_irq(s-pit_enabled, 0); +qemu_irq_lower(s-irqs[0]); qemu_irq_lower(s-irqs[RTC_ISA_IRQ]); } else if (deactivating_bit(old_val, new_val, HPET_CFG_LEGACY)) { -hpet_pit_enable(); +qemu_irq_lower(s-irqs[0]); +qemu_set_irq(s-pit_enabled, 1); qemu_set_irq(s-irqs[RTC_ISA_IRQ], s-rtc_irq_level); } break; @@ -632,7 +636,6 @@ static void hpet_reset(DeviceState *d) { HPETState *s = FROM_SYSBUS(HPETState, sysbus_from_qdev(d)); int i; -static int count = 0; for (i = 0; i s-num_timers; i++) { HPETTimer *timer = s-timer[i]; @@ -649,32 +652,30 @@ static void hpet_reset(DeviceState *d) timer-wrap_flag = 0; } +qemu_set_irq(s-pit_enabled, 1); s-hpet_counter = 0ULL; s-hpet_offset = 0ULL; s-config = 0ULL; -if (count 0) { -/* we don't enable pit when hpet_reset is first called (by hpet_init) - * because hpet is taking over for pit here. On subsequent invocations, - * hpet_reset is called due to system reset. At this point control must - * be returned to pit until SW reenables hpet. - */ -hpet_pit_enable(); -} hpet_cfg.hpet[s-hpet_id].event_timer_block_id = (uint32_t)s-capability; hpet_cfg.hpet[s-hpet_id].address = sysbus_from_qdev(d)-mmio[0].addr; -count = 1; /* to document that the RTC lowers its output on reset as well */ s-rtc_irq_level = 0; } -static void hpet_handle_rtc_irq(void *opaque, int n, int level) +static void hpet_handle_legacy_irq(void *opaque, int n, int level) { HPETState *s = FROM_SYSBUS(HPETState, opaque); -s-rtc_irq_level = level; -if (!hpet_in_legacy_mode(s)) { -qemu_set_irq(s-irqs[RTC_ISA_IRQ], level); +if (n == HPET_LEGACY_PIT_INT) { +if (!hpet_in_legacy_mode(s)) { +qemu_set_irq(s-irqs[0], level); +} +} else { +s-rtc_irq_level = level; +if (!hpet_in_legacy_mode(s)) { +qemu_set_irq(s-irqs[RTC_ISA_IRQ], level); +} } } @@ -717,7 +718,8 @@ static int hpet_init(SysBusDevice *dev) s-capability |= (s-num_timers - 1) HPET_ID_NUM_TIM_SHIFT; s-capability |= ((HPET_CLK_PERIOD) 32); -qdev_init_gpio_in(dev-qdev, hpet_handle_rtc_irq, 1); +qdev_init_gpio_in(dev-qdev, hpet_handle_legacy_irq, 2); +qdev_init_gpio_out(dev-qdev, s-pit_enabled, 1); /* HPET Area */ memory_region_init_io(s-iomem, hpet_ram_ops, s, hpet, 0x400); diff --git a/hw/hpet_emul.h b/hw/hpet_emul.h index 6128702..757f79f 100644 --- a/hw/hpet_emul.h +++ b/hw/hpet_emul.h @@ -22,6 +22,9 @@ #define HPET_NUM_IRQ_ROUTES 32 +#define HPET_LEGACY_PIT_INT 0 +#define HPET_LEGACY_RTC_INT 1 + #define HPET_CFG_ENABLE 0x001 #define HPET_CFG_LEGACY 0x002 diff --git a/hw/i8254.c b/hw/i8254.c index
[Qemu-devel] [PATCH 06/22] qdev: refactor device creation to allow bus_info to be set only in class
As we use class_init to set class members, DeviceInfo no longer holds this information. Signed-off-by: Anthony Liguori aligu...@us.ibm.com --- hw/qdev.c | 42 +++--- 1 files changed, 19 insertions(+), 23 deletions(-) diff --git a/hw/qdev.c b/hw/qdev.c index c9f890c..bba84e2 100644 --- a/hw/qdev.c +++ b/hw/qdev.c @@ -119,21 +119,29 @@ const char *qdev_fw_name(DeviceState *dev) return object_get_typename(OBJECT(dev)); } -void qdev_register_subclass(DeviceInfo *info, const char *parent) +static void qdev_do_register_subclass(DeviceInfo *info, const char *parent, + const char *name) { TypeInfo type_info = {}; assert(info-size = sizeof(DeviceState)); assert(!info-next); -type_info.name = info-name; +type_info.name = name; type_info.parent = parent; type_info.instance_size = info-size; type_info.class_init = qdev_subclass_init; type_info.class_data = info; type_register_static(type_info); +} +void qdev_register_subclass(DeviceInfo *info, const char *parent) +{ +qdev_do_register_subclass(info, parent, info-name); +if (info-alias) { +qdev_do_register_subclass(info, parent, info-alias); +} info-next = device_info_list; device_info_list = info; } @@ -173,12 +181,12 @@ bool qdev_exists(const char *name) static void qdev_property_add_legacy(DeviceState *dev, Property *prop, Error **errp); -static DeviceState *qdev_create_from_info(BusState *bus, DeviceInfo *info) +static DeviceState *qdev_create_from_info(BusState *bus, const char *typename) { DeviceState *dev; Property *prop; -dev = DEVICE(object_new(info-name)); +dev = DEVICE(object_new(typename)); dev-parent_bus = bus; qdev_prop_set_defaults(dev, qdev_get_props(dev)); qdev_prop_set_defaults(dev, dev-parent_bus-info-props); @@ -230,18 +238,11 @@ DeviceState *qdev_create(BusState *bus, const char *name) DeviceState *qdev_try_create(BusState *bus, const char *name) { -DeviceInfo *info; - if (!bus) { bus = sysbus_get_default(); } -info = qdev_find_info(bus-info, name); -if (!info) { -return NULL; -} - -return qdev_create_from_info(bus, info); +return qdev_create_from_info(bus, name); } static void qdev_print_devinfo(DeviceInfo *info) @@ -352,8 +353,8 @@ static DeviceState *qdev_get_peripheral_anon(void) DeviceState *qdev_device_add(QemuOpts *opts) { +DeviceClass *k; const char *driver, *path, *id; -DeviceInfo *info; DeviceState *qdev; BusState *bus; @@ -364,12 +365,7 @@ DeviceState *qdev_device_add(QemuOpts *opts) } /* find driver */ -info = qdev_find_info(NULL, driver); -if (!info || info-no_user) { -qerror_report(QERR_INVALID_PARAMETER_VALUE, driver, a driver name); -error_printf_unless_qmp(Try with argument '?' for a list.\n); -return NULL; -} +k = DEVICE_CLASS(object_class_by_name(driver)); /* find bus */ path = qemu_opt_get(opts, bus); @@ -378,16 +374,16 @@ DeviceState *qdev_device_add(QemuOpts *opts) if (!bus) { return NULL; } -if (bus-info != info-bus_info) { +if (bus-info != k-bus_info) { qerror_report(QERR_BAD_BUS_FOR_DEVICE, driver, bus-info-name); return NULL; } } else { -bus = qbus_find_recursive(main_system_bus, NULL, info-bus_info); +bus = qbus_find_recursive(main_system_bus, NULL, k-bus_info); if (!bus) { qerror_report(QERR_NO_BUS_FOR_DEVICE, - info-name, info-bus_info-name); + driver, k-bus_info-name); return NULL; } } @@ -397,7 +393,7 @@ DeviceState *qdev_device_add(QemuOpts *opts) } /* create device, set properties */ -qdev = qdev_create_from_info(bus, info); +qdev = qdev_create_from_info(bus, driver); id = qemu_opts_id(opts); if (id) { qdev-id = id; -- 1.7.4.1
[Qemu-devel] [PATCH 14/22] qdev: refactor away qdev_create_from_info
Note that the FIXME gets fixed in series 4/4. We need to convert BusState to QOM before we can make parent_bus a link. Signed-off-by: Anthony Liguori aligu...@us.ibm.com --- hw/qdev.c | 35 ++- hw/qdev.h |3 +++ 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/hw/qdev.c b/hw/qdev.c index 9933ea2..e2263cb 100644 --- a/hw/qdev.c +++ b/hw/qdev.c @@ -124,30 +124,22 @@ bool qdev_exists(const char *name) static void qdev_property_add_legacy(DeviceState *dev, Property *prop, Error **errp); -static DeviceState *qdev_create_from_info(BusState *bus, const char *typename) +void qdev_set_parent_bus(DeviceState *dev, BusState *bus) { -DeviceState *dev; Property *prop; -dev = DEVICE(object_new(typename)); - -dev-parent_bus = bus; -qdev_prop_set_defaults(dev, dev-parent_bus-info-props); - if (qdev_hotplug) { assert(bus-allow_hotplug); } +dev-parent_bus = bus; QTAILQ_INSERT_HEAD(bus-children, dev, sibling); +qdev_prop_set_defaults(dev, dev-parent_bus-info-props); for (prop = qdev_get_bus_info(dev)-props; prop prop-name; prop++) { qdev_property_add_legacy(dev, prop, NULL); qdev_property_add_static(dev, prop, NULL); } - -qdev_prop_set_globals(dev); - -return dev; } /* Create a new device. This only initializes the device state structure @@ -172,11 +164,21 @@ DeviceState *qdev_create(BusState *bus, const char *name) DeviceState *qdev_try_create(BusState *bus, const char *name) { +DeviceState *dev; + +dev = DEVICE(object_new(name)); +if (!dev) { +return NULL; +} + if (!bus) { bus = sysbus_get_default(); } -return qdev_create_from_info(bus, name); +qdev_set_parent_bus(dev, bus); +qdev_prop_set_globals(dev); + +return dev; } static void qdev_print_devinfo(ObjectClass *klass, void *opaque) @@ -373,8 +375,15 @@ DeviceState *qdev_device_add(QemuOpts *opts) return NULL; } +if (!bus) { +bus = sysbus_get_default(); +} + /* create device, set properties */ -qdev = qdev_create_from_info(bus, driver); +qdev = DEVICE(object_new(driver)); +qdev_set_parent_bus(qdev, bus); +qdev_prop_set_globals(qdev); + id = qemu_opts_id(opts); if (id) { qdev-id = id; diff --git a/hw/qdev.h b/hw/qdev.h index 5aea4bf..e611804 100644 --- a/hw/qdev.h +++ b/hw/qdev.h @@ -636,4 +636,7 @@ BusInfo *qdev_get_bus_info(DeviceState *dev); Property *qdev_get_props(DeviceState *dev); +/* FIXME: make this a link */ +void qdev_set_parent_bus(DeviceState *dev, BusState *bus); + #endif -- 1.7.4.1
[Qemu-devel] [PATCH 13/22] qdev: split out common init to instance_init
This gets us closer to being able to object_new() a qdev type and have a functioning object verses having to call qdev_create(). Signed-off-by: Anthony Liguori aligu...@us.ibm.com --- hw/qdev.c | 41 - 1 files changed, 28 insertions(+), 13 deletions(-) diff --git a/hw/qdev.c b/hw/qdev.c index 5830bef..9933ea2 100644 --- a/hw/qdev.c +++ b/hw/qdev.c @@ -130,31 +130,22 @@ static DeviceState *qdev_create_from_info(BusState *bus, const char *typename) Property *prop; dev = DEVICE(object_new(typename)); + dev-parent_bus = bus; -qdev_prop_set_defaults(dev, qdev_get_props(dev)); qdev_prop_set_defaults(dev, dev-parent_bus-info-props); -qdev_prop_set_globals(dev); -QTAILQ_INSERT_HEAD(bus-children, dev, sibling); + if (qdev_hotplug) { assert(bus-allow_hotplug); -dev-hotplugged = 1; -qdev_hot_added = true; } -dev-instance_id_alias = -1; -QTAILQ_INIT(dev-properties); -dev-state = DEV_STATE_CREATED; -for (prop = qdev_get_props(dev); prop prop-name; prop++) { -qdev_property_add_legacy(dev, prop, NULL); -qdev_property_add_static(dev, prop, NULL); -} +QTAILQ_INSERT_HEAD(bus-children, dev, sibling); for (prop = qdev_get_bus_info(dev)-props; prop prop-name; prop++) { qdev_property_add_legacy(dev, prop, NULL); qdev_property_add_static(dev, prop, NULL); } -qdev_property_add_str(dev, type, qdev_get_type, NULL, NULL); +qdev_prop_set_globals(dev); return dev; } @@ -1647,6 +1638,29 @@ void qdev_machine_init(void) qdev_get_peripheral(); } +static void device_initfn(Object *obj) +{ +DeviceState *dev = DEVICE(obj); +Property *prop; + +if (qdev_hotplug) { +dev-hotplugged = 1; +qdev_hot_added = true; +} + +dev-instance_id_alias = -1; +QTAILQ_INIT(dev-properties); +dev-state = DEV_STATE_CREATED; + +qdev_prop_set_defaults(dev, qdev_get_props(dev)); +for (prop = qdev_get_props(dev); prop prop-name; prop++) { +qdev_property_add_legacy(dev, prop, NULL); +qdev_property_add_static(dev, prop, NULL); +} + +qdev_property_add_str(dev, type, qdev_get_type, NULL, NULL); +} + void device_reset(DeviceState *dev) { DeviceClass *klass = DEVICE_GET_CLASS(dev); @@ -1660,6 +1674,7 @@ static TypeInfo device_type_info = { .name = TYPE_DEVICE, .parent = TYPE_OBJECT, .instance_size = sizeof(DeviceState), +.instance_init = device_initfn, .abstract = true, .class_size = sizeof(DeviceClass), }; -- 1.7.4.1
Re: [Qemu-devel] [PATCH v2] arm: add device tree support
On 01.02.2012, at 18:38, Grant Likely wrote: On Tue, Jan 31, 2012 at 6:44 PM, Alexander Graf ag...@suse.de wrote: On 01.02.2012, at 02:35, Paul Brook wrote: We could also just change machine-init() and pass the dtb in there. In a QOM world these would become machine device properties anyways. machine-init(ram_size, boot_devices, kernel_filename, kernel_cmdline, initrd_filename, cpu_model); Essentially we shouldn't treat -dtb any different than -kernel or -initrd. It's also useful for more than ARM, namely embedded ppc systems. But I can easily post a follow-up patch for those. Changing machine-init means you have to touch every single board file, and clone the exact same code for every machine that uses arm_boot.c. All of which will be rewritten in the near future. Well, the dt file name would have to be passed into the generic arm_boot.c function, yes. But that's something that we need to do at one point in time either way, because machines will want to have default dtb file names. machine-init is a particularly suckiy interface to start with, we want to be using it less, not more. It's not like we're going support multiple machine instanced. At least not before machine-init is removed altogether. I do see your point on not extending legacy interfaces though and not bloating up the patch. In fact, I'm indifferent enough on the actual implementation atm, as long as the command line interface (or whatever the user sees) is reasonably sane. And it is IMHO. So if it makes everything easier, do it using a global, but keep in mind that this will need refactoring. That's certainly my expectation. My initial instinct was also to handle it the say way as initrd and kernel pointers, but as Paul pointed out it requires touching all init functions which is a dead end effort when -init() gets killed off. This patch is trivial to get the functionality into qemu without making it any more difficult for whoever creates the arm-kernel-loader device that Anthony is talking about. Yeah, I agree. Let's separate the QOM efforts from making things work for now. I don't want to have yet another if=ahci or hotplug magic where I'm waiting for a year for salvation that never came. Let's get the feature in and model the whole thing properly with all cases taken into account. This way we at least don't forget about dtbs when modeling the arm-kernel-loader device :) Alex
[Qemu-devel] [PATCH v4 1/7] i8254: Do not raise IRQ level on reset
Avoid changing the IRQ level to high on reset as it may trigger spurious events. Instead, open-code the effects of pit_load_count(0) in the reset handler. Signed-off-by: Jan Kiszka jan.kis...@siemens.com --- hw/i8254.c |8 +++- 1 files changed, 7 insertions(+), 1 deletions(-) diff --git a/hw/i8254.c b/hw/i8254.c index 522fed8..bfb303e 100644 --- a/hw/i8254.c +++ b/hw/i8254.c @@ -481,7 +481,13 @@ static void pit_reset(DeviceState *dev) s = pit-channels[i]; s-mode = 3; s-gate = (i != 2); -pit_load_count(s, 0); +s-count_load_time = qemu_get_clock_ns(vm_clock); +s-count = 0x1; +if (i == 0) { +s-next_transition_time = +pit_get_next_transition_time(s, s-count_load_time); +qemu_mod_timer(s-irq_timer, s-next_transition_time); +} } } -- 1.7.3.4
Re: [Qemu-devel] [PATCH 07/22] qom: allow object_class_foreach to take additional parameters to refine search
Am 01.02.2012 20:50, schrieb Anthony Liguori: Signed-off-by: Anthony Liguori aligu...@us.ibm.com Reviewed-by: Andreas Färber afaer...@suse.de Thanks, Andreas --- include/qemu/object.h |1 + qom/object.c | 18 -- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/include/qemu/object.h b/include/qemu/object.h index ba37850..adbcfb1 100644 --- a/include/qemu/object.h +++ b/include/qemu/object.h @@ -431,6 +431,7 @@ const char *object_class_get_name(ObjectClass *klass); ObjectClass *object_class_by_name(const char *typename); void object_class_foreach(void (*fn)(ObjectClass *klass, void *opaque), + const char *implements_type, bool include_abstract, void *opaque); #endif diff --git a/qom/object.c b/qom/object.c index a12895f..3dabb1a 100644 --- a/qom/object.c +++ b/qom/object.c @@ -467,6 +467,8 @@ ObjectClass *object_class_by_name(const char *typename) typedef struct OCFData { void (*fn)(ObjectClass *klass, void *opaque); +const char *implements_type; +bool include_abstract; void *opaque; } OCFData; @@ -475,16 +477,28 @@ static void object_class_foreach_tramp(gpointer key, gpointer value, { OCFData *data = opaque; TypeImpl *type = value; +ObjectClass *k; type_class_init(type); +k = type-class; -data-fn(value, type-class); +if (!data-include_abstract type-abstract) { +return; +} + +if (data-implements_type +!object_class_dynamic_cast(k, data-implements_type)) { +return; +} + +data-fn(k, data-opaque); } void object_class_foreach(void (*fn)(ObjectClass *klass, void *opaque), + const char *implements_type, bool include_abstract, void *opaque) { -OCFData data = { fn, opaque }; +OCFData data = { fn, implements_type, include_abstract, opaque }; g_hash_table_foreach(type_table_get(), object_class_foreach_tramp, data); } -- SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
[Qemu-devel] [PATCH 08/22] qdev: kill off DeviceInfo list
Teach the various bits of code that need to walk through available devices to do so via QOM. Signed-off-by: Anthony Liguori --- hw/qdev.c | 87 + hw/qdev.h |2 - hw/ssi.c |2 +- 3 files changed, 31 insertions(+), 60 deletions(-) diff --git a/hw/qdev.c b/hw/qdev.c index bba84e2..a30a1c2 100644 --- a/hw/qdev.c +++ b/hw/qdev.c @@ -38,8 +38,6 @@ static bool qdev_hot_removed = false; static BusState *main_system_bus; static void main_system_bus_create(void); -DeviceInfo *device_info_list; - static BusState *qbus_find_recursive(BusState *bus, const char *name, const BusInfo *info); static BusState *qbus_find(const char *path); @@ -125,7 +123,6 @@ static void qdev_do_register_subclass(DeviceInfo *info, const char *parent, TypeInfo type_info = {}; assert(info-size = sizeof(DeviceState)); -assert(!info-next); type_info.name = name; type_info.parent = parent; @@ -142,40 +139,11 @@ void qdev_register_subclass(DeviceInfo *info, const char *parent) if (info-alias) { qdev_do_register_subclass(info, parent, info-alias); } -info-next = device_info_list; -device_info_list = info; -} - -void qdev_register(DeviceInfo *info) -{ -qdev_register_subclass(info, TYPE_DEVICE); -} - -static DeviceInfo *qdev_find_info(BusInfo *bus_info, const char *name) -{ -DeviceInfo *info; - -/* first check device names */ -for (info = device_info_list; info != NULL; info = info-next) { -if (strcmp(info-name, name) != 0) -continue; -return info; -} - -/* failing that check the aliases */ -for (info = device_info_list; info != NULL; info = info-next) { -if (!info-alias) -continue; -if (strcmp(info-alias, name) != 0) -continue; -return info; -} -return NULL; } bool qdev_exists(const char *name) { -return !!qdev_find_info(NULL, name); +return !!object_class_by_name(name); } static void qdev_property_add_legacy(DeviceState *dev, Property *prop, @@ -245,17 +213,28 @@ DeviceState *qdev_try_create(BusState *bus, const char *name) return qdev_create_from_info(bus, name); } -static void qdev_print_devinfo(DeviceInfo *info) +static void qdev_print_devinfo(ObjectClass *klass, void *opaque) { -error_printf(name \%s\, bus %s, - info-name, info-bus_info-name); -if (info-alias) { -error_printf(, alias \%s\, info-alias); +DeviceClass *dc; +bool *show_no_user = opaque; + +dc = (DeviceClass *)object_class_dynamic_cast(klass, TYPE_DEVICE); + +if (!dc || (show_no_user !*show_no_user dc-no_user)) { +return; } -if (info-desc) { -error_printf(, desc \%s\, info-desc); + +error_printf(name \%s\, object_class_get_name(klass)); +if (dc-bus_info) { +error_printf(, bus %s, dc-bus_info-name); } -if (info-no_user) { +if (dc-alias) { +error_printf(, alias \%s\, dc-alias); +} +if (dc-desc) { +error_printf(, desc \%s\, dc-desc); +} +if (dc-no_user) { error_printf(, no-user); } error_printf(\n); @@ -279,17 +258,14 @@ static int set_property(const char *name, const char *value, void *opaque) int qdev_device_help(QemuOpts *opts) { const char *driver; -DeviceInfo *info; Property *prop; +ObjectClass *klass; +DeviceClass *info; driver = qemu_opt_get(opts, driver); if (driver !strcmp(driver, ?)) { -for (info = device_info_list; info != NULL; info = info-next) { -if (info-no_user) { -continue; /* not available, don't show */ -} -qdev_print_devinfo(info); -} +bool show_no_user = false; +object_class_foreach(qdev_print_devinfo, TYPE_DEVICE, false, show_no_user); return 1; } @@ -297,10 +273,11 @@ int qdev_device_help(QemuOpts *opts) return 0; } -info = qdev_find_info(NULL, driver); -if (!info) { +klass = object_class_by_name(driver); +if (!klass) { return 0; } +info = DEVICE_CLASS(klass); for (prop = info-props; prop prop-name; prop++) { /* @@ -312,14 +289,14 @@ int qdev_device_help(QemuOpts *opts) if (!prop-info-parse) { continue; /* no way to set it, don't show */ } -error_printf(%s.%s=%s\n, info-name, prop-name, +error_printf(%s.%s=%s\n, driver, prop-name, prop-info-legacy_name ?: prop-info-name); } for (prop = info-bus_info-props; prop prop-name; prop++) { if (!prop-info-parse) { continue; /* no way to set it, don't show */ } -error_printf(%s.%s=%s\n, info-name, prop-name, +error_printf(%s.%s=%s\n, driver, prop-name, prop-info-legacy_name ?:
[Qemu-devel] [PATCH 01/22] usb-hid: simplify class initialization a bit
We can probably model USBHidDevice as a base class to get even better code sharing but for now, just use a common function to initialize the common class members. Signed-off-by: Anthony Liguori aligu...@us.ibm.com --- hw/usb-hid.c | 27 +-- 1 files changed, 13 insertions(+), 14 deletions(-) diff --git a/hw/usb-hid.c b/hw/usb-hid.c index 88fdd35..4af27a2 100644 --- a/hw/usb-hid.c +++ b/hw/usb-hid.c @@ -553,13 +553,10 @@ static const VMStateDescription vmstate_usb_kbd = { } }; -static void usb_tablet_class_initfn(ObjectClass *klass, void *data) +static void usb_hid_class_initfn(ObjectClass *klass, void *data) { USBDeviceClass *uc = USB_DEVICE_CLASS(klass); -uc-init = usb_tablet_initfn; -uc-product_desc = QEMU USB Tablet; -uc-usb_desc = desc_tablet; uc-handle_packet = usb_generic_handle_packet; uc-handle_reset = usb_hid_handle_reset; uc-handle_control = usb_hid_handle_control; @@ -567,6 +564,16 @@ static void usb_tablet_class_initfn(ObjectClass *klass, void *data) uc-handle_destroy = usb_hid_handle_destroy; } +static void usb_tablet_class_initfn(ObjectClass *klass, void *data) +{ +USBDeviceClass *uc = USB_DEVICE_CLASS(klass); + +usb_hid_class_initfn(klass, data); +uc-init = usb_tablet_initfn; +uc-product_desc = QEMU USB Tablet; +uc-usb_desc = desc_tablet; +} + static struct DeviceInfo usb_tablet_info = { .name = usb-tablet, .size = sizeof(USBHIDState), @@ -578,14 +585,10 @@ static void usb_mouse_class_initfn(ObjectClass *klass, void *data) { USBDeviceClass *uc = USB_DEVICE_CLASS(klass); +usb_hid_class_initfn(klass, data); uc-init = usb_mouse_initfn; uc-product_desc = QEMU USB Mouse; uc-usb_desc = desc_mouse; -uc-handle_packet = usb_generic_handle_packet; -uc-handle_reset = usb_hid_handle_reset; -uc-handle_control = usb_hid_handle_control; -uc-handle_data= usb_hid_handle_data; -uc-handle_destroy = usb_hid_handle_destroy; } static struct DeviceInfo usb_mouse_info = { @@ -599,14 +602,10 @@ static void usb_keyboard_class_initfn(ObjectClass *klass, void *data) { USBDeviceClass *uc = USB_DEVICE_CLASS(klass); +usb_hid_class_initfn(klass, data); uc-init = usb_keyboard_initfn; uc-product_desc = QEMU USB Keyboard; uc-usb_desc = desc_keyboard; -uc-handle_packet = usb_generic_handle_packet; -uc-handle_reset = usb_hid_handle_reset; -uc-handle_control = usb_hid_handle_control; -uc-handle_data= usb_hid_handle_data; -uc-handle_destroy = usb_hid_handle_destroy; } static struct DeviceInfo usb_keyboard_info = { -- 1.7.4.1
[Qemu-devel] [PATCH 18/22] qom: accept any compatible type when setting a link property
Links had limited utility before as they only allowed a concrete type to be specified. Now we can support abstract types and interfaces which means it's now possible to have a linkPCIDevice. Signed-off-by: Anthony Liguori aligu...@us.ibm.com --- qom/object.c |9 + 1 files changed, 5 insertions(+), 4 deletions(-) diff --git a/qom/object.c b/qom/object.c index 2506d78..49addef 100644 --- a/qom/object.c +++ b/qom/object.c @@ -735,11 +735,12 @@ static void object_set_link_property(Object *obj, Visitor *v, void *opaque, if (target) { gchar *target_type; -target_type = g_strdup_printf(link%s, - object_get_typename(OBJECT(target))); -if (strcmp(target_type, type) == 0) { -*child = target; +target_type = g_strdup(type[5]); +target_type[strlen(target_type) - 2] = 0; + +if (object_dynamic_cast(target, target_type)) { object_ref(target); +*child = target; } else { error_set(errp, QERR_INVALID_PARAMETER_TYPE, name, type); } -- 1.7.4.1
[Qemu-devel] [PATCH v4 2/7] hpet: Save/restore cached RTC IRQ level
In legacy mode, the HPET suppresses the RTC interrupt delivery via IRQ 8 but keeps track of the RTC output level and applies it when legacy mode is turned off again. This value has to be preserved across save/ restore as it cannot be reconstructed otherwise. To document that a raised rtc_irq_level won't survive a vmload without a hpet/rtc_irq_level subsection, add an explicit clearing to the reset handler. Signed-off-by: Jan Kiszka jan.kis...@siemens.com --- hw/hpet.c | 29 + 1 files changed, 29 insertions(+), 0 deletions(-) diff --git a/hw/hpet.c b/hw/hpet.c index b6ace4e..ce981cc 100644 --- a/hw/hpet.c +++ b/hw/hpet.c @@ -240,6 +240,24 @@ static int hpet_post_load(void *opaque, int version_id) return 0; } +static bool hpet_rtc_irq_level_needed(void *opaque) +{ +HPETState *s = opaque; + +return s-rtc_irq_level != 0; +} + +static const VMStateDescription vmstate_hpet_rtc_irq_level = { +.name = hpet/rtc_irq_level, +.version_id = 1, +.minimum_version_id = 1, +.minimum_version_id_old = 1, +.fields = (VMStateField[]) { +VMSTATE_UINT8(rtc_irq_level, HPETState), +VMSTATE_END_OF_LIST() +} +}; + static const VMStateDescription vmstate_hpet_timer = { .name = hpet_timer, .version_id = 1, @@ -273,6 +291,14 @@ static const VMStateDescription vmstate_hpet = { VMSTATE_STRUCT_VARRAY_UINT8(timer, HPETState, num_timers, 0, vmstate_hpet_timer, HPETTimer), VMSTATE_END_OF_LIST() +}, +.subsections = (VMStateSubsection[]) { +{ +.vmsd = vmstate_hpet_rtc_irq_level, +.needed = hpet_rtc_irq_level_needed, +}, { +/* empty */ +} } }; @@ -636,6 +662,9 @@ static void hpet_reset(DeviceState *d) hpet_cfg.hpet[s-hpet_id].event_timer_block_id = (uint32_t)s-capability; hpet_cfg.hpet[s-hpet_id].address = sysbus_from_qdev(d)-mmio[0].addr; count = 1; + +/* to document that the RTC lowers its output on reset as well */ +s-rtc_irq_level = 0; } static void hpet_handle_rtc_irq(void *opaque, int n, int level) -- 1.7.3.4
Re: [Qemu-devel] git bisect results: ec757c67c40a56492001487e69272f62144fd124 breaks windows boot in qemu-kvm
Jan Kiszka wrote: On 2012-02-01 13:52, Erik Rull wrote: Hi all, first of all I'm a bit confused: What is the difference between qemu with command line option --enable-kvm and qemu-kvm? It seems to be a difference in code so far, from the performance point of view it seems to be the same... Now my issue that lead me to a git bisect on qemu-kvm: The following commit / merge breaks my windows guest boot sequence and causes resets infinitely: Cannot confirm yet, but I have no ACPI-free Windows installation at hand. Where does it reset, after the BIOS? ec757c67c40a56492001487e69272f62144fd124 Merge branch 'upstream-merge' into next Thu, 5 Jan 2012 11:00:07 + (13:00 +0200)Avi Kivitya...@redhat.com Interesting: qemu with --enable-kvm master and the same command line options as qemu-kvm runs perfect. My command line options are: qemu-system-x86_64 -serial /dev/ttyS2 -readconfig /etc/ich9-ehci-uhci.cfg -device usb-host,bus=ehci.0 -device usb-tablet -drive file=/dev/sda2,cache=off -m 1024 -net nic,macaddr=$MACADDR -net tap,script=/etc/qemu-ifup -no-acpi -monitor stdio -L /usr/X11R6/share/qemu -boot c -localtime Is the BIOS at /usr/X11R6/share/qemu in sync with the qemu version you try? Does leaving out options change the picture? Jan It happens directly after the windows boot progress bar is completed (I boot without logo) With the -no-kvm-irqchip it seems to be fine... Best regards, Erik
Re: [Qemu-devel] [PATCH] main-loop: Fix SetEvent() on uninitialized handle on win32
On 01/20/2012 07:08 PM, Michael Roth wrote: The __attribute__((constructor)) init_main_loop() automatically get called if qemu-tool.o is linked in. On win32, this leads to a qemu_notify_event() call which attempts to SetEvent() on a HANDLE that won't be initialized until qemu_init_main_loop() is manually called, breaking qemu-tools.o programs on Windows at runtime. This patch checks for an initialized event handle before attempting to set it, which is analoguous to how we deal with an unitialized io_thread_fd in the posix implementation. Signed-off-by: Michael Rothmdr...@linux.vnet.ibm.com Applied. Thanks. Regards, Anthony Liguori --- main-loop.c |5 - 1 files changed, 4 insertions(+), 1 deletions(-) diff --git a/main-loop.c b/main-loop.c index 692381c..62d95b9 100644 --- a/main-loop.c +++ b/main-loop.c @@ -164,7 +164,7 @@ static int qemu_signal_init(void) #else /* _WIN32 */ -HANDLE qemu_event_handle; +HANDLE qemu_event_handle = NULL; static void dummy_event_handler(void *opaque) { @@ -183,6 +183,9 @@ static int qemu_event_init(void) void qemu_notify_event(void) { +if (!qemu_event_handle) { +return; +} if (!SetEvent(qemu_event_handle)) { fprintf(stderr, qemu_notify_event: SetEvent failed: %ld\n, GetLastError());