direct-io.hg

changeset 7419:bd1298cf0b4d

Remove 'n_vcpu' field from start_info structure. Domain0
simply creates a CPU on every physical CPU. Other domains
read the initial VCPU configuration from xenstore.

Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Tue Oct 18 19:02:14 2005 +0100 (2005-10-18)
parents 6ef7386f7370
children 3233e3921fdd
files linux-2.6-xen-sparse/arch/xen/kernel/smpboot.c tools/libxc/xc_linux_build.c tools/libxc/xenguest.h tools/python/xen/lowlevel/xc/xc.c tools/python/xen/xend/image.py xen/arch/x86/domain_build.c xen/include/public/xen.h
line diff
     1.1 --- a/linux-2.6-xen-sparse/arch/xen/kernel/smpboot.c	Tue Oct 18 18:07:11 2005 +0100
     1.2 +++ b/linux-2.6-xen-sparse/arch/xen/kernel/smpboot.c	Tue Oct 18 19:02:14 2005 +0100
     1.3 @@ -186,20 +186,20 @@ void vcpu_prepare(int vcpu)
     1.4  
     1.5  void __init smp_prepare_cpus(unsigned int max_cpus)
     1.6  {
     1.7 -	int cpu;
     1.8 +	int cpu, rc;
     1.9  	struct task_struct *idle;
    1.10  
    1.11 -	if (max_cpus == 0) {
    1.12 -		xen_start_info->n_vcpu = 1;
    1.13 +	if (max_cpus == 0)
    1.14  		return;
    1.15 -	}
    1.16 -
    1.17 -	if (max_cpus < xen_start_info->n_vcpu)
    1.18 -		xen_start_info->n_vcpu = max_cpus;
    1.19  
    1.20  	xen_smp_intr_init(0);
    1.21  
    1.22 -	for (cpu = 1; cpu < xen_start_info->n_vcpu; cpu++) {
    1.23 +	for (cpu = 1; cpu < max_cpus; cpu++) {
    1.24 +		rc = HYPERVISOR_vcpu_op(VCPUOP_is_up, cpu, NULL);
    1.25 +		if (rc == -ENOENT)
    1.26 +			break;
    1.27 +		BUG_ON(rc != 0);
    1.28 +
    1.29  		cpu_data[cpu] = boot_cpu_data;
    1.30  		cpu_2_logical_apicid[cpu] = cpu;
    1.31  		x86_cpu_to_apicid[cpu] = cpu;
    1.32 @@ -220,6 +220,8 @@ void __init smp_prepare_cpus(unsigned in
    1.33  		make_page_readonly((void *)cpu_gdt_descr[cpu].address);
    1.34  
    1.35  		cpu_set(cpu, cpu_possible_map);
    1.36 +		if (xen_start_info->flags & SIF_INITDOMAIN)
    1.37 +			cpu_set(cpu, cpu_present_map);
    1.38  
    1.39  		vcpu_prepare(cpu);
    1.40  	}
    1.41 @@ -243,6 +245,7 @@ void __init smp_prepare_cpus(unsigned in
    1.42  void __devinit smp_prepare_boot_cpu(void)
    1.43  {
    1.44  	cpu_possible_map = cpumask_of_cpu(0);
    1.45 +	cpu_present_map  = cpumask_of_cpu(0);
    1.46  	cpu_online_map   = cpumask_of_cpu(0);
    1.47  
    1.48  	cpu_data[0] = boot_cpu_data;
    1.49 @@ -257,21 +260,14 @@ void __devinit smp_prepare_boot_cpu(void
    1.50  	cpu_set(0, cpu_core_map[0]);
    1.51  }
    1.52  
    1.53 -#ifdef CONFIG_HOTPLUG_CPU
    1.54 -
    1.55 -static void handle_vcpu_hotplug_event(
    1.56 -	struct xenbus_watch *watch, const char **vec, unsigned int len)
    1.57 +static void vcpu_hotplug(unsigned int cpu)
    1.58  {
    1.59 -	int err, cpu;
    1.60 +	int err;
    1.61  	char dir[32], state[32];
    1.62 -	char *cpustr;
    1.63 -	const char *node = vec[XS_WATCH_PATH];
    1.64  
    1.65 -	if ((cpustr = strstr(node, "cpu/")) == NULL)
    1.66 +	if ((cpu >= NR_CPUS) || !cpu_possible(cpu))
    1.67  		return;
    1.68  
    1.69 -	sscanf(cpustr, "cpu/%d", &cpu);
    1.70 -
    1.71  	sprintf(dir, "cpu/%d", cpu);
    1.72  	err = xenbus_scanf(NULL, dir, "availability", "%s", state);
    1.73  	if (err != 1) {
    1.74 @@ -279,22 +275,49 @@ static void handle_vcpu_hotplug_event(
    1.75  		return;
    1.76  	}
    1.77  
    1.78 -	if (strcmp(state, "online") == 0)
    1.79 +	if (strcmp(state, "online") == 0) {
    1.80 +		cpu_set(cpu, cpu_present_map);
    1.81  		(void)cpu_up(cpu);
    1.82 -	else if (strcmp(state, "offline") == 0)
    1.83 +	} else if (strcmp(state, "offline") == 0) {
    1.84 +#ifdef CONFIG_HOTPLUG_CPU
    1.85  		(void)cpu_down(cpu);
    1.86 -	else
    1.87 -		printk(KERN_ERR "XENBUS: unknown state(%s) on node(%s)\n",
    1.88 -		       state, node);
    1.89 +#else
    1.90 +		printk(KERN_INFO "Ignoring CPU%d hotplug request\n", cpu);
    1.91 +#endif
    1.92 +	} else {
    1.93 +		printk(KERN_ERR "XENBUS: unknown state(%s) on CPU%d\n",
    1.94 +		       state, cpu);
    1.95 +	}
    1.96 +}
    1.97 +
    1.98 +static void handle_vcpu_hotplug_event(
    1.99 +	struct xenbus_watch *watch, const char **vec, unsigned int len)
   1.100 +{
   1.101 +	int cpu;
   1.102 +	char *cpustr;
   1.103 +	const char *node = vec[XS_WATCH_PATH];
   1.104 +
   1.105 +	if ((cpustr = strstr(node, "cpu/")) != NULL) {
   1.106 +		sscanf(cpustr, "cpu/%d", &cpu);
   1.107 +		vcpu_hotplug(cpu);
   1.108 +	}
   1.109  }
   1.110  
   1.111  static int setup_cpu_watcher(struct notifier_block *notifier,
   1.112  			      unsigned long event, void *data)
   1.113  {
   1.114 +	int i;
   1.115 +
   1.116  	static struct xenbus_watch cpu_watch = {
   1.117  		.node = "cpu",
   1.118  		.callback = handle_vcpu_hotplug_event };
   1.119  	(void)register_xenbus_watch(&cpu_watch);
   1.120 +
   1.121 +	for_each_cpu(i)
   1.122 +		vcpu_hotplug(i);
   1.123 +
   1.124 +	printk(KERN_INFO "Brought up %ld CPUs\n", (long)num_online_cpus());
   1.125 +
   1.126  	return NOTIFY_DONE;
   1.127  }
   1.128  
   1.129 @@ -308,6 +331,8 @@ static int __init setup_vcpu_hotplug_eve
   1.130  
   1.131  subsys_initcall(setup_vcpu_hotplug_event);
   1.132  
   1.133 +#ifdef CONFIG_HOTPLUG_CPU
   1.134 +
   1.135  int __cpu_disable(void)
   1.136  {
   1.137  	cpumask_t map = cpu_online_map;
   1.138 @@ -338,7 +363,7 @@ void __cpu_die(unsigned int cpu)
   1.139  #endif
   1.140  }
   1.141  
   1.142 -#else /* ... !CONFIG_HOTPLUG_CPU */
   1.143 +#else /* !CONFIG_HOTPLUG_CPU */
   1.144  
   1.145  int __cpu_disable(void)
   1.146  {
     2.1 --- a/tools/libxc/xc_linux_build.c	Tue Oct 18 18:07:11 2005 +0100
     2.2 +++ b/tools/libxc/xc_linux_build.c	Tue Oct 18 19:02:14 2005 +0100
     2.3 @@ -289,7 +289,6 @@ static int setup_guest(int xc_handle,
     2.4                         const char *cmdline,
     2.5                         unsigned long shared_info_frame,
     2.6                         unsigned long flags,
     2.7 -                       unsigned int vcpus,
     2.8                         unsigned int store_evtchn, unsigned long *store_mfn,
     2.9                         unsigned int console_evtchn, unsigned long *console_mfn)
    2.10  {
    2.11 @@ -376,7 +375,6 @@ static int setup_guest(int xc_handle,
    2.12                         const char *cmdline,
    2.13                         unsigned long shared_info_frame,
    2.14                         unsigned long flags,
    2.15 -                       unsigned int vcpus,
    2.16                         unsigned int store_evtchn, unsigned long *store_mfn,
    2.17                         unsigned int console_evtchn, unsigned long *console_mfn)
    2.18  {
    2.19 @@ -636,7 +634,6 @@ static int setup_guest(int xc_handle,
    2.20      start_info->store_evtchn = store_evtchn;
    2.21      start_info->console_mfn   = *console_mfn;
    2.22      start_info->console_evtchn = console_evtchn;
    2.23 -    start_info->n_vcpu       = vcpus;
    2.24      if ( initrd_len != 0 )
    2.25      {
    2.26          start_info->mod_start    = vinitrd_start;
    2.27 @@ -682,7 +679,6 @@ int xc_linux_build(int xc_handle,
    2.28                     const char *ramdisk_name,
    2.29                     const char *cmdline,
    2.30                     unsigned long flags,
    2.31 -                   unsigned int vcpus,
    2.32                     unsigned int store_evtchn,
    2.33                     unsigned long *store_mfn,
    2.34                     unsigned int console_evtchn,
    2.35 @@ -756,8 +752,7 @@ int xc_linux_build(int xc_handle,
    2.36                       &vstartinfo_start, &vkern_entry,
    2.37                       &vstack_start, ctxt, cmdline,
    2.38                       op.u.getdomaininfo.shared_info_frame,
    2.39 -                     flags, vcpus,
    2.40 -                     store_evtchn, store_mfn,
    2.41 +                     flags, store_evtchn, store_mfn,
    2.42                       console_evtchn, console_mfn) < 0 )
    2.43      {
    2.44          ERROR("Error constructing guest OS");
     3.1 --- a/tools/libxc/xenguest.h	Tue Oct 18 18:07:11 2005 +0100
     3.2 +++ b/tools/libxc/xenguest.h	Tue Oct 18 19:02:14 2005 +0100
     3.3 @@ -46,7 +46,6 @@ int xc_linux_build(int xc_handle,
     3.4                     const char *ramdisk_name,
     3.5                     const char *cmdline,
     3.6                     unsigned long flags,
     3.7 -                   unsigned int vcpus,
     3.8                     unsigned int store_evtchn,
     3.9                     unsigned long *store_mfn,
    3.10                     unsigned int console_evtchn,
     4.1 --- a/tools/python/xen/lowlevel/xc/xc.c	Tue Oct 18 18:07:11 2005 +0100
     4.2 +++ b/tools/python/xen/lowlevel/xc/xc.c	Tue Oct 18 19:02:14 2005 +0100
     4.3 @@ -382,7 +382,7 @@ static PyObject *pyxc_linux_build(PyObje
     4.4  
     4.5      uint32_t dom;
     4.6      char *image, *ramdisk = NULL, *cmdline = "";
     4.7 -    int flags = 0, vcpus = 1;
     4.8 +    int flags = 0;
     4.9      int store_evtchn, console_evtchn;
    4.10      unsigned long store_mfn = 0;
    4.11      unsigned long console_mfn = 0;
    4.12 @@ -390,19 +390,17 @@ static PyObject *pyxc_linux_build(PyObje
    4.13      static char *kwd_list[] = { "dom", "store_evtchn", 
    4.14                                  "console_evtchn", "image", 
    4.15  				/* optional */
    4.16 -				"ramdisk", "cmdline", "flags",
    4.17 -				"vcpus", NULL };
    4.18 +				"ramdisk", "cmdline", "flags", NULL };
    4.19  
    4.20 -    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iiis|ssii", kwd_list,
    4.21 +    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iiis|ssi", kwd_list,
    4.22                                        &dom, &store_evtchn,
    4.23  				      &console_evtchn, &image, 
    4.24  				      /* optional */
    4.25 -				      &ramdisk, &cmdline, &flags,
    4.26 -                                      &vcpus) )
    4.27 +				      &ramdisk, &cmdline, &flags) )
    4.28          return NULL;
    4.29  
    4.30      if ( xc_linux_build(xc->xc_handle, dom, image,
    4.31 -                        ramdisk, cmdline, flags, vcpus,
    4.32 +                        ramdisk, cmdline, flags,
    4.33                          store_evtchn, &store_mfn, 
    4.34  			console_evtchn, &console_mfn) != 0 )
    4.35          return PyErr_SetFromErrno(xc_error);
     5.1 --- a/tools/python/xen/xend/image.py	Tue Oct 18 18:07:11 2005 +0100
     5.2 +++ b/tools/python/xen/xend/image.py	Tue Oct 18 19:02:14 2005 +0100
     5.3 @@ -185,8 +185,7 @@ class LinuxImageHandler(ImageHandler):
     5.4                               store_evtchn   = store_evtchn,
     5.5                               console_evtchn = console_evtchn,
     5.6                               cmdline        = self.cmdline,
     5.7 -                             ramdisk        = self.ramdisk,
     5.8 -                             vcpus          = self.vm.getVCpuCount())
     5.9 +                             ramdisk        = self.ramdisk)
    5.10          if isinstance(ret, dict):
    5.11              self.set_vminfo(ret)
    5.12              return 0
     6.1 --- a/xen/arch/x86/domain_build.c	Tue Oct 18 18:07:11 2005 +0100
     6.2 +++ b/xen/arch/x86/domain_build.c	Tue Oct 18 19:02:14 2005 +0100
     6.3 @@ -588,7 +588,6 @@ int construct_dom0(struct domain *d,
     6.4      si = (start_info_t *)vstartinfo_start;
     6.5      memset(si, 0, PAGE_SIZE);
     6.6      si->nr_pages = nr_pages;
     6.7 -    si->n_vcpu   = num_online_cpus();
     6.8  
     6.9      if ( opt_dom0_translate )
    6.10      {
     7.1 --- a/xen/include/public/xen.h	Tue Oct 18 18:07:11 2005 +0100
     7.2 +++ b/xen/include/public/xen.h	Tue Oct 18 19:02:14 2005 +0100
     7.3 @@ -423,7 +423,6 @@ typedef struct start_info {
     7.4      unsigned long mfn_list;     /* VIRTUAL address of page-frame list.    */
     7.5      unsigned long mod_start;    /* VIRTUAL address of pre-loaded module.  */
     7.6      unsigned long mod_len;      /* Size (bytes) of pre-loaded module.     */
     7.7 -    uint32_t n_vcpu;
     7.8      int8_t cmd_line[MAX_GUEST_CMDLINE];
     7.9  } start_info_t;
    7.10