[libvirt] [PATCH] qemuDomainAttachDeviceLive: Check provided disk address

Martin Kletzander mkletzan at redhat.com
Fri Sep 25 09:36:03 UTC 2015


On Thu, Sep 24, 2015 at 05:43:08PM +0200, Michal Privoznik wrote:
>https://bugzilla.redhat.com/show_bug.cgi?id=1257844
>
>Imagine an user who is trying to attach a disk to a domain with
>the following XML:
>
>  <disk type='block' device='disk'>
>    <driver name='qemu' type='raw'/>
>    <source dev='/dev/sr0'/>
>    <target dev='vde' bus='virtio'/>
>    <address type='drive' controller='0' bus='0' target='0' unit='0'/>
>  </disk>
>
>The XML is obviously wrong. It's trying to attach a virtio disk
>onto non-PCI bus. We should forbid that.
>
>Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
>---
> src/qemu/qemu_hotplug.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>

How come this is not handled in qemuDomainAssignAddresses(), it
doesn't get called?  There's a check for exactly that in
qemuAssignDevicePCISlots().

>diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
>index afc5408..fc8e21b 100644
>--- a/src/qemu/qemu_hotplug.c
>+++ b/src/qemu/qemu_hotplug.c
>@@ -336,6 +336,13 @@ qemuDomainAttachVirtioDiskDevice(virConnectPtr conn,
>         if (!qemuCheckCCWS390AddressSupport(vm->def, disk->info, priv->qemuCaps,
>                                             disk->dst))
>             goto cleanup;
>+        if (disk->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI &&
>+            disk->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_S390 &&
>+            disk->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW) {
>+            virReportError(VIR_ERR_OPERATION_INVALID, "%s",
>+                           _("virtio disks must have PCI or CCW address"));
>+            goto cleanup;
>+        }
>     }
>
>     for (i = 0; i < vm->def->ndisks; i++) {
>--
>2.4.9
>
>--
>libvir-list mailing list
>libvir-list at redhat.com
>https://www.redhat.com/mailman/listinfo/libvir-list
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20150925/c56ac6a9/attachment-0001.sig>


More information about the libvir-list mailing list