提交 026ac483 编写于 作者: E Eduardo Habkost

hostmem-file: Register TYPE_MEMORY_BACKEND_FILE properties as class properties

To do the conversion, the file_backend_class_init() was moved
after the getter/setter functions. The old
file_backend_instance_init() function was removed because it is
not needed anymore.

The NULL errp arguments on the property registration calls were
changed to &error_abort.
Reviewed-by: NIgor Mammedov <imammedo@redhat.com>
Signed-off-by: NEduardo Habkost <ehabkost@redhat.com>
上级 e62834ca
...@@ -64,14 +64,6 @@ file_backend_memory_alloc(HostMemoryBackend *backend, Error **errp) ...@@ -64,14 +64,6 @@ file_backend_memory_alloc(HostMemoryBackend *backend, Error **errp)
#endif #endif
} }
static void
file_backend_class_init(ObjectClass *oc, void *data)
{
HostMemoryBackendClass *bc = MEMORY_BACKEND_CLASS(oc);
bc->alloc = file_backend_memory_alloc;
}
static char *get_mem_path(Object *o, Error **errp) static char *get_mem_path(Object *o, Error **errp)
{ {
HostMemoryBackendFile *fb = MEMORY_BACKEND_FILE(o); HostMemoryBackendFile *fb = MEMORY_BACKEND_FILE(o);
...@@ -112,13 +104,18 @@ static void file_memory_backend_set_share(Object *o, bool value, Error **errp) ...@@ -112,13 +104,18 @@ static void file_memory_backend_set_share(Object *o, bool value, Error **errp)
} }
static void static void
file_backend_instance_init(Object *o) file_backend_class_init(ObjectClass *oc, void *data)
{ {
object_property_add_bool(o, "share", HostMemoryBackendClass *bc = MEMORY_BACKEND_CLASS(oc);
file_memory_backend_get_share,
file_memory_backend_set_share, NULL); bc->alloc = file_backend_memory_alloc;
object_property_add_str(o, "mem-path", get_mem_path,
set_mem_path, NULL); object_class_property_add_bool(oc, "share",
file_memory_backend_get_share, file_memory_backend_set_share,
&error_abort);
object_class_property_add_str(oc, "mem-path",
get_mem_path, set_mem_path,
&error_abort);
} }
static void file_backend_instance_finalize(Object *o) static void file_backend_instance_finalize(Object *o)
...@@ -132,7 +129,6 @@ static const TypeInfo file_backend_info = { ...@@ -132,7 +129,6 @@ static const TypeInfo file_backend_info = {
.name = TYPE_MEMORY_BACKEND_FILE, .name = TYPE_MEMORY_BACKEND_FILE,
.parent = TYPE_MEMORY_BACKEND, .parent = TYPE_MEMORY_BACKEND,
.class_init = file_backend_class_init, .class_init = file_backend_class_init,
.instance_init = file_backend_instance_init,
.instance_finalize = file_backend_instance_finalize, .instance_finalize = file_backend_instance_finalize,
.instance_size = sizeof(HostMemoryBackendFile), .instance_size = sizeof(HostMemoryBackendFile),
}; };
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册