ACRN: DM: Fix the vsock Guest Cid overflow issue

The vsock cid type is u64, redefine the cid type to u64, and use
dm_strtoul API replace dm_strtoi.

Tracked-On: #7456
Signed-off-by: Liu Long <long.liu@linux.intel.com>
This commit is contained in:
Liu Long 2022-05-31 09:38:09 +08:00 committed by acrnsi-robot
parent 8331375172
commit 5f06a2f58e
2 changed files with 4 additions and 3 deletions

View File

@ -238,7 +238,8 @@ static int
virtio_vhost_vsock_init(struct vmctx *ctx, struct pci_vdev *dev, char *opts) virtio_vhost_vsock_init(struct vmctx *ctx, struct pci_vdev *dev, char *opts)
{ {
struct virtio_vsock *vsock; struct virtio_vsock *vsock;
int rc, cid; int rc;
uint64_t cid;
pthread_mutexattr_t attr; pthread_mutexattr_t attr;
char *devopts = NULL; char *devopts = NULL;
char *tmp = NULL; char *tmp = NULL;
@ -254,7 +255,7 @@ virtio_vhost_vsock_init(struct vmctx *ctx, struct pci_vdev *dev, char *opts)
} }
if (!strncmp(tmp, "cid=", 4)) { if (!strncmp(tmp, "cid=", 4)) {
strsep(&tmp, "="); strsep(&tmp, "=");
dm_strtoi(tmp, NULL, 10, &cid); dm_strtoul(tmp, NULL, 10, &cid);
} }
free(devopts); free(devopts);

View File

@ -29,7 +29,7 @@
(1ULL << VIRTIO_RING_F_EVENT_IDX) | (1ULL << VHOST_F_LOG_ALL) | \ (1ULL << VIRTIO_RING_F_EVENT_IDX) | (1ULL << VHOST_F_LOG_ALL) | \
(1ULL << VIRTIO_F_ANY_LAYOUT) | (1ULL << VIRTIO_F_VERSION_1) (1ULL << VIRTIO_F_ANY_LAYOUT) | (1ULL << VIRTIO_F_VERSION_1)
#define U32_MAX 65535 #define U32_MAX ((uint32_t)~0U)
#define VMADDR_CID_HOST 2 #define VMADDR_CID_HOST 2
struct virtio_vsock_config { struct virtio_vsock_config {