[PATCH nvme-cli v1 1/2] nvme-cli: Add nvme hostnqn generation option

Christoph Hellwig hch at lst.de
Wed Nov 16 09:11:12 PST 2016


On Tue, Nov 08, 2016 at 12:48:27PM +0200, Sagi Grimberg wrote:
> Add option to generate a NVMe qualified name of a given host
> (in the form of: nqn.2014-08.org.nvmexpress:NVMf:uuid:<some_uuid>).
> This hostnqn will be used for fabrics discovery and connect functions.

Keith - should we have any special prefixes for nvme-cli commands
that don't map to NVMe commands? 

> +static int gen_hostnqn_cmd(int argc, char **argv, struct command *command, struct plugin *plugin)
> +{
> +	char hostnqn[NVMF_NQN_SIZE];
> +	uuid_t uuid;
> +	char uuid_str[37]; /* e.g. 1b4e28ba-2fa1-11d2-883f-0016d3cca427 + \0 */
> +
> +	uuid_generate_random(uuid);
> +	uuid_unparse_lower(uuid, uuid_str);
> +	sprintf(hostnqn, "nqn.2014-08.org.nvmexpress:NVMf:uuid:%s", uuid_str);
> +	printf("%s\n", hostnqn);

Shouldn't the sprintf and printf get merged into one?  No need for the
local variable here.  That would also take care of the snprintf nitpick
from Jay ;-)



More information about the Linux-nvme mailing list