11 #include <sys/types.h>
14 #include<linux/unistd.h>
18 int main(int argc, char* argv[]) {
26 printf("usage: v3_monitor <vm_device> <stream_name>\n");
33 vm_fd = open(vm_dev, O_RDONLY);
35 printf("Error opening VM device: %s\n", vm_dev);
39 cons_fd = ioctl(vm_fd, V3_VM_CONSOLE_CONNECT, stream);
41 /* Close the file descriptor. */
44 printf("Error opening stream Console\n");
51 memset(cons_buf, 0, sizeof(cons_buf));
55 FD_SET(cons_fd, &rset);
57 ret = select(cons_fd + 1, &rset, NULL, NULL, NULL);
60 bytes_read = read(cons_fd, cons_buf, 1024);
61 cons_buf[bytes_read]='\0';
62 printf("%s", cons_buf);
64 printf("v3_monitor ERROR: select returned %d\n", ret);