mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-05-01 21:24:36 +00:00
qmp: add virtio-blk multiqueue
Hotplug virtio-blk with multiqueue support. Signed-off-by: Peng Tao <bergwolf@hyper.sh>
This commit is contained in:
parent
a6e2655b90
commit
f0f18dd0f2
10
qemu/qmp.go
10
qemu/qmp.go
@ -25,6 +25,7 @@ import (
|
||||
"io"
|
||||
"net"
|
||||
"os"
|
||||
"strconv"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
@ -1058,12 +1059,12 @@ func (q *QMP) ExecuteDeviceDel(ctx context.Context, devID string) error {
|
||||
|
||||
// ExecutePCIDeviceAdd is the PCI version of ExecuteDeviceAdd. This function can be used
|
||||
// to hot plug PCI devices on PCI(E) bridges, unlike ExecuteDeviceAdd this function receive the
|
||||
// device address on its parent bus. bus is optional. shared denotes if the drive can be shared
|
||||
// allowing it to be passed more than once.
|
||||
// device address on its parent bus. bus is optional. queues specifies the number of queues of
|
||||
// a block device. shared denotes if the drive can be shared allowing it to be passed more than once.
|
||||
// disableModern indicates if virtio version 1.0 should be replaced by the
|
||||
// former version 0.9, as there is a KVM bug that occurs when using virtio
|
||||
// 1.0 in nested environments.
|
||||
func (q *QMP) ExecutePCIDeviceAdd(ctx context.Context, blockdevID, devID, driver, addr, bus, romfile string, shared, disableModern bool) error {
|
||||
func (q *QMP) ExecutePCIDeviceAdd(ctx context.Context, blockdevID, devID, driver, addr, bus, romfile string, queues int, shared, disableModern bool) error {
|
||||
args := map[string]interface{}{
|
||||
"id": devID,
|
||||
"driver": driver,
|
||||
@ -1076,6 +1077,9 @@ func (q *QMP) ExecutePCIDeviceAdd(ctx context.Context, blockdevID, devID, driver
|
||||
if shared && (q.version.Major > 2 || (q.version.Major == 2 && q.version.Minor >= 10)) {
|
||||
args["share-rw"] = "on"
|
||||
}
|
||||
if queues > 0 {
|
||||
args["num-queues"] = strconv.Itoa(queues)
|
||||
}
|
||||
if isVirtioPCI[DeviceDriver(driver)] {
|
||||
args["romfile"] = romfile
|
||||
|
||||
|
@ -1025,7 +1025,7 @@ func TestQMPPCIDeviceAdd(t *testing.T) {
|
||||
blockdevID := fmt.Sprintf("drive_%s", volumeUUID)
|
||||
devID := fmt.Sprintf("device_%s", volumeUUID)
|
||||
err := q.ExecutePCIDeviceAdd(context.Background(), blockdevID, devID,
|
||||
"virtio-blk-pci", "0x1", "", "", true, false)
|
||||
"virtio-blk-pci", "0x1", "", "", 1, true, false)
|
||||
if err != nil {
|
||||
t.Fatalf("Unexpected error %v", err)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user