On Feb 21 17:38, Nabih Estefan wrote:
> From: Roque Arcudia Hernandez <roq...@google.com>
> 
> This patch adds a way to specify an NGUID for a given NVMe Namespace using a
> string of hexadecimal digits with an optional '-' separator to group bytes. 
> For
> instance:
> 
> -device nvme-ns,nguid="e9accd3b83904e13167cf0593437f57d"
> 
> If provided, the NGUID will be part of the Namespace Identification Descriptor
> list and the Identify Namespace data.
> 
> Signed-off-by: Roque Arcudia Hernandez <roq...@google.com>
> Signed-off-by: Nabih Estefan <nabiheste...@google.com>

Hi Thanks! Looks good,

Reviewed-by: Klaus Jensen <k.jen...@samsung.com>

Only a minor nit below.

> diff --git a/hw/nvme/nguid.c b/hw/nvme/nguid.c
> new file mode 100644
> index 0000000000..3e3e0567c5
> --- /dev/null
> +++ b/hw/nvme/nguid.c
> @@ -0,0 +1,192 @@
> +/*
> + *  QEMU NVMe NGUID functions
> + *
> + * Copyright 2024 Google LLC
> + *
> + * This program is free software; you can redistribute it and/or modify it
> + * under the terms of the GNU General Public License as published by the
> + * Free Software Foundation; either version 2 of the License, or
> + * (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful, but 
> WITHOUT
> + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
> + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
> + * for more details.
> + */
> +
> +#include "qemu/osdep.h"
> +#include "qapi/visitor.h"
> +#include "qemu/ctype.h"
> +#include "nvme.h"
> +
> +#define NGUID_SEPARATOR '-'
> +
> +#define NGUID_VALUE_AUTO "auto"
> +
> +#define NGUID_FMT              \
> +    "%02hhx%02hhx%02hhx%02hhx" \
> +    "%02hhx%02hhx%02hhx%02hhx" \
> +    "%02hhx%02hhx%02hhx%02hhx" \
> +    "%02hhx%02hhx%02hhx%02hhx"
> +
> +#define NGUID_STR_LEN (2 * NGUID_LEN + 1)
> +
> +bool nvme_nguid_is_null(const NvmeNGUID *nguid)
> +{
> +    int i;
> +    for (i = 0; i < NGUID_LEN; i++) {
> +        if (nguid->data[i] != 0) {
> +            return false;
> +        }
> +    }
> +    return true;
> +}

Maybe just

        bool nvme_nguid_is_null(const NvmeNGUID *nguid)
        {
            static NvmeNGUID null_nguid;
            return memcmp(nguid, &null_nguid, sizeof(NvmeNGUID)) == 0;
        }

Attachment: signature.asc
Description: PGP signature

Reply via email to