Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Commit

Permalink
clh: remove cli builder
Browse files Browse the repository at this point in the history
Remove cli builder code as now that we use http client

Signed-off-by: Bo Chen <[email protected]>
Signed-off-by: Jose Carlos Venegas Munoz <[email protected]>
  • Loading branch information
jcvenegas committed Dec 6, 2019
1 parent f73723a commit 9f15dd2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 975 deletions.
292 changes: 2 additions & 290 deletions virtcontainers/clh.go
Original file line number Diff line number Diff line change
Expand Up @@ -816,7 +816,7 @@ func (clh *cloudHypervisor) LaunchClh() (string, int, error) {
return "", -1, err
}

args := []string{cscApisocket, clh.state.apiSocket}
args := []string{cscAPIsocket, clh.state.apiSocket}
if clh.config.Debug {

logfile, err := clh.logFilePath(clh.id)
Expand Down Expand Up @@ -867,298 +867,10 @@ const (
)

const (
cscApisocket string = "--api-socket"
cscCmdline string = "--cmdline"
cscConsole string = "--console"
cscCpus string = "--cpus"
cscDisk string = "--disk"
cscFs string = "--fs"
cscKernel string = "--kernel"
cscAPIsocket string = "--api-socket"
cscLogFile string = "--log-file"
cscMemory string = "--memory"
cscNet string = "--net"
cscRng string = "--rng"
cscSerial string = "--serial"
cscVsock string = "--vsock"
)

type CommandLineBuilder interface {
AddKernelParameters(cmdline []Param)
SetConsole(console *CLIConsole)
SetCpus(cpus *CLICpus)
SetDisk(disk *CLIDisk)
SetFs(fs *CLIFs)
SetKernel(kernel *CLIKernel)
SetMemory(memory *CLIMemory)
AddNet(net CLINet)
SetRng(rng *CLIRng)
SetSerial(serial *CLISerialConsole)
SetVsock(vsock *CLIVsock)
SetAPISocket(apiSocket *CLIAPISocket)
SetLogFile(logFile *CLILogFile)
GetCommandLine() (*CommandLine, error)
}

type CLIOption interface {
Build(cmdline *CommandLine)
}

type CommandLine struct {
args []string
}

//**********************************
// The (virtio) Console
//**********************************
type CLIConsole struct {
consoleType string
filePath string
iommu bool
}

func (o *CLIConsole) Build(cmdline *CommandLine) {

cmdline.args = append(cmdline.args, cscConsole)

consoleArg := ""
if o.consoleType == cctFILE {
consoleArg = o.consoleType + "=" + o.filePath
if o.iommu {
consoleArg += ",iommu=on"
} else {
consoleArg += ",iommu=off"
}
} else {
consoleArg = o.consoleType
}

cmdline.args = append(cmdline.args, consoleArg)
}

//**********************************
// The serial port
//**********************************
type CLISerialConsole struct {
consoleType string
filePath string
}

func (o *CLISerialConsole) Build(cmdline *CommandLine) {

cmdline.args = append(cmdline.args, cscSerial)
if o.consoleType == cctFILE {
cmdline.args = append(cmdline.args, o.consoleType+"="+o.filePath)
} else {
cmdline.args = append(cmdline.args, o.consoleType)
}

}

//**********************************
// The API socket
//**********************************
type CLIAPISocket struct {
socketPath string
}

func (o *CLIAPISocket) Build(cmdline *CommandLine) {

cmdline.args = append(cmdline.args, cscApisocket)
if o.socketPath != "" {
cmdline.args = append(cmdline.args, o.socketPath)
}
}

//**********************************
// The amount of memory in Mb
//**********************************
type CLIMemory struct {
memorySize uint32
backingFile string
}

func (o *CLIMemory) Build(cmdline *CommandLine) {

cmdline.args = append(cmdline.args, cscMemory)
if o.backingFile == "" {
cmdline.args = append(cmdline.args, "size="+strconv.FormatUint(uint64(o.memorySize), 10)+"M")
} else {
cmdline.args = append(cmdline.args, "size="+strconv.FormatUint(uint64(o.memorySize), 10)+"M,file="+o.backingFile)
}

}

//**********************************
// The number of CPU's
//**********************************
type CLICpus struct {
cpus uint32
}

func (o *CLICpus) Build(cmdline *CommandLine) {

cmdline.args = append(cmdline.args, cscCpus)
cmdline.args = append(cmdline.args, strconv.FormatUint(uint64(o.cpus), 10))

}

//**********************************
// The Path to the kernel image
//**********************************
type CLIKernel struct {
path string
}

func (o *CLIKernel) Build(cmdline *CommandLine) {

cmdline.args = append(cmdline.args, cscKernel)
cmdline.args = append(cmdline.args, o.path)

}

//****************************************
// The Path to the root (boot) disk image
//****************************************
type CLIDisk struct {
path string
iommu bool
}

func (o *CLIDisk) Build(cmdline *CommandLine) {

cmdline.args = append(cmdline.args, cscDisk)
if o.iommu {
cmdline.args = append(cmdline.args, "path="+o.path+",iommu=on")
} else {
cmdline.args = append(cmdline.args, "path="+o.path+",iommu=off")
}

}

//****************************************
// The random device
//****************************************
type CLIRng struct {
src string
iommu bool
}

func (o *CLIRng) Build(cmdline *CommandLine) {

cmdline.args = append(cmdline.args, cscRng)
if o.iommu {
cmdline.args = append(cmdline.args, "src="+o.src+",iommu=on")
} else {
cmdline.args = append(cmdline.args, "src="+o.src+",iommu=off")
}

}

//****************************************
// The VSock socket
//****************************************
type CLIVsock struct {
socketPath string
cid uint32
iommu bool
}

func (o *CLIVsock) Build(cmdline *CommandLine) {

cmdline.args = append(cmdline.args, cscVsock)
if o.iommu {
cmdline.args = append(cmdline.args, "cid="+strconv.FormatUint(uint64(o.cid), 10)+",sock="+o.socketPath+",iommu=on")
} else {
cmdline.args = append(cmdline.args, "cid="+strconv.FormatUint(uint64(o.cid), 10)+",sock="+o.socketPath+",iommu=off")
}
}

//****************************************
// The shard (virtio) file system
//****************************************
type CLIFs struct {
tag string
socketPath string
queues uint32
queueSize uint32
dax bool
cacheSize string
}

func (o *CLIFs) Build(cmdline *CommandLine) {

cmdline.args = append(cmdline.args, cscFs)

fsarg := "tag=" + o.tag + ",sock=" + o.socketPath
if o.dax {
fsarg += ",dax=on"
if o.cacheSize != "" {
fsarg += ",cache_size=" + o.cacheSize
}
} else {
fsarg += ",num_queues=" + strconv.FormatUint(uint64(o.queues), 10) + ",queue_size=" + strconv.FormatUint(uint64(o.queueSize), 10)
}
cmdline.args = append(cmdline.args, fsarg)
}

//****************************************
// The net (nic)
//****************************************
type CLINet struct {
device string
ip string
mask string
mac string
iommu bool
}

type CLINets struct {
networks []CLINet
}

func (o *CLINets) Build(cmdline *CommandLine) {

cmdline.args = append(cmdline.args, cscNet)

networks := ""
netIndex := 1
for _, net := range o.networks {
cnet := "tap=tap" + strconv.FormatUint(uint64(netIndex), 10)
if net.ip != "" && net.mask != "" {
cnet += ",ip=" + net.ip + ",mask=" + net.mask
}
if net.mac != "" {
cnet += ",mac=" + net.mac
}

if net.iommu {
cnet += ",iommu=on"
}
if netIndex > 1 {
networks += "," + cnet
} else {
networks += cnet
}
netIndex++
}
cmdline.args = append(cmdline.args, networks)
}

//****************************************
// The log file
//****************************************
type CLILogFile struct {
path string
}

func (o *CLILogFile) Build(cmdline *CommandLine) {

if o.path != "" {
cmdline.args = append(cmdline.args, cscLogFile)
cmdline.args = append(cmdline.args, o.path)
}
}

//****************************************
// The kernel command line
//****************************************
Expand Down
Loading

0 comments on commit 9f15dd2

Please sign in to comment.