WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

Re: [Xen-devel] [PATCH 3/3] xen: implement unplug protocol in xen_platfo

To: stefano.stabellini@xxxxxxxxxxxxx
Subject: Re: [Xen-devel] [PATCH 3/3] xen: implement unplug protocol in xen_platform
From: Anthony PERARD <anthony.perard@xxxxxxxxxx>
Date: Fri, 17 Jun 2011 14:46:53 +0100
Cc: Anthony PERARD <anthony.perard@xxxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxx, qemu-devel@xxxxxxxxxx, anthony@xxxxxxxxxxxxx, agraf@xxxxxxx
Delivery-date: Fri, 17 Jun 2011 06:48:40 -0700
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:in-reply-to:references:from :date:x-google-sender-auth:message-id:subject:to:cc:content-type :content-transfer-encoding; bh=fZEHlqbMaLg/5w990YQq5qXc9TCGEN3SHdNxCWBF2Jc=; b=Icpi7TpW82DM/CNXiGewy4S9JfgCyGX08aUb9lc3vKk6mvb5zmwVB+o5DjMWLWHUlx x+a6QwqVMAEl/ffbbmY3IHWpcIG09yP7q2Oa3/89p9AaS19sT/VFpQzCiRXg5E2OP3OB 788grQ8KpmM0E2CkmbNutSiMXQE2UoplNm1xc=
Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:from:date :x-google-sender-auth:message-id:subject:to:cc:content-type :content-transfer-encoding; b=f2YoPLhakmXsvYdTXGOQJtHYqt7goAM7D9psGBUG4qn8VlnrGbGX7NW0Bplq4ig709 c0WKyKO2Jq8tPUtp2fX46waoEABWjZ2stuxmoJXmZY/9CLeTTkndCWJs15Dey9o00/2h EI1aRZMv138/u9kExbfcYjaZAoMS2limHk9yg=
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <1308240319-13949-3-git-send-email-stefano.stabellini@xxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <alpine.DEB.2.00.1106161645230.12963@kaball-desktop> <1308240319-13949-3-git-send-email-stefano.stabellini@xxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
On Thu, Jun 16, 2011 at 17:05,  <stefano.stabellini@xxxxxxxxxxxxx> wrote:
> From: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>
>
> 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.stabellini@xxxxxxxxxxxxx>
> ---
>  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

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel