[libvirt-users] Retrieving datas sent by host within the Guest

Jean-Pierre Ribeauville jpribeauville at axway.com
Wed Nov 4 14:38:43 UTC 2015


I' trying to read datas sent by my KVM host within the Guest.
Host send these datas trough a channel UNIX type , by using AF_UNIX socket stuff.

If i try to retrive the datas by using such type of thing in the Guest :

#define NAME "/dev/virtio-ports/agent"

sock = socket(AF_UNIX, SOCK_STREAM, 0);
12     if (sock < 0) {
13         perror("opening stream socket");
14         exit(1);
15     }
16     server.sun_family = AF_UNIX;
17     strcpy(server.sun_path, NAME);
18     if (bind(sock, (struct sockaddr *) &server, sizeof(struct sockaddr_un))) {
19         perror("binding stream socket");
20         exit(1);
21     }

I got  ""binding stream socket Address already in use"   when trying to bind the socket .

But If I use such kind of thing :

    fd = open("/dev/virtio-ports/agent", O_RDWR | O_NONBLOCK);
    ssize_t size = read(fd, &rcv_buffer, 100);
    if(size >0) printf("Read length(%d)  %s\n", size, rcv_buffer);

It works fine.

Is there any chance to be able to use socket stuff on Guest side or is there anything  I misunderstand?

Thanks for help.


J.P. Ribeauville

P: +33.(0).
Puteaux 3 Etage 5  Bureau 4

jpribeauville at axway.com<mailto:jpribeauville at axway.com>

P Pensez à l'environnement avant d'imprimer.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/libvirt-users/attachments/20151104/87539816/attachment.htm>

More information about the libvirt-users mailing list