mirror of https://gitee.com/openkylin/libvirt.git
qemu: Forbid "sgio" support for SCSI generic host device
The kernel didn't support the unprivileged SGIO for SCSI generic device finally, and since it's unknow whether the way to support unprivileged SGIO for SCSI generic device will be similar as for SCSI block device or not, even it's simliar (I.e. via sysfs, for SCSI block device, it's /sys/dev/block/8\:0/queue/unpriv_sgio, for example), the file name might be different, So it's better not guess what it should be like currently. This patch removes the related code (mainly about the "shareable" checking on the "sgio" setting, it's not supported at all, why we leave checking code there? :-), and error out if "sgio" is specified in the domain config.
This commit is contained in:
parent
55d444bc01
commit
ce346623c1
|
@ -738,12 +738,8 @@ qemuCheckSharedDevice(virHashTablePtr sharedDevices,
|
||||||
virDomainDeviceDefPtr dev)
|
virDomainDeviceDefPtr dev)
|
||||||
{
|
{
|
||||||
virDomainDiskDefPtr disk = NULL;
|
virDomainDiskDefPtr disk = NULL;
|
||||||
virDomainHostdevDefPtr hostdev = NULL;
|
|
||||||
char *sysfs_path = NULL;
|
char *sysfs_path = NULL;
|
||||||
char *key = NULL;
|
char *key = NULL;
|
||||||
char *hostdev_name = NULL;
|
|
||||||
char *hostdev_path = NULL;
|
|
||||||
char *device_path = NULL;
|
|
||||||
int val;
|
int val;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
|
@ -755,27 +751,11 @@ qemuCheckSharedDevice(virHashTablePtr sharedDevices,
|
||||||
*/
|
*/
|
||||||
if (disk->device != VIR_DOMAIN_DISK_DEVICE_LUN)
|
if (disk->device != VIR_DOMAIN_DISK_DEVICE_LUN)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
device_path = disk->src;
|
|
||||||
} else if (dev->type == VIR_DOMAIN_DEVICE_HOSTDEV) {
|
|
||||||
hostdev = dev->data.hostdev;
|
|
||||||
|
|
||||||
if (!(hostdev_name = virSCSIDeviceGetDevName(NULL,
|
|
||||||
hostdev->source.subsys.u.scsi.adapter,
|
|
||||||
hostdev->source.subsys.u.scsi.bus,
|
|
||||||
hostdev->source.subsys.u.scsi.target,
|
|
||||||
hostdev->source.subsys.u.scsi.unit)))
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
if (virAsprintf(&hostdev_path, "/dev/%s", hostdev_name) < 0)
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
device_path = hostdev_path;
|
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(sysfs_path = virGetUnprivSGIOSysfsPath(device_path, NULL))) {
|
if (!(sysfs_path = virGetUnprivSGIOSysfsPath(disk->src, NULL))) {
|
||||||
ret = -1;
|
ret = -1;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
@ -786,7 +766,7 @@ qemuCheckSharedDevice(virHashTablePtr sharedDevices,
|
||||||
if (!virFileExists(sysfs_path))
|
if (!virFileExists(sysfs_path))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (!(key = qemuGetSharedDeviceKey(device_path))) {
|
if (!(key = qemuGetSharedDeviceKey(disk->src))) {
|
||||||
ret = -1;
|
ret = -1;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
@ -797,7 +777,7 @@ qemuCheckSharedDevice(virHashTablePtr sharedDevices,
|
||||||
if (!(virHashLookup(sharedDevices, key)))
|
if (!(virHashLookup(sharedDevices, key)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (virGetDeviceUnprivSGIO(device_path, NULL, &val) < 0) {
|
if (virGetDeviceUnprivSGIO(disk->src, NULL, &val) < 0) {
|
||||||
ret = -1;
|
ret = -1;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
@ -809,36 +789,25 @@ qemuCheckSharedDevice(virHashTablePtr sharedDevices,
|
||||||
disk->sgio == VIR_DOMAIN_DEVICE_SGIO_UNFILTERED))
|
disk->sgio == VIR_DOMAIN_DEVICE_SGIO_UNFILTERED))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (dev->type == VIR_DOMAIN_DEVICE_DISK) {
|
if (disk->type == VIR_DOMAIN_DISK_TYPE_VOLUME) {
|
||||||
if (disk->type == VIR_DOMAIN_DISK_TYPE_VOLUME) {
|
virReportError(VIR_ERR_OPERATION_INVALID,
|
||||||
virReportError(VIR_ERR_OPERATION_INVALID,
|
_("sgio of shared disk 'pool=%s' 'volume=%s' conflicts "
|
||||||
_("sgio of shared disk 'pool=%s' 'volume=%s' conflicts "
|
"with other active domains"),
|
||||||
"with other active domains"),
|
disk->srcpool->pool,
|
||||||
disk->srcpool->pool,
|
disk->srcpool->volume);
|
||||||
disk->srcpool->volume);
|
|
||||||
} else {
|
|
||||||
virReportError(VIR_ERR_OPERATION_INVALID,
|
|
||||||
_("sgio of shared disk '%s' conflicts with other "
|
|
||||||
"active domains"), disk->src);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
virReportError(VIR_ERR_OPERATION_INVALID,
|
virReportError(VIR_ERR_OPERATION_INVALID,
|
||||||
_("sgio of shared scsi host device '%s-%d-%d-%d' conflicts "
|
_("sgio of shared disk '%s' conflicts with other "
|
||||||
"with other active domains"),
|
"active domains"), disk->src);
|
||||||
hostdev->source.subsys.u.scsi.adapter,
|
|
||||||
hostdev->source.subsys.u.scsi.bus,
|
|
||||||
hostdev->source.subsys.u.scsi.target,
|
|
||||||
hostdev->source.subsys.u.scsi.unit);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = -1;
|
ret = -1;
|
||||||
cleanup:
|
cleanup:
|
||||||
VIR_FREE(hostdev_name);
|
|
||||||
VIR_FREE(hostdev_path);
|
|
||||||
VIR_FREE(sysfs_path);
|
VIR_FREE(sysfs_path);
|
||||||
VIR_FREE(key);
|
VIR_FREE(key);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
qemuSharedDeviceEntryDomainExists(qemuSharedDeviceEntryPtr entry,
|
qemuSharedDeviceEntryDomainExists(qemuSharedDeviceEntryPtr entry,
|
||||||
const char *name,
|
const char *name,
|
||||||
|
@ -1109,8 +1078,6 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev)
|
||||||
virDomainHostdevDefPtr hostdev = NULL;
|
virDomainHostdevDefPtr hostdev = NULL;
|
||||||
char *sysfs_path = NULL;
|
char *sysfs_path = NULL;
|
||||||
char *path = NULL;
|
char *path = NULL;
|
||||||
char *hostdev_name = NULL;
|
|
||||||
char *hostdev_path = NULL;
|
|
||||||
int val = -1;
|
int val = -1;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
|
@ -1128,22 +1095,19 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev)
|
||||||
} else if (dev->type == VIR_DOMAIN_DEVICE_HOSTDEV) {
|
} else if (dev->type == VIR_DOMAIN_DEVICE_HOSTDEV) {
|
||||||
hostdev = dev->data.hostdev;
|
hostdev = dev->data.hostdev;
|
||||||
|
|
||||||
if (!hostdev->shareable ||
|
|
||||||
!(hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS &&
|
|
||||||
hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if (!(hostdev_name = virSCSIDeviceGetDevName(NULL,
|
if (hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS &&
|
||||||
hostdev->source.subsys.u.scsi.adapter,
|
hostdev->source.subsys.type ==
|
||||||
hostdev->source.subsys.u.scsi.bus,
|
VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI &&
|
||||||
hostdev->source.subsys.u.scsi.target,
|
hostdev->source.subsys.u.scsi.sgio) {
|
||||||
hostdev->source.subsys.u.scsi.unit)))
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
|
_("'sgio' is not supported for SCSI "
|
||||||
|
"generic device yet "));
|
||||||
|
ret = -1;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
if (virAsprintf(&hostdev_path, "/dev/%s", hostdev_name) < 0)
|
return 0;
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
path = hostdev_path;
|
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1155,12 +1119,7 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* By default, filter the SG_IO commands, i.e. set unpriv_sgio to 0. */
|
/* By default, filter the SG_IO commands, i.e. set unpriv_sgio to 0. */
|
||||||
|
val = (disk->sgio == VIR_DOMAIN_DEVICE_SGIO_UNFILTERED);
|
||||||
if (dev->type == VIR_DOMAIN_DEVICE_DISK)
|
|
||||||
val = (disk->sgio == VIR_DOMAIN_DEVICE_SGIO_UNFILTERED);
|
|
||||||
else
|
|
||||||
val = (hostdev->source.subsys.u.scsi.sgio ==
|
|
||||||
VIR_DOMAIN_DEVICE_SGIO_UNFILTERED);
|
|
||||||
|
|
||||||
/* Do not do anything if unpriv_sgio is not supported by the kernel and the
|
/* Do not do anything if unpriv_sgio is not supported by the kernel and the
|
||||||
* whitelist is enabled. But if requesting unfiltered access, always call
|
* whitelist is enabled. But if requesting unfiltered access, always call
|
||||||
|
@ -1172,8 +1131,6 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev)
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
VIR_FREE(sysfs_path);
|
VIR_FREE(sysfs_path);
|
||||||
VIR_FREE(hostdev_name);
|
|
||||||
VIR_FREE(hostdev_path);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue