[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH 13/24] mini-os: make frontends and xenbus optional



This adds compile-time logic to disable certain frontends in mini-os:
 - pcifront is disabled by default, enabled for ioemu
 - blkfront, netfront, fbfront, kbdfront, consfront are enabled by default
 - xenbus is required for any frontend, and is enabled by default

If all frontends and xenbus are disabled, mini-os will run without
needing to communicate with xenstore, making it suitable to run the
xenstore daemon. The console frontend is not required for the initial
console, only consoles opened via openpt or ptmx.

Signed-off-by: Daniel De Graaf <dgdegra@xxxxxxxxxxxxx>
Acked-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
Cc: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>
---
 extras/mini-os/Makefile                            |   32 +++-
 extras/mini-os/console/console.c                   |    5 -
 extras/mini-os/console/console.h                   |    2 +
 .../mini-os/console/{xencons_ring.c => xenbus.c}   |  182 +-------------------
 extras/mini-os/console/xencons_ring.c              |  182 +-------------------
 extras/mini-os/include/lib.h                       |    2 +
 extras/mini-os/include/xenbus.h                    |   12 ++
 extras/mini-os/kernel.c                            |    4 -
 extras/mini-os/lib/sys.c                           |   59 +++++++
 extras/mini-os/main.c                              |    6 +-
 stubdom/ioemu-minios.cfg                           |    1 +
 11 files changed, 112 insertions(+), 375 deletions(-)
 create mode 100644 extras/mini-os/console/console.h
 copy extras/mini-os/console/{xencons_ring.c => xenbus.c} (56%)

diff --git a/extras/mini-os/Makefile b/extras/mini-os/Makefile
index b4a9eb4..583f85b 100644
--- a/extras/mini-os/Makefile
+++ b/extras/mini-os/Makefile
@@ -20,11 +20,25 @@ CONFIG_START_NETWORK ?= y
 CONFIG_SPARSE_BSS ?= y
 CONFIG_QEMU_XS_ARGS ?= n
 CONFIG_TEST ?= n
+CONFIG_PCIFRONT ?= n
+CONFIG_BLKFRONT ?= y
+CONFIG_NETFRONT ?= y
+CONFIG_FBFRONT ?= y
+CONFIG_KBDFRONT ?= y
+CONFIG_CONSFRONT ?= y
+CONFIG_XENBUS ?= y
 
 # Export config items as compiler directives
 flags-$(CONFIG_START_NETWORK) += -DCONFIG_START_NETWORK
 flags-$(CONFIG_SPARSE_BSS) += -DCONFIG_SPARSE_BSS
 flags-$(CONFIG_QEMU_XS_ARGS) += -DCONFIG_QEMU_XS_ARGS
+flags-$(CONFIG_PCIFRONT) += -DCONFIG_PCIFRONT
+flags-$(CONFIG_BLKFRONT) += -DCONFIG_BLKFRONT
+flags-$(CONFIG_NETFRONT) += -DCONFIG_NETFRONT
+flags-$(CONFIG_KBDFRONT) += -DCONFIG_KBDFRONT
+flags-$(CONFIG_FBFRONT) += -DCONFIG_FBFRONT
+flags-$(CONFIG_CONSFRONT) += -DCONFIG_CONSFRONT
+flags-$(CONFIG_XENBUS) += -DCONFIG_XENBUS
 
 DEF_CFLAGS += $(flags-y)
 
@@ -50,10 +64,10 @@ TARGET := mini-os
 # Subdirectories common to mini-os
 SUBDIRS := lib xenbus console
 
-src-y += blkfront.c
+src-$(CONFIG_BLKFRONT) += blkfront.c
 src-y += daytime.c
 src-y += events.c
-src-y += fbfront.c
+src-$(CONFIG_FBFRONT) += fbfront.c
 src-y += gntmap.c
 src-y += gnttab.c
 src-y += hypervisor.c
@@ -61,8 +75,8 @@ src-y += kernel.c
 src-y += lock.c
 src-y += main.c
 src-y += mm.c
-src-y += netfront.c
-src-y += pcifront.c
+src-$(CONFIG_NETFRONT) += netfront.c
+src-$(CONFIG_PCIFRONT) += pcifront.c
 src-y += sched.c
 src-$(CONFIG_TEST) += test.c
 
@@ -73,12 +87,13 @@ src-y += lib/stack_chk_fail.c
 src-y += lib/string.c
 src-y += lib/sys.c
 src-y += lib/xmalloc.c
-src-y += lib/xs.c
+src-$(CONFIG_XENBUS) += lib/xs.c
 
-src-y += xenbus/xenbus.c
+src-$(CONFIG_XENBUS) += xenbus/xenbus.c
 
 src-y += console/console.c
 src-y += console/xencons_ring.c
+src-$(CONFIG_CONSFRONT) += console/xenbus.c
 
 # The common mini-os objects to build.
 APP_OBJS :=
@@ -113,7 +128,10 @@ ifeq ($(lwip),y)
 LWC    := $(shell find $(LWIPDIR)/ -type f -name '*.c')
 LWC    := $(filter-out %6.c %ip6_addr.c %ethernetif.c, $(LWC))
 LWO    := $(patsubst %.c,%.o,$(LWC))
-LWO    += $(addprefix $(OBJ_DIR)/,lwip-arch.o lwip-net.o)
+LWO    += $(OBJ_DIR)/lwip-arch.o
+ifeq ($(CONFIG_NETFRONT),y)
+LWO += $(OBJ_DIR)/lwip-net.o
+endif
 
 $(OBJ_DIR)/lwip.a: $(LWO)
        $(RM) $@
diff --git a/extras/mini-os/console/console.c b/extras/mini-os/console/console.c
index 2b4ed9f..fec3791 100644
--- a/extras/mini-os/console/console.c
+++ b/extras/mini-os/console/console.c
@@ -158,8 +158,3 @@ void init_console(void)
     /* This is also required to notify the daemon */
     printk("done.\n");
 }
-
-void fini_console(struct consfront_dev *dev)
-{
-    if (dev) free_consfront(dev);
-}
diff --git a/extras/mini-os/console/console.h b/extras/mini-os/console/console.h
new file mode 100644
index 0000000..e85147a
--- /dev/null
+++ b/extras/mini-os/console/console.h
@@ -0,0 +1,2 @@
+
+void console_handle_input(evtchn_port_t port, struct pt_regs *regs, void 
*data);
diff --git a/extras/mini-os/console/xencons_ring.c 
b/extras/mini-os/console/xenbus.c
similarity index 56%
copy from extras/mini-os/console/xencons_ring.c
copy to extras/mini-os/console/xenbus.c
index af0afed..a7c517d 100644
--- a/extras/mini-os/console/xencons_ring.c
+++ b/extras/mini-os/console/xenbus.c
@@ -11,181 +11,7 @@
 #include <xen/io/ring.h>
 #include <mini-os/xmalloc.h>
 #include <mini-os/gnttab.h>
-
-DECLARE_WAIT_QUEUE_HEAD(console_queue);
-
-static inline void notify_daemon(struct consfront_dev *dev)
-{
-    /* Use evtchn: this is called early, before irq is set up. */
-    if (!dev)
-        notify_remote_via_evtchn(start_info.console.domU.evtchn);
-    else
-        notify_remote_via_evtchn(dev->evtchn);
-}
-
-static inline struct xencons_interface *xencons_interface(void)
-{
-    if (start_info.console.domU.evtchn)
-        return mfn_to_virt(start_info.console.domU.mfn);
-    else
-        return NULL;
-} 
- 
-int xencons_ring_send_no_notify(struct consfront_dev *dev, const char *data, 
unsigned len)
-{      
-    int sent = 0;
-       struct xencons_interface *intf;
-       XENCONS_RING_IDX cons, prod;
-
-       if (!dev)
-            intf = xencons_interface();
-        else
-            intf = dev->ring;
-        if (!intf)
-            return sent;
-
-       cons = intf->out_cons;
-       prod = intf->out_prod;
-       mb();
-       BUG_ON((prod - cons) > sizeof(intf->out));
-
-       while ((sent < len) && ((prod - cons) < sizeof(intf->out)))
-               intf->out[MASK_XENCONS_IDX(prod++, intf->out)] = data[sent++];
-
-       wmb();
-       intf->out_prod = prod;
-    
-    return sent;
-}
-
-int xencons_ring_send(struct consfront_dev *dev, const char *data, unsigned 
len)
-{
-    int sent;
-
-    sent = xencons_ring_send_no_notify(dev, data, len);
-    notify_daemon(dev);
-
-    return sent;
-}      
-
-
-
-static void handle_input(evtchn_port_t port, struct pt_regs *regs, void *data)
-{
-       struct consfront_dev *dev = (struct consfront_dev *) data;
-#ifdef HAVE_LIBC
-        int fd = dev ? dev->fd : -1;
-
-        if (fd != -1)
-            files[fd].read = 1;
-
-        wake_up(&console_queue);
-#else
-       struct xencons_interface *intf = xencons_interface();
-       XENCONS_RING_IDX cons, prod;
-
-       cons = intf->in_cons;
-       prod = intf->in_prod;
-       mb();
-       BUG_ON((prod - cons) > sizeof(intf->in));
-
-       while (cons != prod) {
-               xencons_rx(intf->in+MASK_XENCONS_IDX(cons,intf->in), 1, regs);
-               cons++;
-       }
-
-       mb();
-       intf->in_cons = cons;
-
-       notify_daemon(dev);
-
-       xencons_tx();
-#endif
-}
-
-#ifdef HAVE_LIBC
-int xencons_ring_avail(struct consfront_dev *dev)
-{
-       struct xencons_interface *intf;
-       XENCONS_RING_IDX cons, prod;
-
-        if (!dev)
-            intf = xencons_interface();
-        else
-            intf = dev->ring;
-
-       cons = intf->in_cons;
-       prod = intf->in_prod;
-       mb();
-       BUG_ON((prod - cons) > sizeof(intf->in));
-
-        return prod - cons;
-}
-
-int xencons_ring_recv(struct consfront_dev *dev, char *data, unsigned len)
-{
-       struct xencons_interface *intf;
-       XENCONS_RING_IDX cons, prod;
-        unsigned filled = 0;
-
-        if (!dev)
-            intf = xencons_interface();
-        else
-            intf = dev->ring;
-
-       cons = intf->in_cons;
-       prod = intf->in_prod;
-       mb();
-       BUG_ON((prod - cons) > sizeof(intf->in));
-
-        while (filled < len && cons + filled != prod) {
-                data[filled] = *(intf->in + MASK_XENCONS_IDX(cons + filled, 
intf->in));
-                filled++;
-       }
-
-       mb();
-        intf->in_cons = cons + filled;
-
-       notify_daemon(dev);
-
-        return filled;
-}
-#endif
-
-struct consfront_dev *xencons_ring_init(void)
-{
-       int err;
-       struct consfront_dev *dev;
-
-       if (!start_info.console.domU.evtchn)
-               return 0;
-
-       dev = malloc(sizeof(struct consfront_dev));
-       memset(dev, 0, sizeof(struct consfront_dev));
-       dev->nodename = "device/console";
-       dev->dom = 0;
-       dev->backend = 0;
-       dev->ring_ref = 0;
-
-#ifdef HAVE_LIBC
-       dev->fd = -1;
-#endif
-       dev->evtchn = start_info.console.domU.evtchn;
-       dev->ring = (struct xencons_interface *) 
mfn_to_virt(start_info.console.domU.mfn);
-
-       err = bind_evtchn(dev->evtchn, handle_input, dev);
-       if (err <= 0) {
-               printk("XEN console request chn bind failed %i\n", err);
-                free(dev);
-               return NULL;
-       }
-        unmask_evtchn(dev->evtchn);
-
-       /* In case we have in-flight data after save/restore... */
-       notify_daemon(dev);
-
-       return dev;
-}
+#include "console.h"
 
 void free_consfront(struct consfront_dev *dev)
 {
@@ -262,7 +88,7 @@ struct consfront_dev *init_consfront(char *_nodename)
         return NULL;
     else
         dev->dom = res;
-    evtchn_alloc_unbound(dev->dom, handle_input, dev, &dev->evtchn);
+    evtchn_alloc_unbound(dev->dom, console_handle_input, dev, &dev->evtchn);
 
     dev->ring = (struct xencons_interface *) alloc_page();
     memset(dev->ring, 0, PAGE_SIZE);
@@ -364,8 +190,8 @@ error:
     return NULL;
 }
 
-void xencons_resume(void)
+void fini_console(struct consfront_dev *dev)
 {
-       (void)xencons_ring_init();
+    if (dev) free_consfront(dev);
 }
 
diff --git a/extras/mini-os/console/xencons_ring.c 
b/extras/mini-os/console/xencons_ring.c
index af0afed..81c8e99 100644
--- a/extras/mini-os/console/xencons_ring.c
+++ b/extras/mini-os/console/xencons_ring.c
@@ -11,6 +11,7 @@
 #include <xen/io/ring.h>
 #include <mini-os/xmalloc.h>
 #include <mini-os/gnttab.h>
+#include "console.h"
 
 DECLARE_WAIT_QUEUE_HEAD(console_queue);
 
@@ -70,7 +71,7 @@ int xencons_ring_send(struct consfront_dev *dev, const char 
*data, unsigned len)
 
 
 
-static void handle_input(evtchn_port_t port, struct pt_regs *regs, void *data)
+void console_handle_input(evtchn_port_t port, struct pt_regs *regs, void *data)
 {
        struct consfront_dev *dev = (struct consfront_dev *) data;
 #ifdef HAVE_LIBC
@@ -173,7 +174,7 @@ struct consfront_dev *xencons_ring_init(void)
        dev->evtchn = start_info.console.domU.evtchn;
        dev->ring = (struct xencons_interface *) 
mfn_to_virt(start_info.console.domU.mfn);
 
-       err = bind_evtchn(dev->evtchn, handle_input, dev);
+       err = bind_evtchn(dev->evtchn, console_handle_input, dev);
        if (err <= 0) {
                printk("XEN console request chn bind failed %i\n", err);
                 free(dev);
@@ -187,183 +188,6 @@ struct consfront_dev *xencons_ring_init(void)
        return dev;
 }
 
-void free_consfront(struct consfront_dev *dev)
-{
-    char* err = NULL;
-    XenbusState state;
-
-    char path[strlen(dev->backend) + 1 + 5 + 1];
-    char nodename[strlen(dev->nodename) + 1 + 5 + 1];
-
-    snprintf(path, sizeof(path), "%s/state", dev->backend);
-    snprintf(nodename, sizeof(nodename), "%s/state", dev->nodename);
-
-    if ((err = xenbus_switch_state(XBT_NIL, nodename, XenbusStateClosing)) != 
NULL) {
-        printk("free_consfront: error changing state to %d: %s\n",
-                XenbusStateClosing, err);
-        goto close;
-    }
-    state = xenbus_read_integer(path);
-    while (err == NULL && state < XenbusStateClosing)
-        err = xenbus_wait_for_state_change(path, &state, &dev->events);
-    if (err) free(err);
-
-    if ((err = xenbus_switch_state(XBT_NIL, nodename, XenbusStateClosed)) != 
NULL) {
-        printk("free_consfront: error changing state to %d: %s\n",
-                XenbusStateClosed, err);
-        goto close;
-    }
-
-close:
-    if (err) free(err);
-    xenbus_unwatch_path_token(XBT_NIL, path, path);
-
-    mask_evtchn(dev->evtchn);
-    unbind_evtchn(dev->evtchn);
-    free(dev->backend);
-    free(dev->nodename);
-
-    gnttab_end_access(dev->ring_ref);
-
-    free_page(dev->ring);
-    free(dev);
-}
-
-struct consfront_dev *init_consfront(char *_nodename)
-{
-    xenbus_transaction_t xbt;
-    char* err;
-    char* message=NULL;
-    int retry=0;
-    char* msg = NULL;
-    char nodename[256];
-    char path[256];
-    static int consfrontends = 3;
-    struct consfront_dev *dev;
-    int res;
-
-    if (!_nodename)
-        snprintf(nodename, sizeof(nodename), "device/console/%d", 
consfrontends);
-    else
-        strncpy(nodename, _nodename, sizeof(nodename));
-
-    printk("******************* CONSFRONT for %s **********\n\n\n", nodename);
-
-    consfrontends++;
-    dev = malloc(sizeof(*dev));
-    memset(dev, 0, sizeof(*dev));
-    dev->nodename = strdup(nodename);
-#ifdef HAVE_LIBC
-    dev->fd = -1;
-#endif
-
-    snprintf(path, sizeof(path), "%s/backend-id", nodename);
-    if ((res = xenbus_read_integer(path)) < 0) 
-        return NULL;
-    else
-        dev->dom = res;
-    evtchn_alloc_unbound(dev->dom, handle_input, dev, &dev->evtchn);
-
-    dev->ring = (struct xencons_interface *) alloc_page();
-    memset(dev->ring, 0, PAGE_SIZE);
-    dev->ring_ref = gnttab_grant_access(dev->dom, virt_to_mfn(dev->ring), 0);
-
-    dev->events = NULL;
-
-again:
-    err = xenbus_transaction_start(&xbt);
-    if (err) {
-        printk("starting transaction\n");
-        free(err);
-    }
-
-    err = xenbus_printf(xbt, nodename, "ring-ref","%u",
-                dev->ring_ref);
-    if (err) {
-        message = "writing ring-ref";
-        goto abort_transaction;
-    }
-    err = xenbus_printf(xbt, nodename,
-                "port", "%u", dev->evtchn);
-    if (err) {
-        message = "writing event-channel";
-        goto abort_transaction;
-    }
-    err = xenbus_printf(xbt, nodename,
-                "protocol", "%s", XEN_IO_PROTO_ABI_NATIVE);
-    if (err) {
-        message = "writing protocol";
-        goto abort_transaction;
-    }
-
-    err = xenbus_printf(xbt, nodename, "type", "%s", "ioemu");
-    if (err) {
-        message = "writing type";
-        goto abort_transaction;
-    }
-
-    snprintf(path, sizeof(path), "%s/state", nodename);
-    err = xenbus_switch_state(xbt, path, XenbusStateConnected);
-    if (err) {
-        message = "switching state";
-        goto abort_transaction;
-    }
-
-
-    err = xenbus_transaction_end(xbt, 0, &retry);
-    if (err) free(err);
-    if (retry) {
-            goto again;
-        printk("completing transaction\n");
-    }
-
-    goto done;
-
-abort_transaction:
-    free(err);
-    err = xenbus_transaction_end(xbt, 1, &retry);
-    goto error;
-
-done:
-
-    snprintf(path, sizeof(path), "%s/backend", nodename);
-    msg = xenbus_read(XBT_NIL, path, &dev->backend);
-    if (msg) {
-        printk("Error %s when reading the backend path %s\n", msg, path);
-        goto error;
-    }
-
-    printk("backend at %s\n", dev->backend);
-
-    {
-        XenbusState state;
-        char path[strlen(dev->backend) + 1 + 19 + 1];
-        snprintf(path, sizeof(path), "%s/state", dev->backend);
-        
-       xenbus_watch_path_token(XBT_NIL, path, path, &dev->events);
-        msg = NULL;
-        state = xenbus_read_integer(path);
-        while (msg == NULL && state < XenbusStateConnected)
-            msg = xenbus_wait_for_state_change(path, &state, &dev->events);
-        if (msg != NULL || state != XenbusStateConnected) {
-            printk("backend not available, state=%d\n", state);
-            xenbus_unwatch_path_token(XBT_NIL, path, path);
-            goto error;
-        }
-    }
-    unmask_evtchn(dev->evtchn);
-
-    printk("**************************\n");
-
-    return dev;
-
-error:
-    free(msg);
-    free(err);
-    free_consfront(dev);
-    return NULL;
-}
-
 void xencons_resume(void)
 {
        (void)xencons_ring_init();
diff --git a/extras/mini-os/include/lib.h b/extras/mini-os/include/lib.h
index 3d03cf4..1af2717 100644
--- a/extras/mini-os/include/lib.h
+++ b/extras/mini-os/include/lib.h
@@ -184,11 +184,13 @@ extern struct file {
        struct {
            struct consfront_dev *dev;
        } cons;
+#ifdef CONFIG_XENBUS
         struct {
             /* To each xenbus FD is associated a queue of watch events for this
              * FD.  */
             xenbus_event_queue events;
         } xenbus;
+#endif
     };
     int read;  /* maybe available for read */
 } files[];
diff --git a/extras/mini-os/include/xenbus.h b/extras/mini-os/include/xenbus.h
index de618fc..cd6316e 100644
--- a/extras/mini-os/include/xenbus.h
+++ b/extras/mini-os/include/xenbus.h
@@ -6,8 +6,14 @@
 typedef unsigned long xenbus_transaction_t;
 #define XBT_NIL ((xenbus_transaction_t)0)
 
+#ifdef CONFIG_XENBUS
 /* Initialize the XenBus system. */
 void init_xenbus(void);
+#else
+static inline void init_xenbus(void)
+{
+}
+#endif
 
 /* Read the value associated with a path.  Returns a malloc'd error
    string on failure and sets *value to NULL.  On success, *value is
@@ -98,7 +104,13 @@ char* xenbus_printf(xenbus_transaction_t xbt,
 /* Utility function to figure out our domain id */
 domid_t xenbus_get_self_id(void);
 
+#ifdef CONFIG_XENBUS
 /* Reset the XenBus system. */
 void fini_xenbus(void);
+#else
+static inline void fini_xenbus(void)
+{
+}
+#endif
 
 #endif /* XENBUS_H__ */
diff --git a/extras/mini-os/kernel.c b/extras/mini-os/kernel.c
index c8b9b8c..a8dfe6d 100644
--- a/extras/mini-os/kernel.c
+++ b/extras/mini-os/kernel.c
@@ -142,10 +142,6 @@ void stop_kernel(void)
     /* Reset grant tables */
     fini_gnttab();
 
-    /* Reset the console driver. */
-    fini_console(NULL);
-    /* TODO: record new ring mfn & event in start_info */
-
     /* Reset XenBus */
     fini_xenbus();
 
diff --git a/extras/mini-os/lib/sys.c b/extras/mini-os/lib/sys.c
index 2329a78..5875797 100644
--- a/extras/mini-os/lib/sys.c
+++ b/extras/mini-os/lib/sys.c
@@ -164,6 +164,7 @@ int mkdir(const char *pathname, mode_t mode)
     return -1;
 }
 
+#ifdef CONFIG_CONSFRONT
 int posix_openpt(int flags)
 {
     struct consfront_dev *dev;
@@ -192,6 +193,18 @@ int open_savefile(const char *path, int save)
     printk("fd(%d) = open_savefile\n", dev->fd);
     return(dev->fd);
 }
+#else
+int posix_openpt(int flags)
+{
+       errno = EIO;
+       return -1;
+}
+int open_savefile(const char *path, int save)
+{
+       errno = EIO;
+       return -1;
+}
+#endif
 
 int open(const char *pathname, int flags, ...)
 {
@@ -241,6 +254,7 @@ int read(int fd, void *buf, size_t nbytes)
        case FTYPE_SOCKET:
            return lwip_read(files[fd].socket.fd, buf, nbytes);
 #endif
+#ifdef CONFIG_NETFRONT
        case FTYPE_TAP: {
            ssize_t ret;
            ret = netfront_receive(files[fd].tap.dev, buf, nbytes);
@@ -250,6 +264,8 @@ int read(int fd, void *buf, size_t nbytes)
            }
            return ret;
        }
+#endif
+#ifdef CONFIG_KBDFRONT
         case FTYPE_KBD: {
             int ret, n;
             n = nbytes / sizeof(union xenkbd_in_event);
@@ -260,6 +276,8 @@ int read(int fd, void *buf, size_t nbytes)
            }
            return ret * sizeof(union xenkbd_in_event);
         }
+#endif
+#ifdef CONFIG_FBFRONT
         case FTYPE_FB: {
             int ret, n;
             n = nbytes / sizeof(union xenfb_in_event);
@@ -270,6 +288,7 @@ int read(int fd, void *buf, size_t nbytes)
            }
            return ret * sizeof(union xenfb_in_event);
         }
+#endif
        default:
            break;
     }
@@ -297,9 +316,11 @@ int write(int fd, const void *buf, size_t nbytes)
        case FTYPE_SOCKET:
            return lwip_write(files[fd].socket.fd, (void*) buf, nbytes);
 #endif
+#ifdef CONFIG_NETFRONT
        case FTYPE_TAP:
            netfront_xmit(files[fd].tap.dev, (void*) buf, nbytes);
            return nbytes;
+#endif
        default:
            break;
     }
@@ -326,9 +347,11 @@ int close(int fd)
         default:
            files[fd].type = FTYPE_NONE;
            return 0;
+#ifdef CONFIG_XENBUS
        case FTYPE_XENBUS:
             xs_daemon_close((void*)(intptr_t) fd);
             return 0;
+#endif
 #ifdef HAVE_LWIP
        case FTYPE_SOCKET: {
            int res = lwip_close(files[fd].socket.fd);
@@ -345,27 +368,37 @@ int close(int fd)
        case FTYPE_GNTMAP:
            minios_gnttab_close_fd(fd);
            return 0;
+#ifdef CONFIG_NETFRONT
        case FTYPE_TAP:
            shutdown_netfront(files[fd].tap.dev);
            files[fd].type = FTYPE_NONE;
            return 0;
+#endif
+#ifdef CONFIG_BLKFRONT
        case FTYPE_BLK:
             shutdown_blkfront(files[fd].blk.dev);
            files[fd].type = FTYPE_NONE;
            return 0;
+#endif
+#ifdef CONFIG_KBDFRONT
        case FTYPE_KBD:
             shutdown_kbdfront(files[fd].kbd.dev);
             files[fd].type = FTYPE_NONE;
             return 0;
+#endif
+#ifdef CONFIG_FBFRONT
        case FTYPE_FB:
             shutdown_fbfront(files[fd].fb.dev);
             files[fd].type = FTYPE_NONE;
             return 0;
+#endif
+#ifdef CONFIG_CONSFRONT
         case FTYPE_SAVEFILE:
         case FTYPE_CONSOLE:
             fini_console(files[fd].cons.dev);
             files[fd].type = FTYPE_NONE;
             return 0;
+#endif
        case FTYPE_NONE:
            break;
     }
@@ -611,6 +644,7 @@ static int select_poll(int nfds, fd_set *readfds, fd_set 
*writefds, fd_set *exce
                 n++;
            FD_CLR(i, exceptfds);
            break;
+#ifdef CONFIG_XENBUS
        case FTYPE_XENBUS:
            if (FD_ISSET(i, readfds)) {
                 if (files[i].xenbus.events)
@@ -621,6 +655,7 @@ static int select_poll(int nfds, fd_set *readfds, fd_set 
*writefds, fd_set *exce
            FD_CLR(i, writefds);
            FD_CLR(i, exceptfds);
            break;
+#endif
        case FTYPE_EVTCHN:
        case FTYPE_TAP:
        case FTYPE_BLK:
@@ -705,11 +740,19 @@ int select(int nfds, fd_set *readfds, fd_set *writefds, 
fd_set *exceptfds,
     fd_set myread, mywrite, myexcept;
     struct thread *thread = get_current();
     s_time_t start = NOW(), stop;
+#ifdef CONFIG_NETFRONT
     DEFINE_WAIT(netfront_w);
+#endif
     DEFINE_WAIT(event_w);
+#ifdef CONFIG_BLKFRONT
     DEFINE_WAIT(blkfront_w);
+#endif
+#ifdef CONFIG_XENBUS
     DEFINE_WAIT(xenbus_watch_w);
+#endif
+#ifdef CONFIG_KBDFRONT
     DEFINE_WAIT(kbdfront_w);
+#endif
     DEFINE_WAIT(console_w);
 
     assert(thread == main_thread);
@@ -727,11 +770,19 @@ int select(int nfds, fd_set *readfds, fd_set *writefds, 
fd_set *exceptfds,
     /* Tell people we're going to sleep before looking at what they are
      * saying, hence letting them wake us if events happen between here and
      * schedule() */
+#ifdef CONFIG_NETFRONT
     add_waiter(netfront_w, netfront_queue);
+#endif
     add_waiter(event_w, event_queue);
+#ifdef CONFIG_BLKFRONT
     add_waiter(blkfront_w, blkfront_queue);
+#endif
+#ifdef CONFIG_XENBUS
     add_waiter(xenbus_watch_w, xenbus_watch_queue);
+#endif
+#ifdef CONFIG_KBDFRONT
     add_waiter(kbdfront_w, kbdfront_queue);
+#endif
     add_waiter(console_w, console_queue);
 
     if (readfds)
@@ -814,11 +865,19 @@ int select(int nfds, fd_set *readfds, fd_set *writefds, 
fd_set *exceptfds,
     ret = -1;
 
 out:
+#ifdef CONFIG_NETFRONT
     remove_waiter(netfront_w, netfront_queue);
+#endif
     remove_waiter(event_w, event_queue);
+#ifdef CONFIG_BLKFRONT
     remove_waiter(blkfront_w, blkfront_queue);
+#endif
+#ifdef CONFIG_XENBUS
     remove_waiter(xenbus_watch_w, xenbus_watch_queue);
+#endif
+#ifdef CONFIG_KBDFRONT
     remove_waiter(kbdfront_w, kbdfront_queue);
+#endif
     remove_waiter(console_w, console_queue);
     return ret;
 }
diff --git a/extras/mini-os/main.c b/extras/mini-os/main.c
index aeda548..73eb6fb 100644
--- a/extras/mini-os/main.c
+++ b/extras/mini-os/main.c
@@ -63,10 +63,12 @@ static void call_main(void *p)
 #ifdef CONFIG_SPARSE_BSS
     sparse((unsigned long) &__app_bss_start, &__app_bss_end - 
&__app_bss_start);
 #endif
-#if defined(HAVE_LWIP) && defined(CONFIG_START_NETWORK)
+#if defined(HAVE_LWIP) && defined(CONFIG_START_NETWORK) && 
defined(CONFIG_NETFRONT)
     start_networking();
 #endif
+#ifdef CONFIG_PCIFRONT
     create_thread("pcifront", pcifront_watches, NULL);
+#endif
 
 #ifdef CONFIG_QEMU_XS_ARGS
     /* Fetch argc, argv from XenStore */
@@ -169,7 +171,7 @@ void _exit(int ret)
     close_all_files();
     __libc_fini_array();
     printk("main returned %d\n", ret);
-#ifdef HAVE_LWIP
+#if defined(HAVE_LWIP) && defined(CONFIG_NETFRONT)
     stop_networking();
 #endif
     stop_kernel();
diff --git a/stubdom/ioemu-minios.cfg b/stubdom/ioemu-minios.cfg
index 7ea1d2f..e3a96da 100644
--- a/stubdom/ioemu-minios.cfg
+++ b/stubdom/ioemu-minios.cfg
@@ -1 +1,2 @@
 CONFIG_QEMU_XS_ARGS=y
+CONFIG_PCIFRONT=y
-- 
1.7.7.6


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


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.