]> git.proxmox.com Git - mirror_qemu.git/blame - backends/hostmem-ram.c
Revert "migration: move only_migratable to MigrationState"
[mirror_qemu.git] / backends / hostmem-ram.c
CommitLineData
1f070489
IM
1/*
2 * QEMU Host Memory Backend
3 *
4 * Copyright (C) 2013-2014 Red Hat Inc
5 *
6 * Authors:
7 * Igor Mammedov <imammedo@redhat.com>
8 *
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.
11 */
9c058332 12#include "qemu/osdep.h"
1f070489 13#include "sysemu/hostmem.h"
da34e65c 14#include "qapi/error.h"
1f070489
IM
15#include "qom/object_interfaces.h"
16
17#define TYPE_MEMORY_BACKEND_RAM "memory-backend-ram"
18
1f070489 19static void
bd9262d9 20ram_backend_memory_alloc(HostMemoryBackend *backend, Error **errp)
1f070489 21{
fa0cb34d 22 char *name;
1f070489
IM
23
24 if (!backend->size) {
25 error_setg(errp, "can't create backend with size 0");
26 return;
27 }
28
fa0cb34d
MAL
29 name = host_memory_backend_get_name(backend);
30 memory_region_init_ram_shared_nomigrate(&backend->mr, OBJECT(backend), name,
06329cce 31 backend->size, backend->share, errp);
fa0cb34d 32 g_free(name);
1f070489
IM
33}
34
35static void
36ram_backend_class_init(ObjectClass *oc, void *data)
37{
bd9262d9 38 HostMemoryBackendClass *bc = MEMORY_BACKEND_CLASS(oc);
1f070489 39
bd9262d9 40 bc->alloc = ram_backend_memory_alloc;
1f070489
IM
41}
42
43static const TypeInfo ram_backend_info = {
44 .name = TYPE_MEMORY_BACKEND_RAM,
45 .parent = TYPE_MEMORY_BACKEND,
46 .class_init = ram_backend_class_init,
47};
48
49static void register_types(void)
50{
51 type_register_static(&ram_backend_info);
52}
53
54type_init(register_types);