On 2026/7/10 上午11:02, Bibo Mao wrote:


On 2026/7/10 上午8:50, Tao Cui wrote:
From: Tao Cui <[email protected]>

pv_features holds the value of pseudo-register CPUCFG_KVM_FEATURE and is now
pushed per vCPU. Add it to the vCPU VMState as a subsection (sent when
non-zero) so it travels with the vCPU across migration between host kernel
versions.

Signed-off-by: Tao Cui <[email protected]>
---
  target/loongarch/machine.c | 19 +++++++++++++++++++
  1 file changed, 19 insertions(+)

diff --git a/target/loongarch/machine.c b/target/loongarch/machine.c
index 931a5ca5ba..b8819bd44d 100644
--- a/target/loongarch/machine.c
+++ b/target/loongarch/machine.c
@@ -65,6 +65,24 @@ static const VMStateDescription vmstate_msgint = {
      },
  };
+static bool pv_features_needed(void *opaque)
+{
+    LoongArchCPU *cpu = opaque;
+
+    return cpu->env.pv_features != 0;
I think cpu->no_pv_feature should be check here. For QEMU 11.1 pv_feature is not supported for migration, for later version it supports, something like this:
        return !cpu->no_pv_feature;
For successful migration, env.pv_features from source host should be subset of destination host, there should be such checking also.


Regards
Bibo Mao
+}
+
+static const VMStateDescription vmstate_pv_features = {
+    .name = "cpu/pv_features",
+    .version_id = 1,
+    .minimum_version_id = 1,
+    .needed = pv_features_needed,
+    .fields = (const VMStateField[]) {
+        VMSTATE_UINT32(env.pv_features, LoongArchCPU),
+        VMSTATE_END_OF_LIST()
+    },
+};
+
  static const VMStateDescription vmstate_lsxh_reg = {
      .name = "lsxh_reg",
      .version_id = 1,
@@ -289,6 +307,7 @@ const VMStateDescription vmstate_loongarch_cpu = {
          &vmstate_lbt,
          &vmstate_msgint,
          &vmstate_pmu,
+        &vmstate_pv_features,
          NULL
      }
  };




Reply via email to