s390x/ccw: Error reporting cleanups
cover s390x/ccw: Error reporting cleanups
Hello,
The first patches of this series simply apply the practices described in the Rules section of the qapi/error.h file for routines taking an 'Error **' argument. The remaining patches are a fixup in the error path of vfio_ccw_realize() and some error reporting adjustements.
Applies on top of this vfio PR :
https://lore.kernel.org/qemu-devel/[email protected]
Thanks,
C.
Cédric Le Goater (6):
hw/s390x/ccw: Make s390_ccw_get_dev_info() return a bool s390x/css: Make CCWDeviceClass::realize return bool hw/s390x/ccw: Remove local Error variable from s390_ccw_realize() s390x/css: Make S390CCWDeviceClass::realize return bool vfio/ccw: Use the 'Error **errp' argument of vfio_ccw_realize() vfio/{ap,ccw}: Use warn_report_err() for IRQ notifier registration
errors
Zhenzhong Duan (1):
vfio/ccw: Fix the missed unrealize() call in error path
hw/s390x/ccw-device.h | 2 +- include/hw/s390x/s390-ccw.h | 2 +- hw/s390x/ccw-device.c | 3 ++- hw/s390x/s390-ccw.c | 29 +++++++++++++---------------- hw/vfio/ap.c | 2 +- hw/vfio/ccw.c | 18 ++++++++---------- 6 files changed, 26 insertions(+), 30 deletions(-)
Signature · 1 line
2.45.1
PATCH 1/7 hw/s390x/ccw: Make s390_ccw_get_dev_info() return a bool
Since s390_ccw_get_dev_info() takes an 'Error **' argument, best practices suggest to return a bool. See the qapi/error.h Rules section. While at it, modify the call in s390_ccw_realize().
--- hw/s390x/s390-ccw.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
hw/s390x/s390-ccw.c +6 -6
@@ -71,7 +71,7 @@ IOInstEnding s390_ccw_store(SubchDev *sch)return ret; } -static void s390_ccw_get_dev_info (S390CCWDevice *cdev, +static bool s390_ccw_get_dev_info (S390CCWDevice *cdev,char *sysfsdev,Error **errp) {
@@ -84,12 +84,12 @@ static void s390_ccw_get_dev_info(S390CCWDevice *cdev,error_setg (errp,"No host device provided" );error_append_hint (errp,"Use -device vfio-ccw,sysfsdev=PATH_TO_DEVICE\n" ); -return ; +return false; }if (!realpath (sysfsdev, dev_path)) {error_setg_errno (errp, errno,"Host device '%s' not found" , sysfsdev); -return ; +return false; } cdev->mdevid =g_path_get_basename (dev_path);
@@ -98,13 +98,14 @@ static void s390_ccw_get_dev_info(S390CCWDevice *cdev, tmp =g_path_get_basename (tmp_dir);if (sscanf (tmp,"%2x.%1x.%4x" , &cssid, &ssid, &devid) !=3 ) {error_setg_errno (errp, errno,"Failed to read %s" , tmp); -return ; +return false; } cdev->hostid.cssid = cssid; cdev->hostid.ssid = ssid; cdev->hostid.devid = devid; cdev->hostid.valid = true; +return true; }static void s390_ccw_realize (S390CCWDevice *cdev,char *sysfsdev,Error **errp)
@@ -116,8 +117,7 @@ static void s390_ccw_realize(S390CCWDevice *cdev, char *sysfsdev, Error **errp)int ret;Error *err =NULL ; -s390_ccw_get_dev_info (cdev, sysfsdev, &err); -if (err) { +if (!s390_ccw_get_dev_info (cdev, sysfsdev, &err)) { goto out_err_propagate; }
Signature · 1 line
2.45.1
RE: [PATCH 1/7] hw/s390x/ccw: Make s390_ccw_get_dev_info() return a bool
Quoted 7 lines
-----Original Message-----
From: Cédric Le Goater <[email protected]>
Subject: [PATCH 1/7] hw/s390x/ccw: Makes390_ccw_get_dev_info()return a bool
Quoted 5 lines
Since
s390_ccw_get_dev_info()takes an 'Error **' argument, best practices suggest to return a bool. See theqapi/error.hRules section. While at it, modify the call ins390_ccw_realize().Signed-off-by Cédric Le Goater <[email protected]>
Thanks
Zhenzhong
Quoted 66 lines
---
hw/s390x/s390-ccw.c| 12 ++++++------1 file changed, 6 insertions(+), 6 deletions(-)hw/s390x/s390-ccw.c +0
-0index
5261e66724f1cc3157b9413b0d5fdf5289c92503..a06e91dfb318e3500324851488c56806fa46c08d100644hw/s390x/s390-ccw.c +3
-3@@ -71,7 +71,7 @@ IOInstEnding s390_ccw_store(SubchDev *sch)return ret; } -static void s390_ccw_get_dev_info (S390CCWDevice *cdev, +static bool s390_ccw_get_dev_info (S390CCWDevice *cdev,char *sysfsdev,Error **errp) {@@ -84,12 +84,12 @@ static void s390_ccw_get_dev_info(S390CCWDevice *cdev,error_setg (errp,"No host device provided" );error_append_hint (errp,"Use -device vfio-ccw,sysfsdev=PATH_TO_DEVICE\n" ); -return ; +return false; }if (!realpath (sysfsdev, dev_path)) {error_setg_errno (errp, errno,"Host device '%s' not found" , sysfsdev); -return ; +return false; }cdev->mdevid = g_path_get_basename(dev_path);hw/s390x/s390-ccw.c +2
-1@@ -98,13 +98,14 @@ static void s390_ccw_get_dev_info(S390CCWDevice *cdev, tmp =g_path_get_basename (tmp_dir);if (sscanf (tmp,"%2x.%1x.%4x" , &cssid, &ssid, &devid) !=3 ) {error_setg_errno (errp, errno,"Failed to read %s" , tmp); -return ; +return false; } cdev->hostid.cssid = cssid; cdev->hostid.ssid = ssid; cdev->hostid.devid = devid; cdev->hostid.valid = true; +return true; }static void
s390_ccw_realize(S390CCWDevice *cdev, char *sysfsdev, Error **errp)hw/s390x/s390-ccw.c +1
-3@@ -116,8 +117,7 @@ static void s390_ccw_realize(S390CCWDevice *cdev, char *sysfsdev, Error **errp) int ret;Error *err =NULL ; -s390_ccw_get_dev_info (cdev, sysfsdev, &err); -if (err) { +if (!s390_ccw_get_dev_info (cdev, sysfsdev, &err)) { goto out_err_propagate; } --2.45.1
Re: [PATCH 1/7] hw/s390x/ccw: Make s390_ccw_get_dev_info() return a bool
In reply to Cédric Le GoaterQuoted 5 lines · Cédric Le Goater
Since
s390_ccw_get_dev_info()takes an 'Error **' argument, best practices suggest to return a bool. See theqapi/error.hRules section. While at it, modify the call ins390_ccw_realize().Signed-off-by Cédric Le Goater <[email protected]>
Quoted 58 lines
--- hw/s390x/s390-ccw.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)hw/s390x/s390-ccw.c +6
-6@@ -71,7 +71,7 @@ IOInstEnding s390_ccw_store(SubchDev *sch)return ret; } -static void s390_ccw_get_dev_info (S390CCWDevice *cdev, +static bool s390_ccw_get_dev_info (S390CCWDevice *cdev,char *sysfsdev,Error **errp) {@@ -84,12 +84,12 @@ static void s390_ccw_get_dev_info(S390CCWDevice *cdev,error_setg (errp,"No host device provided" );error_append_hint (errp,"Use -device vfio-ccw,sysfsdev=PATH_TO_DEVICE\n" ); -return ; +return false; }if (!realpath (sysfsdev, dev_path)) {error_setg_errno (errp, errno,"Host device '%s' not found" , sysfsdev); -return ; +return false; } cdev->mdevid =g_path_get_basename (dev_path);@@ -98,13 +98,14 @@ static void s390_ccw_get_dev_info(S390CCWDevice *cdev, tmp =g_path_get_basename (tmp_dir);if (sscanf (tmp,"%2x.%1x.%4x" , &cssid, &ssid, &devid) !=3 ) {error_setg_errno (errp, errno,"Failed to read %s" , tmp); -return ; +return false; } cdev->hostid.cssid = cssid; cdev->hostid.ssid = ssid; cdev->hostid.devid = devid; cdev->hostid.valid = true; +return true; }static void s390_ccw_realize (S390CCWDevice *cdev,char *sysfsdev,Error **errp)@@ -116,8 +117,7 @@ static void s390_ccw_realize(S390CCWDevice *cdev, char *sysfsdev, Error **errp)int ret;Error *err =NULL ; -s390_ccw_get_dev_info (cdev, sysfsdev, &err); -if (err) { +if (!s390_ccw_get_dev_info (cdev, sysfsdev, &err)) { goto out_err_propagate; }
PATCH 2/7 s390x/css: Make CCWDeviceClass::realize return bool
In reply to Cédric Le GoaterSince the realize() handler of CCWDeviceClass takes an 'Error **' argument, best practices suggest to return a bool. See the api/error.h Rules section. While at it, modify the call in s390_ccw_realize().
--- hw/s390x/ccw-device.h | 2 +- hw/s390x/ccw-device.c | 3 ++- hw/s390x/s390-ccw.c | 3 +-- 3 files changed, 4 insertions(+), 4 deletions(-)
hw/s390x/ccw-device.h +1 -1
@@ -36,7 +36,7 @@ extern const VMStateDescription vmstate_ccw_dev;struct CCWDeviceClass {DeviceClass parent_class;void (*unplug)(HotplugHandler *,DeviceState *,Error **); -void (*realize)(CcwDevice *,Error **); +bool (*realize)(CcwDevice *,Error **);void (*refill_ids)(CcwDevice *); };
hw/s390x/ccw-device.c +2 -1
@@ -31,9 +31,10 @@ static void ccw_device_refill_ids(CcwDevice *dev) dev->subch_id.valid = true; } -static void ccw_device_realize (CcwDevice *dev,Error **errp) +static bool ccw_device_realize (CcwDevice *dev,Error **errp) {ccw_device_refill_ids (dev); +return true; }static Property ccw_device_properties[] = {
hw/s390x/s390-ccw.c +1 -2
@@ -137,8 +137,7 @@ static void s390_ccw_realize(S390CCWDevice *cdev, char *sysfsdev, Error **errp) goto out_err; } - ck->realize (ccw_dev, &err); -if (err) { +if (!ck->realize (ccw_dev, &err)) { goto out_err; }
Signature · 1 line
2.45.1
RE: [PATCH 2/7] s390x/css: Make CCWDeviceClass::realize return bool
Quoted 11 lines
-----Original Message-----
From: Cédric Le Goater <[email protected]>
Subject: [PATCH 2/7] s390x/css: MakeCCWDeviceClass::realizereturn boolSince the
realize()handler of CCWDeviceClass takes an 'Error **' argument, best practices suggest to return a bool. See theapi/error.hRules section. While at it, modify the call ins390_ccw_realize().Signed-off-by Cédric Le Goater <[email protected]>
Thanks
Zhenzhong
Quoted 58 lines
---
hw/s390x/ccw-device.h | 2 +- hw/s390x/ccw-device.c | 3 ++- hw/s390x/s390-ccw.c | 3 +-- 3 files changed, 4 insertions(+), 4 deletions(-)hw/s390x/ccw-device.h +0
-0index
6dff95225df11c63f9b66975019026b215c8c448..5feeb0ee7a268b8709043b5bbc56b06e707a448d100644hw/s390x/ccw-device.h +1
-1@@ -36,7 +36,7 @@ extern const VMStateDescription vmstate_ccw_dev;struct CCWDeviceClass {DeviceClass parent_class;void (*unplug)(HotplugHandler *,DeviceState *,Error **); -void (*realize)(CcwDevice *,Error **); +bool (*realize)(CcwDevice *,Error **);void (*refill_ids)(CcwDevice *); };hw/s390x/ccw-device.c +0
-0index
fb8c1acc64d5002c861a4913f292d8346dbef192..a7d682e5af9ce90e7e2fad8c24b30e39328c7cf4100644hw/s390x/ccw-device.c +2
-1@@ -31,9 +31,10 @@ static void ccw_device_refill_ids(CcwDevice *dev) dev->subch_id.valid = true; } -static void ccw_device_realize (CcwDevice *dev,Error **errp) +static bool ccw_device_realize (CcwDevice *dev,Error **errp) {ccw_device_refill_ids (dev); +return true; }static Property ccw_device_properties[] = {hw/s390x/s390-ccw.c +0
-0index
a06e91dfb318e3500324851488c56806fa46c08d..4b8ede701df90949720262b6fc1b65f4e505e34d100644hw/s390x/s390-ccw.c +1
-3@@ -137,8 +137,7 @@ static void s390_ccw_realize(S390CCWDevice *cdev, char *sysfsdev, Error **errp) goto out_err; } - ck->realize (ccw_dev, &err); -if (err) { +if (!ck->realize (ccw_dev, &err)) { goto out_err; } --2.45.1
Re: [PATCH 2/7] s390x/css: Make CCWDeviceClass::realize return bool
In reply to Cédric Le GoaterQuoted 5 lines · Cédric Le Goater
Since the
realize()handler of CCWDeviceClass takes an 'Error **' argument, best practices suggest to return a bool. See theapi/error.hRules section. While at it, modify the call ins390_ccw_realize().Signed-off-by Cédric Le Goater <[email protected]>
Quoted 49 lines
--- hw/s390x/ccw-device.h | 2 +- hw/s390x/ccw-device.c | 3 ++- hw/s390x/s390-ccw.c | 3 +-- 3 files changed, 4 insertions(+), 4 deletions(-)hw/s390x/ccw-device.h +1
-1@@ -36,7 +36,7 @@ extern const VMStateDescription vmstate_ccw_dev;struct CCWDeviceClass {DeviceClass parent_class;void (*unplug)(HotplugHandler *,DeviceState *,Error **); -void (*realize)(CcwDevice *,Error **); +bool (*realize)(CcwDevice *,Error **);void (*refill_ids)(CcwDevice *); };hw/s390x/ccw-device.c +2
-1@@ -31,9 +31,10 @@ static void ccw_device_refill_ids(CcwDevice *dev) dev->subch_id.valid = true; } -static void ccw_device_realize (CcwDevice *dev,Error **errp) +static bool ccw_device_realize (CcwDevice *dev,Error **errp) {ccw_device_refill_ids (dev); +return true; }static Property ccw_device_properties[] = {hw/s390x/s390-ccw.c +1
-2@@ -137,8 +137,7 @@ static void s390_ccw_realize(S390CCWDevice *cdev, char *sysfsdev, Error **errp) goto out_err; } - ck->realize (ccw_dev, &err); -if (err) { +if (!ck->realize (ccw_dev, &err)) { goto out_err; }
PATCH 3/7 hw/s390x/ccw: Remove local Error variable from s390_ccw_realize()
In reply to Cédric Le GoaterUse the 'Error **errp' argument of s390_ccw_realize() instead and remove the error_propagate() call.
--- hw/s390x/s390-ccw.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-)
hw/s390x/s390-ccw.c +5 -8
@@ -115,13 +115,12 @@ static void s390_ccw_realize(S390CCWDevice *cdev, char *sysfsdev, Error **errp)DeviceState *parent =DEVICE (ccw_dev);SubchDev *sch;int ret; -Error *err =NULL ; -if (!s390_ccw_get_dev_info (cdev, sysfsdev, &err)) { - goto out_err_propagate; +if (!s390_ccw_get_dev_info (cdev, sysfsdev, errp)) { +return ; } - sch =css_create_sch (ccw_dev->devno, &err); + sch =css_create_sch (ccw_dev->devno, errp);if (!sch) { goto out_mdevid_free; }
@@ -132,12 +131,12 @@ static void s390_ccw_realize(S390CCWDevice *cdev, char *sysfsdev, Error **errp) ccw_dev->sch = sch; ret =css_sch_build_schib (sch, &cdev->hostid);if (ret) { -error_setg_errno (&err, -ret,"%s: Failed to build initial schib" , +error_setg_errno (errp, -ret,"%s: Failed to build initial schib" , __func__); goto out_err; } -if (!ck->realize (ccw_dev, &err)) { +if (!ck->realize (ccw_dev, errp)) { goto out_err; }
@@ -151,8 +150,6 @@ out_err:g_free (sch); out_mdevid_free:g_free (cdev->mdevid); -out_err_propagate: -error_propagate (errp, err); }static void s390_ccw_unrealize (S390CCWDevice *cdev)
Signature · 1 line
2.45.1
RE: [PATCH 3/7] hw/s390x/ccw: Remove local Error variable from s390_ccw_realize()
Quoted 11 lines
-----Original Message-----
From: Cédric Le Goater <[email protected]>
Subject: [PATCH 3/7] hw/s390x/ccw: Remove local Error variable froms390_ccw_realize()Use the 'Error **errp' argument of
s390_ccw_realize()instead and remove theerror_propagate()call.Signed-off-by Cédric Le Goater <[email protected]>
Thanks
Zhenzhong
Quoted 55 lines
---
hw/s390x/s390-ccw.c| 13 +++++--------1 file changed, 5 insertions(+), 8 deletions(-)hw/s390x/s390-ccw.c +0
-0index
4b8ede701df90949720262b6fc1b65f4e505e34d..b3d14c61d732880a651edcf28a040ca723cb9f5b100644hw/s390x/s390-ccw.c +3
-4@@ -115,13 +115,12 @@ static void s390_ccw_realize(S390CCWDevice *cdev, char *sysfsdev, Error **errp)DeviceState *parent =DEVICE (ccw_dev);SubchDev *sch;int ret; -Error *err =NULL ; -if (!s390_ccw_get_dev_info (cdev, sysfsdev, &err)) { - goto out_err_propagate; +if (!s390_ccw_get_dev_info (cdev, sysfsdev, errp)) { +return ; } - sch =css_create_sch (ccw_dev->devno, &err); + sch =css_create_sch (ccw_dev->devno, errp);if (!sch) { goto out_mdevid_free;}hw/s390x/s390-ccw.c +2
-2@@ -132,12 +131,12 @@ static void s390_ccw_realize(S390CCWDevice *cdev, char *sysfsdev, Error **errp) ccw_dev->sch = sch; ret =css_sch_build_schib (sch, &cdev->hostid);if (ret) { -error_setg_errno (&err, -ret,"%s: Failed to build initial schib" , +error_setg_errno (errp, -ret,"%s: Failed to build initial schib" , __func__); goto out_err; } -if (!ck->realize (ccw_dev, &err)) { +if (!ck->realize (ccw_dev, errp)) { goto out_err; }@@ -151,8 +150,6 @@ out_err:g_free (sch);
out_mdevid_free:g_free(cdev->mdevid);hw/s390x/s390-ccw.c +0
-2-out_err_propagate: -error_propagate (errp, err);}
static void
s390_ccw_unrealize(S390CCWDevice *cdev)--
2.45.1
Re: [PATCH 3/7] hw/s390x/ccw: Remove local Error variable from s390_ccw_realize()
In reply to Cédric Le GoaterQuoted 4 lines · Cédric Le Goater
Use the 'Error **errp' argument of
s390_ccw_realize()instead and remove theerror_propagate()call.Signed-off-by Cédric Le Goater <[email protected]>
Quoted 49 lines
--- hw/s390x/s390-ccw.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-)hw/s390x/s390-ccw.c +5
-8@@ -115,13 +115,12 @@ static void s390_ccw_realize(S390CCWDevice *cdev, char *sysfsdev, Error **errp)DeviceState *parent =DEVICE (ccw_dev);SubchDev *sch;int ret; -Error *err =NULL ; -if (!s390_ccw_get_dev_info (cdev, sysfsdev, &err)) { - goto out_err_propagate; +if (!s390_ccw_get_dev_info (cdev, sysfsdev, errp)) { +return ; } - sch =css_create_sch (ccw_dev->devno, &err); + sch =css_create_sch (ccw_dev->devno, errp);if (!sch) { goto out_mdevid_free; }@@ -132,12 +131,12 @@ static void s390_ccw_realize(S390CCWDevice *cdev, char *sysfsdev, Error **errp) ccw_dev->sch = sch; ret =css_sch_build_schib (sch, &cdev->hostid);if (ret) { -error_setg_errno (&err, -ret,"%s: Failed to build initial schib" , +error_setg_errno (errp, -ret,"%s: Failed to build initial schib" , __func__); goto out_err; } -if (!ck->realize (ccw_dev, &err)) { +if (!ck->realize (ccw_dev, errp)) { goto out_err; }@@ -151,8 +150,6 @@ out_err:g_free (sch); out_mdevid_free:g_free (cdev->mdevid); -out_err_propagate: -error_propagate (errp, err); }static void s390_ccw_unrealize (S390CCWDevice *cdev)
PATCH 4/7 s390x/css: Make S390CCWDeviceClass::realize return bool
In reply to Cédric Le GoaterSince the realize() handler of S390CCWDeviceClass takes an 'Error **' argument, best practices suggest to return a bool. See the api/error.h Rules section. While at it, modify the call in vfio_ccw_realize().
--- include/hw/s390x/s390-ccw.h | 2 +- hw/s390x/s390-ccw.c | 7 ++++--- hw/vfio/ccw.c | 3 +-- 3 files changed, 6 insertions(+), 6 deletions(-)
include/hw/s390x/s390-ccw.h +1 -1
@@ -31,7 +31,7 @@ struct S390CCWDevice {struct S390CCWDeviceClass {CCWDeviceClass parent_class; -void (*realize)(S390CCWDevice *dev,char *sysfsdev,Error **errp); +bool (*realize)(S390CCWDevice *dev,char *sysfsdev,Error **errp);void (*unrealize)(S390CCWDevice *dev);IOInstEnding (*handle_request) (SubchDev *sch);int (*handle_halt) (SubchDev *sch);
hw/s390x/s390-ccw.c +4 -3
@@ -108,7 +108,7 @@ static bool s390_ccw_get_dev_info(S390CCWDevice *cdev,return true; } -static void s390_ccw_realize (S390CCWDevice *cdev,char *sysfsdev,Error **errp) +static bool s390_ccw_realize (S390CCWDevice *cdev,char *sysfsdev,Error **errp) {CcwDevice *ccw_dev =CCW_DEVICE (cdev);CCWDeviceClass *ck =CCW_DEVICE_GET_CLASS (ccw_dev);
@@ -117,7 +117,7 @@ static void s390_ccw_realize(S390CCWDevice *cdev, char *sysfsdev, Error **errp)int ret;if (!s390_ccw_get_dev_info (cdev, sysfsdev, errp)) { -return ; +return false; } sch =css_create_sch (ccw_dev->devno, errp);
@@ -142,7 +142,7 @@ static void s390_ccw_realize(S390CCWDevice *cdev, char *sysfsdev, Error **errp)css_generate_sch_crws (sch->cssid, sch->ssid, sch->schid, parent->hotplugged,1 ); -return ; +return true; out_err:css_subch_assign (sch->cssid, sch->ssid, sch->schid, sch->devno,NULL );
@@ -150,6 +150,7 @@ out_err:g_free (sch); out_mdevid_free:g_free (cdev->mdevid); +return false; }static void s390_ccw_unrealize (S390CCWDevice *cdev)
hw/vfio/ccw.c +1 -2
@@ -582,8 +582,7 @@ static void vfio_ccw_realize(DeviceState *dev, Error **errp)/* Call the class init function for subchannel. */ if (cdc->realize) { - cdc->realize (cdev, vcdev->vdev.sysfsdev, &err); -if (err) { +if (!cdc->realize (cdev, vcdev->vdev.sysfsdev, &err)) { goto out_err_propagate; } }
Signature · 1 line
2.45.1
RE: [PATCH 4/7] s390x/css: Make S390CCWDeviceClass::realize return bool
Quoted 7 lines
-----Original Message-----
From: Cédric Le Goater <[email protected]>
Subject: [PATCH 4/7] s390x/css: MakeS390CCWDeviceClass::realizereturn bool
Quoted 5 lines
Since the
realize()handler of S390CCWDeviceClass takes an 'Error **' argument, best practices suggest to return a bool. See theapi/error.hRules section. While at it, modify the call invfio_ccw_realize().Signed-off-by Cédric Le Goater <[email protected]>
Thanks
Zhenzhong
Quoted 86 lines
---
include/hw/s390x/s390-ccw.h | 2 +- hw/s390x/s390-ccw.c | 7 ++++--- hw/vfio/ccw.c | 3 +-- 3 files changed, 6 insertions(+), 6 deletions(-)include/hw/s390x/s390-ccw.h +0
-0index
2c807ee3a1ae8d85460fe65be8a62c64f212fe4b..2e0a70998132070996d6b0d083b8ddba5b9b87dc100644include/hw/s390x/s390-ccw.h +1
-1@@ -31,7 +31,7 @@ struct S390CCWDevice {struct S390CCWDeviceClass {CCWDeviceClass parent_class; -void (*realize)(S390CCWDevice *dev,char *sysfsdev,Error **errp); +bool (*realize)(S390CCWDevice *dev,char *sysfsdev,Error **errp);void (*unrealize)(S390CCWDevice *dev);IOInstEnding (*handle_request) (SubchDev *sch);int (*handle_halt) (SubchDev *sch);hw/s390x/s390-ccw.c +0
-0index
b3d14c61d732880a651edcf28a040ca723cb9f5b..3c0975055089c3629dd76ce2e1484a4ef66d8d41100644hw/s390x/s390-ccw.c +1
-1@@ -108,7 +108,7 @@ static bool s390_ccw_get_dev_info(S390CCWDevice *cdev, return true; } -static void s390_ccw_realize (S390CCWDevice *cdev,char *sysfsdev,Error **errp) +static bool s390_ccw_realize (S390CCWDevice *cdev,char *sysfsdev,Error **errp){ CcwDevice *ccw_dev = CCW_DEVICE(cdev); CCWDeviceClass *ck = CCW_DEVICE_GET_CLASS(ccw_dev);hw/s390x/s390-ccw.c +1
-1@@ -117,7 +117,7 @@ static void s390_ccw_realize(S390CCWDevice *cdev, char *sysfsdev, Error **errp) int ret;if (!s390_ccw_get_dev_info (cdev, sysfsdev, errp)) { -return ; +return false; }sch = css_create_sch(ccw_dev->devno, errp);hw/s390x/s390-ccw.c +1
-1@@ -142,7 +142,7 @@ static void s390_ccw_realize(S390CCWDevice *cdev, char *sysfsdev, Error **errp) css_generate_sch_crws(sch->cssid, sch->ssid, sch->schid, parent->hotplugged, 1); -return ; +return true;
out_err:css_subch_assign(sch->cssid, sch->ssid, sch->schid, sch->devno, NULL);hw/s390x/s390-ccw.c +0
-0@@ -150,6 +150,7 @@ out_err:g_free (sch);
out_mdevid_free:g_free(cdev->mdevid);+ return false;
}static void
s390_ccw_unrealize(S390CCWDevice *cdev)hw/vfio/ccw.c +0
-0index
2600e62e37238779800dc2b3a0bd315d7633017b..9a8e052711fe2f7c067c52808b2af30d0ebfee0c100644hw/vfio/ccw.c +1
-2@@ -582,8 +582,7 @@ static void vfio_ccw_realize(DeviceState *dev, Error **errp)/* Call the class init function for subchannel. */ if (cdc->realize) { - cdc->realize (cdev, vcdev->vdev.sysfsdev, &err); -if (err) { +if (!cdc->realize (cdev, vcdev->vdev.sysfsdev, &err)) { goto out_err_propagate; }}--
2.45.1
Re: [PATCH 4/7] s390x/css: Make S390CCWDeviceClass::realize return bool
In reply to Cédric Le GoaterQuoted 5 lines · Cédric Le Goater
Since the
realize()handler of S390CCWDeviceClass takes an 'Error **' argument, best practices suggest to return a bool. See theapi/error.hRules section. While at it, modify the call invfio_ccw_realize().Signed-off-by Cédric Le Goater <[email protected]>
Quoted 72 lines
--- include/hw/s390x/s390-ccw.h | 2 +- hw/s390x/s390-ccw.c | 7 ++++--- hw/vfio/ccw.c | 3 +-- 3 files changed, 6 insertions(+), 6 deletions(-)include/hw/s390x/s390-ccw.h +1
-1@@ -31,7 +31,7 @@ struct S390CCWDevice {struct S390CCWDeviceClass {CCWDeviceClass parent_class; -void (*realize)(S390CCWDevice *dev,char *sysfsdev,Error **errp); +bool (*realize)(S390CCWDevice *dev,char *sysfsdev,Error **errp);void (*unrealize)(S390CCWDevice *dev);IOInstEnding (*handle_request) (SubchDev *sch);int (*handle_halt) (SubchDev *sch);hw/s390x/s390-ccw.c +4
-3@@ -108,7 +108,7 @@ static bool s390_ccw_get_dev_info(S390CCWDevice *cdev,return true; } -static void s390_ccw_realize (S390CCWDevice *cdev,char *sysfsdev,Error **errp) +static bool s390_ccw_realize (S390CCWDevice *cdev,char *sysfsdev,Error **errp) {CcwDevice *ccw_dev =CCW_DEVICE (cdev);CCWDeviceClass *ck =CCW_DEVICE_GET_CLASS (ccw_dev);@@ -117,7 +117,7 @@ static void s390_ccw_realize(S390CCWDevice *cdev, char *sysfsdev, Error **errp)int ret;if (!s390_ccw_get_dev_info (cdev, sysfsdev, errp)) { -return ; +return false; } sch =css_create_sch (ccw_dev->devno, errp);@@ -142,7 +142,7 @@ static void s390_ccw_realize(S390CCWDevice *cdev, char *sysfsdev, Error **errp)css_generate_sch_crws (sch->cssid, sch->ssid, sch->schid, parent->hotplugged,1 ); -return ; +return true; out_err:css_subch_assign (sch->cssid, sch->ssid, sch->schid, sch->devno,NULL );@@ -150,6 +150,7 @@ out_err:g_free (sch); out_mdevid_free:g_free (cdev->mdevid); +return false; }static void s390_ccw_unrealize (S390CCWDevice *cdev)hw/vfio/ccw.c +1
-2@@ -582,8 +582,7 @@ static void vfio_ccw_realize(DeviceState *dev, Error **errp)/* Call the class init function for subchannel. */ if (cdc->realize) { - cdc->realize (cdev, vcdev->vdev.sysfsdev, &err); -if (err) { +if (!cdc->realize (cdev, vcdev->vdev.sysfsdev, &err)) { goto out_err_propagate; } }
PATCH 5/7 vfio/ccw: Use the 'Error **errp' argument of vfio_ccw_realize()
In reply to Cédric Le GoaterThe local error variable is kept for vfio_ccw_register_irq_notifier() because it is not considered as a failing condition. We will change how error reporting is done in following changes.
Remove the error_propagate() call.
--- hw/vfio/ccw.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)
hw/vfio/ccw.c +5 -7
@@ -582,8 +582,8 @@ static void vfio_ccw_realize(DeviceState *dev, Error **errp)/* Call the class init function for subchannel. */ if (cdc->realize) { -if (!cdc->realize (cdev, vcdev->vdev.sysfsdev, &err)) { - goto out_err_propagate; +if (!cdc->realize (cdev, vcdev->vdev.sysfsdev, errp)) { +return ; } }
@@ -596,17 +596,17 @@ static void vfio_ccw_realize(DeviceState *dev, Error **errp) goto out_attach_dev_err; } -if (!vfio_ccw_get_region (vcdev, &err)) { +if (!vfio_ccw_get_region (vcdev, errp)) { goto out_region_err; } -if (!vfio_ccw_register_irq_notifier (vcdev,VFIO_CCW_IO_IRQ_INDEX , &err)) { +if (!vfio_ccw_register_irq_notifier (vcdev,VFIO_CCW_IO_IRQ_INDEX , errp)) { goto out_io_notifier_err; }if (vcdev->crw_region) {if (!vfio_ccw_register_irq_notifier (vcdev,VFIO_CCW_CRW_IRQ_INDEX , - &err)) { + errp)) { goto out_irq_notifier_err; } }
@@ -634,8 +634,6 @@ out_attach_dev_err:if (cdc->unrealize) { cdc->unrealize (cdev); } -out_err_propagate: -error_propagate (errp, err); }static void vfio_ccw_unrealize (DeviceState *dev)
Signature · 1 line
2.45.1
RE: [PATCH 5/7] vfio/ccw: Use the 'Error **errp' argument of vfio_ccw_realize()
Quoted 7 lines
-----Original Message-----
From: Cédric Le Goater <[email protected]>
Subject: [PATCH 5/7] vfio/ccw: Use the 'Error **errp' argument ofvfio_ccw_realize()
Quoted 8 lines
The local error variable is kept for
vfio_ccw_register_irq_notifier()because it is not considered as a failing condition. We will change how error reporting is done in following changes.Remove the
error_propagate()call.Cc Zhenzhong Duan <[email protected]>Signed-off-by Cédric Le Goater <[email protected]>
Thanks
Zhenzhong
Quoted 57 lines
---
hw/vfio/ccw.c| 12 +++++-------1 file changed, 5 insertions(+), 7 deletions(-)hw/vfio/ccw.c +0
-0index
9a8e052711fe2f7c067c52808b2af30d0ebfee0c..a468fa2342b97e0ee36bd5fb8443025cc90a0453100644hw/vfio/ccw.c +5
-5@@ -582,8 +582,8 @@ static void vfio_ccw_realize(DeviceState *dev, Error **errp)/* Call the class init function for subchannel. */ if (cdc->realize) { -if (!cdc->realize (cdev, vcdev->vdev.sysfsdev, &err)) { - goto out_err_propagate; +if (!cdc->realize (cdev, vcdev->vdev.sysfsdev, errp)) { +return ; } }@@ -596,17 +596,17 @@ static void vfio_ccw_realize(DeviceState *dev, Error **errp) goto out_attach_dev_err; } -if (!vfio_ccw_get_region (vcdev, &err)) { +if (!vfio_ccw_get_region (vcdev, errp)) { goto out_region_err; } -if (!vfio_ccw_register_irq_notifier (vcdev,VFIO_CCW_IO_IRQ_INDEX , &err)) { +if (!vfio_ccw_register_irq_notifier (vcdev,VFIO_CCW_IO_IRQ_INDEX , errp)) { goto out_io_notifier_err; }if (vcdev->crw_region) {if (!vfio_ccw_register_irq_notifier (vcdev,VFIO_CCW_CRW_IRQ_INDEX , - &err)) { + errp)) {goto out_irq_notifier_err; } }hw/vfio/ccw.c +0
-3@@ -634,8 +634,6 @@ out_attach_dev_err:if (cdc->unrealize) { cdc->unrealize (cdev); } -out_err_propagate: -error_propagate (errp, err); }static void vfio_ccw_unrealize (DeviceState *dev) --2.45.1
Re: [PATCH 5/7] vfio/ccw: Use the 'Error **errp' argument of vfio_ccw_realize()
In reply to Cédric Le GoaterQuoted 8 lines · Cédric Le Goater
The local error variable is kept for
vfio_ccw_register_irq_notifier()because it is not considered as a failing condition. We will change how error reporting is done in following changes.Remove the
error_propagate()call.Cc Zhenzhong Duan <[email protected]>Signed-off-by Cédric Le Goater <[email protected]>
Quoted 49 lines
--- hw/vfio/ccw.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)hw/vfio/ccw.c +5
-7@@ -582,8 +582,8 @@ static void vfio_ccw_realize(DeviceState *dev, Error **errp)/* Call the class init function for subchannel. */ if (cdc->realize) { -if (!cdc->realize (cdev, vcdev->vdev.sysfsdev, &err)) { - goto out_err_propagate; +if (!cdc->realize (cdev, vcdev->vdev.sysfsdev, errp)) { +return ; } }@@ -596,17 +596,17 @@ static void vfio_ccw_realize(DeviceState *dev, Error **errp) goto out_attach_dev_err; } -if (!vfio_ccw_get_region (vcdev, &err)) { +if (!vfio_ccw_get_region (vcdev, errp)) { goto out_region_err; } -if (!vfio_ccw_register_irq_notifier (vcdev,VFIO_CCW_IO_IRQ_INDEX , &err)) { +if (!vfio_ccw_register_irq_notifier (vcdev,VFIO_CCW_IO_IRQ_INDEX , errp)) { goto out_io_notifier_err; }if (vcdev->crw_region) {if (!vfio_ccw_register_irq_notifier (vcdev,VFIO_CCW_CRW_IRQ_INDEX , - &err)) { + errp)) { goto out_irq_notifier_err; } }@@ -634,8 +634,6 @@ out_attach_dev_err:if (cdc->unrealize) { cdc->unrealize (cdev); } -out_err_propagate: -error_propagate (errp, err); }static void vfio_ccw_unrealize (DeviceState *dev)
PATCH 6/7 vfio/ccw: Fix the missed unrealize() call in error path
In reply to Cédric Le GoaterFrom: Zhenzhong Duan <[email protected]>
When get name failed, we should call unrealize() so that vfio_ccw_realize() is self contained.
--- hw/vfio/ccw.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
hw/vfio/ccw.c +2 -1
@@ -588,7 +588,7 @@ static void vfio_ccw_realize(DeviceState *dev, Error **errp) }if (!vfio_device_get_name (vbasedev, errp)) { -return ; + goto out_unrealize; } if (!vfio_attach_device(cdev->mdevid, vbasedev,
@@ -631,6 +631,7 @@ out_region_err:vfio_detach_device (vbasedev); out_attach_dev_err:g_free (vbasedev->name); +out_unrealize:if (cdc->unrealize) { cdc->unrealize (cdev); }
Signature · 1 line
2.45.1
Re: [PATCH 6/7] vfio/ccw: Fix the missed unrealize() call in error path
Quoted 7 lines · Cédric Le Goater
From: Zhenzhong Duan <[email protected]>
When get name failed, we should call
unrealize()so thatvfio_ccw_realize()is self contained.Fixes 909a6254eda ("vfio/ccw: Make vfio cdev pre-openable by passing a file handle")Signed-off-by Zhenzhong Duan <[email protected]>
Thanks,
C.
Quoted 25 lines
--- hw/vfio/ccw.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)hw/vfio/ccw.c +2
-1@@ -588,7 +588,7 @@ static void vfio_ccw_realize(DeviceState *dev, Error **errp) }if (!vfio_device_get_name (vbasedev, errp)) { -return ; + goto out_unrealize; } if (!vfio_attach_device(cdev->mdevid, vbasedev,@@ -631,6 +631,7 @@ out_region_err:vfio_detach_device (vbasedev); out_attach_dev_err:g_free (vbasedev->name); +out_unrealize:if (cdc->unrealize) { cdc->unrealize (cdev); }
PATCH 7/7 vfio/{ap, ccw}: Use warn_report_err() for IRQ notifier registration errors
In reply to Cédric Le Goatervfio_ccw_register_irq_notifier() and vfio_ap_register_irq_notifier() errors are currently reported using error_report_err(). Since they are not considered as failing conditions, using warn_report_err() is more appropriate.
--- hw/vfio/ap.c | 2 +- hw/vfio/ccw.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
hw/vfio/ap.c +1 -1
@@ -172,7 +172,7 @@ static void vfio_ap_realize(DeviceState *dev, Error **errp)* Report this error, but do not make it a failing condition. * Lack of this IRQ in the host does not prevent normal operation. */ -error_report_err (err); +warn_report_err (err); }return ;
hw/vfio/ccw.c +1 -1
@@ -616,7 +616,7 @@ static void vfio_ccw_realize(DeviceState *dev, Error **errp)* Report this error, but do not make it a failing condition. * Lack of this IRQ in the host does not prevent normal operation. */ -error_report_err (err); +warn_report_err (err); }return ;
Signature · 1 line
2.45.1
RE: [PATCH 7/7] vfio/{ap, ccw}: Use warn_report_err() for IRQ notifier registration errors
Quoted 7 lines
-----Original Message-----
From: Cédric Le Goater <[email protected]>
Subject: [PATCH 7/7] vfio/{ap,ccw}: Usewarn_report_err()for IRQ notifier registration errors
Quoted 6 lines
vfio_ccw_register_irq_notifier()andvfio_ap_register_irq_notifier()errors are currently reported usingerror_report_err(). Since they are not considered as failing conditions, usingwarn_report_err()is more appropriate.Signed-off-by Cédric Le Goater <[email protected]>
Thanks
Zhenzhong
Quoted 39 lines
---
hw/vfio/ap.c| 2 +-hw/vfio/ccw.c| 2 +-2 files changed, 2 insertions(+), 2 deletions(-)hw/vfio/ap.c +0
-0index
c12531a7886a2fe87598be0861fba5923bd2c206..0c4354e3e70169ec072e16da0919936647d1d351100644hw/vfio/ap.c +1
-1@@ -172,7 +172,7 @@ static void vfio_ap_realize(DeviceState *dev, Error**errp) * Report this error, but do not make it a failing condition. * Lack of this IRQ in the host does not prevent normal operation. */ -error_report_err (err); +warn_report_err (err); }return;hw/vfio/ccw.c +0
-0index
36f2677a448c5e31523dcc3de7d973ec70e4a13c..1f8e1272c7555cd0a770481d1ae92988f6e2e62e100644hw/vfio/ccw.c +1
-1@@ -616,7 +616,7 @@ static void vfio_ccw_realize(DeviceState *dev, Error**errp) * Report this error, but do not make it a failing condition. * Lack of this IRQ in the host does not prevent normal operation. */ -error_report_err (err); +warn_report_err (err); }return;--
2.45.1
Re: [PATCH 7/7] vfio/{ap, ccw}: Use warn_report_err() for IRQ notifier registration errors
In reply to Cédric Le GoaterQuoted 6 lines · Cédric Le Goater
vfio_ccw_register_irq_notifier()andvfio_ap_register_irq_notifier()errors are currently reported usingerror_report_err(). Since they are not considered as failing conditions, usingwarn_report_err()is more appropriate.Signed-off-by Cédric Le Goater <[email protected]>
Quoted 31 lines
--- hw/vfio/ap.c | 2 +- hw/vfio/ccw.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)hw/vfio/ap.c +1
-1@@ -172,7 +172,7 @@ static void vfio_ap_realize(DeviceState *dev, Error **errp)* Report this error, but do not make it a failing condition. * Lack of this IRQ in the host does not prevent normal operation. */ -error_report_err (err); +warn_report_err (err); }return ;hw/vfio/ccw.c +1
-1@@ -616,7 +616,7 @@ static void vfio_ccw_realize(DeviceState *dev, Error **errp)* Report this error, but do not make it a failing condition. * Lack of this IRQ in the host does not prevent normal operation. */ -error_report_err (err); +warn_report_err (err); }return ;
Quoted 28 lines · Cédric Le Goater
Hello,
The first patches of this series simply apply the practices described in the Rules section of the
qapi/error.hfile for routines taking an 'Error **' argument. The remaining patches are a fixup in the error path ofvfio_ccw_realize()and some error reporting adjustements.Applies on top of this vfio PR :
https://lore.kernel.org/qemu-devel/[email protected]Thanks,
C.
Cédric Le Goater (6):
hw/s390x/ccw: Makes390_ccw_get_dev_info()return a bool s390x/css: MakeCCWDeviceClass::realizereturn bool hw/s390x/ccw: Remove local Error variable froms390_ccw_realize()s390x/css: MakeS390CCWDeviceClass::realizereturn bool vfio/ccw: Use the 'Error **errp' argument ofvfio_ccw_realize()vfio/{ap,ccw}: Usewarn_report_err()for IRQ notifier registration errorsZhenzhong Duan (1):
vfio/ccw: Fix the missedunrealize()call in error path
Quoted 8 lines
hw/s390x/ccw-device.h | 2 +-
include/hw/s390x/s390-ccw.h| 2 +- hw/s390x/ccw-device.c | 3 ++- hw/s390x/s390-ccw.c | 29 +++++++++++++---------------- hw/vfio/ap.c | 2 +-
hw/vfio/ccw.c | 18 ++++++++----------6 files changed, 26 insertions(+), 30 deletions(-)
Quoted 15 lines · Cédric Le Goater
Hello,
The first patches of this series simply apply the practices described in the Rules section of the
qapi/error.hfile for routines taking an 'Error **' argument. The remaining patches are a fixup in the error path ofvfio_ccw_realize()and some error reporting adjustements.Applies on top of this vfio PR :
https://lore.kernel.org/qemu-devel/[email protected]Thanks,
C.
Quoted 8 lines
Cédric Le Goater (6):
hw/s390x/ccw: Makes390_ccw_get_dev_info()return a bool s390x/css: MakeCCWDeviceClass::realizereturn bool hw/s390x/ccw: Remove local Error variable froms390_ccw_realize()s390x/css: MakeS390CCWDeviceClass::realizereturn bool vfio/ccw: Use the 'Error **errp' argument ofvfio_ccw_realize()vfio/{ap,ccw}: Usewarn_report_err()for IRQ notifier registration
errors
Series
Cédric Le Goater
AppliedQuoted 25 lines · Thomas Huth
Quoted 15 lines · Cédric Le Goater
Hello,
The first patches of this series simply apply the practices described in the Rules section of the
qapi/error.hfile for routines taking an 'Error **' argument. The remaining patches are a fixup in the error path ofvfio_ccw_realize()and some error reporting adjustements.Applies on top of this vfio PR :
https://lore.kernel.org/qemu-devel/[email protected]
Thanks,
C.
Quoted 8 lines
Cédric Le Goater (6):
hw/s390x/ccw: Makes390_ccw_get_dev_info()return a bool s390x/css: MakeCCWDeviceClass::realizereturn bool hw/s390x/ccw: Remove local Error variable froms390_ccw_realize()s390x/css: MakeS390CCWDeviceClass::realizereturn bool vfio/ccw: Use the 'Error **errp' argument ofvfio_ccw_realize()vfio/{ap,ccw}: Usewarn_report_err()for IRQ notifier registration errors
Quoted 3 lines
Series
Reviewed-by Thomas Huth <[email protected]>
Applied to vfio-next.
Thanks,
C.