- Jan 26, 2017
-
-
Daniel P. Berrangé authored
If a QIOTask has an error set and the calling code uses qio_task_propagate_error() to steal the reference to that Error object, the task would not clear its own reference. This would lead to a double-free when qio_task_free runs, if the caller had (correctly) freed the Error object they now owned. Signed-off-by:
Daniel P. Berrange <berrange@redhat.com>
-
- Jan 23, 2017
-
-
Daniel P. Berrangé authored
Currently DNS resolution is done automatically as part of the creation of a QIOChannelSocket object instance. This works ok for network clients where you just end up a single network socket, but for servers, the results of DNS resolution may require creation of multiple sockets. Introducing a DNS resolver API allows DNS resolution to be separated from the socket object creation. This will make it practical to create multiple QIOChannelSocket instances for servers. Reviewed-by:
Eric Blake <eblake@redhat.com> Signed-off-by:
Daniel P. Berrange <berrange@redhat.com>
-
Daniel P. Berrangé authored
Now that task objects have a directly associated error, there's no need for an an Error **errp parameter to the QIOTask thread worker function. It already has a QIOTask object, so can directly set the error on it. Reviewed-by:
Eric Blake <eblake@redhat.com> Signed-off-by:
Daniel P. Berrange <berrange@redhat.com>
-
Daniel P. Berrangé authored
Currently the QIOTaskFunc signature takes an Object * for the source, and an Error * for any error. We also need to be able to provide a result pointer. Rather than continue to add parameters to QIOTaskFunc, remove the existing ones and simply pass the QIOTask object instead. This has methods to access all the other data items required in the callback impl. Reviewed-by:
Eric Blake <eblake@redhat.com> Signed-off-by:
Daniel P. Berrange <berrange@redhat.com>
-
Daniel P. Berrangé authored
Currently when a task fails, the error is never explicitly associated with the task object, it is just passed along through the completion callback. This adds the ability to explicitly associate an error with the task. Signed-off-by:
Daniel P. Berrange <berrange@redhat.com>
-
Daniel P. Berrangé authored
Currently there is no data associated with a successful task completion. This adds an opaque pointer to the task to store an arbitrary result. Reviewed-by:
Eric Blake <eblake@redhat.com> Signed-off-by:
Daniel P. Berrange <berrange@redhat.com>
-
Daniel P. Berrangé authored
Incrementing the reference in qio_task_get_source is not necessary, since we're not running concurrently with any other code touching the QIOTask. This minimizes chances of further memory leaks. Reviewed-by:
Eric Blake <eblake@redhat.com> Signed-off-by:
Daniel P. Berrange <berrange@redhat.com>
-
- Oct 27, 2016
-
-
Daniel P. Berrangé authored
The GSource object has ability to have a name, which is useful when debugging performance problems with the mainloop event callbacks that take too long. By associating a name with a QIOChannel object, we can then set the name on any GSource associated with the channel. Reviewed-by:
Eric Blake <eblake@redhat.com> Signed-off-by:
Daniel P. Berrange <berrange@redhat.com>
-
Daniel P. Berrangé authored
The SO_ACCEPTCONN ioctl is not portable across OS, with some BSD versions and OS-X not supporting it. There is no viable alternative to this, so instead just set the feature explicitly when creating a listener socket. The current users of qio_channel_socket_new_fd() won't ever be given a listening socket, so there's no problem with no auto-detecting it in this scenario Signed-off-by:
Daniel P. Berrange <berrange@redhat.com>
-
- Oct 26, 2016
-
-
Felipe Franciosi authored
Testing QIOChannel feature support can be done with a helper called qio_channel_has_feature(). Setting feature support, however, was done manually with a logical OR. This patch introduces a new helper called qio_channel_set_feature() and makes use of it where applicable. Signed-off-by:
Felipe Franciosi <felipe@nutanix.com> Signed-off-by:
Daniel P. Berrange <berrange@redhat.com>
-
Felipe Franciosi authored
Parts of the code have been testing QIOChannel features directly with a logical AND. This patch makes it all consistent by using the qio_channel_has_feature() function to test if a feature is present. Signed-off-by:
Felipe Franciosi <felipe@nutanix.com> Signed-off-by:
Daniel P. Berrange <berrange@redhat.com>
-
Felipe Franciosi authored
When QIOChannels were introduced in 666a3af9, the feature bits were already defined shifted. However, when using them, the code was shifting them again. The incorrect use was consistent until 74b6ce43, where QIO_CHANNEL_FEATURE_LISTEN was defined shifted but tested unshifted. This patch changes the definition to be unshifted and fixes the incorrect usage introduced on 74b6ce43. Signed-off-by:
Felipe Franciosi <felipe@nutanix.com> Signed-off-by:
Daniel P. Berrange <berrange@redhat.com>
-
- Sep 28, 2016
-
-
Daniel P. Berrangé authored
The trace points for util/buffer.c were mistakenly put in the io/trace-events file, instead of util/trace-events in commit 892bd32e Author: Daniel P. Berrange <berrange@redhat.com> Date: Thu Jun 16 09:39:50 2016 +0100 trace: split out trace events for io/ directory Move all trace-events for files in the io/ directory to Signed-off-by:
Daniel P. Berrange <berrange@redhat.com> Reviewed-by:
Eric Blake <eblake@redhat.com> Message-id: 1473872624-23285-2-git-send-email-berrange@redhat.com Signed-off-by:
Stefan Hajnoczi <stefanha@redhat.com>
-
- Aug 12, 2016
-
-
Laurent Vivier authored
Documentation is docs/tracing.txt instead of docs/trace-events.txt. find . -name trace-events -exec \ sed -i "s?See docs/trace-events.txt for syntax documentation.?See docs/tracing.txt for syntax documentation.?" \ {} \; Signed-off-by:
Laurent Vivier <lvivier@redhat.com> Message-id: 1470669081-17860-1-git-send-email-lvivier@redhat.com Signed-off-by:
Stefan Hajnoczi <stefanha@redhat.com>
-
- Aug 03, 2016
-
-
Daniel P. Berrangé authored
The QTask struct is just a standalone struct, not a QOM Object, so calling object_ref() on it is not appropriate. This results in mangling the 'destroy' field in the QTask struct, causing the later call to qtask_free() to try to call the function at address 0x1, with predictably segfault happy results. There is in fact no need for ref counting with QTask, as the call to qtask_abort() or qtask_complete() will automatically free associated memory. This fixes the crash shown in https://bugs.launchpad.net/qemu/+bug/1589923 Reviewed-by:
Eric Blake <eblake@redhat.com> Signed-off-by:
Daniel P. Berrange <berrange@redhat.com>
-
- Jul 13, 2016
-
-
Paolo Bonzini authored
In practice the entry argument is always known at creation time, and it is confusing that sometimes qemu_coroutine_enter is used with a non-NULL argument to re-enter a coroutine (this happens in block/sheepdog.c and tests/test-coroutine.c). So pass the opaque value at creation time, for consistency with e.g. aio_bh_new. Mostly done with the following semantic patch: @ entry1 @ expression entry, arg, co; @@ - co = qemu_coroutine_create(entry); + co = qemu_coroutine_create(entry, arg); ... - qemu_coroutine_enter(co, arg); + qemu_coroutine_enter(co); @ entry2 @ expression entry, arg; identifier co; @@ - Coroutine *co = qemu_coroutine_create(entry); + Coroutine *co = qemu_coroutine_create(entry, arg); ... - qemu_coroutine_enter(co, arg); + qemu_coroutine_enter(co); @ entry3 @ expression entry, arg; @@ - qemu_coroutine_enter(qemu_coroutine_create(entry), arg); + qemu_coroutine_enter(qemu_coroutine_create(entry, arg)); @ reentry @ expression co; @@ - qemu_coroutine_enter(co, NULL); + qemu_coroutine_enter(co); except for the aforementioned few places where the semantic patch stumbled (as expected) and for test_co_queue, which would otherwise produce an uninitialized variable warning. Signed-off-by:
Paolo Bonzini <pbonzini@redhat.com> Reviewed-by:
Fam Zheng <famz@redhat.com> Signed-off-by:
Kevin Wolf <kwolf@redhat.com>
-
- Jul 06, 2016
-
-
Eric Blake authored
Rather than rolling our own clone via an expensive conversion in and back out of QObject, use the new clone visitor. Signed-off-by:
Eric Blake <eblake@redhat.com> Message-Id: <1465490926-28625-15-git-send-email-eblake@redhat.com> Reviewed-by:
Markus Armbruster <armbru@redhat.com> Signed-off-by:
Markus Armbruster <armbru@redhat.com>
-
- Jun 29, 2016
-
-
Marc-André Lureau authored
qemu leaves unix socket files behind when removing a listening chardev or leaving. qemu could clean that up, even if doing so isn't race-free. Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1347077 Signed-off-by:
Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <1466105332-10285-4-git-send-email-marcandre.lureau@redhat.com> Signed-off-by:
Paolo Bonzini <pbonzini@redhat.com>
-
Marc-André Lureau authored
Add a flag to tell whether the channel socket is listening. Signed-off-by:
Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <1466105332-10285-3-git-send-email-marcandre.lureau@redhat.com> Acked-by:
Daniel P. Berrange <berrange@redhat.com> Signed-off-by:
Paolo Bonzini <pbonzini@redhat.com> Signed-off-by:
Marc-André Lureau <marcandre.lureau@redhat.com>
-
- Jun 20, 2016
-
-
Daniel P. Berrangé authored
Move all trace-events for files in the io/ directory to their own file. Signed-off-by:
Daniel P. Berrange <berrange@redhat.com> Message-id: 1466066426-16657-5-git-send-email-berrange@redhat.com Signed-off-by:
Stefan Hajnoczi <stefanha@redhat.com>
-
- May 26, 2016
-
-
Daniel P. Berrangé authored
The QIOChannelBuffer's close implementation will free the internal data buffer. It failed to reset the pointer to NULL though, so when the object is later finalized it will free it a second time with predictable crash. Reviewed-by:
Dr. David Alan Gilbert <dgilbert@redhat.com> Signed-off-by:
Daniel P. Berrange <berrange@redhat.com> Reviewed-by:
Juan Quintela <quintela@redhat.com> Message-Id: <1461751518-12128-3-git-send-email-berrange@redhat.com> Signed-off-by:
Amit Shah <amit.shah@redhat.com>
-
- May 19, 2016
-
-
Paolo Bonzini authored
Move it to the actual users. There are still a few includes of qemu/bswap.h in headers; removing them is left for future work. Signed-off-by:
Paolo Bonzini <pbonzini@redhat.com>
-
- Mar 22, 2016
-
-
Markus Armbruster authored
Commit 57cb38b3 included qapi/error.h into qemu/osdep.h to get the Error typedef. Since then, we've moved to include qemu/osdep.h everywhere. Its file comment explains: "To avoid getting into possible circular include dependencies, this file should not include any other QEMU headers, with the exceptions of config-host.h, compiler.h, os-posix.h and os-win32.h, all of which are doing a similar job to this file and are under similar constraints." qapi/error.h doesn't do a similar job, and it doesn't adhere to similar constraints: it includes qapi-types.h. That's in excess of 100KiB of crap most .c files don't actually need. Add the typedef to qemu/typedefs.h, and include that instead of qapi/error.h. Include qapi/error.h in .c files that need it and don't get it now. Include qapi-types.h in qom/object.h for uint16List. Update scripts/clean-includes accordingly. Update it further to match reality: replace config.h by config-target.h, add sysemu/os-posix.h, sysemu/os-win32.h. Update the list of includes in the qemu/osdep.h comment quoted above similarly. This reduces the number of objects depending on qapi/error.h from "all of them" to less than a third. Unfortunately, the number depending on qapi-types.h shrinks only a little. More work is needed for that one. Signed-off-by:
Markus Armbruster <armbru@redhat.com> [Fix compilation without the spice devel packages. - Paolo] Signed-off-by:
Paolo Bonzini <pbonzini@redhat.com>
-
- Mar 10, 2016
-
-
Daniel P. Berrangé authored
Now that QEMU wraps the Win32 sockets methods to automatically set errno upon failure, there is no reason for callers to use the socket_error() method. They can rely on accessing errno even on Win32. Remove all use of socket_error() from general code, leaving it as a static method in oslib-win32.c only. Signed-off-by:
Daniel P. Berrange <berrange@redhat.com>
-
Paolo Bonzini authored
On Win32 we cannot directly poll on socket handles. Instead we create a Win32 event object and associate the socket handle with the event. When the event signals readyness we then have to use select to determine which events are ready. Creating Win32 events is moderately heavyweight, so we don't want todo it every time we create a GSource, so this associates a single event with a QIOChannel. Signed-off-by:
Paolo Bonzini <pbonzini@redhat.com> Signed-off-by:
Daniel P. Berrange <berrange@redhat.com>
-
Daniel P. Berrangé authored
Since we now canonicalize WSAEWOULDBLOCK into EAGAIN there is no longer any need to explicitly check EWOULDBLOCK for Win32. Signed-off-by:
Daniel P. Berrange <berrange@redhat.com>
-
Daniel P. Berrangé authored
The QIOChannelSocket code mistakenly uses the bare accept() function which does not set SOCK_CLOEXEC. Signed-off-by:
Daniel P. Berrange <berrange@redhat.com>
-
Paolo Bonzini authored
Sockets are not in the same namespace as file descriptors on Windows. As an initial step, introduce separate APIs for file descriptor and socket watches. Signed-off-by:
Paolo Bonzini <pbonzini@redhat.com>
-
Paolo Bonzini authored
Reviewed-by:
Daniel P. Berrange <berrange@redhat.com> Signed-off-by:
Paolo Bonzini <pbonzini@redhat.com>
-
Daniel P. Berrangé authored
s/write/read/ in the error message reported after readmsg() fails Reviewed-by:
Paolo Bonzini <pbonzini@redhat.com> Signed-off-by:
Daniel P. Berrange <berrange@redhat.com>
-
- Feb 23, 2016
-
-
Peter Maydell authored
Clean up includes so that osdep.h is included first and headers which it implies are not included manually. This commit was created with scripts/clean-includes. Signed-off-by:
Peter Maydell <peter.maydell@linaro.org> Reviewed-by:
Eric Blake <eblake@redhat.com>
-
- Feb 15, 2016
-
-
Daniel P. Berrangé authored
The QIOChannelBuffer struct uses a 'char *' for its data buffer. It will give simpler type compatibility with the migration APIs if it uses 'uint8_t *' instead, avoiding several casts. Signed-off-by:
Daniel P. Berrange <berrange@redhat.com>
-
Daniel P. Berrangé authored
Depending on what object a file descriptor refers to a different type of IO channel will be needed - either a QIOChannelFile or a QIOChannelSocket. Introduce a qio_channel_new_fd() method which will return the appropriate channel implementation. Reviewed-by:
Eric Blake <eblake@redhat.com> Signed-off-by:
Daniel P. Berrange <berrange@redhat.com>
-
- Feb 09, 2016
-
-
Paolo Bonzini authored
Two wrongs make a right, but they should be fixed anyway. Cc: Daniel P. Berrange <berrange@redhat.com> Signed-off-by:
Paolo Bonzini <pbonzini@redhat.com> Message-Id: <1455015557-15106-1-git-send-email-pbonzini@redhat.com>
-
- Feb 04, 2016
-
-
Peter Maydell authored
Clean up includes so that osdep.h is included first and headers which it implies are not included manually. This commit was created with scripts/clean-includes. Signed-off-by:
Peter Maydell <peter.maydell@linaro.org> Message-id: 1454089805-5470-14-git-send-email-peter.maydell@linaro.org
-
- Jan 20, 2016
-
-
Daniel P. Berrangé authored
Some versions of GCC on OS-X complain about CMSG_SPACE not being constant size, which prevents use of { 0 } io/channel-socket.c: In function 'qio_channel_socket_writev': io/channel-socket.c:497:18: error: variable-sized object may not be initialized char control[CMSG_SPACE(sizeof(int) * SOCKET_MAX_FDS)] = { 0 }; The compiler is at fault here, but it is nicer to avoid tickling this compiler bug by using memset instead. Reviewed-By:
John Arbuckle <programmingkidx@gmail.com> Signed-off-by:
Daniel P. Berrange <berrange@redhat.com>
-
Daniel P. Berrangé authored
The /dev/null file handle was leaked in a couple of places. There is also the possibility that both readfd and writefd point to the same /dev/null file handle, so care must be taken not to close the same file handle twice. Reviewed-by:
Paolo Bonzini <pbonzini@redhat.com> Signed-off-by:
Daniel P. Berrange <berrange@redhat.com>
-
- Jan 19, 2016
-
-
Daniel P. Berrangé authored
When killing the subcommand, it is intended to first send SIGTERM, then SIGKILL and only report an error if it still doesn't die after SIGKILL. The 'step' counter was not being incremented though, so the code never got past the SIGTERM stage. Signed-off-by:
Daniel P. Berrange <berrange@redhat.com>
-
Daniel P. Berrangé authored
When reporting the number of FDs has been exceeded, pass EINVAL to error_setg_errno, rather than -EINVAL. Signed-off-by:
Daniel P. Berrange <berrange@redhat.com>
-
- Dec 23, 2015
-
-
Daniel P. Berrangé authored
When sending file descriptors over a socket, we have to allocate a data buffer to hold the FDs in the scmsghdr. Unfortunately we allocated the buffer on the stack inside an if () {} block, but called sendmsg() outside the block. So the stack bytes holding the FDs were liable to be overwritten with other data. By luck this was not a problem when sending 1 FD, but if sending 2 or more then it would fail. The fix is to simply move the variables outside the nested 'if' block. To keep valgrind quiet we also zero-initialize the 'control' buffer. Reviewed-by:
Eric Blake <eblake@redhat.com> Signed-off-by:
Daniel P. Berrange <berrange@redhat.com>
-