1. 24 3月, 2016 5 次提交
    • T
      hw/net/spapr_llan: Enable the RX buffer pools by default for new machines · 57c522f4
      Thomas Huth 提交于
      RX buffer pools are now enabled by default for new machine types.
      For older machine types, they are still disabled to avoid breaking
      migration.
      Signed-off-by: NThomas Huth <thuth@redhat.com>
      Reviewed-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Reviewed-by: NLaurent Vivier <lvivier@redhat.com>
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      57c522f4
    • T
      hw/net/spapr_llan: Fix receive buffer handling for better performance · 831e8822
      Thomas Huth 提交于
      tl;dr:
      This patch introduces an alternate way of handling the receive
      buffers of the spapr-vlan device, resulting in much better
      receive performance for the guest.
      
      Full story:
      One of our testers recently discovered that the performance of the
      spapr-vlan device is very poor compared to other NICs, and that
      a simple "ping -i 0.2 -s 65507 someip" in the guest can result
      in more than 50% lost ping packets (especially with older guest
      kernels < 3.17).
      
      After doing some analysis, it was clear that there is a problem
      with the way we handle the receive buffers in spapr_llan.c: The
      ibmveth driver of the guest Linux kernel tries to add a lot of
      buffers into several buffer pools (with 512, 2048 and 65536 byte
      sizes by default, but it can be changed via the entries in the
      /sys/devices/vio/1000/pool* directories of the guest). However,
      the spapr-vlan device of QEMU only tries to squeeze all receive
      buffer descriptors into one single page which has been supplied
      by the guest during the H_REGISTER_LOGICAL_LAN call, without
      taking care of different buffer sizes. This has two bad effects:
      First, only a very limited number of buffer descriptors is accepted
      at all. Second, we also hand 64k buffers to the guest even if
      the 2k buffers would fit better - and this results in dropped packets
      in the IP layer of the guest since too much skbuf memory is used.
      
      Though it seems at a first glance like PAPR says that we should store
      the receive buffer descriptors in the page that is supplied during
      the H_REGISTER_LOGICAL_LAN call, chapter 16.4.1.2 in the LoPAPR spec
      declares that "the contents of these descriptors are architecturally
      opaque, none of these descriptors are manipulated by code above
      the architected interfaces". That means we don't have to store
      the RX buffer descriptors in this page, but can also manage the
      receive buffers at the hypervisor level only. This is now what we
      are doing here: Introducing proper RX buffer pools which are also
      sorted by size of the buffers, so we can hand out a buffer with
      the best fitting size when a packet has been received.
      
      To avoid problems with migration from/to older version of QEMU,
      the old behavior is also retained and enabled by default. The new
      buffer management has to be enabled via a new "use-rx-buffer-pools"
      property.
      
      Now with the new buffer pool management enabled, the problem with
      "ping -s 65507" is fixed for me, and the throughput of a simple
      test with wget increases from creeping 3MB/s up to 20MB/s!
      Signed-off-by: NThomas Huth <thuth@redhat.com>
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      831e8822
    • T
      hw/net/spapr_llan: Extract rx buffer code into separate functions · d6f39fdf
      Thomas Huth 提交于
      Refactor the code a little bit by extracting the code that reads
      and writes the receive buffer list page into separate functions.
      There should be no functional change in this patch, this is just
      a preparation for the upcoming extensions that introduce receive
      buffer pools.
      Signed-off-by: NThomas Huth <thuth@redhat.com>
      Reviewed-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Reviewed-by: NLaurent Vivier <lvivier@redhat.com>
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      d6f39fdf
    • B
      ppc: Create cpu_ppc_set_papr() helper · 26a7f129
      Benjamin Herrenschmidt 提交于
      And move the code adjusting the MSR mask and calling kvmppc_set_papr()
      to it. This allows us to add a few more things such as disabling setting
      of MSR:HV and appropriate LPCR bits which will be used when fixing
      the exception model.
      Signed-off-by: NBenjamin Herrenschmidt <benh@kernel.crashing.org>
      Reviewed-by: NDavid Gibson <david@gibson.dropbear.id.au>
      [clg: removed LPCR setting ]
      Signed-off-by: NCédric Le Goater <clg@fr.ibm.com>
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      26a7f129
    • A
      spapr/target-ppc/kvm: Only add hcall-instructions if KVM supports it · 0ddbd053
      Alexey Kardashevskiy 提交于
      ePAPR defines "hcall-instructions" device-tree property which contains
      code to call hypercalls in ePAPR paravirtualized guests.  In general
      pseries guests won't use this property, instead using the PAPR defined
      hypercall interface.
      
      However, this property has been re-used to implement a hack to allow
      PR KVM to run (slightly modified) guests in some situations where it
      otherwise wouldn't be able to (because the system's L0 hypervisor
      doesn't forward the PAPR hypercalls to the PR KVM kernel).
      
      Hence, this property is always present in the device tree for pseries
      guests. All KVM guests use it at least to read features via the
      KVM_HC_FEATURES hypercall.
      
      The property is populated by the code returned from the KVM's
      KVM_PPC_GET_PVINFO ioctl; if not implemented in the KVM, QEMU supplies
      code which will fail all hypercall attempts. If QEMU does not create
      the property, and the guest kernel is compiled with
      CONFIG_EPAPR_PARAVIRT (which is normally the case), there is exactly
      the same stub at @epapr_hypercall_start already.
      
      Rather than maintaining this fairly useless stub implementation, it
      makes more sense not to create the property in the device tree in the
      first place if the host kernel does not implement it.
      
      This changes kvmppc_get_hypercall() to return 1 if the host kernel
      does not implement KVM_CAP_PPC_GET_PVINFO. The caller can use it to decide
      on whether to create the property or not.
      
      This changes the pseries machine to not create the property if KVM does
      not implement KVM_PPC_GET_PVINFO. In practice this means that from now
      on the property will not be created if either HV KVM or TCG is used.
      Signed-off-by: NAlexey Kardashevskiy <aik@ozlabs.ru>
      [reworded commit message for clarity --dwg]
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      0ddbd053
  2. 22 3月, 2016 29 次提交
    • M
      ivshmem: Require master to have ID zero · 62a830b6
      Markus Armbruster 提交于
      Migration with ivshmem needs to be carefully orchestrated to work.
      Exactly one peer (the "master") migrates to the destination, all other
      peers need to unplug (and disconnect), migrate, plug back (and
      reconnect).  This is sort of documented in qemu-doc.
      
      If peers connect on the destination before migration completes, the
      shared memory can get messed up.  This isn't documented anywhere.  Fix
      that in qemu-doc.
      
      To avoid messing up register IVPosition on migration, the server must
      assign the same ID on source and destination.  ivshmem-spec.txt leaves
      ID assignment unspecified, however.
      
      Amend ivshmem-spec.txt to require the first client to receive ID zero.
      The example ivshmem-server complies: it always assigns the first
      unused ID.
      
      For a bit of additional safety, enforce ID zero for the master.  This
      does nothing when we're not using a server, because the ID is zero for
      all peers then.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: NMarc-André Lureau <marcandre.lureau@redhat.com>
      Message-Id: <1458066895-20632-40-git-send-email-armbru@redhat.com>
      62a830b6
    • M
      ivshmem: Drop ivshmem property x-memdev · 13fd2cb6
      Markus Armbruster 提交于
      Use ivshmem-plain instead.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: NMarc-André Lureau <marcandre.lureau@redhat.com>
      Message-Id: <1458066895-20632-39-git-send-email-armbru@redhat.com>
      13fd2cb6
    • M
      ivshmem: Clean up after the previous commit · ddc85284
      Markus Armbruster 提交于
      Move code to more sensible places.  Use the opportunity to reorder and
      document IVShmemState members.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: NMarc-André Lureau <marcandre.lureau@redhat.com>
      Message-Id: <1458066895-20632-38-git-send-email-armbru@redhat.com>
      ddc85284
    • M
      ivshmem: Split ivshmem-plain, ivshmem-doorbell off ivshmem · 5400c02b
      Markus Armbruster 提交于
      ivshmem can be configured with and without interrupt capability
      (a.k.a. "doorbell").  The two configurations have largely disjoint
      options, which makes for a confusing (and badly checked) user
      interface.  Moreover, the device can't tell the guest whether its
      doorbell is enabled.
      
      Create two new device models ivshmem-plain and ivshmem-doorbell, and
      deprecate the old one.
      
      Changes from ivshmem:
      
      * PCI revision is 1 instead of 0.  The new revision is fully backwards
        compatible for guests.  Guests may elect to require at least
        revision 1 to make sure they're not exposed to the funny "no shared
        memory, yet" state.
      
      * Property "role" replaced by "master".  role=master becomes
        master=on, role=peer becomes master=off.  Default is off instead of
        auto.
      
      * Property "use64" is gone.  The new devices always have 64 bit BARs.
      
      Changes from ivshmem to ivshmem-plain:
      
      * The Interrupt Pin register in PCI config space is zero (does not use
        an interrupt pin) instead of one (uses INTA).
      
      * Property "x-memdev" is renamed to "memdev".
      
      * Properties "shm" and "size" are gone.  Use property "memdev"
        instead.
      
      * Property "msi" is gone.  The new device can't have MSI-X capability.
        It can't interrupt anyway.
      
      * Properties "ioeventfd" and "vectors" are gone.  They're meaningless
        without interrupts anyway.
      
      Changes from ivshmem to ivshmem-doorbell:
      
      * Property "msi" is gone.  The new device always has MSI-X capability.
      
      * Property "ioeventfd" defaults to on instead of off.
      
      * Property "size" is gone.  The new device can only map all the shared
        memory received from the server.
      
      Guests can easily find out whether the device is configured for
      interrupts by checking for MSI-X capability.
      
      Note: some code added in sub-optimal places to make the diff easier to
      review.  The next commit will move it to more sensible places.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: NMarc-André Lureau <marcandre.lureau@redhat.com>
      Message-Id: <1458066895-20632-37-git-send-email-armbru@redhat.com>
      5400c02b
    • M
      ivshmem: Replace int role_val by OnOffAuto master · 2a845da7
      Markus Armbruster 提交于
      In preparation of making it a qdev property.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: NMarc-André Lureau <marcandre.lureau@redhat.com>
      Message-Id: <1458066895-20632-36-git-send-email-armbru@redhat.com>
      2a845da7
    • M
      qdev: New DEFINE_PROP_ON_OFF_AUTO · 55e8a154
      Markus Armbruster 提交于
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: NMarc-André Lureau <marcandre.lureau@redhat.com>
      Message-Id: <1458066895-20632-35-git-send-email-armbru@redhat.com>
      55e8a154
    • M
      ivshmem: Inline check_shm_size() into its only caller · 8baeb22b
      Markus Armbruster 提交于
      Improve the error messages while there.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Message-Id: <1458066895-20632-34-git-send-email-armbru@redhat.com>
      Reviewed-by: NMarc-André Lureau <marcandre.lureau@redhat.com>
      8baeb22b
    • M
      ivshmem: Simplify memory regions for BAR 2 (shared memory) · c2d8019c
      Markus Armbruster 提交于
      ivshmem_realize() puts the shared memory region in a container region.
      Used to be necessary to permit delayed mapping of the shared memory.
      However, we recently moved to synchronous mapping, in "ivshmem:
      Receive shared memory synchronously in realize()" and the commit
      following it.  The container is redundant since then.  Drop it.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: NMarc-André Lureau <marcandre.lureau@redhat.com>
      Reviewed-by: NPaolo Bonzini <pbonzini@redhat.com>
      Message-Id: <1458066895-20632-33-git-send-email-armbru@redhat.com>
      c2d8019c
    • M
      ivshmem: Implement shm=... with a memory backend · 5503e285
      Markus Armbruster 提交于
      ivshmem has its very own code to create and map shared memory.
      Replace that with an implicitly created memory backend.  Reduces the
      number of ways we create BAR 2 from three to two.
      
      The memory-backend-file is currently available only with CONFIG_LINUX,
      so this adds a second Linuxism to ivshmem (the other one is eventfd).
      Should we ever need to make it portable to systems where
      memory-backend-file can't be made to serve, we could create a
      memory-backend-shmem that allocates memory with shm_open().
      
      Bonus fix: shared memory files are now created with permissions 0655
      instead of 0777.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: NPaolo Bonzini <pbonzini@redhat.com>
      Message-Id: <1458066895-20632-32-git-send-email-armbru@redhat.com>
      5503e285
    • M
      ivshmem: Tighten check of property "size" · 08183c20
      Markus Armbruster 提交于
      If size_t is narrower than 64 bits, passing uint64_t ivshmem_size to
      mmap() truncates.  Reject such sizes.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: NMarc-André Lureau <marcandre.lureau@redhat.com>
      Message-Id: <1458066895-20632-31-git-send-email-armbru@redhat.com>
      08183c20
    • M
      ivshmem: Simplify how we cope with short reads from server · ee276391
      Markus Armbruster 提交于
      Short reads from a UNIX domain sockets are exceedingly unlikely when
      the other side always sends eight bytes and we always read eight
      bytes.  We cope with them anyway.  However, the code doing that is
      rather convoluted.  Dumb it down radically.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: NMarc-André Lureau <marcandre.lureau@redhat.com>
      Message-Id: <1458066895-20632-30-git-send-email-armbru@redhat.com>
      ee276391
    • M
      ivshmem: Drop the hackish test for UNIX domain chardev · ba5970a1
      Markus Armbruster 提交于
      The chardev must be capable of transmitting SCM_RIGHTS ancillary
      messages.  We check it by comparing CharDriverState member filename to
      "unix:".  That's almost as brittle as it is disgusting.
      
      When the actual transmission all happened asynchronously, this check
      was all we could do in realize(), and thus better than nothing.  But
      now we receive at least one SCM_RIGHTS synchronously in realize(),
      it's not worth its keep anymore.  Drop it.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: NMarc-André Lureau <marcandre.lureau@redhat.com>
      Message-Id: <1458066895-20632-29-git-send-email-armbru@redhat.com>
      ba5970a1
    • M
      ivshmem: Rely on server sending the ID right after the version · a3feb086
      Markus Armbruster 提交于
      The protocol specification (ivshmem-spec.txt, formerly
      ivshmem_device_spec.txt) has always required the ID message to be sent
      right at the beginning, and ivshmem-server has always complied.  The
      device, however, accepts it out of order.  If an interrupt setup
      arrived before it, though, it would be misinterpreted as connect
      notification.  Fix the latent bug by relying on the spec and
      ivshmem-server's actual behavior.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: NMarc-André Lureau <marcandre.lureau@redhat.com>
      Message-Id: <1458066895-20632-28-git-send-email-armbru@redhat.com>
      a3feb086
    • M
      ivshmem: Propagate errors through ivshmem_recv_setup() · 1309cf44
      Markus Armbruster 提交于
      This kills off the funny state described in the previous commit.
      
      Simplify ivshmem_io_read() accordingly, and update documentation.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Message-Id: <1458066895-20632-27-git-send-email-armbru@redhat.com>
      Reviewed-by: NMarc-André Lureau <marcandre.lureau@redhat.com>
      1309cf44
    • M
      ivshmem: Receive shared memory synchronously in realize() · 3a55fc0f
      Markus Armbruster 提交于
      When configured for interrupts (property "chardev" given), we receive
      the shared memory from an ivshmem server.  We do so asynchronously
      after realize() completes, by setting up callbacks with
      qemu_chr_add_handlers().
      
      Keeping server I/O out of realize() that way avoids delays due to a
      slow server.  This is probably relevant only for hot plug.
      
      However, this funny "no shared memory, yet" state of the device also
      causes a raft of issues that are hard or impossible to work around:
      
      * The guest is exposed to this state: when we enter and leave it its
        shared memory contents is apruptly replaced, and device register
        IVPosition changes.
      
        This is a known issue.  We document that guests should not access
        the shared memory after device initialization until the IVPosition
        register becomes non-negative.
      
        For cold plug, the funny state is unlikely to be visible in
        practice, because we normally receive the shared memory long before
        the guest gets around to mess with the device.
      
        For hot plug, the timing is tighter, but the relative slowness of
        PCI device configuration has a good chance to hide the funny state.
      
        In either case, guests complying with the documented procedure are
        safe.
      
      * Migration becomes racy.
      
        If migration completes before the shared memory setup completes on
        the source, shared memory contents is silently lost.  Fortunately,
        migration is rather unlikely to win this race.
      
        If the shared memory's ramblock arrives at the destination before
        shared memory setup completes, migration fails.
      
        There is no known way for a management application to wait for
        shared memory setup to complete.
      
        All you can do is retry failed migration.  You can improve your
        chances by leaving more time between running the destination QEMU
        and the migrate command.
      
        To mitigate silent memory loss, you need to ensure the server
        initializes shared memory exactly the same on source and
        destination.
      
        These issues are entirely undocumented so far.
      
      I'd expect the server to be almost always fast enough to hide these
      issues.  But then rare catastrophic races are in a way the worst kind.
      
      This is way more trouble than I'm willing to take from any device.
      Kill the funny state by receiving shared memory synchronously in
      realize().  If your hot plug hangs, go kill your ivshmem server.
      
      For easier review, this commit only makes the receive synchronous, it
      doesn't add the necessary error propagation.  Without that, the funny
      state persists.  The next commit will do that, and kill it off for
      real.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: NMarc-André Lureau <marcandre.lureau@redhat.com>
      Message-Id: <1458066895-20632-26-git-send-email-armbru@redhat.com>
      3a55fc0f
    • M
      ivshmem: Plug leaks on unplug, fix peer disconnect · 9db51b4d
      Markus Armbruster 提交于
      close_peer_eventfds() cleans up three things: ioeventfd triggers if
      they exist, eventfds, and the array to store them.
      
      Commit 98609cd8 (v1.2.0) fixed it not to clean up ioeventfd triggers
      when they don't exist (property ioeventfd=off, which is the default).
      Unfortunately, the fix also made it skip cleanup of the eventfds and
      the array then.  This is a memory and file descriptor leak on unplug.
      
      Additionally, the reset of nb_eventfds is skipped.  Doesn't matter on
      unplug.  On peer disconnect, however, this permanently wedges the
      interrupt vectors used for that peer's ID.  The eventfds stay behind,
      but aren't connected to a peer anymore.  When the ID gets recycled for
      a new peer, the new peer's eventfds get assigned to vectors after the
      old ones.  Commonly, the device's number of vectors matches the
      server's, so the new ones get dropped with a "Too many eventfd
      received" message.  Interrupts either don't work (common case) or go
      to the wrong vector.
      
      Fix by narrowing the conditional to just the ioeventfd trigger
      cleanup.
      
      While there, move the "invalid" peer check to the only caller where it
      can actually happen, and tighten it to reject own ID.
      
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: NMarc-André Lureau <marcandre.lureau@redhat.com>
      Message-Id: <1458066895-20632-25-git-send-email-armbru@redhat.com>
      9db51b4d
    • M
      ivshmem: Disentangle ivshmem_read() · ca0b7566
      Markus Armbruster 提交于
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: NMarc-André Lureau <marcandre.lureau@redhat.com>
      Message-Id: <1458066895-20632-24-git-send-email-armbru@redhat.com>
      ca0b7566
    • M
      ivshmem: Simplify rejection of invalid peer ID from server · cd9953f7
      Markus Armbruster 提交于
      ivshmem_read() processes server messages.  These are 64 bit signed
      integers.  -1 is shared memory setup, 16 bit unsigned is a peer ID,
      anything else is invalid.
      
      ivshmem_read() rejects invalid negative messages right away, silently.
      
      Invalid positive messages get rejected only in resize_peers(), and
      ivshmem_read() then prints the rather cryptic message "failed to
      resize peers array".
      
      Extend the first check to cover all invalid messages, make it report
      "server sent invalid message", and drop the second check.
      
      Now resize_peers() can't fail anymore; simplify.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: NMarc-André Lureau <marcandre.lureau@redhat.com>
      Message-Id: <1458066895-20632-23-git-send-email-armbru@redhat.com>
      cd9953f7
    • M
      ivshmem: Assert interrupts are set up once · 3c27969b
      Markus Armbruster 提交于
      An interrupt is set up when the interrupt's file descriptor is
      received.  Each message applies to the next interrupt vector.
      Therefore, each vector cannot be set up more than once.
      
      ivshmem_add_kvm_msi_virq() half-heartedly tries not to rely on this by
      doing nothing then, but that's not going to recover from this error
      should it become possible in the future.  watch_vector_notifier()
      doesn't even try.
      
      Simply assert what is the case, so we get alerted if we ever screw it
      up.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: NMarc-André Lureau <marcandre.lureau@redhat.com>
      Message-Id: <1458066895-20632-22-git-send-email-armbru@redhat.com>
      3c27969b
    • M
      ivshmem: Leave INTx alone when using MSI-X · 2d1d422d
      Markus Armbruster 提交于
      The ivshmem device can either use MSI-X or legacy INTx for interrupts.
      
      With MSI-X enabled, peer interrupt events trigger an MSI as they
      should.  But software can still raise INTx via interrupt status and
      mask register in BAR 0.  This is explicitly prohibited by PCI Local
      Bus Specification Revision 3.0, section 6.8.3.3:
      
          While enabled for MSI or MSI-X operation, a function is prohibited
          from using its INTx# pin (if implemented) to request service (MSI,
          MSI-X, and INTx# are mutually exclusive).
      
      Fix the device model to leave INTx alone when using MSI-X.
      
      Document that we claim to use INTx in config space even when we don't.
      Unlike other devices, ivshmem does *not* use INTx when configured for
      MSI-X and MSI-X isn't enabled by software.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: NMarc-André Lureau <marcandre.lureau@redhat.com>
      Reviewed-by: NPaolo Bonzini <pbonzini@redhat.com>
      Message-Id: <1458066895-20632-21-git-send-email-armbru@redhat.com>
      2d1d422d
    • M
      ivshmem: Clean up MSI-X conditions · 082751e8
      Markus Armbruster 提交于
      There are three predicates related to MSI-X:
      
      * ivshmem_has_feature(s, IVSHMEM_MSI) is true unless the non-MSI-X
        variant of the device is selected with msi=off.
      
      * msix_present() is true when the device has the PCI capability MSI-X.
        It's initially false, and becomes true during successful realize of
        the MSI-X variant of the device.  Thus, it's the same as
        ivshmem_has_feature(s, IVSHMEM_MSI) for realized devices.
      
      * msix_enabled() is true when msix_present() is true and guest software
        has enabled MSI-X.
      
      Code that differs between the non-MSI-X and the MSI-X variant of the
      device needs to be guarded by ivshmem_has_feature(s, IVSHMEM_MSI) or
      by msix_present(), except the latter works only for realized devices.
      
      Code that depends on whether MSI-X is in use needs to be guarded with
      msix_enabled().
      
      Code review led me to two minor messes:
      
      * ivshmem_vector_notify() calls msix_notify() even when
        !msix_enabled(), unlike most other MSI-X-capable devices.  As far as
        I can tell, msix_notify() does nothing when !msix_enabled().  Add
        the guard anyway.
      
      * Most callers of ivshmem_use_msix() guard it with
        ivshmem_has_feature(s, IVSHMEM_MSI).  Not necessary, because
        ivshmem_use_msix() does nothing when !msix_present().  That's
        ivshmem's only use of msix_present(), though.  Guard it
        consistently, and drop the now redundant msix_present() check.
        While there, rename ivshmem_use_msix() to ivshmem_msix_vector_use().
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Message-Id: <1458066895-20632-20-git-send-email-armbru@redhat.com>
      Reviewed-by: NMarc-André Lureau <marcandre.lureau@redhat.com>
      082751e8
    • M
      ivshmem: Clean up register callbacks · 434ad76d
      Markus Armbruster 提交于
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: NMarc-André Lureau <marcandre.lureau@redhat.com>
      Message-Id: <1458066895-20632-19-git-send-email-armbru@redhat.com>
      434ad76d
    • M
      ivshmem: Failed realize() can leave migration blocker behind · d855e275
      Markus Armbruster 提交于
      If pci_ivshmem_realize() fails after it created its migration blocker,
      the blocker is left in place.  Fix that by creating it last.
      
      Likewise, if it fails after it called fifo8_create(), it leaks fifo
      memory.  Fix that the same way.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: NMarc-André Lureau <marcandre.lureau@redhat.com>
      Message-Id: <1458066895-20632-18-git-send-email-armbru@redhat.com>
      d855e275
    • M
      ivshmem: Fix harmless misuse of Error · 9cf70c52
      Markus Armbruster 提交于
      We reuse errp after passing it host_memory_backend_get_memory().  If
      both host_memory_backend_get_memory() and the reuse set an error, the
      reuse will fail the assertion in error_setv().  Fortunately,
      host_memory_backend_get_memory() can't fail.
      
      Pass it &error_abort to make our assumption explicit, and to get the
      assertion failure in the right place should it become invalid.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: NMarc-André Lureau <marcandre.lureau@redhat.com>
      Message-Id: <1458066895-20632-17-git-send-email-armbru@redhat.com>
      9cf70c52
    • M
      ivshmem: Don't destroy the chardev on version mismatch · 71c26581
      Markus Armbruster 提交于
      Yes, the chardev is commonly useless after we read a bad version from
      it, but destroying it is inappropriate anyway: the user created it, so
      the user should be able to hold on to it as long as he likes.  We
      don't destroy it on other errors.  Screwed up in commit 5105b1d8.
      
      Stop reading instead.
      
      Also note QEMU's behavior in ivshmem-spec.txt.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: NMarc-André Lureau <marcandre.lureau@redhat.com>
      Message-Id: <1458066895-20632-16-git-send-email-armbru@redhat.com>
      71c26581
    • M
      ivshmem: Drop ivshmem_event() stub · c20fc0c3
      Markus Armbruster 提交于
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: NMarc-André Lureau <marcandre.lureau@redhat.com>
      Message-Id: <1458066895-20632-15-git-send-email-armbru@redhat.com>
      c20fc0c3
    • M
      ivshmem: Clean up after commit 9940c323 · e64befe9
      Markus Armbruster 提交于
      IVShmemState member eventfd_chr is useless since commit 9940c323.  Drop
      it.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: NMarc-André Lureau <marcandre.lureau@redhat.com>
      Message-Id: <1458066895-20632-14-git-send-email-armbru@redhat.com>
      e64befe9
    • M
      ivshmem: Compile debug prints unconditionally to prevent bit-rot · a4fa93bf
      Markus Armbruster 提交于
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: NMarc-André Lureau <marcandre.lureau@redhat.com>
      Message-Id: <1458066895-20632-13-git-send-email-armbru@redhat.com>
      a4fa93bf
    • M
      ivshmem: Add missing newlines to debug printfs · 97553976
      Markus Armbruster 提交于
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: NMarc-André Lureau <marcandre.lureau@redhat.com>
      Message-Id: <1458066895-20632-12-git-send-email-armbru@redhat.com>
      97553976
  3. 18 3月, 2016 6 次提交