@@ -3,6 +3,7 @@ package xhyve
33import (
44 "archive/tar"
55 "bytes"
6+ "bufio"
67 "errors"
78 "fmt"
89 "io"
@@ -37,7 +38,7 @@ const (
3738 defaultBootKernel = ""
3839 defaultBootInitrd = ""
3940 defaultBoot2DockerURL = ""
40- defaultBootCmd = "loglevel=3 user=docker console=ttyS0 console=tty0 noembed nomodeset norestore waitusb=10 base host=boot2docker "
41+ defaultBootCmd = ""
4142 defaultCPU = 1
4243 defaultCaCertPath = ""
4344 defaultDiskSize = 20000
8485 ErrMachineNotExist = errors .New ("machine does not exist" )
8586 diskRegexp = regexp .MustCompile ("^/dev/disk([0-9]+)" )
8687 kernelRegexp = regexp .MustCompile (`(vmlinu[xz]|bzImage)[\d]*` )
88+ kernelOptionRegexp = regexp .MustCompile (`(\t|\s{2})append` )
8789)
8890
8991// NewDriver creates a new VirtualBox driver with default settings.
@@ -610,6 +612,46 @@ func (d *Driver) publicSSHKeyPath() string {
610612 return d .GetSSHKeyPath () + ".pub"
611613}
612614
615+ func readLine (path string ) string {
616+ line := ""
617+ inFile , err := os .Open (path )
618+ if err != nil {
619+ log .Debugf ("Not able to open %s" , path )
620+ }
621+ defer inFile .Close ()
622+ scanner := bufio .NewScanner (inFile )
623+ scanner .Split (bufio .ScanLines )
624+ for scanner .Scan () {
625+ line = scanner .Text ()
626+ if kernelOptionRegexp .MatchString (line ) {
627+ break
628+ }
629+ }
630+ return line
631+ }
632+
633+ func (d * Driver ) extractKernelOptions () error {
634+ log .Debugf ("Extracting Kernel Options..." )
635+ volumeRootDir := d .ResolveStorePath (isoMountPath )
636+ if d .BootCmd == "" {
637+ err := filepath .Walk (volumeRootDir , func (path string , f os.FileInfo , err error ) error {
638+ if strings .Contains (path , "isolinux.cfg" ) {
639+ d .BootCmd = readLine (path )
640+ }
641+ return nil
642+ })
643+ if err != nil {
644+ return err
645+ }
646+ if d .BootCmd == "" {
647+ err = errors .New ("Not able to parse isolinux.cfg, Please use --xhyve-boot-cmd option" )
648+ return err
649+ }
650+ }
651+ log .Debugf ("Extracted Options %s" , d .BootCmd )
652+ return nil
653+ }
654+
613655func (d * Driver ) extractKernelImages () error {
614656 log .Debugf ("Mounting %s" , isoFilename )
615657
@@ -619,6 +661,10 @@ func (d *Driver) extractKernelImages() error {
619661 return err
620662 }
621663
664+ if err := d .extractKernelOptions (); err != nil {
665+ return err
666+ }
667+
622668 defer func () error {
623669 log .Debugf ("Unmounting %s" , isoFilename )
624670 return hdiutil ("detach" , volumeRootDir )
0 commit comments