ahci: add is_ncq predicate helper
[qemu/ar7.git] / backends / hostmem-ram.c
bloba67a134521a3d921b316cdcd5598b7f8ac7e1549
1 /*
2 * QEMU Host Memory Backend
4 * Copyright (C) 2013-2014 Red Hat Inc
6 * Authors:
7 * Igor Mammedov <imammedo@redhat.com>
9 * This work is licensed under the terms of the GNU GPL, version 2 or later.
10 * See the COPYING file in the top-level directory.
12 #include "sysemu/hostmem.h"
13 #include "qom/object_interfaces.h"
15 #define TYPE_MEMORY_BACKEND_RAM "memory-backend-ram"
18 static void
19 ram_backend_memory_alloc(HostMemoryBackend *backend, Error **errp)
21 char *path;
23 if (!backend->size) {
24 error_setg(errp, "can't create backend with size 0");
25 return;
28 path = object_get_canonical_path_component(OBJECT(backend));
29 memory_region_init_ram(&backend->mr, OBJECT(backend), path,
30 backend->size, errp);
31 g_free(path);
34 static void
35 ram_backend_class_init(ObjectClass *oc, void *data)
37 HostMemoryBackendClass *bc = MEMORY_BACKEND_CLASS(oc);
39 bc->alloc = ram_backend_memory_alloc;
42 static const TypeInfo ram_backend_info = {
43 .name = TYPE_MEMORY_BACKEND_RAM,
44 .parent = TYPE_MEMORY_BACKEND,
45 .class_init = ram_backend_class_init,
48 static void register_types(void)
50 type_register_static(&ram_backend_info);
53 type_init(register_types);