examples/iscsi-dd: use stderr for all error text

Signed-off-by: Simon Rowe <simon.rowe@nutanix.com>
This commit is contained in:
Simon Rowe
2021-08-20 10:18:05 +00:00
committed by Bart Van Assche
parent b3a30d995e
commit 35dcf89599
+15 -15
View File
@@ -76,13 +76,13 @@ void write_cb(struct iscsi_context *iscsi, int status, void *command_data, void
struct client *client = wt->client; struct client *client = wt->client;
if (status == SCSI_STATUS_CHECK_CONDITION) { if (status == SCSI_STATUS_CHECK_CONDITION) {
printf("Write10/16 failed with sense key:%d ascq:%04x\n", task->sense.key, task->sense.ascq); fprintf(stderr, "Write10/16 failed with sense key:%d ascq:%04x\n", task->sense.key, task->sense.ascq);
scsi_free_scsi_task(task); scsi_free_scsi_task(task);
exit(10); exit(10);
} }
if (status != SCSI_STATUS_GOOD) { if (status != SCSI_STATUS_GOOD) {
printf("Write10/16 failed with %s\n", iscsi_get_error(iscsi)); fprintf(stderr, "Write10/16 failed with %s\n", iscsi_get_error(iscsi));
if (!client->ignore_errors) { if (!client->ignore_errors) {
scsi_free_scsi_task(task); scsi_free_scsi_task(task);
exit(10); exit(10);
@@ -117,13 +117,13 @@ void read_cb(struct iscsi_context *iscsi, int status, void *command_data, void *
struct scsi_task *task2; struct scsi_task *task2;
if (status == SCSI_STATUS_CHECK_CONDITION) { if (status == SCSI_STATUS_CHECK_CONDITION) {
printf("Read10/16 failed with sense key:%d ascq:%04x\n", task->sense.key, task->sense.ascq); fprintf(stderr, "Read10/16 failed with sense key:%d ascq:%04x\n", task->sense.key, task->sense.ascq);
scsi_free_scsi_task(task); scsi_free_scsi_task(task);
exit(10); exit(10);
} }
if (status != SCSI_STATUS_GOOD) { if (status != SCSI_STATUS_GOOD) {
printf("Read10/16 failed with %s\n", iscsi_get_error(iscsi)); fprintf(stderr, "Read10/16 failed with %s\n", iscsi_get_error(iscsi));
if (!client->ignore_errors) { if (!client->ignore_errors) {
scsi_free_scsi_task(task); scsi_free_scsi_task(task);
exit(10); exit(10);
@@ -137,7 +137,7 @@ void read_cb(struct iscsi_context *iscsi, int status, void *command_data, void *
if (client->use_16_for_rw) { if (client->use_16_for_rw) {
read16_cdb = scsi_cdb_unmarshall(task, SCSI_OPCODE_READ16); read16_cdb = scsi_cdb_unmarshall(task, SCSI_OPCODE_READ16);
if (read16_cdb == NULL) { if (read16_cdb == NULL) {
printf("Failed to unmarshall READ16 CDB.\n"); fprintf(stderr, "Failed to unmarshall READ16 CDB.\n");
exit(10); exit(10);
} }
task2 = iscsi_write16_task(client->dst.iscsi, client->dst.lun, task2 = iscsi_write16_task(client->dst.iscsi, client->dst.lun,
@@ -147,7 +147,7 @@ void read_cb(struct iscsi_context *iscsi, int status, void *command_data, void *
} else { } else {
read10_cdb = scsi_cdb_unmarshall(task, SCSI_OPCODE_READ10); read10_cdb = scsi_cdb_unmarshall(task, SCSI_OPCODE_READ10);
if (read10_cdb == NULL) { if (read10_cdb == NULL) {
printf("Failed to unmarshall READ10 CDB.\n"); fprintf(stderr, "Failed to unmarshall READ10 CDB.\n");
exit(10); exit(10);
} }
task2 = iscsi_write10_task(client->dst.iscsi, client->dst.lun, task2 = iscsi_write10_task(client->dst.iscsi, client->dst.lun,
@@ -156,7 +156,7 @@ void read_cb(struct iscsi_context *iscsi, int status, void *command_data, void *
write_cb, wt); write_cb, wt);
} }
if (task2 == NULL) { if (task2 == NULL) {
printf("failed to send write10/16 command\n"); fprintf(stderr, "failed to send write10/16 command\n");
scsi_free_scsi_task(task); scsi_free_scsi_task(task);
exit(10); exit(10);
} }
@@ -190,7 +190,7 @@ void fill_read_queue(struct client *client)
read_cb, client); read_cb, client);
} }
if (task == NULL) { if (task == NULL) {
printf("failed to send read10/16 command\n"); fprintf(stderr, "failed to send read10/16 command\n");
exit(10); exit(10);
} }
client->pos += num_blocks; client->pos += num_blocks;
@@ -287,14 +287,14 @@ void xcopy_cb(struct iscsi_context *iscsi, int status, void *command_data, void
struct scsi_task *task = command_data; struct scsi_task *task = command_data;
if (status == SCSI_STATUS_CHECK_CONDITION) { if (status == SCSI_STATUS_CHECK_CONDITION) {
printf("XCOPY failed with sense key:%d ascq:%04x\n", fprintf(stderr, "XCOPY failed with sense key:%d ascq:%04x\n",
task->sense.key, task->sense.ascq); task->sense.key, task->sense.ascq);
scsi_free_scsi_task(task); scsi_free_scsi_task(task);
exit(10); exit(10);
} }
if (status != SCSI_STATUS_GOOD) { if (status != SCSI_STATUS_GOOD) {
printf("XCOPY failed with %s\n", iscsi_get_error(iscsi)); fprintf(stderr, "XCOPY failed with %s\n", iscsi_get_error(iscsi));
if (!client->ignore_errors) { if (!client->ignore_errors) {
scsi_free_scsi_task(task); scsi_free_scsi_task(task);
exit(10); exit(10);
@@ -341,7 +341,7 @@ void fill_xcopy_queue(struct client *client)
28; /* BLK_TO_BLK_SEG_DESCR */ 28; /* BLK_TO_BLK_SEG_DESCR */
data.data = malloc(data.size); data.data = malloc(data.size);
if (data.data == NULL) { if (data.data == NULL) {
printf("failed to alloc XCOPY buffer\n"); fprintf(stderr, "failed to alloc XCOPY buffer\n");
exit(10); exit(10);
} }
@@ -371,7 +371,7 @@ void fill_xcopy_queue(struct client *client)
client->src.lun, client->src.lun,
&data, xcopy_cb, client); &data, xcopy_cb, client);
if (task == NULL) { if (task == NULL) {
printf("failed to send XCOPY command\n"); fprintf(stderr, "failed to send XCOPY command\n");
exit(10); exit(10);
} }
@@ -732,15 +732,15 @@ int main(int argc, char *argv[])
} }
if (poll(&pfd[0], 2, -1) < 0) { if (poll(&pfd[0], 2, -1) < 0) {
printf("Poll failed\n"); fprintf(stderr, "Poll failed\n");
exit(10); exit(10);
} }
if (iscsi_service(client.src.iscsi, pfd[0].revents) < 0) { if (iscsi_service(client.src.iscsi, pfd[0].revents) < 0) {
printf("iscsi_service failed with : %s\n", iscsi_get_error(client.src.iscsi)); fprintf(stderr, "iscsi_service failed with : %s\n", iscsi_get_error(client.src.iscsi));
break; break;
} }
if (iscsi_service(client.dst.iscsi, pfd[1].revents) < 0) { if (iscsi_service(client.dst.iscsi, pfd[1].revents) < 0) {
printf("iscsi_service failed with : %s\n", iscsi_get_error(client.dst.iscsi)); fprintf(stderr, "iscsi_service failed with : %s\n", iscsi_get_error(client.dst.iscsi));
break; break;
} }
} }