Skip to contentSkip to conversation

flag in minios kernel to say whether xenbus is initialised - it might not be if this is a xenstore stubdom

PATCH In review Alex Zeffertt 1 participant 1 message Mar 23, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 18/24 flag in minios kernel to say whether xenbus is initialised - it might not be if this is a xenstore stubdom

Aborts minios xenbus initialization if there is no xenstored mfn or port available. Adds a is_xenbus_ready function for other modules to query whether xenbus is available.

TODO: Do we just want a global integer instead of a function?

TODO: Should fini_xenbus take it back to not ready?

TODO: Should the other non-static functions fail if !ready?

---

extras/mini-os/include/xenbus.h +2 -0
diff -r e53f83b91052 extras/mini-os/include/xenbus.h
@@ -6,6 +6,8 @@
 
 /* Initialize the XenBus system. */
 void init_xenbus(void);
+
+int is_xenbus_ready(void);
 
 /* Read the value associated with a path.  Returns a malloc'd error
    string on failure and sets *value to NULL.  On success, *value is
extras/mini-os/xenbus/xenbus.c +14 -0
diff -r e53f83b91052 extras/mini-os/xenbus/xenbus.c
@@ -41,6 +41,7 @@
 #define DEBUG(_f, _a...)    ((void)0)
 #endif
 
+static int xenbus_ready;
 static struct xenstore_domain_interface *xenstore_buf;
 static DECLARE_WAIT_QUEUE_HEAD(xb_waitq);
 DECLARE_WAIT_QUEUE_HEAD(xenbus_watch_queue);
@@ -254,12 +255,23 @@
     return o_probe;
 }
 
+int is_xenbus_ready(void)
+{
+    return xenbus_ready;
+}
+
 /* Initialise xenbus. */
 void init_xenbus(void)
 {
     int err;
     printk("Initialising xenbus\n");
     DEBUG("init_xenbus called.\n");
+
+    if (start_info.store_mfn == -1 || start_info.store_evtchn == -1) {
+        printk("No start_info store_mfn/store_evtchn, aborting init_xenbus\n");
+        return;
+    }
+
     xenstore_buf = mfn_to_virt(start_info.store_mfn);
     create_thread("xenstore", xenbus_thread_func, NULL);
     DEBUG("buf at %p.\n", xenstore_buf);
@@ -268,6 +280,8 @@
               NULL);
     unmask_evtchn(start_info.store_evtchn);
     DEBUG("xenbus on irq %d\n", err);
+
+    xenbus_ready = 1;
 }
 
 void fini_xenbus(void)

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel