From 3beacfb98ba5f594dff4a4541401f2849e0a9ec6 Mon Sep 17 00:00:00 2001 From: Eduardo Habkost Date: Tue, 29 Aug 2017 19:03:37 -0300 Subject: qom: Remove unused errp parameter from can_be_deleted() The errp argument is ignored by all implementations of the method, and user_creatable_del() would break if any implementation set an error (because it calls error_setg(errp) if the function returns false). Remove the unused parameter. Signed-off-by: Eduardo Habkost Message-Id: <20170829220337.23427-1-ehabkost@redhat.com> Reviewed-by: Gonglei Reviewed-by: Igor Mammedov Signed-off-by: Eduardo Habkost --- include/qom/object_interfaces.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/qom/object_interfaces.h b/include/qom/object_interfaces.h index fdd7603c84..d63c1c28f8 100644 --- a/include/qom/object_interfaces.h +++ b/include/qom/object_interfaces.h @@ -51,7 +51,7 @@ typedef struct UserCreatableClass { /* */ void (*complete)(UserCreatable *uc, Error **errp); - bool (*can_be_deleted)(UserCreatable *uc, Error **errp); + bool (*can_be_deleted)(UserCreatable *uc); } UserCreatableClass; /** @@ -68,12 +68,11 @@ void user_creatable_complete(Object *obj, Error **errp); /** * user_creatable_can_be_deleted: * @uc: the object whose can_be_deleted() method is called if implemented - * @errp: if an error occurs, a pointer to an area to store the error * * Wrapper to call can_be_deleted() method if one of types it's inherited * from implements USER_CREATABLE interface. */ -bool user_creatable_can_be_deleted(UserCreatable *uc, Error **errp); +bool user_creatable_can_be_deleted(UserCreatable *uc); /** * user_creatable_add_type: -- cgit v1.2.3-55-g7522 From 5ce46cb34eecec0bc94a4b1394763f9a1bbe20c3 Mon Sep 17 00:00:00 2001 From: Eduardo Habkost Date: Wed, 26 Jul 2017 15:44:35 -0300 Subject: cpu: cpu_by_arch_id() helper The helper can be used for CPU object lookup using the CPU's arch-specific ID (the one returned by CPUClass::get_arch_id()). Signed-off-by: Eduardo Habkost [Yi Wang: Added documentation comments] Signed-off-by: Yi Wang Signed-off-by: Yun Liu [ehabkost: extracted cpu_by_arch_id() to a separate patch] Signed-off-by: Eduardo Habkost --- include/qom/cpu.h | 10 ++++++++++ qom/cpu.c | 11 ++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/qom/cpu.h b/include/qom/cpu.h index 25eefea7ab..b7ac9491c8 100644 --- a/include/qom/cpu.h +++ b/include/qom/cpu.h @@ -754,6 +754,16 @@ CPUState *qemu_get_cpu(int index); */ bool cpu_exists(int64_t id); +/** + * cpu_by_arch_id: + * @id: Guest-exposed CPU ID of the CPU to obtain. + * + * Get a CPU with matching @id. + * + * Returns: The CPU or %NULL if there is no matching CPU. + */ +CPUState *cpu_by_arch_id(int64_t id); + /** * cpu_throttle_set: * @new_throttle_pct: Percent of sleep time. Valid range is 1 to 99. diff --git a/qom/cpu.c b/qom/cpu.c index 4f38db0dac..e6210d5949 100644 --- a/qom/cpu.c +++ b/qom/cpu.c @@ -34,7 +34,7 @@ CPUInterruptHandler cpu_interrupt_handler; -bool cpu_exists(int64_t id) +CPUState *cpu_by_arch_id(int64_t id) { CPUState *cpu; @@ -42,10 +42,15 @@ bool cpu_exists(int64_t id) CPUClass *cc = CPU_GET_CLASS(cpu); if (cc->get_arch_id(cpu) == id) { - return true; + return cpu; } } - return false; + return NULL; +} + +bool cpu_exists(int64_t id) +{ + return !!cpu_by_arch_id(id); } CPUState *cpu_generic_init(const char *typename, const char *cpu_model) -- cgit v1.2.3-55-g7522