qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Fwd: [Qemu-devel] Using the qemu Monitor


From: Julian Chesterfield
Subject: Re: Fwd: [Qemu-devel] Using the qemu Monitor
Date: Wed, 25 May 2005 17:49:29 -0400 (EDT)

Henrik,

I had been trying to connect to /dev/pts/0 and am having trouble receiving 
data. I'm running redhat 9 and have written a small program to open the 
pty and read/write to it. First time I connect I receive the 'QEMU 0.7.0 
monitor - type 'help' for more information' welcome message. From this 
point onwards I can write commands, but do not read any data from the 
socket. I have 2 questions therefore... Is there a standard unix utility 
that I can use to verify the pts socket is working (I've tried minicom 
and kermit, neither are able to send/receive over the socket)? Perhaps 
there's an error in my test code below?


Code:

/*Socket open and config*/
fd = open(argv[1], O_RDWR | O_NOCTTY | O_NDELAY);
fcntl(fd, F_SETFL, 0); /*Set port to block*/

tcgetattr(fd, &options);
options.c_cflag     |= (CLOCAL | CREAD);
options.c_cflag &= ~CSIZE;
options.c_cflag |= CS8;
options.c_lflag     |= (ICANON | ECHO | ECHOE | ISIG);
options.c_oflag     &= ~OPOST;
options.c_cc[VMIN]  = 0;
options.c_cc[VTIME] = 10;

cfsetispeed(&options, B38400);
cfsetospeed(&options, B38400);
tcsetattr(fd, TCSANOW, &options);

/*initial socket read */
FD_ZERO(&fds);
FD_SET(fd,&fds);
timeout.tv_sec = 1;
timeout.tv_usec = 0;
maxfd = fd+1;
if(select(maxfd,&fds,NULL,NULL,&timeout)>0) {
        nbytes = read(fd, buffer, MAXBUFLEN - 1);
        printf("%s\n",buffer);
}

while(running) {
        enter_string = (char *)calloc(1,MAXBUFLEN);
        bufptr = enter_string;
        memset(enter_string,0x00,MAXBUFLEN);
                        
        if(fgets(enter_string,MAXBUFLEN,stdin)==enter_string) {
                bufptr+=strlen(enter_string);
                *bufptr = '\r';
        } else exit(-1);

        printf("Command received, %s\n",enter_string);

        nbytes = write(fd, enter_string,strlen(enter_string));
        printf("Wrote %d bytes\n",nbytes);

        /*Read response, block until received*/
        nbytes = read(fd, buffer, MAXBUFLEN - 1);
        printf("Received %s\n",buffer);
}

The code above never returns from the final read. Using select 
instead never indicates data available to read. Thanks in advance for any 
pointers!

- Julian


> > From: Henrik Nordstrom <address@hidden>
> > Date: 21 May 2005 02:13:05 GMT-04:00
> > To: address@hidden
> > Subject: Re: [Qemu-devel] Using the qemu Monitor
> > Reply-To: address@hidden
> >
> > On Fri, 20 May 2005, Julian Chesterfield wrote:
> >
> >> Is there a way to redirect monitor IO to a local socket, e.g. a unix
> >> filehandle socket, under linux? When I try to redirect to a pty using
> >> '-monitor pty' the graphical qemu window doesn't boot. Am I starting
> >> it incorrectly?
> >>
> >> ARGS:
> >> qemu -hda <IMAGE> -m 256 -boot c -nics 1 -n <IFUP_SCRIPT> -full-screen
> >> -monitor pty
> >>
> >> I then get the message:
> >> char device redirected to /dev/pts/0
> >
> > You then need to open /dev/pts/0 as if it was a serial port...
> >
> > Regards
> > Henrik
> >
> >
> > _______________________________________________
> > Qemu-devel mailing list
> > address@hidden
> > http://lists.nongnu.org/mailman/listinfo/qemu-devel
> 





reply via email to

[Prev in Thread] Current Thread [Next in Thread]