]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: remove all use of SGIO
authorJán Tomko <jtomko@redhat.com>
Thu, 13 Jan 2022 16:47:03 +0000 (17:47 +0100)
committerJán Tomko <jtomko@redhat.com>
Wed, 19 Jan 2022 12:57:59 +0000 (13:57 +0100)
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>
src/libvirt_private.syms
src/qemu/qemu_conf.c
src/qemu/qemu_conf.h
src/qemu/qemu_hostdev.c
src/qemu/qemu_hotplug.c
src/qemu/qemu_process.c

index e2394318b3b2a2f50fbb124aafabc2134763f9dd..9be2069073f75a304eb4b0455f519b532e759816 100644 (file)
@@ -3509,7 +3509,6 @@ virDoubleToStr;
 virFormatIntDecimal;
 virFormatIntPretty;
 virGetDeviceID;
-virGetDeviceUnprivSGIO;
 virGetGroupID;
 virGetGroupList;
 virGetGroupName;
@@ -3543,7 +3542,6 @@ virPipeQuiet;
 virScaleInteger;
 virSetBlocking;
 virSetCloseExec;
-virSetDeviceUnprivSGIO;
 virSetInherit;
 virSetNonBlock;
 virSetSockReuseAddr;
index 73497ad84801153492c0ea86ef10addecd52ed5f..28cbdd6e61c80921161f77e7bd9768e618d579b1 100644 (file)
@@ -1472,65 +1472,6 @@ qemuGetSharedDeviceKey(const char *device_path)
     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
 qemuSharedDeviceEntryDomainExists(qemuSharedDeviceEntry *entry,
@@ -1647,9 +1588,6 @@ qemuSharedDiskAddRemoveInternal(virQEMUDriver *driver,
         goto cleanup;
 
     if (addDisk) {
-        if (qemuCheckSharedDisk(driver->sharedDevices, disk) < 0)
-            goto cleanup;
-
         if (qemuSharedDeviceEntryInsert(driver, key, name) < 0)
             goto cleanup;
     } 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)
 {
     return g_atomic_int_add(&driver->lastvmid, 1) + 1;
index 2f64e39a186574e4a47124315b5815faddd8046d..5961b0b205dbf9c097d7183af49190c662497a22 100644 (file)
@@ -376,8 +376,6 @@ int qemuRemoveSharedDisk(virQEMUDriver *driver,
                          const char *name)
     ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
 
-int qemuSetUnprivSGIO(virDomainDeviceDef *dev);
-
 int qemuDriverAllocateID(virQEMUDriver *driver);
 virDomainXMLOption *virQEMUDriverCreateXMLConf(virQEMUDriver *driver,
                                                  const char *defsecmodel);
index 00f301f941ec4553043451d8cbf9218cfa3a5236..5461de459a59e7accdb59a64dbfe03d3906b56f7 100644 (file)
@@ -289,9 +289,6 @@ qemuHostdevPrepareSCSIDevices(virQEMUDriver *driver,
 
         if (qemuAddSharedDevice(driver, &dev, name) < 0)
             return -1;
-
-        if (qemuSetUnprivSGIO(&dev) < 0)
-            return -1;
     }
 
     return virHostdevPrepareSCSIDevices(hostdev_mgr, QEMU_DRIVER_NAME,
index 04c6600f26207c2bf819472217457d3c9a8a8419..0dd31212214bd789cb73d690247adb56aed54587 100644 (file)
@@ -980,9 +980,6 @@ qemuDomainAttachDeviceDiskLiveInternal(virQEMUDriver *driver,
     if (qemuAddSharedDevice(driver, dev, vm->def->name) < 0)
         goto cleanup;
 
-    if (qemuSetUnprivSGIO(dev) < 0)
-        goto cleanup;
-
     if (qemuDomainDetermineDiskChain(driver, vm, disk, NULL, true) < 0)
         goto cleanup;
 
index 5c9ca0fe4f294a242ec54596e1b0123e7fd133b0..b425acfec169ee30fe6d45b7455175202b476872 100644 (file)
@@ -5046,9 +5046,6 @@ qemuProcessSetupRawIO(virQEMUDriver *driver,
         dev.data.disk = disk;
         if (qemuAddSharedDevice(driver, &dev, vm->def->name) < 0)
             goto cleanup;
-
-        if (qemuSetUnprivSGIO(&dev) < 0)
-            goto cleanup;
     }
 
     /* If rawio not already set, check hostdevs as well */