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

[libvirt] [PATCH 03/10] qemu: Add/remove the shared disk entry during domain's lifecyle



Lifecyle here only means starting and shutdown.
---
 src/qemu/qemu_process.c |   20 ++++++++++++++++++++
 1 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index d4dad1f..2a60741 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -3700,6 +3700,13 @@ int qemuProcessStart(virConnectPtr conn,
     for (i = 0; i < vm->def->ndisks; i++) {
         if (vm->def->disks[i]->rawio == 1)
             virCommandAllowCap(cmd, CAP_SYS_RAWIO);
+
+        if (vm->def->disks[i]->shared &&
+            (qemuSharedDiskListAdd(driver->sharedDisks,
+                                   vm->def->disks[i]->src,
+                                   vm->def->name) < 0)) {
+            goto cleanup;
+        }
     }
 
     virCommandSetPreExecHook(cmd, qemuProcessHook, &hookData);
@@ -4092,6 +4099,19 @@ void qemuProcessStop(virQEMUDriverPtr driver,
                                           flags & VIR_QEMU_PROCESS_STOP_MIGRATED);
     virSecurityManagerReleaseLabel(driver->securityManager, vm->def);
 
+    /* Remove the shared disk entry from qemud_driver->sharedDisks */
+    for (i = 0; i < vm->def->ndisks; i++) {
+        if (vm->def->disks[i]->shared &&
+            (qemuSharedDiskListDel(driver->sharedDisks,
+                                   vm->def->disks[i]->src,
+                                   vm->def->name) < 0)) {
+            VIR_WARN("Unable to remove shared disk entry for "
+                     "disk = '%s', domain = '%s'",
+                     vm->def->disks[i]->src,
+                     vm->def->name);
+        }
+    }
+
     /* Clear out dynamically assigned labels */
     for (i = 0; i < vm->def->nseclabels; i++) {
         if (vm->def->seclabels[i]->type == VIR_DOMAIN_SECLABEL_DYNAMIC) {
-- 
1.7.1


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