# SMP problem with a FreeBSD guest on kvm / libvirt



## ld50 (Jul 4, 2013)

Hi folks,

_A_s the title says:







This happens whenever I assign more than one CPU to the VM. The host should not be at fault, there are eight other VMs (one Windows, the other Linux) that work just fine with up to eight CPUs.

Relevant software versions:


FreeBSD 9.1-RELEASE-p4 (amd64)
qemu-1.4.2
Linux kernel 3.8.13
libvirt-1.0.5.2

This is the commandline libvirt is using to start up the VM:

`/usr/bin/qemu-system-x86_64 -machine accel=kvm -name iscsitarget -S -machine pc-i440fx-1.4,accel=kvm,usb=off -cpu kvm64,+lahf_lm,+dca,+pdcm,+xtpr,+tm2,+est,+vmx,+ds_cpl,+monitor,+dtes64,+pbe,+tm,+ht,+ss,+acpi,+ds,+vme -m 2048 -smp 2,sockets=2,cores=1,threads=1 -uuid d7a0c1ec-3446-5bb9-57eb-dc081b3c7ddb -no-user-config -nodefaults -chardev socket,id=charmonitor,path=/var/lib/libvirt/qemu/iscsitarget.monitor,server,nowait -mon chardev=charmonitor,id=monitor,mode=control -rtc base=utc -no-shutdown -device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 -drive file=/dev/VMs/iscsitarget,if=none,id=drive-ide0-0-0,format=raw,cache=none,aio=native -device ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 -netdev tap,fd=26,id=hostnet0 -device e1000,netdev=hostnet0,id=net0,mac=52:54:00:71:94:0f,bus=pci.0,addr=0x3 -chardev pty,id=charserial0 -device isa-serial,chardev=charserial0,id=serial0 -vnc 127.0.0.1:8 -vga cirrus`

Any help would be greatly appreciated.


----------



## AndyUKG (Jul 11, 2013)

Hi, very quick reply. Just to let you know I've been running FreeBSD amd64 guests with multiple virtual CPUs on Ubuntu Linux for over a year and never had an issue, so it does work. Didn't do anything special to make it work either. That is with Ubuntu 11.x and 12.04.

*T*hanks, Andy.


----------



## ld50 (Jul 14, 2013)

Thanks for your reply,

I'm glad it works for you. I'm not so lucky :\


----------



## AndyUKG (Jul 17, 2013)

Hi,

_S_ome more information for you, guest process information:


```
/usr/bin/kvm -S -M pc-1.0 -enable-kvm -m 4096 -smp 2,sockets=2,cores=1,threads=1 -name 
mail1 -uuid 17def3f2-4535-3f6b-c6d6-fcd2bbb5eb6e -nodefconfig -nodefaults -chardev 
socket,id=charmonitor,path=/var/lib/libvirt/qemu/mail1.monitor,server,nowait -mon 
chardev=charmonitor,id=monitor,mode=control -rtc base=utc -no-shutdown -drive 
file=/var/lib/libvirt/images/mail1.img,if=none,id=drive-virtio-disk0,format=raw -device 
virtio-blk-pci,bus=pci.0,addr=0x4,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 -
drive file=/var/lib/libvirt/images/mail1-data.img,if=none,id=drive-virtio-disk1,format=raw 
-device virtio-blk-pci,bus=pci.0,addr=0x6,drive=drive-virtio-disk1,id=virtio-disk1 -drive 
if=none,media=cdrom,id=drive-ide0-1-0,readonly=on,format=raw -device ide-
drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 -netdev tap,fd=18,id=hostnet0 -
device virtio-net-pci,netdev=hostnet0,id=net0,mac=52:54:00:c1:e1:68,bus=pci.0,addr=0x3 -
chardev pty,id=charserial0 -device isa-serial,chardev=charserial0,id=serial0 -usb -vnc 
127.0.0.1:3 -vga cirrus -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x5
```

And information from boot up, I notice your system is reporting the CPU as a Core2Duo and mine as a QEMU virtual CPU, not sure why that would be:


```
FreeBSD is a registered trademark of The FreeBSD Foundation.
FreeBSD 9.1-RELEASE #0 r243825: Tue Dec  4 09:23:10 UTC 2012
    root@farrell.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC amd64
CPU: QEMU Virtual CPU version 1.0 (2000.14-MHz K8-class CPU)
  Origin = "GenuineIntel"  Id = 0x623  Family = 6  Model = 2  Stepping = 3
  Features=0x783fbfd<FPU,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,MMX,FXSR,SSE,SSE2>
  Features2=0x80002021<SSE3,VMX,CX16,HV>
  AMD Features=0x20100800<SYSCALL,NX,LM>
  AMD Features2=0x1<LAHF>
real memory  = 4294967296 (4096 MB)
avail memory = 4101820416 (3911 MB)
Event timer "LAPIC" quality 400
ACPI APIC Table: <BOCHS  BXPCAPIC>
FreeBSD/SMP: Multiprocessor System Detected: 2 CPUs
FreeBSD/SMP: 2 package(s) x 1 core(s)
 cpu0 (BSP): APIC ID:  0
 cpu1 (AP): APIC ID:  1
```

The real CPU is of type "Intel(R) Xeon(R) CPU E5335 @ 2.00 GHz"


----------



## ld50 (Jul 22, 2013)

Thanks for your reply,

I guess your Qemu-KVM version is quite different from mine. Maybe I'll try with -M 1.0 and see whether that makes any difference. The real CPU is an "Intel Xeon E5420", I don't know why Qemu emulates it as a Core2Duo.


----------



## ld50 (Aug 31, 2013)

Ok, I've got it working. I don't know what really made the difference, I just upgraded various bits of software. Versions as of now:


Linux kernel 3.10.7
FreeBSD 9.1-RELEASE-p6
libvirt-1.1.1-r1
qemu-1.4.2


----------

