mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-08-15 22:53:43 +00:00
govmm: Refactor code to get rid of redundant code
Get rid of redundant return values from function. args and blockdevArgs used to return different values to maintain compatilibity between qemu versions. These are exactly the same now. Signed-off-by: Archana Shinde <archana.m.shinde@intel.com>
This commit is contained in:
parent
00860a7e43
commit
598884f374
@ -771,9 +771,7 @@ func (q *QMP) ExecuteQuit(ctx context.Context) error {
|
||||
return q.executeCommand(ctx, "quit", nil, nil)
|
||||
}
|
||||
|
||||
func (q *QMP) blockdevAddBaseArgs(driver, device, blockdevID, aio string, ro bool) (map[string]interface{}, map[string]interface{}) {
|
||||
var args map[string]interface{}
|
||||
|
||||
func (q *QMP) blockdevAddBaseArgs(driver, device, blockdevID, aio string, ro bool) map[string]interface{} {
|
||||
blockdevArgs := map[string]interface{}{
|
||||
"driver": "raw",
|
||||
"read-only": ro,
|
||||
@ -785,9 +783,8 @@ func (q *QMP) blockdevAddBaseArgs(driver, device, blockdevID, aio string, ro boo
|
||||
}
|
||||
|
||||
blockdevArgs["node-name"] = blockdevID
|
||||
args = blockdevArgs
|
||||
|
||||
return args, blockdevArgs
|
||||
return blockdevArgs
|
||||
}
|
||||
|
||||
// ExecuteBlockdevAdd sends a blockdev-add to the QEMU instance. device is the
|
||||
@ -795,7 +792,7 @@ func (q *QMP) blockdevAddBaseArgs(driver, device, blockdevID, aio string, ro boo
|
||||
// used to name the device. As this identifier will be passed directly to QMP,
|
||||
// it must obey QMP's naming rules, e,g., it must start with a letter.
|
||||
func (q *QMP) ExecuteBlockdevAdd(ctx context.Context, device, blockdevID, aio string, ro bool) error {
|
||||
args, _ := q.blockdevAddBaseArgs("host_device", device, blockdevID, aio, ro)
|
||||
args := q.blockdevAddBaseArgs("host_device", device, blockdevID, aio, ro)
|
||||
|
||||
return q.executeCommand(ctx, "blockdev-add", args, nil)
|
||||
}
|
||||
@ -808,28 +805,28 @@ func (q *QMP) ExecuteBlockdevAdd(ctx context.Context, device, blockdevID, aio st
|
||||
// is enabled. noFlush denotes whether flush requests for the device are
|
||||
// ignored.
|
||||
func (q *QMP) ExecuteBlockdevAddWithCache(ctx context.Context, device, blockdevID, aio string, direct, noFlush, ro bool) error {
|
||||
args, blockdevArgs := q.blockdevAddBaseArgs("host_device", device, blockdevID, aio, ro)
|
||||
blockdevArgs := q.blockdevAddBaseArgs("host_device", device, blockdevID, aio, ro)
|
||||
|
||||
blockdevArgs["cache"] = map[string]interface{}{
|
||||
"direct": direct,
|
||||
"no-flush": noFlush,
|
||||
}
|
||||
|
||||
return q.executeCommand(ctx, "blockdev-add", args, nil)
|
||||
return q.executeCommand(ctx, "blockdev-add", blockdevArgs, nil)
|
||||
}
|
||||
|
||||
// ExecuteBlockdevAddWithDriverCache has three one parameter driver
|
||||
// than ExecuteBlockdevAddWithCache.
|
||||
// Parameter driver can set the driver of block device.
|
||||
func (q *QMP) ExecuteBlockdevAddWithDriverCache(ctx context.Context, driver, device, blockdevID, aio string, direct, noFlush, ro bool) error {
|
||||
args, blockdevArgs := q.blockdevAddBaseArgs(driver, device, blockdevID, aio, ro)
|
||||
blockdevArgs := q.blockdevAddBaseArgs(driver, device, blockdevID, aio, ro)
|
||||
|
||||
blockdevArgs["cache"] = map[string]interface{}{
|
||||
"direct": direct,
|
||||
"no-flush": noFlush,
|
||||
}
|
||||
|
||||
return q.executeCommand(ctx, "blockdev-add", args, nil)
|
||||
return q.executeCommand(ctx, "blockdev-add", blockdevArgs, nil)
|
||||
}
|
||||
|
||||
// ExecuteDeviceAdd adds the guest portion of a device to a QEMU instance
|
||||
|
Loading…
Reference in New Issue
Block a user