]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: hotplug: Remove pre-blockdev code path from qemuDomainChangeEjectableMedia
authorPeter Krempa <pkrempa@redhat.com>
Thu, 21 Jul 2022 11:08:00 +0000 (13:08 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Thu, 11 Aug 2022 13:21:49 +0000 (15:21 +0200)
All media are changed in blockdev-instantiated cdroms now, remove the
old code.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/qemu/qemu_hotplug.c

index a7c57cd004ccca3c6f43e9b6a3431e4eca7ebd67..e2d30d5873d35338603f1cd9b28c573730d04edf 100644 (file)
@@ -268,88 +268,6 @@ qemuHotplugWaitForTrayEject(virDomainObj *vm,
 }
 
 
-/**
- * qemuDomainChangeMediaLegacy:
- * @driver: qemu driver structure
- * @vm: domain definition
- * @disk: disk definition to change the source of
- * @newsrc: new disk source to change to
- * @force: force the change of media
- *
- * Change the media in an ejectable device to the one described by
- * @newsrc. This function also removes the old source from the
- * shared device table if appropriate. Note that newsrc is consumed
- * on success and the old source is freed on success.
- *
- * Returns 0 on success, -1 on error and reports libvirt error
- */
-static int
-qemuDomainChangeMediaLegacy(virDomainObj *vm,
-                            virDomainDiskDef *disk,
-                            virStorageSource *newsrc,
-                            bool force)
-{
-    int rc;
-    g_autofree char *driveAlias = NULL;
-    qemuDomainObjPrivate *priv = vm->privateData;
-    qemuDomainDiskPrivate *diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
-    const char *format = NULL;
-    g_autofree char *sourcestr = NULL;
-
-    if (!disk->info.alias) {
-        virReportError(VIR_ERR_INTERNAL_ERROR,
-                       _("missing disk device alias name for %s"), disk->dst);
-        return -1;
-    }
-
-    if (!(driveAlias = qemuAliasDiskDriveFromDisk(disk)))
-        return -1;
-
-    qemuDomainObjEnterMonitor(vm);
-    rc = qemuMonitorEjectMedia(priv->mon, driveAlias, force);
-    qemuDomainObjExitMonitor(vm);
-
-    /* If the tray is present wait for it to open. */
-    if (!force && diskPriv->tray) {
-        rc = qemuHotplugWaitForTrayEject(vm, disk);
-        if (rc < 0)
-            return -1;
-
-        /* re-issue ejection command to pop out the media */
-        qemuDomainObjEnterMonitor(vm);
-        rc = qemuMonitorEjectMedia(priv->mon, driveAlias, false);
-        qemuDomainObjExitMonitor(vm);
-        if (rc < 0)
-            return -1;
-
-    } else  {
-        /* otherwise report possible errors from the attempt to eject the media */
-        if (rc < 0)
-            return -1;
-    }
-
-    if (!virStorageSourceIsEmpty(newsrc)) {
-        if (qemuGetDriveSourceString(newsrc, NULL, &sourcestr) < 0)
-            return -1;
-
-        if (virStorageSourceGetActualType(newsrc) != VIR_STORAGE_TYPE_DIR)
-            format = virStorageFileFormatTypeToString(newsrc->format);
-
-        qemuDomainObjEnterMonitor(vm);
-        rc = qemuMonitorChangeMedia(priv->mon,
-                                    driveAlias,
-                                    sourcestr,
-                                    format);
-        qemuDomainObjExitMonitor(vm);
-    }
-
-    if (rc < 0)
-        return -1;
-
-    return 0;
-}
-
-
 /**
  * qemuHotplugAttachDBusVMState:
  * @driver: QEMU driver object
@@ -665,10 +583,7 @@ qemuDomainChangeEjectableMedia(virQEMUDriver *driver,
     if (qemuHotplugAttachManagedPR(vm, newsrc, VIR_ASYNC_JOB_NONE) < 0)
         goto cleanup;
 
-    if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV))
-        rc = qemuDomainChangeMediaBlockdev(vm, disk, oldsrc, newsrc, force);
-    else
-        rc = qemuDomainChangeMediaLegacy(vm, disk, newsrc, force);
+    rc = qemuDomainChangeMediaBlockdev(vm, disk, oldsrc, newsrc, force);
 
     virDomainAuditDisk(vm, oldsrc, newsrc, "update", rc >= 0);