stratovirt/machine_manager-add-autodeflate-for-balloon.patch

72 lines
2.7 KiB
Diff
Raw Normal View History

From aa94544a6fcc53039946cd6545893eed75d60d6e Mon Sep 17 00:00:00 2001
From: Ming Yang <yangming73@huawei.com>
Date: Tue, 24 Aug 2021 16:54:02 +0800
Subject: [PATCH 02/10] machine_manager: add autodeflate for balloon.
Signed-off-by: Ming Yang <yangming73@huawei.com>
---
machine_manager/src/machine.rs | 9 ++++++++-
machine_manager/src/qmp/mod.rs | 2 +-
machine_manager/src/qmp/qmp_schema.rs | 4 +++-
3 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/machine_manager/src/machine.rs b/machine_manager/src/machine.rs
index 49dbc38..ab8b288 100644
--- a/machine_manager/src/machine.rs
+++ b/machine_manager/src/machine.rs
@@ -299,13 +299,20 @@ pub trait DeviceInterface {
Response::create_response(serde_json::to_value(&vec_types).unwrap(), None)
}
- fn device_list_properties(&self) -> Response {
+ fn device_list_properties(&self, typename: String) -> Response {
let mut vec_props = Vec::<DeviceProps>::new();
let prop = DeviceProps {
name: "disable-legacy".to_string(),
prop_type: "OnOffAuto".to_string(),
};
vec_props.push(prop);
+ if typename.contains("virtio-balloon") {
+ let prop = DeviceProps {
+ name: "deflate-on-oom".to_string(),
+ prop_type: "bool".to_string(),
+ };
+ vec_props.push(prop);
+ }
Response::create_response(serde_json::to_value(&vec_props).unwrap(), None)
}
diff --git a/machine_manager/src/qmp/mod.rs b/machine_manager/src/qmp/mod.rs
index 8d9cd6f..f18f869 100644
--- a/machine_manager/src/qmp/mod.rs
+++ b/machine_manager/src/qmp/mod.rs
@@ -436,9 +436,9 @@ fn qmp_command_exec(
(query_cpus, query_cpus),
(query_balloon, query_balloon),
(list_type, list_type),
- (device_list_properties, device_list_properties),
(query_hotpluggable_cpus, query_hotpluggable_cpus);
(device_add, device_add, id, driver, addr, lun),
+ (device_list_properties, device_list_properties, typename),
(device_del, device_del, id),
(blockdev_add, blockdev_add, node_name, file, cache, read_only),
(netdev_add, netdev_add, id, if_name, fds),
diff --git a/machine_manager/src/qmp/qmp_schema.rs b/machine_manager/src/qmp/qmp_schema.rs
index 9544d46..a7c2a73 100644
--- a/machine_manager/src/qmp/qmp_schema.rs
+++ b/machine_manager/src/qmp/qmp_schema.rs
@@ -1375,7 +1375,9 @@ impl Command for list_type {
/// <- {"return":[]}
/// ```
#[derive(Default, Debug, Clone, Serialize, Deserialize)]
-pub struct device_list_properties {}
+pub struct device_list_properties {
+ pub typename: String,
+}
#[derive(Default, Debug, Clone, Serialize, Deserialize)]
pub struct DeviceProps {
--
2.25.1