Skip to content

Commit 4fee9ad

Browse files
vittyvkjgross1
authored andcommitted
xen/balloon: decorate PV-only parts with #ifdef CONFIG_XEN_PV
Balloon driver uses several PV-only concepts (xen_start_info, xen_extra_mem,..) and it seems the simpliest solution to make HVM-only build happy is to decorate these parts with #ifdefs. Signed-off-by: Vitaly Kuznetsov <[email protected]> Reviewed-by: Juergen Gross <[email protected]> Signed-off-by: Juergen Gross <[email protected]>
1 parent 3d4ebdb commit 4fee9ad

File tree

1 file changed

+20
-10
lines changed

1 file changed

+20
-10
lines changed

drivers/xen/balloon.c

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -709,6 +709,7 @@ void free_xenballooned_pages(int nr_pages, struct page **pages)
709709
}
710710
EXPORT_SYMBOL(free_xenballooned_pages);
711711

712+
#ifdef CONFIG_XEN_PV
712713
static void __init balloon_add_region(unsigned long start_pfn,
713714
unsigned long pages)
714715
{
@@ -732,19 +733,22 @@ static void __init balloon_add_region(unsigned long start_pfn,
732733

733734
balloon_stats.total_pages += extra_pfn_end - start_pfn;
734735
}
736+
#endif
735737

736738
static int __init balloon_init(void)
737739
{
738-
int i;
739-
740740
if (!xen_domain())
741741
return -ENODEV;
742742

743743
pr_info("Initialising balloon driver\n");
744744

745+
#ifdef CONFIG_XEN_PV
745746
balloon_stats.current_pages = xen_pv_domain()
746747
? min(xen_start_info->nr_pages - xen_released_pages, max_pfn)
747748
: get_num_physpages();
749+
#else
750+
balloon_stats.current_pages = get_num_physpages();
751+
#endif
748752
balloon_stats.target_pages = balloon_stats.current_pages;
749753
balloon_stats.balloon_low = 0;
750754
balloon_stats.balloon_high = 0;
@@ -761,14 +765,20 @@ static int __init balloon_init(void)
761765
register_sysctl_table(xen_root);
762766
#endif
763767

764-
/*
765-
* Initialize the balloon with pages from the extra memory
766-
* regions (see arch/x86/xen/setup.c).
767-
*/
768-
for (i = 0; i < XEN_EXTRA_MEM_MAX_REGIONS; i++)
769-
if (xen_extra_mem[i].n_pfns)
770-
balloon_add_region(xen_extra_mem[i].start_pfn,
771-
xen_extra_mem[i].n_pfns);
768+
#ifdef CONFIG_XEN_PV
769+
{
770+
int i;
771+
772+
/*
773+
* Initialize the balloon with pages from the extra memory
774+
* regions (see arch/x86/xen/setup.c).
775+
*/
776+
for (i = 0; i < XEN_EXTRA_MEM_MAX_REGIONS; i++)
777+
if (xen_extra_mem[i].n_pfns)
778+
balloon_add_region(xen_extra_mem[i].start_pfn,
779+
xen_extra_mem[i].n_pfns);
780+
}
781+
#endif
772782

773783
return 0;
774784
}

0 commit comments

Comments
 (0)