qemu-option: Guard against qemu_opts_set_defaults() misuse
Commit 6d4cd40 fixed qemu_opts_set_defaults() for an existing cornercase, but broke it for another one that can't be reached in currentcode.
Quote from its commit message:
I believe [opts_parse()] attempts to do the following:...
iov: handle EOF in iov_send_recv
Without this patch, iov_send_recv() never returns when do_send_recv()returns zero.
Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
semaphore: fix a hangup problem under load on NetBSD hosts.
Fix following bugs in "fallback implementation of counting semaphoreswith mutex+condvar" added in c166cb72f1676855816340666c3b618beef4b976: - waiting threads are not restarted properly if more than one threads...
qdev: Add SIZE type to qdev properties
This patch adds a 'SIZE' type property to qdev.
Signed-off-by: Ian Molton <ian.molton@collabora.co.uk>Signed-off-by: Vasilis Liaskovitis <vasilis.liaskovitis@profitbricks.com>Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>...
aes: Remove unused code (NDEBUG, u16)
The current code includes assert.h very early (from qemu-common.h),so the definition of NDEBUG was without any effect.
In the initial version from 2004, NDEBUG was used to disable the assertions.Those assertions are not in time critical code, so it is no longer...
QemuOpts: Add qemu_opt_unset()
Signed-off-by: Kevin Wolf <kwolf@redhat.com>Reviewed-by: Eric Blake <eblake@redhat.com>
add timestamp to error_report()
[Issue]When we offer a customer support service and a problem happensin a customer's system, we try to understand the problem bycomparing what the customer reports with message logs of thecustomer's system.
In this case, we often need to know when the problem happens....
qemu-option: Fix qemu_opts_set_defaults() for corner cases
Commit 4f6dd9a changed the initialization of opts in opts_parse() tothis:
if (defaults) { if (!id && !QTAILQ_EMPTY(&list->head)) { opts = qemu_opts_find(list, NULL); } else {...
qemu-option: Fix qemu_opts_find() for null id arguments
Crashes when the first list member has an ID. Admittedly nonsensicalreproducer:
$ qemu-system-x86_64 -nodefaults -machine id=foo -machine ""
Signed-off-by: Markus Armbruster <armbru@redhat.com>Reviewed-by: Peter Maydell <peter.maydell@linaro.org>...
qemu-socket: don't leak opts on error
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>Reviewed-by: Laszlo Ersek <lersek@redhat.com>Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
qemu-socket: zero-initialize SocketAddress
qemu-socket: drop pointless allocation
qemu-socket: catch monitor_get_fd failures
notify: add NotiferWithReturn so notifier list can abort
notifier_list_notify() has no return value. This is fine when we justwant to invoke side-effects.
Sometimes it's useful for notifiers to produce a return value. Thisallows notifiers to "veto" an operation and will be used by the block...
acl: acl_add can't insert before last list element, fix
Watch this:
$ upstream-qemu -nodefaults -S -vnc :0,acl,sasl -monitor stdio QEMU 1.5.50 monitor - type 'help' for more information (qemu) acl_add vnc.username drei allow acl: added rule at position 1...
qemu-option: check_params() is now unused, drop it
Signed-off-by: Markus Armbruster <armbru@redhat.com>Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>Message-id: 1371208516-7857-3-git-send-email-armbru@redhat.comSigned-off-by: Anthony Liguori <aliguori@us.ibm.com>
qemu-socket: allow hostnames starting with a digit
According to RFC 1123 [1], hostnames can start with a digit too.
[1] http://tools.ietf.org/html/rfc1123#page-13
Signed-off-by: Ján Tomko <jtomko@redhat.com>Cc: qemu-stable@nongnu.org[Use strspn, not strcspn. - Paolo]...
error: add error_setg_file_open() helper
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>Acked-by: Kevin Wolf <kwolf@redhat.com>
create qemu_openpty_raw() helper function and move it to a separate file
In two places qemu uses openpty() which is very system-dependent,and in both places the pty is switched to raw mode as well.Make a wrapper function which does both steps, and move all the...
qemu-io: Move qemu_strsep() to cutils.c
Signed-off-by: Kevin Wolf <kwolf@redhat.com>Reviewed-by: Eric Blake <eblake@redhat.com>Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
cutils: Support 'P' and 'E' suffixes in strtosz()
osdep: add qemu_get_local_state_pathname()
This function returns ${prefix}/var/RELATIVE_PATHNAME on POSIX-y systems,and <CSIDL_COMMON_APPDATA>/RELATIVE_PATHNAME on Win32.
http://msdn.microsoft.com/en-us/library/bb762494.aspx
[...] This folder is used for application data that is not user...
Rename hexdump to avoid FreeBSD libutil conflict
On FreeBSD libutil is used for openpty(), but it also provides a hexdump()which conflicts with QEMU's.
Signed-off-by: Ed Maste <emaste@freebsd.org>Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>Message-id: 1368718348-15199-1-git-send-email-emaste@freebsd.org...
osdep, kvm: rename low-level RAM allocation functions
This is preparatory to the introduction of a separate freeing API.
Reported-by: Amos Kong <akong@redhat.com>Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>Reviewed-by: Amos Kong <akong@redhat.com>...
osdep: introduce qemu_anon_ram_free to free qemu_anon_ram_alloc-ed memory
We switched from qemu_memalign to mmap() but then we don't modifyqemu_vfree() to do a munmap() over free(). Which we cannot dobecause qemu_vfree() frees memory allocated by qemu_{mem,block}align....
clean unnecessary code: don't check g_strdup arg for NULL
Signed-off-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com>Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
qemu: add castagnoli crc32c checksum algorithm
This adds the Castagnoli CRC32C algorithm, using the 0x11EDC6F41polynomial.
This is extracted from the linux kernel cryptographic crc32.c module.
The algorithm is based on:
Castagnoli93: Guy Castagnoli and Stefan Braeuer and Martin Herrman...
win32: add readv/writev emulation
Commit e9d8fbf (qemu-file: do not use stdio for qemu_fdopen, 2013-03-27)introduced a usage of writev, which mingw32 does not have. Even thoughqemu_fdopen itself is not used on mingw32, the future-proof solution isto add an implementation of it. This is simple and similar to how we...
monitor: introduce query-command-line-options
Libvirt has no way to probe if an option or property is supported,This patch introduces a new qmp command to query command lineoption information. hmp command isn't added because it's not needed.
Signed-off-by: Amos Kong <akong@redhat.com>...
ccid-card-passthru, dev-smartcard-reader: add debug environment variables
Introduces a new utility function: parse_debug_env to avoid codeduplication.
This overrides whatever debug value is set on the corresponding devicesfrom the command line, and is meant to ease the usage with any...
util: move socket_init() to osdep.c
vscclient needs to call socket_init() for portability.Moving to osdep.c since it has no internal dependency.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>Reviewed-by: Alon Levy <alevy@redhat.com>
iov: reorganize iov_send_recv, part 3
"si" and "ei" are merged in a single variable.
Reviewed-by: Juan Quintela <quintela@redhat.com>Reviewed-by: Orit Wassermann <owasserm@redhat.com>Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
iov: handle partial writes from sendmsg and recvmsg
Partial writes can still happen in sendmsg and recvmsg, if asignal is received in the middle of a write. To handle this,retry the operation with a new offset/bytes pair.
Reviewed-by: Juan Quintela <quintela@redhat.com>...
iov: reorganize iov_send_recv, part 1
Once the initial part of the iov is dropped, it is not used anymore.Modify iov/iovcnt directly instead of adjusting them with the "si" variable.
Reviewed-by: Juan Quintela <quintela@redhat.com>Reviewed-by: Orit Wassermann <owasserm@redhat.com>...
iov: reorganize iov_send_recv, part 2
Do not touch the "bytes" argument anymore. Instead, remember theoriginal length of the last iovec if we touch it, and restore itafterwards.
This requires undoing the changes in opposite order. The previousalgorithm didn't care....
migration: initialize RAM to zero
Using qemu_memalign only leaves the RAM zero by chance, because libcwill usually use mmap to satisfy our huge requests. But memory willnot be zero when using MALLOC_PERTURB_ with a nonzero value. In thecase of incoming migration, this breaks a recently-introduced...
sysemu: avoid proliferation of include/ subdirectories
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
unicode: New mod_utf8_codepoint()
Signed-off-by: Markus Armbruster <armbru@redhat.com>Reviewed-by: Laszlo Ersek <lersek@redhat.com>Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
aes: move aes.h from include/block to include/qemu
Move aes.h from include/block to include/qemu to show it can be reusedby other subsystems.
Cc: Kevin Wolf <kwolf@redhat.com>Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>Reviewed-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>...
aes: make Td[0-5] and Te[0-5] tables non static
Remove static attribute to Td[0-5] and Te[0-5] tables so that theycan be used outside of aes.c. Change their type from u32 to uint32_t,to keep the u32 udef local to aes.c. Prefix them with AES_ so that they...
Allow clock_gettime() monotonic clock to be utilized on more OS's
Allow the clock_gettime() code using monotonic clock to be utilized onmore POSIX compliannt OS's. This started as a fix for OpenBSD which waslisted in one function as part of the previous hard coded list of OS's...
oslib-posix: rename socket_set_nonblock() to qemu_set_nonblock()
The fcntl(fd, F_SETFL, O_NONBLOCK) flag is not specific to sockets.Rename to qemu_set_nonblock() just like qemu_set_cloexec().
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>Reviewed-by: Eric Blake <eblake@redhat.com>...
qemu-socket: set passed fd non-blocking in socket_connect()
socket_connect() sets non-blocking on TCP or UNIX domain sockets if acallback function is passed. Do the same for file descriptor passing,otherwise we could unexpectedly be using a blocking file descriptor....
buffer_is_zero: use vector optimizations if possible
performance gain on SSE2 is approx. 20-25%. altivecis not tested. performance for unsigned long arithmeticis unchanged.
Signed-off-by: Peter Lieven <pl@kamp.de>Reviewed-by: Eric Blake <eblake@redhat.com>...
bitops: unroll while loop in find_next_bit()
this patch adopts the loop unrolling idea of bitmap_is_zero() tospeed up the skipping of large areas with zeros in find_next_bit().
this routine is extensively used to find dirty pages inlive migration.
testing only the find_next_bit performance on a zeroed bitfield...
cutils: add a function to find non-zero content in a buffer
this adds buffer_find_nonzero_offset() which is a SSE2/Altivecoptimized function that searches for non-zero content in abuffer.
the function starts full unrolling only after the first few chunks have...
Merge remote-tracking branch 'kwolf/for-anthony' into staging
qemu-socket: Make socket_optslist public
Allow other users to create the QemuOpts needed for inet_connect_opts().
nbd: Keep hostname and port separate
The NBD block supports an URL syntax, for which a URL parser returnsseparate hostname and port fields. It also supports the traditional qemusyntax encoded in a filename. Until now, after parsing the URL to geteach piece of information, a new string is built to be fed to socket...
MinGW: Replace setsockopt by qemu_setsocketopt
Instead of adding missing type casts which are needed by MinGW for the4th argument, the patch uses qemu_setsockopt which was invented for thispurpose.
Signed-off-by: Stefan Weil <sw@weilnetz.de>Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
iov: Factor out hexdumper
Factor out the hexdumper functionality from iov for all to use. Useful forcreating verbose debug printfery that dumps packet data.
Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>Message-id: faaac219c55ea586d3f748befaf5a2788fd271b8.1361853677.git.peter.crosthwaite@xilinx.com...
qemu-option: Add qemu_opts_absorb_qdict()
This adds a function that adds all entries of a QDict to a QemuOpts ifthe keys are known, and leaves only the rest in the QDict.
This way a single QDict of -drive options can be processed in multipleplaces (generic block layer, block driver, backing file block driver,...
chardev: add udp support to qapi
This patch adds 'udp' support to qapi.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Merge remote-tracking branch 'bonzini/hw-dirs' into staging
Merge remote-tracking branch 'stefanha/trivial-patches' into staging
char-socket: fix error reporting
Right now the inet connect code tries all available addresses but until onedoesn't fail. It passes local_err each time without clearing it from theprevious failure. This can trigger an assert since the inet connect code...
osdep: replace setsockopt by qemu_setsockopt
Fix the compiler warning when cross build qemu-gafor windows by using qemu_setsockopt() instead ofsetsockopt().
util/osdep.c: In function 'socket_set_nodelay':util/osdep.c:69:5: warning: passing argument 4 of 'setsockopt' from...
oslib-posix: Align to permit transparent hugepages on ARM Linux
ARM Linux (like x86-64 Linux) can use transparent hugepages forKVM if memory blocks are 2MiB aligned; set QEMU_VMALLOC_ALIGNaccordingly.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>...
move socket_set_nodelay to osdep.c
Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
hw: move qdev-monitor.o to toplevel directory
qdev-monitor.c is the only "core qdev" file that is not used inuser-mode emulation, and it does not define anything that is usedby hardware models. Remove it from the hw/ directory andremove hw/qdev-monitor.h from hw/qdev.h too; this requires...
hw: move fifo.[ch] to libqemuutil
fifo.c is generic code that can be easily unit tested. So itbelongs in libqemuutil.
host-utils: Improve mulu64 and muls64
The new formulation makes better use of add-with-carry type insnsthat the host may have. Use gcc's sign adjustment trick to avoidhaving to perform a 128-bit negation.
Signed-off-by: Richard Henderson <rth@twiddle.net>...
host-utils: Use __int128_t for mul[us]64
Replace some x86_64 specific inline assembly with something thatall 64-bit hosts ought to optimize well. At worst this becomesa call to the gcc __multi3 routine, which is no worse than ourimplementation in util/host-utils.c....
bitops: Replace bitops_ctol with ctzl
The is the only remaining user.
Signed-off-by: Richard Henderson <rth@twiddle.net>Reviewed-by: Eric Blake <eblake@redhat.com>Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
bitops: Inline bitops_flsl
This is the only remaining user.
bitops: Use non-bitops ctzl
The use of ctz has already eliminated zero, and thus the differencein edge conditions between the two routines is irrelevant.
hbitmap: Use non-bitops ctzl
Both uses of ctz have already eliminated zero, and thus the differencein edge conditions between the two routines is irrelevant.
Signed-off-by: Richard Henderson <rth@twiddle.net>Acked-by: Paolo Bonzini <pbonzini@redhat.com>...
error: Strip trailing '\n' from error string arguments (again)
Commit 6daf194d and be62a2eb got rid of a bunch, but they keep comingback. Tracked down with this Coccinelle semantic patch:
r expression err, eno, cls, fmt; position p; @@ (...
r
qemu-option: Disable two helpful messages that got broken recently
commit 8be7e7e4 and commit ec7b2ccb messed up the ordering of errormessage and the helpful explanation that should follow it, like this:
$ qemu-system-x86_64 --nodefaults -S --vnc :0 --chardev null,id=,...
qemu/iovec: Don't assert if sbytes is zero
Since these values can possibly be sent from guest (for hw/9pfs), do a sanity checkon them. A 9p write request with 0 bytes caused qemu to abort without this patch
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>...
cutils: unsigned int parsing functions
There are lots of duplicate parsing code using strto*() in QEMU, andmost of that code is broken in one way or another. Even the visitorscode have duplicate integer parsing code1. This introduces functionsto help parsing unsigned int values: parse_uint() and parse_uint_full()....
bitops: unify bitops_ffsl with the one in host-utils.h, call it bitops_ctzl
We had two copies of a ffs function for longs with subtly differentsemantics and, for the one in bitops.h, a confusing name: the resultwas off-by-one compared to the library function ffsl....
util: Fix compilation of envlist.c for MinGW
MinGW has no strtok_r, so we need a declaration in sysemu/os-win32.h.We must also fix the include statements in util/envlist.c to includethat file.
We currently don't need an implementation of strtok_r because the...
g_strdup(NULL) returns NULL; simplify
Signed-off-by: Markus Armbruster <armbru@redhat.com>Reviewed-by: Eric Blake <eblake@redhat.com>Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
bsd-user: avoid conflict with qemu_vmalloc
Rename qemu_vmalloc() to bsd_vmalloc(), adjust the only user.
Remove #ifdeffery in oslib-posix.c.
Tested-by: Andreas Färber <andreas.faerber@web.de>Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
hbitmap: add assertion on hbitmap_iter_init
hbitmap_iter_init causes an out-of-bounds access when the "first" argument is or greater than or equal to the size of the bitmap.Forbid this with an assertion, and remove the failing testcase.
Reported-by: Kevin Wolf <kwolf@redhat.com>...
add hierarchical bitmap data type and test cases
HBitmaps provides an array of bits. The bits are stored as usual in anarray of unsigned longs, but HBitmap is also optimized to provide fastiteration over set bits; going from one bit to the next is O(logB n)...
Replace non-portable asprintf by g_strdup_printf
g_strdup_printf already handles OOM errors, so some error handling inQEMU code can be removed.
Signed-off-by: Stefan Weil <sw@weilnetz.de>Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
acl: Fix acl_remove not to mess up the ACL
It leaks memory and fails to adjust qemu_acl member nentries. Futureacl_add become confused: can misreport the position, and can silentlyfail to add.
Cc: qemu-stable@nongnu.orgSigned-off-by: Markus Armbruster <armbru@redhat.com>...
acl: Free memory allocated with g_malloc() with g_free()
Signed-off-by: Markus Armbruster <armbru@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
w32: Make qemu_vfree() accept NULL like the POSIX implementation
On POSIX, qemu_vfree() accepts NULL, because it's merely wrapperaround free(). As far as I can tell, the Windows implementationdoesn't. Breeds bugs that bite only under Windows.
Make the Windows implementation behave like the POSIX implementation....
build: move libqemuutil.a components to util/