pcifront: implement dynamic connections and disconnections
PATCH 1/1 pcifront: implement dynamic connections and disconnections
Hi all,
this patch implements dynamic connections and disconnections in pcifront. This feature is required to properly support pci hotplug, because when no pci devices are assigned to a guest, xend will remove the pci backend altogether.
Signed-off-by Stefano Stabellini <[email protected]>
---
extras/mini-os/include/pcifront.h +1 -0
@@ -1,6 +1,7 @@#include <mini-os/types.h> #include <xen/io/pciif.h> struct pcifront_dev ; +void pcifront_watches (void *opaque);struct pcifront_dev *init_pcifront (char *nodename);void pcifront_op (struct pcifront_dev *dev,struct xen_pci_op *op);void pcifront_scan (struct pcifront_dev *dev,void (*fun)(unsigned int domain,unsigned int bus,unsigned slot,unsigned int fun));
extras/mini-os/main.c +2 -0
@@ -9,6 +9,7 @@#include <sched.h> #include <console.h> #include <netfront.h> +#include <pcifront.h> #include <time.h> #include <stdlib.h> #include <unistd.h>
@@ -67,6 +68,7 @@#endif init_fs_frontend ();#endif +create_thread ("pcifront" , pcifront_watches,NULL );#ifdef CONFIG_QEMU /* Fetch argc, argv from XenStore */
extras/mini-os/pcifront.c +127 -7
238 lines not on this page · raw message
extras/mini-os/xenbus/xenbus.c +4 -1
@@ -96,7 +96,10 @@if (!queue) queue = &xenbus_events; ret =xenbus_wait_for_watch_return (queue); -free (ret); +if (ret) +free (ret); +else +printk ("unexpected path returned by watch\n" ); }char *xenbus_wait_for_value (const char * path,const char * value,xenbus_event_queue *queue)
stubdom/pciutils.patch +8 -21
@@ -23,14 +23,6 @@ PCI_ACCESS_MAX }; -@@ -63,6 +64,7 @@ - int fd_rw; /* proc: fd opened read-write */ - struct pci_dev *cached_dev; /* proc: device the fd is for */ - int fd_pos; /* proc: current position */ -+ void *minios; - }; - - /* Initialize PCI access */ --- pciutils-2.2.9.orig/lib/internal.h 2006-09-09 11:52:47.000000000 +0100 +++ pciutils-2.2.9/lib/internal.h 2008-07-01 10:46:24.968202000 +0100 @@ -37,4 +37,4 @@
@@ -72,7 +64,7 @@ --- pciutils-2.2.9.orig/lib/minios.c 1970-01-01 01:00:00.000000000 +0100 +++ pciutils-2.2.9/lib/minios.c 2008-07-01 12:31:40.554260000 +0100 -@@ -0,0 +1,113 @@ +@@ -0,0 +1,108 @@ +/* + * The PCI Library -- MiniOS PCI frontend access + *
@@ -95,24 +87,19 @@ +static void +minios_init(struct pci_access *a) +{ -+ a->minios = init_pcifront(NULL); -+ if (!a->minios) ++ if (!init_pcifront(NULL)) + a->warning("minios_init open failed"); +} + +static void +minios_cleanup(struct pci_access *a) +{ -+ if (a->minios) -+ shutdown_pcifront(a->minios); ++ shutdown_pcifront(NULL); +} + +static void +minios_scan(struct pci_access *a) +{ -+ if (!a->minios) -+ return; -+ + void func(unsigned int domain, unsigned int bus, unsigned int slot, unsigned int fun) + { + struct pci_dev *d = pci_alloc_dev(a);
@@ -125,7 +112,7 @@ + pci_link_dev(a, d); + } + -+ pcifront_scan(a->minios, func); ++ pcifront_scan(NULL, func); +} + +static int
@@ -134,17 +121,17 @@ + unsigned int val; + switch (len) { + case 1: -+ if (pcifront_conf_read(d->access->minios, d->domain, d->bus, d->dev, d->func, pos, len, &val)) ++ if (pcifront_conf_read(NULL, d->domain, d->bus, d->dev, d->func, pos, len, &val)) + return 0; + * buf = val; + return 1; + case 2: -+ if (pcifront_conf_read(d->access->minios, d->domain, d->bus, d->dev, d->func, pos, len, &val)) ++ if (pcifront_conf_read(NULL, d->domain, d->bus, d->dev, d->func, pos, len, &val)) + return 0; + *(u16 *) buf = cpu_to_le16((u16) val); + return 1; + case 4: -+ if (pcifront_conf_read(d->access->minios, d->domain, d->bus, d->dev, d->func, pos, len, &val)) ++ if (pcifront_conf_read(NULL, d->domain, d->bus, d->dev, d->func, pos, len, &val)) + return 0; + *(u32 *) buf = cpu_to_le32((u32) val); + return 1;
@@ -170,7 +157,7 @@ + default: + return pci_generic_block_write(d, pos, buf, len); + } -+ return !pcifront_conf_write(d->access->minios, d->domain, d->bus, d->dev, d->func, pos, len, val); ++ return !pcifront_conf_write(NULL, d->domain, d->bus, d->dev, d->func, pos, len, val); +} + +struct pci_methods pm_minios = {