diff options
| author | Stefan Hajnoczi <stefanha@redhat.com> | 2017-05-18 10:05:50 +0100 |
|---|---|---|
| committer | Stefan Hajnoczi <stefanha@redhat.com> | 2017-05-18 10:05:52 +0100 |
| commit | 2ccbd47c1def618b31af1d88b550f6d2bdd15b0f (patch) | |
| tree | 9944ab67319550408e114c6842722e326df7c172 /migration/page_cache.h | |
| parent | adb354dd1e00aa6b8bd674f0e1f70008badded0f (diff) | |
| parent | 1bfe5f0586083747f1602931713111673849cd9d (diff) | |
| download | focaccia-qemu-2ccbd47c1def618b31af1d88b550f6d2bdd15b0f.tar.gz focaccia-qemu-2ccbd47c1def618b31af1d88b550f6d2bdd15b0f.zip | |
Merge remote-tracking branch 'quintela/tags/migration/20170517' into staging
migration/next for 20170517
# gpg: Signature made Wed 17 May 2017 11:46:36 AM BST
# gpg: using RSA key 0xF487EF185872D723
# gpg: Good signature from "Juan Quintela <quintela@redhat.com>"
# gpg: aka "Juan Quintela <quintela@trasno.org>"
# Primary key fingerprint: 1899 FF8E DEBF 58CC EE03 4B82 F487 EF18 5872 D723
* quintela/tags/migration/20170517:
migration: Move check_migratable() into qdev.c
migration: Move postcopy stuff to postcopy-ram.c
migration: Move page_cache.c to migration/
migration: Create migration/blocker.h
ram: Rename RAM_SAVE_FLAG_COMPRESS to RAM_SAVE_FLAG_ZERO
migration: Pass Error ** argument to {save,load}_vmstate
migration: Fix regression with compression threads
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'migration/page_cache.h')
| -rw-r--r-- | migration/page_cache.h | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/migration/page_cache.h b/migration/page_cache.h new file mode 100644 index 0000000000..10ed53274c --- /dev/null +++ b/migration/page_cache.h @@ -0,0 +1,86 @@ +/* + * Page cache for QEMU + * The cache is base on a hash of the page address + * + * Copyright 2012 Red Hat, Inc. and/or its affiliates + * + * Authors: + * Orit Wasserman <owasserm@redhat.com> + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + * + */ + +#ifndef PAGE_CACHE_H +#define PAGE_CACHE_H + +/* Page cache for storing guest pages */ +typedef struct PageCache PageCache; + +/** + * cache_init: Initialize the page cache + * + * + * Returns new allocated cache or NULL on error + * + * @cache pointer to the PageCache struct + * @num_pages: cache maximal number of cached pages + * @page_size: cache page size + */ +PageCache *cache_init(int64_t num_pages, unsigned int page_size); + +/** + * cache_fini: free all cache resources + * @cache pointer to the PageCache struct + */ +void cache_fini(PageCache *cache); + +/** + * cache_is_cached: Checks to see if the page is cached + * + * Returns %true if page is cached + * + * @cache pointer to the PageCache struct + * @addr: page addr + * @current_age: current bitmap generation + */ +bool cache_is_cached(const PageCache *cache, uint64_t addr, + uint64_t current_age); + +/** + * get_cached_data: Get the data cached for an addr + * + * Returns pointer to the data cached or NULL if not cached + * + * @cache pointer to the PageCache struct + * @addr: page addr + */ +uint8_t *get_cached_data(const PageCache *cache, uint64_t addr); + +/** + * cache_insert: insert the page into the cache. the page cache + * will dup the data on insert. the previous value will be overwritten + * + * Returns -1 when the page isn't inserted into cache + * + * @cache pointer to the PageCache struct + * @addr: page address + * @pdata: pointer to the page + * @current_age: current bitmap generation + */ +int cache_insert(PageCache *cache, uint64_t addr, const uint8_t *pdata, + uint64_t current_age); + +/** + * cache_resize: resize the page cache. In case of size reduction the extra + * pages will be freed + * + * Returns -1 on error new cache size on success + * + * @cache pointer to the PageCache struct + * @num_pages: new page cache size (in pages) + */ +int64_t cache_resize(PageCache *cache, int64_t num_pages); + +#endif |