Enable configuring QEMU with Virtfs support

Add support for configuring QEMU with VirtFS to share data
between the guest QEMU VM and host operating systems.

To specify dir, that has to be mounted inside QEMU VM, edit
QEMU_VIRTFS_HOST_DIR var in qemu.mk

To mount shared folder within QEMU ARM VM, run:
$ mount -t 9p -o trans=virtio host /tmp/shared/

If Virtfs support is enabled, libattr1-dev and libcap-dev
have to be installed before configuring QEMU.

For additional details see:
http://wiki.qemu.org/Documentation/9psetup

Signed-off-by: Igor Opaniuk <igor.opaniuk@linaro.org>
Reviewed-by: Joakim Bech <joakim.bech@linaro.org>
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
Tested-by: Igor Opaniuk <igor.opaniuk@linaro.org> (qemu_v7/v8)
diff --git a/common.mk b/common.mk
index c5f5c54..0b15428 100644
--- a/common.mk
+++ b/common.mk
@@ -22,6 +22,12 @@
 
 CCACHE ?= $(shell which ccache) # Don't remove this comment (space is needed)
 
+# Accessing a shared folder on the host from QEMU:
+# # Set QEMU_VIRTFS_ENABLE to 'y' and adjust QEMU_VIRTFS_HOST_DIR
+# # Then in QEMU, run:
+# # $ mount -t 9p -o trans=virtio host <mount_point>
+QEMU_VIRTFS_ENABLE		?= n
+QEMU_VIRTFS_HOST_DIR	?= $(ROOT)
 
 ################################################################################
 # Check coherency of compilation mode
@@ -179,7 +185,17 @@
 	$(call edk2-call) clean && \
 	$(MAKE) -j1 -C $(EDK2_PATH)/BaseTools clean && \
 	rm -f $(EDK2_PATH)/Conf/target.txt
+################################################################################
+# QEMU / QEMUv8
+################################################################################
+QEMU_CONFIGURE_PARAMS_COMMON = --cc="$(CCACHE)gcc" --extra-cflags="-Wno-error"
 
+ifeq ($(QEMU_VIRTFS_ENABLE),y)
+QEMU_CONFIGURE_PARAMS +=  --enable-virtfs
+QEMU_EXTRA_ARGS +=\
+	-fsdev local,id=fsdev0,path=$(QEMU_VIRTFS_HOST_DIR),security_model=none \
+	-device virtio-9p-device,fsdev=fsdev0,mount_tag=host
+endif
 ################################################################################
 # OP-TEE
 ################################################################################