Hi,
I'm trying to use unix-type channel to send/receive datas between host and guest .
Here are the steps I follow :
1) Adding these lines to expose a channel unix type to my guest
<channel type='unix'>
<source mode='bind'
path='/var/lib/libvirt/qemu/omnivision_1.agent'/>
<target type='virtio' name='org.qemu.guest_agent.0'/>
<alias name='channel0'/>
<address type='virtio-serial' controller='0' bus='0'
port='2'/>
</channel>
2) the VM_Orion-1 Guest, exposing a channel "unix" omnivision_1.agent is
started, then netstat shows these new things :
netstat -apn | grep qemu
unix 2 [ ACC ] STREAM LISTENING 37214 19124/qemu-kvm
/var/lib/libvirt/qemu/VM_Orion-1.monitor
unix 2 [ ACC ] STREAM LISTENING 37219 19124/qemu-kvm
/var/lib/libvirt/qemu/omnivision_1.agent
unix 3 [ ] STREAM CONNECTED 37242 19124/qemu-kvm
/var/lib/libvirt/qemu/omnivision_1.agent
unix 3 [ ] STREAM CONNECTED 37240 19124/qemu-kvm
/var/lib/libvirt/qemu/VM_Orion-1.monitor
3) I start , on the host , a simple test in order to send datas to the guest:
.....
sock = socket(AF_UNIX, SOCK_STREAM, 0);
if (sock < 0) {
perror("opening stream socket");
return(1);
}
server.sun_family = AF_UNIX;
strcpy(server.sun_path, argv[1]);
printf("connecting to socket number : %d \n",sock);
fflush(stdout);
if (connect(sock, (struct sockaddr *) &server, sizeof(struct sockaddr_un)) <
0) {
close(sock);
perror("connecting stream socket");
return(1);
}
printf("writing data on stream socket");
if (write(sock, DATA, sizeof(DATA)) < 0)
perror("writing on stream socket");
close(sock);
.....
4) invoking > test "/var/lib/libvirt/qemu/omnivision_1.agent"
then I got :
connecting to socket number : 3
writing data on stream socket
and following netstat result :
netstat -apn | grep qemu
unix 2 [ ACC ] STREAM LISTENING 39348 20587/qemu-kvm
/var/lib/libvirt/qemu/VM_Orion-1.monitor
unix 2 [ ACC ] STREAM LISTENING 39353 20587/qemu-kvm
/var/lib/libvirt/qemu/omnivision_1.agent
unix 2 [ ] STREAM CONNECTING 0 -
/var/lib/libvirt/qemu/omnivision_1.agent
unix 3 [ ] STREAM CONNECTED 39375 20587/qemu-kvm
/var/lib/libvirt/qemu/omnivision_1.agent
unix 3 [ ] STREAM CONNECTED 39373 20587/qemu-kvm
/var/lib/libvirt/qemu/VM_Orion-1.monitor
5) if I try to re-invoke test "/var/lib/libvirt/qemu/omnivision_1.agent" then
:
netstat -apn | grep qemu
tcp 0 0 127.0.0.1:5902 0.0.0.0:* LISTEN
20587/qemu-kvm
tcp 0 0 127.0.0.1:5902 127.0.0.1:57772 ESTABLISHED
20587/qemu-kvm
unix 2 [ ACC ] STREAM LISTENING 39348 20587/qemu-kvm
/var/lib/libvirt/qemu/VM_Orion-1.monitor
unix 2 [ ACC ] STREAM LISTENING 39353 20587/qemu-kvm
/var/lib/libvirt/qemu/omnivision_1.agent
unix 2 [ ] STREAM CONNECTING 0 -
/var/lib/libvirt/qemu/omnivision_1.agent
unix 2 [ ] STREAM CONNECTING 0 -
/var/lib/libvirt/qemu/omnivision_1.agent
unix 3 [ ] STREAM CONNECTED 39375 20587/qemu-kvm
/var/lib/libvirt/qemu/omnivision_1.agent
unix 3 [ ] STREAM CONNECTED 39373 20587/qemu-kvm
/var/lib/libvirt/qemu/VM_Orion-1.monitor
on the guest side , I try to retrieve datas sent by host , by using this kind of thing :
...
int fd = open("/dev/virtio-ports/org.qemu.guest_agent.0", O_RDWR | O_NONBLOCK);
ssize_t size = read(fd, &buffer, 100);
...
As you can imagine , I never receive any data from the host .
Is it the right way to use this "unix-type" channel ?
Thx for your patience.
Regards,
J.P. Ribeauville
P: +33.(0).1.47.17.27.87
Puteaux 3 Etage 5 Bureau 4
jpribeauville@axway.com<mailto:jpribeauville@axway.com>
http://www.axway.com<http://www.axway.com/>
P Pensez à l'environnement avant d'imprimer.