Skip to contentSkip to conversation

vhost-scsi: init backend features earlier

PATCH In review Michael S. Tsirkin 3 participants 4 messages Sep 3, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 vhost-scsi: init backend features earlier

As vhost core uses backend_features during init, clear it earlier to avoid using uninitialized memory.
This is harmless since vhost scsi ignores the result anyway, but it avoids valgrind errors.

---
 hw/scsi/vhost-scsi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/scsi/vhost-scsi.c +1 -1
index ddfe76a..7146e0e 100644
@@ -238,6 +238,7 @@ static void vhost_scsi_realize(DeviceState *dev, Error **errp)
     s->dev.nvqs = VHOST_SCSI_VQ_NUM_FIXED + vs->conf.num_queues;
     s->dev.vqs = g_new(struct vhost_virtqueue, s->dev.nvqs);
     s->dev.vq_index = 0;
+    s->dev.backend_features = 0;
 
     ret = vhost_dev_init(&s->dev, (void *)(uintptr_t)vhostfd,
                          VHOST_BACKEND_TYPE_KERNEL, true);
@@ -246,7 +247,6 @@ static void vhost_scsi_realize(DeviceState *dev, Error **errp)
                    strerror(-ret));
         return;
     }
-    s->dev.backend_features = 0;
 
     error_setg(&s->migration_blocker,
             "vhost-scsi does not support migration");
Signature · 1 line
MST
Acked-by on v1 1/1
#1 lore raw

Il 03/09/2014 11:02, Michael S. Tsirkin ha scritto:

Quoted 27 lines

As vhost core uses backend_features during init, clear it earlier to avoid using uninitialized memory.
This is harmless since vhost scsi ignores the result anyway, but it avoids valgrind errors.

---
 hw/scsi/vhost-scsi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/scsi/vhost-scsi.c +1 -0
index ddfe76a..7146e0e 100644
@@ -238,6 +238,7 @@ static void vhost_scsi_realize(DeviceState *dev, Error **errp)
     s->dev.nvqs = VHOST_SCSI_VQ_NUM_FIXED + vs->conf.num_queues;
     s->dev.vqs = g_new(struct vhost_virtqueue, s->dev.nvqs);
     s->dev.vq_index = 0;
+    s->dev.backend_features = 0;
 
     ret = vhost_dev_init(&s->dev, (void *)(uintptr_t)vhostfd,
                          VHOST_BACKEND_TYPE_KERNEL, true);

hw/scsi/vhost-scsi.c static void vhost_scsi_realize(DeviceState *dev, Error **errp) · line 252

Quoted 7 lines
hw/scsi/vhost-scsi.c +0 -1
@@ -246,7 +247,6 @@ static void vhost_scsi_realize(DeviceState *dev, Error **errp)
                    strerror(-ret));
         return;
     }
-    s->dev.backend_features = 0;
 
     error_setg(&s->migration_blocker,
             "vhost-scsi does not support migration");

want to keep it in your treee?

Paolo

#2 lore raw
Quoted 38 lines · Paolo Bonzini

Il 03/09/2014 11:02, Michael S. Tsirkin ha scritto:

Quoted 27 lines

As vhost core uses backend_features during init, clear it earlier to avoid using uninitialized memory.
This is harmless since vhost scsi ignores the result anyway, but it avoids valgrind errors.

---
 hw/scsi/vhost-scsi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/scsi/vhost-scsi.c +1 -0
index ddfe76a..7146e0e 100644
@@ -238,6 +238,7 @@ static void vhost_scsi_realize(DeviceState *dev, Error **errp)
     s->dev.nvqs = VHOST_SCSI_VQ_NUM_FIXED + vs->conf.num_queues;
     s->dev.vqs = g_new(struct vhost_virtqueue, s->dev.nvqs);
     s->dev.vq_index = 0;
+    s->dev.backend_features = 0;
 
     ret = vhost_dev_init(&s->dev, (void *)(uintptr_t)vhostfd,
                          VHOST_BACKEND_TYPE_KERNEL, true);

hw/scsi/vhost-scsi.c static void vhost_scsi_realize(DeviceState *dev, Error **errp) · line 252

Quoted 7 lines
hw/scsi/vhost-scsi.c +0 -1
@@ -246,7 +247,6 @@ static void vhost_scsi_realize(DeviceState *dev, Error **errp)
                    strerror(-ret));
         return;
     }
-    s->dev.backend_features = 0;
 
     error_setg(&s->migration_blocker,
             "vhost-scsi does not support migration");
Quoted 3 lines

want to keep it in your treee?

Paolo

Yes please.

Acked-by on v1 1/1
#3 lore raw
In reply to Michael S. Tsirkin
Quoted 26 lines · Michael S. Tsirkin

As vhost core uses backend_features during init, clear it earlier to avoid using uninitialized memory.
This is harmless since vhost scsi ignores the result anyway, but it avoids valgrind errors.

---
 hw/scsi/vhost-scsi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/scsi/vhost-scsi.c +1 -0
index ddfe76a..7146e0e 100644
@@ -238,6 +238,7 @@ static void vhost_scsi_realize(DeviceState *dev, Error **errp)
     s->dev.nvqs = VHOST_SCSI_VQ_NUM_FIXED + vs->conf.num_queues;
     s->dev.vqs = g_new(struct vhost_virtqueue, s->dev.nvqs);
     s->dev.vq_index = 0;
+    s->dev.backend_features = 0;
 
     ret = vhost_dev_init(&s->dev, (void *)(uintptr_t)vhostfd,
                          VHOST_BACKEND_TYPE_KERNEL, true);

hw/scsi/vhost-scsi.c static void vhost_scsi_realize(DeviceState *dev, Error **errp) · line 252

Quoted 7 lines
hw/scsi/vhost-scsi.c +0 -1
@@ -246,7 +247,6 @@ static void vhost_scsi_realize(DeviceState *dev, Error **errp)
                    strerror(-ret));
         return;
     }
-    s->dev.backend_features = 0;
 
     error_setg(&s->migration_blocker,
             "vhost-scsi does not support migration");