Skip to content
Snippets Groups Projects
  1. Sep 13, 2019
    • Philippe Mathieu-Daudé's avatar
      block/create: Do not abort if a block driver is not available · d90d5cae
      Philippe Mathieu-Daudé authored
      
      The 'blockdev-create' QMP command was introduced as experimental
      feature in commit b0292b85, using the assert() debug call.
      It got promoted to 'stable' command in 3fb588a0, but the
      assert call was not removed.
      
      Some block drivers are optional, and bdrv_find_format() might
      return a NULL value, triggering the assertion.
      
      Stable code is not expected to abort, so return an error instead.
      
      This is easily reproducible when libnfs is not installed:
      
        ./configure
        [...]
        module support    no
        Block whitelist (rw)
        Block whitelist (ro)
        libiscsi support  yes
        libnfs support    no
        [...]
      
      Start QEMU:
      
        $ qemu-system-x86_64 -S -qmp unix:/tmp/qemu.qmp,server,nowait
      
      Send the 'blockdev-create' with the 'nfs' driver:
      
        $ ( cat << 'EOF'
        {'execute': 'qmp_capabilities'}
        {'execute': 'blockdev-create', 'arguments': {'job-id': 'x', 'options': {'size': 0, 'driver': 'nfs', 'location': {'path': '/', 'server': {'host': '::1', 'type': 'inet'}}}}, 'id': 'x'}
        EOF
        ) | socat STDIO UNIX:/tmp/qemu.qmp
        {"QMP": {"version": {"qemu": {"micro": 50, "minor": 1, "major": 4}, "package": "v4.1.0-733-g89ea03a7dc"}, "capabilities": ["oob"]}}
        {"return": {}}
      
      QEMU crashes:
      
        $ gdb qemu-system-x86_64 core
        Program received signal SIGSEGV, Segmentation fault.
        (gdb) bt
        #0  0x00007ffff510957f in raise () at /lib64/libc.so.6
        #1  0x00007ffff50f3895 in abort () at /lib64/libc.so.6
        #2  0x00007ffff50f3769 in _nl_load_domain.cold.0 () at /lib64/libc.so.6
        #3  0x00007ffff5101a26 in .annobin_assert.c_end () at /lib64/libc.so.6
        #4  0x0000555555d7e1f1 in qmp_blockdev_create (job_id=0x555556baee40 "x", options=0x555557666610, errp=0x7fffffffc770) at block/create.c:69
        #5  0x0000555555c96b52 in qmp_marshal_blockdev_create (args=0x7fffdc003830, ret=0x7fffffffc7f8, errp=0x7fffffffc7f0) at qapi/qapi-commands-block-core.c:1314
        #6  0x0000555555deb0a0 in do_qmp_dispatch (cmds=0x55555645de70 <qmp_commands>, request=0x7fffdc005c70, allow_oob=false, errp=0x7fffffffc898) at qapi/qmp-dispatch.c:131
        #7  0x0000555555deb2a1 in qmp_dispatch (cmds=0x55555645de70 <qmp_commands>, request=0x7fffdc005c70, allow_oob=false) at qapi/qmp-dispatch.c:174
      
      With this patch applied, QEMU returns a QMP error:
      
        {'execute': 'blockdev-create', 'arguments': {'job-id': 'x', 'options': {'size': 0, 'driver': 'nfs', 'location': {'path': '/', 'server': {'host': '::1', 'type': 'inet'}}}}, 'id': 'x'}
        {"id": "x", "error": {"class": "GenericError", "desc": "Block driver 'nfs' not found or not supported"}}
      
      Cc: qemu-stable@nongnu.org
      Reported-by: default avatarXu Tian <xutian@redhat.com>
      Signed-off-by: default avatarPhilippe Mathieu-Daudé <philmd@redhat.com>
      Reviewed-by: default avatarEric Blake <eblake@redhat.com>
      Reviewed-by: default avatarJohn Snow <jsnow@redhat.com>
      Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
      d90d5cae
  2. Aug 16, 2019
  3. Aug 31, 2018
    • John Snow's avatar
      jobs: utilize job_exit shim · eb23654d
      John Snow authored
      
      Utilize the job_exit shim by not calling job_defer_to_main_loop, and
      where applicable, converting the deferred callback into the job_exit
      callback.
      
      This converts backup, stream, create, and the unit tests all at once.
      Most of these jobs do not see any changes to the order in which they
      clean up their resources, except the test-blockjob-txn test, which
      now puts down its bs before job_completed is called.
      
      This is safe for the same reason the reordering in the mirror job is
      safe, because job_completed no longer runs under two locks, making
      the unref safe even if it causes a flush.
      
      Signed-off-by: default avatarJohn Snow <jsnow@redhat.com>
      Reviewed-by: default avatarMax Reitz <mreitz@redhat.com>
      Message-id: 20180830015734.19765-7-jsnow@redhat.com
      Signed-off-by: default avatarMax Reitz <mreitz@redhat.com>
      eb23654d
    • John Snow's avatar
      jobs: canonize Error object · 3d1f8b07
      John Snow authored
      
      Jobs presently use both an Error object in the case of the create job,
      and char strings in the case of generic errors elsewhere.
      
      Unify the two paths as just j->err, and remove the extra argument from
      job_completed. The integer error code for job_completed is kept for now,
      to be removed shortly in a separate patch.
      
      Signed-off-by: default avatarJohn Snow <jsnow@redhat.com>
      Message-id: 20180830015734.19765-3-jsnow@redhat.com
      [mreitz: Dropped a superfluous g_strdup()]
      Reviewed-by: default avatarEric Blake <eblake@redhat.com>
      Signed-off-by: default avatarMax Reitz <mreitz@redhat.com>
      3d1f8b07
    • John Snow's avatar
      jobs: change start callback to run callback · f67432a2
      John Snow authored
      
      Presently we codify the entry point for a job as the "start" callback,
      but a more apt name would be "run" to clarify the idea that when this
      function returns we consider the job to have "finished," except for
      any cleanup which occurs in separate callbacks later.
      
      As part of this clarification, change the signature to include an error
      object and a return code. The error ptr is not yet used, and the return
      code while captured, will be overwritten by actions in the job_completed
      function.
      
      Signed-off-by: default avatarJohn Snow <jsnow@redhat.com>
      Reviewed-by: default avatarMax Reitz <mreitz@redhat.com>
      Message-id: 20180830015734.19765-2-jsnow@redhat.com
      Reviewed-by: default avatarJeff Cody <jcody@redhat.com>
      Signed-off-by: default avatarMax Reitz <mreitz@redhat.com>
      f67432a2
  4. May 30, 2018
  5. Mar 09, 2018
    • Kevin Wolf's avatar
      block: x-blockdev-create QMP command · b0292b85
      Kevin Wolf authored
      
      This adds a synchronous x-blockdev-create QMP command that can create
      qcow2 images on a given node name.
      
      We don't want to block while creating an image, so this is not the final
      interface in all aspects, but BlockdevCreateOptionsQcow2 and
      .bdrv_co_create() are what they actually might look like in the end. In
      any case, this should be good enough to test whether we interpret
      BlockdevCreateOptions as we should.
      
      Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
      Reviewed-by: default avatarMax Reitz <mreitz@redhat.com>
      Reviewed-by: default avatarEric Blake <eblake@redhat.com>
      b0292b85
Loading