Skip to content

test_set_capacity does not restore Host capacity or VM template on failed VM resize #8185

Open

Description

@trukhinyuri

Description
In test_set_capacity() (src/dm/DispatchManagerActions.cc, lines 2763-2805), when resizing a VM that is already assigned to a host (POWEROFF, SUSPENDED, or ACTIVE/RUNNING), host->del_capacity(sr) is called on the cached Host object in HostPool before vm->resize(cpu, mem, vcpu, error) and host->test_capacity(sr, error, enforce).

If vm->resize() returns -1 or host->test_capacity() returns false, test_set_capacity() returns -1 without calling host->add_capacity(old_sr) and without reverting vm->resize(). Because host and vm are cached entries in HostPool / VirtualMachinePool, the host's in-memory cpu_usage, mem_usage, running_vms and vm_collection stay decremented (and dropping a RUNNING VM from host->vm_collection causes the next host monitor poll to report it as a zombie VM), while the cached VirtualMachine template keeps the new CPU/MEMORY/VCPU values in memory.

Also, host->test_capacity(sr, error, enforce) checks both sr.cpu and sr.mem unconditionally (HostShare::test_capacity), so increasing only CPU/VCPU (with unchanged or reduced MEMORY) on a host where mem_usage > max_mem fails with Not enough memory.

To Reproduce

  1. Have a VM in POWEROFF or RUNNING on a host.
  2. Run onevm resize <vid> --memory <larger_than_host_free_mem> --enforce so host->test_capacity() fails.
  3. onehost show <hid> shows the VM's capacity and <VMS><ID> entry removed from the host, and onevm show <vid> shows the new MEMORY in the cached template.

Expected behavior
Failed vm->resize() or host->test_capacity() in test_set_capacity() should restore host->add_capacity(old_sr) and revert the in-memory VM template attributes, and host->test_capacity() should only check resources (cpu / mem) that increase during the resize.

Details

  • Affected Component: Core (DM)
  • Hypervisor: Any
  • Version: 6.10, 7.0, master

Progress Status

  • Code committed
  • Testing - QA
  • Documentation (Release notes - resolved issues, compatibility, known issues)

Activity

  1. added 4 commits that reference this issue on Oct 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions