Repository navigation
server: Avoid device id collision between config drive ISO and data volumes on KVM #14073
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 4.22
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -160,6 +160,7 @@ | |
| import com.cloud.hypervisor.Hypervisor.HypervisorType; | ||
| import com.cloud.hypervisor.HypervisorCapabilitiesVO; | ||
| import com.cloud.hypervisor.dao.HypervisorCapabilitiesDao; | ||
| import com.cloud.network.element.ConfigDriveNetworkElement; | ||
| import com.cloud.offering.DiskOffering; | ||
| import com.cloud.org.Cluster; | ||
| import com.cloud.org.Grouping; | ||
|
|
@@ -5042,8 +5043,10 @@ private Long getDeviceId(UserVmVO vm, Long deviceId) { | |
| int maxDevices = getMaxDataVolumesSupported(vm) + 2; // add 2 to consider devices root volume and cdrom | ||
| int maxDeviceId = maxDevices - 1; | ||
| List<VolumeVO> vols = _volsDao.findByInstance(vm.getId()); | ||
| boolean vmHasConfigDrive = vmInstanceDetailsDao.findDetail(vm.getId(), VmDetailConstants.CONFIG_DRIVE_LOCATION) != null; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what happens for a vm deployed with startvm=false and then given three data disks? the config drive detail only shows up on first start, so the third disk still lands on 4
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. good point. I did not consider this case.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. makes sense, checking if the default network uses config drive for user data would work even before the first start |
||
| if (deviceId != null) { | ||
| if (deviceId.longValue() < 0 || deviceId.longValue() > maxDeviceId || deviceId.longValue() == 3) { | ||
| if (deviceId.longValue() < 0 || deviceId.longValue() > maxDeviceId || deviceId.longValue() == 3 | ||
| || (vmHasConfigDrive && deviceId.longValue() == ConfigDriveNetworkElement.CONFIGDRIVEDISKSEQ)) { | ||
| throw new RuntimeException("deviceId should be 0,1,2,4-" + maxDeviceId); | ||
| } | ||
| for (VolumeVO vol : vols) { | ||
|
|
@@ -5058,6 +5061,9 @@ private Long getDeviceId(UserVmVO vm, Long deviceId) { | |
| devIds.add(String.valueOf(i)); | ||
| } | ||
| devIds.remove("3"); | ||
| if (vmHasConfigDrive) { | ||
| devIds.remove(ConfigDriveNetworkElement.CONFIGDRIVEDISKSEQ.toString()); | ||
| } | ||
| for (VolumeVO vol : vols) { | ||
| devIds.remove(vol.getDeviceId().toString().trim()); | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what about vms that already have a data disk on 4? looks like they still clash with the config drive on the next start after upgrade
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the configdrive ISO will still use device id 4, the other disks will use other device ids, I think.
@Damans227 since you developed the support for multiple CD-ROMs, do you know how the device ids are determined ? is it possible that one of the CD-ROM uses device id 4 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
on 4.22 there is only one cd drive and it sits on 3, so nothing else takes 4. on main the extra cd drives count up from 3, so a second iso goes on 4, the same spot as the config drive. so this will clash once it merges forward to main
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Damans227
Thanks, agreed. This is also why I asked you about the configurations for multiple CD-ROMs. We do need to consider these scenarios.
In my opinion, we don't need to consider the device ID changing when a VM is stopped and started. Users should use the device UUID rather than the device name inside the guest OS, since the device name (/dev/sdX) may change as ACS orders the devices when the VM is started.
I think we should focus on preventing duplicate device IDs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
makes sense to focus on duplicate ids. a vm that already has a data disk on 4 still clashes after upgrade though, since nothing moves that disk