qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Alex Bennée" <alex.bennee@linaro.org>
To: "Liu, Changpeng" <changpeng.liu@intel.com>
Cc: "qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
	Jason Wang <jasowang@redhat.com>,
	Michael S. Tsirkin <mst@redhat.com>
Subject: Re: [PATCH 1/2] hw/virtio/vhost-user: don't use uninitialized variable
Date: Thu, 02 Jun 2022 09:27:38 +0100	[thread overview]
Message-ID: <87tu93v4qj.fsf@linaro.org> (raw)
In-Reply-To: <PH0PR11MB50934D0391B918A38DD2488EEEDF9@PH0PR11MB5093.namprd11.prod.outlook.com>


"Liu, Changpeng" <changpeng.liu@intel.com> writes:

>> -----Original Message-----
>> From: Alex Bennée <alex.bennee@linaro.org>
>> Sent: Tuesday, May 31, 2022 10:46 PM
>> To: Liu, Changpeng <changpeng.liu@intel.com>
>> Cc: qemu-devel@nongnu.org
>> Subject: Re: [PATCH 1/2] hw/virtio/vhost-user: don't use uninitialized variable
>> 
>> 
>> Changpeng Liu <changpeng.liu@intel.com> writes:
>> 
>> > Variable `vdev` in `struct vhost_dev` will not be ready
>> > until start the device, so let's not use it for the error
>> > output here.
>> 
>> This seems to be one of the areas where vhost_user_backend_dev_init and
>> vhost_dev_init do things differently. Is there any particular reason why
>> we couldn't initialise hdev->vdev consistently at init time?
> vhost_dev_init() set hdev->vdev to NULL, and vhost_dev_start() set it to VirtIODevice,
> it's consistent, they are common APIs designed for vhost-kernel and
> vhost-user.

Ahh vhost_user_backend_dev_init actually sets VhostUserBackend->vdev
right before calling vhost_dev_init during it's realize phase.

There is definitely some scope for rationalisation here given we know
the type at realize. Why delay setting it?

It looks like this all came in with c471ad0e9b (vhost_net: device IOTLB
support).

>> 
>> >
>> > Fixes: 5653493 ("hw/virtio/vhost-user: don't suppress F_CONFIG when
>> supported")
>> >
>> > Signed-off-by: Changpeng Liu <changpeng.liu@intel.com>
>> > ---
>> >  hw/virtio/vhost-user.c | 8 +++-----
>> >  1 file changed, 3 insertions(+), 5 deletions(-)
>> >
>> > diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c
>> > index b040c1ad2b..0594178224 100644
>> > --- a/hw/virtio/vhost-user.c
>> > +++ b/hw/virtio/vhost-user.c
>> > @@ -2031,18 +2031,16 @@ static int vhost_user_backend_init(struct
>> vhost_dev *dev, void *opaque,
>> >          if (supports_f_config) {
>> >              if (!virtio_has_feature(protocol_features,
>> >                                      VHOST_USER_PROTOCOL_F_CONFIG)) {
>> > -                error_setg(errp, "vhost-user device %s expecting "
>> > +                error_setg(errp, "vhost-user device expecting "
>> >                             "VHOST_USER_PROTOCOL_F_CONFIG but the vhost-user
>> backend does "
>> > -                           "not support it.", dev->vdev->name);
>> > +                           "not support it.");
>> >                  return -EPROTO;
>> >              }
>> >          } else {
>> >              if (virtio_has_feature(protocol_features,
>> >                                     VHOST_USER_PROTOCOL_F_CONFIG)) {
>> >                  warn_reportf_err(*errp, "vhost-user backend supports "
>> > -                                 "VHOST_USER_PROTOCOL_F_CONFIG for "
>> > -                                 "device %s but QEMU does not.",
>> > -                                 dev->vdev->name);
>> > +                                 "VHOST_USER_PROTOCOL_F_CONFIG but QEMU does not.");
>> >                  protocol_features &= ~(1ULL << VHOST_USER_PROTOCOL_F_CONFIG);
>> >              }
>> >          }
>> 
>> 
>> --
>> Alex Bennée


-- 
Alex Bennée


      reply	other threads:[~2022-06-02  8:41 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-25 12:55 [PATCH 1/2] hw/virtio/vhost-user: don't use uninitialized variable Changpeng Liu
2022-05-25 12:55 ` [PATCH 2/2] hw/vhost-user-scsi|blk: set `supports_config` flag correctly Changpeng Liu
2022-05-31  5:40   ` Raphael Norwitz
2022-05-31  5:21 ` [PATCH 1/2] hw/virtio/vhost-user: don't use uninitialized variable Raphael Norwitz
2022-05-31 14:45 ` Alex Bennée
2022-06-01  0:58   ` Liu, Changpeng
2022-06-02  8:27     ` Alex Bennée [this message]

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=87tu93v4qj.fsf@linaro.org \
    --to=alex.bennee@linaro.org \
    --cc=changpeng.liu@intel.com \
    --cc=jasowang@redhat.com \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).