[PATCH] parallels: delete old networks in prlsdkDoApplyConfig before adding new ones

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

 



In order to change an existing domain we delete all existing devices and add
new from scratch. In case of network devices we should also delete corresponding
virtual networks (if any) before removing actual devices from xml. In the patch,
we do it by extending prlsdkDoApplyConfig with a new parameter, which stands for
old xml, and calling prlsdkDelNet every time old xml is specified.

Signed-off-by: Maxim Nestratov <mnestratov@xxxxxxxxxxxxx>
---
 src/parallels/parallels_sdk.c |   24 +++++++++++++++---------
 1 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/src/parallels/parallels_sdk.c b/src/parallels/parallels_sdk.c
index c36b772..64a2d15 100644
--- a/src/parallels/parallels_sdk.c
+++ b/src/parallels/parallels_sdk.c
@@ -2935,7 +2935,8 @@ prlsdkAddFS(PRL_HANDLE sdkdom, virDomainFSDefPtr fs)
 static int
 prlsdkDoApplyConfig(virConnectPtr conn,
                     PRL_HANDLE sdkdom,
-                    virDomainDefPtr def)
+                    virDomainDefPtr def,
+                    virDomainDefPtr olddef)
 {
     PRL_RESULT pret;
     size_t i;
@@ -2997,6 +2998,16 @@ prlsdkDoApplyConfig(virConnectPtr conn,
     if (prlsdkRemoveBootDevices(sdkdom) < 0)
         goto error;
 
+    if(olddef) {
+        for (i = 0; i < olddef->nnets; i++)
+            prlsdkDelNet(conn->privateData, olddef->nets[i]);
+    }
+
+    for (i = 0; i < def->nnets; i++) {
+        if (prlsdkAddNet(sdkdom, conn->privateData, def->nets[i]) < 0)
+           goto error;
+    }
+
     if (prlsdkApplyGraphicsParams(sdkdom, def) < 0)
         goto error;
 
@@ -3008,11 +3019,6 @@ prlsdkDoApplyConfig(virConnectPtr conn,
             goto error;
     }
 
-    for (i = 0; i < def->nnets; i++) {
-        if (prlsdkAddNet(sdkdom, conn->privateData, def->nets[i]) < 0)
-           goto error;
-    }
-
     for (i = 0; i < def->ndisks; i++) {
         bool bootDisk = false;
 
@@ -3060,7 +3066,7 @@ prlsdkApplyConfig(virConnectPtr conn,
     if (PRL_FAILED(waitJob(job, privconn->jobTimeout)))
         return -1;
 
-    ret = prlsdkDoApplyConfig(conn, sdkdom, new);
+    ret = prlsdkDoApplyConfig(conn, sdkdom, new, dom->def);
 
     if (ret == 0) {
         job = PrlVm_CommitEx(sdkdom, PVCF_DETACH_HDD_BUNDLE);
@@ -3100,7 +3106,7 @@ prlsdkCreateVm(virConnectPtr conn, virDomainDefPtr def)
     pret = PrlVmCfg_SetOfflineManagementEnabled(sdkdom, 0);
     prlsdkCheckRetGoto(pret, cleanup);
 
-    ret = prlsdkDoApplyConfig(conn, sdkdom, def);
+    ret = prlsdkDoApplyConfig(conn, sdkdom, def, NULL);
     if (ret)
         goto cleanup;
 
@@ -3162,7 +3168,7 @@ prlsdkCreateCt(virConnectPtr conn, virDomainDefPtr def)
 
     }
 
-    ret = prlsdkDoApplyConfig(conn, sdkdom, def);
+    ret = prlsdkDoApplyConfig(conn, sdkdom, def, NULL);
     if (ret)
         goto cleanup;
 
-- 
1.7.1

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