Skip to content

Commit 29ce03e

Browse files
committed
Merge remote-tracking branch 'apache/4.20' into 4.22
2 parents d7bdbcc + a6ccde4 commit 29ce03e

File tree

7 files changed

+694
-59
lines changed

7 files changed

+694
-59
lines changed

plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4775,12 +4775,11 @@ public DiskDef.DiskBus getDataDiskModelFromVMDetail(final VirtualMachineTO vmTO)
47754775

47764776
String dataDiskController = details.get(VmDetailConstants.DATA_DISK_CONTROLLER);
47774777
if (StringUtils.isNotBlank(dataDiskController)) {
4778-
LOGGER.debug("Passed custom disk controller for DATA disk " + dataDiskController);
4779-
for (DiskDef.DiskBus bus : DiskDef.DiskBus.values()) {
4780-
if (bus.toString().equalsIgnoreCase(dataDiskController)) {
4781-
LOGGER.debug("Found matching enum for disk controller for DATA disk " + dataDiskController);
4782-
return bus;
4783-
}
4778+
LOGGER.debug("Passed custom disk controller for DATA disk {}", dataDiskController);
4779+
DiskDef.DiskBus bus = DiskDef.DiskBus.fromValue(dataDiskController);
4780+
if (bus != null) {
4781+
LOGGER.debug("Found matching enum for disk controller for DATA disk {}", dataDiskController);
4782+
return bus;
47844783
}
47854784
}
47864785
return null;

plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtVMDef.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -686,6 +686,15 @@ public enum DiskBus {
686686
_bus = bus;
687687
}
688688

689+
public static DiskBus fromValue(String bus) {
690+
for (DiskBus b : DiskBus.values()) {
691+
if (b.toString().equalsIgnoreCase(bus)) {
692+
return b;
693+
}
694+
}
695+
return null;
696+
}
697+
689698
@Override
690699
public String toString() {
691700
return _bus;

plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/KVMStorageProcessor.java

Lines changed: 68 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1374,64 +1374,66 @@ protected boolean checkDetachSuccess(String diskPath, Domain dm) throws LibvirtE
13741374

13751375
/**
13761376
* Attaches or detaches a disk to an instance.
1377-
* @param conn libvirt connection
1378-
* @param attach boolean that determines whether the device will be attached or detached
1379-
* @param vmName instance name
1380-
* @param attachingDisk kvm physical disk
1381-
* @param devId device id in instance
1377+
* @param conn libvirt connection
1378+
* @param attach boolean that determines whether the device will be attached or detached
1379+
* @param vmName instance name
1380+
* @param attachingDisk kvm physical disk
1381+
* @param devId device id in instance
13821382
* @param serial
1383-
* @param bytesReadRate bytes read rate
1384-
* @param bytesReadRateMax bytes read rate max
1385-
* @param bytesReadRateMaxLength bytes read rate max length
1386-
* @param bytesWriteRate bytes write rate
1387-
* @param bytesWriteRateMax bytes write rate amx
1383+
* @param bytesReadRate bytes read rate
1384+
* @param bytesReadRateMax bytes read rate max
1385+
* @param bytesReadRateMaxLength bytes read rate max length
1386+
* @param bytesWriteRate bytes write rate
1387+
* @param bytesWriteRateMax bytes write rate amx
13881388
* @param bytesWriteRateMaxLength bytes write rate max length
1389-
* @param iopsReadRate iops read rate
1390-
* @param iopsReadRateMax iops read rate max
1391-
* @param iopsReadRateMaxLength iops read rate max length
1392-
* @param iopsWriteRate iops write rate
1393-
* @param iopsWriteRateMax iops write rate max
1394-
* @param iopsWriteRateMaxLength iops write rate max length
1395-
* @param cacheMode cache mode
1396-
* @param encryptDetails encrypt details
1389+
* @param iopsReadRate iops read rate
1390+
* @param iopsReadRateMax iops read rate max
1391+
* @param iopsReadRateMaxLength iops read rate max length
1392+
* @param iopsWriteRate iops write rate
1393+
* @param iopsWriteRateMax iops write rate max
1394+
* @param iopsWriteRateMaxLength iops write rate max length
1395+
* @param cacheMode cache mode
1396+
* @param encryptDetails encrypt details
1397+
* @param controllerInfo
13971398
* @throws LibvirtException
13981399
* @throws InternalErrorException
13991400
*/
14001401
protected synchronized void attachOrDetachDisk(final Connect conn, final boolean attach, final String vmName, final KVMPhysicalDisk attachingDisk, final int devId,
14011402
final String serial, final Long bytesReadRate, final Long bytesReadRateMax, final Long bytesReadRateMaxLength,
14021403
final Long bytesWriteRate, final Long bytesWriteRateMax, final Long bytesWriteRateMaxLength, final Long iopsReadRate,
14031404
final Long iopsReadRateMax, final Long iopsReadRateMaxLength, final Long iopsWriteRate, final Long iopsWriteRateMax,
1404-
final Long iopsWriteRateMaxLength, final String cacheMode, final DiskDef.LibvirtDiskEncryptDetails encryptDetails, Map<String, String> details)
1405+
final Long iopsWriteRateMaxLength, final String cacheMode, final DiskDef.LibvirtDiskEncryptDetails encryptDetails, Map<String, String> details, Map<String, String> controllerInfo)
14051406
throws LibvirtException, InternalErrorException {
14061407
attachOrDetachDisk(conn, attach, vmName, attachingDisk, devId, serial, bytesReadRate, bytesReadRateMax, bytesReadRateMaxLength,
14071408
bytesWriteRate, bytesWriteRateMax, bytesWriteRateMaxLength, iopsReadRate, iopsReadRateMax, iopsReadRateMaxLength, iopsWriteRate,
1408-
iopsWriteRateMax, iopsWriteRateMaxLength, cacheMode, encryptDetails, 0l, details);
1409+
iopsWriteRateMax, iopsWriteRateMaxLength, cacheMode, encryptDetails, 0l, details, controllerInfo);
14091410
}
14101411

14111412
/**
14121413
*
14131414
* Attaches or detaches a disk to an instance.
1414-
* @param conn libvirt connection
1415-
* @param attach boolean that determines whether the device will be attached or detached
1416-
* @param vmName instance name
1417-
* @param attachingDisk kvm physical disk
1418-
* @param devId device id in instance
1415+
* @param conn libvirt connection
1416+
* @param attach boolean that determines whether the device will be attached or detached
1417+
* @param vmName instance name
1418+
* @param attachingDisk kvm physical disk
1419+
* @param devId device id in instance
14191420
* @param serial
1420-
* @param bytesReadRate bytes read rate
1421-
* @param bytesReadRateMax bytes read rate max
1422-
* @param bytesReadRateMaxLength bytes read rate max length
1423-
* @param bytesWriteRate bytes write rate
1424-
* @param bytesWriteRateMax bytes write rate amx
1421+
* @param bytesReadRate bytes read rate
1422+
* @param bytesReadRateMax bytes read rate max
1423+
* @param bytesReadRateMaxLength bytes read rate max length
1424+
* @param bytesWriteRate bytes write rate
1425+
* @param bytesWriteRateMax bytes write rate amx
14251426
* @param bytesWriteRateMaxLength bytes write rate max length
1426-
* @param iopsReadRate iops read rate
1427-
* @param iopsReadRateMax iops read rate max
1428-
* @param iopsReadRateMaxLength iops read rate max length
1429-
* @param iopsWriteRate iops write rate
1430-
* @param iopsWriteRateMax iops write rate max
1431-
* @param iopsWriteRateMaxLength iops write rate max length
1432-
* @param cacheMode cache mode
1433-
* @param encryptDetails encrypt details
1434-
* @param waitDetachDevice value set in milliseconds to wait before assuming device removal failed
1427+
* @param iopsReadRate iops read rate
1428+
* @param iopsReadRateMax iops read rate max
1429+
* @param iopsReadRateMaxLength iops read rate max length
1430+
* @param iopsWriteRate iops write rate
1431+
* @param iopsWriteRateMax iops write rate max
1432+
* @param iopsWriteRateMaxLength iops write rate max length
1433+
* @param cacheMode cache mode
1434+
* @param encryptDetails encrypt details
1435+
* @param waitDetachDevice value set in milliseconds to wait before assuming device removal failed
1436+
* @param controllerInfo
14351437
* @throws LibvirtException
14361438
* @throws InternalErrorException
14371439
*/
@@ -1440,7 +1442,7 @@ protected synchronized void attachOrDetachDisk(final Connect conn, final boolean
14401442
final Long bytesWriteRate, final Long bytesWriteRateMax, final Long bytesWriteRateMaxLength, final Long iopsReadRate,
14411443
final Long iopsReadRateMax, final Long iopsReadRateMaxLength, final Long iopsWriteRate, final Long iopsWriteRateMax,
14421444
final Long iopsWriteRateMaxLength, final String cacheMode, final DiskDef.LibvirtDiskEncryptDetails encryptDetails,
1443-
long waitDetachDevice, Map<String, String> details)
1445+
long waitDetachDevice, Map<String, String> details, Map<String, String> controllerInfo)
14441446
throws LibvirtException, InternalErrorException {
14451447

14461448
List<DiskDef> disks = null;
@@ -1477,17 +1479,7 @@ protected synchronized void attachOrDetachDisk(final Connect conn, final boolean
14771479
return;
14781480
}
14791481
} else {
1480-
DiskDef.DiskBus busT = DiskDef.DiskBus.VIRTIO;
1481-
for (final DiskDef disk : disks) {
1482-
if (disk.getDeviceType() == DeviceType.DISK) {
1483-
if (disk.getBusType() == DiskDef.DiskBus.SCSI) {
1484-
busT = DiskDef.DiskBus.SCSI;
1485-
} else if (disk.getBusType() == DiskDef.DiskBus.VIRTIOBLK) {
1486-
busT = DiskDef.DiskBus.VIRTIOBLK;
1487-
}
1488-
break;
1489-
}
1490-
}
1482+
DiskDef.DiskBus busT = getAttachDiskBusType(devId, disks, controllerInfo);
14911483
diskdef = new DiskDef();
14921484
if (busT == DiskDef.DiskBus.SCSI || busT == DiskDef.DiskBus.VIRTIOBLK) {
14931485
diskdef.setQemuDriver(true);
@@ -1592,6 +1584,28 @@ protected synchronized void attachOrDetachDisk(final Connect conn, final boolean
15921584
}
15931585
}
15941586

1587+
protected DiskDef.DiskBus getAttachDiskBusType(int deviceId, List<DiskDef> disks, Map<String, String> controllerInfo) {
1588+
String controllerKey = deviceId == 0 ? VmDetailConstants.ROOT_DISK_CONTROLLER : VmDetailConstants.DATA_DISK_CONTROLLER;
1589+
String diskController = MapUtils.getString(controllerInfo, controllerKey);
1590+
DiskDef.DiskBus busType = DiskDef.DiskBus.fromValue(diskController);
1591+
if (diskController != null) {
1592+
logger.debug("Using controller '{}' from command specified as {} while attaching disk (deviceId={})",
1593+
diskController, controllerKey, deviceId);
1594+
return busType;
1595+
}
1596+
for (final DiskDef disk : disks) {
1597+
if (disk.getDeviceType() != DeviceType.DISK) {
1598+
continue;
1599+
}
1600+
if (disk.getBusType() == DiskDef.DiskBus.SCSI) {
1601+
return DiskDef.DiskBus.SCSI;
1602+
} else if (disk.getBusType() == DiskDef.DiskBus.VIRTIOBLK) {
1603+
return DiskDef.DiskBus.VIRTIOBLK;
1604+
}
1605+
}
1606+
return DiskDef.DiskBus.VIRTIO;
1607+
}
1608+
15951609
@Override
15961610
public Answer attachVolume(final AttachCommand cmd) {
15971611
final DiskTO disk = cmd.getDisk();
@@ -1619,7 +1633,8 @@ public Answer attachVolume(final AttachCommand cmd) {
16191633
vol.getBytesReadRate(), vol.getBytesReadRateMax(), vol.getBytesReadRateMaxLength(),
16201634
vol.getBytesWriteRate(), vol.getBytesWriteRateMax(), vol.getBytesWriteRateMaxLength(),
16211635
vol.getIopsReadRate(), vol.getIopsReadRateMax(), vol.getIopsReadRateMaxLength(),
1622-
vol.getIopsWriteRate(), vol.getIopsWriteRateMax(), vol.getIopsWriteRateMaxLength(), volCacheMode, encryptDetails, disk.getDetails());
1636+
vol.getIopsWriteRate(), vol.getIopsWriteRateMax(), vol.getIopsWriteRateMaxLength(), volCacheMode,
1637+
encryptDetails, disk.getDetails(), cmd.getControllerInfo());
16231638

16241639
resource.recreateCheckpointsOnVm(List.of((VolumeObjectTO) disk.getData()), vmName, conn);
16251640

@@ -1658,7 +1673,7 @@ public Answer dettachVolume(final DettachCommand cmd) {
16581673
vol.getBytesReadRate(), vol.getBytesReadRateMax(), vol.getBytesReadRateMaxLength(),
16591674
vol.getBytesWriteRate(), vol.getBytesWriteRateMax(), vol.getBytesWriteRateMaxLength(),
16601675
vol.getIopsReadRate(), vol.getIopsReadRateMax(), vol.getIopsReadRateMaxLength(),
1661-
vol.getIopsWriteRate(), vol.getIopsWriteRateMax(), vol.getIopsWriteRateMaxLength(), volCacheMode, null, waitDetachDevice, null);
1676+
vol.getIopsWriteRate(), vol.getIopsWriteRateMax(), vol.getIopsWriteRateMaxLength(), volCacheMode, null, waitDetachDevice, null, null);
16621677

16631678
storagePoolMgr.disconnectPhysicalDisk(primaryStore.getPoolType(), primaryStore.getUuid(), vol.getPath());
16641679

ui/public/config.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@
105105
"showAllCategoryForModernImageSelection": false,
106106
"docHelpMappings": {},
107107
"notifyLatestCSVersion": true,
108+
"showSearchFilters": true,
108109
"announcementBanner": {
109110
"enabled": false,
110111
"showIcon": false,

0 commit comments

Comments
 (0)