Skip to content
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

Change the memory in a running VM #7069

Closed
moussa854 opened this issue Oct 3, 2023 · 6 comments
Closed

Change the memory in a running VM #7069

moussa854 opened this issue Oct 3, 2023 · 6 comments

Comments

@moussa854
Copy link

Is your feature request related to a problem? Please describe.
In XO, in order to change the memory, the VM need to be stopped.

image

But becaue Pfsense supplies the IP addresses for all VMs including the XO and the host, stopping Pfsense VM will make the system not functioning.

On the other hand, in XCP center I would get a messsage that the memory will change after a reboot.

image

It would be nice if XO allow a memory change in a running VM by forcing the VM to reboot

@olivierlambert
Copy link
Member

I wonder, how XO could send the memory modification if the router VM is off? I wonder what XenCenter is doing 🤔

@julien-f
Copy link
Member

julien-f commented Oct 3, 2023

I don't know how XenCenter is doing it, XO is not preventing changing the memory, simply translating the error:

return this.call('VM.set_memory_dynamic_range', $ref, dynamicMin, dynamicMax)::pCatch(
isMemoryConstraintError,
() => {
throw new Error('Cannot change memory on running VM')
}
)

@olivierlambert
Copy link
Member

It seems to be the XC code @julien-f :

        protected override void Run()
        {
            // If either of the static memories has changed, we need to shut down the VM
            // before and reboot afterwards. The user has already been warned about this.
            bool reboot = needReboot;
            XenAPI.Host vmHost = null;
            if (reboot)
            {
                vmHost = VM.Home();
                AsyncAction action = null;
                if (VM.allowed_operations.Contains(XenAPI.vm_operations.clean_shutdown))
                    action = new VMCleanShutdown(VM);
                else
                    action = new VMHardShutdown(VM);
                action.RunExternal(Session);
            }

            // Now save the memory settings. We can't use VM.SaveChanges() for this,
            // because we have to do the operations simultaneously or we will
            // violate the memory ordering constraints.
            try
            {
                if (staticChanged)
                    XenAPI.VM.set_memory_limits(Session, VM.opaque_ref, static_min, static_max, dynamic_min, dynamic_max);
                else
                    XenAPI.VM.set_memory_dynamic_range(Session, VM.opaque_ref, dynamic_min, dynamic_max);
            }

            // Reboot the VM, even if we failed to change the memory settings
            finally
            {
                if (reboot)
                {
                    var action = new VMStartOnAction(VM, vmHost, _warningDialogHAInvalidConfig, _startDiagnosticForm);
                    action.RunExternal(Session);
                }
            }

            Description = string.Format(Messages.ACTION_CHANGE_MEMORY_SETTINGS_DONE, VM.Name());
        }

@julien-f
Copy link
Member

julien-f commented Oct 3, 2023

Oh I see, my bad I misunderstood, we could detect this error on the UI side and then reboot the VM to change the values.

It should be easy to do.

@olivierlambert
Copy link
Member

So todo: do the same approach than XenCenter for now: provide a modal with the error message and tell we can apply after a reboot. Then:

  1. Shutdown the VM
  2. Set the memory
  3. Start the VM

@olivierlambert
Copy link
Member

Issue planned for Bastien

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants