From: Markus Armbruster <armbru@redhat.com>
To: Li Feng <fengli@smartx.com>
Cc: Raphael Norwitz <raphael.norwitz@nutanix.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
Paolo Bonzini <pbonzini@redhat.com>, Fam Zheng <fam@euphon.net>,
"open list:All patches CC here" <qemu-devel@nongnu.org>
Subject: Re: [PATCH 2/2] vhost: Add Error parameter to vhost_scsi_common_start()
Date: Mon, 21 Aug 2023 14:09:57 +0200 [thread overview]
Message-ID: <87o7j0egve.fsf@pond.sub.org> (raw)
In-Reply-To: <844CBDD0-E0A9-4097-904E-5CD74C2884AD@smartx.com> (Li Feng's message of "Thu, 17 Aug 2023 14:49:53 +0800")
Li Feng <fengli@smartx.com> writes:
>> 2023年8月14日 下午8:11,Raphael Norwitz <raphael.norwitz@nutanix.com> 写道:
>>
>> Thanks for the cleanup! A few comments.
>>
>>> On Aug 4, 2023, at 1:29 AM, Li Feng <fengli@smartx.com> wrote:
>>>
>>> Add a Error parameter to report the real error, like vhost-user-blk.
>>>
>>> Signed-off-by: Li Feng <fengli@smartx.com>
>>> ---
>>> hw/scsi/vhost-scsi-common.c | 17 ++++++++++-------
>>> hw/scsi/vhost-scsi.c | 5 +++--
>>> hw/scsi/vhost-user-scsi.c | 14 ++++++++------
>>> include/hw/virtio/vhost-scsi-common.h | 2 +-
>>> 4 files changed, 22 insertions(+), 16 deletions(-)
>>>
>>> diff --git a/hw/scsi/vhost-scsi-common.c b/hw/scsi/vhost-scsi-common.c
>>> index a61cd0e907..392587dfb5 100644
>>> --- a/hw/scsi/vhost-scsi-common.c
>>> +++ b/hw/scsi/vhost-scsi-common.c
>>> @@ -16,6 +16,7 @@
>>> */
>>>
>>> #include "qemu/osdep.h"
>>> +#include "qapi/error.h"
>>> #include "qemu/error-report.h"
>>> #include "qemu/module.h"
>>> #include "hw/virtio/vhost.h"
>>> @@ -25,7 +26,7 @@
>>> #include "hw/virtio/virtio-access.h"
>>> #include "hw/fw-path-provider.h"
>>>
>>> -int vhost_scsi_common_start(VHostSCSICommon *vsc)
>>> +int vhost_scsi_common_start(VHostSCSICommon *vsc, Error **errp)
>>> {
>>> int ret, i;
>>> VirtIODevice *vdev = VIRTIO_DEVICE(vsc);
>>> @@ -35,18 +36,19 @@ int vhost_scsi_common_start(VHostSCSICommon *vsc)
>>> VirtIOSCSICommon *vs = (VirtIOSCSICommon *)vsc;
>>>
>>> if (!k->set_guest_notifiers) {
>>> - error_report("binding does not support guest notifiers");
>>> + error_setg(errp, "binding does not support guest notifiers");
>>> return -ENOSYS;
>>> }
>>>
>>> ret = vhost_dev_enable_notifiers(&vsc->dev, vdev);
>>> if (ret < 0) {
>>> + error_setg_errno(errp, -ret, "Error enabling host notifiers");
>>> return ret;
>>> }
>>>
>>> ret = k->set_guest_notifiers(qbus->parent, vsc->dev.nvqs, true);
>>> if (ret < 0) {
>>> - error_report("Error binding guest notifier");
>>> + error_setg_errno(errp, -ret, "Error binding guest notifier");
>>> goto err_host_notifiers;
>>> }
>>>
>>> @@ -54,7 +56,7 @@ int vhost_scsi_common_start(VHostSCSICommon *vsc)
>>>
>>> ret = vhost_dev_prepare_inflight(&vsc->dev, vdev);
>>> if (ret < 0) {
>>> - error_report("Error setting inflight format: %d", -ret);
>>
>> Curious why you’re adding the error value to the string. Isn’t it redundant since we pass it in as the second param?
>>
>>> + error_setg_errno(errp, -ret, "Error setting inflight format: %d", -ret);
>
> I don’t understand. Here I put the error message in errp, where is redundant?
The error message will come out like
Error setting inflight format: 22: Invalid argument
You need to drop ": %d".
Two remarks:
1. The #1 reason for bad error messages is neglecting to *test* them.
2. Printing errno as a number is needlessly unfriendly to users.
[...]
next prev parent reply other threads:[~2023-08-21 12:10 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-04 5:29 [PATCH 0/2] Fix vhost reconnect issues Li Feng
2023-08-04 5:29 ` [PATCH 1/2] vhost-user: fix lost reconnect Li Feng
2023-08-14 12:11 ` Raphael Norwitz
2023-08-17 6:40 ` Li Feng
2023-08-22 0:38 ` Raphael Norwitz
2023-08-22 4:49 ` Li Feng
2023-08-22 10:17 ` Raphael Norwitz
2023-08-24 7:27 ` Li Feng
2023-08-04 5:29 ` [PATCH 2/2] vhost: Add Error parameter to vhost_scsi_common_start() Li Feng
2023-08-14 12:11 ` Raphael Norwitz
2023-08-17 6:49 ` Li Feng
2023-08-21 12:09 ` Markus Armbruster [this message]
2023-08-22 4:47 ` Li Feng
2023-08-24 7:41 ` [PATCH v2 0/2] Fix vhost reconnect issues Li Feng
2023-08-24 7:41 ` [PATCH v2 1/2] vhost-user: Fix lost reconnect Li Feng
2023-08-29 22:11 ` Raphael Norwitz
2023-08-30 4:51 ` Li Feng
2023-08-24 7:41 ` [PATCH v2 2/2] vhost: Add Error parameter to vhost_scsi_common_start() Li Feng
2023-08-29 22:20 ` Raphael Norwitz
2023-08-30 4:57 ` [PATCH v3 0/2] Fix vhost reconnect issues Li Feng
2023-08-30 4:57 ` [PATCH v3 1/2] vhost-user: Fix lost reconnect Li Feng
2023-08-30 8:47 ` Raphael Norwitz
2023-08-30 4:57 ` [PATCH v3 2/2] vhost: Add Error parameter to vhost_scsi_common_start() Li Feng
2023-08-30 8:51 ` Raphael Norwitz
2023-09-01 12:00 ` Markus Armbruster
2023-09-12 8:32 ` Li Feng
2023-10-01 20:00 ` Michael S. Tsirkin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87o7j0egve.fsf@pond.sub.org \
--to=armbru@redhat.com \
--cc=fam@euphon.net \
--cc=fengli@smartx.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=raphael.norwitz@nutanix.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.