Use kvm->nr_disks instead of kvm->cfg.image_count
A user can specify multiple disk images using the --disk/-d argument. The callback for the argument ends up in disk/core.c::calling disk_img_name_parser(), which increments kvm->cfg.image_count for each disk image. Immediately after parsing the arguments in kvm_cmd_run_init(), kvm->nr_disks is set to kvm->cfg.image_count, effectively making kvm->nr_disks an alias for kvm->cfg.image_count, as image_count is never changed afterward. Later on, the core disk code uses kvm->cfg.image_count when opening all the disk images, but kvm->nr_disks when closing them, which is inconsistent, but technically correct since they represent the same thing and have the same value. Let's remove all this confusing usage and use only kvm->nr_disks to represent the number of disk images specified by the user. While this technically means that kvmtool now supports up to INT_MAX disk images, in practice this is limited by MAX_DISK_IMAGES, which is equal to four. Which means there are no functional changes. Signed-off-by:Alexandru Elisei <alexandru.elisei@arm.com> Link: https://lore.kernel.org/r/20210923144505.60776-6-alexandru.elisei@arm.com Signed-off-by:
Will Deacon <will@kernel.org>
Loading
Please register or sign in to comment