On Thu, Jun 16, 2011 at 17:05, <stefano.stabell...@eu.citrix.com> wrote: > From: Stefano Stabellini <stefano.stabell...@eu.citrix.com> > > The unplug protocol is necessary to support PV drivers in the guest: the > drivers expect to be able to "unplug" emulated disks and nics before > initializing the Xen PV interfaces. > It is responsibility of the guest to make sure that the unplug is done > before the emulated devices or the PV interface start to be used. > > We use pci_for_each_device to walk the PCI bus, identify the devices and > disks that we want to disable and dynamically unplug them. > > Signed-off-by: Stefano Stabellini <stefano.stabell...@eu.citrix.com> > --- > hw/xen_platform.c | 63 > ++++++++++++++++++++++++++++++++++++++++++++++++++++- > 1 files changed, 62 insertions(+), 1 deletions(-) > > diff --git a/hw/xen_platform.c b/hw/xen_platform.c > index b167eee..9f8c843 100644 > --- a/hw/xen_platform.c > +++ b/hw/xen_platform.c > @@ -34,6 +34,9 @@ > #include "xen_backend.h" > #include "rwhandler.h" > #include "trace.h" > +#include "hw/ide/internal.h" > +#include "hw/ide/pci.h" > +#include "hw/pci_ids.h" > > #include <xenguest.h> > > @@ -76,6 +79,54 @@ static void log_writeb(PCIXenPlatformState *s, char val) > } > > /* Xen Platform, Fixed IOPort */ > +#define UNPLUG_ALL_IDE_DISKS 1 > +#define UNPLUG_ALL_NICS 2 > +#define UNPLUG_AUX_IDE_DISKS 4 > + > +static int unplug_param; > + > +static void unplug_nic(PCIBus *b, PCIDevice *d) > +{ > + if (d->config[0xa] == 0 && d->config[0xb] == 2) {
You should use: pci_get_word(d->config+PCI_CLASS_DEVICE) == PCI_CLASS_NETWORK_ETHERNET It'll be clearer. > + pci_unplug_device(&(d->qdev)); > + } > +} > + > +static void pci_unplug_nics(PCIBus *bus) > +{ > + pci_for_each_device(bus, 0, unplug_nic); > +} > + > +static void unplug_disks(PCIBus *b, PCIDevice *d) > +{ > + if (d->config[0xa] == 1 && d->config[0xb] == 1) { Same here with PCI_CLASS_STORAGE_IDE. Regards, -- Anthony PERARD