qemu/include/sysemu/hostmem.h
<<
>>
Prefs
   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 */
  12#ifndef QEMU_RAM_H
  13#define QEMU_RAM_H
  14
  15#include "sysemu/sysemu.h" /* for MAX_NODES */
  16#include "qom/object.h"
  17#include "exec/memory.h"
  18#include "qemu/option.h"
  19#include "qemu/bitmap.h"
  20
  21#define TYPE_MEMORY_BACKEND "memory-backend"
  22#define MEMORY_BACKEND(obj) \
  23    OBJECT_CHECK(HostMemoryBackend, (obj), TYPE_MEMORY_BACKEND)
  24#define MEMORY_BACKEND_GET_CLASS(obj) \
  25    OBJECT_GET_CLASS(HostMemoryBackendClass, (obj), TYPE_MEMORY_BACKEND)
  26#define MEMORY_BACKEND_CLASS(klass) \
  27    OBJECT_CLASS_CHECK(HostMemoryBackendClass, (klass), TYPE_MEMORY_BACKEND)
  28
  29typedef struct HostMemoryBackend HostMemoryBackend;
  30typedef struct HostMemoryBackendClass HostMemoryBackendClass;
  31
  32/**
  33 * HostMemoryBackendClass:
  34 * @parent_class: opaque parent class container
  35 */
  36struct HostMemoryBackendClass {
  37    ObjectClass parent_class;
  38
  39    void (*alloc)(HostMemoryBackend *backend, Error **errp);
  40};
  41
  42/**
  43 * @HostMemoryBackend
  44 *
  45 * @parent: opaque parent object container
  46 * @size: amount of memory backend provides
  47 * @mr: MemoryRegion representing host memory belonging to backend
  48 */
  49struct HostMemoryBackend {
  50    /* private */
  51    Object parent;
  52
  53    /* protected */
  54    uint64_t size;
  55    bool merge, dump;
  56    bool prealloc, force_prealloc;
  57    DECLARE_BITMAP(host_nodes, MAX_NODES + 1);
  58    HostMemPolicy policy;
  59
  60    MemoryRegion mr;
  61};
  62
  63MemoryRegion *host_memory_backend_get_memory(HostMemoryBackend *backend,
  64                                             Error **errp);
  65
  66#endif
  67