[PATCH 04/15] qemu: Add/Remove the entry of sharedDisks when live attaching/detaching

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

 



This adds one entry to the list qemud_driver->sharedDisks when
attaching a shared disk. And removing the entry from the list
when detaching.
---
 src/qemu/qemu_driver.c |   22 ++++++++++++++++++++++
 1 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 3d7f52e..2c36935 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -6041,6 +6041,18 @@ qemuDomainAttachDeviceDiskLive(virConnectPtr conn,
             VIR_WARN("Failed to teardown cgroup for disk path %s",
                      NULLSTR(disk->src));
     }
+
+    /* If the attached disk is shareable, add it to the list
+     * qemud_driver->sharedDisks if attachment succeeded
+     */
+    if (ret == 0 && disk->shared) {
+        if (qemuSharedDiskListAdd(driver->sharedDisks,
+                                  disk->src,
+                                  vm->def->name) < 0) {
+            VIR_DEBUG("Failed to add the disk '%s' of domain '%s' to "
+                      "sharedDisks list", disk->src, vm->def->name);
+       }
+   }
 end:
     if (cgroup)
         virCgroupFree(&cgroup);
@@ -6156,6 +6168,16 @@ qemuDomainDetachDeviceDiskLive(virQEMUDriverPtr driver,
                        virDomainDiskDeviceTypeToString(disk->type));
         break;
     }
+
+    if (ret == 0 && disk->shared) {
+        if (qemuSharedDiskListDel(driver->sharedDisks,
+                                  disk->src,
+                                  vm->def->name) < 0) {
+            VIR_DEBUG("Failed to remove the entry of disk '%s', domain "
+                      "%s from sharedDisks", disk->src, vm->def->name);
+        }
+    }
+
     return ret;
 }
 
-- 
1.7.7.6

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