diff mbox

[06/11] tpm: Avoid qerror_report() outside QMP command handlers

Message ID 1434205258-1932-7-git-send-email-armbru@redhat.com
State New
Headers show

Commit Message

Markus Armbruster June 13, 2015, 2:20 p.m. UTC
qerror_report() is a transitional interface to help with converting
existing monitor commands to QMP.  It should not be used elsewhere.
Replace by error_report().

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 tpm.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

Comments

Eric Blake June 15, 2015, 8:37 p.m. UTC | #1
On 06/13/2015 08:20 AM, Markus Armbruster wrote:
> qerror_report() is a transitional interface to help with converting
> existing monitor commands to QMP.  It should not be used elsewhere.
> Replace by error_report().
> 
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> ---
>  tpm.c | 10 ++++------
>  1 file changed, 4 insertions(+), 6 deletions(-)
> 
> diff --git a/tpm.c b/tpm.c
> index 99a9895..224e65e 100644
> --- a/tpm.c
> +++ b/tpm.c
> @@ -140,23 +140,21 @@ static int configure_tpm(QemuOpts *opts)
>  
>      id = qemu_opts_id(opts);
>      if (id == NULL) {
> -        qerror_report(ERROR_CLASS_GENERIC_ERROR, QERR_MISSING_PARAMETER, "id");
> +        error_report(QERR_MISSING_PARAMETER, "id");

Ah, this fixes a hunk difference I pointed out in 5/11.  If you need to
rebase, I'd consider rearranging to put this patch first, so that the
mechanical 5/11 is even more mechanical (limited to just error_setg
conversion).  But that's not enough reason in itself for a respin, so:

Reviewed-by: Eric Blake <eblake@redhat.com>
Markus Armbruster June 16, 2015, 1:07 p.m. UTC | #2
Eric Blake <eblake@redhat.com> writes:

> On 06/13/2015 08:20 AM, Markus Armbruster wrote:
>> qerror_report() is a transitional interface to help with converting
>> existing monitor commands to QMP.  It should not be used elsewhere.
>> Replace by error_report().
>> 
>> Signed-off-by: Markus Armbruster <armbru@redhat.com>
>> ---
>>  tpm.c | 10 ++++------
>>  1 file changed, 4 insertions(+), 6 deletions(-)
>> 
>> diff --git a/tpm.c b/tpm.c
>> index 99a9895..224e65e 100644
>> --- a/tpm.c
>> +++ b/tpm.c
>> @@ -140,23 +140,21 @@ static int configure_tpm(QemuOpts *opts)
>>  
>>      id = qemu_opts_id(opts);
>>      if (id == NULL) {
>> -        qerror_report(ERROR_CLASS_GENERIC_ERROR, QERR_MISSING_PARAMETER, "id");
>> +        error_report(QERR_MISSING_PARAMETER, "id");
>
> Ah, this fixes a hunk difference I pointed out in 5/11.  If you need to
> rebase, I'd consider rearranging to put this patch first, so that the
> mechanical 5/11 is even more mechanical (limited to just error_setg
> conversion).

While that would make PATCH 05 a bit more mechanical, this one would
become quite a bit uglier, because I can't directly pass
QERR_MISSING_PARAMETER to any of the error_report() functions.

I'd either have to create an Error to pass to error_report_err(), or
drop the unwanted error class by wrapping parenthesis around
QERR_MISSING_PARAMETER to turn its comma into a comma operator.  Ugh.

>               But that's not enough reason in itself for a respin, so:
>
> Reviewed-by: Eric Blake <eblake@redhat.com>

Thanks!
diff mbox

Patch

diff --git a/tpm.c b/tpm.c
index 99a9895..224e65e 100644
--- a/tpm.c
+++ b/tpm.c
@@ -140,23 +140,21 @@  static int configure_tpm(QemuOpts *opts)
 
     id = qemu_opts_id(opts);
     if (id == NULL) {
-        qerror_report(ERROR_CLASS_GENERIC_ERROR, QERR_MISSING_PARAMETER, "id");
+        error_report(QERR_MISSING_PARAMETER, "id");
         return 1;
     }
 
     value = qemu_opt_get(opts, "type");
     if (!value) {
-        qerror_report(ERROR_CLASS_GENERIC_ERROR, QERR_MISSING_PARAMETER,
-                      "type");
+        error_report(QERR_MISSING_PARAMETER, "type");
         tpm_display_backend_drivers();
         return 1;
     }
 
     be = tpm_get_backend_driver(value);
     if (be == NULL) {
-        qerror_report(ERROR_CLASS_GENERIC_ERROR,
-                      QERR_INVALID_PARAMETER_VALUE, "type",
-                      "a TPM backend type");
+        error_report(QERR_INVALID_PARAMETER_VALUE, "type",
+                     "a TPM backend type");
         tpm_display_backend_drivers();
         return 1;
     }