1 start guest
sudo /etc/init.d/networking restart
sudo qemu-system-x86_64 -m 1204 -hda /home/xzl/virtual_machine/ubuntu-12.04-amd64-test.img -localtime -net nic,vlan=0,macaddr=52-54-00-12-34-2,model=virtio -net tap,vlan=0,ifname=tap2,script=no -boot c -smp 2 -chardev socket,path=/tmp/ivshmem_socket,id=foo -device ivshmem,chardev=foo,size=256
2 make and make install driver kernel modules on VM
cd Nahanni/kernel_module/uio/
make
make install
Makefile for driver kernel modules
# obj-m is a list of what kernel modules to build. The .o and other
# objects will be automatically built from the corresponding .c file -
# no need to list the source files explicitly.
obj-m := uio_ivshmem.o
# KDIR is the location of the kernel source. The current standard is
# to link to the associated source tree from the directory containing
# the compiled modules.
KDIR := /lib/modules/$(shell uname -r)/build
# PWD is the current working directory and the location of our module
# source files.
PWD := $(shell pwd)
# default is the default make target. The rule here says to run make
# with a working directory of the directory containing the kernel
# source and compile only the modules in the PWD (local) directory.
default:
$(MAKE) -C $(KDIR) M=$(PWD) modules
install:
cp uio_ivshmem.ko /lib/modules/$(shell uname -r)/kernel/drivers/uio/
clean:
rm -f *.ko *.o uio_ivshmem.mod.c Module.symvers
make install == "cp uio_ivhshmem.ko /lib/modules/$(shell uname -r)/kernel/driver/uio/"
3 install driver kernel modules
cd /lib/modules/3.5.0-23-generic/kernel/drivers/uio/
sudo insmod uio.ko
sudo insmod uio_ivshmem.ko
4 verification
ls /dev/uio*
you will see
/dev/uio0
or
ls /sys/bus/pci/drivers
agpgart-intel ahci ata_generic ehci_hcd ioapic ohci_hcd pata_acpi pcieport serial uhci_hcd virtio-pci xhci_hcd
agpgart-via asiliantfb ata_piix imsttfb langwell_gpio parport_pc pata_sis piix4_smbus tsi721 uio_ivshmem xen-platform-pcii
you can find uio_ivshmem in /sys/pci/drivers
or
ls /sys/bus/pci/devices/0000\:00\:04.0/driver/module/drivers/
you also can find uio_ivshmem
pci:uio_ivshmem
0000:00:04.0 is the busID of ivshmem device
you can fetch the busID through "lspci"
5 problems
It is failed to load the uio_ivshmem driver modules at boot time when I edit the /etc/modules adding lines uio and uio_ivshmem
I can't figure out the reason.