Lines Matching full:if
17 * along with this program; if not, see <http://www.gnu.org/licenses/>.
64 * a C string; and @data may be NULL if @len is 0).
65 * Return 0 if successful, -1 with errp set if it is impossible to
75 if (len == -1) { in nbd_send_option_request()
84 if (nbd_write(ioc, &req, sizeof(req), errp) < 0) { in nbd_send_option_request()
89 if (len && nbd_write(ioc, (char *) data, len, errp) < 0) { in nbd_send_option_request()
104 * even care if the request makes it to the server, let alone in nbd_send_opt_abort()
112 * payload. Return 0 if successful, -1 with errp set if it is
118 if (nbd_read(ioc, reply, sizeof(*reply), "option reply", errp) < 0) { in nbd_receive_option_reply()
131 if (reply->magic != NBD_REP_MAGIC) { in nbd_receive_option_reply()
136 if (reply->option != opt) { in nbd_receive_option_reply()
147 * If reply represents success, return 1 without further action. If
150 * fall back to other approaches), where @strict determines if only
160 if (!(reply->type & (1 << 31))) { in nbd_handle_reply_err()
164 if (reply->length) { in nbd_handle_reply_err()
165 if (reply->length > NBD_MAX_BUFFER_SIZE) { in nbd_handle_reply_err()
172 if (nbd_read(ioc, msg, reply->length, NULL, errp) < 0) { in nbd_handle_reply_err()
183 if (reply->type == NBD_REP_ERR_UNSUP || !strict) { in nbd_handle_reply_err()
232 if (msg) { in nbd_handle_reply_err()
243 * name received into *@name. If @description is non-NULL, and the
246 * Returns 1 if name and description were set and iteration must continue,
247 * 0 if iteration is complete (including if OPT_LIST unsupported),
248 * -1 with @errp set if an unrecoverable error occurred.
260 if (nbd_receive_option_reply(ioc, NBD_OPT_LIST, &reply, errp) < 0) { in nbd_receive_list()
264 if (error <= 0) { in nbd_receive_list()
269 if (reply.type == NBD_REP_ACK) { in nbd_receive_list()
270 if (len != 0) { in nbd_receive_list()
276 } else if (reply.type != NBD_REP_SERVER) { in nbd_receive_list()
284 if (len < sizeof(namelen) || len > NBD_MAX_BUFFER_SIZE) { in nbd_receive_list()
289 if (nbd_read32(ioc, &namelen, "option name length", errp) < 0) { in nbd_receive_list()
294 if (len < namelen || namelen > NBD_MAX_STRING_SIZE) { in nbd_receive_list()
301 if (nbd_read(ioc, local_name, namelen, "export name", errp) < 0) { in nbd_receive_list()
307 if (len) { in nbd_receive_list()
308 if (len > NBD_MAX_STRING_SIZE) { in nbd_receive_list()
315 if (nbd_read(ioc, local_desc, len, "export description", errp) < 0) { in nbd_receive_list()
324 if (description) { in nbd_receive_list()
334 * Returns -1 if the option proves the export @info->name cannot be
335 * used, 0 if the option is unsupported (fall back to NBD_OPT_LIST and
336 * NBD_OPT_EXPORT_NAME in that case), and > 0 if the export is good to
361 if (info->request_sizes) { in nbd_opt_info_or_go()
368 if (error < 0) { in nbd_opt_info_or_go()
373 if (nbd_receive_option_reply(ioc, opt, &reply, errp) < 0) { in nbd_opt_info_or_go()
377 if (error <= 0) { in nbd_opt_info_or_go()
382 if (reply.type == NBD_REP_ACK) { in nbd_opt_info_or_go()
387 if (len) { in nbd_opt_info_or_go()
391 if (!info->flags) { in nbd_opt_info_or_go()
398 if (reply.type != NBD_REP_INFO) { in nbd_opt_info_or_go()
405 if (len < sizeof(type)) { in nbd_opt_info_or_go()
411 if (nbd_read16(ioc, &type, "info type", errp) < 0) { in nbd_opt_info_or_go()
418 if (len != sizeof(info->size) + sizeof(info->flags)) { in nbd_opt_info_or_go()
424 if (nbd_read64(ioc, &info->size, "info size", errp) < 0) { in nbd_opt_info_or_go()
428 if (nbd_read16(ioc, &info->flags, "info flags", errp) < 0) { in nbd_opt_info_or_go()
432 if (info->min_block && in nbd_opt_info_or_go()
444 if (len != sizeof(info->min_block) * 3) { in nbd_opt_info_or_go()
450 if (nbd_read32(ioc, &info->min_block, "info minimum block size", in nbd_opt_info_or_go()
455 if (!is_power_of_2(info->min_block)) { in nbd_opt_info_or_go()
461 if (nbd_read32(ioc, &info->opt_block, "info preferred block size", in nbd_opt_info_or_go()
467 if (!is_power_of_2(info->opt_block) || in nbd_opt_info_or_go()
474 if (nbd_read32(ioc, &info->max_block, "info maximum block size", in nbd_opt_info_or_go()
480 if (info->max_block < info->min_block) { in nbd_opt_info_or_go()
492 * Not worth the bother to check if NBD_INFO_NAME or in nbd_opt_info_or_go()
496 if (nbd_drop(ioc, len, errp) < 0) { in nbd_opt_info_or_go()
506 /* Return -1 on failure, 0 if wantname is an available export. */
515 if (nbd_send_option_request(ioc, NBD_OPT_LIST, 0, NULL, errp) < 0) { in nbd_receive_query_exports()
523 if (ret < 0) { in nbd_receive_query_exports()
526 } else if (ret == 0) { in nbd_receive_query_exports()
528 if (list_empty) { in nbd_receive_query_exports()
538 } else if (!found_export) { in nbd_receive_query_exports()
548 if (!strcmp(name, wantname)) { in nbd_receive_query_exports()
559 * 0 if operation is unsupported,
568 if (nbd_send_option_request(ioc, opt, 0, NULL, errp) < 0) { in nbd_request_simple_option()
572 if (nbd_receive_option_reply(ioc, opt, &reply, errp) < 0) { in nbd_request_simple_option()
576 if (error <= 0) { in nbd_request_simple_option()
580 if (reply.type != NBD_REP_ACK) { in nbd_request_simple_option()
588 if (reply.length != 0) { in nbd_request_simple_option()
612 if (data->loop) { in nbd_client_tls_handshake()
626 if (ret <= 0) { in nbd_receive_starttls()
627 if (ret == 0) { in nbd_receive_starttls()
636 if (!tioc) { in nbd_receive_starttls()
647 if (!data.complete) { in nbd_receive_starttls()
654 if (data.error) { in nbd_receive_starttls()
683 if (query) { in nbd_send_meta_query()
696 if (query) { in nbd_send_meta_query()
711 * return 1 if name is set and iteration must continue,
712 * 0 if iteration is complete (including if option is unsupported),
726 if (nbd_receive_option_reply(ioc, opt, &reply, errp) < 0) { in nbd_receive_one_meta_context()
731 if (ret <= 0) { in nbd_receive_one_meta_context()
735 if (reply.type == NBD_REP_ACK) { in nbd_receive_one_meta_context()
736 if (reply.length != 0) { in nbd_receive_one_meta_context()
742 } else if (reply.type != NBD_REP_META_CONTEXT) { in nbd_receive_one_meta_context()
750 if (reply.length <= sizeof(local_id) || in nbd_receive_one_meta_context()
759 if (nbd_read32(ioc, &local_id, "context id", errp) < 0) { in nbd_receive_one_meta_context()
765 if (nbd_read(ioc, local_name, reply.length, "context name", errp) < 0) { in nbd_receive_one_meta_context()
772 if (name) { in nbd_receive_one_meta_context()
777 if (id) { in nbd_receive_one_meta_context()
787 * setting @info->context_id to the resulting id. Fail if the server
791 * 0 if operation is unsupported,
809 if (nbd_send_meta_query(ioc, NBD_OPT_SET_META_CONTEXT, in nbd_negotiate_simple_meta_context()
816 if (ret < 0) { in nbd_negotiate_simple_meta_context()
819 if (ret == 1) { in nbd_negotiate_simple_meta_context()
820 if (strcmp(context, name)) { in nbd_negotiate_simple_meta_context()
833 if (ret < 0) { in nbd_negotiate_simple_meta_context()
837 if (ret != 0) { in nbd_negotiate_simple_meta_context()
848 * return 0 if list is complete (even if empty),
859 if (nbd_send_meta_query(ioc, NBD_OPT_LIST_META_CONTEXT, in nbd_list_meta_contexts()
869 if (ret == 0 && seen_any && !seen_qemu) { in nbd_list_meta_contexts()
872 * "qemu:" replies to 0 queries. If we saw at least one in nbd_list_meta_contexts()
877 if (nbd_send_meta_query(ioc, NBD_OPT_LIST_META_CONTEXT, in nbd_list_meta_contexts()
883 if (ret <= 0) { in nbd_list_meta_contexts()
910 if (zeroes) { in nbd_start_negotiate()
913 if (outioc) { in nbd_start_negotiate()
916 if (tlscreds && !outioc) { in nbd_start_negotiate()
921 if (nbd_read64(ioc, &magic, "initial magic", errp) < 0) { in nbd_start_negotiate()
926 if (magic != NBD_INIT_MAGIC) { in nbd_start_negotiate()
931 if (nbd_read64(ioc, &magic, "server magic", errp) < 0) { in nbd_start_negotiate()
936 if (magic == NBD_OPTS_MAGIC) { in nbd_start_negotiate()
941 if (nbd_read16(ioc, &globalflags, "server flags", errp) < 0) { in nbd_start_negotiate()
945 if (globalflags & NBD_FLAG_FIXED_NEWSTYLE) { in nbd_start_negotiate()
949 if (globalflags & NBD_FLAG_NO_ZEROES) { in nbd_start_negotiate()
950 if (zeroes) { in nbd_start_negotiate()
957 if (nbd_write(ioc, &clientflags, sizeof(clientflags), errp) < 0) { in nbd_start_negotiate()
961 if (tlscreds) { in nbd_start_negotiate()
962 if (fixedNewStyle) { in nbd_start_negotiate()
964 if (!*outioc) { in nbd_start_negotiate()
973 if (fixedNewStyle) { in nbd_start_negotiate()
976 if (max_mode >= NBD_MODE_EXTENDED) { in nbd_start_negotiate()
980 if (result) { in nbd_start_negotiate()
984 if (max_mode >= NBD_MODE_STRUCTURED) { in nbd_start_negotiate()
988 if (result) { in nbd_start_negotiate()
996 } else if (magic == NBD_CLIENT_MAGIC) { in nbd_start_negotiate()
997 if (tlscreds) { in nbd_start_negotiate()
1019 if (nbd_read64(ioc, &info->size, "export length", errp) < 0) { in nbd_negotiate_finish_oldstyle()
1023 if (nbd_read32(ioc, &oldflags, "export flags", errp) < 0) { in nbd_negotiate_finish_oldstyle()
1026 if (oldflags & ~0xffff) { in nbd_negotiate_finish_oldstyle()
1054 if (result < 0) { in nbd_receive_negotiate()
1060 if (tlscreds && *outioc) { in nbd_receive_negotiate()
1067 if (base_allocation) { in nbd_receive_negotiate()
1069 if (result < 0) { in nbd_receive_negotiate()
1076 /* Try NBD_OPT_GO first - if it works, we are done (it in nbd_receive_negotiate()
1077 * also gives us a good message if the server requires in nbd_receive_negotiate()
1078 * TLS). If it is not available, fall back to in nbd_receive_negotiate()
1082 if (result < 0) { in nbd_receive_negotiate()
1085 if (result > 0) { in nbd_receive_negotiate()
1091 * query gives us better error reporting if the in nbd_receive_negotiate()
1094 if (nbd_receive_query_exports(ioc, info->name, errp) < 0) { in nbd_receive_negotiate()
1100 if (nbd_send_option_request(ioc, NBD_OPT_EXPORT_NAME, -1, info->name, in nbd_receive_negotiate()
1106 if (nbd_read64(ioc, &info->size, "export length", errp) < 0) { in nbd_receive_negotiate()
1110 if (nbd_read16(ioc, &info->flags, "export flags", errp) < 0) { in nbd_receive_negotiate()
1115 if (*info->name) { in nbd_receive_negotiate()
1119 if (nbd_negotiate_finish_oldstyle(ioc, info, errp) < 0) { in nbd_receive_negotiate()
1128 if (zeroes && nbd_drop(ioc, 124, errp) < 0) { in nbd_receive_negotiate()
1140 if (!info) { in nbd_free_export_list()
1177 if (tlscreds && sioc) { in nbd_receive_export_list()
1180 if (result < 0) { in nbd_receive_export_list()
1189 * NBD_OPT_INFO on each array member. If structured replies in nbd_receive_export_list()
1191 if (nbd_send_option_request(ioc, NBD_OPT_LIST, 0, NULL, errp) < 0) { in nbd_receive_export_list()
1199 if (rc < 0) { in nbd_receive_export_list()
1201 } else if (rc == 0) { in nbd_receive_export_list()
1214 if (rc < 0) { in nbd_receive_export_list()
1216 } else if (rc == 0) { in nbd_receive_export_list()
1218 * Pointless to try rest of loop. If OPT_INFO doesn't work, in nbd_receive_export_list()
1224 if (result >= NBD_MODE_STRUCTURED && in nbd_receive_export_list()
1244 if (nbd_negotiate_finish_oldstyle(ioc, array, errp) < 0) { in nbd_receive_export_list()
1250 if (nbd_drop(ioc, 124, NULL) == 0) { in nbd_receive_export_list()
1283 if (info->size / sector_size != sectors) { in nbd_init()
1291 if (ioctl(fd, NBD_SET_SOCK, (unsigned long) sioc->fd) < 0) { in nbd_init()
1299 if (ioctl(fd, NBD_SET_BLKSIZE, sector_size) < 0) { in nbd_init()
1306 if (info->size % sector_size) { in nbd_init()
1310 if (ioctl(fd, NBD_SET_SIZE_BLOCKS, sectors) < 0) { in nbd_init()
1316 if (ioctl(fd, NBD_SET_FLAGS, (unsigned long) info->flags) < 0) { in nbd_init()
1317 if (errno == ENOTTY) { in nbd_init()
1321 if (ioctl(fd, BLKROSET, (unsigned long) &read_only) < 0) { in nbd_init()
1346 if (ret < 0 && errno == EPIPE) { in nbd_client()
1390 if (request->mode >= NBD_MODE_EXTENDED) { in nbd_send_request()
1418 if (ret < 0) { in nbd_receive_simple_reply()
1440 if (chunk->magic == NBD_STRUCTURED_REPLY_MAGIC) { in nbd_receive_reply_chunk_header()
1450 if (ret < 0) { in nbd_receive_reply_chunk_header()
1462 * this. Even if we stopped using REQ_ONE, sane servers will cap in nbd_receive_reply_chunk_header()
1465 if (chunk->magic == NBD_STRUCTURED_REPLY_MAGIC) { in nbd_receive_reply_chunk_header()
1472 if (payload_len > NBD_MAX_BUFFER_SIZE + sizeof(NBDStructuredReadData)) { in nbd_receive_reply_chunk_header()
1501 if (len == QIO_CHANNEL_ERR_BLOCK) { in nbd_read_eof()
1504 } else if (len < 0) { in nbd_read_eof()
1506 } else if (len == 0) { in nbd_read_eof()
1507 if (partial) { in nbd_read_eof()
1525 * Wait for a new reply. If this yields, the coroutine must be able to be
1542 if (ret <= 0) { in nbd_receive_reply()
1551 if (mode >= NBD_MODE_EXTENDED) { in nbd_receive_reply()
1556 if (ret < 0) { in nbd_receive_reply()
1567 if (reply->magic != expected) { in nbd_receive_reply()
1572 if (ret < 0) { in nbd_receive_reply()