debuggers.hg

changeset 20893:15efdfc46593

pv-on-hvm: Only unplug emulated devices if requested via module parameter.

dev_unplug=[all,][ide-disks,][aux-ide-disks,][nics]

ide-disks: Unplug all emulated IDE disks (but not CD-ROMs)
aux-ide-disks: As above, but doesn't touch primary IDE master
nics: Unplug all emulated NICs
all: ide-disks and nics

Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Sat Jan 23 08:26:23 2010 +0000 (2010-01-23)
parents 7d65247d5f06
children cd453b3d7b25
files unmodified_drivers/linux-2.6/platform-pci/platform-pci.c
line diff
     1.1 --- a/unmodified_drivers/linux-2.6/platform-pci/platform-pci.c	Sat Jan 23 08:23:24 2010 +0000
     1.2 +++ b/unmodified_drivers/linux-2.6/platform-pci/platform-pci.c	Sat Jan 23 08:26:23 2010 +0000
     1.3 @@ -62,6 +62,13 @@ MODULE_AUTHOR("ssmith@xensource.com");
     1.4  MODULE_DESCRIPTION("Xen platform PCI device");
     1.5  MODULE_LICENSE("GPL");
     1.6  
     1.7 +/* NB. [aux-]ide-disks options do not unplug IDE CD-ROM drives. */
     1.8 +/* NB. aux-ide-disks is equiv to ide-disks except ignores primary master. */
     1.9 +static char *dev_unplug;
    1.10 +module_param(dev_unplug, charp, 0644);
    1.11 +MODULE_PARM_DESC(dev_unplug, "Emulated devices to unplug: "
    1.12 +		 "[all,][ide-disks,][aux-ide-disks,][nics]\n");
    1.13 +
    1.14  struct pci_dev *xen_platform_pdev;
    1.15  
    1.16  static unsigned long shared_info_frame;
    1.17 @@ -272,19 +279,43 @@ int gnttab_init(void);
    1.18  #define XEN_IOPORT_LINUX_PRODNUM 0xffff /* NB: register a proper one */
    1.19  #define XEN_IOPORT_LINUX_DRVVER  ((LINUX_VERSION_CODE << 8) + 0x0)
    1.20  
    1.21 +#define UNPLUG_ALL_IDE_DISKS 1
    1.22 +#define UNPLUG_ALL_NICS 2
    1.23 +#define UNPLUG_AUX_IDE_DISKS 4
    1.24 +#define UNPLUG_ALL 7
    1.25 +
    1.26  static int check_platform_magic(struct device *dev, long ioaddr, long iolen)
    1.27  {
    1.28 -	short magic;
    1.29 -	char protocol;
    1.30 +	short magic, unplug = 0;
    1.31 +	char protocol, *p, *q, *err;
    1.32  
    1.33 -	if (iolen < 0x16)
    1.34 -		return -ENODEV;
    1.35 +	for (p = dev_unplug; p; p = q) {
    1.36 +		q = strchr(dev_unplug, ',');
    1.37 +		if (q)
    1.38 +			*q++ = '\0';
    1.39 +		if (!strcmp(p, "all"))
    1.40 +			unplug |= UNPLUG_ALL;
    1.41 +		else if (!strcmp(p, "ide-disks"))
    1.42 +			unplug |= UNPLUG_ALL_IDE_DISKS;
    1.43 +		else if (!strcmp(p, "aux-ide-disks"))
    1.44 +			unplug |= UNPLUG_AUX_IDE_DISKS;
    1.45 +		else if (!strcmp(p, "nics"))
    1.46 +			unplug |= UNPLUG_ALL_NICS;
    1.47 +		else
    1.48 +			dev_warn(dev, "unrecognised option '%s' "
    1.49 +				 "in module parameter 'dev_unplug'\n", p);
    1.50 +	}
    1.51 +
    1.52 +	if (iolen < 0x16) {
    1.53 +		err = "backend too old";
    1.54 +		goto no_dev;
    1.55 +	}
    1.56  
    1.57  	magic = inw(XEN_IOPORT_MAGIC);
    1.58  
    1.59  	if (magic != XEN_IOPORT_MAGIC_VAL) {
    1.60 -		dev_err(dev, "invalid magic %#x", magic);
    1.61 -		return -ENODEV;
    1.62 +		err = "unrecognised magic value";
    1.63 +		goto no_dev;
    1.64  	}
    1.65  
    1.66  	protocol = inb(XEN_IOPORT_PROTOVER);
    1.67 @@ -293,8 +324,8 @@ static int check_platform_magic(struct d
    1.68  
    1.69  	switch (protocol) {
    1.70  	case 1:
    1.71 -		outw(XEN_IOPORT_PRODNUM, 0xbeef);
    1.72 -		outl(XEN_IOPORT_DRVVER, 0xdead);
    1.73 +		outw(XEN_IOPORT_PRODNUM, XEN_IOPORT_LINUX_PRODNUM);
    1.74 +		outl(XEN_IOPORT_DRVVER, XEN_IOPORT_LINUX_DRVVER);
    1.75  		if (inw(XEN_IOPORT_MAGIC) != XEN_IOPORT_MAGIC_VAL) {
    1.76  			dev_err(dev, "blacklisted by host\n");
    1.77  			return -ENODEV;
    1.78 @@ -304,11 +335,18 @@ static int check_platform_magic(struct d
    1.79  		outw(XEN_IOPORT_UNPLUG, 0xf);
    1.80  		break;
    1.81  	default:
    1.82 -		dev_err(dev, "unknown qemu version\n");
    1.83 -		return -ENODEV;
    1.84 +		err = "unknown I/O protocol version";
    1.85 +		goto no_dev;
    1.86  	}
    1.87  
    1.88  	return 0;
    1.89 +
    1.90 + no_dev:
    1.91 +	dev_warn(dev, "failed backend handshake: %s\n", err);
    1.92 +	if (!unplug)
    1.93 +		return 0;
    1.94 +	dev_err(dev, "failed to execute specified dev_unplug options!\n");
    1.95 +	return -ENODEV;
    1.96  }
    1.97  
    1.98  static int __devinit platform_pci_init(struct pci_dev *pdev,