Skip to content

Commit

Permalink
Update the logging namespace - qemu (c)
Browse files Browse the repository at this point in the history
Issue: autotest#3048

Signed-off-by: Xu Han <[email protected]>
  • Loading branch information
luckyh committed Feb 23, 2022
1 parent b2c9322 commit 719a465
Show file tree
Hide file tree
Showing 42 changed files with 597 additions and 645 deletions.
8 changes: 3 additions & 5 deletions qemu/tests/cache_sizes_test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import logging

from provider import qemu_img_utils as img_utils


Expand All @@ -19,16 +17,16 @@ def run(test, params, env):
initial_tag = params["images"]
cache_sizes = params["cache_sizes"].split()

logging.info("Boot a guest up from initial image: %s, and create a"
" file %s on the disk.", initial_tag, file)
test.log.info("Boot a guest up from initial image: %s, and create a"
" file %s on the disk.", initial_tag, file)
for cache_size in cache_sizes:
params["drv_extra_params_image1"] = "cache-size=%s" % cache_size
vm = img_utils.boot_vm_with_images(test, params, env)
session = vm.wait_for_login()
guest_temp_file = params["guest_file_name"]
sync_bin = params.get("sync_bin", "sync")

logging.debug("Create temporary file on guest: %s", guest_temp_file)
test.log.debug("Create temporary file on guest: %s", guest_temp_file)
img_utils.save_random_file_to_vm(vm, guest_temp_file, 2048 * 512,
sync_bin)

Expand Down
95 changes: 47 additions & 48 deletions qemu/tests/cdrom.py

Large diffs are not rendered by default.

21 changes: 10 additions & 11 deletions qemu/tests/cdrom_block_size_check.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import re
import logging
import os
import six
import time
Expand Down Expand Up @@ -96,7 +95,7 @@ def create_iso_image(params, name, prepare=True, file_size=None):
:return: path to new iso image file.
"""
error_context.context("Creating test iso image '%s'" % name,
logging.info)
test.log.info)
if not os.path.isabs(name):
cdrom_path = utils_misc.get_path(data_dir.get_data_dir(), name)
else:
Expand All @@ -116,7 +115,7 @@ def create_iso_image(params, name, prepare=True, file_size=None):
return cdrom_path

def check_cdrom_size(session):
error_context.context("Get the cdrom's size in guest.", logging.info)
error_context.context("Get the cdrom's size in guest.", test.log.info)
check_cdrom_size_cmd = params["check_cdrom_size_cmd"]
output = session.cmd(check_cdrom_size_cmd, timeout=60)
if not output:
Expand All @@ -128,13 +127,13 @@ def check_cdrom_size(session):
cdrom_size = int(size)
except ValueError:
cdrom_size = 0
logging.info("Cdrom's size in guest %s", cdrom_size)
test.log.info("Cdrom's size in guest %s", cdrom_size)
return cdrom_size

def mount_cdrom(session, guest_cdrom, mount_point,
show_mount_cmd, mount_cmd):
txt = "Mount the cdrom in guest and check its block size."
error_context.context(txt, logging.info)
error_context.context(txt, test.log.info)
mounted = session.cmd(show_mount_cmd)
if mount_point not in mounted:
mount_cmd = params.get("mount_cdrom_cmd") % (guest_cdrom,
Expand All @@ -161,7 +160,7 @@ def change_media(device, target):
except QMPCmdError as e:
if excepted_qmp_err not in str(e):
test.error(str(e))
logging.warn(str(e))
test.log.warn(str(e))
wait_for_tray_open(cdroms)
with change_check:
vm.change_media(device, target)
Expand All @@ -181,7 +180,7 @@ def eject_cdrom(device):
excepted_qmp_err = params.get('excepted_qmp_err')
sleep_time_after_change = params.get_numeric('sleep_time_after_change', 30)
os_type = params["os_type"]
error_context.context("Get the main VM", logging.info)
error_context.context("Get the main VM", test.log.info)
main_vm = params["main_vm"]
env_process.preprocess_vm(test, params, env, main_vm)
vm = env.get_vm(params["main_vm"])
Expand All @@ -203,7 +202,7 @@ def eject_cdrom(device):
change_check = QMPEventCheckCDChange(vm, cdrom_device)

error_context.context("Attach a small cd iso file to the cdrom.",
logging.info)
test.log.info)
change_media(cdrom_device, orig_cdrom)
if mount_cmd:
mount_cdrom(session, guest_cdrom, mount_point,
Expand All @@ -215,23 +214,23 @@ def eject_cdrom(device):
test.fail(err)

if umount_cmd:
error_context.context("umount cdrom in guest.", logging.info)
error_context.context("umount cdrom in guest.", test.log.info)
umount_cmd = umount_cmd % mount_point
status, output = session.cmd_status_output(umount_cmd, timeout=360)
if status:
msg = "Unable to umount cdrom. command: %s\n" % umount_cmd
msg += "Output: %s" % output
test.error(msg)

error_context.context("eject the cdrom from monitor.", logging.info)
error_context.context("eject the cdrom from monitor.", test.log.info)
eject_cdrom(cdrom_device)

cdrom_name = params.get("final_cdrom", "images/final.iso")
file_size = params.get("final_cdrom_size", 1000)
final_cdrom = create_iso_image(params, cdrom_name, prepare=True,
file_size=file_size)
error_context.context("Attach a bigger cd iso file to the cdrom.",
logging.info)
test.log.info)
change_media(cdrom_device, final_cdrom)
if mount_cmd:
mount_cdrom(session, guest_cdrom, mount_point,
Expand Down
Loading

0 comments on commit 719a465

Please sign in to comment.