1. Homepage
  2. Articoli
  3. Video
  4. Bash scripting
  5. Sistema
  6. Tips
  7. News


QEMU notes

» Author: Andrea Ganduglia Date: 2008-11-04 12:40:19 Copyright: (c)2008 Andrea Ganduglia

Indice dei contenuti


Quick references:

Configurare la rete in qemu

Vedi: http://ubuntuforums.org/showthread.php?t=179472

Cose da fare una tantum

apt-get install uml-utilities
sudo modprobe tun
mkdir /dev/net
mknod /dev/net/tun c 10 200
tunctl

Invocare qemu (da root):

qemu -hda win98.img -boot c -net nic -net tap

Questo modo di invocare qemu dovrebbe creare un tap0:

ifconfig
...
tap1      Link encap:Ethernet  HWaddr 00:FF:D1:17:42:03  
          inet addr:172.20.0.1  Bcast:172.20.255.255  Mask:255.255.0.0
          inet6 addr: fe80::2ff:d1ff:fe17:4203/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:17 errors:0 dropped:0 overruns:0 frame:0
          TX packets:112 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:500 
          RX bytes:1205 (1.1 KB)  TX bytes:18272 (17.8 KB)

Se così non fosse assegnare un IP manualmente

ifconfig tap0 192.168.100.1 up

Configurare il client con i parametri giusti, utilizzando questo indirizzo IP come gateway.

Ricordarsi di abilitare la rete:

iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
echo 1 > /proc/sys/net/ipv4/ip_forward

Inviare comandi a qemu

Premere Ctrl+Alt+{1,2,3} per entrare nelle varie modalita` di qemu.

Utile in particolare:

Ctrl+Alt+1 // Entra in modalita` comandi
sendkeys ctrl-alt-f1 || ctrl-alt-backspace // Invia un comando tastiera all'emulatore

Installare kqemu

Vedi http://tech.tolero.org/blog/en/linux/qemu-9-and-kqemu-for-ubuntu-dapper-edgy-feisty

# apt-get update
# apt-get install kqemu-common kqemu-source
# apt-get install module-assistant
# m-a prepare
# m-a build kqemu
# m-a install kqemu
# apt-get install qemu

Creare il device

modprobe kqemu
mknod /dev/kqemu c 250 0
/bin/chmod 666 /dev/kqemu

USB: disco esterno o chiave USB

Aggiungere -usb alla linea di attivazione. Una volta dentro il sistema entrare in #modalità comandi e digitare:

usb_add host:addr

dove addr può essere scoperto con lsusb da terminale.

Se su Ubuntu (8.04) non funziona

Su Ubuntu non sempre funziona (sulla 8.04 e 32bit non funziona). Seguire questo howto: https://bugs.launchpad.net/qemu/+bug/156085.

On Gutsy 64-bit using qemu/kvm (also VirtualBox and, I believe, VMWare) 
and the "-usb" switch no USB devices are available since qemu/kvm looks for the 
escription of them in the 'devices' file of a usbfs mount at

/proc/bus/usb/

but the code previously providing the usbfs mount that is created at 
start-up via /etc/rcS/S11mountdevsubfs.sh --> /etc/init.d/mountdevsubfs.sh 
was commented out. The USB devices are now reported at

/dev/bus/usb/

but currently there is no usbfs file-system mounted/linked there to provide 
the 'devices' text-file.

qemu/kvm reports:

qemuctl -qemu vdeq kvm -boot c -m 512 \\
-hda /home/all/VirtualMachines/WindowsXP-SP2.ovl -net nic,vlan=0 -soundhw es1370 -usb -net vde

info usbhost
Could not open /proc/bus/usb/devices

$ ls -l /proc/bus/usb
total 0

WORKAROUND:
To re-enable it edit the file '/etc/init.d/mountdevsubfs.sh' 
and uncomment the code after line 40 so it reads:
  # Magic to make /proc/bus/usb work
  #
  mkdir -p /dev/bus/usb/.usbfs
  domount usbfs "" /dev/bus/usb/.usbfs -obusmode=0700,devmode=0600,listmode=0644
  ln -s .usbfs/devices /dev/bus/usb/devices
  mount --rbind /dev/bus/usb /proc/bus/usb
Execute the script manually to enable the change before a system reboot:
$ sudo /etc/init.d/mountdevsubfs.sh start

FAQs

device not found

Quando provo a cambiare disco ricevo il messaggio device not found

change fda disk-2.img
device not found

provare con

change floppy0 disk-2.img