/* * Get the list of PFNs that are not in the psuedo-phys map. * Although we allocate pages on demand, balloon driver may * decreased simaltenously. So we have to free the freed * pages here. */ static int xc_ia64_recv_unallocated_list(int xc_handle, int io_fd, uint32_t dom, struct xen_ia64_p2m_table *p2m_table) { int rc = -1; unsigned int i; unsigned int count; unsigned long *pfntab = NULL; unsigned int nr_frees; if (read_exact(io_fd, &count, sizeof(count))) { ERROR("Error when reading pfn count"); goto out; } pfntab = malloc(sizeof(unsigned long) * count); if (pfntab == NULL) { ERROR("Out of memory"); goto out; } if (read_exact(io_fd, pfntab, sizeof(unsigned long)*count)) { ERROR("Error when reading pfntab"); goto out; } nr_frees = 0; for (i = 0; i < count; i++) { if (xc_ia64_p2m_allocated(p2m_table, pfntab[i])) { pfntab[nr_frees] = pfntab[i]; nr_frees++; } } if (nr_frees > 0) { if (xc_domain_memory_decrease_reservation(xc_handle, dom, nr_frees, 0, pfntab) < 0) { PERROR("Could not decrease reservation"); goto out; } else DPRINTF("Decreased reservation by %d / %d pages\n", nr_frees, count); } rc = 0; out: if (pfntab != NULL) free(pfntab); return rc; }
unsigned long xc_make_page_below_4G( int xc_handle, uint32_t domid, unsigned long mfn) { xen_pfn_t old_mfn = mfn; xen_pfn_t new_mfn; if ( xc_domain_memory_decrease_reservation( xc_handle, domid, 1, 0, &old_mfn) != 0 ) { DPRINTF("xc_make_page_below_4G decrease failed. mfn=%lx\n",mfn); return 0; } if ( xc_domain_memory_increase_reservation( xc_handle, domid, 1, 0, XENMEMF_address_bits(32), &new_mfn) != 0 ) { DPRINTF("xc_make_page_below_4G increase failed. mfn=%lx\n",mfn); return 0; } return new_mfn; }