提交 8f059255 编写于 作者: L Lukáš Doktor

block_copy: Improve block regexp to work with recent qemu

Newer qemu version modified the human protocol to report block devices,
removing the "file=" headers and using the filename as the first thing.
Signed-off-by: NLukáš Doktor <ldoktor@redhat.com>
上级 0da3d743
......@@ -264,9 +264,21 @@ class BlockCopy(object):
blocks = self.vm.monitor.info("block")
try:
if isinstance(blocks, str):
# ide0-hd0: removable=1 locked=0 file=/tmp/test.img
image_regex = '%s.*\s+file=(\S*)' % self.device
image_file = re.findall(image_regex, blocks)
return image_file[0]
if image_file:
return image_file[0]
# ide0-hd0 (#block184): a b c
# or
# ide0-hd0 (#block184): a b c (raw)
image_file = re.findall("%s[^:]+: ([^(]+)\(?" % self.device,
blocks)
if image_file:
if image_file[0][-1] == ' ':
return image_file[0][:-1]
else:
return image_file[0]
for block in blocks:
if block['device'] == self.device:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册