| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch. |
Sorry, something went wrong.
Data volumes could be assigned the same device id as one of the CD-ROM devices or the config drive ISO, which end up with the same libvirt target name (e.g. sde) when they are on the same bus namespace (SATA with UEFI/Q35). With multiple CD-ROM support, the KVM agent defines all the CD-ROMs supported by the host at boot, so any slot after the primary one can conflict. Add VolumeApiService.getReservedDeviceIds(), which returns the device ids of the CD-ROM devices and of the config drive ISO when the Instance uses config drive. The number of CD-ROM devices is returned by TemplateManager.getVmCdromCount(), based on the CD-ROM cap advertised by the host and the ISOs attached. The config drive is detected from the network providers (Dhcp, Dns, UserData), so Instances which have never been started are covered as well as the ones with the config drive location detail. The reserved ids are skipped when allocating device ids in: - attach volume - restore of volumes and Instances from backup - import of Instances (unmanaged Instances and VMware to KVM) The max number of data volumes is preserved when device ids are reserved, and the error message of an invalid deviceId lists the reserved ids.
The config drive ISO is attached as a CD-ROM, but its device id was hardcoded to 4, which is also the device id of the second ISO CD-ROM when multiple ISOs are supported. With vm.iso.max.count >= 2 the Instance could get two CD-ROMs on the same device id. The config drive ISO is now the CD-ROM following the ones of the ISOs, so its device id is the primary CD-ROM device id plus the number of the CD-ROMs of the ISOs (TemplateManager.getConfigDriveDeviceId). As the config drive ISO takes one of the CD-ROMs supported by the host, the maximum number of ISOs of an Instance using config drive is lowered by one. The number of CD-ROM devices of an Instance (TemplateManager.getVmCdromCount) includes the config drive ISO, so the device ids reserved for the volumes follow it, and the volume device id allocators do not need to know about the config drive any more. The KVM agent finds the config drive CD-ROM by the path of its ISO, and keeps its label and bus when refreshing it, instead of using the hardcoded id 4 and the label hdd (which does not match the SATA CD-ROMs of UEFI Instances).
Codecov Report❌ Patch coverage is 88.00000% with 12 lines in your changes missing coverage. Please review. @@ Coverage Diff @@
## main #14407 +/- ##
============================================
+ Coverage 20.68% 20.69% +0.01%
- Complexity 21724 21765 +41
============================================
Files 6489 6489
Lines 590173 590241 +68
Branches 72362 72375 +13
============================================
+ Hits 122060 122173 +113
+ Misses 454842 454797 -45
Partials 13271 13271
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness.
|
Sorry, something went wrong.
vm.iso.max.count is the maximum number of ISOs of an Instance, so it should not take the config drive ISO into account: the config drive ISO is attached as an additional CD-ROM, following the ones of the ISOs. As the IDE bus only has the slots of the first MAX_CDROMS_PER_VM CD-ROMs (hdc and hdd), the KVM agent attaches the CD-ROMs beyond these slots (e.g. the config drive ISO following the maximum number of ISOs) on the SATA bus.
| } | ||
| } | ||
|
|
||
| @Override |
There was a problem hiding this comment.
The changes in this file looks good but I am not sure if this is the place where these methods should exist.
Sorry, something went wrong.
There was a problem hiding this comment.
just one minor comment. otherwise the changes looks good.
Sorry, something went wrong.
The config drive ISO keeps the device id 4, whatever the number of CD-ROMs of the Instance. The CD-ROMs of the ISOs are attached around it. This reverts the commits: - server,kvm: Do not count the config drive ISO in vm.iso.max.count - server,kvm: Calculate the device id of the config drive ISO
The config drive ISO keeps the device id 4, whatever the number of ISOs of the Instance. When an Instance uses config drive, the CD-ROMs of the ISOs which would use that device id or the next ones are moved to the next device ids, i.e. the CD-ROMs are, by device id: ISO 1 (3), config drive (4), ISO 2 (5), ISO 3 (6), ... The ISO slots stored for the Instance (user_vm.iso_id and vm_iso_map) are not changed. They are converted to device ids when the CD-ROMs are defined for the Instance, and when an ISO is attached or detached, so Instances which already have an ISO in the slot following the first one do not need to be updated. The number of CD-ROM devices of an Instance (TemplateManager.getVmCdromCount) includes the one of the config drive ISO, so the device ids reserved for the volumes cover all of them. When the networks of an Instance are not known yet (import, restore from backup), the config drive is always assumed. CloudStack supports 2 CD-ROMs per Instance on the IDE bus (hdc and hdd, the first two slots are kept for the disks). The KVM agent defines the CD-ROMs beyond these slots on the SATA bus.
TemplateManager exposed the number of CD-ROMs of an Instance, which the only caller (VolumeApiServiceImpl) converted back to the device ids starting from the primary CD-ROM device id. Return the device ids directly (TemplateManager.getCdromDeviceIds), so the callers do not have to assume that they are consecutive, and the number of CD-ROMs becomes an internal detail of TemplateManagerImpl.
|
overall the changes look good. nit: what happens if a running vm is added to a config drive network and then gets a second iso? looks like the iso goes to a drive that was never set up at start, so the attach fails until a restart. |
Sorry, something went wrong.
good point. if so, I would advise to reserve device id 3 as primary CD-ROM, and device id 4 as configdrive ISO. if the VM use IDE controller which support 2 CDROMs, the additional CD-ROMs (from 2nd CDROM) will use SATA controller or 2nd IDE controller, due to hardcoded MAX_CDROMS_PER_VM = 2 , right ? |
Sorry, something went wrong.
@weizhouapache right, the limit of 2 is ours, not qemu's. with 4 always kept for the config drive, the ide bus is full after the first cd, so extra isos go on sata or a second ide controller. that also covers the running vm case, since the second iso no longer moves when a config drive shows up. |
Sorry, something went wrong.
checked again, when a running vm is added to a network with config drive, the ISO will be created , but it is not attached to the running vm, so it has no duplicate id 4 after the NIC is added |
Sorry, something went wrong.
Manual test results (commit de91dd4)Environment: management server and one KVM host built from this branch (24.0.0-SNAPSHOT). The agent advertises host.cdrom.max.count=2. vm.iso.max.count is 1 by default and was raised to 2 for the two-ISO cases (restored afterwards). Template: Ubuntu 24.04 cloud image. Guest OS types: Ubuntu, Windows Server 2022 and "Other (64-bit)". Every check was asserted by a script (target dev and bus from virsh dumpxml, device ids from the DB, VM state after start).
Also checked: a second ISO on a running config drive VM that booted with vm.iso.max.count=1 fails to attach until the VM is restarted. This matches the description. q35 selected only through kvm.guest.os.machine.type, without the UEFI detail, still fails to start (IDE is unsupported on q35). This is the same as before the change. Unit tests of the touched classes pass (VolumeApiServiceImplTest, TemplateManagerImplTest, UnmanagedVMsManagerImplTest, KVMGuruTest, LibvirtComputingResourceTest, LibvirtVMDefTest, ConfigDriveNetworkElementTest). Not covered by these tests
|
Sorry, something went wrong.
|
This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch. |
Sorry, something went wrong.
Conflicts in KVMGuru and KVMGuruTest: keep the restore of the device id recorded in the backup, but fall back to the next free device id when the recorded one is reserved for a CD-ROM or the config drive ISO now.
cc @Damans227 @NuxRo |
Sorry, something went wrong.
|
@weizhouapache a [SL] Jenkins job has been kicked to build packages. It will be bundled with no SystemVM templates. I'll keep you posted as I make progress. |
Sorry, something went wrong.
|
Packaging result [SF]: ✖️ el8 ✖️ el9 ✖️ debian ✖️ suse15. SL-JID 19743 |
Sorry, something went wrong.
|
Accepted: package kvm G for 3336b483e8e7. Planned: RPM + DEB, KVM SystemVM. Status: Completed. Packaging results. |
Sorry, something went wrong.
Packaging results:
Test packages are available at: |
Sorry, something went wrong.
There was a problem hiding this comment.
thanks @weizhouapache, the merge from main looks right and the running vm case is in the notes now. CLGTM.
Sorry, something went wrong.
|
@RosiKyu a [SL] Jenkins job has been kicked to build packages. It will be bundled with no SystemVM templates. I'll keep you posted as I make progress. |
Sorry, something went wrong.
|
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 19780 |
Sorry, something went wrong.
There was a problem hiding this comment.
Tested on build 24.0.0-shapeblue22317 (head 3336b48), upgraded from 4.23.0.0: first the management server, then the agents. The q35 hosts (host.cdrom.max.count 2) use config drive and NAS backup.
LGTM for the reported issues (#13484 and #14321): data volumes no longer take the device ids of the CD-ROMs or the config drive ISO, on running and stopped VMs, with 1 and 2 ISOs. No regression was found.
Sorry, something went wrong.
|
Follow-up issues for the open cases from testing. All three also fail on 4.23.0.0 (before this PR), so they are not caused by it:
|
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Description
This PR fixes #13484 and #14321 (the fix for 4.22 is in #14073).
On KVM, a data volume could get the same device id as a CD-ROM or as the config drive ISO. When both devices end up with the same sd* target name (SATA CD-ROMs on UEFI/q35 Instances plus SCSI or SATA data disks), libvirt rejects the domain XML with target 'sde' duplicated for disk sources ...:
Besides the attach volume API, the same conflicts could happen when attaching volumes to a stopped Instance (the conflict only shows up when it is started), when restoring volumes/Instances from backup, and when importing Instances (unmanaged Instances and VMware to KVM), which numbered the data disks 1, 2, 3, 4, ...
Device ids of an Instance
Examples (KVM host which supports 2 CD-ROMs, default maximum of 6 data volumes):
Libvirt targets of the last row: BIOS (IDE) Instance: ISO 1 hdc, config drive hdd, ISO 2 sdf; UEFI Instance with SCSI disks: ISO 1 sdd, config drive sde, ISO 2 sdf, data volumes sdb, sdc, sdg, sdh, ...
For a host which does not advertise the number of CD-ROMs (older agents, other hypervisors): one ISO CD-ROM (3), and the config drive ISO (4) if the Instance uses config drive.
Changes
Notes
Types of changes
Feature/Enhancement Scale or Bug Severity
Feature/Enhancement Scale
Bug Severity
Screenshots (if appropriate):
How Has This Been Tested?
Unit tests (TemplateManagerImplTest, VolumeApiServiceImplTest, ConfigDriveNetworkElementTest, KVMGuruTest, UnmanagedVMsManagerImplTest, LibvirtComputingResourceTest, LibvirtVMDefTest) cover the reserved device ids, the number of CD-ROMs, the config drive detection (from the network providers and from the location detail), the conversion of ISO slots to device ids, the device id allocation for attach volume, restore and import, and the SATA bus for the CD-ROMs beyond the IDE slots.
Manually tested on a KVM host (management server and agent built from this branch, Ubuntu 24.04 template, L2 networks with and without config drive, vm.iso.max.count 1 and 2):
How did you try to break this feature and the system with this change?