2
0

ramblock.h 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /*
  2. * Declarations for cpu physical memory functions
  3. *
  4. * Copyright 2011 Red Hat, Inc. and/or its affiliates
  5. *
  6. * Authors:
  7. * Avi Kivity <avi@redhat.com>
  8. *
  9. * This work is licensed under the terms of the GNU GPL, version 2 or
  10. * later. See the COPYING file in the top-level directory.
  11. *
  12. */
  13. /*
  14. * This header is for use by exec.c and memory.c ONLY. Do not include it.
  15. * The functions declared here will be removed soon.
  16. */
  17. #ifndef QEMU_EXEC_RAMBLOCK_H
  18. #define QEMU_EXEC_RAMBLOCK_H
  19. #ifndef CONFIG_USER_ONLY
  20. #include "cpu-common.h"
  21. #include "qemu/rcu.h"
  22. #include "exec/ramlist.h"
  23. struct RAMBlock {
  24. struct rcu_head rcu;
  25. struct MemoryRegion *mr;
  26. uint8_t *host;
  27. uint8_t *colo_cache; /* For colo, VM's ram cache */
  28. ram_addr_t offset;
  29. ram_addr_t used_length;
  30. ram_addr_t max_length;
  31. void (*resized)(const char*, uint64_t length, void *host);
  32. uint32_t flags;
  33. /* Protected by the BQL. */
  34. char idstr[256];
  35. /* RCU-enabled, writes protected by the ramlist lock */
  36. QLIST_ENTRY(RAMBlock) next;
  37. QLIST_HEAD(, RAMBlockNotifier) ramblock_notifiers;
  38. Error *cpr_blocker;
  39. int fd;
  40. uint64_t fd_offset;
  41. int guest_memfd;
  42. size_t page_size;
  43. /* dirty bitmap used during migration */
  44. unsigned long *bmap;
  45. /*
  46. * Below fields are only used by mapped-ram migration
  47. */
  48. /* bitmap of pages present in the migration file */
  49. unsigned long *file_bmap;
  50. /*
  51. * offset in the file pages belonging to this ramblock are saved,
  52. * used only during migration to a file.
  53. */
  54. off_t bitmap_offset;
  55. uint64_t pages_offset;
  56. /* Bitmap of already received pages. Only used on destination side. */
  57. unsigned long *receivedmap;
  58. /*
  59. * bitmap to track already cleared dirty bitmap. When the bit is
  60. * set, it means the corresponding memory chunk needs a log-clear.
  61. * Set this up to non-NULL to enable the capability to postpone
  62. * and split clearing of dirty bitmap on the remote node (e.g.,
  63. * KVM). The bitmap will be set only when doing global sync.
  64. *
  65. * It is only used during src side of ram migration, and it is
  66. * protected by the global ram_state.bitmap_mutex.
  67. *
  68. * NOTE: this bitmap is different comparing to the other bitmaps
  69. * in that one bit can represent multiple guest pages (which is
  70. * decided by the `clear_bmap_shift' variable below). On
  71. * destination side, this should always be NULL, and the variable
  72. * `clear_bmap_shift' is meaningless.
  73. */
  74. unsigned long *clear_bmap;
  75. uint8_t clear_bmap_shift;
  76. /*
  77. * RAM block length that corresponds to the used_length on the migration
  78. * source (after RAM block sizes were synchronized). Especially, after
  79. * starting to run the guest, used_length and postcopy_length can differ.
  80. * Used to register/unregister uffd handlers and as the size of the received
  81. * bitmap. Receiving any page beyond this length will bail out, as it
  82. * could not have been valid on the source.
  83. */
  84. ram_addr_t postcopy_length;
  85. };
  86. #endif
  87. #endif