Skip to content
Snippets Groups Projects
  1. May 28, 2022
  2. Apr 21, 2022
  3. Apr 20, 2022
  4. Mar 22, 2022
  5. Aug 26, 2021
  6. May 14, 2021
    • Vladimir Sementsov-Ogievskiy's avatar
      monitor: hmp_qemu_io: acquire aio contex, fix crash · 78632a3d
      Vladimir Sementsov-Ogievskiy authored
      
      Max reported the following bug:
      
      $ ./qemu-img create -f raw src.img 1G
      $ ./qemu-img create -f raw dst.img 1G
      
      $ (echo '
         {"execute":"qmp_capabilities"}
         {"execute":"blockdev-mirror",
          "arguments":{"job-id":"mirror",
                       "device":"source",
                       "target":"target",
                       "sync":"full",
                       "filter-node-name":"mirror-top"}}
      '; sleep 3; echo '
         {"execute":"human-monitor-command",
          "arguments":{"command-line":
                       "qemu-io mirror-top \"write 0 1G\""}}') \
      | x86_64-softmmu/qemu-system-x86_64 \
         -qmp stdio \
         -blockdev file,node-name=source,filename=src.img \
         -blockdev file,node-name=target,filename=dst.img \
         -object iothread,id=iothr0 \
         -device virtio-blk,drive=source,iothread=iothr0
      
      crashes:
      
      0  raise () at /usr/lib/libc.so.6
      1  abort () at /usr/lib/libc.so.6
      2  error_exit
         (err=<optimized out>,
         msg=msg@entry=0x55fbb1634790 <__func__.27> "qemu_mutex_unlock_impl")
         at ../util/qemu-thread-posix.c:37
      3  qemu_mutex_unlock_impl
         (mutex=mutex@entry=0x55fbb25ab6e0,
         file=file@entry=0x55fbb1636957 "../util/async.c",
         line=line@entry=650)
         at ../util/qemu-thread-posix.c:109
      4  aio_context_release (ctx=ctx@entry=0x55fbb25ab680) at ../util/async.c:650
      5  bdrv_do_drained_begin
         (bs=bs@entry=0x55fbb3a87000, recursive=recursive@entry=false,
         parent=parent@entry=0x0,
         ignore_bds_parents=ignore_bds_parents@entry=false,
         poll=poll@entry=true) at ../block/io.c:441
      6  bdrv_do_drained_begin
         (poll=true, ignore_bds_parents=false, parent=0x0, recursive=false,
         bs=0x55fbb3a87000) at ../block/io.c:448
      7  blk_drain (blk=0x55fbb26c5a00) at ../block/block-backend.c:1718
      8  blk_unref (blk=0x55fbb26c5a00) at ../block/block-backend.c:498
      9  blk_unref (blk=0x55fbb26c5a00) at ../block/block-backend.c:491
      10 hmp_qemu_io (mon=0x7fffaf3fc7d0, qdict=<optimized out>)
         at ../block/monitor/block-hmp-cmds.c:628
      
      man pthread_mutex_unlock
      ...
          EPERM  The  mutex type is PTHREAD_MUTEX_ERRORCHECK or
          PTHREAD_MUTEX_RECURSIVE, or the mutex is a robust mutex, and the
          current thread does not own the mutex.
      
      So, thread doesn't own the mutex. And we have iothread here.
      
      Next, note that AIO_WAIT_WHILE() documents that ctx must be acquired
      exactly once by caller. But where is it acquired in the call stack?
      Seems nowhere.
      
      qemuio_command do acquire aio context.. But we need context acquired
      around blk_unref() as well and actually around blk_insert_bs() too.
      
      Let's refactor qemuio_command so that it doesn't acquire aio context
      but callers do that instead. This way we can cleanly acquire aio
      context in hmp_qemu_io() around all three calls.
      
      Reported-by: default avatarMax Reitz <mreitz@redhat.com>
      Signed-off-by: default avatarVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
      Message-Id: <20210423134233.51495-1-vsementsov@virtuozzo.com>
      [mreitz: Fixed comment]
      Signed-off-by: default avatarMax Reitz <mreitz@redhat.com>
      78632a3d
  7. Mar 19, 2021
  8. Nov 11, 2020
  9. Sep 02, 2020
  10. Jan 30, 2020
  11. Oct 14, 2019
  12. Jun 12, 2019
    • Markus Armbruster's avatar
      Include qemu-common.h exactly where needed · a8d25326
      Markus Armbruster authored
      
      No header includes qemu-common.h after this commit, as prescribed by
      qemu-common.h's file comment.
      
      Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Message-Id: <20190523143508.25387-5-armbru@redhat.com>
      [Rebased with conflicts resolved automatically, except for
      include/hw/arm/xlnx-zynqmp.h hw/arm/nrf51_soc.c hw/arm/msf2-soc.c
      block/qcow2-refcount.c block/qcow2-cluster.c block/qcow2-cache.c
      target/arm/cpu.h target/lm32/cpu.h target/m68k/cpu.h target/mips/cpu.h
      target/moxie/cpu.h target/nios2/cpu.h target/openrisc/cpu.h
      target/riscv/cpu.h target/tilegx/cpu.h target/tricore/cpu.h
      target/unicore32/cpu.h target/xtensa/cpu.h; bsd-user/main.c and
      net/tap-bsd.c fixed up]
      a8d25326
    • Markus Armbruster's avatar
      Include qemu/module.h where needed, drop it from qemu-common.h · 0b8fa32f
      Markus Armbruster authored
      
      Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Message-Id: <20190523143508.25387-4-armbru@redhat.com>
      [Rebased with conflicts resolved automatically, except for
      hw/usb/dev-hub.c hw/misc/exynos4210_rng.c hw/misc/bcm2835_rng.c
      hw/misc/aspeed_scu.c hw/display/virtio-vga.c hw/arm/stm32f205_soc.c;
      ui/cocoa.m fixed up]
      0b8fa32f
  13. Apr 17, 2019
  14. Oct 19, 2018
  15. Jun 11, 2018
  16. May 15, 2018
    • Hanna Reitz's avatar
      qemu-io: Use purely string blockdev options · 2a01c01f
      Hanna Reitz authored
      
      Currently, qemu-io only uses string-valued blockdev options (as all are
      converted directly from QemuOpts) -- with one exception: -U adds the
      force-share option as a boolean.  This in itself is already a bit
      questionable, but a real issue is that it also assumes the value already
      existing in the options QDict would be a boolean, which is wrong.
      
      That has the following effect:
      
      $ ./qemu-io -r -U --image-opts \
          driver=file,filename=/dev/null,force-share=off
      [1]    15200 segmentation fault (core dumped)  ./qemu-io -r -U
      --image-opts driver=file,filename=/dev/null,force-share=off
      
      Since @opts is converted from QemuOpts, the value must be a string, and
      we have to compare it as such.  Consequently, it makes sense to also set
      it as a string instead of a boolean.
      
      Cc: qemu-stable@nongnu.org
      Signed-off-by: default avatarMax Reitz <mreitz@redhat.com>
      Message-id: 20180502202051.15493-2-mreitz@redhat.com
      Reviewed-by: default avatarEric Blake <eblake@redhat.com>
      Signed-off-by: default avatarMax Reitz <mreitz@redhat.com>
      2a01c01f
  17. May 04, 2018
  18. Mar 12, 2018
    • Thomas Huth's avatar
      Polish the version strings containing the package version · 7e563bfb
      Thomas Huth authored
      Since commit 67a1de0d there is no space anymore between the
      version number and the parentheses when running configure with
      --with-pkgversion=foo :
      
       $ qemu-system-s390x --version
       QEMU emulator version 2.11.50(foo)
      
      But the space is included when building without that option
      when building from a git checkout:
      
       $ qemu-system-s390x --version
       QEMU emulator version 2.11.50 (v2.11.0-1494-gbec9c64-dirty)
      
      The same confusion exists with the "query-version" QMP command.
      Let's fix this by introducing a proper QEMU_FULL_VERSION definition
      that includes the space and parentheses, while the QEMU_PKGVERSION
      should just cleanly contain the package version string itself.
      Note that this also changes the behavior of the "query-version" QMP
      command (the space and parentheses are not included there anymore),
      but that's supposed to be OK since the strings there are not meant
      to be parsed by other tools.
      
      Fixes: 67a1de0d
      Buglink: https://bugs.launchpad.net/qemu/+bug/1673373
      
      
      Signed-off-by: default avatarThomas Huth <thuth@redhat.com>
      Message-Id: <1518692807-25859-1-git-send-email-thuth@redhat.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      7e563bfb
  19. Mar 06, 2018
  20. Feb 13, 2018
    • Daniel P. Berrangé's avatar
      qemu-io: fix EOF Ctrl-D handling in qemu-io readline code · 0e448a05
      Daniel P. Berrangé authored
      
      qemu-io puts the TTY into non-canonical mode, which means no EOF processing is
      done and thus getchar() will never return the EOF constant. Instead we have to
      query the TTY attributes to determine the configured EOF character (usually
      Ctrl-D / 0x4), and then explicitly check for that value. This fixes the
      regression that prevented Ctrl-D from triggering an exit of qemu-io that has
      existed since readline was first added in
      
        commit 0cf17e18
        Author: Stefan Hajnoczi <stefanha@redhat.com>
        Date:   Thu Nov 14 11:54:17 2013 +0100
      
          qemu-io: use readline.c
      
      It also ensures that a newline is printed when exiting, to complete the
      line output by the "qemu-io> " prompt.
      
      Signed-off-by: default avatarDaniel P. Berrange <berrange@redhat.com>
      Reviewed-by: default avatarEric Blake <eblake@redhat.com>
      Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
      0e448a05
  21. Feb 09, 2018
  22. Oct 06, 2017
  23. Aug 08, 2017
  24. Jul 11, 2017
  25. Jul 10, 2017
    • Eric Blake's avatar
      qemu-io: Don't die on second open · 64ebf556
      Eric Blake authored
      
      Most callback commands in qemu-io return 0 to keep the interpreter
      loop running, or 1 to quit immediately.  However, open_f() just
      passed through the return value of openfile(), which has different
      semantics of returning 0 if a file was opened, or 1 on any failure.
      
      As a result of mixing the return semantics, we are forcing the
      qemu-io interpreter to exit early on any failures, which is rather
      annoying when some of the failures are obviously trying to give
      the user a hint of how to proceed (if we didn't then kill qemu-io
      out from under the user's feet):
      
      $ qemu-io
      qemu-io> open foo
      qemu-io> open foo
      file open already, try 'help close'
      $ echo $?
      0
      
      In general, we WANT openfile() to report failures, since it is the
      function used in the form 'qemu-io -c "$something" no_such_file'
      for performing one or more -c options on a single file, and it is
      not worth attempting $something if the file itself cannot be opened.
      So the solution is to fix open_f() to always return 0 (when we are
      in interactive mode, even failure to open should not end the
      session), and save the return value of openfile() for command line
      use in main().
      
      Note, however, that we do have some qemu-iotests that do 'qemu-io
      -c "open file" -c "$something"'; such tests will now proceed to
      attempt $something whether or not the open succeeded, the same way
      as if the two commands had been attempted in interactive mode.  As
      such, the expected output for those tests has to be modified.  But it
      also means that it is now possible to use -c close and have a single
      qemu-io command line operate on more than one file even without
      using interactive mode.  Although the '-c open' action is a subtle
      change in behavior, remember that qemu-io is for debugging purposes,
      so as long as it serves the needs of qemu-iotests while still being
      reasonable for interactive use, it should not be a problem that we
      are changing tests to the new behavior.
      
      This has been awkward since at least as far back as commit
      e3aff4f6, in 2009.
      
      Signed-off-by: default avatarEric Blake <eblake@redhat.com>
      Reviewed-by: default avatarFam Zheng <famz@redhat.com>
      Reviewed-by: default avatarJohn Snow <jsnow@redhat.com>
      Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
      64ebf556
  26. May 23, 2017
  27. May 11, 2017
  28. May 09, 2017
  29. Feb 11, 2017
    • Nir Soffer's avatar
      qemu-io: Return non-zero exit code on failure · b7aa1315
      Nir Soffer authored
      
      The result of openfile was not checked, leading to failure deep in the
      actual command with confusing error message, and exiting with exit code 0.
      
      Here is a simple example - trying to read with the wrong format:
      
          $ touch file
          $ qemu-io -f qcow2 -c 'read -P 1 0 1024' file; echo $?
          can't open device file: Image is not in qcow2 format
          no file open, try 'help open'
          0
      
      With this patch, we fail earlier with exit code 1:
      
          $ ./qemu-io -f qcow2 -c 'read -P 1 0 1024' file; echo $?
          can't open device file: Image is not in qcow2 format
          1
      
      Failing earlier, we don't log this error now:
      
          no file open, try 'help open'
      
      But some tests expected it; the line was removed from the test output.
      
      Signed-off-by: default avatarNir Soffer <nirsof@gmail.com>
      Reviewed-by: default avatarEric Blake <eblake@redhat.com>
      Message-id: 20170201003120.23378-2-nirsof@gmail.com
      Reviewed-by: default avatarMax Reitz <mreitz@redhat.com>
      Signed-off-by: default avatarMax Reitz <mreitz@redhat.com>
      b7aa1315
  30. Oct 12, 2016
    • Daniel P. Berrangé's avatar
      trace: provide mechanism for registering trace events · fe4db84d
      Daniel P. Berrangé authored
      
      Remove the notion of there being a single global array
      of trace events, by introducing a method for registering
      groups of events.
      
      The module_call_init() needs to be invoked at the start
      of any program that wants to make use of the trace
      support. Currently this covers system emulators qemu-nbd,
      qemu-img and qemu-io.
      
      [Squashed the following fix from Daniel P. Berrange
      <berrange@redhat.com>:
      
      linux-user/bsd-user: initialize trace events subsystem
      
      The bsd-user/linux-user programs make use of the CPU emulation
      code and this now requires that the trace events subsystem
      is enabled, otherwise it'll crash trying to allocate an empty
      trace events bitmap for the CPU object.
      
      --Stefan]
      
      Reviewed-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
      Reviewed-by: default avatarLluís Vilanova <vilanova@ac.upc.edu>
      Signed-off-by: default avatarDaniel P. Berrange <berrange@redhat.com>
      Message-id: 1475588159-30598-14-git-send-email-berrange@redhat.com
      Signed-off-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
      fe4db84d
  31. Jun 28, 2016
  32. May 20, 2016
  33. May 12, 2016
    • Eric Blake's avatar
      qemu-io: Make 'open' subcommand more like command line · b8d970f1
      Eric Blake authored
      
      The command line defaults to BDRV_O_UNMAP, but can use
      -d to reset it.  Meanwhile, the 'open' subcommand was
      defaulting to no discards, with no way to set it.
      
      The command line has both -n and -tMODE to set a variety
      of cache modes, but the 'open' subcommand had only -n.
      
      The 'open' subcommand had no way to set BDRV_O_NATIVE_AIO.
      
      Note that the 'reopen' subcommand uses '-c' where the
      command line and 'open' use -t.  Making that consistent
      would be a separate patch.
      
      Signed-off-by: default avatarEric Blake <eblake@redhat.com>
      Message-id: 1462677405-4752-3-git-send-email-eblake@redhat.com
      Reviewed-by: default avatarMax Reitz <mreitz@redhat.com>
      Signed-off-by: default avatarMax Reitz <mreitz@redhat.com>
      b8d970f1
Loading