Lines Matching refs:msg

275 static int vhost_user_read_header(struct vhost_dev *dev, VhostUserMsg *msg)  in vhost_user_read_header()  argument
279 uint8_t *p = (uint8_t *) msg; in vhost_user_read_header()
286 " Original request %d.", r, size, msg->hdr.request); in vhost_user_read_header()
291 if (msg->hdr.flags != (VHOST_USER_REPLY_MASK | VHOST_USER_VERSION)) { in vhost_user_read_header()
293 " Flags 0x%x instead of 0x%x.", msg->hdr.flags, in vhost_user_read_header()
298 trace_vhost_user_read(msg->hdr.request, msg->hdr.flags); in vhost_user_read_header()
303 static int vhost_user_read(struct vhost_dev *dev, VhostUserMsg *msg) in vhost_user_read() argument
307 uint8_t *p = (uint8_t *) msg; in vhost_user_read()
310 r = vhost_user_read_header(dev, msg); in vhost_user_read()
316 if (msg->hdr.size > VHOST_USER_PAYLOAD_SIZE) { in vhost_user_read()
318 " Size %d exceeds the maximum %zu.", msg->hdr.size, in vhost_user_read()
323 if (msg->hdr.size) { in vhost_user_read()
325 size = msg->hdr.size; in vhost_user_read()
330 " Read %d instead of %d.", r, msg->hdr.size); in vhost_user_read()
339 const VhostUserMsg *msg) in process_message_reply() argument
344 if ((msg->hdr.flags & VHOST_USER_NEED_REPLY_MASK) == 0) { in process_message_reply()
353 if (msg_reply.hdr.request != msg->hdr.request) { in process_message_reply()
356 msg->hdr.request, msg_reply.hdr.request); in process_message_reply()
382 static int vhost_user_write(struct vhost_dev *dev, VhostUserMsg *msg, in vhost_user_write() argument
387 int ret, size = VHOST_USER_HDR_SIZE + msg->hdr.size; in vhost_user_write()
399 if (vhost_user_per_device_request(msg->hdr.request) in vhost_user_write()
401 msg->hdr.flags &= ~VHOST_USER_NEED_REPLY_MASK; in vhost_user_write()
410 ret = qemu_chr_fe_write_all(chr, (const uint8_t *) msg, size); in vhost_user_write()
418 trace_vhost_user_write(msg->hdr.request, msg->hdr.flags); in vhost_user_write()
425 VhostUserMsg msg = { in vhost_user_gpu_set_socket() local
430 return vhost_user_write(dev, &msg, &fd, 1); in vhost_user_gpu_set_socket()
441 VhostUserMsg msg = { in vhost_user_set_log_base() local
446 .hdr.size = sizeof(msg.payload.log), in vhost_user_set_log_base()
458 ret = vhost_user_write(dev, &msg, fds, fd_num); in vhost_user_set_log_base()
464 msg.hdr.size = 0; in vhost_user_set_log_base()
465 ret = vhost_user_read(dev, &msg); in vhost_user_set_log_base()
470 if (msg.hdr.request != VHOST_USER_SET_LOG_BASE) { in vhost_user_set_log_base()
473 VHOST_USER_SET_LOG_BASE, msg.hdr.request); in vhost_user_set_log_base()
507 VhostUserMsg *msg, in vhost_user_fill_set_mem_table_msg() argument
517 msg->hdr.request = VHOST_USER_SET_MEM_TABLE; in vhost_user_fill_set_mem_table_msg()
538 msg->payload.memory.regions[*fd_num] = region_buffer; in vhost_user_fill_set_mem_table_msg()
546 msg->payload.memory.nregions = *fd_num; in vhost_user_fill_set_mem_table_msg()
554 msg->hdr.size = sizeof(msg->payload.memory.nregions); in vhost_user_fill_set_mem_table_msg()
555 msg->hdr.size += sizeof(msg->payload.memory.padding); in vhost_user_fill_set_mem_table_msg()
556 msg->hdr.size += *fd_num * sizeof(VhostUserMemoryRegion); in vhost_user_fill_set_mem_table_msg()
663 int nr_rem_reg, VhostUserMsg *msg, in send_remove_regions() argument
684 msg->hdr.request = VHOST_USER_REM_MEM_REG; in send_remove_regions()
686 msg->payload.mem_reg.region = region_buffer; in send_remove_regions()
688 ret = vhost_user_write(dev, msg, NULL, 0); in send_remove_regions()
694 ret = process_message_reply(dev, msg); in send_remove_regions()
717 VhostUserMsg *msg, uint64_t *shadow_pcb, in send_add_regions() argument
745 msg->hdr.request = VHOST_USER_ADD_MEM_REG; in send_add_regions()
747 msg->payload.mem_reg.region = region_buffer; in send_add_regions()
749 ret = vhost_user_write(dev, msg, &fd, 1); in send_add_regions()
776 if (msg_reply.hdr.size != msg->hdr.size) { in send_add_regions()
779 msg->hdr.size); in send_add_regions()
789 msg->payload.mem_reg.region.userspace_addr, in send_add_regions()
799 ret = process_message_reply(dev, msg); in send_add_regions()
828 VhostUserMsg *msg, in vhost_user_add_remove_regions() argument
839 msg->hdr.size = sizeof(msg->payload.mem_reg); in vhost_user_add_remove_regions()
846 ret = send_remove_regions(dev, rem_reg, nr_rem_reg, msg, in vhost_user_add_remove_regions()
854 ret = send_add_regions(dev, add_reg, nr_add_reg, msg, shadow_pcb, in vhost_user_add_remove_regions()
870 msg->hdr.size = sizeof(msg->payload.u64); in vhost_user_add_remove_regions()
871 msg->payload.u64 = 0; /* OK */ in vhost_user_add_remove_regions()
873 ret = vhost_user_write(dev, msg, NULL, 0); in vhost_user_add_remove_regions()
902 VhostUserMsg msg = { in vhost_user_set_mem_table_postcopy() local
918 ret = vhost_user_add_remove_regions(dev, &msg, reply_supported, true); in vhost_user_set_mem_table_postcopy()
923 ret = vhost_user_fill_set_mem_table_msg(u, dev, &msg, fds, &fd_num, in vhost_user_set_mem_table_postcopy()
929 ret = vhost_user_write(dev, &msg, fds, fd_num); in vhost_user_set_mem_table_postcopy()
950 if (msg_reply.hdr.size != msg.hdr.size) { in vhost_user_set_mem_table_postcopy()
953 msg.hdr.size); in vhost_user_set_mem_table_postcopy()
975 msg.payload.memory.regions[msg_i].userspace_addr, in vhost_user_set_mem_table_postcopy()
993 msg.hdr.size = sizeof(msg.payload.u64); in vhost_user_set_mem_table_postcopy()
994 msg.payload.u64 = 0; /* OK */ in vhost_user_set_mem_table_postcopy()
995 ret = vhost_user_write(dev, &msg, NULL, 0); in vhost_user_set_mem_table_postcopy()
1027 VhostUserMsg msg = { in vhost_user_set_mem_table() local
1032 msg.hdr.flags |= VHOST_USER_NEED_REPLY_MASK; in vhost_user_set_mem_table()
1036 ret = vhost_user_add_remove_regions(dev, &msg, reply_supported, false); in vhost_user_set_mem_table()
1041 ret = vhost_user_fill_set_mem_table_msg(u, dev, &msg, fds, &fd_num, in vhost_user_set_mem_table()
1047 ret = vhost_user_write(dev, &msg, fds, fd_num); in vhost_user_set_mem_table()
1053 return process_message_reply(dev, &msg); in vhost_user_set_mem_table()
1065 VhostUserMsg msg = { in vhost_user_set_vring_endian() local
1069 .hdr.size = sizeof(msg.payload.state), in vhost_user_set_vring_endian()
1077 return vhost_user_write(dev, &msg, NULL, 0); in vhost_user_set_vring_endian()
1083 VhostUserMsg msg = { in vhost_user_get_u64() local
1092 ret = vhost_user_write(dev, &msg, NULL, 0); in vhost_user_get_u64()
1097 ret = vhost_user_read(dev, &msg); in vhost_user_get_u64()
1102 if (msg.hdr.request != request) { in vhost_user_get_u64()
1104 request, msg.hdr.request); in vhost_user_get_u64()
1108 if (msg.hdr.size != sizeof(msg.payload.u64)) { in vhost_user_get_u64()
1113 *u64 = msg.payload.u64; in vhost_user_get_u64()
1128 static int vhost_user_write_sync(struct vhost_dev *dev, VhostUserMsg *msg, in vhost_user_write_sync() argument
1137 msg->hdr.flags |= VHOST_USER_NEED_REPLY_MASK; in vhost_user_write_sync()
1141 ret = vhost_user_write(dev, msg, NULL, 0); in vhost_user_write_sync()
1149 if (msg->hdr.flags & VHOST_USER_NEED_REPLY_MASK) { in vhost_user_write_sync()
1150 return process_message_reply(dev, msg); in vhost_user_write_sync()
1170 VhostUserMsg msg = { in vhost_set_vring() local
1174 .hdr.size = sizeof(msg.payload.state), in vhost_set_vring()
1177 return vhost_user_write_sync(dev, &msg, wait_for_reply); in vhost_set_vring()
1273 VhostUserMsg msg = { in vhost_user_get_vring_base() local
1277 .hdr.size = sizeof(msg.payload.state), in vhost_user_get_vring_base()
1286 ret = vhost_user_write(dev, &msg, NULL, 0); in vhost_user_get_vring_base()
1291 ret = vhost_user_read(dev, &msg); in vhost_user_get_vring_base()
1296 if (msg.hdr.request != VHOST_USER_GET_VRING_BASE) { in vhost_user_get_vring_base()
1298 VHOST_USER_GET_VRING_BASE, msg.hdr.request); in vhost_user_get_vring_base()
1302 if (msg.hdr.size != sizeof(msg.payload.state)) { in vhost_user_get_vring_base()
1307 *ring = msg.payload.state; in vhost_user_get_vring_base()
1318 VhostUserMsg msg = { in vhost_set_vring_file() local
1322 .hdr.size = sizeof(msg.payload.u64), in vhost_set_vring_file()
1328 msg.payload.u64 |= VHOST_USER_VRING_NOFD_MASK; in vhost_set_vring_file()
1331 return vhost_user_write(dev, &msg, fds, fd_num); in vhost_set_vring_file()
1355 VhostUserMsg msg = { in vhost_user_set_vring_addr() local
1359 .hdr.size = sizeof(msg.payload.addr), in vhost_user_set_vring_addr()
1368 return vhost_user_write_sync(dev, &msg, wait_for_reply); in vhost_user_set_vring_addr()
1374 VhostUserMsg msg = { in vhost_user_set_u64() local
1378 .hdr.size = sizeof(msg.payload.u64), in vhost_user_set_u64()
1381 return vhost_user_write_sync(dev, &msg, wait_for_reply); in vhost_user_set_u64()
1460 VhostUserMsg msg = { in vhost_user_set_owner() local
1465 return vhost_user_write(dev, &msg, NULL, 0); in vhost_user_set_owner()
1487 VhostUserMsg msg = { in vhost_user_reset_device() local
1501 return vhost_user_write(dev, &msg, NULL, 0); in vhost_user_reset_device()
1666 VhostUserMsg msg = { in vhost_user_get_shared_object() local
1670 memcpy(msg.payload.object.uuid, uuid, sizeof(msg.payload.object.uuid)); in vhost_user_get_shared_object()
1672 ret = vhost_user_write(dev, &msg, NULL, 0); in vhost_user_get_shared_object()
1677 ret = vhost_user_read(dev, &msg); in vhost_user_get_shared_object()
1682 if (msg.hdr.request != VHOST_USER_GET_SHARED_OBJECT) { in vhost_user_get_shared_object()
1685 VHOST_USER_GET_SHARED_OBJECT, msg.hdr.request); in vhost_user_get_shared_object()
1856 VhostUserMsg msg = { in vhost_setup_backend_channel() local
1889 msg.hdr.flags |= VHOST_USER_NEED_REPLY_MASK; in vhost_setup_backend_channel()
1892 ret = vhost_user_write(dev, &msg, &sv[1], 1); in vhost_setup_backend_channel()
1898 ret = process_message_reply(dev, &msg); in vhost_setup_backend_channel()
1921 struct uffd_msg *msg = ufd; in vhost_user_postcopy_fault_handler() local
1922 uint64_t faultaddr = msg->arg.pagefault.address; in vhost_user_postcopy_fault_handler()
1991 VhostUserMsg msg = { in vhost_user_postcopy_advise() local
1996 ret = vhost_user_write(dev, &msg, NULL, 0); in vhost_user_postcopy_advise()
2002 ret = vhost_user_read(dev, &msg); in vhost_user_postcopy_advise()
2008 if (msg.hdr.request != VHOST_USER_POSTCOPY_ADVISE) { in vhost_user_postcopy_advise()
2010 VHOST_USER_POSTCOPY_ADVISE, msg.hdr.request); in vhost_user_postcopy_advise()
2014 if (msg.hdr.size) { in vhost_user_postcopy_advise()
2046 VhostUserMsg msg = { in vhost_user_postcopy_listen() local
2054 ret = vhost_user_write(dev, &msg, NULL, 0); in vhost_user_postcopy_listen()
2060 ret = process_message_reply(dev, &msg); in vhost_user_postcopy_listen()
2074 VhostUserMsg msg = { in vhost_user_postcopy_end() local
2083 ret = vhost_user_write(dev, &msg, NULL, 0); in vhost_user_postcopy_end()
2089 ret = process_message_reply(dev, &msg); in vhost_user_postcopy_end()
2334 VhostUserMsg msg = { }; in vhost_user_migration_done() local
2346 msg.hdr.request = VHOST_USER_SEND_RARP; in vhost_user_migration_done()
2347 msg.hdr.flags = VHOST_USER_VERSION; in vhost_user_migration_done()
2348 memcpy((char *)&msg.payload.u64, mac_addr, 6); in vhost_user_migration_done()
2349 msg.hdr.size = sizeof(msg.payload.u64); in vhost_user_migration_done()
2351 return vhost_user_write(dev, &msg, NULL, 0); in vhost_user_migration_done()
2358 VhostUserMsg msg; in vhost_user_net_set_mtu() local
2367 msg.hdr.request = VHOST_USER_NET_SET_MTU; in vhost_user_net_set_mtu()
2368 msg.payload.u64 = mtu; in vhost_user_net_set_mtu()
2369 msg.hdr.size = sizeof(msg.payload.u64); in vhost_user_net_set_mtu()
2370 msg.hdr.flags = VHOST_USER_VERSION; in vhost_user_net_set_mtu()
2372 msg.hdr.flags |= VHOST_USER_NEED_REPLY_MASK; in vhost_user_net_set_mtu()
2375 ret = vhost_user_write(dev, &msg, NULL, 0); in vhost_user_net_set_mtu()
2382 return process_message_reply(dev, &msg); in vhost_user_net_set_mtu()
2392 VhostUserMsg msg = { in vhost_user_send_device_iotlb_msg() local
2394 .hdr.size = sizeof(msg.payload.iotlb), in vhost_user_send_device_iotlb_msg()
2399 ret = vhost_user_write(dev, &msg, NULL, 0); in vhost_user_send_device_iotlb_msg()
2404 return process_message_reply(dev, &msg); in vhost_user_send_device_iotlb_msg()
2417 VhostUserMsg msg = { in vhost_user_get_config() local
2431 msg.payload.config.offset = 0; in vhost_user_get_config()
2432 msg.payload.config.size = config_len; in vhost_user_get_config()
2433 ret = vhost_user_write(dev, &msg, NULL, 0); in vhost_user_get_config()
2439 ret = vhost_user_read(dev, &msg); in vhost_user_get_config()
2445 if (msg.hdr.request != VHOST_USER_GET_CONFIG) { in vhost_user_get_config()
2448 VHOST_USER_GET_CONFIG, msg.hdr.request); in vhost_user_get_config()
2452 if (msg.hdr.size != VHOST_USER_CONFIG_HDR_SIZE + config_len) { in vhost_user_get_config()
2457 memcpy(config, msg.payload.config.region, config_len); in vhost_user_get_config()
2470 VhostUserMsg msg = { in vhost_user_set_config() local
2482 msg.hdr.flags |= VHOST_USER_NEED_REPLY_MASK; in vhost_user_set_config()
2489 msg.payload.config.offset = offset, in vhost_user_set_config()
2490 msg.payload.config.size = size, in vhost_user_set_config()
2491 msg.payload.config.flags = flags, in vhost_user_set_config()
2492 p = msg.payload.config.region; in vhost_user_set_config()
2495 ret = vhost_user_write(dev, &msg, NULL, 0); in vhost_user_set_config()
2501 return process_message_reply(dev, &msg); in vhost_user_set_config()
2515 VhostUserMsg msg = { in vhost_user_crypto_create_session() local
2518 .hdr.size = sizeof(msg.payload.session), in vhost_user_crypto_create_session()
2532 memcpy(&msg.payload.session.u.asym.session_setup_data, sess, in vhost_user_crypto_create_session()
2535 keylen = sizeof(msg.payload.session.u.asym.key); in vhost_user_crypto_create_session()
2541 memcpy(&msg.payload.session.u.asym.key, sess->key, in vhost_user_crypto_create_session()
2548 memcpy(&msg.payload.session.u.sym.session_setup_data, sess, in vhost_user_crypto_create_session()
2551 keylen = sizeof(msg.payload.session.u.sym.key); in vhost_user_crypto_create_session()
2557 memcpy(&msg.payload.session.u.sym.key, sess->cipher_key, in vhost_user_crypto_create_session()
2562 keylen = sizeof(msg.payload.session.u.sym.auth_key); in vhost_user_crypto_create_session()
2568 memcpy(&msg.payload.session.u.sym.auth_key, sess->auth_key, in vhost_user_crypto_create_session()
2573 msg.payload.session.op_code = backend_info->op_code; in vhost_user_crypto_create_session()
2574 msg.payload.session.session_id = backend_info->session_id; in vhost_user_crypto_create_session()
2575 ret = vhost_user_write(dev, &msg, NULL, 0); in vhost_user_crypto_create_session()
2582 ret = vhost_user_read(dev, &msg); in vhost_user_crypto_create_session()
2589 if (msg.hdr.request != VHOST_USER_CREATE_CRYPTO_SESSION) { in vhost_user_crypto_create_session()
2591 VHOST_USER_CREATE_CRYPTO_SESSION, msg.hdr.request); in vhost_user_crypto_create_session()
2595 if (msg.hdr.size != sizeof(msg.payload.session)) { in vhost_user_crypto_create_session()
2600 if (msg.payload.session.session_id < 0) { in vhost_user_crypto_create_session()
2602 msg.payload.session.session_id); in vhost_user_crypto_create_session()
2605 *session_id = msg.payload.session.session_id; in vhost_user_crypto_create_session()
2616 VhostUserMsg msg = { in vhost_user_crypto_close_session() local
2619 .hdr.size = sizeof(msg.payload.u64), in vhost_user_crypto_close_session()
2621 msg.payload.u64 = session_id; in vhost_user_crypto_close_session()
2628 ret = vhost_user_write(dev, &msg, NULL, 0); in vhost_user_crypto_close_session()
2652 VhostUserMsg msg = { in vhost_user_get_inflight_fd() local
2657 .hdr.size = sizeof(msg.payload.inflight), in vhost_user_get_inflight_fd()
2665 ret = vhost_user_write(dev, &msg, NULL, 0); in vhost_user_get_inflight_fd()
2670 ret = vhost_user_read(dev, &msg); in vhost_user_get_inflight_fd()
2675 if (msg.hdr.request != VHOST_USER_GET_INFLIGHT_FD) { in vhost_user_get_inflight_fd()
2678 VHOST_USER_GET_INFLIGHT_FD, msg.hdr.request); in vhost_user_get_inflight_fd()
2682 if (msg.hdr.size != sizeof(msg.payload.inflight)) { in vhost_user_get_inflight_fd()
2687 if (!msg.payload.inflight.mmap_size) { in vhost_user_get_inflight_fd()
2697 addr = mmap(0, msg.payload.inflight.mmap_size, PROT_READ | PROT_WRITE, in vhost_user_get_inflight_fd()
2698 MAP_SHARED, fd, msg.payload.inflight.mmap_offset); in vhost_user_get_inflight_fd()
2708 inflight->size = msg.payload.inflight.mmap_size; in vhost_user_get_inflight_fd()
2709 inflight->offset = msg.payload.inflight.mmap_offset; in vhost_user_get_inflight_fd()
2718 VhostUserMsg msg = { in vhost_user_set_inflight_fd() local
2725 .hdr.size = sizeof(msg.payload.inflight), in vhost_user_set_inflight_fd()
2733 return vhost_user_write(dev, &msg, &inflight->fd, 1); in vhost_user_set_inflight_fd()
2885 VhostUserMsg msg = { in vhost_user_set_device_state_fd() local
2889 .size = sizeof(msg.payload.transfer_state), in vhost_user_set_device_state_fd()
2905 ret = vhost_user_write(dev, &msg, &fd, 1); in vhost_user_set_device_state_fd()
2913 ret = vhost_user_read(dev, &msg); in vhost_user_set_device_state_fd()
2920 if (msg.hdr.request != VHOST_USER_SET_DEVICE_STATE_FD) { in vhost_user_set_device_state_fd()
2923 VHOST_USER_SET_DEVICE_STATE_FD, msg.hdr.request); in vhost_user_set_device_state_fd()
2927 if (msg.hdr.size != sizeof(msg.payload.u64)) { in vhost_user_set_device_state_fd()
2930 sizeof(msg.payload.u64), msg.hdr.size); in vhost_user_set_device_state_fd()
2934 if ((msg.payload.u64 & 0xff) != 0) { in vhost_user_set_device_state_fd()
2939 if (!(msg.payload.u64 & VHOST_USER_VRING_NOFD_MASK)) { in vhost_user_set_device_state_fd()
2955 VhostUserMsg msg = { in vhost_user_check_device_state() local
2968 ret = vhost_user_write(dev, &msg, NULL, 0); in vhost_user_check_device_state()
2975 ret = vhost_user_read(dev, &msg); in vhost_user_check_device_state()
2982 if (msg.hdr.request != VHOST_USER_CHECK_DEVICE_STATE) { in vhost_user_check_device_state()
2985 VHOST_USER_CHECK_DEVICE_STATE, msg.hdr.request); in vhost_user_check_device_state()
2989 if (msg.hdr.size != sizeof(msg.payload.u64)) { in vhost_user_check_device_state()
2992 sizeof(msg.payload.u64), msg.hdr.size); in vhost_user_check_device_state()
2996 if (msg.payload.u64 != 0) { in vhost_user_check_device_state()