qmp: Pass aio backend while adding block device

Allow govmm to pass aio backend while adding block device.

Signed-off-by: Archana Shinde <archana.m.shinde@intel.com>
This commit is contained in:
Archana Shinde 2022-08-01 14:30:15 -07:00
parent e1b49d7586
commit 00860a7e43
2 changed files with 12 additions and 10 deletions

View File

@ -771,7 +771,7 @@ func (q *QMP) ExecuteQuit(ctx context.Context) error {
return q.executeCommand(ctx, "quit", nil, nil) return q.executeCommand(ctx, "quit", nil, nil)
} }
func (q *QMP) blockdevAddBaseArgs(driver, device, blockdevID string, ro bool) (map[string]interface{}, map[string]interface{}) { func (q *QMP) blockdevAddBaseArgs(driver, device, blockdevID, aio string, ro bool) (map[string]interface{}, map[string]interface{}) {
var args map[string]interface{} var args map[string]interface{}
blockdevArgs := map[string]interface{}{ blockdevArgs := map[string]interface{}{
@ -780,6 +780,7 @@ func (q *QMP) blockdevAddBaseArgs(driver, device, blockdevID string, ro bool) (m
"file": map[string]interface{}{ "file": map[string]interface{}{
"driver": driver, "driver": driver,
"filename": device, "filename": device,
"aio": aio,
}, },
} }
@ -793,8 +794,8 @@ func (q *QMP) blockdevAddBaseArgs(driver, device, blockdevID string, ro bool) (m
// path of the device to add, e.g., /dev/rdb0, and blockdevID is an identifier // path of the device to add, e.g., /dev/rdb0, and blockdevID is an identifier
// used to name the device. As this identifier will be passed directly to QMP, // 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. // it must obey QMP's naming rules, e,g., it must start with a letter.
func (q *QMP) ExecuteBlockdevAdd(ctx context.Context, device, blockdevID string, ro bool) error { func (q *QMP) ExecuteBlockdevAdd(ctx context.Context, device, blockdevID, aio string, ro bool) error {
args, _ := q.blockdevAddBaseArgs("host_device", device, blockdevID, ro) args, _ := q.blockdevAddBaseArgs("host_device", device, blockdevID, aio, ro)
return q.executeCommand(ctx, "blockdev-add", args, nil) return q.executeCommand(ctx, "blockdev-add", args, nil)
} }
@ -806,8 +807,8 @@ func (q *QMP) ExecuteBlockdevAdd(ctx context.Context, device, blockdevID string,
// direct denotes whether use of O_DIRECT (bypass the host page cache) // direct denotes whether use of O_DIRECT (bypass the host page cache)
// is enabled. noFlush denotes whether flush requests for the device are // is enabled. noFlush denotes whether flush requests for the device are
// ignored. // ignored.
func (q *QMP) ExecuteBlockdevAddWithCache(ctx context.Context, device, blockdevID string, direct, noFlush, ro bool) error { func (q *QMP) ExecuteBlockdevAddWithCache(ctx context.Context, device, blockdevID, aio string, direct, noFlush, ro bool) error {
args, blockdevArgs := q.blockdevAddBaseArgs("host_device", device, blockdevID, ro) args, blockdevArgs := q.blockdevAddBaseArgs("host_device", device, blockdevID, aio, ro)
blockdevArgs["cache"] = map[string]interface{}{ blockdevArgs["cache"] = map[string]interface{}{
"direct": direct, "direct": direct,
@ -820,8 +821,8 @@ func (q *QMP) ExecuteBlockdevAddWithCache(ctx context.Context, device, blockdevI
// ExecuteBlockdevAddWithDriverCache has three one parameter driver // ExecuteBlockdevAddWithDriverCache has three one parameter driver
// than ExecuteBlockdevAddWithCache. // than ExecuteBlockdevAddWithCache.
// Parameter driver can set the driver of block device. // Parameter driver can set the driver of block device.
func (q *QMP) ExecuteBlockdevAddWithDriverCache(ctx context.Context, driver, device, blockdevID string, direct, noFlush, ro bool) error { func (q *QMP) ExecuteBlockdevAddWithDriverCache(ctx context.Context, driver, device, blockdevID, aio string, direct, noFlush, ro bool) error {
args, blockdevArgs := q.blockdevAddBaseArgs(driver, device, blockdevID, ro) args, blockdevArgs := q.blockdevAddBaseArgs(driver, device, blockdevID, aio, ro)
blockdevArgs["cache"] = map[string]interface{}{ blockdevArgs["cache"] = map[string]interface{}{
"direct": direct, "direct": direct,

View File

@ -1292,12 +1292,13 @@ func (q *qemu) hotplugAddBlockDevice(ctx context.Context, drive *config.BlockDri
return nil return nil
} }
aio := q.config.BlockDeviceAIO
if drive.Swap { if drive.Swap {
err = q.qmpMonitorCh.qmp.ExecuteBlockdevAddWithDriverCache(q.qmpMonitorCh.ctx, "file", drive.File, drive.ID, false, false, false) err = q.qmpMonitorCh.qmp.ExecuteBlockdevAddWithDriverCache(q.qmpMonitorCh.ctx, "file", drive.File, drive.ID, aio, false, false, false)
} else if q.config.BlockDeviceCacheSet { } else if q.config.BlockDeviceCacheSet {
err = q.qmpMonitorCh.qmp.ExecuteBlockdevAddWithCache(q.qmpMonitorCh.ctx, drive.File, drive.ID, q.config.BlockDeviceCacheDirect, q.config.BlockDeviceCacheNoflush, drive.ReadOnly) err = q.qmpMonitorCh.qmp.ExecuteBlockdevAddWithCache(q.qmpMonitorCh.ctx, drive.File, drive.ID, aio, q.config.BlockDeviceCacheDirect, q.config.BlockDeviceCacheNoflush, drive.ReadOnly)
} else { } else {
err = q.qmpMonitorCh.qmp.ExecuteBlockdevAdd(q.qmpMonitorCh.ctx, drive.File, drive.ID, drive.ReadOnly) err = q.qmpMonitorCh.qmp.ExecuteBlockdevAdd(q.qmpMonitorCh.ctx, drive.File, drive.ID, aio, drive.ReadOnly)
} }
if err != nil { if err != nil {
return err return err