Skip to contentSkip to conversation

hw/scsi/vmw_pvscsi: Remove the dead error handling

PATCH Applied Mao Zhongyi 3 participants 5 messages Jul 26, 2017 – Aug 1, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 hw/scsi/vmw_pvscsi: Remove the dead error handling

qemu_bh_new() is a wrapper around aio_bh_new(), which returns null only when g_new() does. It doesn't. So remove the dead error handling.

Cc Dmitry Fleytman <[email protected]>
Cc Paolo Bonzini <[email protected]>
Cc Markus Armbruster <[email protected]>
---
 hw/scsi/vmw_pvscsi.c | 4 ----
 1 file changed, 4 deletions(-)
hw/scsi/vmw_pvscsi.c +0 -4
index 4a106da..d92973e 100644
@@ -1138,10 +1138,6 @@ pvscsi_init(PCIDevice *pci_dev)
     }
 
     s->completion_worker = qemu_bh_new(pvscsi_process_completion_queue, s);
-    if (!s->completion_worker) {
-        pvscsi_cleanup_msi(s);
-        return -ENOMEM;
-    }
 
     scsi_bus_new(&s->bus, sizeof(s->bus), DEVICE(pci_dev),
                  &pvscsi_scsi_info, NULL);
Signature · 1 line
2.9.4
#1 lore raw

PATCH 2/2 hw/scsi/vmw_pvscsi: Convert to realize

Convert a device model where initialization obviously can't fail, make it implement realize() rather than init().

Cc Dmitry Fleytman <[email protected]>
Cc Paolo Bonzini <[email protected]>
Cc Markus Armbruster <[email protected]>
---
 hw/scsi/vmw_pvscsi.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
hw/scsi/vmw_pvscsi.c +3 -5
index d92973e..77d8b6f 100644
@@ -1103,8 +1103,8 @@ static const struct SCSIBusInfo pvscsi_scsi_info = {
         .cancel = pvscsi_request_cancelled,
 };
 
-static int
-pvscsi_init(PCIDevice *pci_dev)
+static void
+pvscsi_realizefn(PCIDevice *pci_dev, Error **errp)
 {
     PVSCSIState *s = PVSCSI(pci_dev);
 
@@ -1144,8 +1144,6 @@ pvscsi_init(PCIDevice *pci_dev)
     /* override default SCSI bus hotplug-handler, with pvscsi's one */
     qbus_set_hotplug_handler(BUS(&s->bus), DEVICE(s), &error_abort);
     pvscsi_reset_state(s);
-
-    return 0;
 }
 
 static void
@@ -1278,7 +1276,7 @@ static void pvscsi_class_init(ObjectClass *klass, void *data)
     PVSCSIClass *pvs_k = PVSCSI_DEVICE_CLASS(klass);
     HotplugHandlerClass *hc = HOTPLUG_HANDLER_CLASS(klass);
 
-    k->init = pvscsi_init;
+    k->realize = pvscsi_realizefn;
     k->exit = pvscsi_uninit;
     k->vendor_id = PCI_VENDOR_ID_VMWARE;
     k->device_id = PCI_DEVICE_ID_VMWARE_PVSCSI;
Signature · 1 line
2.9.4
Acked-by on v1 2/2
#2 lore raw

Re: [Qemu-devel] [PATCH 2/2] hw/scsi/vmw_pvscsi: Convert to realize

Quoted 5 lines · Mao Zhongyi

Convert a device model where initialization obviously can't fail, make it implement realize() rather than init().

Acked-by Dmitry Fleytman <[email protected] <mailto:[email protected]>>
Quoted 47 lines
Cc Dmitry Fleytman <[email protected]>
Cc Paolo Bonzini <[email protected]>
Cc Markus Armbruster <[email protected]>

---
hw/scsi/vmw_pvscsi.c | 8 +++-----

1 file changed, 3 insertions(+), 5 deletions(-)
hw/scsi/vmw_pvscsi.c +2 -4
index d92973e..77d8b6f 100644
@@ -1103,8 +1103,8 @@ static const struct SCSIBusInfo pvscsi_scsi_info = {
        .cancel = pvscsi_request_cancelled,
 };
 
-static int
-pvscsi_init(PCIDevice *pci_dev)
+static void
+pvscsi_realizefn(PCIDevice *pci_dev, Error **errp)
 {
    PVSCSIState *s = PVSCSI(pci_dev);
 
@@ -1144,8 +1144,6 @@ pvscsi_init(PCIDevice *pci_dev)
    /* override default SCSI bus hotplug-handler, with pvscsi's one */
    qbus_set_hotplug_handler(BUS(&s->bus), DEVICE(s), &error_abort);
    pvscsi_reset_state(s);
-
-    return 0;
 }
 

static void

hw/scsi/vmw_pvscsi.c +1 -1
@@ -1278,7 +1276,7 @@ static void pvscsi_class_init(ObjectClass *klass, void *data)
    PVSCSIClass *pvs_k = PVSCSI_DEVICE_CLASS(klass);
    HotplugHandlerClass *hc = HOTPLUG_HANDLER_CLASS(klass);
 
-    k->init = pvscsi_init;
+    k->realize = pvscsi_realizefn;
    k->exit = pvscsi_uninit;
    k->vendor_id = PCI_VENDOR_ID_VMWARE;
    k->device_id = PCI_DEVICE_ID_VMWARE_PVSCSI;
Signature · 1 line
2.9.4
Acked-by on v1 1/2
#3 lore raw
In reply to Mao Zhongyi
Quoted 7 lines · Mao Zhongyi

qemu_bh_new() is a wrapper around aio_bh_new(), which returns null only when g_new() does. It doesn't. So remove the dead error handling.

Acked-by Dmitry Fleytman <[email protected] <mailto:[email protected]>>
Quoted 28 lines
Cc Dmitry Fleytman <[email protected]>
Cc Paolo Bonzini <[email protected]>
Cc Markus Armbruster <[email protected]>

---
hw/scsi/vmw_pvscsi.c | 4 ----

1 file changed, 4 deletions(-)
hw/scsi/vmw_pvscsi.c +0 -4
index 4a106da..d92973e 100644
@@ -1138,10 +1138,6 @@ pvscsi_init(PCIDevice *pci_dev)
    }
 
    s->completion_worker = qemu_bh_new(pvscsi_process_completion_queue, s);
-    if (!s->completion_worker) {
-        pvscsi_cleanup_msi(s);
-        return -ENOMEM;
-    }
 
    scsi_bus_new(&s->bus, sizeof(s->bus), DEVICE(pci_dev),
                 &pvscsi_scsi_info, NULL);
Signature · 1 line
2.9.4
#4 lore raw
In reply to Mao Zhongyi
Quoted 18 lines · Mao Zhongyi

qemu_bh_new() is a wrapper around aio_bh_new(), which returns null only when g_new() does. It doesn't. So remove the dead error handling.

Cc Dmitry Fleytman <[email protected]>
Cc Paolo Bonzini <[email protected]>
Cc Markus Armbruster <[email protected]>
---
 hw/scsi/vmw_pvscsi.c | 4 ----
 1 file changed, 4 deletions(-)
hw/scsi/vmw_pvscsi.c +0 -0
index 4a106da..d92973e 100644

hw/scsi/vmw_pvscsi.c pvscsi_init(PCIDevice *pci_dev) · line 1143

Quoted 10 lines
hw/scsi/vmw_pvscsi.c +0 -4
@@ -1138,10 +1138,6 @@ pvscsi_init(PCIDevice *pci_dev)
     }
 
     s->completion_worker = qemu_bh_new(pvscsi_process_completion_queue, s);
-    if (!s->completion_worker) {
-        pvscsi_cleanup_msi(s);
-        return -ENOMEM;
-    }
 
     scsi_bus_new(&s->bus, sizeof(s->bus), DEVICE(pci_dev),
                  &pvscsi_scsi_info, NULL);

Queued both patches, thanks.

Paolo