# Xen VM cannot see its VHD



## justinhaynes (May 5, 2018)

I'm using FreeBSD 11.1-RELEASE as a Xen Dom0 as described in The FreeBSD Handbook in https://www.freebsd.org/doc/handbook/virtualization-host-xen.html ">, and I am having a problem with having a CentOS guest see the vhd hard drive I am trying to present to it.  The VM does boot up with the CentOS Everything .iso for version 7.4, but I have no options to select for local storage to which to install CentOS.

I am using cbsd() to manage the Xen DomU VM I am creating.  I'll skip describing all the steps I took with cbsd and focus instead on the Xen machine and vhd drive itself.

I start the vm like this:
`cbsd@Xen01> xstart
List of offline VMs
0 .. CANCEL
a .. centos1 on local`

(I selected option a, centos1):

`VRDP is enabled. VNC port: 5900. VNC pass: cbsd
VRDP is enabled. VNC bind/port: 127.0.0.1:5900
For attach VM console, use: vncviewer 127.0.0.1:5900
Resolution: x.
VNC pass: cbsd
[debug]: /usr/local/sbin/xl -vvv create -c /usr/jails/jails-system/centos1/xen.cfg

PID: 0`

We can see it is running:
`root@Xen01:/usr/jails # cbsd xls
JNAME    VM_RAM  VM_CPUS  VM_OS_TYPE  IP4_ADDR  STATUS  VNC_PORT
centos1  2048    2        linux       -         On      127.0.0.1:5900`

In the attached xen.cfg, see the disks line:

```
disk = [
'/usr/jails/jails-data/centos1-data/dsk1.vhd,raw,hda,rw', '/usr/jails/src/iso/cbsd-iso-CentOS-7-x86_64-DVD-1708.iso,raw,hdb:cdrom,r'
]
```

The dsk1.vhd file is nothing more than `dd=/dev/zero if=dsk1.vhd`.   In the attached screenshot you can see the symptom. 
`root@Xen01:/usr/jails # ls -alh jails-data/centos1-data/dsk1.vhd
-rw-rw-r--  1 root  wheel    10G May  5 21:29 jails-data/centos1-data/dsk1.vhd
root@Xen01:/usr/jails # file jails-data/centos1-data/dsk1.vhd
jails-data/centos1-data/dsk1.vhd: data
root@Xen01:/usr/jails #`

Is there some preparation I should be doing for the dsk1.vhd?


----------



## justinhaynes (May 5, 2018)

I do see two block devices "attached" when I ask the Dom-0:

`root@Xen01:/usr/jails/jails-data/centos1-data # xl block-list centos1
Vdev  BE  handle state evt-ch ring-ref BE-path                       
768   0   7      1     -1     -1       /local/domain/0/backend/vbd/7/768
832   0   7      6     -1     -1       /local/domain/0/backend/qdisk/7/832
root@Xen01:/usr/jails/jails-data/centos1-data #`

I have seen this when the /usr/jails/jails-data/centos1-data/dsk1.vhd file was an empty file and also after I had written a partitioning scheme to it using mdconfig and gpart

`root@Xen01:/usr/jails/jails-data/centos1-data # file dsk1.vhd 
dsk1.vhd: DOS/MBR boot sector
root@Xen01:/usr/jails/jails-data/centos1-data #`


----------



## Oko (May 5, 2018)

You shouldn't!!! FreeBSD Dom0 is highly experimental. That section just like many others obsolete sections should be deleted from the handbook.


----------



## justinhaynes (May 5, 2018)

Oko, it's really OK.  This is a lab, not a production machine. . Also, for a feature that requires the FreeBSD team to maintain an additional kernel, and for Citrix software engineer, Roger Pau Monne to invest years into this project, I'm OK taking the risk on something new. Finally, I think Xen makes good architectural and strategic sense.  

Perhaps you are right, and it won't last in FreeBSD, but given the choice of some LINUX distro with its pantheon of individual and corporate interests and separate kernel, and a single unified system where all developers are basically on the same page about what kind of an airplane they are trying to build, I'll go with FreeBSD and not with LINUX or ESX as my hypervisor.  And to your point, I'm *very* appreciative of your attitude and of others in the FreeBSD community who consider a feature that has been around for several years to be "new" and who would caution a new user to go only with what is mature and core to the system.

I'll try bhyve and use that for now until I can figure this out.  Admittedly I have been away from FreeBSD for a very long time, and haven't even scratched the surface of Xen, so its nice to have so many tools in the playground.  I can still select something that will work and I have other options to try alongside.  That's another think I find really interesting about cbsd.


----------

