# windows server can't restart on freebsd bhyve



## joggx (Jan 26, 2019)

I installed Windows 2012 r2 vm on bhyve on freebsd 11.1. It runs fine but biggest problem it can't restart or properly shut down itself. After the shutdown i need to destroy the vm and then start the vm manually. Does someone have the same problem?

The reason I use bhyve is that the physical host runs freebsd.


----------



## aragats (Jan 26, 2019)

You have to destroy the VM anyway, but you can check the exit code and recreate it when restart is needed.
Exic code 0 means restart, 1 – halt. I use the following script to run my Windows 2019 server:

```
HD=/dev/zvol/zoo/win2019
UEFI=/usr/local/share/uefi-firmware/BHYVE_UEFI.fd
MEM=4G
VM="Win2019"
IF="tap0"
MAC="mac=00:A0:98:78:32:19"
DPY="w=1600,h=900"

while true ; do
    bhyve \
      -c 4 -S \
      -s 0,hostbridge \
      -s 3,ahci-hd,$HD,sectorsize=512 \
      -s 5,fbuf,tcp=0.0.0.0:5902,$DPY \
      -s 6,xhci,tablet \
      -s 10,virtio-net,$IF,$MAC \
      -s 31,lpc \
      -l com1,/dev/nmdm0A \
      -l com2,/dev/nmdm1A \
      -l bootrom,$UEFI \
      -m $MEM -H -w \
      $VM

    RES=$?
    bhyvectl --destroy --vm=$VM
    if [ $RES -eq 1 ] ; then
        exit 1
    fi
    sleep 5
done
```


----------



## joggx (Jan 26, 2019)

Thanks for sharing the info. why can't bhyve just automatically destroy and restart the vm like others do? That's a  very basic feature. I also found Windows's networking stack running on bhyve is much slower than on hyper-v.


----------



## aragats (Jan 26, 2019)

joggx said:


> why can't bhyve just automatically destroy and restart the vm like others do?


Well, IMO, this approach is better: to get that "common" behavior you can use a simple wrapper script, but in certain situations you may want to check the exit code for other decisions. E.g. VirtualBox may loop infinitely if something is wrong, and you'll not know.


joggx said:


> I also found Windows's networking stack running on bhyve is much slower than on hyper-v


Have you measured the actual speed? I get around 5Gb/s with bhyve(8) for the host<->guest communication.


----------



## joggx (Jan 26, 2019)

Correction: it is the disk I/O. The speed is half of that the freebsd jail running on the same machine (both on zfs).


----------



## SirDice (Feb 6, 2019)

joggx said:


> I installed Windows 2012 r2 vm on bhyve on freebsd 11.1.


Make sure to update some time soon, FreeBSD 11.1 is End-of-Life and not supported any more. Support for 11.1 ended three months after the release of 11.2.


----------

