Advertisement
Guest User

kvm-install

a guest
Jun 5th, 2016
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.22 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. INSTALLFILE=/media/Windows_VM/win7-uefi-x64_system.img
  4. FILESIZE=460G
  5. INSTALLCD=/media/Autres/Windows/Logiciel/fr_windows_10_multiple_editions_x64_dvd_6846939.iso
  6.  
  7. # if you use a hardware CD-ROM drive, check for the device. In most cases it's /dev/sr0
  8. DRIVERCD=/media/Autres/Windows/Logiciel/virtio-win-0.1.117.iso
  9.  
  10. #Repertoire Windows
  11. WINDOWS=/media/Autres/Windows
  12.  
  13. # PCI address of the passtrough devices
  14. DEVICE1="01:00.0"
  15. DEVICE2="01:00.1"
  16.  
  17. # load vfio-pci module
  18. modprobe vfio-pci
  19.  
  20. for dev in "0000:$DEVICE1" "0000:$DEVICE2"; do
  21. vendor=$(cat /sys/bus/pci/devices/$dev/vendor)
  22. device=$(cat /sys/bus/pci/devices/$dev/device)
  23. if [ -e /sys/bus/pci/devices/$dev/driver ]; then
  24. echo $dev > /sys/bus/pci/devices/$dev/driver/unbind
  25. fi
  26. echo $vendor $device > /sys/bus/pci/drivers/vfio-pci/new_id
  27. done
  28.  
  29. # create installation file if not exist
  30. if [ ! -e $INSTALLFILE ]; then
  31. qemu-img create -f raw $INSTALLFILE $FILESIZE
  32. fi
  33.  
  34. QEMU_PA_SAMPLES=4096 QEMU_AUDIO_DRV=pa \
  35. qemu-system-x86_64 \
  36. -enable-kvm \
  37. -m 4096 \
  38. -cpu host,kvm=off \
  39. -smp 8,sockets=1,cores=4,threads=2 \
  40. -machine pc-i440fx-2.1,accel=kvm \
  41. -soundhw hda \
  42. -drive if=pflash,format=raw,readonly,file=/home/odelpasso/QEMU/OVMF_CODE-pure-efi.fd \
  43. -drive if=pflash,format=raw,file=/home/odelpasso/QEMU/OVMF_VARS-pure-efi.fd \
  44. -device vfio-pci,host=$DEVICE1,addr=0x8.0x0,multifunction=on \
  45. -device vfio-pci,host=$DEVICE2,addr=0x8.0x1 \
  46. -vga qxl \
  47. -device virtio-net-pci,netdev=user.0,mac=52:54:00:a0:66:43 \
  48. -netdev user,id=user.0 \
  49.  
  50. ##CDROM Drive for Iso Windows
  51. -drive file=$INSTALLCD,if=none,id=drive-ide0-0-0,readonly=on,format=raw \
  52. -device ide-cd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 \
  53.  
  54. ##HDD for Windows
  55. -drive file=$INSTALLFILE,if=none,id=drive-virtio-disk0,format=raw,cache=unsafe \
  56. -device virtio-blk-pci,scsi=off,addr=0x7,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=2 \
  57.  
  58. ##CDROM Drive for Virtio Driver
  59. -drive file=$DRIVERCD,if=none,id=drive-ide0-1-0,readonly=on,format=raw \
  60. -device ide-cd,bus=ide.0,unit=1,drive=drive-ide0-1-0,id=ide0-1-0,bootindex=3 \
  61. -rtc base=localtime,driftfix=slew \
  62. -smb $WINDOWS \
  63. -usb \
  64. -device usb-mouse \
  65. -device usb-kbd
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement