mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-04-28 11:44:38 +00:00
iothread: Add ability to configure iothreads
IOthreads also known as x-data-plane allow IO to be processed in a separate thread rather than the main event loop. This produces much better IO throughput and latency. Signed-off-by: Archana Shinde <archana.m.shinde@intel.com>
This commit is contained in:
parent
82c67ab9b2
commit
a54de1835b
17
qemu/qemu.go
17
qemu/qemu.go
@ -1159,6 +1159,11 @@ type Knobs struct {
|
||||
Realtime bool
|
||||
}
|
||||
|
||||
// IOThread allows IO to be performed on a separate thread.
|
||||
type IOThread struct {
|
||||
ID string
|
||||
}
|
||||
|
||||
// Config is the qemu configuration structure.
|
||||
// It allows for passing custom settings and parameters to the qemu API.
|
||||
type Config struct {
|
||||
@ -1213,6 +1218,8 @@ type Config struct {
|
||||
// fds is a list of open file descriptors to be passed to the spawned qemu process
|
||||
fds []*os.File
|
||||
|
||||
IOThreads []IOThread
|
||||
|
||||
qemuParams []string
|
||||
}
|
||||
|
||||
@ -1481,6 +1488,15 @@ func (config *Config) appendBios() {
|
||||
}
|
||||
}
|
||||
|
||||
func (config *Config) appendIOThreads() {
|
||||
for _, t := range config.IOThreads {
|
||||
if t.ID != "" {
|
||||
config.qemuParams = append(config.qemuParams, "-object")
|
||||
config.qemuParams = append(config.qemuParams, fmt.Sprintf("iothread,id=%s", t.ID))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// LaunchQemu can be used to launch a new qemu instance.
|
||||
//
|
||||
// The Config parameter contains a set of qemu parameters and settings.
|
||||
@ -1504,6 +1520,7 @@ func LaunchQemu(config Config, logger QMPLog) (string, error) {
|
||||
config.appendKnobs()
|
||||
config.appendKernel()
|
||||
config.appendBios()
|
||||
config.appendIOThreads()
|
||||
|
||||
if err := config.appendCPUs(); err != nil {
|
||||
return "", err
|
||||
|
@ -67,6 +67,10 @@ func testAppend(structure interface{}, expected string, t *testing.T) {
|
||||
case RTC:
|
||||
config.RTC = s
|
||||
config.appendRTC()
|
||||
|
||||
case IOThread:
|
||||
config.IOThreads = []IOThread{s}
|
||||
config.appendIOThreads()
|
||||
}
|
||||
|
||||
result := strings.Join(config.qemuParams, " ")
|
||||
@ -525,3 +529,13 @@ func TestAppendRTC(t *testing.T) {
|
||||
|
||||
testAppend(rtc, rtcString, t)
|
||||
}
|
||||
|
||||
var ioThreadString = "-object iothread,id=iothread1"
|
||||
|
||||
func TestAppendIOThread(t *testing.T) {
|
||||
ioThread := IOThread{
|
||||
ID: "iothread1",
|
||||
}
|
||||
|
||||
testAppend(ioThread, ioThreadString, t)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user