All of lore.kernel.org
 help / color / mirror / Atom feed
* xs_read problem leads segmentation fault
@ 2009-03-05 14:49 Gihan Munasinghe
  0 siblings, 0 replies; only message in thread
From: Gihan Munasinghe @ 2009-03-05 14:49 UTC (permalink / raw)
  To: xen-devel


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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2009-03-05 14:49 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-03-05 14:49 xs_read problem leads segmentation fault Gihan Munasinghe

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.