[PATCH] qemu: Check address when attaching a virtio disk with an invalid address.

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

 



https://bugzilla.redhat.com/show_bug.cgi?id=1257844

Attach-device can hotplug a virtio disk device with any address now.
It need to validate the address before the attachment. This patch
fix the problem.

Signed-off-by: rbian <rbian@xxxxxxxxxx>
---
 src/qemu/qemu_hotplug.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index e71a204..be24993 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -331,6 +331,23 @@ qemuDomainAttachVirtioDiskDevice(virConnectPtr conn,
             disk->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW;
         else if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VIRTIO_S390))
             disk->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_S390;
+    } else {
+        if (STREQLEN(vm->def->os.machine, "s390-ccw", 8) &&
+            virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VIRTIO_CCW)) {
+            if (!virDomainDeviceAddressIsValid(&disk->info,
+                                               VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW)) {
+                virReportError(VIR_ERR_OPERATION_FAILED, "%s",
+                               _("device cannot be attached without a valid CCW address"));
+                goto error;
+            }
+        } else {
+            if (!virDomainDeviceAddressIsValid(&disk->info,
+                                               VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI)) {
+                virReportError(VIR_ERR_OPERATION_FAILED, "%s",
+                               _("device cannot be attached without a valid PCI address"));
+                goto error;
+            }
+        }
     }
 
     for (i = 0; i < vm->def->ndisks; i++) {
-- 
2.4.3

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