Skip to content

Commit

Permalink
Merge pull request #720 from xiywang/live_commit
Browse files Browse the repository at this point in the history
Add API for block commit
  • Loading branch information
Xu Tian authored Dec 7, 2016
2 parents 49c5dfa + e27b2c8 commit 978247a
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 11 deletions.
8 changes: 8 additions & 0 deletions shared/cfg/guest-os/Linux.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,11 @@
s4_bg_program_kill_cmd = 'pkill ping'
s4_log_chk_cmd = 'dmesg | grep -E "ACPI: Waking up from system sleep state S4"\|"ACPI: PCI interrupt for device .* disabled"'
s4_start_cmd = 'echo disk > /sys/power/state'
with_stress:
stress_test = autotest_control
test_control_file = stress.control
# Use a low stress to make sure guest can response during stress
control_args = "--cpu 4 --io 4 --vm 2 --vm-bytes 256M"
test_timeout = 1800
check_cmd = 'pgrep stress'
stop_cmd = "killall -g stress"
12 changes: 1 addition & 11 deletions shared/cfg/guest-os/Windows.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -295,17 +295,7 @@
post_snapshot_cmd = {monitor:nmi 0}
block_stream, drive_mirror:
tmp_dir = "C:\"
drive_mirror.with_stress.dd:
#if this link not available, please download from http://www.chrysocome.net/downloads/dd-0.5.zip
download_link = "http://www.chrysocome.net/downloads/dd.exe"
pkg_md5sum = 168b73cc0f3d8c92c98c5028aec770df
install_cmd = 'mkdir "C:\Program Files\dd" && copy /b ${tmp_dir}\dd.exe "C:\Program Files\dd\"'
config_cmd = 'setx path "%path%;C:\Program Files\dd" -m'
app_check_cmd = "dd --list"
start_cmd = "del /f /s /q c:\test.img & dd if=/dev/random of=c:\test.img bs=8k count=250000"
stop_cmd = 'taskkill /F /T /IM dd.exe & del /f /s /q "c:\test.img"'
check_cmd = 'tasklist | findstr /I "dd.exe"'
drive_mirror.with_stress.heavyload, drive_mirror.with_powerdown, block_stream.with_stress:
drive_mirror.with_powerdown:
download_link = "http://www.jam-software.com/heavyload/HeavyLoadSetup.exe"
pkg_md5sum = 5bf187bd914ac8ce7f79361d7b56bc15
install_cmd = 'start /wait ${tmp_dir}\HeavyLoadSetup.exe /verysilent'
Expand Down
52 changes: 52 additions & 0 deletions virttest/qemu_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -907,6 +907,32 @@ def block_stream(self, device, speed=None, base=None,
cmd += " %s" % base
return self.cmd(cmd)

def block_commit(self, device, speed=None, base=None, top=None,
cmd="block_commit", correct=True):
"""
Start block-commit job
:param device: device ID
:param speed: int type, limited speed(B/s)
:param base: base file
:param top: top file
:param cmd: block commit job command
:param correct: auto correct command, correct by default
:return: The command's output
"""
if correct:
cmd = self.correct(cmd)
self.verify_supported_cmd(cmd)
cmd += " %s" % device
if speed:
cmd += " %sB" % speed
if base:
cmd += " %s" % base
if top:
cmd += " %s" % top
return self.cmd(cmd)

def set_block_job_speed(self, device, speed=0,
cmd="block_job_set_speed", correct=True):
"""
Expand Down Expand Up @@ -2005,6 +2031,32 @@ def block_stream(self, device, speed=None, base=None,
args["base"] = base
return self.cmd(cmd, args)

def block_commit(self, device, speed=None, base=None, top=None,
cmd="block-commit", correct=True):
"""
Start block-commit job
:param device: device ID
:param speed: int type, limited speed(B/s)
:param base: base file
:param top: top file
:param cmd: block commit job command
:param correct: auto correct command, correct by default
:return: The command's output
"""
if correct:
cmd = self.correct(cmd)
self.verify_supported_cmd(cmd)
args = {"device": device}
if speed:
args["speed"] = speed
if base:
args["base"] = base
if top:
args["top"] = top
return self.cmd(cmd, args)

def set_block_job_speed(self, device, speed=0,
cmd="block-job-set-speed", correct=True):
"""
Expand Down
14 changes: 14 additions & 0 deletions virttest/qemu_vm.py
Original file line number Diff line number Diff line change
Expand Up @@ -4294,6 +4294,20 @@ def block_stream(self, device, speed, base=None, correct=True):
return self.monitor.block_stream(device, speed, base,
cmd, correct=correct)

def block_commit(self, device, speed, base=None, top=None, correct=True):
"""
start to commit block device, aka merge snapshot
:param device: device ID
:param speed: limited speed, default unit B/s
:param base: base file
:param top: top file
:param correct: auto correct cmd, correct by default
"""
cmd = self.params.get("block_commit_cmd", "block-commit")
return self.monitor.block_commit(device, speed, base, top,
cmd, correct=correct)

def block_mirror(self, device, target, sync,
correct=True, **kwargs):
"""
Expand Down

0 comments on commit 978247a

Please sign in to comment.