Skip to content
  • Marc-André Lureau's avatar
    fdec16e3
    net/socket: learn to talk with a unix dgram socket · fdec16e3
    Marc-André Lureau authored
    
    
    -net socket has a fd argument, and may be passed pre-opened sockets.
    
    TCP sockets use framing.
    UDP sockets have datagram boundaries.
    
    When given a unix dgram socket, it will be able to read from it, but
    will attempt to send on the dgram_dst, which is unset. The other end
    will not receive the data.
    
    Let's teach -net socket to recognize a UNIX DGRAM socket, and use the
    regular send() command (without dgram_dst).
    
    This makes running slirp out-of-process possible that
    way (python pseudo-code):
    
    a, b = socket.socketpair(socket.AF_UNIX, socket.SOCK_DGRAM)
    
    subprocess.Popen('qemu -net socket,fd=%d -net user' % a.fileno(), shell=True)
    subprocess.Popen('qemu ... -net nic -net socket,fd=%d' % b.fileno(), shell=True)
    
    Signed-off-by: default avatarMarc-André Lureau <marcandre.lureau@redhat.com>
    Signed-off-by: default avatarJason Wang <jasowang@redhat.com>
    fdec16e3
    net/socket: learn to talk with a unix dgram socket
    Marc-André Lureau authored
    
    
    -net socket has a fd argument, and may be passed pre-opened sockets.
    
    TCP sockets use framing.
    UDP sockets have datagram boundaries.
    
    When given a unix dgram socket, it will be able to read from it, but
    will attempt to send on the dgram_dst, which is unset. The other end
    will not receive the data.
    
    Let's teach -net socket to recognize a UNIX DGRAM socket, and use the
    regular send() command (without dgram_dst).
    
    This makes running slirp out-of-process possible that
    way (python pseudo-code):
    
    a, b = socket.socketpair(socket.AF_UNIX, socket.SOCK_DGRAM)
    
    subprocess.Popen('qemu -net socket,fd=%d -net user' % a.fileno(), shell=True)
    subprocess.Popen('qemu ... -net nic -net socket,fd=%d' % b.fileno(), shell=True)
    
    Signed-off-by: default avatarMarc-André Lureau <marcandre.lureau@redhat.com>
    Signed-off-by: default avatarJason Wang <jasowang@redhat.com>
Loading