Bug 210410 - /usr/share/examples/bhyve/vmrun.sh assumes virtio_diskdev must be a regular file
Summary: /usr/share/examples/bhyve/vmrun.sh assumes virtio_diskdev must be a regular ...
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 10.3-RELEASE
Hardware: Any Any
: --- Affects Some People
Assignee: freebsd-virtualization (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-06-20 16:10 UTC by Victor Sudakov
Modified: 2016-08-10 16:31 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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