diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index c445d9faed..9ad473dde4 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2279,6 +2279,7 @@ virStorageSourceFree; virStorageSourceGetActualType; virStorageSourceGetSecurityLabelDef; virStorageSourceInitChainElement; +virStorageSourceIsBlockLocal; virStorageSourceIsEmpty; virStorageSourceIsLocalStorage; virStorageSourceNewFromBacking; diff --git a/src/lxc/lxc_cgroup.c b/src/lxc/lxc_cgroup.c index 4afe7e229e..ea86d3603a 100644 --- a/src/lxc/lxc_cgroup.c +++ b/src/lxc/lxc_cgroup.c @@ -393,7 +393,8 @@ static int virLXCCgroupSetupDeviceACL(virDomainDefPtr def, VIR_DEBUG("Allowing any disk block devs"); for (i = 0; i < def->ndisks; i++) { - if (!virDomainDiskSourceIsBlockType(def->disks[i]->src, false)) + if (virStorageSourceIsEmpty(def->disks[i]->src) || + !virStorageSourceIsBlockLocal(def->disks[i]->src)) continue; if (virCgroupAllowDevicePath(cgroup, diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 5ed5776a45..e00ddcaa57 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -1243,7 +1243,9 @@ qemuAddSharedDisk(virQEMUDriverPtr driver, char *key = NULL; int ret = -1; - if (!disk->src->shared || !virDomainDiskSourceIsBlockType(disk->src, false)) + if (virStorageSourceIsEmpty(disk->src) || + !disk->src->shared || + !virStorageSourceIsBlockLocal(disk->src)) return 0; qemuDriverLock(driver); @@ -1388,7 +1390,9 @@ qemuRemoveSharedDisk(virQEMUDriverPtr driver, char *key = NULL; int ret = -1; - if (!disk->src->shared || !virDomainDiskSourceIsBlockType(disk->src, false)) + if (virStorageSourceIsEmpty(disk->src) || + !disk->src->shared || + !virStorageSourceIsBlockLocal(disk->src)) return 0; qemuDriverLock(driver); @@ -1476,7 +1480,7 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev) disk = dev->data.disk; if (disk->device != VIR_DOMAIN_DISK_DEVICE_LUN || - !virDomainDiskSourceIsBlockType(disk->src, false)) + !virStorageSourceIsBlockLocal(disk->src)) return 0; path = virDomainDiskGetSource(disk); diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index 05ac2546bd..4f44e05de5 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -1955,7 +1955,7 @@ virStorageSourcePoolDefFree(virStorageSourcePoolDefPtr def) int -virStorageSourceGetActualType(virStorageSourcePtr def) +virStorageSourceGetActualType(const virStorageSource *def) { if (def->type == VIR_STORAGE_TYPE_VOLUME && def->srcpool) return def->srcpool->actualtype; @@ -2011,6 +2011,20 @@ virStorageSourceIsEmpty(virStorageSourcePtr src) } +/** + * virStorageSourceIsBlockLocal: + * @src: disk source definition + * + * Returns true if @src describes a locally accessible block storage source. + * This includes block devices and host-mapped iSCSI volumes. + */ +bool +virStorageSourceIsBlockLocal(const virStorageSource *src) +{ + return virStorageSourceGetActualType(src) == VIR_STORAGE_TYPE_BLOCK; +} + + /** * virStorageSourceBackingStoreClear: * diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h index b98fe25871..17e12779c1 100644 --- a/src/util/virstoragefile.h +++ b/src/util/virstoragefile.h @@ -357,9 +357,10 @@ int virStorageSourceInitChainElement(virStorageSourcePtr newelem, bool force); void virStorageSourcePoolDefFree(virStorageSourcePoolDefPtr def); void virStorageSourceClear(virStorageSourcePtr def); -int virStorageSourceGetActualType(virStorageSourcePtr def); +int virStorageSourceGetActualType(const virStorageSource *def); bool virStorageSourceIsLocalStorage(virStorageSourcePtr src); bool virStorageSourceIsEmpty(virStorageSourcePtr src); +bool virStorageSourceIsBlockLocal(const virStorageSource *src); void virStorageSourceFree(virStorageSourcePtr def); void virStorageSourceBackingStoreClear(virStorageSourcePtr def); int virStorageSourceUpdateBlockPhysicalSize(virStorageSourcePtr src,