提交 1cc6bdc2 编写于 作者: P Peter Krempa

conf: Pass virStorageSource into virDomainDiskSourceIsBlockType

All checks are based on the storage source, thus there's no need to pass
the complete disk def.
上级 afa44743
......@@ -20004,29 +20004,26 @@ virDomainDefFindDevice(virDomainDefPtr def,
* Return true if its source is block type, or false otherwise.
*/
bool
virDomainDiskSourceIsBlockType(virDomainDiskDefPtr def)
virDomainDiskSourceIsBlockType(virStorageSourcePtr src)
{
/* No reason to think the disk source is block type if
* the source is empty
*/
if (!virDomainDiskGetSource(def))
if (!src->path)
return false;
if (virDomainDiskGetType(def) == VIR_STORAGE_TYPE_BLOCK)
if (src->type == VIR_STORAGE_TYPE_BLOCK)
return true;
/* For volume types, check the srcpool.
* If it's a block type source pool, then it's possible
*/
if (virDomainDiskGetType(def) == VIR_STORAGE_TYPE_VOLUME &&
def->src->srcpool &&
def->src->srcpool->voltype == VIR_STORAGE_VOL_BLOCK) {
if (src->type == VIR_STORAGE_TYPE_VOLUME &&
src->srcpool &&
src->srcpool->voltype == VIR_STORAGE_VOL_BLOCK) {
/* We don't think the volume accessed by remote URI is
* block type source, since we can't/shouldn't manage it
* (e.g. set sgio=filtered|unfiltered for it) in libvirt.
*/
if (def->src->srcpool->pooltype == VIR_STORAGE_POOL_ISCSI &&
def->src->srcpool->mode == VIR_STORAGE_SOURCE_POOL_MODE_DIRECT)
if (src->srcpool->pooltype == VIR_STORAGE_POOL_ISCSI &&
src->srcpool->mode == VIR_STORAGE_SOURCE_POOL_MODE_DIRECT)
return false;
return true;
......
......@@ -2713,7 +2713,7 @@ int virDomainDefFindDevice(virDomainDefPtr def,
virDomainDeviceDefPtr dev,
bool reportError);
bool virDomainDiskSourceIsBlockType(virDomainDiskDefPtr def)
bool virDomainDiskSourceIsBlockType(virStorageSourcePtr src)
ATTRIBUTE_NONNULL(1);
void virDomainChrSourceDefClear(virDomainChrSourceDefPtr def);
......
......@@ -373,7 +373,7 @@ static int virLXCCgroupSetupDeviceACL(virDomainDefPtr def,
VIR_DEBUG("Allowing any disk block devs");
for (i = 0; i < def->ndisks; i++) {
if (!virDomainDiskSourceIsBlockType(def->disks[i]))
if (!virDomainDiskSourceIsBlockType(def->disks[i]->src))
continue;
if (virCgroupAllowDevicePath(cgroup,
......
......@@ -4039,7 +4039,7 @@ lxcDomainAttachDeviceDiskLive(virLXCDriverPtr driver,
goto cleanup;
}
if (!virDomainDiskSourceIsBlockType(def)) {
if (!virDomainDiskSourceIsBlockType(def->src)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("Can't setup disk for non-block device"));
goto cleanup;
......
......@@ -3660,7 +3660,7 @@ qemuBuildDriveDevStr(virDomainDefPtr def,
virStorageNetProtocolTypeToString(disk->src->protocol));
goto error;
}
} else if (!virDomainDiskSourceIsBlockType(disk)) {
} else if (!virDomainDiskSourceIsBlockType(disk->src)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("disk device='lun' is only valid for block type disk source"));
goto error;
......
......@@ -979,7 +979,7 @@ qemuAddSharedDevice(virQEMUDriverPtr driver,
if (dev->type == VIR_DOMAIN_DEVICE_DISK) {
disk = dev->data.disk;
if (!disk->src->shared || !virDomainDiskSourceIsBlockType(disk))
if (!disk->src->shared || !virDomainDiskSourceIsBlockType(disk->src))
return 0;
} else if (dev->type == VIR_DOMAIN_DEVICE_HOSTDEV) {
hostdev = dev->data.hostdev;
......@@ -1088,7 +1088,7 @@ qemuRemoveSharedDevice(virQEMUDriverPtr driver,
if (dev->type == VIR_DOMAIN_DEVICE_DISK) {
disk = dev->data.disk;
if (!disk->src->shared || !virDomainDiskSourceIsBlockType(disk))
if (!disk->src->shared || !virDomainDiskSourceIsBlockType(disk->src))
return 0;
} else if (dev->type == VIR_DOMAIN_DEVICE_HOSTDEV) {
hostdev = dev->data.hostdev;
......@@ -1174,7 +1174,7 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev)
disk = dev->data.disk;
if (disk->device != VIR_DOMAIN_DISK_DEVICE_LUN ||
!virDomainDiskSourceIsBlockType(disk))
!virDomainDiskSourceIsBlockType(disk->src))
return 0;
path = virDomainDiskGetSource(disk);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册