Sorry I cannot figure out a good use case.
It is normal for a host to have multiple ip addresses used for
communication.
So I thought it might be nice to have both host and guest use multiple
CIDs for communication.
I know this is not a very strong argument.
The vsock driver does not work if one of the two peers doesn't support
multiple CIDs.
I have a possible solution here, but there may be some problems with it
that I haven't noticed.
Hypervisors will use different ways to send CIDs setup to the kernel based
on their vsock setup.
------For host-------
If host vsock driver supports multi-cid, the hypervisor will use the
modified VHOST_VSOCK_SET_GUEST_CID call to set its CIDs.
Otherwise, the original call is used.
------For guest-------
Now the virtio_vsock_config looks like this:
u64 guest_cid
u32 num_guest_cid;
u32 num_host_cid;
u32 index;
u64 cid;
If the guest vsock driver supports multi-cid, it will read num_guest_cid
and num_host_cid from the device config space.
Then it writes an index register, which is the cid it wants to read. After
hypervisors handle this issue, it can read the cid
from the cid register.
If it does not support multi-cid, it will just read the guest_cid from the
config space, which should work just fine.
-------Communication--------
For communication issues, we might need to use a new feature bit. Let's
call it VHOST_VSOCK_SUPPORT_MULTI_CID.
The basic idea is that this feature bit is set when both host and guest
support using multiple CIDs. After negotiation, if the feature bit
is set, the host can use all the CIDs specified to communicate with the
guest. Otherwise, the first cid passed in will
be used as the guest_cid to communicate with guests.
Also, if the bit is set for guests, all the CIDs can be used to communicate
with the host. Otherwise, the first cid with index 0 will be
used as the guest_cid while the VMADDR_HOST_CID will be used for host cid.