From c26724668d51d15b2592a3e34676af03cffca2c5 Mon Sep 17 00:00:00 2001
From: Guido Trotter <ultrotter@google.com>
Date: Mon, 9 Feb 2009 15:16:34 +0000
Subject: [PATCH] KVM: export hvparams in the runtime

They'll be used to set the nic type when we execute the runtime, since
the nics are processed later. We need to save the hvparams because we
want to use the same one as when we saved the runtime, rather than use
the current instance ones, to avoid applying only some changed
parameters when the runtime is loaded.

Reviewed-by: iustinp
---
 lib/hypervisor/hv_kvm.py | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/lib/hypervisor/hv_kvm.py b/lib/hypervisor/hv_kvm.py
index 3ba752936..9baf279f2 100644
--- a/lib/hypervisor/hv_kvm.py
+++ b/lib/hypervisor/hv_kvm.py
@@ -330,8 +330,9 @@ class KVMHypervisor(hv_base.BaseHypervisor):
     # Save the current instance nics, but defer their expansion as parameters,
     # as we'll need to generate executable temp files for them.
     kvm_nics = instance.nics
+    hvparams = instance.hvparams
 
-    return (kvm_cmd, kvm_nics)
+    return (kvm_cmd, kvm_nics, hvparams)
 
   def _WriteKVMRuntime(self, instance_name, data):
     """Write an instance's KVM runtime
@@ -357,9 +358,9 @@ class KVMHypervisor(hv_base.BaseHypervisor):
     """Save an instance's KVM runtime
 
     """
-    kvm_cmd, kvm_nics = kvm_runtime
+    kvm_cmd, kvm_nics, hvparams = kvm_runtime
     serialized_nics = [nic.ToDict() for nic in kvm_nics]
-    serialized_form = serializer.Dump((kvm_cmd, serialized_nics))
+    serialized_form = serializer.Dump((kvm_cmd, serialized_nics, hvparams))
     self._WriteKVMRuntime(instance.name, serialized_form)
 
   def _LoadKVMRuntime(self, instance, serialized_runtime=None):
@@ -369,9 +370,9 @@ class KVMHypervisor(hv_base.BaseHypervisor):
     if not serialized_runtime:
       serialized_runtime = self._ReadKVMRuntime(instance.name)
     loaded_runtime = serializer.Load(serialized_runtime)
-    kvm_cmd, serialized_nics = loaded_runtime
+    kvm_cmd, serialized_nics, hvparams = loaded_runtime
     kvm_nics = [objects.NIC.FromDict(snic) for snic in serialized_nics]
-    return (kvm_cmd, kvm_nics)
+    return (kvm_cmd, kvm_nics, hvparams)
 
   def _ExecuteKVMRuntime(self, instance, kvm_runtime, incoming=None):
     """Execute a KVM cmd, after completing it with some last minute data
@@ -387,7 +388,7 @@ class KVMHypervisor(hv_base.BaseHypervisor):
 
     temp_files = []
 
-    kvm_cmd, kvm_nics = kvm_runtime
+    kvm_cmd, kvm_nics, hvparams = kvm_runtime
 
     if not kvm_nics:
       kvm_cmd.extend(['-net', 'none'])
-- 
GitLab