[PATCH v2 6/6] parallels: fix virDomainDefineXML for domain in saved state

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

 



PCS doesn't store domain config in managed save state file.
It's forbidden to change config for VMs in this state.
It's possible to change config for containers, but after
restoring domain will have that new config, not a config,
which domain had at the moment of virDomainManagedSave.

So we need to handle this case differently from other states.
Let's forbid this operation, if config is changed and if it's
not changed - just do nothing.

Openstack/nova calls virDomainDefineXML on resume with
current domain config, so we can't forbid this operation
in managed save state.

Signed-off-by: Dmitry Guryanov <dguryanov@xxxxxxxxxxxxx>
---
 src/parallels/parallels_driver.c | 32 ++++++++++++++++++++++++++++----
 1 file changed, 28 insertions(+), 4 deletions(-)

diff --git a/src/parallels/parallels_driver.c b/src/parallels/parallels_driver.c
index 9bbb970..391e927 100644
--- a/src/parallels/parallels_driver.c
+++ b/src/parallels/parallels_driver.c
@@ -723,11 +723,35 @@ parallelsDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int
         if (!olddom)
             goto cleanup;
     } else {
-        if (prlsdkApplyConfig(conn, olddom, def))
-            goto cleanup;
+        int state, reason;
+
+        state = virDomainObjGetState(olddom, &reason);
+
+        if (state == VIR_DOMAIN_SHUTOFF &&
+            reason == VIR_DOMAIN_SHUTOFF_SAVED) {
+
+            /* PCS doesn't store domain config in managed save state file.
+             * It's forbidden to change config for VMs in this state.
+             * It's possible to change config for containers, but after
+             * restoring domain will have that new config, not a config,
+             * which domain had at the moment of virDomainManagedSave.
+             *
+             * So forbid this operation, if config is changed. If it's
+             * not changed - just do nothing. */
+
+            if (!virDomainDefCheckABIStability(olddom->def, def)) {
+                virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
+                               _("Can't change domain configuration "
+                                 "in managed save state"));
+                goto cleanup;
+            }
+        } else {
+            if (prlsdkApplyConfig(conn, olddom, def))
+                goto cleanup;
 
-        if (prlsdkUpdateDomain(privconn, olddom))
-            goto cleanup;
+            if (prlsdkUpdateDomain(privconn, olddom))
+                goto cleanup;
+        }
     }
 
     retdom = virGetDomain(conn, def->name, def->uuid);
-- 
2.1.0

--
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]