diff mbox series

[v2,11/16] nvme: factor out block backend setup

Message ID 20200415130159.611361-12-its@irrelevant.dk (mailing list archive)
State New, archived
Headers show
Series nvme: refactoring and cleanups | expand

Commit Message

Klaus Jensen April 15, 2020, 1:01 p.m. UTC
From: Klaus Jensen <k.jensen@samsung.com>

Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
---
 hw/block/nvme.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

Comments

Philippe Mathieu-Daudé April 15, 2020, 1:08 p.m. UTC | #1
On 4/15/20 3:01 PM, Klaus Jensen wrote:
> From: Klaus Jensen <k.jensen@samsung.com>
> 
> Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
> ---
>   hw/block/nvme.c | 13 ++++++++++---
>   1 file changed, 10 insertions(+), 3 deletions(-)
> 
> diff --git a/hw/block/nvme.c b/hw/block/nvme.c
> index 45a352b63d89..80da0825d295 100644
> --- a/hw/block/nvme.c
> +++ b/hw/block/nvme.c
> @@ -1351,6 +1351,13 @@ static void nvme_init_state(NvmeCtrl *n)
>       n->cq = g_new0(NvmeCQueue *, n->params.max_ioqpairs + 1);
>   }
>   
> +static void nvme_init_blk(NvmeCtrl *n, Error **errp)
> +{
> +    blkconf_blocksizes(&n->conf);
> +    blkconf_apply_backend_options(&n->conf, blk_is_read_only(n->conf.blk),
> +                                  false, errp);

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>

> +}
> +
>   static void nvme_realize(PCIDevice *pci_dev, Error **errp)
>   {
>       NvmeCtrl *n = NVME(pci_dev);
> @@ -1375,9 +1382,9 @@ static void nvme_realize(PCIDevice *pci_dev, Error **errp)
>           return;
>       }
>   
> -    blkconf_blocksizes(&n->conf);
> -    if (!blkconf_apply_backend_options(&n->conf, blk_is_read_only(n->conf.blk),
> -                                       false, errp)) {
> +    nvme_init_blk(n, &err);
> +    if (err) {
> +        error_propagate(errp, err);
>           return;
>       }
>   
>
Maxim Levitsky April 21, 2020, 3:04 p.m. UTC | #2
On Wed, 2020-04-15 at 15:01 +0200, Klaus Jensen wrote:
> From: Klaus Jensen <k.jensen@samsung.com>
> 
> Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
> ---
>  hw/block/nvme.c | 13 ++++++++++---
>  1 file changed, 10 insertions(+), 3 deletions(-)
> 
> diff --git a/hw/block/nvme.c b/hw/block/nvme.c
> index 45a352b63d89..80da0825d295 100644
> --- a/hw/block/nvme.c
> +++ b/hw/block/nvme.c
> @@ -1351,6 +1351,13 @@ static void nvme_init_state(NvmeCtrl *n)
>      n->cq = g_new0(NvmeCQueue *, n->params.max_ioqpairs + 1);
>  }
>  
> +static void nvme_init_blk(NvmeCtrl *n, Error **errp)
> +{
> +    blkconf_blocksizes(&n->conf);
> +    blkconf_apply_backend_options(&n->conf, blk_is_read_only(n->conf.blk),
> +                                  false, errp);
> +}
> +
>  static void nvme_realize(PCIDevice *pci_dev, Error **errp)
>  {
>      NvmeCtrl *n = NVME(pci_dev);
> @@ -1375,9 +1382,9 @@ static void nvme_realize(PCIDevice *pci_dev, Error **errp)
>          return;
>      }
>  
> -    blkconf_blocksizes(&n->conf);
> -    if (!blkconf_apply_backend_options(&n->conf, blk_is_read_only(n->conf.blk),
> -                                       false, errp)) {
> +    nvme_init_blk(n, &err);
> +    if (err) {
> +        error_propagate(errp, err);
>          return;
>      }
>  

Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com>

Best regards,
	Maxim Levitsky
diff mbox series

Patch

diff --git a/hw/block/nvme.c b/hw/block/nvme.c
index 45a352b63d89..80da0825d295 100644
--- a/hw/block/nvme.c
+++ b/hw/block/nvme.c
@@ -1351,6 +1351,13 @@  static void nvme_init_state(NvmeCtrl *n)
     n->cq = g_new0(NvmeCQueue *, n->params.max_ioqpairs + 1);
 }
 
+static void nvme_init_blk(NvmeCtrl *n, Error **errp)
+{
+    blkconf_blocksizes(&n->conf);
+    blkconf_apply_backend_options(&n->conf, blk_is_read_only(n->conf.blk),
+                                  false, errp);
+}
+
 static void nvme_realize(PCIDevice *pci_dev, Error **errp)
 {
     NvmeCtrl *n = NVME(pci_dev);
@@ -1375,9 +1382,9 @@  static void nvme_realize(PCIDevice *pci_dev, Error **errp)
         return;
     }
 
-    blkconf_blocksizes(&n->conf);
-    if (!blkconf_apply_backend_options(&n->conf, blk_is_read_only(n->conf.blk),
-                                       false, errp)) {
+    nvme_init_blk(n, &err);
+    if (err) {
+        error_propagate(errp, err);
         return;
     }