Using the qemu Monitor
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
Quoted 31 lines
Quoted 30 lines
From: Henrik Nordstrom <[email protected]>
Date: 21 May 2005 02:13:05 GMT-04:00
To: [email protected]
Subject: Re: [Qemu-devel] Using the qemu Monitor
Reply-To: [email protected]Quoted 11 lines · Julian Chesterfield
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 ptyI then get the message:
char device redirected to/dev/pts/0You then need to open
/dev/pts/0as if it was a serial port...Regards
Henrik_______________________________________________
Qemu-devel mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/qemu-devel