mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-24 14:45:24 +00:00
qemu: remove all use of SGIO
Now that the 'unfiltered' attribute is rejected by the validator, remove all the code that deals with the feature. Signed-off-by: Ján Tomko <jtomko@redhat.com> Reviewed-by: Andrea Bolognani <abologna@redhat.com>
This commit is contained in:
parent
711f593566
commit
dbd2f26cf0
@ -3509,7 +3509,6 @@ virDoubleToStr;
|
|||||||
virFormatIntDecimal;
|
virFormatIntDecimal;
|
||||||
virFormatIntPretty;
|
virFormatIntPretty;
|
||||||
virGetDeviceID;
|
virGetDeviceID;
|
||||||
virGetDeviceUnprivSGIO;
|
|
||||||
virGetGroupID;
|
virGetGroupID;
|
||||||
virGetGroupList;
|
virGetGroupList;
|
||||||
virGetGroupName;
|
virGetGroupName;
|
||||||
@ -3543,7 +3542,6 @@ virPipeQuiet;
|
|||||||
virScaleInteger;
|
virScaleInteger;
|
||||||
virSetBlocking;
|
virSetBlocking;
|
||||||
virSetCloseExec;
|
virSetCloseExec;
|
||||||
virSetDeviceUnprivSGIO;
|
|
||||||
virSetInherit;
|
virSetInherit;
|
||||||
virSetNonBlock;
|
virSetNonBlock;
|
||||||
virSetSockReuseAddr;
|
virSetSockReuseAddr;
|
||||||
|
@ -1472,65 +1472,6 @@ qemuGetSharedDeviceKey(const char *device_path)
|
|||||||
return g_strdup_printf("%d:%d", maj, min);
|
return g_strdup_printf("%d:%d", maj, min);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Make necessary checks for the need to check and for the current setting
|
|
||||||
* of the 'unpriv_sgio' value for the device_path passed.
|
|
||||||
*
|
|
||||||
* Returns:
|
|
||||||
* 0 - Success
|
|
||||||
* -1 - Some failure which would already have been messaged
|
|
||||||
* -2 - Mismatch with the "shared" sgio setting - needs to be messaged
|
|
||||||
* by caller since it has context of which type of disk resource is
|
|
||||||
* being used and in the future the hostdev information.
|
|
||||||
*/
|
|
||||||
static int
|
|
||||||
qemuCheckUnprivSGIO(GHashTable *sharedDevices G_GNUC_UNUSED,
|
|
||||||
const char *device_path G_GNUC_UNUSED,
|
|
||||||
int sgio G_GNUC_UNUSED)
|
|
||||||
{
|
|
||||||
/* It can't be conflict if unpriv_sgio is not supported by kernel. */
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* Check if a shared device's setting conflicts with the conf
|
|
||||||
* used by other domain(s). Currently only checks the sgio
|
|
||||||
* setting. Note that this should only be called for disk with
|
|
||||||
* block source if the device type is disk.
|
|
||||||
*
|
|
||||||
* Returns 0 if no conflicts, otherwise returns -1.
|
|
||||||
*/
|
|
||||||
static int
|
|
||||||
qemuCheckSharedDisk(GHashTable *sharedDevices,
|
|
||||||
virDomainDiskDef *disk)
|
|
||||||
{
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
if (disk->device != VIR_DOMAIN_DISK_DEVICE_LUN)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if ((ret = qemuCheckUnprivSGIO(sharedDevices, disk->src->path,
|
|
||||||
disk->sgio)) < 0) {
|
|
||||||
if (ret == -2) {
|
|
||||||
if (virDomainDiskGetType(disk) == VIR_STORAGE_TYPE_VOLUME) {
|
|
||||||
virReportError(VIR_ERR_OPERATION_INVALID,
|
|
||||||
_("sgio of shared disk 'pool=%s' 'volume=%s' "
|
|
||||||
"conflicts with other active domains"),
|
|
||||||
disk->src->srcpool->pool,
|
|
||||||
disk->src->srcpool->volume);
|
|
||||||
} else {
|
|
||||||
virReportError(VIR_ERR_OPERATION_INVALID,
|
|
||||||
_("sgio of shared disk '%s' conflicts with "
|
|
||||||
"other active domains"),
|
|
||||||
disk->src->path);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
qemuSharedDeviceEntryDomainExists(qemuSharedDeviceEntry *entry,
|
qemuSharedDeviceEntryDomainExists(qemuSharedDeviceEntry *entry,
|
||||||
@ -1647,9 +1588,6 @@ qemuSharedDiskAddRemoveInternal(virQEMUDriver *driver,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (addDisk) {
|
if (addDisk) {
|
||||||
if (qemuCheckSharedDisk(driver->sharedDevices, disk) < 0)
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
if (qemuSharedDeviceEntryInsert(driver, key, name) < 0)
|
if (qemuSharedDeviceEntryInsert(driver, key, name) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
} else {
|
} else {
|
||||||
@ -1804,65 +1742,6 @@ qemuRemoveSharedDevice(virQEMUDriver *driver,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
|
||||||
qemuSetUnprivSGIO(virDomainDeviceDef *dev)
|
|
||||||
{
|
|
||||||
virDomainDiskDef *disk = NULL;
|
|
||||||
virDomainHostdevDef *hostdev = NULL;
|
|
||||||
const char *path = NULL;
|
|
||||||
int val = -1;
|
|
||||||
|
|
||||||
/* "sgio" is only valid for block disk; cdrom
|
|
||||||
* and floopy disk can have empty source.
|
|
||||||
*/
|
|
||||||
if (dev->type == VIR_DOMAIN_DEVICE_DISK) {
|
|
||||||
disk = dev->data.disk;
|
|
||||||
|
|
||||||
if (disk->device != VIR_DOMAIN_DISK_DEVICE_LUN ||
|
|
||||||
!virStorageSourceIsBlockLocal(disk->src))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
path = virDomainDiskGetSource(disk);
|
|
||||||
} else if (dev->type == VIR_DOMAIN_DEVICE_HOSTDEV) {
|
|
||||||
hostdev = dev->data.hostdev;
|
|
||||||
|
|
||||||
if (!qemuIsSharedHostdev(hostdev))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if (hostdev->source.subsys.u.scsi.sgio) {
|
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
||||||
_("'sgio' is not supported for SCSI "
|
|
||||||
"generic device yet "));
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
} else {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* By default, filter the SG_IO commands, i.e. set unpriv_sgio to 0. */
|
|
||||||
val = (disk->sgio == VIR_DOMAIN_DEVICE_SGIO_UNFILTERED);
|
|
||||||
|
|
||||||
/* 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
|
|
||||||
* virSetDeviceUnprivSGIO, to report an error for unsupported unpriv_sgio.
|
|
||||||
*/
|
|
||||||
if (val == 1) {
|
|
||||||
int curr_val;
|
|
||||||
|
|
||||||
if (virGetDeviceUnprivSGIO(path, NULL, &curr_val) < 0)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
if (curr_val != val &&
|
|
||||||
virSetDeviceUnprivSGIO(path, NULL, val) < 0) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int qemuDriverAllocateID(virQEMUDriver *driver)
|
int qemuDriverAllocateID(virQEMUDriver *driver)
|
||||||
{
|
{
|
||||||
return g_atomic_int_add(&driver->lastvmid, 1) + 1;
|
return g_atomic_int_add(&driver->lastvmid, 1) + 1;
|
||||||
|
@ -376,8 +376,6 @@ int qemuRemoveSharedDisk(virQEMUDriver *driver,
|
|||||||
const char *name)
|
const char *name)
|
||||||
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
|
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
|
||||||
|
|
||||||
int qemuSetUnprivSGIO(virDomainDeviceDef *dev);
|
|
||||||
|
|
||||||
int qemuDriverAllocateID(virQEMUDriver *driver);
|
int qemuDriverAllocateID(virQEMUDriver *driver);
|
||||||
virDomainXMLOption *virQEMUDriverCreateXMLConf(virQEMUDriver *driver,
|
virDomainXMLOption *virQEMUDriverCreateXMLConf(virQEMUDriver *driver,
|
||||||
const char *defsecmodel);
|
const char *defsecmodel);
|
||||||
|
@ -289,9 +289,6 @@ qemuHostdevPrepareSCSIDevices(virQEMUDriver *driver,
|
|||||||
|
|
||||||
if (qemuAddSharedDevice(driver, &dev, name) < 0)
|
if (qemuAddSharedDevice(driver, &dev, name) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (qemuSetUnprivSGIO(&dev) < 0)
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return virHostdevPrepareSCSIDevices(hostdev_mgr, QEMU_DRIVER_NAME,
|
return virHostdevPrepareSCSIDevices(hostdev_mgr, QEMU_DRIVER_NAME,
|
||||||
|
@ -980,9 +980,6 @@ qemuDomainAttachDeviceDiskLiveInternal(virQEMUDriver *driver,
|
|||||||
if (qemuAddSharedDevice(driver, dev, vm->def->name) < 0)
|
if (qemuAddSharedDevice(driver, dev, vm->def->name) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (qemuSetUnprivSGIO(dev) < 0)
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
if (qemuDomainDetermineDiskChain(driver, vm, disk, NULL, true) < 0)
|
if (qemuDomainDetermineDiskChain(driver, vm, disk, NULL, true) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
|
@ -5046,9 +5046,6 @@ qemuProcessSetupRawIO(virQEMUDriver *driver,
|
|||||||
dev.data.disk = disk;
|
dev.data.disk = disk;
|
||||||
if (qemuAddSharedDevice(driver, &dev, vm->def->name) < 0)
|
if (qemuAddSharedDevice(driver, &dev, vm->def->name) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (qemuSetUnprivSGIO(&dev) < 0)
|
|
||||||
goto cleanup;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If rawio not already set, check hostdevs as well */
|
/* If rawio not already set, check hostdevs as well */
|
||||||
|
Loading…
Reference in New Issue
Block a user