Hi
I am having a problem with xs_read..
In my program I want to create a VM and get the vnc port out of it.. and
this is a multi threaded programs.. but I have made sure that there will
be only one create at a time
This is the function that reads the vnc port off the xenstore
------------------------------------------------------------------------------------------------------------------------------
/**
* Returns the VNC port for a given dom ID
* 0 in case of a failure
*/
unsigned int get_vnc_port(unsigned int dom_id){
unsigned int port = 0;
unsigned int len=0;
struct xs_handle* xsn;
xsn = connect_to_xenstore();
if(xsn){
char s[40];
snprintf(s, 39, "/local/domain/%u/console/vnc-port",
dom_id);
s[39] = 0;
LOG_INFO_MSG("Trying to read %s off XEN Store",s);
char *vnc_port = (char *)xs_read(xs,0,&s[0],&len);
LOG_INFO_MSG("Value read %p off XEN Store LEN
%u",vnc_port,len);
close_conn_xenstore(xsn);
if(vnc_port && len>0){
LOG_INFO_MSG("VNC port from xs %s ",vnc_port);
port = atoi(vnc_port);
free(vnc_port);
LOG_INFO_MSG("VNC port for dom %u is %u
",dom_id,port);
}else{
LOG_ERROR_MSG("Could Not get the VNC port for
dom %u",dom_id);
}
}else{
LOG_ERROR_MSG("Could Not Connect to xenstore");
}
return port;
}
---------------------------------------------------------------------------------------------
This code works most of the time but at some point it gives segmentation
fault
The Logging Info
LOG_INFO_MSG("Value read %p off XEN Store LEN %u",vnc_port,len);
log out the following before the segmentation fault happens (seems like
some sort of a garbage memory )
Mar 5 14:16:50 Agent: [25238]: Value read 0xffffffffac0008f0 off XEN
Store LEN 4
When this work The info log looks as follows
Mar 5 14:16:43 Agent: [25238]: Value read 0x63e5a0 off XEN Store LEN 4
Does any one have ant insight to why this is happening.. or a way of
avoiding this..
Thanks
--
Gihan Munasinghe
Development Team Leader
XCalibre Communications Ltd.
www.flexiscale.com
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
|