static int setup_cpu_watcher(struct notifier_block *notifier, unsigned long event, void *data) { int cpu; static struct xenbus_watch cpu_watch = { .node = "cpu", .callback = handle_vcpu_hotplug_event}; (void)register_xenbus_watch(&cpu_watch); for_each_possible_cpu(cpu) { if (vcpu_online(cpu) == 0) { (void)cpu_down(cpu); set_cpu_present(cpu, false); } } return NOTIFY_DONE; } static int __init setup_vcpu_hotplug_event(void) { static struct notifier_block xsn_cpu = { .notifier_call = setup_cpu_watcher }; if (!xen_pv_domain()) return -ENODEV; register_xenstore_notifier(&xsn_cpu); return 0; } arch_initcall(setup_vcpu_hotplug_event);
static int setup_cpu_watcher(struct notifier_block *notifier, unsigned long event, void *data) { static struct xenbus_watch cpu_watch = { .node = "cpu", .callback = handle_vcpu_hotplug_event}; (void)register_xenbus_watch(&cpu_watch); return NOTIFY_DONE; } static int __init setup_vcpu_hotplug_event(void) { static struct notifier_block xsn_cpu = { .notifier_call = setup_cpu_watcher }; if (!xen_pv_domain()) return -ENODEV; register_xenstore_notifier(&xsn_cpu); return 0; } arch_initcall(setup_vcpu_hotplug_event);
static int __cpuinit setup_cpu_watcher(struct notifier_block *notifier, unsigned long event, void *data) { unsigned int i; static struct xenbus_watch __cpuinitdata cpu_watch = { .node = "cpu", .callback = handle_vcpu_hotplug_event, .flags = XBWF_new_thread }; (void)register_xenbus_watch(&cpu_watch); if (!is_initial_xendomain()) { for_each_possible_cpu(i) vcpu_hotplug(i); printk(KERN_INFO "Brought up %ld CPUs\n", (long)num_online_cpus()); } return NOTIFY_DONE; } static int __init setup_vcpu_hotplug_event(void) { static struct notifier_block hotplug_cpu = { .notifier_call = smpboot_cpu_notify }; static struct notifier_block __cpuinitdata xsn_cpu = { .notifier_call = setup_cpu_watcher }; if (!is_running_on_xen()) return -ENODEV; register_cpu_notifier(&hotplug_cpu); register_xenstore_notifier(&xsn_cpu); return 0; } arch_initcall(setup_vcpu_hotplug_event); int __ref smp_suspend(void) { unsigned int cpu; int err; for_each_online_cpu(cpu) { if (cpu == 0) continue; err = cpu_down(cpu); if (err) { printk(KERN_CRIT "Failed to take all CPUs " "down: %d.\n", err); for_each_possible_cpu(cpu) vcpu_hotplug(cpu); return err; } } return 0; }
static int __init setup_shutdown_event(void) { static struct notifier_block xenstore_notifier = { .notifier_call = setup_shutdown_watcher }; register_xenstore_notifier(&xenstore_notifier); return 0; }
void xen_balloon_init(void) { register_balloon(&balloon_dev); register_xen_selfballooning(&balloon_dev); register_xenstore_notifier(&xenstore_notifier); }
static int __init balloon_init(void) { #if defined(CONFIG_X86) && defined(CONFIG_XEN) unsigned long pfn; struct page *page; #endif if (!is_running_on_xen()) return -ENODEV; IPRINTK("Initialising balloon driver.\n"); #ifdef CONFIG_XEN current_pages = min(xen_start_info->nr_pages, max_pfn); totalram_pages = current_pages; #else current_pages = totalram_pages; #endif target_pages = current_pages; balloon_low = 0; balloon_high = 0; driver_pages = 0UL; hard_limit = ~0UL; init_timer(&balloon_timer); balloon_timer.data = 0; balloon_timer.function = balloon_alarm; /* don't include on bare-metal & FV guest */ #if defined(CONFIG_PROC_FS) && defined(CONFIG_XEN) if ((balloon_pde = create_xen_proc_entry("balloon", 0644)) == NULL) { WPRINTK("Unable to create /proc/xen/balloon.\n"); return -1; } balloon_pde->read_proc = balloon_read; balloon_pde->write_proc = balloon_write; #endif #if defined(CONFIG_X86) && defined(CONFIG_XEN) /* Initialise the balloon with excess memory space. */ for (pfn = xen_start_info->nr_pages; pfn < max_pfn; pfn++) { page = pfn_to_page(pfn); balloon_append(page); } #endif target_watch.callback = watch_target; xenstore_notifier.notifier_call = balloon_init_watcher; register_xenstore_notifier(&xenstore_notifier); return 0; }
int xen_setup_shutdown_event(void) { static struct notifier_block xenstore_notifier = { .notifier_call = shutdown_event }; if (!xen_domain()) return -ENODEV; register_xenstore_notifier(&xenstore_notifier); return 0; }
static int __init balloon_init(void) { if (!xen_domain()) return -ENODEV; pr_info("xen-balloon: Initialising balloon driver.\n"); register_balloon(&balloon_dev); register_xen_selfballooning(&balloon_dev); register_xenstore_notifier(&xenstore_notifier); return 0; }
static int __init balloon_init(void) { unsigned long pfn, extra_pfn_end; struct page *page; if (!xen_pv_domain()) return -ENODEV; pr_info("xen_balloon: Initialising balloon driver.\n"); balloon_stats.current_pages = min(xen_start_info->nr_pages, max_pfn); balloon_stats.target_pages = balloon_stats.current_pages; balloon_stats.balloon_low = 0; balloon_stats.balloon_high = 0; init_timer(&balloon_timer); balloon_timer.data = 0; balloon_timer.function = balloon_alarm; register_balloon(&balloon_sysdev); /* * Initialise the balloon with excess memory space. We need * to make sure we don't add memory which doesn't exist or * logically exist. The E820 map can be trimmed to be smaller * than the amount of physical memory due to the mem= command * line parameter. And if this is a 32-bit non-HIGHMEM kernel * on a system with memory which requires highmem to access, * don't try to use it. */ extra_pfn_end = min(min(max_pfn, e820_end_of_ram_pfn()), (unsigned long)PFN_DOWN(xen_extra_mem_start + xen_extra_mem_size)); for (pfn = PFN_UP(xen_extra_mem_start); pfn < extra_pfn_end; pfn++) { page = pfn_to_page(pfn); /* totalram_pages and totalhigh_pages do not include the boot-time balloon extension, so don't subtract from it. */ __balloon_append(page); } target_watch.callback = watch_target; xenstore_notifier.notifier_call = balloon_init_watcher; register_xenstore_notifier(&xenstore_notifier); return 0; }
static int __init balloon_init(void) { unsigned long pfn,num_physpages,max_pfn; struct page *page; if (!xen_domain()) return -ENODEV; pr_info("xen_balloon: Initialising balloon driver.\n"); num_physpages = get_num_physpages(); if (xen_pv_domain()) max_pfn = xen_start_info->nr_pages; else max_pfn = num_physpages; balloon_stats.current_pages = min(num_physpages,max_pfn); totalram_bias = balloon_stats.current_pages - totalram_pages; old_totalram_pages = totalram_pages; balloon_stats.target_pages = balloon_stats.current_pages; balloon_stats.balloon_low = 0; balloon_stats.balloon_high = 0; balloon_stats.driver_pages = 0UL; pr_info("current_pages=%luKB, totalram_pages=%luKB, totalram_bias=%luKB\n",balloon_stats.current_pages*4, totalram_pages*4, totalram_bias*4); init_timer(&balloon_timer); balloon_timer.data = 0; balloon_timer.function = balloon_alarm; register_balloon(&balloon_sysdev); /* Initialise the balloon with excess memory space. */ #ifdef CONFIG_PVM for (pfn = xen_start_info->nr_pages; pfn < max_pfn; pfn++) { page = pfn_to_page(pfn); if (!PageReserved(page)) balloon_append(page); } #endif target_watch.callback = watch_target; xenstore_notifier.notifier_call = balloon_init_watcher; register_xenstore_notifier(&xenstore_notifier); return 0; }
static int __init xenbus_probe_backend_init(void) { static struct notifier_block xenstore_notifier = { .notifier_call = backend_probe_and_watch }; int err; DPRINTK(""); /* Register ourselves with the kernel bus subsystem */ err = bus_register(&xenbus_backend.bus); if (err) return err; register_xenstore_notifier(&xenstore_notifier); return 0; }
static int __init balloon_init(void) { if (!xen_domain()) return -ENODEV; pr_info("xen-balloon: Initialising balloon driver.\n"); register_balloon(&balloon_sysdev); register_xen_selfballooning(&balloon_sysdev); target_watch.callback = watch_target; xenstore_notifier.notifier_call = balloon_init_watcher; register_xenstore_notifier(&xenstore_notifier); return 0; }
static int __init balloon_init(void) { unsigned long pfn; struct page *page; if (!xen_pv_domain()) return -ENODEV; pr_info("xen_balloon: Initialising balloon driver.\n"); balloon_stats.current_pages = min(xen_start_info->nr_pages, max_pfn); totalram_pages = balloon_stats.current_pages; balloon_stats.target_pages = balloon_stats.current_pages; balloon_stats.balloon_low = 0; balloon_stats.balloon_high = 0; balloon_stats.driver_pages = 0UL; balloon_stats.hard_limit = ~0UL; init_timer(&balloon_timer); balloon_timer.data = 0; balloon_timer.function = balloon_alarm; register_balloon(&balloon_sysdev); /* Initialise the balloon with excess memory space. */ for (pfn = xen_start_info->nr_pages; pfn < max_pfn; pfn++) { page = pfn_to_page(pfn); if (!PageReserved(page)) balloon_append(page); } target_watch.callback = watch_target; xenstore_notifier.notifier_call = balloon_init_watcher; register_xenstore_notifier(&xenstore_notifier); return 0; }