Re: kqemu patch for CURRENT/10-STABLE (was Re: Linux on BHyVe in 10.0-RELEASE )

2014-02-08 Thread Shteryana Shopova
Hi,

Ok, I seem to have sent an earlier and not-well-though-out version of
the patch - attaching the correct one now (I dug into this a couple of
months ago and needed some time to remember the details). I tried it
with your test setup and - module loads/unloads cleanly, but will
freeze the vbox FreeBSD 10 host if I try to run openbsd 5.5 VM (my
FreeBSD current host freezes too if I try to run a VirtualBox VM with
vmm.ko and nmdm.ko modules loaded, not sure why).

I tested it again on a FreeBSD current host running on real hardware
with a number of VMs/OSes and the results I got are  -

* Ubuntu-12.04.4 both amd64 and i386 fail to boot from CD - get stuck
somewhere after a purple screen
* Debian 7.3.0 both amd64 and i386 boot and install fine from  CD,
booting from hard disk gets stuck at GRUB though
* FreeBSD 10 i386 boots from CD and disk, however is very slow
(installation took literally several hours)
* pfSense 2.1 i386 works fine
* OpenBSD 5.5 i386 boots and installs from CD, boots from disk after
installation only when ACPI is disabled at boot
* OpenBSD 5.5 amd64 boots and installs from CD, booting the installed
OS from disk however crashes qemu late around starting sndiod with

RAX= RBX=1a938686c340 RCX=1a91832031e5
RDX=1a938dc82b64
RSI=0012 RDI=1a938686c350 RBP=1a938dfb6f60
RSP=7f7ebf30
R8 =1a938dfb6f60 R9 =000d R10=
R11=
R12=1a91832031e5 R13=0012 R14=1a9392ff4000
R15=
RIP=1a938db21c7d RFL=00010246 [---Z-P-] CPL=3 II=0 A20=1 SMM=0
HLT=0
ES =0023  bfff 00aff300 DPL=3 DS16 [-WA]
CS =002b  bfff 00affb00 DPL=3 CS64 [-RA]
SS =0023  bfff 00aff300 DPL=3 DS16 [-WA]
DS =0023  bfff 00aff300 DPL=3 DS16 [-WA]
FS =0023  bfff 00aff300 DPL=3 DS16 [-WA]
GS =0023  bfff 00aff300 DPL=3 DS16 [-WA]
LDT=   8200 DPL=0 LDT
TR =0030 80011000 0067 8900 DPL=0 TSS64-avl
GDT= 80011068 003f
IDT= 8001 0fff
CR0=e001003b CR2=1a938686c348 CR3=3f498000 CR4=07b0
DR0= DR1= DR2=
DR3=
DR6=0ff0 DR7=0400
Unsupported return value: 0x

and

kqemu: closed by pid=26323
kqemu: aborting: Unexpected exception 0x0d in monitor space

in dmesg. This however looks like a problem with kqemu-kmod not
related to the KPI changes. I tested this with kqemu-kmod-devel with
the patch applied and qemu-0.11.1_13 since obviously KQEMU support was
dropped in later versions. Considering that kqemu support was dropped
in newer versions of qemu however, the patch is probably useless and
kqemu-kmod ports should just be marked obsolete.

cheers,
Shteryana

On Thu, Feb 6, 2014 at 10:12 PM, Juergen Lock n...@jelal.kn-bremen.de wrote:

 The commit does look relevant but testing your patch on a 10.0-RC1
 vbox guest (it's what I had available) with the RC1 iso like so:

 # kldload kqemu
 % qemu-system-x86_64 -cdrom /dev/cd0 -m 512 -curses -enable-kqemu

 panics like this:

 --
 10rc1amd64mbr2 dumped core - see /var/crash/vmcore.1

--- kqemu-freebsd.c~2014-02-07 20:00:33.656255395 +0200
+++ kqemu-freebsd.c 2014-02-08 08:43:19.209100708 +0200
@@ -105,17 +105,29 @@
  */
 struct kqemu_page *CDECL kqemu_alloc_zeroed_page(unsigned long *ppage_index)
 {
+#if __FreeBSD_version  130
 pmap_t pmap;
+#endif
 vm_offset_t va;
 vm_paddr_t pa;
 
+#if __FreeBSD_version = 130
+va = kmem_malloc(kernel_arena, PAGE_SIZE, M_ZERO | M_WAITOK);
+#else
 va = kmem_alloc(kernel_map, PAGE_SIZE);
+#endif
+
 if (va == 0) {
kqemu_log(kqemu_alloc_zeroed_page: NULL\n);
return NULL;
 }
+
+#if __FreeBSD_version = 130
+pa = vtophys(va);
+#else
 pmap = vm_map_pmap(kernel_map);
 pa = pmap_extract(pmap, va);
+#endif
 /* kqemu_log(kqemu_alloc_zeroed_page: %08x\n, pa); */
 *ppage_index = pa  PAGE_SHIFT;
 return (struct kqemu_page *)va;
@@ -125,7 +137,11 @@
 {
 if (kqemu_debug  0)
kqemu_log(kqemu_free_page(%p)\n, page);
+#if __FreeBSD_version = 130
+kmem_free(kernel_arena, (vm_offset_t) page, PAGE_SIZE);
+#else
 kmem_free(kernel_map, (vm_offset_t) page, PAGE_SIZE);
+#endif
 }
 
 /* return kernel address of the physical page page_index */
___
freebsd-virtualization@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-virtualization
To unsubscribe, send any mail to 
freebsd-virtualization-unsubscr...@freebsd.org

kqemu patch for CURRENT/10-STABLE (was Re: Linux on BHyVe in 10.0-RELEASE )

2014-02-06 Thread Shteryana Shopova
Hi all,

Sorry for top posting but I'm new to the list and came across this
thread while playing with bhyve these days. To apply the patch -

#cp patch-unit3minorfix /usr/ports/emulators/kqemu-kmod/files/

compile and install the module.

I've been running kqemu under current with the attached patch (plain
text below in case the attachment is removed) for a couple of months
now and the module is loaded successfully -

root@demetra:/usr/ports/emulators/kqemu-kmod # dmesg | tail -n 10 | grep kqemu
kqemu version 0x00010300
kqemu: KQEMU installed, max_locked_mem=4120624kB.
root@demetra:/usr/ports/emulators/kqemu-kmod # uname -v
FreeBSD 11.0-CURRENT #6 r260863: Sun Jan 19 02:57:49 EET 2014

The original commit that broke kqemu-kmod is from March 9th, 2013, so
the patch should be applicable to 10-STABLE too. Reports on
success/failures welcome.

cheers,
Shteryana

P.S. Example on getting a headless VM with vbox -

#VBoxManage createvm --name MyServer --ostype Windows7 --register
#VBoxManage createhd --filename MyServer.vdi --size 20
#VBoxManage storagectl MyServer --name IDE Controller --add ide
--controller PIIX3
#VBoxManage storageattach MyServer --storagectl IDE Controller
--port 0 --device 1 --type hdd --medium MyServer.vdi
#VBoxManage storageattach MyServer --storagectl IDE Controller
--port 1 --device 0 --type dvddrive --medium
/home/myserver/install.iso
#VBoxManage modifyvm MyServer --nic1 bridged --cableconnected1 on
--bridgeadapter1 em0 --nictype1 82540EM
#VBoxManage modifyvm MyServer --memory 1024 --acpi on --boot1 dvd
#VBoxHeadless -n -m 5901 -s MyServer

The VM is then accessible via vncviewer to the IP of the original
machine port 5901

--- kqemu-freebsd.c.orig2014-02-06 16:03:15.881335406 +0200
+++ kqemu-freebsd.c2014-02-06 16:04:25.951329106 +0200
@@ -109,7 +109,12 @@
 vm_offset_t va;
 vm_paddr_t pa;

+#if __FreeBSD_version = 130
+va = kmem_malloc(kernel_map, PAGE_SIZE, M_WAITOK);
+#else
 va = kmem_alloc(kernel_map, PAGE_SIZE);
+#endif
+
 if (va == 0) {
 kqemu_log(kqemu_alloc_zeroed_page: NULL\n);
 return NULL;


patch-unit3minorfix
Description: Binary data
___
freebsd-virtualization@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-virtualization
To unsubscribe, send any mail to 
freebsd-virtualization-unsubscr...@freebsd.org

Re: kqemu patch for CURRENT/10-STABLE (was Re: Linux on BHyVe in 10.0-RELEASE )

2014-02-06 Thread Shteryana Shopova
On Thu, Feb 6, 2014 at 7:59 PM, Juergen Lock n...@jelal.kn-bremen.de wrote:
 On Thu, Feb 06, 2014 at 05:16:15PM +0200, Shteryana Shopova wrote:
 Hi all,

 Sorry for top posting but I'm new to the list and came across this
 thread while playing with bhyve these days. To apply the patch -

 #cp patch-unit3minorfix /usr/ports/emulators/kqemu-kmod/files/

 compile and install the module.

 I've been running kqemu under current with the attached patch (plain
 text below in case the attachment is removed) for a couple of months
 now and the module is loaded successfully -

 root@demetra:/usr/ports/emulators/kqemu-kmod # dmesg | tail -n 10 | grep 
 kqemu
 kqemu version 0x00010300
 kqemu: KQEMU installed, max_locked_mem=4120624kB.
 root@demetra:/usr/ports/emulators/kqemu-kmod # uname -v
 FreeBSD 11.0-CURRENT #6 r260863: Sun Jan 19 02:57:49 EET 2014

 The original commit that broke kqemu-kmod is from March 9th, 2013, so
 the patch should be applicable to 10-STABLE too. Reports on
 success/failures welcome.

 cheers,
 Shteryana

 P.S. Example on getting a headless VM with vbox -

 #VBoxManage createvm --name MyServer --ostype Windows7 --register
 #VBoxManage createhd --filename MyServer.vdi --size 20
 #VBoxManage storagectl MyServer --name IDE Controller --add ide
 --controller PIIX3
 #VBoxManage storageattach MyServer --storagectl IDE Controller
 --port 0 --device 1 --type hdd --medium MyServer.vdi
 #VBoxManage storageattach MyServer --storagectl IDE Controller
 --port 1 --device 0 --type dvddrive --medium
 /home/myserver/install.iso
 #VBoxManage modifyvm MyServer --nic1 bridged --cableconnected1 on
 --bridgeadapter1 em0 --nictype1 82540EM
 #VBoxManage modifyvm MyServer --memory 1024 --acpi on --boot1 dvd
 #VBoxHeadless -n -m 5901 -s MyServer

 The VM is then accessible via vncviewer to the IP of the original
 machine port 5901

 --- kqemu-freebsd.c.orig2014-02-06 16:03:15.881335406 +0200
 +++ kqemu-freebsd.c2014-02-06 16:04:25.951329106 +0200
 @@ -109,7 +109,12 @@
  vm_offset_t va;
  vm_paddr_t pa;

 +#if __FreeBSD_version = 130
 +va = kmem_malloc(kernel_map, PAGE_SIZE, M_WAITOK);
 +#else
  va = kmem_alloc(kernel_map, PAGE_SIZE);
 +#endif
 +
  if (va == 0) {
  kqemu_log(kqemu_alloc_zeroed_page: NULL\n);
  return NULL;

 Oh well kqemu isn't even used by vbox, it's for emulaotors/qemu when

Well, the VirtualBox off topic was caused by someone saying in an earlier thread

me and
Dee (personally and not as the petitecloud development team) would be
willing to give $50 to anyone who can get kqemu running on 10 and/or show
how to get vbox to work headless


 built with the KQEMU knob and run with -enable-kqemu or -kernel-kqemu,
 and fixing _that_ needs most likely more changes than this. (I.e. I
 think I tried something similar and only got a panic.  And also qemu

Did you really try it? Can you explain then why it works for me with
both kqemu-kmod-devel and kqemu-kmod?
Can you please explain why this commit  -
http://svnweb.freebsd.org/base?view=revisionrevision=248084 - is
(ir-)relevant to the patch proposed?

 uses kqemu-kmod-devel, kqemu-kmod is only left for people still using
 even older qemu forks.)

  Sorry...
 Juergen

cheers,
Shteryana Shopova
___
freebsd-virtualization@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-virtualization
To unsubscribe, send any mail to 
freebsd-virtualization-unsubscr...@freebsd.org