[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PULL 28/53] vdpa: move CVQ isolation check to net_init_vhost_vdpa
From: |
Peter Maydell |
Subject: |
Re: [PULL 28/53] vdpa: move CVQ isolation check to net_init_vhost_vdpa |
Date: |
Tue, 27 Jun 2023 12:30:01 +0100 |
On Mon, 26 Jun 2023 at 13:29, Michael S. Tsirkin <mst@redhat.com> wrote:
>
> From: Eugenio PĂ©rez <eperezma@redhat.com>
>
> Evaluating it at start time instead of initialization time may make the
> guest capable of dynamically adding or removing migration blockers.
>
> Also, moving to initialization reduces the number of ioctls in the
> migration, reducing failure possibilities.
>
> As a drawback we need to check for CVQ isolation twice: one time with no
> MQ negotiated and another one acking it, as long as the device supports
> it. This is because Vring ASID / group management is based on vq
> indexes, but we don't know the index of CVQ before negotiating MQ.
I was looking at this code because of a Coverity report.
That turned out to be a false positive, but I did notice
something here that looks like it might be wrong:
>
> +/**
> + * Probe if CVQ is isolated
> + *
> + * @device_fd The vdpa device fd
> + * @features Features offered by the device.
> + * @cvq_index The control vq pair index
> + *
> + * Returns <0 in case of failure, 0 if false and 1 if true.
> + */
> +static int vhost_vdpa_probe_cvq_isolation(int device_fd, uint64_t features,
> + int cvq_index, Error **errp)
> +{
> + uint64_t backend_features;
> + int64_t cvq_group;
> + uint8_t status = VIRTIO_CONFIG_S_ACKNOWLEDGE |
> + VIRTIO_CONFIG_S_DRIVER |
> + VIRTIO_CONFIG_S_FEATURES_OK;
> + int r;
> +
> + ERRP_GUARD();
> +
> + r = ioctl(device_fd, VHOST_GET_BACKEND_FEATURES, &backend_features);
> + if (unlikely(r < 0)) {
> + error_setg_errno(errp, errno, "Cannot get vdpa backend_features");
> + return r;
> + }
> +
> + if (!(backend_features & BIT_ULL(VHOST_BACKEND_F_IOTLB_ASID))) {
> + return 0;
> + }
> +
> + r = ioctl(device_fd, VHOST_SET_FEATURES, &features);
> + if (unlikely(r)) {
> + error_setg_errno(errp, errno, "Cannot set features");
Shouldn't we have a 'return r' (or maybe a 'goto out') here ?
Otherwise we'll just plough onward and attempt to continue
execution...
> + }
> +
> + r = ioctl(device_fd, VHOST_VDPA_SET_STATUS, &status);
> + if (unlikely(r)) {
> + error_setg_errno(errp, -r, "Cannot set device features");
Isn't this trying to set device status, not features ?
> + goto out;
> + }
thanks
-- PMM
- [PULL 27/53] vdpa: return errno in vhost_vdpa_get_vring_group error, (continued)
- [PULL 27/53] vdpa: return errno in vhost_vdpa_get_vring_group error, Michael S. Tsirkin, 2023/06/26
- [PULL 30/53] hw/acpi: Fix PM control register access, Michael S. Tsirkin, 2023/06/26
- [PULL 38/53] vdpa: reuse virtio_vdev_has_feature(), Michael S. Tsirkin, 2023/06/26
- [PULL 20/53] hw/virtio/virtio-iommu: Use target-agnostic qemu_target_page_mask(), Michael S. Tsirkin, 2023/06/26
- [PULL 37/53] include/hw/virtio: make some VirtIODevice const, Michael S. Tsirkin, 2023/06/26
- [PULL 21/53] hw/virtio: Remove unnecessary 'virtio-access.h' header, Michael S. Tsirkin, 2023/06/26
- [PULL 26/53] virtio-mem: Simplify bitmap handling and virtio_mem_set_block_state(), Michael S. Tsirkin, 2023/06/26
- [PULL 28/53] vdpa: move CVQ isolation check to net_init_vhost_vdpa, Michael S. Tsirkin, 2023/06/26
- Re: [PULL 28/53] vdpa: move CVQ isolation check to net_init_vhost_vdpa,
Peter Maydell <=
- [PULL 29/53] cryptodev: fix memory leak during stats query, Michael S. Tsirkin, 2023/06/26
- [PULL 31/53] hw/i386/pc: Default to use SMBIOS 3.0 for newer machine models, Michael S. Tsirkin, 2023/06/26
- [PULL 17/53] hw/virtio: Introduce VHOST_VSOCK_COMMON symbol in Kconfig, Michael S. Tsirkin, 2023/06/26
- [PULL 19/53] hw/virtio/vhost-vsock: Include missing 'virtio/virtio-bus.h' header, Michael S. Tsirkin, 2023/06/26
- [PULL 33/53] pc: q35: Bump max_cpus to 1024, Michael S. Tsirkin, 2023/06/26
- [PULL 41/53] vdpa: Add vhost_vdpa_net_load_offloads(), Michael S. Tsirkin, 2023/06/26
- [PULL 42/53] vdpa: Allow VIRTIO_NET_F_CTRL_GUEST_OFFLOADS in SVQ, Michael S. Tsirkin, 2023/06/26
- [PULL 48/53] vhost-user: fully use new backend/frontend naming, Michael S. Tsirkin, 2023/06/26
- [PULL 51/53] intel_iommu: Fix address space unmap, Michael S. Tsirkin, 2023/06/26
- [PULL 34/53] vdpa: do not block migration if device has cvq and x-svq=on, Michael S. Tsirkin, 2023/06/26