Skip to content

Commit

Permalink
Adjustments to match spec changes regarding the "twin_socket.supporte…
Browse files Browse the repository at this point in the history
…d" field.
  • Loading branch information
mnissler-rivos committed Sep 7, 2023
1 parent beb8d78 commit 4d56e0b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
10 changes: 7 additions & 3 deletions lib/tran.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
* "pgsize": 4096
* },
* "twin_socket": {
* "enable": true,
* "supported": true,
* "fd_index": 0
* }
* }
Expand Down Expand Up @@ -143,7 +143,7 @@ tran_parse_version_json(const char *json_str, int *client_max_fdsp,
goto out;
}

if (json_object_object_get_ex(jo, "enable", &jo2)) {
if (json_object_object_get_ex(jo, "supported", &jo2)) {
if (json_object_get_type(jo2) != json_type_boolean) {
goto out;
}
Expand Down Expand Up @@ -376,11 +376,15 @@ format_server_capabilities(vfu_ctx_t *vfu_ctx, int twin_socket_fd_index)
}

if (twin_socket_fd_index >= 0) {
struct json_object *jo_supported = NULL;

if ((jo_twin_socket = json_object_new_object()) == NULL) {
goto out;
}

if (json_add_uint64(jo_twin_socket, "fd_index",
if ((jo_supported = json_object_new_boolean(true)) == NULL ||
json_add(jo_twin_socket, "supported", &jo_supported) < 0 ||
json_add_uint64(jo_twin_socket, "fd_index",
twin_socket_fd_index) < 0) {
goto out;
}
Expand Down
3 changes: 2 additions & 1 deletion test/py/libvfio_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -740,7 +740,8 @@ def update(target, overrides):

server_caps = json.loads(payload[struct.calcsize("HH"):-1].decode())
try:
if client_caps["capabilities"]["twin_socket"]["enable"]:
if (client_caps["capabilities"]["twin_socket"]["supported"] and
server_caps["capabilities"]["twin_socket"]["supported"]):
index = server_caps["capabilities"]["twin_socket"]["fd_index"]
self.client_cmd_socket = socket.socket(fileno=fds[index])
except KeyError:
Expand Down
2 changes: 1 addition & 1 deletion test/py/test_sgl_read_write.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def setup_function(function):
"capabilities": {
"max_data_xfer_size": PAGE_SIZE,
"twin_socket": {
"enable": True,
"supported": True,
},
}
}
Expand Down

0 comments on commit 4d56e0b

Please sign in to comment.