1. 14 7月, 2016 1 次提交
    • L
      virtio-mmio: format transport base address in BusClass.get_dev_path · f58b39d2
      Laszlo Ersek 提交于
      At the moment the following QEMU command line triggers an assertion
      failure (minimal reproducer by Cole):
      
        qemu-system-aarch64 \
          -machine virt-2.6,accel=tcg \
          -nodefaults \
          -no-user-config \
          -nographic -monitor stdio \
          -device virtio-scsi-device,id=scsi0 \
          -device virtio-scsi-device,id=scsi1 \
          -drive file=foo.img,format=raw,if=none,id=d0 \
          -device scsi-hd,bus=scsi0.0,drive=d0 \
          -drive file=foo.img,format=raw,if=none,id=d1 \
          -device scsi-hd,bus=scsi1.0,drive=d1
      
        qemu-system-aarch64: migration/savevm.c:615:
        vmstate_register_with_alias_id:
        Assertion `!se->compat || se->instance_id == 0' failed.
      
      The reason is that the vmstate sections for the two scsi-hd devices are
      not uniquely identifiable by name.
      
      The direct parent buses of the scsi-hd devices -- scsi0.0 and scsi1.0 --
      support the BusClass.get_dev_path member function. scsibus_get_dev_path()
      formats a device path prefix with the help of its topologically parent
      bus, and then appends the chan:id:lun triplet to it. For both scsi-hd
      devices, this triplet is 0:0:0.
      
      (Here we use "device path" in the QEMU migration sense, for vmstate
      section identification, not in the OFW or UEFI device path senses.)
      
      The virtio-scsi HBA is plugged into the virtio-mmio bus (implemented by
      the internal VirtIOMMIOProxy device). This bus class
      (TYPE_VIRTIO_MMIO_BUS) inherits, as its get_dev_path() member function,
      the virtio_bus_get_dev_path() method from its parent class
      (TYPE_VIRTIO_BUS).
      
      virtio_bus_get_dev_path() does not format any kind of device address on
      its own; "virtio addresses" are transport-specific. Therefore
      virtio_bus_get_dev_path() asks the topologically parent bus of the proxy
      object (implementing the specific virtio transport) to format the address
      of the proxy object.
      
      (For virtio-pci devices (where the proxy is an instance of VirtIOPCIProxy,
      plugged into a PCI bus), this ends up in pcibus_get_dev_path().)
      
      However, VirtIOMMIOProxy is usually (in practice: always) plugged into
      "main-system-bus", the singleton TYPE_SYSTEM_BUS object. This BusClass
      does not support formatting QEMU vmstate device paths at all (as
      SysBusDevice objects can have zero or more IO ports and zero or more MMIO
      regions). Hence the formatting request delegated from
      virtio_bus_get_dev_path() gets answered with NULL.
      
      The end result is that the two scsi-hd devices end up with the same device
      path "0:0:0", which triggers the assert.
      
      We can solve this by recognizing that virtio-mmio transports are
      distinguished from each other by their base addresses in MMIO address
      space. Implement virtio_mmio_bus_get_dev_path() as follows:
      
      (1) The virtio device whose devpath is to be formatted resides on a
          virtio-mmio bus that is implemented by a VirtIOMMIOProxy object. Ask
          the parent bus of VirtIOMMIOProxy to format the device path of
          VirtIOMMIOProxy, as a path prefix. (This is identical to what
          virtio_bus_get_dev_path() does.)
      
      (2) Append the base address of VirtIOMMIOProxy to the device path, such
          as:
          - virtio-mmio@000000000a003e00,
          - virtio-mmio@000000000a003c00.
      
      Given that these device paths are placed in the migration stream, step (2)
      above, if done unconditionally, would break migration. So make that step
      conditional on a new VirtIOMMIOProxy property, which is enabled for 2.7
      machine types and later.
      
      Cc: "Michael S. Tsirkin" <mst@redhat.com>
      Cc: Cole Robinson <crobinso@redhat.com>
      Cc: Dr. David Alan Gilbert <dgilbert@redhat.com>
      Cc: Kevin Zhao <kevin.zhao@linaro.org>
      Cc: Peter Maydell <peter.maydell@linaro.org>
      Cc: Tom Hanson <thomas.hanson@linaro.org>
      Reported-by: NKevin Zhao <kevin.zhao@linaro.org>
      Reviewed-by: NAndrew Jones <drjones@redhat.com>
      Signed-off-by: NLaszlo Ersek <lersek@redhat.com>
      Message-id: 1467739394-28357-1-git-send-email-lersek@redhat.com
      Fixes: https://bugs.launchpad.net/qemu/+bug/1594239Signed-off-by: NLaszlo Ersek <lersek@redhat.com>
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      f58b39d2
  2. 12 7月, 2016 1 次提交
  3. 07 7月, 2016 1 次提交
  4. 06 7月, 2016 1 次提交
    • E
      qapi: Add parameter to visit_end_* · 1158bb2a
      Eric Blake 提交于
      Rather than making the dealloc visitor track of stack of pointers
      remembered during visit_start_* in order to free them during
      visit_end_*, it's a lot easier to just make all callers pass the
      same pointer to visit_end_*.  The generated code has access to the
      same pointer, while all other users are doing virtual walks and
      can pass NULL.  The dealloc visitor is then greatly simplified.
      
      All three visit_end_*() functions intentionally take a void**,
      even though the visit_start_*() functions differ between void**,
      GenericList**, and GenericAlternate**.  This is done for several
      reasons: when doing a virtual walk, passing NULL doesn't care
      what the type is, but when doing a generated walk, we already
      have to cast the caller's specific FOO* to call visit_start,
      while using void** lets us use visit_end without a cast. Also,
      an upcoming patch will add a clone visitor that wants to use
      the same implementation for all three visit_end callbacks,
      which is made easier if all three share the same signature.
      
      For visitors with already track per-object state (the QMP visitors
      via a stack, and the string visitors which do not allow nesting),
      add an assertion that the caller is indeed passing the same
      pointer to paired calls.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Message-Id: <1465490926-28625-4-git-send-email-eblake@redhat.com>
      Reviewed-by: NMarkus Armbruster <armbru@redhat.com>
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      1158bb2a
  5. 04 7月, 2016 2 次提交
  6. 24 6月, 2016 5 次提交
  7. 21 6月, 2016 1 次提交
  8. 20 6月, 2016 1 次提交
    • E
      coccinelle: Remove unnecessary variables for function return value · 9be38598
      Eduardo Habkost 提交于
      Use Coccinelle script to replace 'ret = E; return ret' with
      'return E'. The script will do the substitution only when the
      function return type and variable type are the same.
      
      Manual fixups:
      
      * audio/audio.c: coding style of "read (...)" and "write (...)"
      * block/qcow2-cluster.c: wrap line to make it shorter
      * block/qcow2-refcount.c: change indentation of wrapped line
      * target-tricore/op_helper.c: fix coding style of
        "remainder|quotient"
      * target-mips/dsp_helper.c: reverted changes because I don't
        want to argue about checkpatch.pl
      * ui/qemu-pixman.c: fix line indentation
      * block/rbd.c: restore blank line between declarations and
        statements
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Signed-off-by: NEduardo Habkost <ehabkost@redhat.com>
      Message-Id: <1465855078-19435-4-git-send-email-ehabkost@redhat.com>
      Reviewed-by: NMarkus Armbruster <armbru@redhat.com>
      [Unused Coccinelle rule name dropped along with a redundant comment;
      whitespace touched up in block/qcow2-cluster.c; stale commit message
      paragraph deleted]
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      9be38598
  9. 17 6月, 2016 1 次提交
  10. 07 6月, 2016 2 次提交
  11. 29 5月, 2016 2 次提交
  12. 12 5月, 2016 1 次提交
    • E
      qapi: Split visit_end_struct() into pieces · 15c2f669
      Eric Blake 提交于
      As mentioned in previous patches, we want to call visit_end_struct()
      functions unconditionally, so that visitors can release resources
      tied up since the matching visit_start_struct() without also having
      to worry about error priority if more than one error occurs.
      
      Even though error_propagate() can be safely used to ignore a second
      error during cleanup caused by a first error, it is simpler if the
      cleanup cannot set an error.  So, split out the error checking
      portion (basically, input visitors checking for unvisited keys) into
      a new function visit_check_struct(), which can be safely skipped if
      any earlier errors are encountered, and leave the cleanup portion
      (which never fails, but must be called unconditionally if
      visit_start_struct() succeeded) in visit_end_struct().
      
      Generated code in qapi-visit.c has diffs resembling:
      
      |@@ -59,10 +59,12 @@ void visit_type_ACPIOSTInfo(Visitor *v,
      |         goto out_obj;
      |     }
      |     visit_type_ACPIOSTInfo_members(v, obj, &err);
      |-    error_propagate(errp, err);
      |-    err = NULL;
      |+    if (err) {
      |+        goto out_obj;
      |+    }
      |+    visit_check_struct(v, &err);
      | out_obj:
      |-    visit_end_struct(v, &err);
      |+    visit_end_struct(v);
      | out:
      
      and in qapi-event.c:
      
      @@ -47,7 +47,10 @@ void qapi_event_send_acpi_device_ost(ACP
      |         goto out;
      |     }
      |     visit_type_q_obj_ACPI_DEVICE_OST_arg_members(v, &param, &err);
      |-    visit_end_struct(v, err ? NULL : &err);
      |+    if (!err) {
      |+        visit_check_struct(v, &err);
      |+    }
      |+    visit_end_struct(v);
      |     if (err) {
      |         goto out;
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Message-Id: <1461879932-9020-20-git-send-email-eblake@redhat.com>
      [Conflict with a doc fixup resolved]
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      15c2f669
  13. 22 4月, 2016 2 次提交
  14. 14 4月, 2016 1 次提交
    • T
      hw/virtio/balloon: Replace TARGET_PAGE_SIZE with BALLOON_PAGE_SIZE · 01310e2a
      Thomas Huth 提交于
      The balloon code currently calls madvise() with TARGET_PAGE_SIZE as
      length parameter. Since the virtio-balloon protocol is always based
      on 4k pages, no matter what the host and guest are using as page size,
      this could cause problems: If TARGET_PAGE_SIZE is bigger than 4k, the
      madvise call also destroys the 4k areas after the current one - which
      might be wrong since the guest did not want free that area yet (in
      case the guest used as smaller MMU page size than the hard-coded
      TARGET_PAGE_SIZE). So to fix this issue, introduce a proper define
      called BALLOON_PAGE_SIZE (which is 4096) to use this as the size
      parameter for the madvise() call instead.
      Signed-off-by: NThomas Huth <thuth@redhat.com>
      Reviewed-by: NMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: NMichael S. Tsirkin <mst@redhat.com>
      01310e2a
  15. 08 4月, 2016 4 次提交
  16. 23 3月, 2016 2 次提交
    • P
      hw: explicitly include qemu-common.h and cpu.h · 4771d756
      Paolo Bonzini 提交于
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      4771d756
    • M
      include/qemu/osdep.h: Don't include qapi/error.h · da34e65c
      Markus Armbruster 提交于
      Commit 57cb38b3 included qapi/error.h into qemu/osdep.h to get the
      Error typedef.  Since then, we've moved to include qemu/osdep.h
      everywhere.  Its file comment explains: "To avoid getting into
      possible circular include dependencies, this file should not include
      any other QEMU headers, with the exceptions of config-host.h,
      compiler.h, os-posix.h and os-win32.h, all of which are doing a
      similar job to this file and are under similar constraints."
      qapi/error.h doesn't do a similar job, and it doesn't adhere to
      similar constraints: it includes qapi-types.h.  That's in excess of
      100KiB of crap most .c files don't actually need.
      
      Add the typedef to qemu/typedefs.h, and include that instead of
      qapi/error.h.  Include qapi/error.h in .c files that need it and don't
      get it now.  Include qapi-types.h in qom/object.h for uint16List.
      
      Update scripts/clean-includes accordingly.  Update it further to match
      reality: replace config.h by config-target.h, add sysemu/os-posix.h,
      sysemu/os-win32.h.  Update the list of includes in the qemu/osdep.h
      comment quoted above similarly.
      
      This reduces the number of objects depending on qapi/error.h from "all
      of them" to less than a third.  Unfortunately, the number depending on
      qapi-types.h shrinks only a little.  More work is needed for that one.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      [Fix compilation without the spice devel packages. - Paolo]
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      da34e65c
  17. 11 3月, 2016 5 次提交
  18. 03 3月, 2016 1 次提交
  19. 25 2月, 2016 6 次提交