diff options
author | Ian Campbell <Ian.Campbell@citrix.com> | 2009-04-02 08:24:28 -0400 |
---|---|---|
committer | Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com> | 2009-04-08 17:25:51 -0400 |
commit | d745562cc40bff60f0597004d8128fa0225cc267 (patch) | |
tree | 28aedfeafde600301a3e27af2796f4c32d2b7323 /drivers/xen | |
parent | 2b2a733447b2bce5fef053df38412e4c0634ec22 (diff) |
xen: honour VCPU availability on boot
If a VM is booted with offline VCPUs then unplug them during boot. Determining
the availability of a VCPU requires access to XenStore which is not available
at the point smp_prepare_cpus() is called, therefore we bring up all VCPUS
initially and unplug the offline ones as soon as XenStore becomes available.
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Diffstat (limited to 'drivers/xen')
-rw-r--r-- | drivers/xen/cpu_hotplug.c | 40 |
1 files changed, 30 insertions, 10 deletions
diff --git a/drivers/xen/cpu_hotplug.c b/drivers/xen/cpu_hotplug.c index 5f54c01c1568..bdfd584ad853 100644 --- a/drivers/xen/cpu_hotplug.c +++ b/drivers/xen/cpu_hotplug.c | |||
@@ -21,29 +21,41 @@ static void disable_hotplug_cpu(int cpu) | |||
21 | set_cpu_present(cpu, false); | 21 | set_cpu_present(cpu, false); |
22 | } | 22 | } |
23 | 23 | ||
24 | static void vcpu_hotplug(unsigned int cpu) | 24 | static int vcpu_online(unsigned int cpu) |
25 | { | 25 | { |
26 | int err; | 26 | int err; |
27 | char dir[32], state[32]; | 27 | char dir[32], state[32]; |
28 | 28 | ||
29 | if (!cpu_possible(cpu)) | ||
30 | return; | ||
31 | |||
32 | sprintf(dir, "cpu/%u", cpu); | 29 | sprintf(dir, "cpu/%u", cpu); |
33 | err = xenbus_scanf(XBT_NIL, dir, "availability", "%s", state); | 30 | err = xenbus_scanf(XBT_NIL, dir, "availability", "%s", state); |
34 | if (err != 1) { | 31 | if (err != 1) { |
35 | printk(KERN_ERR "XENBUS: Unable to read cpu state\n"); | 32 | printk(KERN_ERR "XENBUS: Unable to read cpu state\n"); |
36 | return; | 33 | return err; |
37 | } | 34 | } |
38 | 35 | ||
39 | if (strcmp(state, "online") == 0) { | 36 | if (strcmp(state, "online") == 0) |
37 | return 1; | ||
38 | else if (strcmp(state, "offline") == 0) | ||
39 | return 0; | ||
40 | |||
41 | printk(KERN_ERR "XENBUS: unknown state(%s) on CPU%d\n", state, cpu); | ||
42 | return -EINVAL; | ||
43 | } | ||
44 | static void vcpu_hotplug(unsigned int cpu) | ||
45 | { | ||
46 | if (!cpu_possible(cpu)) | ||
47 | return; | ||
48 | |||
49 | switch (vcpu_online(cpu)) { | ||
50 | case 1: | ||
40 | enable_hotplug_cpu(cpu); | 51 | enable_hotplug_cpu(cpu); |
41 | } else if (strcmp(state, "offline") == 0) { | 52 | break; |
53 | case 0: | ||
42 | (void)cpu_down(cpu); | 54 | (void)cpu_down(cpu); |
43 | disable_hotplug_cpu(cpu); | 55 | disable_hotplug_cpu(cpu); |
44 | } else { | 56 | break; |
45 | printk(KERN_ERR "XENBUS: unknown state(%s) on CPU%d\n", | 57 | default: |
46 | state, cpu); | 58 | break; |
47 | } | 59 | } |
48 | } | 60 | } |
49 | 61 | ||
@@ -64,12 +76,20 @@ static void handle_vcpu_hotplug_event(struct xenbus_watch *watch, | |||
64 | static int setup_cpu_watcher(struct notifier_block *notifier, | 76 | static int setup_cpu_watcher(struct notifier_block *notifier, |
65 | unsigned long event, void *data) | 77 | unsigned long event, void *data) |
66 | { | 78 | { |
79 | int cpu; | ||
67 | static struct xenbus_watch cpu_watch = { | 80 | static struct xenbus_watch cpu_watch = { |
68 | .node = "cpu", | 81 | .node = "cpu", |
69 | .callback = handle_vcpu_hotplug_event}; | 82 | .callback = handle_vcpu_hotplug_event}; |
70 | 83 | ||
71 | (void)register_xenbus_watch(&cpu_watch); | 84 | (void)register_xenbus_watch(&cpu_watch); |
72 | 85 | ||
86 | for_each_possible_cpu(cpu) { | ||
87 | if (vcpu_online(cpu) == 0) { | ||
88 | (void)cpu_down(cpu); | ||
89 | cpu_clear(cpu, cpu_present_map); | ||
90 | } | ||
91 | } | ||
92 | |||
73 | return NOTIFY_DONE; | 93 | return NOTIFY_DONE; |
74 | } | 94 | } |
75 | 95 | ||