VHOST_SET_MEM_TABLE failed: Operation not supported

In vhost_set_memory(), We have

        if (mem.padding)
                return -EOPNOTSUPP;

So, we need to zero struct vhost_memory.

Signed-off-by: Asias He <asias.he...@gmail.com>
---
 tools/kvm/virtio/net.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/kvm/virtio/net.c b/tools/kvm/virtio/net.c
index ae17eb5..aa769d9 100644
--- a/tools/kvm/virtio/net.c
+++ b/tools/kvm/virtio/net.c
@@ -471,7 +471,7 @@ static void virtio_net__vhost_init(struct kvm *kvm, struct 
net_dev *ndev)
        if (ndev->vhost_fd < 0)
                die_perror("Failed openning vhost-net device");
 
-       mem = malloc(sizeof(*mem) + sizeof(struct vhost_memory_region));
+       mem = calloc(1, sizeof(*mem) + sizeof(struct vhost_memory_region));
        if (mem == NULL)
                die("Failed allocating memory for vhost memory map");
 
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to