aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2015-02-10spapr_vio: Pair g_malloc() with g_free(), not free()Markus Armbruster
Spotted by Coverity with preview checker ALLOC_FREE_MISMATCH enabled and my "coverity: Model g_free() isn't necessarily free()" model patch applied. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Gonglei <arei.gonglei@huawei.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2015-02-10qemu-option: Pair g_malloc() with g_free(), not free()Markus Armbruster
Spotted by Coverity with preview checker ALLOC_FREE_MISMATCH enabled and my "coverity: Model g_free() isn't necessarily free()" model patch applied. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Gonglei <arei.gonglei@huawei.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2015-02-10qemu-option: Replace pointless use of g_malloc0() by g_malloc()Markus Armbruster
get_opt_value() takes a write-only buffer, so zeroing it is pointless. We don't do it elsewhere, either. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Gonglei <arei.gonglei@huawei.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2015-02-10libcacard: stop linking against every single 3rd party libraryDaniel P. Berrange
Building QEMU results in a libcacard.so that links against practically the entire world linux-vdso.so.1 => (0x00007fff71e99000) libssl3.so => /usr/lib64/libssl3.so (0x00007f49f94b6000) libsmime3.so => /usr/lib64/libsmime3.so (0x00007f49f928e000) libnss3.so => /usr/lib64/libnss3.so (0x00007f49f8f67000) libnssutil3.so => /usr/lib64/libnssutil3.so (0x00007f49f8d3b000) libplds4.so => /usr/lib64/libplds4.so (0x00007f49f8b36000) libplc4.so => /usr/lib64/libplc4.so (0x00007f49f8931000) libnspr4.so => /usr/lib64/libnspr4.so (0x00007f49f86f2000) libdl.so.2 => /usr/lib64/libdl.so.2 (0x00007f49f84ed000) libm.so.6 => /usr/lib64/libm.so.6 (0x00007f49f81e5000) libgthread-2.0.so.0 => /usr/lib64/libgthread-2.0.so.0 (0x00007f49f7fe3000) librt.so.1 => /usr/lib64/librt.so.1 (0x00007f49f7dda000) libz.so.1 => /usr/lib64/libz.so.1 (0x00007f49f7bc4000) libcap-ng.so.0 => /usr/lib64/libcap-ng.so.0 (0x00007f49f79be000) libuuid.so.1 => /usr/lib64/libuuid.so.1 (0x00007f49f77b8000) libgnutls.so.28 => /usr/lib64/libgnutls.so.28 (0x00007f49f749a000) libSDL-1.2.so.0 => /usr/lib64/libSDL-1.2.so.0 (0x00007f49f71fd000) libpthread.so.0 => /usr/lib64/libpthread.so.0 (0x00007f49f6fe0000) libvte.so.9 => /usr/lib64/libvte.so.9 (0x00007f49f6d3f000) libXext.so.6 => /usr/lib64/libXext.so.6 (0x00007f49f6b2d000) libgtk-x11-2.0.so.0 => /usr/lib64/libgtk-x11-2.0.so.0 (0x00007f49f64a0000) libgdk-x11-2.0.so.0 => /usr/lib64/libgdk-x11-2.0.so.0 (0x00007f49f61de000) libpangocairo-1.0.so.0 => /usr/lib64/libpangocairo-1.0.so.0 (0x00007f49f5fd1000) libatk-1.0.so.0 => /usr/lib64/libatk-1.0.so.0 (0x00007f49f5daa000) libcairo.so.2 => /usr/lib64/libcairo.so.2 (0x00007f49f5a9d000) libgdk_pixbuf-2.0.so.0 => /usr/lib64/libgdk_pixbuf-2.0.so.0 (0x00007f49f5878000) libgio-2.0.so.0 => /usr/lib64/libgio-2.0.so.0 (0x00007f49f5500000) libpangoft2-1.0.so.0 => /usr/lib64/libpangoft2-1.0.so.0 (0x00007f49f52eb000) libpango-1.0.so.0 => /usr/lib64/libpango-1.0.so.0 (0x00007f49f50a0000) libgobject-2.0.so.0 => /usr/lib64/libgobject-2.0.so.0 (0x00007f49f4e4e000) libglib-2.0.so.0 => /usr/lib64/libglib-2.0.so.0 (0x00007f49f4b15000) libfontconfig.so.1 => /usr/lib64/libfontconfig.so.1 (0x00007f49f48d6000) libfreetype.so.6 => /usr/lib64/libfreetype.so.6 (0x00007f49f462b000) libX11.so.6 => /usr/lib64/libX11.so.6 (0x00007f49f42e8000) libxenstore.so.3.0 => /usr/lib64/libxenstore.so.3.0 (0x00007f49f40de000) libxenctrl.so.4.4 => /usr/lib64/libxenctrl.so.4.4 (0x00007f49f3eb6000) libxenguest.so.4.4 => /usr/lib64/libxenguest.so.4.4 (0x00007f49f3c8b000) libseccomp.so.2 => /usr/lib64/libseccomp.so.2 (0x00007f49f3a74000) librdmacm.so.1 => /usr/lib64/librdmacm.so.1 (0x00007f49f385d000) libibverbs.so.1 => /usr/lib64/libibverbs.so.1 (0x00007f49f364a000) libutil.so.1 => /usr/lib64/libutil.so.1 (0x00007f49f3447000) libc.so.6 => /usr/lib64/libc.so.6 (0x00007f49f3089000) /lib64/ld-linux-x86-64.so.2 (0x00007f49f9902000) libp11-kit.so.0 => /usr/lib64/libp11-kit.so.0 (0x00007f49f2e23000) libtspi.so.1 => /usr/lib64/libtspi.so.1 (0x00007f49f2bb2000) libtasn1.so.6 => /usr/lib64/libtasn1.so.6 (0x00007f49f299f000) libnettle.so.4 => /usr/lib64/libnettle.so.4 (0x00007f49f276d000) libhogweed.so.2 => /usr/lib64/libhogweed.so.2 (0x00007f49f2545000) libgmp.so.10 => /usr/lib64/libgmp.so.10 (0x00007f49f22cd000) libncurses.so.5 => /usr/lib64/libncurses.so.5 (0x00007f49f20a5000) libtinfo.so.5 => /usr/lib64/libtinfo.so.5 (0x00007f49f1e7a000) libgmodule-2.0.so.0 => /usr/lib64/libgmodule-2.0.so.0 (0x00007f49f1c76000) libXfixes.so.3 => /usr/lib64/libXfixes.so.3 (0x00007f49f1a6f000) libXrender.so.1 => /usr/lib64/libXrender.so.1 (0x00007f49f1865000) libXinerama.so.1 => /usr/lib64/libXinerama.so.1 (0x00007f49f1662000) libXi.so.6 => /usr/lib64/libXi.so.6 (0x00007f49f1452000) libXrandr.so.2 => /usr/lib64/libXrandr.so.2 (0x00007f49f1247000) libXcursor.so.1 => /usr/lib64/libXcursor.so.1 (0x00007f49f103c000) libXcomposite.so.1 => /usr/lib64/libXcomposite.so.1 (0x00007f49f0e39000) libXdamage.so.1 => /usr/lib64/libXdamage.so.1 (0x00007f49f0c35000) libharfbuzz.so.0 => /usr/lib64/libharfbuzz.so.0 (0x00007f49f09dd000) libpixman-1.so.0 => /usr/lib64/libpixman-1.so.0 (0x00007f49f072f000) libEGL.so.1 => /usr/lib64/libEGL.so.1 (0x00007f49f0505000) libpng16.so.16 => /usr/lib64/libpng16.so.16 (0x00007f49f02d2000) libxcb-shm.so.0 => /usr/lib64/libxcb-shm.so.0 (0x00007f49f00cd000) libxcb-render.so.0 => /usr/lib64/libxcb-render.so.0 (0x00007f49efec3000) libxcb.so.1 => /usr/lib64/libxcb.so.1 (0x00007f49efca1000) libGL.so.1 => /usr/lib64/libGL.so.1 (0x00007f49efa06000) libffi.so.6 => /usr/lib64/libffi.so.6 (0x00007f49ef7fe000) libselinux.so.1 => /usr/lib64/libselinux.so.1 (0x00007f49ef5d8000) libresolv.so.2 => /usr/lib64/libresolv.so.2 (0x00007f49ef3be000) libexpat.so.1 => /usr/lib64/libexpat.so.1 (0x00007f49ef193000) libbz2.so.1 => /usr/lib64/libbz2.so.1 (0x00007f49eef83000) libgcc_s.so.1 => /usr/lib64/libgcc_s.so.1 (0x00007f49eed6c000) liblzma.so.5 => /usr/lib64/liblzma.so.5 (0x00007f49eeb46000) libnl-route-3.so.200 => /usr/lib64/libnl-route-3.so.200 (0x00007f49ee8e2000) libnl-3.so.200 => /usr/lib64/libnl-3.so.200 (0x00007f49ee6c4000) libcrypto.so.10 => /usr/lib64/libcrypto.so.10 (0x00007f49ee2d6000) libssl.so.10 => /usr/lib64/libssl.so.10 (0x00007f49ee067000) libgraphite2.so.3 => /usr/lib64/libgraphite2.so.3 (0x00007f49ede48000) libX11-xcb.so.1 => /usr/lib64/libX11-xcb.so.1 (0x00007f49edc46000) libxcb-dri2.so.0 => /usr/lib64/libxcb-dri2.so.0 (0x00007f49eda41000) libxcb-xfixes.so.0 => /usr/lib64/libxcb-xfixes.so.0 (0x00007f49ed838000) libxcb-shape.so.0 => /usr/lib64/libxcb-shape.so.0 (0x00007f49ed634000) libgbm.so.1 => /usr/lib64/libgbm.so.1 (0x00007f49ed426000) libwayland-client.so.0 => /usr/lib64/libwayland-client.so.0 (0x00007f49ed217000) libwayland-server.so.0 => /usr/lib64/libwayland-server.so.0 (0x00007f49ed005000) libglapi.so.0 => /usr/lib64/libglapi.so.0 (0x00007f49ecddb000) libdrm.so.2 => /usr/lib64/libdrm.so.2 (0x00007f49ecbce000) libXau.so.6 => /usr/lib64/libXau.so.6 (0x00007f49ec9ca000) libxcb-glx.so.0 => /usr/lib64/libxcb-glx.so.0 (0x00007f49ec7b0000) libxcb-dri3.so.0 => /usr/lib64/libxcb-dri3.so.0 (0x00007f49ec5ad000) libxcb-present.so.0 => /usr/lib64/libxcb-present.so.0 (0x00007f49ec3aa000) libxcb-randr.so.0 => /usr/lib64/libxcb-randr.so.0 (0x00007f49ec19b000) libxcb-sync.so.1 => /usr/lib64/libxcb-sync.so.1 (0x00007f49ebf94000) libxshmfence.so.1 => /usr/lib64/libxshmfence.so.1 (0x00007f49ebd91000) libXxf86vm.so.1 => /usr/lib64/libXxf86vm.so.1 (0x00007f49ebb8a000) libpcre.so.1 => /usr/lib64/libpcre.so.1 (0x00007f49eb91d000) libgssapi_krb5.so.2 => /usr/lib64/libgssapi_krb5.so.2 (0x00007f49eb6cf000) libkrb5.so.3 => /usr/lib64/libkrb5.so.3 (0x00007f49eb3ec000) libcom_err.so.2 => /usr/lib64/libcom_err.so.2 (0x00007f49eb1e8000) libk5crypto.so.3 => /usr/lib64/libk5crypto.so.3 (0x00007f49eafb4000) libkrb5support.so.0 => /usr/lib64/libkrb5support.so.0 (0x00007f49eada5000) libkeyutils.so.1 => /usr/lib64/libkeyutils.so.1 (0x00007f49eaba0000) All libcacard actually needs are the NSS libs. Linking against the entire world is a regression caused by commit 9d171bd9375e4d08feff9adda15163e0811f5f42 Author: Michael Tokarev <mjt@tls.msk.ru> Date: Thu May 8 16:48:27 2014 +0400 libcacard: remove libcacard-specific CFLAGS and LIBS from global vars Which removed the setting of the LIBS variable in libcacard/Makefile. Adding it back as an empty assignment brings the linked libs back to a more reasonable set linux-vdso.so.1 => (0x00007fff575c1000) libssl3.so => /usr/lib64/libssl3.so (0x00007f7f753b1000) libsmime3.so => /usr/lib64/libsmime3.so (0x00007f7f75189000) libnss3.so => /usr/lib64/libnss3.so (0x00007f7f74e62000) libnssutil3.so => /usr/lib64/libnssutil3.so (0x00007f7f74c36000) libplds4.so => /usr/lib64/libplds4.so (0x00007f7f74a31000) libplc4.so => /usr/lib64/libplc4.so (0x00007f7f7482c000) libnspr4.so => /usr/lib64/libnspr4.so (0x00007f7f745ed000) libpthread.so.0 => /usr/lib64/libpthread.so.0 (0x00007f7f743d0000) libdl.so.2 => /usr/lib64/libdl.so.2 (0x00007f7f741cc000) libgthread-2.0.so.0 => /usr/lib64/libgthread-2.0.so.0 (0x00007f7f73fca000) libglib-2.0.so.0 => /usr/lib64/libglib-2.0.so.0 (0x00007f7f73c90000) libc.so.6 => /usr/lib64/libc.so.6 (0x00007f7f738d3000) libz.so.1 => /usr/lib64/libz.so.1 (0x00007f7f736bd000) librt.so.1 => /usr/lib64/librt.so.1 (0x00007f7f734b4000) /lib64/ld-linux-x86-64.so.2 (0x00007f7f757fd000) Signed-off-by: Daniel P. Berrange <berrange@redhat.com> Cc: <qemu-stable@nongnu.org> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2015-02-10linux-user: wrong TARGET_SI_PAD_SIZE value for some targets.Maxim Ostapenko
Fix TARGET_SI_PAD_SIZE calculation to match the way the kernel does it. Use different TARGET_SI_PREAMBLE_SIZE for 32-bit and 64-bit targets. Signed-off-by: Maxim Ostapenko <m.ostapenko@partner.samsung.com> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2015-02-10qemu-sockets: Fix buffer overflow in inet_parse()Kevin Wolf
The size of the stack allocated host[] array didn't account for the terminating '\0' byte that sscanf() writes. Fix the array size. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: John Snow <jsnow@redhat.com> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2015-02-10vl.c: fix memory leak spotted by valgrindChristian Borntraeger
valgrind complains about: ==42062== 16 bytes in 1 blocks are definitely lost in loss record 387 of 1,048 ==42062== at 0x402DCB2: malloc (vg_replace_malloc.c:299) ==42062== by 0x40C1BE3: g_malloc (in /usr/lib64/libglib-2.0.so.0.3800.2) ==42062== by 0x40DA133: g_slice_alloc (in /usr/lib64/libglib-2.0.so.0.3800.2) ==42062== by 0x40DB2E5: g_slist_prepend (in /usr/lib64/libglib-2.0.so.0.3800.2) ==42062== by 0x801637FF: object_class_get_list_tramp (object.c:690) ==42062== by 0x40A96C9: g_hash_table_foreach (in /usr/lib64/libglib-2.0.so.0.3800.2) ==42062== by 0x80164885: object_class_foreach (object.c:665) ==42062== by 0x80164975: object_class_get_list (object.c:698) ==42062== by 0x800100A5: machine_parse (vl.c:2447) ==42062== by 0x800100A5: main (vl.c:3756) Lets free machines in case of mc. Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2015-02-10aes: remove a dead return statementPaolo Bonzini
bits is checked to be 128, 192 or 256 at the beginning of the function. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2015-02-10qemu-sockets: improve error reporting in unix_listen_optsPaolo Bonzini
Coverity complains about not checking the returned value of mkstemp. While at it, also improve error checking for snprintf, and refine error messages in general. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2015-02-10cpu-exec: simplify icount codePaolo Bonzini
Use MIN instead of an "if" statement. Move "tb" assignment where the value is actually used. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2015-02-10cpu-exec: drop dead assignmentPaolo Bonzini
All uses of TB inside cpu_exec are dominated by "tb = tb_find_fast(env)", and there are no uses after the switch statement. So the assignment is dead, as reported by Coverity. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2015-02-10qemu-log: Correct help text of 'log cpu_reset'Thomas Huth
The logging of the CPU state during reset is done for all architectures nowadays (see cpu_common_reset() in qom/cpu.c), so the "x86 only" text does not apply here anymore. Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2015-02-10linux-user/syscall.c: do_ioctl_dm: Need to call unlock_user() before going ↵Chen Gang S
to failure return in default case In abi_long do_ioctl_dm(), after lock_user() call, the code does not call unlock_user() before going to failure return in default case. Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2015-02-10linux-user/main.c: Use TARGET_SIG* instead of SIG*Chen Gang S
In main.c, all SIG* should be TARGET_SIG*, since the relevant functions (queue_signal() and gdb_handlesig()) expect TARGET_SIG*. The corresponding vi command is "1,$ s/\<SIG/TARGET_SIG/g". Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2015-02-10linux-user/syscall.c: Fix typo issue for using target_vec[i].iov_len instead ↵Chen Gang S
of target_vec[i].iov_base It is only a typo issue, need use tswapal(target_vec[i].iov_len) for the len. Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2015-02-10linux-user/syscall.c: lock_iovec: unlock vec[i] in failure processing code blockChen Gang S
When failure occurs during locking of vec[i], we also need to unlock all already locked vec[i] in failure processing code block before return. Code in unlock_user() checks vec[i].iov_base for NULL, so there's no need not check it . If error is EFAULT when "i == 0", vec[i].iov_base is NULL, we can just skip it, so can still use "while (--i >= 0)" loop condition. Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2015-02-10virtfs-proxy-helper: Fix possible socket leak.Gonglei
Signed-off-by: Gonglei <arei.gonglei@huawei.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2015-02-10vl: Fix bogus error message for implied mon ID clashingMarkus Armbruster
monitor_parse() desugars --monitor, --qmp and -qmp-pretty to --mon. The ID it picks can clash with a user-specified ID. When it happens, the error message is misleading. Reproducer: $ qemu --mon id=compat_monitor0 --monitor stdio Message before the patch: duplicate chardev: compat_monitor0 There's no "duplicate chardev" here. The problem is a duplicate monitor ID. Moreover, the message provides no clue which option caused the problem. The patch changes the message to: qemu: --monitor stdio: Duplicate ID 'compat_monitor0' for mon monitor_parse() is also used for creating a default monitor, but that's not done when the user specifies a monitor, so an ID clash is impossible then. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2015-02-10Convert some debugging printfs to trace calls in pcnet.c.Don Koch
Signed-off-by: Don Koch <dkoch@verizon.com> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2015-02-10Add/convert trace calls in pcnet-pci.c.Don Koch
Add trace calls. Convert some #ifdef DEBUG printfs to trace. Signed-off-by: Don Koch <dkoch@verizon.com> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2015-02-10Add trace to ps2.c.Don Koch
Signed-off-by: Don Koch <dkoch@verizon.com> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2015-02-10Add tracing to xenfb.Don Koch
Signed-off-by: Don Koch <dkoch@verizon.com> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2015-02-10fw_cfg: fix typos in comments: patch -> pathGonglei
Signed-off-by: Gonglei <arei.gonglei@huawei.com> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2015-02-10target-mips: Clean up switch fall through after commit fecd264Markus Armbruster
Commit fecd264 added a number of fall-throughs, but neglected to properly document them as intentional. Commit d922445 cleaned that up for many, but not all cases. Take care of the remaining ones. Spotted by Coverity. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2015-02-09qmp: unbreak build for non-vnc configurationLeon Yu
Signed-off-by: Leon Yu <chianglungyu@gmail.com> Message-id: 1422853731-5282-1-git-send-email-chianglungyu@gmail.com Fixes: df887684603a ("monitor: add query-vnc-servers command") Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2015-02-06Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into stagingPeter Maydell
Block patches for 2.3 # gpg: Signature made Fri 06 Feb 2015 17:14:10 GMT using RSA key ID C88F2FD6 # gpg: Good signature from "Kevin Wolf <kwolf@redhat.com>" * remotes/kevin/tags/for-upstream: (47 commits) block/raw-posix.c: Fix raw_getlength() on Mac OS X block devices block: Eliminate silly QERR_ macros used for encryption keys block: New bdrv_add_key(), convert monitor to use it blockdev: Eliminate silly QERR_BLOCK_JOB_NOT_ACTIVE macro blockdev: Give find_block_job() an Error ** parameter qcow2: Rewrite qcow2_alloc_bytes() block: Give always priority to unused entries in the qcow2 L2 cache nbd: fix max_discard/max_transfer_length block: introduce BDRV_REQUEST_MAX_SECTORS nbd: Improve error messages iotests: Fix 104 for NBD iotests: Fix 100 for nbd iotests: Fix 083 block: fix off-by-one error in qcow and qcow2 qemu-iotests: add 116 invalid QED input file tests qed: check for header size overflow block/dmg: improve zeroes handling block/dmg: support bzip2 block entry types block/dmg: factor out block type check block/dmg: use SectorNumber from BLKX header ... Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2015-02-06block/raw-posix.c: Fix raw_getlength() on Mac OS X block devicesProgrammingkid
This patch replaces the dummy code in raw_getlength() for block devices on OS X, which always returned LLONG_MAX, with a real implementation that returns the actual block device size. Signed-off-by: John Arbuckle <programmingkidx@gmail.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Tested-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2015-02-06Merge remote-tracking branch 'mreitz/block' into queue-blockKevin Wolf
* mreitz/block: block: Eliminate silly QERR_ macros used for encryption keys block: New bdrv_add_key(), convert monitor to use it blockdev: Eliminate silly QERR_BLOCK_JOB_NOT_ACTIVE macro blockdev: Give find_block_job() an Error ** parameter
2015-02-06block: Eliminate silly QERR_ macros used for encryption keysMarkus Armbruster
The QERR_ macros are leftovers from the days of "rich" error objects. They're used with error_set() and qerror_report(), and expand into the first *two* arguments. This trickiness has become pointless. Clean up QERR_DEVICE_ENCRYPTED and QERR_DEVICE_NOT_ENCRYPTED. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-id: 1422524221-8566-5-git-send-email-armbru@redhat.com Reviewed-by: Max Reitz <mreitz@redhat.com> Signed-off-by: Max Reitz <mreitz@redhat.com>
2015-02-06block: New bdrv_add_key(), convert monitor to use itMarkus Armbruster
Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-id: 1422524221-8566-4-git-send-email-armbru@redhat.com Reviewed-by: Max Reitz <mreitz@redhat.com> Signed-off-by: Max Reitz <mreitz@redhat.com>
2015-02-06blockdev: Eliminate silly QERR_BLOCK_JOB_NOT_ACTIVE macroMarkus Armbruster
The QERR_ macros are leftovers from the days of "rich" error objects. They're used with error_set() and qerror_report(), and expand into the first *two* arguments. This trickiness has become pointless. Clean this one up. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-id: 1422524221-8566-3-git-send-email-armbru@redhat.com Reviewed-by: Max Reitz <mreitz@redhat.com> Signed-off-by: Max Reitz <mreitz@redhat.com>
2015-02-06blockdev: Give find_block_job() an Error ** parameterMarkus Armbruster
When find_block_job() fails, all its callers build the same Error object. Build it in find_block_job() instead. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-id: 1422524221-8566-2-git-send-email-armbru@redhat.com Reviewed-by: Max Reitz <mreitz@redhat.com> Signed-off-by: Max Reitz <mreitz@redhat.com>
2015-02-06qcow2: Rewrite qcow2_alloc_bytes()Max Reitz
qcow2_alloc_bytes() is a function with insufficient error handling and an unnecessary goto. This patch rewrites it. Signed-off-by: Max Reitz <mreitz@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2015-02-06block: Give always priority to unused entries in the qcow2 L2 cacheAlberto Garcia
The current algorithm to replace entries from the L2 cache gives priority to newer hits by dividing the hit count of all existing entries by two everytime there is a cache miss. However, if there are several cache misses the hit count of the existing entries can easily go down to 0. This will result in those entries being replaced even when there are others that have never been used. This problem is more noticeable with larger disk images and cache sizes, since the chances of having several misses before the cache is full are higher. If we make sure that the hit count can never go down to 0 again, unused entries will always have priority. Signed-off-by: Alberto Garcia <berto@igalia.com> Reviewed-by: Max Reitz <mreitz@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2015-02-06nbd: fix max_discard/max_transfer_lengthDenis V. Lunev
nbd_co_discard calls nbd_client_session_co_discard which uses uint32_t as the length in bytes of the data to discard due to the following definition: struct nbd_request { uint32_t magic; uint32_t type; uint64_t handle; uint64_t from; uint32_t len; <-- the length of data to be discarded, in bytes } QEMU_PACKED; Thus we should limit bl_max_discard to UINT32_MAX >> BDRV_SECTOR_BITS to avoid overflow. NBD read/write code uses the same structure for transfers. Fix max_transfer_length accordingly. Signed-off-by: Denis V. Lunev <den@openvz.org> CC: Peter Lieven <pl@kamp.de> CC: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2015-02-06block: introduce BDRV_REQUEST_MAX_SECTORSPeter Lieven
we check and adjust request sizes at several places with sometimes inconsistent checks or default values: INT_MAX INT_MAX >> BDRV_SECTOR_BITS UINT_MAX >> BDRV_SECTOR_BITS SIZE_MAX >> BDRV_SECTOR_BITS This patches introdocues a macro for the maximal allowed sectors per request and uses it at several places. Signed-off-by: Peter Lieven <pl@kamp.de> Reviewed-by: Denis V. Lunev <den@openvz.org> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2015-02-06nbd: Improve error messagesMax Reitz
This patch makes use of the Error object for nbd_receive_negotiate() so that errors during negotiation look nicer. Furthermore, this patch adds an additional error message if the received magic was wrong, but would be correct for the other protocol version, respectively: So if an export name was specified, but the NBD server magic corresponds to an old handshake, this condition is explicitly signaled to the user, and vice versa. As these messages are now part of the "Could not open image" error message, additional filtering has to be employed in iotest 083, which this patch does as well. Signed-off-by: Max Reitz <mreitz@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2015-02-06iotests: Fix 104 for NBDMax Reitz
_make_test_img sets up an NBD server, _cleanup_test_img shuts it down; thus, _cleanup_test_img has to be called before _make_test_img is invoked another time. Furthermore, the pipe through _filter_test_img was unnecessary; _make_test_img already takes care of that. And finally, a filter is added to _filter_img_info to replace "nbd://127.0.0.1:10810" by "TEST_DIR/t.IMGFMT", since the former is the way to express the full image path (normally the latter) for NBD tests. Signed-off-by: Max Reitz <mreitz@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2015-02-06iotests: Fix 100 for nbdMax Reitz
In case of NBD, _make_test_img starts a new NBD server. Therefore, _cleanup_test_img (which shuts that server down) has to be invoked before the next _make_test_img call in order to make 100 work for NBD. Signed-off-by: Max Reitz <mreitz@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2015-02-06iotests: Fix 083Max Reitz
As of 8f9e835fd2e687d2bfe936819c3494af4343614d, probing should be disabled in the qemu-iotests (at least when using qemu-io). This broke 083's reference output (which consisted mostly of "Could not read image for determining its format"). This patch fixes it. Note that one case which failed before is now successful: Disconnect after data. This is due to qemu having read twice before (once for probing, once for the qemu-io read command), but only once now (the qemu-io read command). Therefore, reading is successful (which is correct). Signed-off-by: Max Reitz <mreitz@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2015-02-06block: fix off-by-one error in qcow and qcow2Jeff Cody
This fixes an off-by-one error introduced in 9a29e18. Both qcow and qcow2 need to make sure to leave room for string terminator '\0' for the backing file, so the max length of the non-terminated string is either 1023 or PATH_MAX - 1. Reported-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Jeff Cody <jcody@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2015-02-06qemu-iotests: add 116 invalid QED input file testsStefan Hajnoczi
These tests exercise error code paths in the QED image format. The tests are very simple, they just prove that the error path exits cleanly. Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Message-id: 1421065893-18875-3-git-send-email-stefanha@redhat.com Reviewed-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2015-02-06qed: check for header size overflowStefan Hajnoczi
Header size is denoted in clusters. The maximum cluster size is 64 MB but there is no limit on header size. Check for uint32_t overflow in case the header size field has a whacky value. Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Message-id: 1421065893-18875-2-git-send-email-stefanha@redhat.com Reviewed-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2015-02-06block/dmg: improve zeroes handlingPeter Wu
Disk images may contain large all-zeroes gaps (1.66k sectors or 812 MiB is seen in the real world). These blocks (type 2) do not need to be extracted into a temporary buffer, there is no need to allocate memory for these blocks nor to check its length. (For the test image, the maximum uncompressed size is 1054371 bytes, probably for a bzip2-compressed block.) Signed-off-by: Peter Wu <peter@lekensteyn.nl> Reviewed-by: John Snow <jsnow@redhat.com> Message-id: 1420566495-13284-13-git-send-email-peter@lekensteyn.nl Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2015-02-06block/dmg: support bzip2 block entry typesPeter Wu
This patch adds support for bzip2-compressed block entries as introduced with OS X 10.4 (source: https://en.wikipedia.org/wiki/Apple_Disk_Image). It was tested against a 5.2G "OS X Yosemite" installation image which stores the BLXX block in the XML property list (instead of resource forks) and has over 5k chunks. New configure entries are added (--enable-bzip2 / --disable-bzip2) to control inclusion of bzip2 functionality (which requires linking against libbz2). The help message suggests that this option is needed for DMG files, but the tests are generic enough that other parts of QEMU can use bzip2 if needed. The identifiers are based on http://newosxbook.com/DMG.html. The decompression routines are based on the zlib case, but as there is no way to reset the decompression state (unlike zlib), memory is allocated and deallocated for every decompression. This should not be problematic as the decompression takes most of the time and as blocks are typically about/over 1 MiB in size, only one allocation is done every 2000 sectors. Signed-off-by: Peter Wu <peter@lekensteyn.nl> Reviewed-by: John Snow <jsnow@redhat.com> Acked-by: Paolo Bonzini <pbonzini@redhat.com> Message-id: 1420566495-13284-12-git-send-email-peter@lekensteyn.nl Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2015-02-06block/dmg: factor out block type checkPeter Wu
In preparation for adding bzip2 support, split the type check into a separate function. Make all offsets relative to the begin of a chunk such that it is easier to recognize the position without having to add up all offsets. Some comments are added to describe the fields. There is no functional change. Signed-off-by: Peter Wu <peter@lekensteyn.nl> Reviewed-by: John Snow <jsnow@redhat.com> Message-id: 1420566495-13284-11-git-send-email-peter@lekensteyn.nl Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2015-02-06block/dmg: use SectorNumber from BLKX headerPeter Wu
Previously the sector table parsing relied on the previous offset of the DMG file. Now it uses the sector number from the BLKX header (see http://newosxbook.com/DMG.html). The implementation of dmg2img (from vu1tur) does not base the output sector on the location of the terminator (0xffffffff) either so it should be safe to drop this dependency on the previous state. (It makes somehow makes sense, a terminator should halt further processing of a block and is perhaps used to preallocate some space.) Signed-off-by: Peter Wu <peter@lekensteyn.nl> Reviewed-by: John Snow <jsnow@redhat.com> Message-id: 1420566495-13284-10-git-send-email-peter@lekensteyn.nl Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2015-02-06block/dmg: fix sector data offset calculationPeter Wu
This patch addresses two issues: - The data fork offset was not taken into account, resulting in failure to read an InstallESD.dmg file (5164763151 bytes) which had a non-zero DataForkOffset field. - The offset of the previous block ("partition") was unconditionally added to the current block because older files would start the input offset of a new block at zero. Newer files (including vlc-2.1.5.dmg, tuxpaint-0.9.15-macosx.dmg and OS X Yosemite [MAS].dmg) failed in reads because these files have chunk offsets, relative to the begin of a data fork. Now the data offset of the mish is taken into account. While we could check that the data_offset is within the data fork, let's not do that here as it would only result in parse failures on invalid files (rather than gracefully handling such bad files). dmg_read will error out if the offset is incorrect. Signed-off-by: Peter Wu <peter@lekensteyn.nl> Reviewed-by: John Snow <jsnow@redhat.com> Message-id: 1420566495-13284-9-git-send-email-peter@lekensteyn.nl Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2015-02-06block/dmg: set virtual size to a non-zero valuePeter Wu
Right now the virtual size is always reported as zero which makes it impossible to convert between formats. After this patch, the number of sectors will be read from the trailer ("koly" block). To verify the behavior, the output of `dmg2img foo.dmg foo.img` was compared against `qemu-img convert -f dmg -O raw foo.dmg foo.raw`. The tests showed that the file contents are exactly the same, except that QEMU creates a slightly larger file (it matches the total sectors count). Signed-off-by: Peter Wu <peter@lekensteyn.nl> Reviewed-by: John Snow <jsnow@redhat.com> Message-id: 1420566495-13284-8-git-send-email-peter@lekensteyn.nl Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2015-02-06block/dmg: process XML plistsPeter Wu
The format is simple enough to avoid using a full-blown XML parser. It assumes that all BLKX items begin with the "mish" magic word, therefore it is not a problem if other values get matched which are not a BLKX block. The offsets are based on the description at http://newosxbook.com/DMG.html For compatibility with glib 2.12, use g_base64_decode (which additionally requires an extra buffer allocation) instead of g_base64_decode_inplace (which is only available since glib 2.20). Signed-off-by: Peter Wu <peter@lekensteyn.nl> Reviewed-by: John Snow <jsnow@redhat.com> Message-id: 1420566495-13284-7-git-send-email-peter@lekensteyn.nl Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>