* [Qemu-devel] [PATCH v2 1/2] vhost-scsi: Call virtio_scsi_common_unrealize() when device realize failed
@ 2019-07-17 0:46 elohimes
2019-07-17 0:46 ` [Qemu-devel] [PATCH v2 2/2] vhost-user-scsi: " elohimes
0 siblings, 1 reply; 3+ messages in thread
From: elohimes @ 2019-07-17 0:46 UTC (permalink / raw)
To: mst, stefanha, pbonzini, fam; +Cc: Xie Yongji, qemu-devel
From: Xie Yongji <xieyongji@baidu.com>
This avoids memory leak when device hotplug is failed.
Signed-off-by: Xie Yongji <xieyongji@baidu.com>
---
hw/scsi/vhost-scsi.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/hw/scsi/vhost-scsi.c b/hw/scsi/vhost-scsi.c
index 4090f99ee4..c0dd9bdf89 100644
--- a/hw/scsi/vhost-scsi.c
+++ b/hw/scsi/vhost-scsi.c
@@ -210,7 +210,7 @@ static void vhost_scsi_realize(DeviceState *dev, Error **errp)
if (err) {
error_propagate(errp, err);
error_free(vsc->migration_blocker);
- goto close_fd;
+ goto free_virtio;
}
}
@@ -240,6 +240,10 @@ static void vhost_scsi_realize(DeviceState *dev, Error **errp)
migrate_del_blocker(vsc->migration_blocker);
}
g_free(vsc->dev.vqs);
+ free_virtio:
+ err = NULL;
+ virtio_scsi_common_unrealize(dev, &err);
+ error_propagate(errp, err);
close_fd:
close(vhostfd);
return;
--
2.17.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [Qemu-devel] [PATCH v2 2/2] vhost-user-scsi: Call virtio_scsi_common_unrealize() when device realize failed
2019-07-17 0:46 [Qemu-devel] [PATCH v2 1/2] vhost-scsi: Call virtio_scsi_common_unrealize() when device realize failed elohimes
@ 2019-07-17 0:46 ` elohimes
2019-07-17 9:42 ` Paolo Bonzini
0 siblings, 1 reply; 3+ messages in thread
From: elohimes @ 2019-07-17 0:46 UTC (permalink / raw)
To: mst, stefanha, pbonzini, fam; +Cc: Xie Yongji, qemu-devel
From: Xie Yongji <xieyongji@baidu.com>
This avoids memory leak when device hotplug is failed.
Signed-off-by: Xie Yongji <xieyongji@baidu.com>
---
hw/scsi/vhost-user-scsi.c | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/hw/scsi/vhost-user-scsi.c b/hw/scsi/vhost-user-scsi.c
index a9fd8ea305..17826ef8e2 100644
--- a/hw/scsi/vhost-user-scsi.c
+++ b/hw/scsi/vhost-user-scsi.c
@@ -87,7 +87,7 @@ static void vhost_user_scsi_realize(DeviceState *dev, Error **errp)
}
if (!vhost_user_init(&s->vhost_user, &vs->conf.chardev, errp)) {
- return;
+ goto free_virtio;
}
vsc->dev.nvqs = 2 + vs->conf.num_queues;
@@ -101,15 +101,23 @@ static void vhost_user_scsi_realize(DeviceState *dev, Error **errp)
if (ret < 0) {
error_setg(errp, "vhost-user-scsi: vhost initialization failed: %s",
strerror(-ret));
- vhost_user_cleanup(&s->vhost_user);
- g_free(vqs);
- return;
+ goto free_vhost;
}
/* Channel and lun both are 0 for bootable vhost-user-scsi disk */
vsc->channel = 0;
vsc->lun = 0;
vsc->target = vs->conf.boot_tpgt;
+
+ return;
+
+free_vhost:
+ vhost_user_cleanup(&s->vhost_user);
+ g_free(vqs);
+free_virtio:
+ err = NULL;
+ virtio_scsi_common_unrealize(dev, &err);
+ error_propagate(errp, err);
}
static void vhost_user_scsi_unrealize(DeviceState *dev, Error **errp)
--
2.17.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH v2 2/2] vhost-user-scsi: Call virtio_scsi_common_unrealize() when device realize failed
2019-07-17 0:46 ` [Qemu-devel] [PATCH v2 2/2] vhost-user-scsi: " elohimes
@ 2019-07-17 9:42 ` Paolo Bonzini
0 siblings, 0 replies; 3+ messages in thread
From: Paolo Bonzini @ 2019-07-17 9:42 UTC (permalink / raw)
To: elohimes, mst, stefanha, fam; +Cc: Xie Yongji, qemu-devel
On 17/07/19 02:46, elohimes@gmail.com wrote:
> From: Xie Yongji <xieyongji@baidu.com>
>
> This avoids memory leak when device hotplug is failed.
>
> Signed-off-by: Xie Yongji <xieyongji@baidu.com>
> ---
> hw/scsi/vhost-user-scsi.c | 16 ++++++++++++----
> 1 file changed, 12 insertions(+), 4 deletions(-)
>
> diff --git a/hw/scsi/vhost-user-scsi.c b/hw/scsi/vhost-user-scsi.c
> index a9fd8ea305..17826ef8e2 100644
> --- a/hw/scsi/vhost-user-scsi.c
> +++ b/hw/scsi/vhost-user-scsi.c
> @@ -87,7 +87,7 @@ static void vhost_user_scsi_realize(DeviceState *dev, Error **errp)
> }
>
> if (!vhost_user_init(&s->vhost_user, &vs->conf.chardev, errp)) {
> - return;
> + goto free_virtio;
> }
>
> vsc->dev.nvqs = 2 + vs->conf.num_queues;
> @@ -101,15 +101,23 @@ static void vhost_user_scsi_realize(DeviceState *dev, Error **errp)
> if (ret < 0) {
> error_setg(errp, "vhost-user-scsi: vhost initialization failed: %s",
> strerror(-ret));
> - vhost_user_cleanup(&s->vhost_user);
> - g_free(vqs);
> - return;
> + goto free_vhost;
> }
>
> /* Channel and lun both are 0 for bootable vhost-user-scsi disk */
> vsc->channel = 0;
> vsc->lun = 0;
> vsc->target = vs->conf.boot_tpgt;
> +
> + return;
> +
> +free_vhost:
> + vhost_user_cleanup(&s->vhost_user);
> + g_free(vqs);
> +free_virtio:
> + err = NULL;
> + virtio_scsi_common_unrealize(dev, &err);
> + error_propagate(errp, err);
> }
>
> static void vhost_user_scsi_unrealize(DeviceState *dev, Error **errp)
>
Queued both patches, thanks.
Paolo
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-07-17 9:42 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-17 0:46 [Qemu-devel] [PATCH v2 1/2] vhost-scsi: Call virtio_scsi_common_unrealize() when device realize failed elohimes
2019-07-17 0:46 ` [Qemu-devel] [PATCH v2 2/2] vhost-user-scsi: " elohimes
2019-07-17 9:42 ` Paolo Bonzini
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).