Monday, May 11, 2015

GSoC: Qemu setup with bochs/cirrus + linux guest

I am now trying to setup qemu with bochs/cirrus.

As I didn't use qemu that much, I searched the internet to set up the qemu, there might be some mistakes, if I am wrong, please tell me.

I intended to use the machine of the laboratory, but unfortunately someone else was using it doing some test, and made it unable to run qemu-system-x86_64, there are too many depends problems. Then I came back to my PC with Windows 7 running on it, and I set up a VirtualMachine on the VMware workstation using the debian 7 iso.

After that, I installed qemu, and run the following command to create another two VMs on the former VM, this is slow and sometimes lost the mouse, but it works.
  1. create a virtual disk
   # qemu-img create linux-bochs.img 40G
  2. install from iso
   # qemu-system-x86_64 -m 1024 -smp 2 -boot d -hda ./linux-bochs.img -no-acpi -vga std -k en-us -cdrom ./debian-live-7.8.0-amd64-xfce-desktop.iso
  3. boot from linux-bochs.img
   # qemu-system-x86_64 -m 1024 -smp 2 -hda ./linux-bochs.img -no-acpi -vga std -k en-us

Same for the other VM, just post it here:
  1. create a virtual disk
   # qemu-img create linux-cirrus.img 40G
  2. install from iso 
   # qemu-system-x86_64 -m 1024 -smp 2 -boot d -hda ./linux-cirrus.img -no-acpi -vga cirrus -k en-us -cdrom ./debian-live-7.8.0-amd64-xfce-desktop.iso
  3. boot from linux-bochs.img
   # qemu-system-x86_64 -m 1024 -smp 2 -hda ./linux-cirrus.img -no-acpi -vga cirrus -k en-us

Now, both work :)

Problems:

But then I got a problem, when I check the dmesg, I try to search some information related to bochs or cirrus, for the bochs virtual machine, I got the following information:

[    0.000000] Initializing cgroup subsys cpuset
[    0.000000] Initializing cgroup subsys cpu
[    0.000000] Linux version 3.2.0-4-amd64 (debian-kernel@lists.debian.org) (gcc version 4.6.3 (Debian 4.6.3-14) ) #1 SMP Debian 3.2.65-1
[    0.000000] Command line: BOOT_IMAGE=/boot/vmlinuz-3.2.0-4-amd64 root=UUID=0e31ae86-cebe-4a89-b335-7b235dd671a0 ro initrd=/install/gtk/initrd.gz quiet
[    0.000000] BIOS-provided physical RAM map:
[    0.000000]  BIOS-e820: 0000000000000000 - 000000000009f400 (usable)
[    0.000000]  BIOS-e820: 000000000009f400 - 00000000000a0000 (reserved)
[    0.000000]  BIOS-e820: 00000000000f0000 - 0000000000100000 (reserved)
[    0.000000]  BIOS-e820: 0000000000100000 - 0000000040000000 (usable)
[    0.000000]  BIOS-e820: 00000000fffc0000 - 0000000100000000 (reserved)
[    0.000000] NX (Execute Disable) protection: active
[    0.000000] SMBIOS 2.4 present.
[    0.000000] DMI: Bochs Bochs, BIOS Bochs 01/01/2007

I thought maybe the DMI line means something.
But when it comes to cirrus virtual machine, got the following:

[    0.000000] Initializing cgroup subsys cpuset
[    0.000000] Initializing cgroup subsys cpu
[    0.000000] Linux version 3.2.0-4-amd64 (debian-kernel@lists.debian.org) (gcc version 4.6.3 (Debian 4.6.3-14) ) #1 SMP Debian 3.2.65-1
[    0.000000] Command line: BOOT_IMAGE=/boot/vmlinuz-3.2.0-4-amd64 root=UUID=64a91cb7-eead-4d10-9edf-091f31a2a590 ro initrd=/install/gtk/initrd.gz quiet
[    0.000000] BIOS-provided physical RAM map:
[    0.000000]  BIOS-e820: 0000000000000000 - 000000000009f400 (usable)
[    0.000000]  BIOS-e820: 000000000009f400 - 00000000000a0000 (reserved)
[    0.000000]  BIOS-e820: 00000000000f0000 - 0000000000100000 (reserved)
[    0.000000]  BIOS-e820: 0000000000100000 - 0000000040000000 (usable)
[    0.000000]  BIOS-e820: 00000000fffc0000 - 0000000100000000 (reserved)
[    0.000000] NX (Execute Disable) protection: active
[    0.000000] SMBIOS 2.4 present.
[    0.000000] DMI: Bochs Bochs, BIOS Bochs 01/01/2007

Still Bochs, that's odd, where is the cirrus? Why no information related to cirrus.

note: After talking to Daniel on IRC, I got to know that DMI is the overall machine, that means it will always be Bochs for qemu.
DMI is often used for blacklists and quirks since it's machine-dependent.

After that I run lspci, for bochs got:
00:00.0 Host bridge: Intel Corporation 440FX - 82441FX PMC [Natoma] (rev 02)
00:01.0 ISA bridge: Intel Corporation 82371SB PIIX3 ISA [Natoma/Triton II]
00:01.1 IDE interface: Intel Corporation 82371SB PIIX3 IDE [Natoma/Triton II]
00:02.0 VGA compatible controller: Device 1234:1111
00:03.0 Ethernet controller: Intel Corporation 82540EM Gigabit Ethernet Controller (rev 03)

For cirrus I got:
00:00.0 Host bridge: Intel Corporation 440FX - 82441FX PMC [Natoma] (rev 02)
00:01.0 ISA bridge: Intel Corporation 82371SB PIIX3 ISA [Natoma/Triton II]
00:01.1 IDE interface: Intel Corporation 82371SB PIIX3 IDE [Natoma/Triton II]
00:02.0 VGA compatible controller: Cirrus Logic GD 5446
00:03.0 Ethernet controller: Intel Corporation 82540EM Gigabit Ethernet Controller (rev 03)

The information above makes me happy :)