Statistics
| Branch: | Revision:

root / qemu-sockets.c @ 26ca8c06

History | View | Annotate | Download (26 kB)

# Date Author Comment
1de7afc9 12/19/2012 09:32 am Paolo Bonzini

misc: move include files to include/qemu/

Signed-off-by: Paolo Bonzini <>

83c9089e 12/19/2012 09:31 am Paolo Bonzini

monitor: move include files to include/monitor/

Signed-off-by: Paolo Bonzini <>

e478b448 12/11/2012 05:35 pm Dong Xu Wang

use qemu_opts_create_nofail

We will use qemu_opts_create_nofail function, it can make code
more readable.

Signed-off-by: Dong Xu Wang <>
Signed-off-by: Kevin Wolf <>

1ccbc285 11/21/2012 10:07 am Anthony PERARD

qemu-sockets: Fix parsing of the inet option 'to'.

Having a qemu command line argument like "-vnc 127.0.0.1:0,to=99" is broken.
This have been break with commit 879e45c72da1569e07fbbc6a1aa2a708ea796044.

Signed-off-by: Anthony PERARD <>...

3bc2f570 11/18/2012 09:19 pm Paolo Bonzini

build: replace weak symbols with a static library

Weak symbols were a nice idea, but they turned out not to be a good one.
Toolchain support is just too sparse, in particular llvm-gcc is totally
broken.

This patch uses a surprisingly low-tech approach: a static library....

1f001dc7 11/02/2012 08:07 pm Paolo Bonzini

compiler: support Darwin weak references

Weakrefs only tell you if the symbol was defined elsewhere, so you
need a further check at runtime to pick the default definition
when needed.

This could be automated by the compiler, but it does not do it.

Signed-off-by: Paolo Bonzini <>...

462016d2 10/30/2012 10:18 am Paolo Bonzini

iohandler: add weak alias in qemu-sockets.c, for qemu-ga

Signed-off-by: Paolo Bonzini <>

d249e1fc 10/30/2012 10:18 am Paolo Bonzini

sockets: use weak aliases instead of qemu-tool.c

qemu-tool.c has its own (largeish) set of dependencies. Weak aliases
can be placed directly where people use them, and do not contribute
to increasing the dependencies of generic utility files.

Signed-off-by: Paolo Bonzini <>

101f9cbc 10/23/2012 11:39 pm Paolo Bonzini

qemu-sockets: add socket_listen, socket_connect, socket_parse

These are QAPI-friendly versions of the qemu-sockets functions. They
support IP sockets, Unix sockets, and named file descriptors, using a
QAPI union to dispatch to the correct function.

Reviewed-by: Luiz Capitulino <>...

879e45c7 10/23/2012 08:05 pm Paolo Bonzini

qemu-sockets: return InetSocketAddress from inet_parse

Reviewed-by: Luiz Capitulino <>
Signed-off-by: Paolo Bonzini <>

a12fb8ad 10/23/2012 02:54 pm Paolo Bonzini

qemu-sockets: include strerror or gai_strerror output in error messages

Among others, before:

$ qemu-system-x86_64 -chardev socket,port=12345,id=char
inet_connect: host and/or port not specified
chardev: opening backend "socket" failed

After:...

11663b55 10/23/2012 02:54 pm Paolo Bonzini

qemu-sockets: add error propagation to inet_connect_addr

perror and fprintf can be removed because all clients can now consume
Errors properly. However, we'll need to change the non-blocking connect
handlers to take an Error, in order to improve error handling for...

4f085c82 10/23/2012 02:54 pm Paolo Bonzini

qemu-sockets: add error propagation to inet_dgram_opts

Before:

$ qemu-system-x86_64 -monitor udp:localhost:631@localhost:631
inet_dgram_opts: bind(ipv4,127.0.0.1,631): OK
inet_dgram_opts failed
chardev: opening backend "udp" failed

After:...

2f002c43 10/23/2012 02:54 pm Paolo Bonzini

qemu-sockets: add error propagation to inet_parse

Reviewed-by: Luiz Capitulino <>
Signed-off-by: Paolo Bonzini <>

58899664 10/23/2012 02:54 pm Paolo Bonzini

qemu-sockets: add error propagation to Unix socket functions

Before:

$ qemu-system-x86_64 -monitor unix:/vvv,server=off
connect(unix:/vvv): No such file or directory
chardev: opening backend "socket" failed

After:

$ x86_64-softmmu/qemu-system-x86_64 -monitor unix:/vvv,server=off...
7fc4e63e 10/23/2012 02:54 pm Paolo Bonzini

qemu-sockets: add Error ** to all functions

This lets me adjust the clients to do proper error propagation first,
thus avoiding temporary regressions in the quality of the error messages.

Reviewed-by: Luiz Capitulino <>
Signed-off-by: Paolo Bonzini <>

0c814709 10/23/2012 02:54 pm Paolo Bonzini

qemu-sockets: unix_listen and unix_connect are portable

They are just wrappers and do not need a Win32-specific version.

Reviewed-by: Luiz Capitulino <>
Signed-off-by: Paolo Bonzini <>

1fc05adf 10/23/2012 02:54 pm Paolo Bonzini

qemu-sockets: add nonblocking connect for Unix sockets

This patch mostly mimics what was done to TCP sockets, but simpler
because there is only one address to try. It also includes a free EINTR
bug fix.

Signed-off-by: Paolo Bonzini <>

4d5b97da 10/05/2012 04:10 pm Amos Kong

cleanup useless return sentence

This patch cleans up return sentences in the end of void functions.

Reported-by: Paolo Bonzini <>
Signed-off-by: Amos Kong <>
Signed-off-by: Stefan Hajnoczi <>

58455eb9 10/05/2012 03:49 pm Stefan Weil

qemu-sockets: Fix compiler warning (regression for MinGW)

setsockopt needs a type cast for MinGW. That type cast is missing in
a recent commit which results in a compiler warning.

Like for other socket related functions which have the same problem,
we add a 'qemu_setsockopt' macro which provides that type cast where...

233aa5c2 09/26/2012 03:05 am Orit Wasserman

Fix address handling in inet_nonblocking_connect

getaddrinfo can give us a list of addresses, but we only try to
connect to the first one. If that fails we never proceed to
the next one. This is common on desktop setups that often have ipv6
configured but not actually working....

05bc1d8a 09/26/2012 03:05 am Michael S. Tsirkin

Refactor inet_connect_opts function

refactor address resolution code to fix nonblocking connect
remove getnameinfo call

Signed-off-by: Michael S. Tsirkin <>
Signed-off-by: Amos Kong <>
Signed-off-by: Orit Wasserman <>...

5db5f44c 09/26/2012 03:05 am Orit Wasserman

Separate inet_connect into inet_connect (blocking) and inet_nonblocking_connect

No need to add non blocking parameters to the blocking inet_connect
add block parameter for inet_connect_opts instead of using QemuOpt "block".

Signed-off-by: Orit Wasserman <>...

39b38459 09/23/2012 09:11 am Stefan Weil

qemu-sockets: Fix potential memory leak

The old code leaks variable 'peer'.

Signed-off-by: Stefan Weil <>
Signed-off-by: Stefan Hajnoczi <>

540c79fe 08/13/2012 07:20 pm Luiz Capitulino

migration: don't rely on any QERR_SOCKET_*

Use the in_progress argument for QERR_SOCKET_CONNECT_IN_PROGRESS. The
other errors are handled the same by checking if the error is set and
then calling migrate_fd_error() if it's.

It's also necessary to change inet_connect_opts() not to set...

02a08fef 08/13/2012 07:20 pm Luiz Capitulino

net: inet_connect(), inet_connect_opts(): add in_progress argument

It's used to indicate the special case where a valid file-descriptor
is returned (ie. success) but the connection can't be completed
w/o blocking.

This is needed because QERR_SOCKET_CONNECT_IN_PROGRESS is not...

8715fc1e 08/03/2012 04:25 pm Amos Kong

socket: clean up redundant assignment

Signed-off-by: Amos Kong <>
Signed-off-by: Stefan Hajnoczi <>

e6d91ab6 07/29/2012 11:44 am Paolo Bonzini

place qemu-sockets.c contributions since 2012-01-13 under GPLv2+

Past contributions since 2012-01-13 were only made by Red Hat people,
so they are already available under GPLv2+.

Signed-off-by: Paolo Bonzini <>
Reviewed-by: Stefan Weil <>...

8be7e7e4 06/04/2012 07:49 pm Luiz Capitulino

qemu-option: qemu_opts_create(): use error_set()

This commit converts qemu_opts_create() from qerror_report() to
error_set().

Currently, most calls to qemu_opts_create() can't fail, so most
callers don't need any changes.

The two cases where code checks for qemu_opts_create() erros are:...

a6ba35b3 05/10/2012 08:37 pm Amos Kong

sockets: change inet_connect() to support nonblock socket

Add a bool argument to inet_connect() to assign if set socket
to block/nonblock, and delete original argument 'socktype'
that is unused.
Add a new argument to inet_connect()/inet_connect_opts(),
to pass back connect error by error class....

029409e5 05/10/2012 08:37 pm Amos Kong

sockets: use error class to pass listen error

Add a new argument in inet_listen()/inet_listen_opts()
to pass back listen error.

Change nbd, qemu-char, vnc to use new interface.

Signed-off-by: Amos Kong <>
Reviewed-by: Orit Wasserman <>...

136faa36 02/24/2012 05:06 pm Markus Armbruster

sockets: Drop sockets_debug debug code

I'm trying to improve this code's error reporting, and the debug code
is getting in my way: it clutters the code, it clobbers errno in
inconvenient places, and it uses the same fprintf() both for error
reporting and debug output in a few places....

877691f9 02/24/2012 05:06 pm Markus Armbruster

sockets: Clean up inet_listen_opts()'s convoluted bind() loop

Signed-off-by: Markus Armbruster <>
Signed-off-by: Anthony Liguori <>

9d947472 11/11/2011 08:49 pm Markus Armbruster

qemu-sockets: Plug fd leak on unix_connect_opts() error path

Spotted by Coverity.

Signed-off-by: Markus Armbruster <>
Signed-off-by: Anthony Liguori <>

7267c094 08/21/2011 07:01 am Anthony Liguori

Use glib memory allocation and free functions

qemu_malloc/qemu_free no longer exist after this commit.

Signed-off-by: Anthony Liguori <>

b82eac92 04/07/2011 02:51 pm Nick Thomas

Set errno=ENOTSUP for attempts to use UNIX sockets on Windows platforms

Signed-off-by: Nick Thomas <>
Signed-off-by: Kevin Wolf <>

e23a22e6 05/18/2010 08:49 pm Jens Osterkamp

qemu-sockets: avoid strlen of NULL pointer

If the user wants to create a chardev of type socket but forgets to give a
host= option, qemu_opt_get returns NULL. This NULL pointer is then fed into
strlen a few lines below without a check which results in a segfault....

0706a4dc 04/09/2010 07:55 pm Paolo Bonzini

move socket_init to qemu-sockets.c

Signed-off-by: Paolo Bonzini <>
Signed-off-by: Aurelien Jarno <>

2198a62e 02/10/2010 08:46 pm Marcelo Tosatti

fix inet_parse typo

qemu_opt_set wants on/off, not yes/no.

Signed-off-by: Marcelo Tosatti <>
Signed-off-by: Anthony Liguori <>

c9c4b34e 01/20/2010 04:25 pm Luiz Capitulino

net: Make inet_strfamily() public

So that it can be used by other subsystems.

Signed-off-by: Luiz Capitulino <>
Signed-off-by: Anthony Liguori <>

c445321e 01/20/2010 04:25 pm Luiz Capitulino

net: inet_strfamily(): Better unknown family report

Returning "????" is a bit meaningless, let's call it "unknown".

Signed-off-by: Luiz Capitulino <>
Signed-off-by: Anthony Liguori <>

40ff6d7e 12/03/2009 07:45 pm Kevin Wolf

Don't leak file descriptors

We're leaking file descriptors to child processes. Set FD_CLOEXEC on file
descriptors that don't need to be passed to children to stop this misbehaviour.

Signed-off-by: Kevin Wolf <>
Signed-off-by: Anthony Liguori <>

c1390903 09/12/2009 12:58 pm Blue Swirl

Add 'static'

Signed-off-by: Blue Swirl <>

72cf2d4f 09/12/2009 10:36 am Blue Swirl

Fix sys-queue.h conflict for good

Problem: Our file sys-queue.h is a copy of the BSD file, but there are
some additions and it's not entirely compatible. Because of that, there have
been conflicts with system headers on BSD systems. Some hacks have been
introduced in the commits 15cc9235840a22c289edbe064a9b3c19c5f49896,...

7e1b35b4 09/11/2009 06:19 pm Gerd Hoffmann

convert udp chardev to QemuOpts.

While being at it: create a new inet_dgram_opts() function for udp setup,
so udp can handle IPv6 now.

new cmd line syntax:
-chardev udp,id=name,host=remotehost,port=remoteport,\
localaddr=bindaddr,localport=bindport...

2af2bf67 09/11/2009 06:19 pm Gerd Hoffmann

sockets: add unix_connect_opts

Add unix_connect_opts(). Does the same as unix_connect(), but uses
QemuOpts. unix_connect() is a compatibility wrapper for
unix_connect_opts() now and should go away some day.

Signed-off-by: Gerd Hoffmann <>...

62b6adfb 09/11/2009 06:19 pm Gerd Hoffmann

sockets: add unix_listen_opts

Add unix_listen_opts(). Does the same as unix_listen(), but uses
QemuOpts. unix_listen() is a compatibility wrapper for
unix_listen_opts() now and should go away some day.

Signed-off-by: Gerd Hoffmann <>
Signed-off-by: Anthony Liguori <>

108af7b9 09/11/2009 06:19 pm Gerd Hoffmann

sockets: add unix_*_opts for windows.

Add unix_*_opts function dummys for windows.

Signed-off-by: Gerd Hoffmann <>
Signed-off-by: Anthony Liguori <>

f4c94c7c 09/11/2009 06:19 pm Gerd Hoffmann

sockets: add inet_connect_opts

Add inet_connect_opts(). Does the same as inet_connect(), but uses
QemuOpts. inet_connect() is a compatibility wrapper for
inet_connect_opts() now and should go away some day.

Signed-off-by: Gerd Hoffmann <>...

e5bc776f 09/11/2009 06:19 pm Gerd Hoffmann

sockets: add inet_listen_opts

Add inet_listen_opts(). Does the same as inet_listen(), but uses
QemuOpts. inet_listen() is a compatibility wrapper for
inet_listen_opts() now and should go away some day.

Signed-off-by: Gerd Hoffmann <>
Signed-off-by: Anthony Liguori <>

39b6efc8 05/09/2009 12:11 am vibi

Fix in file qemu-sockets.c

1) Changed usage of malloc,free,strdup to qemu_malloc,qemu_free,qemu_strdup
2) Some coding style fixes (based on CODING_STYLE document)
3) Free struct addrinfo *res after failure of listen

Signed-off-by: vibi <>...

bc575e95 01/14/2009 08:34 pm blueswir1

Fix some more warnings

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6300 c046a42c-6fe2-441c-8c8c-71466251a162

47398b9c 11/22/2008 10:04 pm blueswir1

Use qemu_isfoobar and qemu_towombat versions, based on patch by Christoph Egger

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5774 c046a42c-6fe2-441c-8c8c-71466251a162

305b0eb2 11/13/2008 06:19 pm aliguori

copyright & license for qemu_sockets.c (Gerd Hoffman)

Signed-off-by: Gerd Hoffmann <>
Signed-off-by: Anthony Liguori <>

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5714 c046a42c-6fe2-441c-8c8c-71466251a162

d247d25f 11/11/2008 10:46 pm aliguori

sockets: helper functions for qemu (Gerd Hoffman)

This patch creates a new source file qemu-sockets.c with a bunch of
helper functions to create listening and connected sockets.

New features of this code are (a) support for searching for a free
port in a given range and (b) support for IPv6....