]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
kvm tools: Fix VHOST_SET_MEM_TABLE failure
authorAsias He <asias.hejun@gmail.com>
Wed, 11 Jul 2012 16:08:13 +0000 (00:08 +0800)
committerPekka Enberg <penberg@kernel.org>
Thu, 12 Jul 2012 07:09:15 +0000 (10:09 +0300)
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.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
tools/kvm/virtio/net.c

index ae17eb5ea0d01300e4246243a650a62cf6d643d8..aa769d95e56f3e7031b3318b26a22a9c8c2003be 100644 (file)
@@ -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");