runtime: use actual booleans for QMP device_add boolean options

Since
be93fd5372,
which is included in QEMU since version 9.2.0, the options for the
`device_add` QMP command need to be typed correctly.

This makes it so that instead of `"on"`, the value is set to `true`,
matching QEMU's expectations.

This has been tested on QEMU 9.2.0 and QEMU 9.1.2, so before and after
the change.

The compatibility with incorrectly typed options  for the `device_add`
command is deprecated since version 6.2.0 [^1].

[^1]:  https://qemu-project.gitlab.io/qemu/about/deprecated.html#incorrectly-typed-device-add-arguments-since-6-2

Signed-off-by: Moritz Sanft <58110325+msanft@users.noreply.github.com>
This commit is contained in:
Moritz Sanft
2025-01-08 16:13:49 +01:00
parent 71b14d40f2
commit e5735b221c

View File

@@ -869,7 +869,7 @@ func (q *QMP) ExecuteDeviceAdd(ctx context.Context, blockdevID, devID, driver, b
} }
if shared { if shared {
args["share-rw"] = "on" args["share-rw"] = true
} }
if transport.isVirtioPCI(nil) { if transport.isVirtioPCI(nil) {
args["romfile"] = romfile args["romfile"] = romfile
@@ -923,7 +923,7 @@ func (q *QMP) ExecuteSCSIDeviceAdd(ctx context.Context, blockdevID, devID, drive
args["lun"] = lun args["lun"] = lun
} }
if shared { if shared {
args["share-rw"] = "on" args["share-rw"] = true
} }
return q.executeCommand(ctx, "device_add", args, nil) return q.executeCommand(ctx, "device_add", args, nil)
@@ -1050,7 +1050,7 @@ func (q *QMP) ExecuteNetPCIDeviceAdd(ctx context.Context, netdevID, devID, macAd
// Clearlinux automatically sets up the queues properly // Clearlinux automatically sets up the queues properly
// The agent implementation should do this to ensure that it is // The agent implementation should do this to ensure that it is
// always set // always set
args["mq"] = "on" args["mq"] = true
args["vectors"] = 2*queues + 2 args["vectors"] = 2*queues + 2
} }
@@ -1071,7 +1071,7 @@ func (q *QMP) ExecuteNetCCWDeviceAdd(ctx context.Context, netdevID, devID, macAd
} }
if queues > 0 { if queues > 0 {
args["mq"] = "on" args["mq"] = true
} }
return q.executeCommand(ctx, "device_add", args, nil) return q.executeCommand(ctx, "device_add", args, nil)
@@ -1113,7 +1113,7 @@ func (q *QMP) ExecutePCIDeviceAdd(ctx context.Context, blockdevID, devID, driver
args["bus"] = bus args["bus"] = bus
} }
if shared { if shared {
args["share-rw"] = "on" args["share-rw"] = true
} }
if queues > 0 { if queues > 0 {
args["num-queues"] = strconv.Itoa(queues) args["num-queues"] = strconv.Itoa(queues)