summaryrefslogtreecommitdiffstats
path: root/util
Commit message (Collapse)AuthorAgeFilesLines
* iov: handle partial writes from sendmsg and recvmsgPaolo Bonzini2013-04-171-47/+55
| | | | | | | | | | Partial writes can still happen in sendmsg and recvmsg, if a signal 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> Reviewed-by: Orit Wassermann <owasserm@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* iov: reorganize iov_send_recv, part 3Paolo Bonzini2013-04-171-15/+15
| | | | | | | | "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: reorganize iov_send_recv, part 2Paolo Bonzini2013-04-171-14/+14
| | | | | | | | | | | | | Do not touch the "bytes" argument anymore. Instead, remember the original length of the last iovec if we touch it, and restore it afterwards. This requires undoing the changes in opposite order. The previous algorithm didn't care. Reviewed-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Orit Wassermann <owasserm@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* iov: reorganize iov_send_recv, part 1Paolo Bonzini2013-04-171-7/+13
| | | | | | | | | | 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> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* migration: initialize RAM to zeroPaolo Bonzini2013-04-161-17/+18
| | | | | | | | | | | | | | | | | | | | | | Using qemu_memalign only leaves the RAM zero by chance, because libc will usually use mmap to satisfy our huge requests. But memory will not be zero when using MALLOC_PERTURB_ with a nonzero value. In the case of incoming migration, this breaks a recently-introduced invariant (commit f1c7279, migration: do not sent zero pages in bulk stage, 2013-03-26). To fix this, use mmap ourselves to get a well-aligned, always zero block for the RAM. Mmap-ed memory is easy to "trim" at the sides. This also removes the need to do something special on valgrind (see commit c2a8238a, Support running QEMU on Valgrind, 2011-10-31), thus effectively reverts that patch. Reviewed-by: Juan Quintela <quintela@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Message-id: 1365522223-20153-1-git-send-email-pbonzini@redhat.com Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* sysemu: avoid proliferation of include/ subdirectoriesPaolo Bonzini2013-04-151-1/+1
| | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* unicode: New mod_utf8_codepoint()Markus Armbruster2013-04-132-1/+101
| | | | | | Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Laszlo Ersek <lersek@redhat.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* aes: make Td[0-5] and Te[0-5] tables non staticAurelien Jarno2013-04-131-252/+252
| | | | | | | | | | | Remove static attribute to Td[0-5] and Te[0-5] tables so that they can 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 do not conflict with other symbols. Reviewed-by: Edgar E. Iglesias <edgar.iglesias@gmail.com> Reviewed-by: Richard Henderson <rth@twiddle.net> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
* aes: move aes.h from include/block to include/qemuAurelien Jarno2013-04-131-1/+1
| | | | | | | | | | | Move aes.h from include/block to include/qemu to show it can be reused by other subsystems. Cc: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Edgar E. Iglesias <edgar.iglesias@gmail.com> Reviewed-by: Richard Henderson <rth@twiddle.net> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
* Allow clock_gettime() monotonic clock to be utilized on more OS'sBrad Smith2013-04-041-3/+1
| | | | | | | | | | | | Allow the clock_gettime() code using monotonic clock to be utilized on more POSIX compliannt OS's. This started as a fix for OpenBSD which was listed in one function as part of the previous hard coded list of OS's for the functions to support but not in the other. Signed-off-by: Brad Smith <brad@comstyle.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Message-id: 20130405003748.GH884@rox.home.comstyle.com Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* qemu-socket: set passed fd non-blocking in socket_connect()Stefan Hajnoczi2013-04-021-0/+1
| | | | | | | | | | socket_connect() sets non-blocking on TCP or UNIX domain sockets if a callback function is passed. Do the same for file descriptor passing, otherwise we could unexpectedly be using a blocking file descriptor. Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
* oslib-posix: rename socket_set_nonblock() to qemu_set_nonblock()Stefan Hajnoczi2013-04-023-6/+6
| | | | | | | | | 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> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
* bitops: unroll while loop in find_next_bit()Peter Lieven2013-03-261-1/+17
| | | | | | | | | | | | | | this patch adopts the loop unrolling idea of bitmap_is_zero() to speed up the skipping of large areas with zeros in find_next_bit(). this routine is extensively used to find dirty pages in live migration. testing only the find_next_bit performance on a zeroed bitfield the loop onrolling decreased executing time by approx. 50% on x86_64. Signed-off-by: Peter Lieven <pl@kamp.de> Signed-off-by: Juan Quintela <quintela@redhat.com>
* buffer_is_zero: use vector optimizations if possiblePeter Lieven2013-03-261-0/+5
| | | | | | | | | | | performance gain on SSE2 is approx. 20-25%. altivec is not tested. performance for unsigned long arithmetic is unchanged. Signed-off-by: Peter Lieven <pl@kamp.de> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Orit Wasserman <owasserm@redhat.com> Signed-off-by: Juan Quintela <quintela@redhat.com>
* cutils: add a function to find non-zero content in a bufferPeter Lieven2013-03-261-0/+55
| | | | | | | | | | | | | | | | | | | | | this adds buffer_find_nonzero_offset() which is a SSE2/Altivec optimized function that searches for non-zero content in a buffer. the function starts full unrolling only after the first few chunks have been checked one by one. analyzing real memory page data has revealed that non-zero pages are non-zero within the first 256-512 bits in most cases. as this function is also heavily used to check for zero memory pages this tweak has been made to avoid the high setup costs of the fully unrolled check for non-zero pages. due to the optimizations used in the function there are restrictions on buffer address and search length. the function can_use_buffer_find_nonzero_content() can be used to check if the function can be used safely. Signed-off-by: Peter Lieven <pl@kamp.de> Signed-off-by: Juan Quintela <quintela@redhat.com>
* Merge remote-tracking branch 'kwolf/for-anthony' into stagingAnthony Liguori2013-03-221-15/+15
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | # By Kevin Wolf (12) and Peter Lieven (2) # Via Kevin Wolf * kwolf/for-anthony: nbd: Check against invalid option combinations nbd: Use default port if only host is specified block: Allow omitting the file name when using driver-specific options block: Make find_image_format safe with NULL filename block: Rename variable to avoid shadowing block: Introduce .bdrv_parse_filename callback nbd: Accept -drive options for the network connection nbd: Remove unused functions nbd: Keep hostname and port separate qemu-socket: Make socket_optslist public block: Pass bdrv_file_open() options to block drivers block: Add options QDict to bdrv_file_open() prototypes block: complete all IOs before resizing a device Revert "block: complete all IOs before .bdrv_truncate"
| * nbd: Keep hostname and port separateKevin Wolf2013-03-221-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The NBD block supports an URL syntax, for which a URL parser returns separate hostname and port fields. It also supports the traditional qemu syntax encoded in a filename. Until now, after parsing the URL to get each piece of information, a new string is built to be fed to socket functions. Instead of building a string in the URL case that is immediately parsed again, parse the string in both cases and use the QemuOpts interface to qemu-sockets.c. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
| * qemu-socket: Make socket_optslist publicKevin Wolf2013-03-221-12/+12
| | | | | | | | | | | | | | Allow other users to create the QemuOpts needed for inet_connect_opts(). Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
* | MinGW: Replace setsockopt by qemu_setsocketoptStefan Weil2013-03-221-5/+5
|/ | | | | | | | | Instead of adding missing type casts which are needed by MinGW for the 4th argument, the patch uses qemu_setsockopt which was invented for this purpose. Signed-off-by: Stefan Weil <sw@weilnetz.de> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
* iov: Factor out hexdumperPeter Crosthwaite2013-03-153-25/+49
| | | | | | | | | Factor out the hexdumper functionality from iov for all to use. Useful for creating 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 Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
* qemu-option: Add qemu_opts_absorb_qdict()Kevin Wolf2013-03-151-0/+34
| | | | | | | | | | | | | | | This adds a function that adds all entries of a QDict to a QemuOpts if the keys are known, and leaves only the rest in the QDict. This way a single QDict of -drive options can be processed in multiple places (generic block layer, block driver, backing file block driver, etc.), where each part picks the options it knows. If at the end of the process the QDict isn't empty, the user specified an invalid option. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
* chardev: add udp support to qapiGerd Hoffmann2013-03-131-0/+25
| | | | | | This patch adds 'udp' support to qapi. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* Merge remote-tracking branch 'bonzini/hw-dirs' into stagingAnthony Liguori2013-03-103-0/+81
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * bonzini/hw-dirs: sh: move files referencing CPU to hw/sh4/ ppc: move more files to hw/ppc ppc: move files referencing CPU to hw/ppc/ m68k: move files referencing CPU to hw/m68k/ i386: move files referencing CPU to hw/i386/ arm: move files referencing CPU to hw/arm/ hw: move boards and other isolated files to hw/ARCH ppc: express FDT dependency of pSeries and e500 boards via default-configs/ build: always link device_tree.o into emulators if libfdt available hw: include hw header files with full paths ppc: do not use ../ in include files vt82c686: vt82c686 is not a PCI host bridge virtio-9p: remove PCI dependencies from hw/9pfs/ virtio-9p: use CONFIG_VIRTFS, not CONFIG_LINUX hw: move device-hotplug.o to toplevel, compile it once hw: move qdev-monitor.o to toplevel directory hw: move fifo.[ch] to libqemuutil hw: move char backends to backends/ Conflicts: backends/baum.c backends/msmouse.c hw/a15mpcore.c hw/arm/Makefile.objs hw/arm/pic_cpu.c hw/dataplane/event-poll.c hw/dataplane/virtio-blk.c include/char/baum.h include/char/msmouse.h qemu-char.c vl.c Resolve conflicts caused by header movements. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
| * hw: move qdev-monitor.o to toplevel directoryPaolo Bonzini2013-03-011-0/+1
| | | | | | | | | | | | | | | | | | | | qdev-monitor.c is the only "core qdev" file that is not used in user-mode emulation, and it does not define anything that is used by hardware models. Remove it from the hw/ directory and remove hw/qdev-monitor.h from hw/qdev.h too; this requires some files to have some new explicitly includes. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
| * hw: move fifo.[ch] to libqemuutilPaolo Bonzini2013-03-012-0/+80
| | | | | | | | | | | | | | fifo.c is generic code that can be easily unit tested. So it belongs in libqemuutil. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* | Merge remote-tracking branch 'stefanha/trivial-patches' into stagingAnthony Liguori2013-03-101-2/+2
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | # By Lei Li (2) and others # Via Stefan Hajnoczi * stefanha/trivial-patches: Fix the wrong description in qemu manual pci_host: Drop write-only address_space field rng-random: Use qemu_open / qemu_close configure: Require at least spice-protocol-0.12.3 osdep: replace setsockopt by qemu_setsockopt lm32: remove unused function rtc-test: Fix test failures with recent glib configure: Create link to icon bitmap for out-of-tree builds
| * | osdep: replace setsockopt by qemu_setsockoptLei Li2013-03-081-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fix the compiler warning when cross build qemu-ga for windows by using qemu_setsockopt() instead of setsockopt(). util/osdep.c: In function 'socket_set_nodelay': util/osdep.c:69:5: warning: passing argument 4 of 'setsockopt' from incompatible pointer type [enabled by default] In file included from /home/lei/qemu_b/include/sysemu/os-win32.h:30:0, from /home/lei/qemu_b/include/qemu-common.h:46, from util/osdep.c:48: /usr/i686-w64-mingw32/sys-root/mingw/include/winsock2.h:990:63: note: expected 'const char *' but argument is of type 'int *' Signed-off-by: Lei Li <lilei@linux.vnet.ibm.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
* | | char-socket: fix error reportingAnthony Liguori2013-03-081-0/+4
|/ / | | | | | | | | | | | | | | | | | | | | | | Right now the inet connect code tries all available addresses but until one doesn't fail. It passes local_err each time without clearing it from the previous failure. This can trigger an assert since the inet connect code tries to set an error on an object != NULL. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> Signed-off-by: Amit Shah <amit.shah@redhat.com> Message-id: 16c806d60aa5e9660ed7751bb4e37dcd278f97f0.1362505276.git.amit.shah@redhat.com Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* | oslib-posix: Align to permit transparent hugepages on ARM LinuxPeter Maydell2013-03-051-1/+1
| | | | | | | | | | | | | | | | | | ARM Linux (like x86-64 Linux) can use transparent hugepages for KVM if memory blocks are 2MiB aligned; set QEMU_VMALLOC_ALIGN accordingly. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
* | move socket_set_nodelay to osdep.cMORITA Kazutaka2013-03-041-0/+6
|/ | | | | Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
* host-utils: Improve mulu64 and muls64Richard Henderson2013-02-171-54/+38
| | | | | | | | | The new formulation makes better use of add-with-carry type insns that the host may have. Use gcc's sign adjustment trick to avoid having to perform a 128-bit negation. Signed-off-by: Richard Henderson <rth@twiddle.net> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* host-utils: Use __int128_t for mul[us]64Richard Henderson2013-02-171-2/+2
| | | | | | | | | | | | | | Replace some x86_64 specific inline assembly with something that all 64-bit hosts ought to optimize well. At worst this becomes a call to the gcc __multi3 routine, which is no worse than our implementation in util/host-utils.c. With gcc 4.7, we get identical code generation for x86_64. We now get native multiplication on ia64 and s390x hosts. With minor improvements to gcc we can get it for ppc64 as well. Signed-off-by: Richard Henderson <rth@twiddle.net> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* bitops: Replace bitops_ctol with ctzlRichard Henderson2013-02-161-1/+1
| | | | | | | | 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_flslRichard Henderson2013-02-161-1/+1
| | | | | | | | This 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: Use non-bitops ctzlRichard Henderson2013-02-161-1/+1
| | | | | | | | | The use of ctz has already eliminated zero, and thus the difference in edge conditions between the two routines is irrelevant. Signed-off-by: Richard Henderson <rth@twiddle.net> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* hbitmap: Use non-bitops ctzlRichard Henderson2013-02-161-1/+2
| | | | | | | | | | Both uses of ctz have already eliminated zero, and thus the difference in edge conditions between the two routines is irrelevant. Signed-off-by: Richard Henderson <rth@twiddle.net> Acked-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* qemu-option: Disable two helpful messages that got broken recentlyMarkus Armbruster2013-02-111-0/+4
| | | | | | | | | | | | | | | | | | | commit 8be7e7e4 and commit ec7b2ccb messed up the ordering of error message and the helpful explanation that should follow it, like this: $ qemu-system-x86_64 --nodefaults -S --vnc :0 --chardev null,id=, Identifiers consist of letters, digits, '-', '.', '_', starting with a letter. qemu-system-x86_64: -chardev null,id=,: Parameter 'id' expects an identifier $ qemu-system-x86_64 --nodefaults -S --vnc :0 --machine kvm_shadow_mem=dunno You may use k, M, G or T suffixes for kilobytes, megabytes, gigabytes and terabytes. qemu-system-x86_64: -machine kvm_shadow_mem=dunno: Parameter 'kvm_shadow_mem' expects a size Pity. Disable them for now. Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-id: 1360354939-10994-5-git-send-email-armbru@redhat.com Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* error: Strip trailing '\n' from error string arguments (again)Markus Armbruster2013-02-112-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit 6daf194d and be62a2eb got rid of a bunch, but they keep coming back. Tracked down with this Coccinelle semantic patch: @r@ expression err, eno, cls, fmt; position p; @@ ( error_report(fmt, ...)@p | error_set(err, cls, fmt, ...)@p | error_set_errno(err, eno, cls, fmt, ...)@p | error_setg(err, fmt, ...)@p | error_setg_errno(err, eno, fmt, ...)@p ) @script:python@ fmt << r.fmt; p << r.p; @@ if "\\n" in str(fmt): print "%s:%s:%s:%s" % (p[0].file, p[0].line, p[0].column, fmt) Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-id: 1360354939-10994-4-git-send-email-armbru@redhat.com Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* qemu/iovec: Don't assert if sbytes is zeroAneesh Kumar K.V2013-02-061-0/+4
| | | | | | | | Since these values can possibly be sent from guest (for hw/9pfs), do a sanity check on 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> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* cutils: unsigned int parsing functionsEduardo Habkost2013-02-041-0/+99
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There are lots of duplicate parsing code using strto*() in QEMU, and most of that code is broken in one way or another. Even the visitors code have duplicate integer parsing code[1]. This introduces functions to help parsing unsigned int values: parse_uint() and parse_uint_full(). Parsing functions for signed ints and floats will be submitted later. parse_uint_full() has all the checks made by opts_type_uint64() at opts-visitor.c: - Check for NULL (returns -EINVAL) - Check for negative numbers (returns -EINVAL) - Check for empty string (returns -EINVAL) - Check for overflow or other errno values set by strtoll() (returns -errno) - Check for end of string (reject invalid characters after number) (returns -EINVAL) parse_uint() does everything above except checking for the end of the string, so callers can continue parsing the remainder of string after the number. Unit tests included. [1] string-input-visitor.c:parse_int() could use the same parsing code used by opts-visitor.c:opts_type_int(), instead of duplicating that logic. Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Laszlo Ersek <lersek@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* bitops: unify bitops_ffsl with the one in host-utils.h, call it bitops_ctzlPaolo Bonzini2013-02-022-3/+3
| | | | | | | | | | | | | | | | | | We had two copies of a ffs function for longs with subtly different semantics and, for the one in bitops.h, a confusing name: the result was off-by-one compared to the library function ffsl. Unify the functions into one, and solve the name problem by calling the 0-based functions "bitops_ctzl" and "bitops_ctol" respectively. This also fixes the build on platforms with ffsl, including Mac OS X and Windows. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Tested-by: Andreas Färber <afaerber@suse.de> Tested-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* util: Fix compilation of envlist.c for MinGWStefan Weil2013-02-021-6/+1
| | | | | | | | | | | | 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 include that file. We currently don't need an implementation of strtok_r because the code is compiled but not linked for MinGW. Signed-off-by: Stefan Weil <sw@weilnetz.de> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* g_strdup(NULL) returns NULL; simplifyMarkus Armbruster2013-01-301-6/+2
| | | | | | Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
* Merge remote-tracking branch 'kwolf/for-anthony' into stagingAnthony Liguori2013-01-282-1/+402
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | # By Paolo Bonzini (14) and others # Via Kevin Wolf * kwolf/for-anthony: (24 commits) ide: Add fall through annotations block: Create proper size file for disk mirror ahci: Add migration support ahci: Change data types in preparation for migration ahci: Remove unused AHCIDevice fields hbitmap: add assertion on hbitmap_iter_init mirror: do nothing on zero-sized disk block/vdi: Check for bad signature block/vdi: Improved return values from vdi_open block/vdi: Improve debug output for signature block: Use error code EMEDIUMTYPE for wrong format in some block drivers block: Add special error code for wrong format mirror: support arbitrarily-sized iterations mirror: support more than one in-flight AIO operation mirror: add buf-size argument to drive-mirror mirror: switch mirror_iteration to AIO mirror: allow customizing the granularity block: allow customizing the granularity of the dirty bitmap block: return count of dirty sectors, not chunks mirror: perform COW if the cluster size is bigger than the granularity ...
| * hbitmap: add assertion on hbitmap_iter_initPaolo Bonzini2013-01-251-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | 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> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Laszlo Ersek <lersek@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
| * add hierarchical bitmap data type and test casesPaolo Bonzini2013-01-252-1/+401
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | HBitmaps provides an array of bits. The bits are stored as usual in an array of unsigned longs, but HBitmap is also optimized to provide fast iteration over set bits; going from one bit to the next is O(logB n) worst case, with B = sizeof(long) * CHAR_BIT: the result is low enough that the number of levels is in fact fixed. In order to do this, it stacks multiple bitmaps with progressively coarser granularity; in all levels except the last, bit N is set iff the N-th unsigned long is nonzero in the immediately next level. When iteration completes on the last level it can examine the 2nd-last level to quickly skip entire words, and even do so recursively to skip blocks of 64 words or powers thereof (32 on 32-bit machines). Given an index in the bitmap, it can be split in group of bits like this (for the 64-bit case): bits 0-57 => word in the last bitmap | bits 58-63 => bit in the word bits 0-51 => word in the 2nd-last bitmap | bits 52-57 => bit in the word bits 0-45 => word in the 3rd-last bitmap | bits 46-51 => bit in the word So it is easy to move up simply by shifting the index right by log2(BITS_PER_LONG) bits. To move down, you shift the index left similarly, and add the word index within the group. Iteration uses ffs (find first set bit) to find the next word to examine; this operation can be done in constant time in most current architectures. Setting or clearing a range of m bits on all levels, the work to perform is O(m + m/W + m/W^2 + ...), which is O(m) like on a regular bitmap. When iterating on a bitmap, each bit (on any level) is only visited once. Hence, The total cost of visiting a bitmap with m bits in it is the number of bits that are set in all bitmaps. Unless the bitmap is extremely sparse, this is also O(m + m/W + m/W^2 + ...), so the amortized cost of advancing from one bit to the next is usually constant. Reviewed-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* | bsd-user: avoid conflict with qemu_vmallocBlue Swirl2013-01-261-3/+0
|/ | | | | | | | | 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>
* Replace non-portable asprintf by g_strdup_printfStefan Weil2013-01-191-4/+1
| | | | | | | | g_strdup_printf already handles OOM errors, so some error handling in QEMU code can be removed. Signed-off-by: Stefan Weil <sw@weilnetz.de> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* acl: Free memory allocated with g_malloc() with g_free()Markus Armbruster2013-01-151-2/+2
| | | | | Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* acl: Fix acl_remove not to mess up the ACLMarkus Armbruster2013-01-151-0/+3
| | | | | | | | | | It leaks memory and fails to adjust qemu_acl member nentries. Future acl_add become confused: can misreport the position, and can silently fail to add. Cc: qemu-stable@nongnu.org Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
OpenPOWER on IntegriCloud