Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UVMOptions.SCSIControllerCount should be uint #397

Merged
merged 1 commit into from
Nov 30, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions functional/lcow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
// TestLCOWUVMNoSCSINoVPMemInitrd starts an LCOW utility VM without a SCSI controller and
// no VPMem device. Uses initrd.
func TestLCOWUVMNoSCSINoVPMemInitrd(t *testing.T) {
scsiCount := 0
var scsiCount uint32 = 0
var vpmemCount uint32 = 0
opts := &uvm.UVMOptions{
OperatingSystem: "linux",
Expand All @@ -36,7 +36,7 @@ func TestLCOWUVMNoSCSINoVPMemInitrd(t *testing.T) {
// TestLCOWUVMNoSCSISingleVPMemVHD starts an LCOW utility VM without a SCSI controller and
// only a single VPMem device. Uses VPMEM VHD
func TestLCOWUVMNoSCSISingleVPMemVHD(t *testing.T) {
scsiCount := 0
var scsiCount uint32 = 0
var vpmemCount uint32 = 1
var prfst uvm.PreferredRootFSType = uvm.PreferredRootFSTypeVHD
opts := &uvm.UVMOptions{
Expand Down
16 changes: 8 additions & 8 deletions internal/uvm/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ type UVMOptions struct {
LayerFolders []string // Set of folders for base layers and scratch. Ordered from top most read-only through base read-only layer, followed by scratch

// LCOW specific parameters
BootFilesPath string // Folder in which kernel and root file system reside. Defaults to \Program Files\Linux Containers
KernelFile string // Filename under BootFilesPath for the kernel. Defaults to `kernel`
RootFSFile string // Filename under BootFilesPath for the UVMs root file system. Defaults are `initrd.img` or `rootfs.vhd`.
KernelBootOptions string // Additional boot options for the kernel
EnableGraphicsConsole bool // If true, enable a graphics console for the utility VM
ConsolePipe string // The named pipe path to use for the serial console. eg \\.\pipe\vmpipe
SCSIControllerCount *int // The number of SCSI controllers. Defaults to 1 if omitted. Currently we only support 0 or 1.
BootFilesPath string // Folder in which kernel and root file system reside. Defaults to \Program Files\Linux Containers
KernelFile string // Filename under BootFilesPath for the kernel. Defaults to `kernel`
RootFSFile string // Filename under BootFilesPath for the UVMs root file system. Defaults are `initrd.img` or `rootfs.vhd`.
KernelBootOptions string // Additional boot options for the kernel
EnableGraphicsConsole bool // If true, enable a graphics console for the utility VM
ConsolePipe string // The named pipe path to use for the serial console. eg \\.\pipe\vmpipe
SCSIControllerCount *uint32 // The number of SCSI controllers. Defaults to 1 if omitted. Currently we only support 0 or 1.

// Fields that can be configured via OCI annotations in runhcs.

Expand Down Expand Up @@ -183,7 +183,7 @@ func Create(opts *UVMOptions) (_ *UtilityVM, err error) {
scsi["0"] = hcsschema.Scsi{Attachments: attachments}
uvm.scsiControllerCount = 1
if opts.SCSIControllerCount != nil {
if *opts.SCSIControllerCount < 0 || *opts.SCSIControllerCount > 1 {
if *opts.SCSIControllerCount > 1 {
return nil, fmt.Errorf("SCSI controller count must be 0 or 1") // Future extension here for up to 4
}
uvm.scsiControllerCount = *opts.SCSIControllerCount
Expand Down
2 changes: 1 addition & 1 deletion internal/uvm/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ type UtilityVM struct {

// SCSI devices that are mapped into a Windows or Linux utility VM
scsiLocations [4][64]scsiInfo // Hyper-V supports 4 controllers, 64 slots per controller. Limited to 1 controller for now though.
scsiControllerCount int // Number of SCSI controllers in the utility VM
scsiControllerCount uint32 // Number of SCSI controllers in the utility VM

// Plan9 are directories mapped into a Linux utility VM
plan9Shares map[string]*plan9Info
Expand Down