Commit 5ad7d0174e for qemu.org

commit 5ad7d0174e8e5f3e5af27719d4fc5f6a93efa1f2
Author: Klaus Jensen <k.jensen@samsung.com>
Date:   Tue Mar 23 09:03:10 2021 +0100

    hw/block/nvme: fix pi constraint check

    Protection Information can only be enabled if there is at least 8 bytes
    of metadata.

    Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
    Reviewed-by: Gollu Appalanaidu <anaidu.gollu@samsung.com>
    Reviewed-by: Keith Busch <kbusch@kernel.org>

diff --git a/hw/block/nvme-ns.c b/hw/block/nvme-ns.c
index 7f8d139a86..ca04ee1bac 100644
--- a/hw/block/nvme-ns.c
+++ b/hw/block/nvme-ns.c
@@ -394,7 +394,7 @@ static int nvme_ns_check_constraints(NvmeNamespace *ns, Error **errp)
         return -1;
     }

-    if (ns->params.pi && !ns->params.ms) {
+    if (ns->params.pi && ns->params.ms < 8) {
         error_setg(errp, "at least 8 bytes of metadata required to enable "
                    "protection information");
         return -1;