Definitely.+ for (i = 0; i < num_pfns; i++) {Since the interval of vb->num_pfns is VIRTIO_BALLOON_PAGES_PER_PAGE,
+ set_page_pfns(vb, vb->pfns + vb->num_pfns + i,
+ nth_page(page, i));
+ }
it seems that the pfns[] should be vb->pfns + vb->num_pfns + i * VIRTIO_BALLOON_PAGES_PER_PAGE.
+ vb->num_pages +=num_pfns is of the unsigned int type so need be to converted to long manually.
+ num_pfns * VIRTIO_BALLOON_PAGES_PER_PAGE;
+ if (!virtio_has_feature(
+ vb->vdev, VIRTIO_BALLOON_F_DEFLATE_ON_OOM))
+ adjust_managed_page_count(page, -num_pfns);