diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2011-03-15 13:59:09 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-03-15 13:59:09 -0400 |
commit | 76ca07832842100b14a31ad8996dab7b0c28aa42 (patch) | |
tree | 496df81083fda9be38f8ff88cdc3ef59c2d72a8d /drivers | |
parent | 27d2a8b97ebc4467e47722415b81ebe72d5f654f (diff) | |
parent | b056b6a0144de90707cd22cf7b4f60bf69c86d59 (diff) |
Merge branch 'for-linus' of git://xenbits.xen.org/people/sstabellini/linux-pvhvm
* 'for-linus' of git://xenbits.xen.org/people/sstabellini/linux-pvhvm:
xen: suspend: remove xen_hvm_suspend
xen: suspend: pull pre/post suspend hooks out into suspend_info
xen: suspend: move arch specific pre/post suspend hooks into generic hooks
xen: suspend: refactor non-arch specific pre/post suspend hooks
xen: suspend: add "arch" to pre/post suspend hooks
xen: suspend: pass extra hypercall argument via suspend_info struct
xen: suspend: refactor cancellation flag into a structure
xen: suspend: use HYPERVISOR_suspend for PVHVM case instead of open coding
xen: switch to new schedop hypercall by default.
xen: use new schedop interface for suspend
xen: do not respond to unknown xenstore control requests
xen: fix compile issue if XEN is enabled but XEN_PVHVM is disabled
xen: PV on HVM: support PV spinlocks and IPIs
xen: make the ballon driver work for hvm domains
xen-blkfront: handle Xen major numbers other than XENVBD
xen: do not use xen_info on HVM, set pv_info name to "Xen HVM"
xen: no need to delay xen_setup_shutdown_event for hvm guests anymore
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/block/xen-blkfront.c | 79 | ||||
-rw-r--r-- | drivers/xen/balloon.c | 14 | ||||
-rw-r--r-- | drivers/xen/manage.c | 153 | ||||
-rw-r--r-- | drivers/xen/platform-pci.c | 3 |
4 files changed, 169 insertions, 80 deletions
diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c index cc4514c9d8a6..9cb8668ff5f4 100644 --- a/drivers/block/xen-blkfront.c +++ b/drivers/block/xen-blkfront.c | |||
@@ -120,6 +120,10 @@ static DEFINE_SPINLOCK(minor_lock); | |||
120 | #define EXTENDED (1<<EXT_SHIFT) | 120 | #define EXTENDED (1<<EXT_SHIFT) |
121 | #define VDEV_IS_EXTENDED(dev) ((dev)&(EXTENDED)) | 121 | #define VDEV_IS_EXTENDED(dev) ((dev)&(EXTENDED)) |
122 | #define BLKIF_MINOR_EXT(dev) ((dev)&(~EXTENDED)) | 122 | #define BLKIF_MINOR_EXT(dev) ((dev)&(~EXTENDED)) |
123 | #define EMULATED_HD_DISK_MINOR_OFFSET (0) | ||
124 | #define EMULATED_HD_DISK_NAME_OFFSET (EMULATED_HD_DISK_MINOR_OFFSET / 256) | ||
125 | #define EMULATED_SD_DISK_MINOR_OFFSET (EMULATED_HD_DISK_MINOR_OFFSET + (4 * 16)) | ||
126 | #define EMULATED_SD_DISK_NAME_OFFSET (EMULATED_HD_DISK_NAME_OFFSET + 4) | ||
123 | 127 | ||
124 | #define DEV_NAME "xvd" /* name in /dev */ | 128 | #define DEV_NAME "xvd" /* name in /dev */ |
125 | 129 | ||
@@ -434,6 +438,65 @@ static void xlvbd_flush(struct blkfront_info *info) | |||
434 | info->feature_flush ? "enabled" : "disabled"); | 438 | info->feature_flush ? "enabled" : "disabled"); |
435 | } | 439 | } |
436 | 440 | ||
441 | static int xen_translate_vdev(int vdevice, int *minor, unsigned int *offset) | ||
442 | { | ||
443 | int major; | ||
444 | major = BLKIF_MAJOR(vdevice); | ||
445 | *minor = BLKIF_MINOR(vdevice); | ||
446 | switch (major) { | ||
447 | case XEN_IDE0_MAJOR: | ||
448 | *offset = (*minor / 64) + EMULATED_HD_DISK_NAME_OFFSET; | ||
449 | *minor = ((*minor / 64) * PARTS_PER_DISK) + | ||
450 | EMULATED_HD_DISK_MINOR_OFFSET; | ||
451 | break; | ||
452 | case XEN_IDE1_MAJOR: | ||
453 | *offset = (*minor / 64) + 2 + EMULATED_HD_DISK_NAME_OFFSET; | ||
454 | *minor = (((*minor / 64) + 2) * PARTS_PER_DISK) + | ||
455 | EMULATED_HD_DISK_MINOR_OFFSET; | ||
456 | break; | ||
457 | case XEN_SCSI_DISK0_MAJOR: | ||
458 | *offset = (*minor / PARTS_PER_DISK) + EMULATED_SD_DISK_NAME_OFFSET; | ||
459 | *minor = *minor + EMULATED_SD_DISK_MINOR_OFFSET; | ||
460 | break; | ||
461 | case XEN_SCSI_DISK1_MAJOR: | ||
462 | case XEN_SCSI_DISK2_MAJOR: | ||
463 | case XEN_SCSI_DISK3_MAJOR: | ||
464 | case XEN_SCSI_DISK4_MAJOR: | ||
465 | case XEN_SCSI_DISK5_MAJOR: | ||
466 | case XEN_SCSI_DISK6_MAJOR: | ||
467 | case XEN_SCSI_DISK7_MAJOR: | ||
468 | *offset = (*minor / PARTS_PER_DISK) + | ||
469 | ((major - XEN_SCSI_DISK1_MAJOR + 1) * 16) + | ||
470 | EMULATED_SD_DISK_NAME_OFFSET; | ||
471 | *minor = *minor + | ||
472 | ((major - XEN_SCSI_DISK1_MAJOR + 1) * 16 * PARTS_PER_DISK) + | ||
473 | EMULATED_SD_DISK_MINOR_OFFSET; | ||
474 | break; | ||
475 | case XEN_SCSI_DISK8_MAJOR: | ||
476 | case XEN_SCSI_DISK9_MAJOR: | ||
477 | case XEN_SCSI_DISK10_MAJOR: | ||
478 | case XEN_SCSI_DISK11_MAJOR: | ||
479 | case XEN_SCSI_DISK12_MAJOR: | ||
480 | case XEN_SCSI_DISK13_MAJOR: | ||
481 | case XEN_SCSI_DISK14_MAJOR: | ||
482 | case XEN_SCSI_DISK15_MAJOR: | ||
483 | *offset = (*minor / PARTS_PER_DISK) + | ||
484 | ((major - XEN_SCSI_DISK8_MAJOR + 8) * 16) + | ||
485 | EMULATED_SD_DISK_NAME_OFFSET; | ||
486 | *minor = *minor + | ||
487 | ((major - XEN_SCSI_DISK8_MAJOR + 8) * 16 * PARTS_PER_DISK) + | ||
488 | EMULATED_SD_DISK_MINOR_OFFSET; | ||
489 | break; | ||
490 | case XENVBD_MAJOR: | ||
491 | *offset = *minor / PARTS_PER_DISK; | ||
492 | break; | ||
493 | default: | ||
494 | printk(KERN_WARNING "blkfront: your disk configuration is " | ||
495 | "incorrect, please use an xvd device instead\n"); | ||
496 | return -ENODEV; | ||
497 | } | ||
498 | return 0; | ||
499 | } | ||
437 | 500 | ||
438 | static int xlvbd_alloc_gendisk(blkif_sector_t capacity, | 501 | static int xlvbd_alloc_gendisk(blkif_sector_t capacity, |
439 | struct blkfront_info *info, | 502 | struct blkfront_info *info, |
@@ -441,7 +504,7 @@ static int xlvbd_alloc_gendisk(blkif_sector_t capacity, | |||
441 | { | 504 | { |
442 | struct gendisk *gd; | 505 | struct gendisk *gd; |
443 | int nr_minors = 1; | 506 | int nr_minors = 1; |
444 | int err = -ENODEV; | 507 | int err; |
445 | unsigned int offset; | 508 | unsigned int offset; |
446 | int minor; | 509 | int minor; |
447 | int nr_parts; | 510 | int nr_parts; |
@@ -456,12 +519,20 @@ static int xlvbd_alloc_gendisk(blkif_sector_t capacity, | |||
456 | } | 519 | } |
457 | 520 | ||
458 | if (!VDEV_IS_EXTENDED(info->vdevice)) { | 521 | if (!VDEV_IS_EXTENDED(info->vdevice)) { |
459 | minor = BLKIF_MINOR(info->vdevice); | 522 | err = xen_translate_vdev(info->vdevice, &minor, &offset); |
460 | nr_parts = PARTS_PER_DISK; | 523 | if (err) |
524 | return err; | ||
525 | nr_parts = PARTS_PER_DISK; | ||
461 | } else { | 526 | } else { |
462 | minor = BLKIF_MINOR_EXT(info->vdevice); | 527 | minor = BLKIF_MINOR_EXT(info->vdevice); |
463 | nr_parts = PARTS_PER_EXT_DISK; | 528 | nr_parts = PARTS_PER_EXT_DISK; |
529 | offset = minor / nr_parts; | ||
530 | if (xen_hvm_domain() && offset <= EMULATED_HD_DISK_NAME_OFFSET + 4) | ||
531 | printk(KERN_WARNING "blkfront: vdevice 0x%x might conflict with " | ||
532 | "emulated IDE disks,\n\t choose an xvd device name" | ||
533 | "from xvde on\n", info->vdevice); | ||
464 | } | 534 | } |
535 | err = -ENODEV; | ||
465 | 536 | ||
466 | if ((minor % nr_parts) == 0) | 537 | if ((minor % nr_parts) == 0) |
467 | nr_minors = nr_parts; | 538 | nr_minors = nr_parts; |
@@ -475,8 +546,6 @@ static int xlvbd_alloc_gendisk(blkif_sector_t capacity, | |||
475 | if (gd == NULL) | 546 | if (gd == NULL) |
476 | goto release; | 547 | goto release; |
477 | 548 | ||
478 | offset = minor / nr_parts; | ||
479 | |||
480 | if (nr_minors > 1) { | 549 | if (nr_minors > 1) { |
481 | if (offset < 26) | 550 | if (offset < 26) |
482 | sprintf(gd->disk_name, "%s%c", DEV_NAME, 'a' + offset); | 551 | sprintf(gd->disk_name, "%s%c", DEV_NAME, 'a' + offset); |
diff --git a/drivers/xen/balloon.c b/drivers/xen/balloon.c index b1661cd416b0..718050ace08f 100644 --- a/drivers/xen/balloon.c +++ b/drivers/xen/balloon.c | |||
@@ -232,7 +232,7 @@ static int increase_reservation(unsigned long nr_pages) | |||
232 | set_phys_to_machine(pfn, frame_list[i]); | 232 | set_phys_to_machine(pfn, frame_list[i]); |
233 | 233 | ||
234 | /* Link back into the page tables if not highmem. */ | 234 | /* Link back into the page tables if not highmem. */ |
235 | if (pfn < max_low_pfn) { | 235 | if (!xen_hvm_domain() && pfn < max_low_pfn) { |
236 | int ret; | 236 | int ret; |
237 | ret = HYPERVISOR_update_va_mapping( | 237 | ret = HYPERVISOR_update_va_mapping( |
238 | (unsigned long)__va(pfn << PAGE_SHIFT), | 238 | (unsigned long)__va(pfn << PAGE_SHIFT), |
@@ -280,7 +280,7 @@ static int decrease_reservation(unsigned long nr_pages) | |||
280 | 280 | ||
281 | scrub_page(page); | 281 | scrub_page(page); |
282 | 282 | ||
283 | if (!PageHighMem(page)) { | 283 | if (!xen_hvm_domain() && !PageHighMem(page)) { |
284 | ret = HYPERVISOR_update_va_mapping( | 284 | ret = HYPERVISOR_update_va_mapping( |
285 | (unsigned long)__va(pfn << PAGE_SHIFT), | 285 | (unsigned long)__va(pfn << PAGE_SHIFT), |
286 | __pte_ma(0), 0); | 286 | __pte_ma(0), 0); |
@@ -392,15 +392,19 @@ static struct notifier_block xenstore_notifier; | |||
392 | 392 | ||
393 | static int __init balloon_init(void) | 393 | static int __init balloon_init(void) |
394 | { | 394 | { |
395 | unsigned long pfn, extra_pfn_end; | 395 | unsigned long pfn, nr_pages, extra_pfn_end; |
396 | struct page *page; | 396 | struct page *page; |
397 | 397 | ||
398 | if (!xen_pv_domain()) | 398 | if (!xen_domain()) |
399 | return -ENODEV; | 399 | return -ENODEV; |
400 | 400 | ||
401 | pr_info("xen_balloon: Initialising balloon driver.\n"); | 401 | pr_info("xen_balloon: Initialising balloon driver.\n"); |
402 | 402 | ||
403 | balloon_stats.current_pages = min(xen_start_info->nr_pages, max_pfn); | 403 | if (xen_pv_domain()) |
404 | nr_pages = xen_start_info->nr_pages; | ||
405 | else | ||
406 | nr_pages = max_pfn; | ||
407 | balloon_stats.current_pages = min(nr_pages, max_pfn); | ||
404 | balloon_stats.target_pages = balloon_stats.current_pages; | 408 | balloon_stats.target_pages = balloon_stats.current_pages; |
405 | balloon_stats.balloon_low = 0; | 409 | balloon_stats.balloon_low = 0; |
406 | balloon_stats.balloon_high = 0; | 410 | balloon_stats.balloon_high = 0; |
diff --git a/drivers/xen/manage.c b/drivers/xen/manage.c index 24177272bcb8..ebb292859b59 100644 --- a/drivers/xen/manage.c +++ b/drivers/xen/manage.c | |||
@@ -34,42 +34,38 @@ enum shutdown_state { | |||
34 | /* Ignore multiple shutdown requests. */ | 34 | /* Ignore multiple shutdown requests. */ |
35 | static enum shutdown_state shutting_down = SHUTDOWN_INVALID; | 35 | static enum shutdown_state shutting_down = SHUTDOWN_INVALID; |
36 | 36 | ||
37 | #ifdef CONFIG_PM_SLEEP | 37 | struct suspend_info { |
38 | static int xen_hvm_suspend(void *data) | 38 | int cancelled; |
39 | { | 39 | unsigned long arg; /* extra hypercall argument */ |
40 | int err; | 40 | void (*pre)(void); |
41 | struct sched_shutdown r = { .reason = SHUTDOWN_suspend }; | 41 | void (*post)(int cancelled); |
42 | int *cancelled = data; | 42 | }; |
43 | |||
44 | BUG_ON(!irqs_disabled()); | ||
45 | |||
46 | err = sysdev_suspend(PMSG_SUSPEND); | ||
47 | if (err) { | ||
48 | printk(KERN_ERR "xen_hvm_suspend: sysdev_suspend failed: %d\n", | ||
49 | err); | ||
50 | return err; | ||
51 | } | ||
52 | |||
53 | *cancelled = HYPERVISOR_sched_op(SCHEDOP_shutdown, &r); | ||
54 | 43 | ||
55 | xen_hvm_post_suspend(*cancelled); | 44 | static void xen_hvm_post_suspend(int cancelled) |
45 | { | ||
46 | xen_arch_hvm_post_suspend(cancelled); | ||
56 | gnttab_resume(); | 47 | gnttab_resume(); |
48 | } | ||
57 | 49 | ||
58 | if (!*cancelled) { | 50 | static void xen_pre_suspend(void) |
59 | xen_irq_resume(); | 51 | { |
60 | xen_console_resume(); | 52 | xen_mm_pin_all(); |
61 | xen_timer_resume(); | 53 | gnttab_suspend(); |
62 | } | 54 | xen_arch_pre_suspend(); |
63 | 55 | } | |
64 | sysdev_resume(); | ||
65 | 56 | ||
66 | return 0; | 57 | static void xen_post_suspend(int cancelled) |
58 | { | ||
59 | xen_arch_post_suspend(cancelled); | ||
60 | gnttab_resume(); | ||
61 | xen_mm_unpin_all(); | ||
67 | } | 62 | } |
68 | 63 | ||
64 | #ifdef CONFIG_PM_SLEEP | ||
69 | static int xen_suspend(void *data) | 65 | static int xen_suspend(void *data) |
70 | { | 66 | { |
67 | struct suspend_info *si = data; | ||
71 | int err; | 68 | int err; |
72 | int *cancelled = data; | ||
73 | 69 | ||
74 | BUG_ON(!irqs_disabled()); | 70 | BUG_ON(!irqs_disabled()); |
75 | 71 | ||
@@ -80,22 +76,20 @@ static int xen_suspend(void *data) | |||
80 | return err; | 76 | return err; |
81 | } | 77 | } |
82 | 78 | ||
83 | xen_mm_pin_all(); | 79 | if (si->pre) |
84 | gnttab_suspend(); | 80 | si->pre(); |
85 | xen_pre_suspend(); | ||
86 | 81 | ||
87 | /* | 82 | /* |
88 | * This hypercall returns 1 if suspend was cancelled | 83 | * This hypercall returns 1 if suspend was cancelled |
89 | * or the domain was merely checkpointed, and 0 if it | 84 | * or the domain was merely checkpointed, and 0 if it |
90 | * is resuming in a new domain. | 85 | * is resuming in a new domain. |
91 | */ | 86 | */ |
92 | *cancelled = HYPERVISOR_suspend(virt_to_mfn(xen_start_info)); | 87 | si->cancelled = HYPERVISOR_suspend(si->arg); |
93 | 88 | ||
94 | xen_post_suspend(*cancelled); | 89 | if (si->post) |
95 | gnttab_resume(); | 90 | si->post(si->cancelled); |
96 | xen_mm_unpin_all(); | ||
97 | 91 | ||
98 | if (!*cancelled) { | 92 | if (!si->cancelled) { |
99 | xen_irq_resume(); | 93 | xen_irq_resume(); |
100 | xen_console_resume(); | 94 | xen_console_resume(); |
101 | xen_timer_resume(); | 95 | xen_timer_resume(); |
@@ -109,7 +103,7 @@ static int xen_suspend(void *data) | |||
109 | static void do_suspend(void) | 103 | static void do_suspend(void) |
110 | { | 104 | { |
111 | int err; | 105 | int err; |
112 | int cancelled = 1; | 106 | struct suspend_info si; |
113 | 107 | ||
114 | shutting_down = SHUTDOWN_SUSPEND; | 108 | shutting_down = SHUTDOWN_SUSPEND; |
115 | 109 | ||
@@ -139,20 +133,29 @@ static void do_suspend(void) | |||
139 | goto out_resume; | 133 | goto out_resume; |
140 | } | 134 | } |
141 | 135 | ||
142 | if (xen_hvm_domain()) | 136 | si.cancelled = 1; |
143 | err = stop_machine(xen_hvm_suspend, &cancelled, cpumask_of(0)); | 137 | |
144 | else | 138 | if (xen_hvm_domain()) { |
145 | err = stop_machine(xen_suspend, &cancelled, cpumask_of(0)); | 139 | si.arg = 0UL; |
140 | si.pre = NULL; | ||
141 | si.post = &xen_hvm_post_suspend; | ||
142 | } else { | ||
143 | si.arg = virt_to_mfn(xen_start_info); | ||
144 | si.pre = &xen_pre_suspend; | ||
145 | si.post = &xen_post_suspend; | ||
146 | } | ||
147 | |||
148 | err = stop_machine(xen_suspend, &si, cpumask_of(0)); | ||
146 | 149 | ||
147 | dpm_resume_noirq(PMSG_RESUME); | 150 | dpm_resume_noirq(PMSG_RESUME); |
148 | 151 | ||
149 | if (err) { | 152 | if (err) { |
150 | printk(KERN_ERR "failed to start xen_suspend: %d\n", err); | 153 | printk(KERN_ERR "failed to start xen_suspend: %d\n", err); |
151 | cancelled = 1; | 154 | si.cancelled = 1; |
152 | } | 155 | } |
153 | 156 | ||
154 | out_resume: | 157 | out_resume: |
155 | if (!cancelled) { | 158 | if (!si.cancelled) { |
156 | xen_arch_resume(); | 159 | xen_arch_resume(); |
157 | xs_resume(); | 160 | xs_resume(); |
158 | } else | 161 | } else |
@@ -172,12 +175,39 @@ out: | |||
172 | } | 175 | } |
173 | #endif /* CONFIG_PM_SLEEP */ | 176 | #endif /* CONFIG_PM_SLEEP */ |
174 | 177 | ||
178 | struct shutdown_handler { | ||
179 | const char *command; | ||
180 | void (*cb)(void); | ||
181 | }; | ||
182 | |||
183 | static void do_poweroff(void) | ||
184 | { | ||
185 | shutting_down = SHUTDOWN_POWEROFF; | ||
186 | orderly_poweroff(false); | ||
187 | } | ||
188 | |||
189 | static void do_reboot(void) | ||
190 | { | ||
191 | shutting_down = SHUTDOWN_POWEROFF; /* ? */ | ||
192 | ctrl_alt_del(); | ||
193 | } | ||
194 | |||
175 | static void shutdown_handler(struct xenbus_watch *watch, | 195 | static void shutdown_handler(struct xenbus_watch *watch, |
176 | const char **vec, unsigned int len) | 196 | const char **vec, unsigned int len) |
177 | { | 197 | { |
178 | char *str; | 198 | char *str; |
179 | struct xenbus_transaction xbt; | 199 | struct xenbus_transaction xbt; |
180 | int err; | 200 | int err; |
201 | static struct shutdown_handler handlers[] = { | ||
202 | { "poweroff", do_poweroff }, | ||
203 | { "halt", do_poweroff }, | ||
204 | { "reboot", do_reboot }, | ||
205 | #ifdef CONFIG_PM_SLEEP | ||
206 | { "suspend", do_suspend }, | ||
207 | #endif | ||
208 | {NULL, NULL}, | ||
209 | }; | ||
210 | static struct shutdown_handler *handler; | ||
181 | 211 | ||
182 | if (shutting_down != SHUTDOWN_INVALID) | 212 | if (shutting_down != SHUTDOWN_INVALID) |
183 | return; | 213 | return; |
@@ -194,7 +224,14 @@ static void shutdown_handler(struct xenbus_watch *watch, | |||
194 | return; | 224 | return; |
195 | } | 225 | } |
196 | 226 | ||
197 | xenbus_write(xbt, "control", "shutdown", ""); | 227 | for (handler = &handlers[0]; handler->command; handler++) { |
228 | if (strcmp(str, handler->command) == 0) | ||
229 | break; | ||
230 | } | ||
231 | |||
232 | /* Only acknowledge commands which we are prepared to handle. */ | ||
233 | if (handler->cb) | ||
234 | xenbus_write(xbt, "control", "shutdown", ""); | ||
198 | 235 | ||
199 | err = xenbus_transaction_end(xbt, 0); | 236 | err = xenbus_transaction_end(xbt, 0); |
200 | if (err == -EAGAIN) { | 237 | if (err == -EAGAIN) { |
@@ -202,17 +239,8 @@ static void shutdown_handler(struct xenbus_watch *watch, | |||
202 | goto again; | 239 | goto again; |
203 | } | 240 | } |
204 | 241 | ||
205 | if (strcmp(str, "poweroff") == 0 || | 242 | if (handler->cb) { |
206 | strcmp(str, "halt") == 0) { | 243 | handler->cb(); |
207 | shutting_down = SHUTDOWN_POWEROFF; | ||
208 | orderly_poweroff(false); | ||
209 | } else if (strcmp(str, "reboot") == 0) { | ||
210 | shutting_down = SHUTDOWN_POWEROFF; /* ? */ | ||
211 | ctrl_alt_del(); | ||
212 | #ifdef CONFIG_PM_SLEEP | ||
213 | } else if (strcmp(str, "suspend") == 0) { | ||
214 | do_suspend(); | ||
215 | #endif | ||
216 | } else { | 244 | } else { |
217 | printk(KERN_INFO "Ignoring shutdown request: %s\n", str); | 245 | printk(KERN_INFO "Ignoring shutdown request: %s\n", str); |
218 | shutting_down = SHUTDOWN_INVALID; | 246 | shutting_down = SHUTDOWN_INVALID; |
@@ -291,27 +319,18 @@ static int shutdown_event(struct notifier_block *notifier, | |||
291 | return NOTIFY_DONE; | 319 | return NOTIFY_DONE; |
292 | } | 320 | } |
293 | 321 | ||
294 | static int __init __setup_shutdown_event(void) | ||
295 | { | ||
296 | /* Delay initialization in the PV on HVM case */ | ||
297 | if (xen_hvm_domain()) | ||
298 | return 0; | ||
299 | |||
300 | if (!xen_pv_domain()) | ||
301 | return -ENODEV; | ||
302 | |||
303 | return xen_setup_shutdown_event(); | ||
304 | } | ||
305 | |||
306 | int xen_setup_shutdown_event(void) | 322 | int xen_setup_shutdown_event(void) |
307 | { | 323 | { |
308 | static struct notifier_block xenstore_notifier = { | 324 | static struct notifier_block xenstore_notifier = { |
309 | .notifier_call = shutdown_event | 325 | .notifier_call = shutdown_event |
310 | }; | 326 | }; |
327 | |||
328 | if (!xen_domain()) | ||
329 | return -ENODEV; | ||
311 | register_xenstore_notifier(&xenstore_notifier); | 330 | register_xenstore_notifier(&xenstore_notifier); |
312 | 331 | ||
313 | return 0; | 332 | return 0; |
314 | } | 333 | } |
315 | EXPORT_SYMBOL_GPL(xen_setup_shutdown_event); | 334 | EXPORT_SYMBOL_GPL(xen_setup_shutdown_event); |
316 | 335 | ||
317 | subsys_initcall(__setup_shutdown_event); | 336 | subsys_initcall(xen_setup_shutdown_event); |
diff --git a/drivers/xen/platform-pci.c b/drivers/xen/platform-pci.c index afbe041f42c5..319dd0a94d51 100644 --- a/drivers/xen/platform-pci.c +++ b/drivers/xen/platform-pci.c | |||
@@ -156,9 +156,6 @@ static int __devinit platform_pci_init(struct pci_dev *pdev, | |||
156 | if (ret) | 156 | if (ret) |
157 | goto out; | 157 | goto out; |
158 | xenbus_probe(NULL); | 158 | xenbus_probe(NULL); |
159 | ret = xen_setup_shutdown_event(); | ||
160 | if (ret) | ||
161 | goto out; | ||
162 | return 0; | 159 | return 0; |
163 | 160 | ||
164 | out: | 161 | out: |