[PATCHv10 6/6] support update device persistent.

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

 



This patch adds support for Disk exchange in persistent.

Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@xxxxxxxxxxxxxx>

* src/qemu/qemu_driver.c
 (qemudDomainUpdateDeviceConfig): add cdrom/floppy exchange code.
---
 src/qemu/qemu_driver.c |   40 +++++++++++++++++++++++++++++++++++++++-
 1 files changed, 39 insertions(+), 1 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 92643ef..6188722 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -4119,11 +4119,49 @@ qemudDomainDetachDeviceConfig(virDomainDefPtr vmdef,
 }
 
 static int
-qemudDomainUpdateDeviceConfig(virDomainDefPtr vmdef ATTRIBUTE_UNUSED,
+qemudDomainUpdateDeviceConfig(virDomainDefPtr vmdef,
                               virDomainDeviceDefPtr dev,
                               bool force ATTRIBUTE_UNUSED)
 {
+    virDomainDiskDefPtr orig, disk;
+    int pos;
+
     switch (dev->type) {
+    case VIR_DOMAIN_DEVICE_DISK:
+        disk = dev->data.disk;
+        pos = virDomainDiskIndexByName(vmdef, disk->dst);
+        if (pos < 0) {
+            qemuReportError(VIR_ERR_INVALID_ARG,
+                            _("target %s doesn't exists."), disk->dst);
+            return -1;
+        }
+        orig = vmdef->disks[pos];
+        if (!(orig->device == VIR_DOMAIN_DISK_DEVICE_CDROM) &&
+            !(orig->device == VIR_DOMAIN_DISK_DEVICE_FLOPPY)) {
+            qemuReportError(VIR_ERR_INVALID_ARG,
+                            _("this disk doesn't support update"));
+            return -1;
+        }
+        /*
+         * Update 'orig'
+         * We allow updating src/type//driverType/cachemode/
+         */
+        VIR_FREE(orig->src);
+        orig->src = disk->src;
+        orig->type = disk->type;
+        orig->cachemode = disk->cachemode;
+        if (disk->driverName) {
+            VIR_FREE(orig->driverName);
+            orig->driverName = disk->driverName;
+            disk->driverName = NULL;
+        }
+        if (disk->driverType) {
+            VIR_FREE(orig->driverType);
+            orig->driverType = disk->driverType;
+            disk->driverType = NULL;
+        }
+        disk->src = NULL;
+        break;
     default:
         qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
                          _("persistent update of device is not supported"));
-- 
1.7.4.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]