Bug 210410

Summary: /usr/share/examples/bhyve/vmrun.sh assumes virtio_diskdev must be a regular file
Product: Base System Reporter: Victor Sudakov <vas>
Component: binAssignee: freebsd-virtualization (Nobody) <virtualization>
Status: Closed FIXED    
Severity: Affects Some People CC: jhb, vas
Priority: ---    
Version: 10.3-RELEASE   
Hardware: Any   
OS: Any   

Description Victor Sudakov 2016-06-20 16:10:50 UTC
The /usr/share/examples/bhyve/vmrun.sh script has the following code:

   # Create the virtio diskdev file if needed
    if [ ! -f ${virtio_diskdev} ]; then
            echo "virtio disk device file \"${virtio_diskdev}\" does not exist."
            echo "Creating it ..."
            truncate -s 8G ${virtio_diskdev} > /dev/null
    fi

which assumes that ${virtio_diskdev} should be a regular file. When  ${virtio_diskdev} is a ZFS volume or an md(4) memory disk, it causes an unnecessary warning message and an attempt to truncate the device.

Should we replace -f with something more reasonable, perhaps "-f -o -c"
Comment 1 John Baldwin freebsd_committer freebsd_triage 2016-08-10 16:29:37 UTC
This was fixed in HEAD/11 by r273102.  It just needs to be merged to 10.
Comment 2 commit-hook freebsd_committer freebsd_triage 2016-08-10 16:31:27 UTC
A commit references this bug:

Author: jhb
Date: Wed Aug 10 16:31:15 UTC 2016
New revision: 303925
URL: https://svnweb.freebsd.org/changeset/base/303925

Log:
  MFC 273102:
  Use '-e' to check if the virtio backing file has already been created.

  The '-f' check works fine on a regular file but not if the backing file is
  a device (e.g., /dev/md0). In this case it would print a misleading but
  otherwise benign message about the backing file not being present.

  PR:		210410

Changes:
_U  stable/10/
  stable/10/share/examples/bhyve/vmrun.sh