Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

imgedit.py can't always connect to qemu-nbd #534

Closed
jpeach opened this issue Oct 27, 2014 · 2 comments
Closed

imgedit.py can't always connect to qemu-nbd #534

jpeach opened this issue Oct 27, 2014 · 2 comments

Comments

@jpeach
Copy link

jpeach commented Oct 27, 2014

There are a couple of issues with imgedit.py being able to reliably connect to qemu-nbd.

First, it connects to "localhost". On my Fedora20 VM, "localhost" was configured to resolve to ::1, and emu-nbd seems to only listen on IPv4 addresses. I fixed this by editing imgedit.py to connect to "127.0.0.1".

Second, imgedit.py assumes the port number that qemu-nbd is going to listen to. It should be choosing an explicit port and passing that as the argument to the qemu-nbd --port option and to the nbd_client port= argument.

@wkozaczuk
Copy link
Collaborator

We could do something similar to

def find_free_port():
with closing(socket.socket(socket.AF_INET, socket.SOCK_STREAM)) as s:
s.bind(('localhost', 0))
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
return s.getsockname()[1]
to fix it.

@nyh
Copy link
Contributor

nyh commented May 19, 2019

Two years after this issue was opened, imgedit.py was changed in commit 464f4e0 to open a random port in the same way described here.

The fact we allow qemu-nbd to default to listening to any IPv4 address but then connect to localhost, remains. The real solution is very simple and described in issue #709: imgedit.py should call qemu-nbd with "-b 127.0.0.1" and connect to 127.0.0.1, instead of localhost.
So I'm closing this issue in favor of #709.

@nyh nyh closed this as completed May 19, 2019
wkozaczuk pushed a commit that referenced this issue May 27, 2019
Since commit 464f4e0, imgedit.py opens runs qemu-nbd on a random port,
but qemu-nbd needlessly listens to all interfaces - including potentially
to connections from the outside world. While the practical risk is minimal
(imgedit.py runs for very short duration), there is no need to take it at
all - qemu-nbd should only listen to the 127.0.0.1 interface (see issue #709).

And in turn, imgedit.py should contact 127.0.0.1 and not rely on the
alias "localhost" working for ipv4 (see issue #534).

Signed-off-by: Nadav Har'El <[email protected]>
Message-Id: <[email protected]>
tonosaman pushed a commit to tonosaman/osv that referenced this issue May 30, 2019
Since commit 464f4e0, imgedit.py opens runs qemu-nbd on a random port,
but qemu-nbd needlessly listens to all interfaces - including potentially
to connections from the outside world. While the practical risk is minimal
(imgedit.py runs for very short duration), there is no need to take it at
all - qemu-nbd should only listen to the 127.0.0.1 interface (see issue cloudius-systems#709).

And in turn, imgedit.py should contact 127.0.0.1 and not rely on the
alias "localhost" working for ipv4 (see issue cloudius-systems#534).

Signed-off-by: Nadav Har'El <[email protected]>
Message-Id: <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants