Re: [PATCH 0/4] Add multi-cid support for vsock driver

From: Stefano Garzarella
Date: Mon Aug 02 2021 - 09:43:06 EST


On Mon, Aug 02, 2021 at 08:07:16PM +0800, fuguancheng wrote:
This patchset enables the user to specify additional CIDS for host and
guest when booting up the guest machine. The guest's additional CIDS cannot
be repeated, and can be used to communicate with the host. The user can
also choose to specify a set of additional host cids, which can be
used to communicate with the guest who specify them. The original
CID(VHOST_DEFAULT_CID) is still available for host. The guest cid field is
deleted.

To ensure that multiple guest CID maps to the same vhost_vsock struct,
a struct called vhost_vsock_ref is added. The function of vhost_vsock_ref
is simply used to allow multiple guest CIDS map to the
same vhost_vsock struct.

If not specified, the host and guest will now use the first CID specified
in the array for connect operation. If the host or guest wants to use
one specific CID, the bind operation can be performed before the connect
operation so that the vsock_auto_bind operation can be avoided.

Hypervisors such as qemu needs to be modified to use this feature. The
required changes including at least the following:
1. Invoke the modified ioctl call with the request code
VHOST_VSOCK_SET_GUEST_CID. Also see struct multi_cid_message for
arguments used in this ioctl call.
2. Write new arguments to the emulated device config space.
3. Modify the layout of the data written to the device config space.
See struct virtio_vsock_config for reference.

Can you please describe a use case?

vsock was created to be zero configuration, we're complicating enough here, we should have a particular reason.

Also I gave a quick view and it seems to me that you change virtio_vsock_config, are you sure it works if one of the two peers doesn't support multiple CIDs?

Maybe we'd need a new feature bit, and we'd definitely need to discuss specification changes with virtio-comment@xxxxxxxxxxxxxxxxxxxx first.

How does the guest or host applications know which CIDs are assigned to them?

Please use the RFC tag if the patches are not in good shape.
Patches seem hard to review, please avoid adding code that is removed later (e.g. multi_cid_message), and try not to break the backward compatibility.

Thanks,
Stefano