Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am trying to establish a communication channel between the host and one of its guest virtual machine using kvm as a hypervisor. For this, I am using virtio-serial.

To create the virtual machine, I issued the following command:

qemu-system-x86_64 \
-m 2048 -name ubuntu \
-hda ubuntu_image \
-device virtio-serial \
-chardev socket,path=/tmp/foo,server,nowait,id=foo \
-device virtconsole,name=jobsfoo,chardev=foo,name=org.ubuntu.foo \

And then for communicating, on the guest, I use:

socat /dev/hvc0 -

And on the host:

socat /tmp/foo -

I come to understand that /tmp/foo is a socket and /dev/hvc0 a character device.

Why is there an symmetric interface for communication: a socket on the host and a character device on the guest?

share|improve this question
add comment

1 Answer 1

You have a character device on the guest because Unix and Unix-like operating systems represent serial ports as guest devices, and have done so for about as long as Unix has been around, and you explicitly asked for a virtual serial port in the guest.

You have a socket on the host because you explicitly asked for one. Presumably you want two-way communication from some program on the host to some program on the guest which understands serial ports. The other end of this socket is handled, of course, by the qemu process running the virtual machine. You could also have connected this to a pty to emulate a serial console, or to a plain file to just log everything coming out of the port.

share|improve this answer
    
Is there a way I can explicitly ask for a socket on the host? If not, can you please guide on how do I go about implementing a socket on top of the character device? –  i08in Feb 4 at 14:45
    
You already did! –  Michael Hampton Feb 4 at 14:55
    
I am sorry I meant a socket on the guest. –  i08in Feb 4 at 15:00
    
You don't. It's a virtual machine! –  Michael Hampton Feb 4 at 15:04
    
Why would that be a hindrance to create a socket on it, can you please elaborate? –  i08in Feb 4 at 15:12
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.