Commit Graph

50 Commits

Author SHA1 Message Date
sallyjunjun
045c2387e7 fix iscsi-ls parameter parse
If invalid option is input with iscsi-ls,such as "iscsi-ls -a iscsi://", the command just stuck here and do not print useful information for the user to correct.
Fix this problem with getopt_long.
2022-06-07 19:19:39 -07:00
sallyjunjun
b087a09a0b iscsi-swp: handle setting of debug_level correctly
According to the man page and help info, --debug=integer can specify the
debug_level, while it would report following error:

iscsi-swp --debug=1
iscsi-swp: option '--debug' doesn't allow an argument
2022-05-31 15:12:49 -07:00
Wenchao Hao
5e63853230 iscsi-inq: handle setting of debug_level correctly
According to the man page and help info, --debug=integer can specify the
debug_level, while it would report following error:

iscsi-inq --debug=2
iscsi-inq: option '--debug' doesn't allow an argument

It's because the iscsi-inq code did not handle this parameters
correctly. So here we just correct it.

Signed-off-by: Wenchao Hao <haowenchao@huawei.com>
2022-04-06 10:28:23 +08:00
zhenwei pi
fb9c3f93ed iscsi-pr: add persistent reservation tool
iscsi-pr uses libiscsi to connect target and issues PR command.
In most cases, iscsi-pr use the same parameters as sg_persist(from sg3-utils).

For example, use iscsi-pr to dump keys by command:
  ~# ./utils/iscsi-pr --read-keys iscsi://192.168.122.44/iqn.2003-01.org.linux-iscsi.bytedance.x8664:sn.a6b7bff3d509/0 -i iqn.2005-03.org.open-iscsi:12345678
  PR generation=0x20, 19 registered reservation keys follow:
    0xabcd1234
    0xabcd
    0xabcd
    0xabc

A few command is not implemented in this patch, add them if necessary
in future.

Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
2022-02-20 21:17:40 -08:00
Bart Van Assche
5e6f6ec5ed MinGW: Second step of porting to MinGW 2021-07-18 20:13:03 -07:00
Bart Van Assche
2a5a0b3291 Enable -Wno-unused-parameter
Instead of adding __attribute__((unused)) to unused arguments, add the
-Wno-unused-parameter compiler flag.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
2021-05-23 13:23:41 -07:00
Bart Van Assche
ea6b2282d4 Use __attribute__((format(printf, ...))) directly
Instead of defining the macro _R_(), define __attribute__() as a macro for
compilers that do not support __attribute__(), namely Microsoft Visual
Studio.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
2021-05-23 11:52:40 -07:00
orbea
c437afa825 build: Add -no-undefined where missing
Signed-off-by: orbea <orbea@riseup.net>
2021-05-22 19:32:12 -07:00
orbea
c547d2dc7f build: Remove bogus LDADD variables
Signed-off-by: orbea <orbea@riseup.net>
2021-05-22 19:31:50 -07:00
Issam Maghni
d08547f38a Add header <strings.h> for strncasecmp 2021-05-03 03:45:44 +00:00
Han Han
6db782bb0a iscsi-ls: Fix iser url scheme parsing
Libiscsi supports to parse two iscsi url schemes: 'iscsi://' and 'iser://'.
Fix the missing iser parsing, introduced from 12222077.

Signed-off-by: Han Han <hhan@redhat.com>
2020-08-11 21:57:12 +08:00
Ronnie Sahlberg
c54c4cd202 iscsi-perf: Add explicit casts to avoid two warnings
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2020-07-31 09:21:33 +10:00
Bart Van Assche
3804f3c2e0 Remove the discard_const() macro
Declare dynamically allocated strings as 'char *' instead of 'const char *'.
Remove the discard_const() macro. Do not test whether or not a pointer is
NULL before calling free() because it is allowed to pass NULL to free().

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
2020-02-28 21:54:49 -08:00
Ronnie Sahlberg
1ab84e2175 fix LGTM.com warning
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2019-09-28 17:32:29 -07:00
Tim Crawford
9347cfebf2 Replace file variables with .dir-locals.el
Signed-off-by: Tim Crawford <tcrawford@datto.com>
2019-02-21 11:54:02 -05:00
Tim Crawford
aba0f7da1a Replace WIN32 with _WIN32
Using WIN32 depends on the build environment defining the variable.
_WIN32 is a predefined MSVC macro and is always available.

Signed-off-by: Tim Crawford <crawfxrd@gmail.com>
2017-11-29 10:07:44 -05:00
Ronnie Sahlberg
6d6cb515fb Update the documentation for the --debug flag to iscsi-ls
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2017-06-03 11:36:04 -07:00
Ronnie Sahlberg
12222077cc Add project file for iscsi-ls and make it build under visual studio
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2017-05-13 12:09:42 -07:00
Ronnie Sahlberg
cd0dcb5dae Make iscsi-ls default to HeaderDigest=None for its discovery session
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2017-02-17 18:18:08 -08:00
optimistyzy
63cfcd3384 iscsi-perf: fix overflow issue in fill_read_queue
If with int defintion, this statement:

num_blocks = client->num_blocks - client->pos;

May not get the exact value we want.

Signed-off-by: optimistyzy <optimistyzy@gmail.com>
2017-01-09 18:38:59 +08:00
Vicente Olivert Riera
f27bdf64f0 Do not use -I/usr/include. This is considered unsafe when cross-compiling
Signed-off-by: Vicente Olivert Riera <Vincent.Riera@imgtec.com>
2016-10-16 10:53:13 +01:00
Peter Lieven
ab01692ea6 iscsi-ls: strip portal group tag in url output
we do not use it in libiscsi anyway, but e.g. Qemu does not support in in the URL.

Signed-off-by: Peter Lieven <pl@kamp.de>
2016-07-07 12:00:56 +02:00
Peter Lieven
d0943249f6 iscsi-inq: use right int types
the block limits vpd has unsinged values. casting them to signed can return negative results.

Signed-off-by: Peter Lieven <pl@kamp.de>
2016-07-07 11:24:50 +02:00
Peter Lieven
19a3412d58 iscsi-perf: add a logging parameter
if specified the perf output will log the perf data once per second.

Signed-off-by: Peter Lieven <pl@kamp.de>
2016-07-07 10:44:24 +02:00
Roy Shterman
a628264ef0 Libiscsi: iSER implementation
This commit includes all iSER implementation in libscsi
library and utilities.

Also, adding iser option in url.

Change-Id: I55ca8a9d4db802e72eb991061260dbb0bd0ef9ba
Signed-off-by: Roy Shterman <roysh@mellanox.com>
2016-06-03 18:59:01 -07:00
Paolo Bonzini
d84ee65eaa iscsi-ls: skip link-local IPv6 addresses
Some iSCSI targets provide a link-local IPv6 address as a portal, but that
is unusable without knowing the interface (aka scope-id) to use for the
connection.  This causes iscsi-ls to report an EINVAL and exit.  Just
skip the error.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2016-03-30 17:55:03 +02:00
Ronnie Sahlberg
99a5f99527 Add some emacs defaults. Tabs are 8 spaces.
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-02-18 21:34:43 -08:00
Sitsofe Wheeler
403ec4493a iscsi-perf: Add ULL suffix to large integer literals
Add ULL to all the large integer literals. Without this they can be
treated as being signed by the compiler (at least on 32 bit machines)
leading to underflow problems and strange output when calculating the
elapsed time.
2016-01-30 09:44:45 +00:00
Sitsofe Wheeler
831b222917 iscsi-perf: Allow a better clock to be used
7c6a3e4a0b wound up always forcing the
usage of gettimeofday (even when the more accurate CLOCK_MONOTONIC was
available) because the define to indicate its availability is in
config.h which wasn't included.

Fix this by including config.h, correct the misnamed variable in the
CLOCK_MONOTONIC branch and rename VERSION to PERF_VERSION to avoid the
naming conflict.
2016-01-30 09:44:34 +00:00
Ronnie Sahlberg
1c9792941f iscsi-perf: use uint64_t instead of u_int64_t
because portability

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-05-10 10:55:27 -07:00
Chris Zankel
e186169064 build: fix 'out-of-tree' build
Prefix include paths with '${srcdir}' to allow 'out-of-tree' builds:

  cd $BUILD
  $LIBISCSI/configure
  make

Signed-off-by: Chris Zankel <chris@zankel.net>
2015-04-22 18:18:14 -07:00
Peter Lieven
e219f1bb97 utils/examples: avoid busy waiting on wait for reconnect
Signed-off-by: Peter Lieven <pl@kamp.de>
2015-04-13 10:26:28 +02:00
Peter Lieven
2c1b88e9e7 iscsi-perf: add a max reconnects switch and fix double CTRL-C
this adds a switch to define max_reconnects instead of just aborting
after a NOP timeout. It is now also possible to force an exit
if CTRL-C is pressed twice.

Signed-off-by: Peter Lieven <pl@kamp.de>
2015-03-31 15:44:46 +02:00
Peter Lieven
b9dc3749c9 iscsi-perf: add a switch to send requests of random size
Signed-off-by: Peter Lieven <pl@kamp.de>
2015-03-27 12:18:58 +01:00
Peter Lieven
9d6f0690f8 iscsi-perf: add NOPs to the perf stream and account for timeouts
Signed-off-by: Peter Lieven <pl@kamp.de>
2015-03-27 11:08:37 +01:00
Peter Lieven
44b1a2e1e0 iscsi-perf: use a common iovec for all requests
this avoids a lot of unnecessary mallocs and frees.

Signed-off-by: Peter Lieven <pl@kamp.de>
2015-03-26 11:08:31 +01:00
Peter Lieven
fe265aef9c connect: allow to avoid the testunit ready call in iscsi_full_connect_async
iscsi-ls show luns command does not work when the target redirects at login.
to avoid redundant code allow iscsi_full_connect_async to skip the testunit ready
part.

Signed-off-by: Peter Lieven <pl@kamp.de>
2015-03-26 10:48:01 +01:00
Peter Lieven
2955b2c616 init: apply settings to context in iscsi_parse_url
if iscsi_context is not NULL we apply the parsed settings
to the context.

Signed-off-by: Peter Lieven <pl@kamp.de>
2015-03-26 10:37:39 +01:00
Peter Lieven
2fc538c8be iscsi-perf: add SCSI_STATUS_BUSY and SCSI_STATUS_CHECK_CONDITION handling.
this also fixes abort on errors and time output.

Signed-off-by: Peter Lieven <pl@kamp.de>
2015-03-24 14:32:00 +01:00
Stefan Weil
86adf5847c Fix wrong checks for username
The variable user in struct iscsi_url is a character array, not a pointer.
Therefore its address will never be NULL.

When libscsi is built using clang instead of gcc, those errors are reported:

iscsi-perf.c:256:17: error:
 comparison of array 'iscsi_url->user' not equal to a null
 pointer is always true [-Werror,-Wtautological-pointer-compare]
iscsi-dd.c:272:17: error:
 comparison of array 'iscsi_url->user' not equal to a null
 pointer is always true [-Werror,-Wtautological-pointer-compare]
iscsi-dd.c:331:17: error:
 comparison of array 'iscsi_url->user' not equal to a null
 pointer is always true [-Werror,-Wtautological-pointer-compare]
ld_iscsi.c:99:18: error:
 comparison of array 'iscsi_url->user' not equal to a null
 pointer is always true [-Werror,-Wtautological-pointer-compare]

Fix those errors and also similar code patterns in aros/iscsi-ls.c and
test-tool/iscsi-support.c.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2015-03-07 09:54:38 +01:00
Stefan Weil
d7a8ab0f1e Remove trailing blanks
The files touched here need a bug fix which is applied with the
following patch.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2015-03-07 09:54:38 +01:00
Ronnie Sahlberg
7ffce43dc9 iscsi-util.c: use PRIu64 instead of llu
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-03-02 19:46:46 -08:00
Sitsofe Wheeler
7c6a3e4a0b iscsi-perf: Use gettimeofday if clock_gettime is unavailable
clock_gettime doesn't existing on OS X
(http://stackoverflow.com/questions/5167269/clock-gettime-alternative-in-mac-os-x
) so add an autoconf test to check if the platform has it and fall back
on gettimeofday if not.

Signed-off-by: Sitsofe Wheeler <sitsofe@yahoo.com>
2015-03-01 16:15:51 +00:00
Sitsofe Wheeler
04ff9584ee iscsi-perf.c: Use %llu format string.
Compiling with clang gives a format warning like
iscsi-perf.c:98:53: error: format specifies type 'unsigned long' but the
argument has type 'uint64_t' (aka 'unsigned long long')
      [-Werror,-Wformat]
so replace %lu with %llu where appropriate.

Signed-off-by: Sitsofe Wheeler <sitsofe@yahoo.com>
2015-03-01 16:12:13 +00:00
Ronnie Sahlberg
004f16675e Merge pull request #141 from plieven/iscsi-io
util: introduce iscsi-perf
2015-01-23 06:18:11 -08:00
Peter Lieven
433b3384e6 util: introduce iscsi-perf
this adds the very first version of iscsi-perf to measure throughput
to and performance of an iscsi LUN.

Signed-off-by: Peter Lieven <pl@kamp.de>
2014-11-25 16:08:29 +01:00
Bart Van Assche
0763dc5743 libiscsi: Clear PS bit before sending MODE SELECT
A quote from SPC-4: "When using the MODE SENSE command, a
parameters saveable (PS) bit set to one indicates that the mode
page may be saved by the logical unit in a nonvolatile, vendor
specific location. A PS bit set to zero indicates that the device
server is not able to save the supported parameters. When using
the MODE SELECT command, the PS bit is reserved."

Hence clear the PS bit after having queried a mode page via MODE
SENSE and before changing it via MODE SELECT.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
2014-10-14 17:56:40 -07:00
Ronnie Sahlberg
6285ba72b7 iscsi-swp: Check user[0]!=0 instead of user!=NULL. user is no longer a pointer.
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2014-07-13 17:19:24 -07:00
Ronnie Sahlberg
1daa323e8b Change remaining command line arguments --initiator_name to --initiator-name
Change the remaining instances to match the manpages and help texts
2014-03-26 17:58:30 -07:00
Ronnie Sahlberg
c07779cfa7 AUTOTOOLS: Add a Makefile.am for the iscsi-* utilities 2014-03-22 13:10:19 -07:00