hw/arm/virt-acpi-build: don't save VirtGuestInfo on AcpiBuildState
[qemu.git] / include / migration / page_cache.h
1 /*
2 * Page cache for QEMU
3 * The cache is base on a hash of the page address
4 *
5 * Copyright 2012 Red Hat, Inc. and/or its affiliates
6 *
7 * Authors:
8 * Orit Wasserman <owasserm@redhat.com>
9 *
10 * This work is licensed under the terms of the GNU GPL, version 2 or later.
11 * See the COPYING file in the top-level directory.
12 *
13 */
14
15 #ifndef PAGE_CACHE_H
16 #define PAGE_CACHE_H
17
18 /* Page cache for storing guest pages */
19 typedef struct PageCache PageCache;
20
21 /**
22 * cache_init: Initialize the page cache
23 *
24 *
25 * Returns new allocated cache or NULL on error
26 *
27 * @cache pointer to the PageCache struct
28 * @num_pages: cache maximal number of cached pages
29 * @page_size: cache page size
30 */
31 PageCache *cache_init(int64_t num_pages, unsigned int page_size);
32
33 /**
34 * cache_fini: free all cache resources
35 * @cache pointer to the PageCache struct
36 */
37 void cache_fini(PageCache *cache);
38
39 /**
40 * cache_is_cached: Checks to see if the page is cached
41 *
42 * Returns %true if page is cached
43 *
44 * @cache pointer to the PageCache struct
45 * @addr: page addr
46 * @current_age: current bitmap generation
47 */
48 bool cache_is_cached(const PageCache *cache, uint64_t addr,
49 uint64_t current_age);
50
51 /**
52 * get_cached_data: Get the data cached for an addr
53 *
54 * Returns pointer to the data cached or NULL if not cached
55 *
56 * @cache pointer to the PageCache struct
57 * @addr: page addr
58 */
59 uint8_t *get_cached_data(const PageCache *cache, uint64_t addr);
60
61 /**
62 * cache_insert: insert the page into the cache. the page cache
63 * will dup the data on insert. the previous value will be overwritten
64 *
65 * Returns -1 when the page isn't inserted into cache
66 *
67 * @cache pointer to the PageCache struct
68 * @addr: page address
69 * @pdata: pointer to the page
70 * @current_age: current bitmap generation
71 */
72 int cache_insert(PageCache *cache, uint64_t addr, const uint8_t *pdata,
73 uint64_t current_age);
74
75 /**
76 * cache_resize: resize the page cache. In case of size reduction the extra
77 * pages will be freed
78 *
79 * Returns -1 on error new cache size on success
80 *
81 * @cache pointer to the PageCache struct
82 * @num_pages: new page cache size (in pages)
83 */
84 int64_t cache_resize(PageCache *cache, int64_t num_pages);
85
86 #endif