From 3c75e12ea64666f2fc9f822675490e8672f45453 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Wed, 13 Nov 2019 13:57:55 +0100 Subject: qom: add object_new_with_class Similar to CPU and machine classes, "-accel" class names are mangled, so we have to first get a class via accel_find and then instantiate it. Provide a new function to instantiate a class without going through object_class_get_name, and use it for CPUs and machines already. Reviewed-by: Marc-André Lureau Signed-off-by: Paolo Bonzini --- include/qom/object.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'include') diff --git a/include/qom/object.h b/include/qom/object.h index 230b18fe14..f9ad692f21 100644 --- a/include/qom/object.h +++ b/include/qom/object.h @@ -592,6 +592,18 @@ struct InterfaceClass ((interface *)object_dynamic_cast_assert(OBJECT((obj)), (name), \ __FILE__, __LINE__, __func__)) +/** + * object_new_with_class: + * @klass: The class to instantiate. + * + * This function will initialize a new object using heap allocated memory. + * The returned object has a reference count of 1, and will be freed when + * the last reference is dropped. + * + * Returns: The newly allocated and instantiated object. + */ +Object *object_new_with_class(ObjectClass *klass); + /** * object_new: * @typename: The name of the type of the object to instantiate. -- cgit v1.2.3-55-g7522