dcavalca / rpms / qemu

Forked from rpms/qemu a year ago
Clone

Blame qemu-vhost-add-configure-check.patch

Justin M. Forbes 272dfe
Teach configure to check for vhost.h
Justin M. Forbes 272dfe
and disable vhost_net if not present.
Justin M. Forbes 272dfe
Justin M. Forbes 272dfe
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>'
Justin M. Forbes 272dfe
Justin M. Forbes 272dfe
---
Justin M. Forbes 272dfe
Justin M. Forbes 272dfe
diff --git a/Makefile.target b/Makefile.target
Justin M. Forbes 272dfe
index 2ebd30c..38783da 100644
Justin M. Forbes 272dfe
--- a/Makefile.target
Justin M. Forbes 272dfe
+++ b/Makefile.target
Justin M. Forbes 272dfe
@@ -168,7 +168,8 @@ obj-y = vl.o async.o monitor.o pci.o pci_host.o pcie_host.o machine.o gdbstub.o
Justin M. Forbes 272dfe
 # need to fix this properly
Justin M. Forbes 272dfe
 obj-y += virtio-blk.o virtio-balloon.o virtio-net.o virtio-pci.o virtio-serial-bus.o
Justin M. Forbes 272dfe
 obj-y += notifier.o
Justin M. Forbes 272dfe
-obj-y += vhost_net.o vhost.o
Justin M. Forbes 272dfe
+obj-y += vhost_net.o
Justin M. Forbes 272dfe
+obj-$(CONFIG_VHOST_NET) += vhost.o
Justin M. Forbes 272dfe
 obj-$(CONFIG_KVM) += kvm.o kvm-all.o
Justin M. Forbes 272dfe
 # MSI-X depends on kvm for interrupt injection,
Justin M. Forbes 272dfe
 # so moved it from Makefile.hw to Makefile.target for now
Justin M. Forbes 272dfe
diff --git a/configure b/configure
Justin M. Forbes 272dfe
index 88ba002..4994506 100755
Justin M. Forbes 272dfe
--- a/configure
Justin M. Forbes 272dfe
+++ b/configure
Justin M. Forbes 272dfe
@@ -1510,6 +1510,23 @@ EOF
Justin M. Forbes 272dfe
 fi
Justin M. Forbes 272dfe
 
Justin M. Forbes 272dfe
 ##########################################
Justin M. Forbes 272dfe
+# test for vhost net
Justin M. Forbes 272dfe
+
Justin M. Forbes 272dfe
+if test "$kvm" != "no"; then
Justin M. Forbes 272dfe
+	cat > $TMPC <
Justin M. Forbes 272dfe
+#include <linux/vhost.h>
Justin M. Forbes 272dfe
+int main(void) { return 0; }
Justin M. Forbes 272dfe
+EOF
Justin M. Forbes 272dfe
+	if compile_prog "$kvm_cflags" "" ; then
Justin M. Forbes 272dfe
+	vhost_net=yes
Justin M. Forbes 272dfe
+	else
Justin M. Forbes 272dfe
+	vhost_net=no
Justin M. Forbes 272dfe
+	fi
Justin M. Forbes 272dfe
+else
Justin M. Forbes 272dfe
+	vhost_net=no
Justin M. Forbes 272dfe
+fi
Justin M. Forbes 272dfe
+
Justin M. Forbes 272dfe
+##########################################
Justin M. Forbes 272dfe
 # libpci probe for kvm_cap_device_assignment
Justin M. Forbes 272dfe
 if test $kvm_cap_device_assignment = "yes" ; then
Justin M. Forbes 272dfe
   cat > $TMPC << EOF
Justin M. Forbes 272dfe
@@ -2058,6 +2075,7 @@ echo "fdt support       $fdt"
Justin M. Forbes 272dfe
 echo "preadv support    $preadv"
Justin M. Forbes 272dfe
 echo "fdatasync         $fdatasync"
Justin M. Forbes 272dfe
 echo "uuid support      $uuid"
Justin M. Forbes 272dfe
+echo "vhost-net support $vhost_net"
Justin M. Forbes 272dfe
 
Justin M. Forbes 272dfe
 if test $sdl_too_old = "yes"; then
Justin M. Forbes 272dfe
 echo "-> Your SDL version is too old - please upgrade to have SDL support"
Justin M. Forbes 272dfe
@@ -2593,6 +2611,9 @@ case "$target_arch2" in
Justin M. Forbes 272dfe
       if test $kvm_cap_device_assignment = "yes" ; then
Justin M. Forbes 272dfe
         echo "CONFIG_KVM_DEVICE_ASSIGNMENT=y" >> $config_target_mak
Justin M. Forbes 272dfe
       fi
Justin M. Forbes 272dfe
+      if test $vhost_net = "yes" ; then
Justin M. Forbes 272dfe
+        echo "CONFIG_VHOST_NET=y" >> $config_target_mak
Justin M. Forbes 272dfe
+      fi
Justin M. Forbes 272dfe
     fi
Justin M. Forbes 272dfe
 esac
Justin M. Forbes 272dfe
 echo "TARGET_PHYS_ADDR_BITS=$target_phys_bits" >> $config_target_mak
Justin M. Forbes 272dfe
diff --git a/hw/vhost_net.c b/hw/vhost_net.c
Justin M. Forbes 272dfe
index c89ff40..cab9a0a 100644
Justin M. Forbes 272dfe
--- a/hw/vhost_net.c
Justin M. Forbes 272dfe
+++ b/hw/vhost_net.c
Justin M. Forbes 272dfe
@@ -16,9 +16,13 @@
Justin M. Forbes 272dfe
 #include "net/tap.h"
Justin M. Forbes 272dfe
 
Justin M. Forbes 272dfe
 #include "virtio-net.h"
Justin M. Forbes 272dfe
-#include "vhost.h"
Justin M. Forbes 272dfe
 #include "vhost_net.h"
Justin M. Forbes 272dfe
 
Justin M. Forbes 272dfe
+#include "config.h"
Justin M. Forbes 272dfe
+
Justin M. Forbes 272dfe
+#ifdef CONFIG_VHOST_NET
Justin M. Forbes 272dfe
+#include "vhost.h"
Justin M. Forbes 272dfe
+
Justin M. Forbes 272dfe
 struct vhost_net {
Justin M. Forbes 272dfe
 	struct vhost_dev dev;
Justin M. Forbes 272dfe
 	struct vhost_virtqueue vqs[2];
Justin M. Forbes 272dfe
@@ -145,3 +149,31 @@ void vhost_net_cleanup(struct vhost_net *net)
Justin M. Forbes 272dfe
 	qemu_free(net);
Justin M. Forbes 272dfe
 }
Justin M. Forbes 272dfe
 /* TODO: log */
Justin M. Forbes 272dfe
+#else
Justin M. Forbes 272dfe
+struct vhost_net *vhost_net_init(VLANClientState *backend, int devfd)
Justin M. Forbes 272dfe
+{
Justin M. Forbes 272dfe
+	return NULL;
Justin M. Forbes 272dfe
+}
Justin M. Forbes 272dfe
+
Justin M. Forbes 272dfe
+int vhost_net_start(struct vhost_net *net,
Justin M. Forbes 272dfe
+		    VirtIODevice *dev)
Justin M. Forbes 272dfe
+{
Justin M. Forbes 272dfe
+	return -ENOSYS;
Justin M. Forbes 272dfe
+}
Justin M. Forbes 272dfe
+void vhost_net_stop(struct vhost_net *net,
Justin M. Forbes 272dfe
+		    VirtIODevice *dev)
Justin M. Forbes 272dfe
+{
Justin M. Forbes 272dfe
+}
Justin M. Forbes 272dfe
+
Justin M. Forbes 272dfe
+void vhost_net_cleanup(struct vhost_net *net)
Justin M. Forbes 272dfe
+{
Justin M. Forbes 272dfe
+}
Justin M. Forbes 272dfe
+
Justin M. Forbes 272dfe
+unsigned vhost_net_get_features(struct vhost_net *net, unsigned features)
Justin M. Forbes 272dfe
+{
Justin M. Forbes 272dfe
+	return features;
Justin M. Forbes 272dfe
+}
Justin M. Forbes 272dfe
+void vhost_net_ack_features(struct vhost_net *net, unsigned features)
Justin M. Forbes 272dfe
+{
Justin M. Forbes 272dfe
+}
Justin M. Forbes 272dfe
+#endif