libvirt: Extract method _guest_add_memory_balloon
Partial-Bug: #1494374 Change-Id: Ibf3bd59fb4ce5233c26c64ef70a0ab05094ce10d Signed-off-by: Maciej Kucia <maciej@kucia.net>
This commit is contained in:
parent
d3aae9684c
commit
931503a0d9
|
@ -4816,9 +4816,16 @@ class LibvirtDriver(driver.ComputeDriver):
|
|||
|
||||
self._guest_add_watchdog_action(guest, flavor, image_meta)
|
||||
|
||||
self._guest_add_memory_balloon(guest)
|
||||
|
||||
return guest
|
||||
|
||||
@staticmethod
|
||||
def _guest_add_memory_balloon(guest):
|
||||
virt_type = guest.virt_type
|
||||
# Memory balloon device only support 'qemu/kvm' and 'xen' hypervisor
|
||||
if (virt_type in ('xen', 'qemu', 'kvm') and
|
||||
CONF.libvirt.mem_stats_period_seconds > 0):
|
||||
CONF.libvirt.mem_stats_period_seconds > 0):
|
||||
balloon = vconfig.LibvirtConfigMemoryBalloon()
|
||||
if virt_type in ('qemu', 'kvm'):
|
||||
balloon.model = 'virtio'
|
||||
|
@ -4827,8 +4834,6 @@ class LibvirtDriver(driver.ComputeDriver):
|
|||
balloon.period = CONF.libvirt.mem_stats_period_seconds
|
||||
guest.add_device(balloon)
|
||||
|
||||
return guest
|
||||
|
||||
@staticmethod
|
||||
def _guest_add_watchdog_action(guest, flavor, image_meta):
|
||||
# image meta takes precedence over flavor extra specs; disable the
|
||||
|
|
Loading…
Reference in New Issue