-
Notifications
You must be signed in to change notification settings - Fork 498
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
Fix memory setting issue when starting domain #1818
base: main
Are you sure you want to change the base?
Fix memory setting issue when starting domain #1818
Conversation
By passing a flag to libvirt's API to apply the memory size change to the domain's configuration file, the following issue was solved. - fail to update the domain.memory on existing running vm 'Call to virDomainSetMemory failed' vagrant-libvirt#1812 vagrant-libvirt#1812 The problem was caused by passing only memory size to #memory= method in start_domain.rb. Specifying a flag in addition to the memory size causes libvirt's API, virDomainSetMemoryFlags, to be called with that flag, explicitly choosing whether to apply the size setting to the running domain or the config file for that domain. The missing flag was causing the above issue by attempting to change the memory size of a running domain that did not exist. Therefore, a list of possible flags is introduced, and a flag that make changes to the domain's configuration file is selected and used. Below are links to some related documents. - https://ruby.libvirt.org/api/Libvirt/Domain.html#method-i-memory-3D - https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainSetMemoryFlags
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.
Are you able to add an acceptance test that modified the memory and reloads? If you can add it in the first commit and then have this fix in the latter so that I can see the failure and then it passing it'll make it easy for me to just approve and merge without needing to wait until I've time to test it out myself.
It should be possible to copy
context 'with modified config' do |
environment.workdir
attribute for where to find the current run test Vagrantfile
to modify before the reload call.
module ModImpactFlags | ||
VIR_DOMAIN_AFFECT_CURRENT = 0 # affect current domain state | ||
VIR_DOMAIN_AFFECT_LIVE = 1 # affect running domain state | ||
VIR_DOMAIN_AFFECT_CONFIG = 2 # affect persistent domain state |
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.
Can you keep these with the rest of domain_flags.rb
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.
Yes, let's do that.
Download the latest artifacts for this pull request here: |
Pull Request Test Coverage Report for Build 9043414875Details
💛 - Coveralls |
Thank you! I'm on vacation right now and will be able to work on it the day after tomorrow. |
As long as you're comfortable with rebase swapping the two commits it should be fine. There shouldn't be any of the same files touched by the two commits so it should be a clean swap. |
By passing a flag to libvirt's API to apply the memory size change to the domain's configuration file, the following issue was solved.
The problem was caused by passing only memory size to #memory= method in start_domain.rb. Specifying a flag in addition to the memory size causes libvirt's API, virDomainSetMemoryFlags, to be called with that flag, explicitly choosing whether to apply the size setting to the running domain or the config file for that domain. The missing flag was causing the above issue by attempting to change the memory size of a running domain that did not exist.
Therefore, a list of possible flags is introduced, and a flag that make changes to the domain's configuration file is selected and used.
Below are links to some related documents.
https://ruby.libvirt.org/api/Libvirt/Domain.html#method-i-memory-3D
https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainSetMemoryFlags