Patchwork [04/15] xen: xen_machine_fv, initialize xenstore

login
register
mail settings
Submitter Stefano Stabellini
Date Aug. 12, 2010, 2:09 p.m.
Message ID <1281622202-3453-4-git-send-email-stefano.stabellini@eu.citrix.com>
Download mbox | patch
Permalink /patch/61600/
State New
Headers show

Comments

Stefano Stabellini - Aug. 12, 2010, 2:09 p.m.
From: Anthony PERARD <anthony.perard@citrix.com>

Introduce a xen_dm_init function that opens a new xenstore connection
and the xenctrl interface; call xen_dm_init from xen_machine_fv.

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
---
 Makefile.target       |    1 +
 hw/xen_machine_fv.c   |    8 ++++++++
 target-xen/xenstore.c |   24 ++++++++++++++++++++++++
 target-xen/xenstore.h |    6 ++++++
 4 files changed, 39 insertions(+), 0 deletions(-)
 create mode 100644 target-xen/xenstore.c
 create mode 100644 target-xen/xenstore.h

Patch

diff --git a/Makefile.target b/Makefile.target
index 359a984..63dc7d1 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -323,6 +323,7 @@  obj-xen-y += i8259.o
 obj-xen-y += pc.o
 obj-xen-y += piix_pci.o
 obj-xen-y += mc146818rtc.o
+obj-xen-y += xenstore.o
 
 obj-xen-y += xen_mapcache.o
 obj-xen-y += stub-functions.o
diff --git a/hw/xen_machine_fv.c b/hw/xen_machine_fv.c
index 8114460..5fef7de 100644
--- a/hw/xen_machine_fv.c
+++ b/hw/xen_machine_fv.c
@@ -32,6 +32,8 @@ 
 #include "ide.h"
 #include "sysemu.h"
 
+#include "xen_backend.h"
+#include "xenstore.h"
 #include "xen/hvm/hvm_info_table.h"
 
 #define MAX_IDE_BUS 2
@@ -61,6 +63,12 @@  static void xen_init_fv(ram_addr_t ram_size,
 
     CPUState *env;
 
+    /* Initialize backend core & drivers */
+    if (xen_dm_init() != 0) {
+        fprintf(stderr, "%s: xen backend core setup failed\n", __FUNCTION__);
+        exit(1);
+    }
+
     /* Initialize a dummy CPU */
     if (cpu_model == NULL) {
 #ifdef TARGET_X86_64
diff --git a/target-xen/xenstore.c b/target-xen/xenstore.c
new file mode 100644
index 0000000..c202f66
--- /dev/null
+++ b/target-xen/xenstore.c
@@ -0,0 +1,24 @@ 
+#include "hw/xen_backend.h"
+#include "xenstore.h"
+
+int xen_dm_init(void)
+{
+    xenstore = xs_daemon_open();
+    if (!xenstore) {
+        xen_be_printf(NULL, 0, "can't connect to xenstored\n");
+        return -1;
+    }
+
+    xen_xc = xc_interface_open(NULL, NULL, 0);
+    if (xen_xc == NULL) {
+        xen_be_printf(NULL, 0, "can't open xen interface\n");
+        goto err;
+    }
+    return 0;
+
+err:
+    xs_daemon_close(xenstore);
+    xenstore = NULL;
+
+    return -1;
+}
diff --git a/target-xen/xenstore.h b/target-xen/xenstore.h
new file mode 100644
index 0000000..90baf79
--- /dev/null
+++ b/target-xen/xenstore.h
@@ -0,0 +1,6 @@ 
+#ifndef XENSTORE_H_
+#define XENSTORE_H_
+
+int xen_dm_init(void);
+
+#endif /* !XENSTORE_H_ */