[PATCH 4/6] tpm: Handle TPM emulator device reconfigurations

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This patch looks at device changes due to modified XML. With the TPM
emulator we have to handle cases where the TPM is removed from the VM
or when it is reconfigured in some way.

In the device removal case we remove the storage path.

The function we create here will be used later to handle other device
changes as well.

Signed-off-by: Stefan Berger <stefanb@xxxxxxxxxxxxxxxxxx>
---
 src/conf/domain_conf.c   | 38 ++++++++++++++++++++++++++++++++++++++
 src/conf/domain_conf.h   |  3 +++
 src/libvirt_private.syms |  1 +
 src/qemu/qemu_driver.c   |  3 ++-
 4 files changed, 44 insertions(+), 1 deletion(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 9f7f3ce..72e4412 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -29412,3 +29412,41 @@ virDomainDiskTranslateSourcePool(virDomainDiskDefPtr def)
     virStoragePoolDefFree(pooldef);
     return ret;
 }
+
+
+static int
+virDomainCheckTPMChanges(virDomainDefPtr def,
+                         virDomainDefPtr newDef)
+{
+    int ret = 0;
+
+    if (!def->tpm)
+        return 0;
+
+    if (!newDef->tpm) {
+        /* TPM removed */
+        virDomainTPMDeleteAny(def);
+    } else {
+        if (newDef->tpm->type != def->tpm->type) {
+            /* type changed */
+            virDomainTPMDeleteAny(def);
+        }
+    }
+
+    return ret;
+}
+
+
+int
+virDomainCheckDeviceChanges(virDomainDefPtr def,
+                            virDomainDefPtr newDef)
+{
+    int ret;
+
+    if (!def || !newDef)
+        return 0;
+
+    ret = virDomainCheckTPMChanges(def, newDef);
+
+    return ret;
+}
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 9802533..1f479b0 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -3537,5 +3537,8 @@ virDomainNetResolveActualType(virDomainNetDefPtr iface)
 
 int virDomainDiskTranslateSourcePool(virDomainDiskDefPtr def);
 
+int virDomainCheckDeviceChanges(virDomainDefPtr def,
+                                virDomainDefPtr newDef)
+    ATTRIBUTE_NONNULL(1);
 
 #endif /* __DOMAIN_CONF_H */
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 191142e..488882d 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -198,6 +198,7 @@ virDomainBootTypeFromString;
 virDomainBootTypeToString;
 virDomainCapabilitiesPolicyTypeToString;
 virDomainCapsFeatureTypeToString;
+virDomainCheckDeviceChanges;
 virDomainChrConsoleTargetTypeFromString;
 virDomainChrConsoleTargetTypeToString;
 virDomainChrDefForeach;
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index ef0d0c9..e7a325c 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -7438,7 +7438,8 @@ qemuDomainDefineXMLFlags(virConnectPtr conn,
     }
     vm->persistent = 1;
 
-    if (virDomainSaveConfig(cfg->configDir, driver->caps,
+    if (virDomainCheckDeviceChanges(oldDef, vm->def) < 0 ||
+        virDomainSaveConfig(cfg->configDir, driver->caps,
                             vm->newDef ? vm->newDef : vm->def) < 0) {
         if (oldDef) {
             /* There is backup so this VM was defined before.
-- 
2.5.5

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux