Skip to content

Commit

Permalink
packages/kata-runtime: correctly type QMP commands
Browse files Browse the repository at this point in the history
This pulls in an upstream patch (kata-containers/kata-containers@92cc0e2)
which correctly types the QMP `device_add` command options.
This is required to make Kata work with QEMU >= 9.2.0.
  • Loading branch information
msanft committed Jan 10, 2025
1 parent 630a6aa commit e87a68c
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Moritz Sanft <58110325+msanft@users.noreply.github.com>
Date: Wed, 8 Jan 2025 16:13:49 +0100
Subject: [PATCH] runtime: use actual booleans for QMP `device_add` boolean
options

Since
https://github.com/qemu/qemu/commit/be93fd53723cbdca675bd9ed112dae5cabbe1e91,
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
---
src/runtime/pkg/govmm/qemu/qmp.go | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/runtime/pkg/govmm/qemu/qmp.go b/src/runtime/pkg/govmm/qemu/qmp.go
index bf18bef9fc027cbf8c77c169ae2b36fdcbdaaa44..af907ba56e514e7fa8c1fc71175c2d039fef9010 100644
--- a/src/runtime/pkg/govmm/qemu/qmp.go
+++ b/src/runtime/pkg/govmm/qemu/qmp.go
@@ -869,7 +869,7 @@ func (q *QMP) ExecuteDeviceAdd(ctx context.Context, blockdevID, devID, driver, b
}

if shared {
- args["share-rw"] = "on"
+ args["share-rw"] = true
}
if transport.isVirtioPCI(nil) {
args["romfile"] = romfile
@@ -923,7 +923,7 @@ func (q *QMP) ExecuteSCSIDeviceAdd(ctx context.Context, blockdevID, devID, drive
args["lun"] = lun
}
if shared {
- args["share-rw"] = "on"
+ args["share-rw"] = true
}

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
}
if shared {
- args["share-rw"] = "on"
+ args["share-rw"] = true
}
if queues > 0 {
args["num-queues"] = strconv.Itoa(queues)
5 changes: 5 additions & 0 deletions packages/by-name/kata/kata-runtime/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,11 @@ buildGoModule rec {
# `allowed_guest_hooks` setting , which controls what paths may be set for hooks.
# Upstream issue: https://github.com/kata-containers/kata-containers/issues/10633
./0017-genpolicy-support-guest-hooks.patch

# Correctly type QEMU QMP command options for the `device_add` command.
# See: https://github.com/kata-containers/kata-containers/pull/10719
# TODO(msanft): Remove once upstream PR is released.
./0018-runtime-use-actual-booleans-for-QMP-device_add-boole.patch
];
};

Expand Down

0 comments on commit e87a68c

Please sign in to comment.