Merge "Make QEMU_IMG_LIMITS process limits configurable"

This commit is contained in:
Zuul
2026-07-09 20:49:17 +00:00
committed by Gerrit Code Review
4 changed files with 39 additions and 2 deletions
+6
View File
@@ -1098,6 +1098,12 @@ Requires:
* Qemu >= 1.5 (raw format)
* Qemu >= 1.6 (qcow2 format)
"""),
cfg.IntOpt('images_cpu_time_limit',
default=30,
help='CPU time process limit in seconds for qemu-img'),
cfg.IntOpt('images_address_space_limit',
default=2,
help='Address space process limit in gigabytes for qemu-img'),
]
libvirt_lvm_opts = [
+5 -2
View File
@@ -25,15 +25,18 @@ from oslo_concurrency import processutils
from oslo_log import log as logging
from oslo_utils import units
import nova.conf
from nova import exception
from nova.i18n import _
import nova.privsep.utils
LOG = logging.getLogger(__name__)
CONF = nova.conf.CONF
QEMU_IMG_LIMITS = processutils.ProcessLimits(
cpu_time=30,
address_space=1 * units.Gi)
cpu_time=CONF.libvirt.images_cpu_time_limit,
address_space=CONF.libvirt.images_address_space_limit * units.Gi)
class EncryptionOptions(ty.TypedDict):
+17
View File
@@ -13,9 +13,11 @@
# License for the specific language governing permissions and limitations
# under the License.
import importlib
from unittest import mock
import ddt
from oslo_utils import units
import nova.privsep.qemu
from nova import test
@@ -203,9 +205,24 @@ class QemuTestCase(test.NoDBTestCase):
# Assert that the expected command is used
mock_execute.assert_called_once_with(
*expected_cmd, prlimit=nova.privsep.qemu.QEMU_IMG_LIMITS)
return mock_execute.call_args
def test_privileged_qemu_img_info(self):
self._test_qemu_img_info(nova.privsep.qemu.privileged_qemu_img_info)
def test_unprivileged_qemu_img_info(self):
self._test_qemu_img_info(nova.privsep.qemu.unprivileged_qemu_img_info)
def test_qemu_img_info_limits_config(self):
self.flags(images_cpu_time_limit=60, group='libvirt')
self.flags(images_address_space_limit=3, group='libvirt')
# Reload the nova.privsep.qemu module after setting the conf options
# because QEMU_IMG_LIMITS is global.
importlib.reload(nova.privsep.qemu)
# Save the call args of execute() to assert.
call_args = self._test_qemu_img_info(
nova.privsep.qemu.unprivileged_qemu_img_info)
# Verify that execute() was called with the configured values.
self.assertEqual(60, call_args.kwargs['prlimit'].cpu_time)
self.assertEqual(3 * units.Gi,
call_args.kwargs['prlimit'].address_space)
@@ -0,0 +1,11 @@
features:
- |
New configuration options ``[libvirt]images_cpu_time_limit`` and
``[libvirt]images_address_space_limit`` have been added to enable tuning of
process limits for qemu-img. The default for
``[libvirt]images_address_space_limit`` is increased from a hard-coded 1G
to 2G in order to accommodate larger image requirements in newer versions
of Ceph. For more details, see bug `#2116852`_.
.. _#2116852: https://bugs.launchpad.net/nova/+bug/2116852