qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
To: qemu-block@nongnu.org
Cc: "Li Feng" <fengli@smartx.com>,
	"Markus Armbruster" <armbru@redhat.com>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	"Raphael Norwitz" <raphael.norwitz@nutanix.com>,
	"Kevin Wolf" <kwolf@redhat.com>,
	"Hanna Reitz" <hreitz@redhat.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Fam Zheng" <fam@euphon.net>,
	"Alex Benné e" <alex.bennee@linaro.org>,
	"Viresh Kumar" <viresh.kumar@linaro.org>,
	qemu-devel@nongnu.org
Subject: Re: [PATCH v7 3/5] vhost-user-scsi: support reconnect to backend
Date: Sun, 08 Oct 2023 13:46:09 +0300	[thread overview]
Message-ID: <27ldj.4hqzhrkvm1st@linaro.org> (raw)
In-Reply-To: <20231008091220.870171-4-fengli@smartx.com>

Hello Li, I have some trivial style comments you could possibly address 
in a next version:

On Sun, 08 Oct 2023 12:12, Li Feng <fengli@smartx.com> wrote:
>diff --git a/hw/scsi/vhost-user-scsi.c b/hw/scsi/vhost-user-scsi.c
>index df6b66cc1a..5df24faff4 100644
>--- a/hw/scsi/vhost-user-scsi.c
>+++ b/hw/scsi/vhost-user-scsi.c
>@@ -39,26 +39,56 @@ static const int user_feature_bits[] = {
>     VHOST_INVALID_FEATURE_BIT
> };
> 
>+static int vhost_user_scsi_start(VHostUserSCSI *s, Error **errp)
>+{
>+    VHostSCSICommon *vsc = VHOST_SCSI_COMMON(s);
>+    int ret;
>+
>+    ret = vhost_scsi_common_start(vsc, errp);
>+    s->started_vu = (ret < 0 ? false : true);

-+    s->started_vu = (ret < 0 ? false : true);
++    s->started_vu = !(ret < 0);

> static void vhost_user_scsi_set_status(VirtIODevice *vdev, uint8_t 
> status)
> {
>     VHostUserSCSI *s = (VHostUserSCSI *)vdev;
>+    DeviceState *dev = &s->parent_obj.parent_obj.parent_obj.parent_obj;

-+    DeviceState *dev = &s->parent_obj.parent_obj.parent_obj.parent_obj;
++    DeviceState *dev = DEVICE(vdev);

>+static int vhost_user_scsi_connect(DeviceState *dev, Error **errp)
>+{
>+    VirtIODevice *vdev = VIRTIO_DEVICE(dev);
>+    VHostUserSCSI *s = VHOST_USER_SCSI(vdev);
>+    VHostSCSICommon *vsc = VHOST_SCSI_COMMON(s);
>+    VirtIOSCSICommon *vs = VIRTIO_SCSI_COMMON(dev);
>+    int ret = 0;
>+
>+    if (s->connected) {
>+        return 0;
>+    }
>+    s->connected = true;
>+
>+    vsc->dev.num_queues = vs->conf.num_queues;
>+    vsc->dev.nvqs = VIRTIO_SCSI_VQ_NUM_FIXED + vs->conf.num_queues;
>+    vsc->dev.vqs = s->vhost_vqs;
>+    vsc->dev.vq_index = 0;
>+    vsc->dev.backend_features = 0;
>+
>+    ret = vhost_dev_init(&vsc->dev, &s->vhost_user, VHOST_BACKEND_TYPE_USER, 0,
>+                         errp);
>+    if (ret < 0) {
>+        return ret;
>+    }
>+
>+    /* restore vhost state */
>+    if (virtio_device_started(vdev, vdev->status)) {
>+        ret = vhost_user_scsi_start(s, errp);
>+        if (ret < 0) {
>+            return ret;
>+        }
>+    }
>+
>+    return 0;
>+}


-+    if (virtio_device_started(vdev, vdev->status)) {
-+        ret = vhost_user_scsi_start(s, errp);
-+        if (ret < 0) {
-+            return ret;
-+        }
-+    }
-+
-+    return 0;
-+}
++    if (virtio_device_started(vdev, vdev->status)) {
++        ret = vhost_user_scsi_start(s, errp);
++    }
++
++    return ret;
++}

[skipping..]

>+static int vhost_user_scsi_realize_connect(VHostUserSCSI *s, Error **errp)
>+{
>+    DeviceState *dev = &s->parent_obj.parent_obj.parent_obj.parent_obj;


-+    DeviceState *dev = &s->parent_obj.parent_obj.parent_obj.parent_obj;
++    DeviceState *dev = DEVICE(s);

>diff --git a/include/hw/virtio/vhost-user-scsi.h b/include/hw/virtio/vhost-user-scsi.h
>index 521b08e559..b405ec952a 100644
>--- a/include/hw/virtio/vhost-user-scsi.h
>+++ b/include/hw/virtio/vhost-user-scsi.h
>@@ -29,6 +29,10 @@ OBJECT_DECLARE_SIMPLE_TYPE(VHostUserSCSI, VHOST_USER_SCSI)
> struct VHostUserSCSI {
>     VHostSCSICommon parent_obj;
>     VhostUserState vhost_user;
>+    bool connected;
>+    bool started_vu;
>+
>+    struct vhost_virtqueue *vhost_vqs;

 +    bool connected;
 +    bool started_vu;
-+
 +    struct vhost_virtqueue *vhost_vqs;

See https://www.qemu.org/docs/master/devel/style.html#qemu-object-model-declarations

The definition should look like:

struct VHostUserSCSI {
    VHostSCSICommon parent_obj;

    /* Properties */
    bool connected;
    bool started_vu;

    VhostUserState vhost_user;
    struct vhost_virtqueue *vhost_vqs;
}


  reply	other threads:[~2023-10-08 12:02 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-08  9:12 [PATCH v7 0/5] Implement reconnect for vhost-user-scsi Li Feng
2023-10-08  9:12 ` [PATCH v7 1/5] vhost-user-common: send get_inflight_fd once Li Feng
2023-10-08  9:12 ` [PATCH v7 2/5] vhost: move and rename the conn retry times Li Feng
2023-10-08  9:12 ` [PATCH v7 3/5] vhost-user-scsi: support reconnect to backend Li Feng
2023-10-08 10:46   ` Manos Pitsidianakis [this message]
2023-10-09  4:34     ` Li Feng
2023-10-08  9:12 ` [PATCH v7 4/5] vhost-user-scsi: start vhost when guest kicks Li Feng
2023-10-08  9:12 ` [PATCH v7 5/5] vhost-user: fix lost reconnect Li Feng

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=27ldj.4hqzhrkvm1st@linaro.org \
    --to=manos.pitsidianakis@linaro.org \
    --cc=alex.bennee@linaro.org \
    --cc=armbru@redhat.com \
    --cc=fam@euphon.net \
    --cc=fengli@smartx.com \
    --cc=hreitz@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=raphael.norwitz@nutanix.com \
    --cc=viresh.kumar@linaro.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).