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

[Xen-devel] [PATCH 10/10] Xen: Xenstore example -do not apply

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH 10/10] Xen: Xenstore example -do not apply
From: Daniel Castro <evil.dani@xxxxxxxxx>
Date: Fri, 19 Aug 2011 01:03:27 +0900
Cc: Daniel Castro <evil.dani@xxxxxxxxx>
Delivery-date: Thu, 18 Aug 2011 09:17:46 -0700
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=jkICv5DcmJhDPBUNa/qX6hwRMCv/PN1/cPJImxIq5zo=; b=bvGcI2M8WWa5VzgtbIdcTlCL7yxXtROsnvbhTzyH6bS1fRMi+kWB5ssuppd6x1X+t5 bKbccn6RQUn6NiKZfuco73dMA1E4akMu8WKT2/r7fQuQxvU78mXcsHgF3lLCald6kmp8 I3cp5Vf6/rLbVfzwLPKzrEBSM3+NgZkd0rANE=
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <1313683408-32306-1-git-send-email-evil.dani@xxxxxxxxx>
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: <1313683408-32306-1-git-send-email-evil.dani@xxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
Here is a simple example of xenstore query functionality. Please
do not apply this patch.

After the xenbus ring initialization we issue a directory query
for the list of virtual block devices attached to the current
guest. The answer is displayed in the console. For simplicity we
only print the first vbd but we leave a clue that there may be
more.

Signed-off-by: Daniel Castro <evil.dani@xxxxxxxxx>
---
 src/xen-xs.c |   10 +++++++++-
 src/xen-xs.h |    1 +
 2 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/src/xen-xs.c b/src/xen-xs.c
index d4b6b26..1173ce2 100644
--- a/src/xen-xs.c
+++ b/src/xen-xs.c
@@ -36,7 +36,7 @@ static struct xenstore_domain_interface *rings; /* Shared 
ring with dom0 */
 static evtchn_port_t event;                     /* Event-channel to dom0 */
 static char payload[XENSTORE_PAYLOAD_MAX + 1];  /* Unmarshalling area */
 
-
+void test_xenstore(void);
 /*
  * Connect our xenbus client to the backend.
  * Call once, before any other xenbus actions.
@@ -62,6 +62,7 @@ void xenbus_setup(void)
        event = param.value;
        dprintf(1,"Xenbus rings @0x%lx, event channel %lu\n",
                        (unsigned long) rings, (unsigned long) event);
+       test_xenstore();
 }
 
 /*
@@ -241,3 +242,10 @@ char * xenstore_directory(char *path, u32 *ans_len){
        /* We know xenbus_send() nul-terminates its answer, so just pass it on. 
*/
        return answer;
 }
+
+void test_xenstore(void){
+       char path[11] = {'d','e','v','i','c','e','/','v','b','d','\0'};
+       u32 ans_len;
+       char * res = xenstore_directory(path,&ans_len);
+       dprintf(1,"length: %d strlen: %d vdb-id: %s 
.\n",ans_len,strlen(res),res);
+}
diff --git a/src/xen-xs.h b/src/xen-xs.h
index 91e8da0..6957031 100644
--- a/src/xen-xs.h
+++ b/src/xen-xs.h
@@ -4,5 +4,6 @@
 void xenbus_setup(void);
 char * xenstore_read(char *path);
 char * xenstore_directory(char *path, u32 *ans_len);
+void test_xenstore(void);
 
 #endif
-- 
1.7.4.1


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