Re: [Qemu-devel] [PATCH v5 2/5] util: Use new error_report_fatal/abort instead of error_setg(_fatal/abort)

2016-01-30 Thread David Gibson
On Fri, Jan 29, 2016 at 02:33:08PM +0100, Lluís Vilanova wrote:
> David Gibson writes:
> 
> > On Thu, Jan 28, 2016 at 10:53:43PM +0100, Lluís Vilanova wrote:
> >> Replaces all direct uses of 'error_setg(_fatal/abort)' with
> >> 'error_report_fatal/abort'. Also reimplements the former on top of the
> >> latter.
> >> 
> >> Signed-off-by: Lluís Vilanova 
> 
> > I think the spapr parts of this will be obsoleted by the cleanups to
> > error handling included in the pull request I sent today.
> 
> Ok, then I'll rebase once merged. Is there an ETA for the merge?

Well, I'd been hoping a couple of days ago, but there were some
mistakes in the last pull request, so.. sometime this week, I hope?

-- 
David Gibson| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au  | minimalist, thank you.  NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson


signature.asc
Description: PGP signature


Re: [Qemu-devel] [PATCH v5 2/5] util: Use new error_report_fatal/abort instead of error_setg(_fatal/abort)

2016-01-29 Thread Lluís Vilanova
David Gibson writes:

> On Thu, Jan 28, 2016 at 10:53:43PM +0100, Lluís Vilanova wrote:
>> Replaces all direct uses of 'error_setg(_fatal/abort)' with
>> 'error_report_fatal/abort'. Also reimplements the former on top of the
>> latter.
>> 
>> Signed-off-by: Lluís Vilanova 

> I think the spapr parts of this will be obsoleted by the cleanups to
> error handling included in the pull request I sent today.

Ok, then I'll rebase once merged. Is there an ETA for the merge?

Thanks,
  Lluis



Re: [Qemu-devel] [PATCH v5 2/5] util: Use new error_report_fatal/abort instead of error_setg(_fatal/abort)

2016-01-28 Thread David Gibson
On Thu, Jan 28, 2016 at 10:53:43PM +0100, Lluís Vilanova wrote:
> Replaces all direct uses of 'error_setg(_fatal/abort)' with
> 'error_report_fatal/abort'. Also reimplements the former on top of the
> latter.
> 
> Signed-off-by: Lluís Vilanova 

I think the spapr parts of this will be obsoleted by the cleanups to
error handling included in the pull request I sent today.
-- 
David Gibson| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au  | minimalist, thank you.  NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson


signature.asc
Description: PGP signature


[Qemu-devel] [PATCH v5 2/5] util: Use new error_report_fatal/abort instead of error_setg(_fatal/abort)

2016-01-28 Thread Lluís Vilanova
Replaces all direct uses of 'error_setg(_fatal/abort)' with
'error_report_fatal/abort'. Also reimplements the former on top of the
latter.

Signed-off-by: Lluís Vilanova 
---
 hw/block/fdc.c |6 +++---
 hw/ppc/spapr.c |8 
 hw/ppc/spapr_drc.c |2 +-
 util/error.c   |9 +++--
 4 files changed, 11 insertions(+), 14 deletions(-)

diff --git a/hw/block/fdc.c b/hw/block/fdc.c
index e3b0e1e..8f0c947 100644
--- a/hw/block/fdc.c
+++ b/hw/block/fdc.c
@@ -347,9 +347,9 @@ static int pick_geometry(FDrive *drv)
 
 /* No match of any kind found -- fd_format is misconfigured, abort. */
 if (match == -1) {
-error_setg(_abort, "No candidate geometries present in table "
-   " for floppy drive type '%s'",
-   FloppyDriveType_lookup[drv->drive]);
+error_report_abort("No candidate geometries present in table "
+   " for floppy drive type '%s'",
+   FloppyDriveType_lookup[drv->drive]);
 }
 
 parse = &(fd_formats[match]);
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 50e5a26..a5afea1 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -1031,7 +1031,7 @@ static void spapr_alloc_htab(sPAPRMachineState *spapr)
  * For HV KVM, host kernel will return -ENOMEM when requested
  * HTAB size can't be allocated.
  */
-error_setg(_abort, "Failed to allocate HTAB of requested size, 
try with smaller maxmem");
+error_report_abort("Failed to allocate HTAB of requested size, try 
with smaller maxmem");
 } else if (shift > 0) {
 /*
  * Kernel handles htab, we don't need to allocate one
@@ -1040,7 +1040,7 @@ static void spapr_alloc_htab(sPAPRMachineState *spapr)
  * but we don't allow booting of such guests.
  */
 if (shift != spapr->htab_shift) {
-error_setg(_abort, "Failed to allocate HTAB of requested 
size, try with smaller maxmem");
+error_report_abort("Failed to allocate HTAB of requested size, try 
with smaller maxmem");
 }
 
 spapr->htab_shift = shift;
@@ -1071,10 +1071,10 @@ static void spapr_reset_htab(sPAPRMachineState *spapr)
 
 shift = kvmppc_reset_htab(spapr->htab_shift);
 if (shift < 0) {
-error_setg(_abort, "Failed to reset HTAB");
+error_report_abort("Failed to reset HTAB");
 } else if (shift > 0) {
 if (shift != spapr->htab_shift) {
-error_setg(_abort, "Requested HTAB allocation failed during 
reset");
+error_report_abort("Requested HTAB allocation failed during 
reset");
 }
 
 /* Tell readers to update their file descriptor */
diff --git a/hw/ppc/spapr_drc.c b/hw/ppc/spapr_drc.c
index dccb908..0d8f5b4 100644
--- a/hw/ppc/spapr_drc.c
+++ b/hw/ppc/spapr_drc.c
@@ -322,7 +322,7 @@ static void prop_get_fdt(Object *obj, Visitor *v, void 
*opaque,
 break;
 }
 default:
-error_setg(_abort, "device FDT in unexpected state: %d", 
tag);
+error_report_abort("device FDT in unexpected state: %d", tag);
 }
 fdt_offset = fdt_offset_next;
 } while (fdt_depth != 0);
diff --git a/util/error.c b/util/error.c
index 57303fd..b8a9120 100644
--- a/util/error.c
+++ b/util/error.c
@@ -30,15 +30,12 @@ Error *error_fatal;
 
 static void error_handle_fatal(Error **errp, Error *err)
 {
+/* None of them has a hint, so error_report_err() is not necessary here */
 if (errp == _abort) {
-fprintf(stderr, "Unexpected error in %s() at %s:%d:\n",
-err->func, err->src, err->line);
-error_report_err(err);
-abort();
+error_report_abort_internal("%s", err->msg);
 }
 if (errp == _fatal) {
-error_report_err(err);
-exit(1);
+error_report_fatal("%s", err->msg);
 }
 }