# Xen and X.org ?



## Adrien2002 (Jan 3, 2018)

Hi !
So I want to continue my training with all my classmates. We are using Windows 10 and Virtualbox but I want to use FreeBSD as DOM0 and install Xen to run Windows Server and other Windows clients as DOMU (I'm following an IT Helpdesk training).

The question is : Can I start X on my FreeBSD/DOM0 to use SDL2 to display the DOMU Windows ? I have a GTX 765m and have to use the nvidia-driver package and the "nvidia' driver in X.org configuration file. What will I have to do to run X after booting FreeBSD as a DOM0 ?


----------



## SirDice (Jan 3, 2018)

Adrien2002 said:


> I want to use FreeBSD as DOM0 and install Xen to run Windows Server and other Windows clients as DOMU (I'm following an IT Helpdesk training)


Xen on FreeBSD is HIGHLY experimental. Besides that, you actually need a Linux kernel for the Dom0. So unless you want to spend a lot of time battling with Xen I wouldn't recommend it. 

https://wiki.freebsd.org/FreeBSD/Xen

If you really want to use FreeBSD for this using bhyve(8) (FreeBSD's own hypervisor) is probably a better solution. Combined with sysutils/vm-bhyve it makes an excellent virtualization platform. 

https://github.com/churchers/vm-bhyve/wiki/Running-Windows


----------



## Adrien2002 (Jan 3, 2018)

Sounds really interesting but after reading twice the steps on how to make a vm with Windows, I have three questions :

It says to use VNC to get a display but it doesn't say how to use it to connect to the guest. If I try the bhyve solution, I'll need to be quickly effective. Is it complicated to use VNC to connect to a Windows guest ? I never used VNC in the past, I know it's universal and I doubt it is complicated but everything is when you know nothing about it.

When do we create a virtual hard drive disk and how ? Do we use Qemu ? Do we use dd ?

Can we bridge the network to get an Internet access and a real IP from the router ? Cause I'll need to connect the guests between themselves for the excercises.

Thank you very much for introducing bhyve to me. My machine isn't that powerful to run a Windows 10 + many other Windows 7 but if I use a FreeBSD instead of Windows 10, I'll save a lot for the VMs


----------



## SirDice (Jan 3, 2018)

Adrien2002 said:


> It says to use VNC to get a display but it doesn't say how to use it to connect to the guest.


Simple really. Just look at the output from `vm list`:


```
root@molly:~ # vm list
NAME            DATASTORE       LOADER      CPU    MEMORY    VNC                  AUTOSTART    STATE
fbsdtest        default         bhyveload   1      512M      -                    No           Stopped
pptimg01        default         uefi        1      512M      -                    No           Stopped
ppttst01        default         uefi        1      512M      -                    No           Stopped
sdgame01        default         grub        2      4096M     -                    No           Stopped
sdkerb01        default         uefi        1      512M      -                    No           Stopped
sdtest01        default         uefi        1      512M      0.0.0.0:5900         No           Running (63226)
wintermute      default         bhyveload   4      2048M     -                    Yes [1]      Running (1032)
```
My sdtest01 is a VNC capable VM, you simply connect your VNC client to the IP address of the host and use the correct VNC port.



Adrien2002 said:


> When do we create a virtual hard drive disk and how ? Do we use Qemu ? Do we use dd ?


Based on templates.

```
root@molly:~ # vm create -t freebsd-zvol sdtest3
root@molly:~ # vm list
NAME            DATASTORE       LOADER      CPU    MEMORY    VNC                  AUTOSTART    STATE
fbsdtest        default         bhyveload   1      512M      -                    No           Stopped
pptimg01        default         uefi        1      512M      -                    No           Stopped
ppttst01        default         uefi        1      512M      -                    No           Stopped
sdgame01        default         grub        2      4096M     -                    No           Stopped
sdkerb01        default         uefi        1      512M      -                    No           Stopped
sdtest01        default         uefi        1      512M      0.0.0.0:5900         No           Running (63226)
sdtest3         default         bhyveload   1      512M      -                    No           Stopped
wintermute      default         bhyveload   4      2048M     -                    Yes [1]      Running (1032)
root@molly:~ # cat /vm/.templates/freebsd-zvol.conf
loader="bhyveload"
cpu=1
memory=512M
network0_type="virtio-net"
network0_switch="public"
disk0_type="virtio-blk"
disk0_name="disk0"
disk0_dev="sparse-zvol"
```



Adrien2002 said:


> Can we bridge the network to get an Internet access and a real IP from the router ?


Sure, you can make it as complex as you want.

```
# vm switch list
NAME            TYPE       IDENT       VLAN      NAT          PORTS
public          auto       bridge0     -         -            em0
```
I have a public network named public that's bridged to the physical em0 of the host. My VMs are tied to this public virtual switch.


----------



## SirDice (Jan 3, 2018)

I haven't done any extensive testing with it yet but for your situation creating several pre-configured VM images could be helpful. That would allow you to quickly destroy and recreate a new VM based on an image. 


```
root@molly:~ # vm image list
UUID                                   NAME             CREATED                        DESCRIPTION
e6c113f8-f0c4-11e6-b502-94de8071eddd   pptimg01         Sun Feb 12 02:45:15 CET 2017   No description provided
root@molly:~ # vm list
NAME            DATASTORE       LOADER      CPU    MEMORY    VNC                  AUTOSTART    STATE
fbsdtest        default         bhyveload   1      512M      -                    No           Stopped
pptimg01        default         uefi        1      512M      -                    No           Stopped
ppttst01        default         uefi        1      512M      -                    No           Stopped
sdgame01        default         grub        2      4096M     -                    No           Stopped
sdkerb01        default         uefi        1      512M      -                    No           Stopped
sdtest01        default         uefi        1      512M      0.0.0.0:5900         No           Running (63226)
sdtest3         default         bhyveload   1      512M      -                    No           Stopped
wintermute      default         bhyveload   4      2048M     -                    Yes [1]      Running (1032)
root@molly:~ # vm image provision e6c113f8-f0c4-11e6-b502-94de8071eddd ppttst02
Unpacking guest image, this may take some time...
root@molly:~ # vm list
NAME            DATASTORE       LOADER      CPU    MEMORY    VNC                  AUTOSTART    STATE
fbsdtest        default         bhyveload   1      512M      -                    No           Stopped
pptimg01        default         uefi        1      512M      -                    No           Stopped
ppttst01        default         uefi        1      512M      -                    No           Stopped
ppttst02        default         uefi        1      512M      -                    No           Stopped
sdgame01        default         grub        2      4096M     -                    No           Stopped
sdkerb01        default         uefi        1      512M      -                    No           Stopped
sdtest01        default         uefi        1      512M      0.0.0.0:5900         No           Running (63226)
sdtest3         default         bhyveload   1      512M      -                    No           Stopped
wintermute      default         bhyveload   4      2048M     -                    Yes [1]      Running (1032)
```


----------

