From 1bc7e522d9cf1b58f2de9c8f1737be0bb5129c35 Mon Sep 17 00:00:00 2001 From: Igor Mammedov Date: Mon, 25 Jul 2016 11:59:19 +0200 Subject: exec: Reduce CONFIG_USER_ONLY ifdeffenery Signed-off-by: Igor Mammedov Reviewed-by: David Gibson Signed-off-by: Eduardo Habkost --- include/exec/exec-all.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'include') diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h index acda7b613d..d008296c1b 100644 --- a/include/exec/exec-all.h +++ b/include/exec/exec-all.h @@ -56,6 +56,18 @@ TranslationBlock *tb_gen_code(CPUState *cpu, target_ulong pc, target_ulong cs_base, uint32_t flags, int cflags); +#if defined(CONFIG_USER_ONLY) +void cpu_list_lock(void); +void cpu_list_unlock(void); +#else +static inline void cpu_list_unlock(void) +{ +} +static inline void cpu_list_lock(void) +{ +} +#endif + void cpu_exec_init(CPUState *cpu, Error **errp); void QEMU_NORETURN cpu_loop_exit(CPUState *cpu); void QEMU_NORETURN cpu_loop_exit_restore(CPUState *cpu, uintptr_t pc); -- cgit v1.2.3-55-g7522 From a07f953ef4ef48058c24fb50b49e6fa28bf5f5f4 Mon Sep 17 00:00:00 2001 From: Igor Mammedov Date: Mon, 25 Jul 2016 11:59:21 +0200 Subject: exec: Set cpu_index only if it's not been explictly set It keeps the legacy behavior for all users that doesn't care about stable cpu_index value, but would allow boards that would support device_add/device_del to set stable cpu_index that won't depend on order in which cpus are created/destroyed. While at that simplify cpu_get_free_index() as cpu_index generated by USER_ONLY and softmmu variants is the same since none of the users support cpu-remove so far, except of not yet released spapr/x86 device_add/delr, which will be altered by follow up patches to set stable cpu_index manually. Signed-off-by: Igor Mammedov Reviewed-by: David Gibson Signed-off-by: Eduardo Habkost --- exec.c | 44 ++++++-------------------------------------- include/qom/cpu.h | 2 ++ qom/cpu.c | 2 +- 3 files changed, 9 insertions(+), 39 deletions(-) (limited to 'include') diff --git a/exec.c b/exec.c index ae45a707b6..50e3ee237c 100644 --- a/exec.c +++ b/exec.c @@ -598,30 +598,7 @@ AddressSpace *cpu_get_address_space(CPUState *cpu, int asidx) } #endif -#ifndef CONFIG_USER_ONLY -static DECLARE_BITMAP(cpu_index_map, MAX_CPUMASK_BITS); - -static int cpu_get_free_index(Error **errp) -{ - int cpu = find_first_zero_bit(cpu_index_map, MAX_CPUMASK_BITS); - - if (cpu >= MAX_CPUMASK_BITS) { - error_setg(errp, "Trying to use more CPUs than max of %d", - MAX_CPUMASK_BITS); - return -1; - } - - bitmap_set(cpu_index_map, cpu, 1); - return cpu; -} - -static void cpu_release_index(CPUState *cpu) -{ - bitmap_clear(cpu_index_map, cpu->cpu_index, 1); -} -#else - -static int cpu_get_free_index(Error **errp) +static int cpu_get_free_index(void) { CPUState *some_cpu; int cpu_index = 0; @@ -632,12 +609,6 @@ static int cpu_get_free_index(Error **errp) return cpu_index; } -static void cpu_release_index(CPUState *cpu) -{ - return; -} -#endif - void cpu_exec_exit(CPUState *cpu) { CPUClass *cc = CPU_GET_CLASS(cpu); @@ -651,8 +622,7 @@ void cpu_exec_exit(CPUState *cpu) QTAILQ_REMOVE(&cpus, cpu, node); cpu->node.tqe_prev = NULL; - cpu_release_index(cpu); - cpu->cpu_index = -1; + cpu->cpu_index = UNASSIGNED_CPU_INDEX; cpu_list_unlock(); if (cc->vmsd != NULL) { @@ -666,7 +636,7 @@ void cpu_exec_exit(CPUState *cpu) void cpu_exec_init(CPUState *cpu, Error **errp) { CPUClass *cc ATTRIBUTE_UNUSED = CPU_GET_CLASS(cpu); - Error *local_err = NULL; + Error *local_err ATTRIBUTE_UNUSED = NULL; cpu->as = NULL; cpu->num_ases = 0; @@ -690,11 +660,9 @@ void cpu_exec_init(CPUState *cpu, Error **errp) #endif cpu_list_lock(); - cpu->cpu_index = cpu_get_free_index(&local_err); - if (local_err) { - error_propagate(errp, local_err); - cpu_list_unlock(); - return; + if (cpu->cpu_index == UNASSIGNED_CPU_INDEX) { + cpu->cpu_index = cpu_get_free_index(); + assert(cpu->cpu_index != UNASSIGNED_CPU_INDEX); } QTAILQ_INSERT_TAIL(&cpus, cpu, node); cpu_list_unlock(); diff --git a/include/qom/cpu.h b/include/qom/cpu.h index cbcd64c92b..ce0c406f27 100644 --- a/include/qom/cpu.h +++ b/include/qom/cpu.h @@ -883,4 +883,6 @@ extern const struct VMStateDescription vmstate_cpu_common; .offset = 0, \ } +#define UNASSIGNED_CPU_INDEX -1 + #endif diff --git a/qom/cpu.c b/qom/cpu.c index 42b5631c7c..2553247907 100644 --- a/qom/cpu.c +++ b/qom/cpu.c @@ -340,7 +340,7 @@ static void cpu_common_initfn(Object *obj) CPUState *cpu = CPU(obj); CPUClass *cc = CPU_GET_CLASS(obj); - cpu->cpu_index = -1; + cpu->cpu_index = UNASSIGNED_CPU_INDEX; cpu->gdb_num_regs = cpu->gdb_num_g_regs = cc->gdb_num_core_regs; qemu_mutex_init(&cpu->work_mutex); QTAILQ_INIT(&cpu->breakpoints); -- cgit v1.2.3-55-g7522 From b3443f43f45e06971d87c985bb0316c1e40259c9 Mon Sep 17 00:00:00 2001 From: Greg Kurz Date: Thu, 21 Jul 2016 23:58:37 +0200 Subject: qdev: ignore GlobalProperty.errp for hotplugged devices This patch ensures QEMU won't terminate while hotplugging a device if the global property cannot be set and errp points to error_fatal or error_abort. While here, it also fixes indentation of the typename argument. Suggested-by: Eduardo Habkost Signed-off-by: Greg Kurz Reviewed-by: Eduardo Habkost Signed-off-by: Eduardo Habkost --- hw/core/qdev-properties.c | 4 ++-- include/hw/qdev-core.h | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c index 14e544ab17..311af6da76 100644 --- a/hw/core/qdev-properties.c +++ b/hw/core/qdev-properties.c @@ -1084,7 +1084,7 @@ int qdev_prop_check_globals(void) } static void qdev_prop_set_globals_for_type(DeviceState *dev, - const char *typename) + const char *typename) { GList *l; @@ -1100,7 +1100,7 @@ static void qdev_prop_set_globals_for_type(DeviceState *dev, if (err != NULL) { error_prepend(&err, "can't apply global %s.%s=%s: ", prop->driver, prop->property, prop->value); - if (prop->errp) { + if (!dev->hotplugged && prop->errp) { error_propagate(prop->errp, err); } else { assert(prop->user_provided); diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h index 1d1f8612a9..4b4b33bec8 100644 --- a/include/hw/qdev-core.h +++ b/include/hw/qdev-core.h @@ -261,7 +261,9 @@ struct PropertyInfo { * @used: Set to true if property was used when initializing a device. * @errp: Error destination, used like first argument of error_setg() * in case property setting fails later. If @errp is NULL, we - * print warnings instead of ignoring errors silently. + * print warnings instead of ignoring errors silently. For + * hotplugged devices, errp is always ignored and warnings are + * printed instead. */ typedef struct GlobalProperty { const char *driver; -- cgit v1.2.3-55-g7522