[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] Regarding Xenstore/Xenbus
Once again thanks for replying, I appreciate your patience.Actually I already realized that mistake and replaced "daemon_open" with "domain_open". But getting the "unknown error" has now changed into a "segmentation fault" and apparently it occurs after i execute the "xs_directory" function to get the path in buf2 variable (line31 below). I checked the value of 'len' variable after the call and it turns out to be arbitrarily large. What am I doing wrong here ? After replacing "daemon_open" with "domain_open" all the rest of the calls to xs.h functions remain the same or are there specific "daemon" and "domain" versions of functions? (apparently its the former case) A few related questions:-Are there any specific initializations/calls that need to be made from inside domU to first initialize and then access xenstore ? Or the functions exposed by xs.h are the only thing required ? Apparently xenstore is initialized by dom0 once at startup only.-Does ability to communicate with xenstore depend on whether the ethernet interface b/w dom0 and domU is working or not (since it uses sockets)? Currently my domU can't ping dom0 or any one else for that matter.-I am trying to only read the xenstore(which is allowed to all domains by default), does my problem in anyway relate to xenstore access permissions ?-Are you aware of any user-space management tools available that access xenstore from within domU? Sorry for a detailed mail but I am just a beginner and dont know a lot of stuff. I'll appreciate your help once again. ------------------------------------------------------------------------------------------- 1 #include <xs.h> 2 #include <sys/types.h> 3 #include <stdio.h> 4 #include <string.h> 5 6 void main(int argc, char *argv[]) 7 { 8 9 struct xs_handle *xs; 10 xs_transaction_t th; 11 char *path; 12 int fd; 13 fd_set set; 14 int er; 15 struct timeval tv = {.tv_sec = 0, .tv_usec = 0 }; 16 char **vec; 17 unsigned int num; 18 char * buf; 19 char ** buf2; 20 unsigned int len; 21 22 unsigned int domid; 23 24 printf("Msg1\n"); 25 26 /* Get a connection to the daemon */ 27 xs = xs_domain_open(); 28 if ( xs == NULL ) error(); 29 30 th = xs_transaction_start(xs); 31 buf2 = xs_directory(xs, th,"/local/domain", &len); 32 xs_transaction_end(xs, th, true); 33 34 int i=0; 35 36 for(i=0;i<len;i++) 37 { 38 printf("%s\n",buf2[i]); 39 } 40 4142 // I am running dom0 and oly 1 domU so this condition chooses one of them 43 if(len>1) 44 domid = atoi(buf2[1]); 45 if(len==1) 46 domid = atoi(buf2[0]); 47 //sprintf( domid, "%ui", buf2[0] ); 48 49 printf("Domid: %i\n", domid); 50 51 /* Get the local domain path */ 52 path = xs_get_domain_path(xs, domid); 53 if ( path == NULL ) error(); 54 55 printf("Msg3\n"); 56 57 /* Make space for our node on the path */ 58 path = realloc(path, strlen(path) + strlen("/memory/target") + 1); 59 if ( path == NULL ) error(); 60 strcat(path, "/memory/target"); 61 62 /* Create a watch on /local/domain/%d/mynode. */ 63 er = xs_watch(xs, path, "mytoken"); 64 if ( er == 0 ) error(); 65 66 /* We are notified of read availability on the watch via the 67 * file descriptor. 68 */ 69 fd = xs_fileno(xs); 70 71 while (1) 72 { 73 FD_ZERO(&set); 74 FD_SET(fd, &set); 75 76 /* Poll for data. */ 77 if ( select(fd + 1, &set, NULL, NULL, &tv) > 0 78 && FD_ISSET(fd, &set)) 79 { 80 /* I am not sure how num works -- please describe. */ 81 vec = xs_read_watch(xs, &num); 82 if ( !vec ) error(); 83 printf("vec contents: %s|%s\n", vec[XS_WATCH_PATH], 84 vec[XS_WATCH_TOKEN]); 85 86 /* Prepare a transaction and do a read. */ 87 th = xs_transaction_start(xs); 88 buf = xs_read(xs, th, vec[XS_WATCH_PATH], &len); 89 xs_transaction_end(xs, th, true); 90 if ( buf ) 91 { 92 printf("buflen: %d\nbuf: %s\n", len, buf); 93 } 94 95 /* Prepare a transaction and do a write. */ 96 /*th = xs_transaction_start(xs); 97 98 er = xs_write(xs, th, path, "somestuff", strlen("somestuff")); 99 xs_transaction_end(xs, th, true); 100 if ( er == 0 ) error();*/ 101 } 102 } 103 104 /* Cleanup */ 105 close(fd); 106 xs_daemon_close(xs); 107 free(path); 108 109 }----- Original Message ----- From: "Vincent Hanquez" <vincent@xxxxxxxxxxxxx> To: "Umar Farooq Minhas" <umarfm13@xxxxxxxxxxx> Cc: <aball@xxxxxxxxxxxxxxxxxx>; <xen-devel@xxxxxxxxxxxxxxxxxxx> Sent: Wednesday, November 22, 2006 10:52 AM Subject: Re: [Xen-devel] Regarding Xenstore/Xenbus On Mon, Nov 20, 2006 at 08:21:20PM -0500, Umar Farooq Minhas wrote:Thanks for your reply. I was into trying out xenstore acess using 'libxenstore.so'. I have copied the exact code that I am trying to run(most of this comes from xenstore wiki). The issue is that I am able to runthis code from dom0 but when I try to run it from inside a domU after the first printf output i.e. "Msg1" it terminates abnormally saying "unknown error". My guess is that its failing when it calls xs_daemon_open(). I can't figure out what am i missing. Some processes need to be started before i can acess xenstore? Are there any packages that need to beinstalled in domU to access xenstore? I already have 'xen-devel', 'xen-lib'and 'xen-tools' packages installed inside domU. Please help.you need to use "domain_open" instead of "daemon_open" in domU. daemon_open is using a direct unix socket to communicate with xenstored. this socket is only accessible to dom0. domU need to use the other way to communicate with xenstored. Cheers, -- Vincent Hanquez _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |