Commit 8f0da01d authored by Peter Maydell's avatar Peter Maydell
Browse files

Merge remote-tracking branch 'remotes/mst/tags/for_upstream' into staging



virtio, vhost: fixes for 2.5

This fixes a performance regression with virtio 1,
and makes device stop/start more robust for vhost-user.
virtio devices on pcie bus now have pcie and pm
capability, as required by the PCI Express spec.
migration now works better with virtio 9p.

Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>

# gpg: Signature made Thu 12 Nov 2015 14:40:42 GMT using RSA key ID D28D5469
# gpg: Good signature from "Michael S. Tsirkin <mst@kernel.org>"
# gpg:                 aka "Michael S. Tsirkin <mst@redhat.com>"

* remotes/mst/tags/for_upstream:
  virtio-9p: add savem handlers
  hw/virtio: Add PCIe capability to virtio devices
  vhost: send SET_VRING_ENABLE at start/stop
  vhost: rename RESET_DEVICE backto RESET_OWNER
  vhost-user: modify SET_LOG_BASE to pass mmap size and offset
  virtio-pci: unbreak queue_enable read
  virtio-pci: introduce pio notification capability for modern device
  virtio-pci: use zero length mmio eventfd for 1.0 notification cap when possible
  KVM: add support for any length io eventfd
  memory: don't try to adjust endianness for zero length eventfd
  virtio-pci: fix 1.0 virtqueue migration

Conflicts:
	include/hw/compat.h
[Fixed a trivial merge conflict in compat.h]
Signed-off-by: default avatarPeter Maydell <peter.maydell@linaro.org>
parents 17e50a72 4652f164
Loading
Loading
Loading
Loading
+9 −3
Original line number Diff line number Diff line
@@ -98,6 +98,7 @@ typedef struct VhostUserMsg {
        struct vhost_vring_state state;
        struct vhost_vring_addr addr;
        VhostUserMemory memory;
        VhostUserLog log;
    };
} QEMU_PACKED VhostUserMsg;

@@ -255,10 +256,10 @@ Message types
      as an owner of the session. This can be used on the Slave as a
      "session start" flag.

 * VHOST_USER_RESET_DEVICE
 * VHOST_USER_RESET_OWNER

      Id: 4
      Equivalent ioctl: VHOST_RESET_DEVICE
      Equivalent ioctl: VHOST_RESET_OWNER
      Master payload: N/A

      Issued when a new connection is about to be closed. The Master will no
@@ -282,7 +283,12 @@ Message types
      Master payload: u64
      Slave payload: N/A

      Sets the logging base address.
      Sets logging shared memory space.
      When slave has VHOST_USER_PROTOCOL_F_LOG_SHMFD protocol
      feature, the log memory fd is provided in the ancillary data of
      VHOST_USER_SET_LOG_BASE message, the size and offset of shared
      memory area provided in the message.


 * VHOST_USER_SET_LOG_FD

+11 −0
Original line number Diff line number Diff line
@@ -43,6 +43,16 @@ static void virtio_9p_get_config(VirtIODevice *vdev, uint8_t *config)
    g_free(cfg);
}

static void virtio_9p_save(QEMUFile *f, void *opaque)
{
    virtio_save(VIRTIO_DEVICE(opaque), f);
}

static int virtio_9p_load(QEMUFile *f, void *opaque, int version_id)
{
    return virtio_load(VIRTIO_DEVICE(opaque), f, version_id);
}

static void virtio_9p_device_realize(DeviceState *dev, Error **errp)
{
    VirtIODevice *vdev = VIRTIO_DEVICE(dev);
@@ -130,6 +140,7 @@ static void virtio_9p_device_realize(DeviceState *dev, Error **errp)
    }
    v9fs_path_free(&path);

    register_savevm(dev, "virtio-9p", -1, 1, virtio_9p_save, virtio_9p_load, s);
    return;
out:
    g_free(s->ctx.fs_root);
+1 −1
Original line number Diff line number Diff line
@@ -156,7 +156,7 @@ static int vhost_kernel_set_owner(struct vhost_dev *dev)

static int vhost_kernel_reset_device(struct vhost_dev *dev)
{
    return vhost_kernel_call(dev, VHOST_RESET_DEVICE, NULL);
    return vhost_kernel_call(dev, VHOST_RESET_OWNER, NULL);
}

static int vhost_kernel_get_vq_index(struct vhost_dev *dev, int idx)
+12 −5
Original line number Diff line number Diff line
@@ -43,7 +43,7 @@ typedef enum VhostUserRequest {
    VHOST_USER_GET_FEATURES = 1,
    VHOST_USER_SET_FEATURES = 2,
    VHOST_USER_SET_OWNER = 3,
    VHOST_USER_RESET_DEVICE = 4,
    VHOST_USER_RESET_OWNER = 4,
    VHOST_USER_SET_MEM_TABLE = 5,
    VHOST_USER_SET_LOG_BASE = 6,
    VHOST_USER_SET_LOG_FD = 7,
@@ -75,6 +75,11 @@ typedef struct VhostUserMemory {
    VhostUserMemoryRegion regions[VHOST_MEMORY_MAX_NREGIONS];
} VhostUserMemory;

typedef struct VhostUserLog {
    uint64_t mmap_size;
    uint64_t mmap_offset;
} VhostUserLog;

typedef struct VhostUserMsg {
    VhostUserRequest request;

@@ -89,6 +94,7 @@ typedef struct VhostUserMsg {
        struct vhost_vring_state state;
        struct vhost_vring_addr addr;
        VhostUserMemory memory;
        VhostUserLog log;
    } payload;
} QEMU_PACKED VhostUserMsg;

@@ -157,7 +163,7 @@ static bool vhost_user_one_time_request(VhostUserRequest request)
{
    switch (request) {
    case VHOST_USER_SET_OWNER:
    case VHOST_USER_RESET_DEVICE:
    case VHOST_USER_RESET_OWNER:
    case VHOST_USER_SET_MEM_TABLE:
    case VHOST_USER_GET_QUEUE_NUM:
        return true;
@@ -200,8 +206,9 @@ static int vhost_user_set_log_base(struct vhost_dev *dev, uint64_t base,
    VhostUserMsg msg = {
        .request = VHOST_USER_SET_LOG_BASE,
        .flags = VHOST_USER_VERSION,
        .payload.u64 = base,
        .size = sizeof(msg.payload.u64),
        .payload.log.mmap_size = log->size,
        .payload.log.mmap_offset = 0,
        .size = sizeof(msg.payload.log),
    };

    if (shmfd && log->fd != -1) {
@@ -486,7 +493,7 @@ static int vhost_user_set_owner(struct vhost_dev *dev)
static int vhost_user_reset_device(struct vhost_dev *dev)
{
    VhostUserMsg msg = {
        .request = VHOST_USER_RESET_DEVICE,
        .request = VHOST_USER_RESET_OWNER,
        .flags = VHOST_USER_VERSION,
    };

+9 −0
Original line number Diff line number Diff line
@@ -1226,6 +1226,11 @@ int vhost_dev_start(struct vhost_dev *hdev, VirtIODevice *vdev)
        }
    }

    if (hdev->vhost_ops->vhost_set_vring_enable) {
        /* only enable first vq pair by default */
        hdev->vhost_ops->vhost_set_vring_enable(hdev, hdev->vq_index == 0);
    }

    return 0;
fail_log:
    vhost_log_put(hdev, false);
@@ -1256,6 +1261,10 @@ void vhost_dev_stop(struct vhost_dev *hdev, VirtIODevice *vdev)
                             hdev->vq_index + i);
    }

    if (hdev->vhost_ops->vhost_set_vring_enable) {
        hdev->vhost_ops->vhost_set_vring_enable(hdev, 0);
    }

    vhost_log_put(hdev, true);
    hdev->started = false;
    hdev->log = NULL;
Loading