未验证 提交 1a8591b1 编写于 作者: Y YongxueHong 提交者: GitHub

Merge pull request #2223 from aliang123/1831968

blockdev_snapshot_install:snapshot during guest installation
import time
import logging
import random
from virttest import utils_test
from virttest import utils_misc
from virttest.tests import unattended_install
from provider.blockdev_snapshot_base import BlockDevSnapshotTest
def run(test, params, env):
"""
Backup VM disk test when VM reboot
1) Install guest
2) Do snapshot during guest
3) Rebase snapshot to base after installation finished
4) Start guest with snapshot
:param test: test object
:param params: Dictionary with the test parameters
:param env: Dictionary with test environment.
"""
def tag_for_install(vm, tag):
if vm.serial_console:
serial_output = vm.serial_console.get_output()
if tag in serial_output:
return True
logging.info("VM has not started yet")
return False
base_image = params.get("images", "image1").split()[0]
params.update(
{"image_format_%s" % base_image: params["image_format"]})
snapshot_test = BlockDevSnapshotTest(test, params, env)
args = (test, params, env)
bg = utils_test.BackgroundTest(unattended_install.run, args)
bg.start()
if bg.is_alive():
tag = params["tag_for_install_start"]
if utils_misc.wait_for(lambda: tag_for_install(snapshot_test.main_vm, tag), 120, 10, 5):
logging.info("sleep random time before do snapshots")
time.sleep(random.randint(120, 600))
snapshot_test.pre_test()
try:
snapshot_test.create_snapshot()
try:
bg.join(timeout=1200)
except Exception:
raise
snapshot_test.verify_snapshot()
snapshot_test.clone_vm.wait_for_login()
finally:
snapshot_test.post_test()
else:
test.fail("Failed to install guest")
else:
test.fail("Background process:installation not started")
- blockdev_snapshot_install:
type = blockdev_snapshot_install
virt_test_type = qemu
need_install = yes
start_vm = no
image_name_image1 = "images/snapshot_install"
medium = cdrom
installation = cdrom
kernel = vmlinuz
initrd = initrd.img
force_create_image_image1 = yes
image_aio = threads
unattended_delivery_method = cdrom
cdroms += " unattended"
index_enable = no
kill_vm = yes
tag_for_install_start = "Starting Login Service"
storage_type_default = "directory"
storage_pool = default
snapshot_tag = sn1
image_format_sn1 = qcow2
image_name_sn1 = images/sn1
device = "drive_image1"
base_tag = "image1"
rebase_mode = unsafe
only Linux
node = "drive_image1"
overlay = "drive_sn1"
qemu_force_use_drive_expression = no
no RHEL.5 RHEL.6 RHEL.7 RHEL.8.0 RHEL8.1
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册