[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-discuss] hostfwd, connection hangs (qemu-system-x86_64)

From: Dmitry Dolgov
Subject: [Qemu-discuss] hostfwd, connection hangs (qemu-system-x86_64)
Date: Thu, 28 Mar 2019 14:02:34 +0100

hostfwd, connection hangs (qemu-system-x86_64)


It seems pretty simple, but for some reason when I'm trying to to expose a port
from an application within a qemu to the host system, it doesn't work for me.
What I'm doing is:

    qemu-system-x86_64 \
        -kernel custom_kernel/arch/x86/boot/bzImage \
        -initrd custom_initramfs/usr/initramfs.img \
        -virtfs ... \
        --enable-kvm \
        -m 1024M \
        -cpu host \
        -monitor unix:/tmp/qemu.socket,server,nowait \
        # one option
        -net user, hostfwd=tcp: \
        # or this way
        -netdev user,id=myid,hostfwd=tcp: \
        -device virtio-net,netdev=network0 -netdev
tap,id=network0,ifname=tap0,script=no,downscript=no \
        -nographic \
        -append "console=ttyS0"

There is a custom initramfs, busybox and a postgres database inside. From
whithin a qemu it looks like that:

    $ netstat -pna
    Proto Recv-Q Send-Q Local Address           Foreign Address
 State       PID/Program name
    tcp        0      0  *
 LISTEN      1114/postgres
    tcp6       0      0 :::5432                 :::*
 LISTEN      1114/postgres
    Active UNIX domain sockets (servers and established)
    Proto RefCnt Flags       Type       State         I-Node
PID/Program name     Path
    unix  2      [ ACC ]     STREAM     LISTENING     7582
1114/postgres        /tmp/.s.PGSQL.5432

>From the host point of view:

    $ netstat -pna | grep 5432
    tcp        0      0*           LISTEN

Then I'm trying to connect from host:

    $ psql -h -U postgres
    $ netstat -pna | grep 5432
    tcp        0      0*           LISTEN
    tcp        0      0
ESTABLISHED 27164/psql
    tcp        8      0
ESTABLISHED 26829/qemu-system-x

Looks like everything is fine, but connection doesn't work, and psql just hangs
and report timeout after some time. Netstat inside qemu also doesn't show any
connection open. Any ideas what am I doing wrong?

reply via email to

[Prev in Thread] Current Thread [Next in Thread]