* [KVM-AUTOTEST PATCH] KVM test: formatting improvements to scan_results.py
@ 2010-05-17 13:29 Michael Goldish
2010-05-17 13:29 ` [KVM-AUTOTEST PATCH] KVM test: make use of tcpdump optional Michael Goldish
0 siblings, 1 reply; 7+ messages in thread
From: Michael Goldish @ 2010-05-17 13:29 UTC (permalink / raw)
To: autotest, kvm; +Cc: Michael Goldish
Print results clearly even if test names are very long.
Also, for consistency, use the same quote character everywhere.
Signed-off-by: Michael Goldish <mgoldish@redhat.com>
---
client/tests/kvm/scan_results.py | 49 ++++++++++++++++++++++---------------
1 files changed, 29 insertions(+), 20 deletions(-)
diff --git a/client/tests/kvm/scan_results.py b/client/tests/kvm/scan_results.py
index f7bafa9..f7073e4 100755
--- a/client/tests/kvm/scan_results.py
+++ b/client/tests/kvm/scan_results.py
@@ -24,19 +24,19 @@ def parse_results(text):
# Found a START line -- get start time
if (line.startswith("START") and len(parts) >= 5 and
parts[3].startswith("timestamp")):
- start_time = float(parts[3].split('=')[1])
+ start_time = float(parts[3].split("=")[1])
start_time_list.append(start_time)
info_list.append("")
# Found an END line -- get end time, name and status
elif (line.startswith("END") and len(parts) >= 5 and
parts[3].startswith("timestamp")):
- end_time = float(parts[3].split('=')[1])
+ end_time = float(parts[3].split("=")[1])
start_time = start_time_list.pop()
info = info_list.pop()
test_name = parts[2]
test_status = parts[0].split()[1]
- # Remove 'kvm.' prefix
+ # Remove "kvm." prefix
if test_name.startswith("kvm."):
test_name = test_name.split("kvm.")[1]
result_list.append((test_name, test_status,
@@ -50,39 +50,48 @@ def parse_results(text):
return result_list
-def print_result(result):
- """Nicely print a single Autotest result.
+def print_result(result, name_width):
+ """
+ Nicely print a single Autotest result.
- result -- a 4-tuple
+ @param result: a 4-tuple
+ @param name_width: test name maximum width
"""
if result:
- print '%-48s\t\t%s\t%s\t%s' % tuple(map(str, result))
+ format = "%%-%ds %%-10s %%-8s %%s" % name_width
+ print format % result
def main(resfiles):
- print_result(('Test', 'Status', 'Seconds', 'Info'))
- print_result(('----', '------', '-------', '----'))
+ result_lists = []
+ name_width = 40
for resfile in resfiles:
- print ' (Result file: %s)' % resfile
try:
- f = file(resfile)
- text = f.read()
- f.close()
+ text = open(resfile).read()
except IOError:
- print 'Bad result file: %s' % resfile
- return
+ print "Bad result file: %s" % resfile
+ continue
results = parse_results(text)
- map(print_result, results)
+ result_lists.append((resfile, results))
+ name_width = max(name_width, max(len(r[0]) for r in results))
+
+ print_result(("Test", "Status", "Seconds", "Info"), name_width)
+ print_result(("----", "------", "-------", "----"), name_width)
+
+ for resfile, results in result_lists:
+ print " (Result file: %s)" % resfile
+ for r in results:
+ print_result(r, name_width)
-if __name__ == '__main__':
+if __name__ == "__main__":
import sys, os, glob
- resfiles = glob.glob('../../results/default/status*')
+ resfiles = glob.glob("../../results/default/status*")
if len(sys.argv) > 1:
- if sys.argv[1] == '-h' or sys.argv[1] == '--help':
- print 'Usage: %s [result files]' % sys.argv[0]
+ if sys.argv[1] == "-h" or sys.argv[1] == "--help":
+ print "Usage: %s [result files]" % sys.argv[0]
sys.exit(0)
resfiles = sys.argv[1:]
main(resfiles)
--
1.5.4.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [KVM-AUTOTEST PATCH] KVM test: make use of tcpdump optional
2010-05-17 13:29 [KVM-AUTOTEST PATCH] KVM test: formatting improvements to scan_results.py Michael Goldish
@ 2010-05-17 13:29 ` Michael Goldish
2010-05-17 13:29 ` [KVM-AUTOTEST PATCH] KVM test: use command line option wrapper functions Michael Goldish
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Michael Goldish @ 2010-05-17 13:29 UTC (permalink / raw)
To: autotest, kvm
To disable tcpdump, set 'run_tcpdump = no' in a config file.
If 'run_tcpdump' isn't set at all, it defaults to 'yes'.
(Currently TAP mode cannot be used without tcpdump.)
Signed-off-by: Michael Goldish <mgoldish@redhat.com>
---
client/tests/kvm/kvm_preprocessing.py | 2 +-
client/tests/kvm/tests_base.cfg.sample | 1 +
2 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/client/tests/kvm/kvm_preprocessing.py b/client/tests/kvm/kvm_preprocessing.py
index 50db65c..e11207a 100644
--- a/client/tests/kvm/kvm_preprocessing.py
+++ b/client/tests/kvm/kvm_preprocessing.py
@@ -196,7 +196,7 @@ def preprocess(test, params, env):
if "tcpdump" in env and not env["tcpdump"].is_alive():
env["tcpdump"].close()
del env["tcpdump"]
- if "tcpdump" not in env:
+ if "tcpdump" not in env and params.get("run_tcpdump", "yes") == "yes":
command = "/usr/sbin/tcpdump -npvi any 'dst port 68'"
logging.debug("Starting tcpdump (%s)...", command)
env["tcpdump"] = kvm_subprocess.kvm_tail(
diff --git a/client/tests/kvm/tests_base.cfg.sample b/client/tests/kvm/tests_base.cfg.sample
index c9dfd0b..1276267 100644
--- a/client/tests/kvm/tests_base.cfg.sample
+++ b/client/tests/kvm/tests_base.cfg.sample
@@ -46,6 +46,7 @@ nic_mode = user
#nic_mode = tap
nic_script = scripts/qemu-ifup
address_index = 0
+run_tcpdump = yes
# Misc
run_kvm_stat = yes
--
1.5.4.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [KVM-AUTOTEST PATCH] KVM test: use command line option wrapper functions
2010-05-17 13:29 ` [KVM-AUTOTEST PATCH] KVM test: make use of tcpdump optional Michael Goldish
@ 2010-05-17 13:29 ` Michael Goldish
2010-05-26 13:49 ` [Autotest] " Lucas Meneghel Rodrigues
2010-05-17 13:35 ` [KVM-AUTOTEST PATCH] KVM test: make use of tcpdump optional Lucas Meneghel Rodrigues
2010-05-25 23:47 ` Lucas Meneghel Rodrigues
2 siblings, 1 reply; 7+ messages in thread
From: Michael Goldish @ 2010-05-17 13:29 UTC (permalink / raw)
To: autotest, kvm; +Cc: Michael Goldish
In order to support multiple versions of qemu which use different command line
options or syntaxes, wrap all command line options in small helper functions,
which append text to the command line according to the output of 'qemu -help'.
Signed-off-by: Michael Goldish <mgoldish@redhat.com>
---
client/tests/kvm/kvm_vm.py | 198 ++++++++++++++++++++++++++++++--------------
1 files changed, 135 insertions(+), 63 deletions(-)
diff --git a/client/tests/kvm/kvm_vm.py b/client/tests/kvm/kvm_vm.py
index 047505a..94bacdf 100755
--- a/client/tests/kvm/kvm_vm.py
+++ b/client/tests/kvm/kvm_vm.py
@@ -186,12 +186,100 @@ class VM:
nic_model -- string to pass as 'model' parameter for this
NIC (e.g. e1000)
"""
- if name is None:
- name = self.name
- if params is None:
- params = self.params
- if root_dir is None:
- root_dir = self.root_dir
+ # Helper function for command line option wrappers
+ def has_option(help, option):
+ return bool(re.search(r"^-%s(\s|$)" % option, help, re.MULTILINE))
+
+ # Wrappers for all supported qemu command line parameters.
+ # This is meant to allow support for multiple qemu versions.
+ # Each of these functions receives the output of 'qemu -help' as a
+ # parameter, and should add the requested command line option
+ # accordingly.
+
+ def add_name(help, name):
+ return " -name '%s'" % name
+
+ def add_unix_socket_monitor(help, filename):
+ return " -monitor unix:%s,server,nowait" % filename
+
+ def add_mem(help, mem):
+ return " -m %s" % mem
+
+ def add_smp(help, smp):
+ return " -smp %s" % smp
+
+ def add_cdrom(help, filename, index=2):
+ if has_option(help, "drive"):
+ return " -drive file=%s,index=%d,media=cdrom" % (filename,
+ index)
+ else:
+ return " -cdrom %s" % filename
+
+ def add_drive(help, filename, format=None, cache=None, werror=None,
+ serial=None, snapshot=False, boot=False):
+ cmd = " -drive file=%s" % filename
+ if format: cmd += ",if=%s" % format
+ if cache: cmd += ",cache=%s" % cache
+ if werror: cmd += ",werror=%s" % werror
+ if serial: cmd += ",serial=%s" % serial
+ if snapshot: cmd += ",snapshot=on"
+ if boot: cmd += ",boot=on"
+ return cmd
+
+ def add_nic(help, vlan, model=None, mac=None):
+ cmd = " -net nic,vlan=%d" % vlan
+ if model: cmd += ",model=%s" % model
+ if mac: cmd += ",macaddr=%s" % mac
+ return cmd
+
+ def add_net(help, vlan, mode, ifname=None, script=None,
+ downscript=None):
+ cmd = " -net %s,vlan=%d" % (mode, vlan)
+ if mode == "tap":
+ if ifname: cmd += ",ifname=%s" % ifname
+ if script: cmd += ",script=%s" % script
+ cmd += ",downscript=%s" % (downscript or "no")
+ return cmd
+
+ def add_floppy(help, filename):
+ return " -fda %s" % filename
+
+ def add_tftp(help, filename):
+ return " -tftp %s" % filename
+
+ def add_tcp_redir(help, host_port, guest_port):
+ return " -redir tcp:%s::%s" % (host_port, guest_port)
+
+ def add_vnc(help, vnc_port):
+ return " -vnc :%d" % (vnc_port - 5900)
+
+ def add_sdl(help):
+ if has_option(help, "sdl"):
+ return " -sdl"
+ else:
+ return ""
+
+ def add_nographic(help):
+ return " -nographic"
+
+ def add_uuid(help, uuid):
+ return " -uuid %s" % uuid
+
+ def add_pcidevice(help, host):
+ return " -pcidevice host=%s" % host
+
+ # End of command line option wrappers
+
+ if name is None: name = self.name
+ if params is None: params = self.params
+ if root_dir is None: root_dir = self.root_dir
+
+ qemu_binary = kvm_utils.get_path(root_dir, params.get("qemu_binary",
+ "qemu"))
+ # Get the output of 'qemu -help' (log a message in case this call never
+ # returns or causes some other kind of trouble)
+ logging.debug("Getting output of 'qemu -help'")
+ help = commands.getoutput("%s -help" % qemu_binary)
# Start constructing the qemu command
qemu_cmd = ""
@@ -199,65 +287,49 @@ class VM:
if params.get("x11_display"):
qemu_cmd += "DISPLAY=%s " % params.get("x11_display")
# Add the qemu binary
- qemu_cmd += kvm_utils.get_path(root_dir, params.get("qemu_binary",
- "qemu"))
+ qemu_cmd += qemu_binary
# Add the VM's name
- qemu_cmd += " -name '%s'" % name
+ qemu_cmd += add_name(help, name)
# Add the monitor socket parameter
- qemu_cmd += " -monitor unix:%s,server,nowait" % self.monitor_file_name
+ qemu_cmd += add_unix_socket_monitor(help, self.monitor_file_name)
for image_name in kvm_utils.get_sub_dict_names(params, "images"):
image_params = kvm_utils.get_sub_dict(params, image_name)
if image_params.get("boot_drive") == "no":
continue
- qemu_cmd += " -drive file=%s" % get_image_filename(image_params,
- root_dir)
- if image_params.get("drive_format"):
- qemu_cmd += ",if=%s" % image_params.get("drive_format")
- if image_params.get("drive_cache"):
- qemu_cmd += ",cache=%s" % image_params.get("drive_cache")
- if image_params.get("drive_werror"):
- qemu_cmd += ",werror=%s" % image_params.get("drive_werror")
- if image_params.get("drive_serial"):
- qemu_cmd += ",serial=%s" % image_params.get("drive_serial")
- if image_params.get("image_snapshot") == "yes":
- qemu_cmd += ",snapshot=on"
- if image_params.get("image_boot") == "yes":
- qemu_cmd += ",boot=on"
+ qemu_cmd += add_drive(help,
+ get_image_filename(image_params, root_dir),
+ image_params.get("drive_format"),
+ image_params.get("drive_cache"),
+ image_params.get("drive_werror"),
+ image_params.get("drive_serial"),
+ image_params.get("image_snapshot") == "yes",
+ image_params.get("image_boot") == "yes")
vlan = 0
for nic_name in kvm_utils.get_sub_dict_names(params, "nics"):
nic_params = kvm_utils.get_sub_dict(params, nic_name)
# Handle the '-net nic' part
- qemu_cmd += " -net nic,vlan=%d" % vlan
- if nic_params.get("nic_model"):
- qemu_cmd += ",model=%s" % nic_params.get("nic_model")
- if nic_params.has_key("address_index"):
- mac, ip = kvm_utils.get_mac_ip_pair_from_dict(nic_params)
- if mac:
- qemu_cmd += ",macaddr=%s" % mac
+ mac = None
+ if "address_index" in nic_params:
+ mac = kvm_utils.get_mac_ip_pair_from_dict(nic_params)[0]
+ qemu_cmd += add_nic(help, vlan, nic_params.get("nic_model"), mac)
# Handle the '-net tap' or '-net user' part
- mode = nic_params.get("nic_mode", "user")
- qemu_cmd += " -net %s,vlan=%d" % (mode, vlan)
- if mode == "tap":
- if nic_params.get("nic_ifname"):
- qemu_cmd += ",ifname=%s" % nic_params.get("nic_ifname")
- script_path = nic_params.get("nic_script")
- if script_path:
- script_path = kvm_utils.get_path(root_dir, script_path)
- qemu_cmd += ",script=%s" % script_path
- script_path = nic_params.get("nic_downscript")
- if script_path:
- script_path = kvm_utils.get_path(root_dir, script_path)
- qemu_cmd += ",downscript=%s" % script_path
- else:
- qemu_cmd += ",downscript=no"
+ script = nic_params.get("script")
+ downscript = nic_params.get("downscript")
+ if script:
+ script = kvm_utils.get_path(root_dir, script)
+ if downscript:
+ downscript = kvm_utils.get_path(root_dir, downscript)
+ qemu_cmd += add_net(help, vlan, nic_params.get("nic_mode", "user"),
+ nic_params.get("nic_ifname"),
+ script, downscript)
# Proceed to next NIC
vlan += 1
mem = params.get("mem")
if mem:
- qemu_cmd += " -m %s" % mem
+ qemu_cmd += add_mem(help, mem)
smp = params.get("smp")
if smp:
@@ -266,7 +338,7 @@ class VM:
iso = params.get("cdrom")
if iso:
iso = kvm_utils.get_path(root_dir, iso)
- qemu_cmd += " -drive file=%s,index=2,media=cdrom" % iso
+ qemu_cmd += add_cdrom(help, iso)
# Even though this is not a really scalable approach,
# it doesn't seem like we are going to need more than
@@ -274,47 +346,47 @@ class VM:
iso_extra = params.get("cdrom_extra")
if iso_extra:
iso_extra = kvm_utils.get_path(root_dir, iso_extra)
- qemu_cmd += " -drive file=%s,index=3,media=cdrom" % iso_extra
+ qemu_cmd += add_cdrom(help, iso_extra, 3)
# We may want to add {floppy_otps} parameter for -fda
- # {fat:floppy:}/path/. However vvfat is not usually recommended
+ # {fat:floppy:}/path/. However vvfat is not usually recommended.
floppy = params.get("floppy")
if floppy:
floppy = kvm_utils.get_path(root_dir, floppy)
- qemu_cmd += " -fda %s" % floppy
+ qemu_cmd += add_floppy(help, floppy)
tftp = params.get("tftp")
if tftp:
tftp = kvm_utils.get_path(root_dir, tftp)
- qemu_cmd += " -tftp %s" % tftp
-
- extra_params = params.get("extra_params")
- if extra_params:
- qemu_cmd += " %s" % extra_params
+ qemu_cmd += add_tftp(help, tftp)
for redir_name in kvm_utils.get_sub_dict_names(params, "redirs"):
redir_params = kvm_utils.get_sub_dict(params, redir_name)
guest_port = int(redir_params.get("guest_port"))
host_port = self.redirs.get(guest_port)
- qemu_cmd += " -redir tcp:%s::%s" % (host_port, guest_port)
+ qemu_cmd += add_tcp_redir(help, host_port, guest_port)
if params.get("display") == "vnc":
- qemu_cmd += " -vnc :%d" % (self.vnc_port - 5900)
+ qemu_cmd += add_vnc(help, self.vnc_port)
elif params.get("display") == "sdl":
- qemu_cmd += " -sdl"
+ qemu_cmd += add_sdl(help)
elif params.get("display") == "nographic":
- qemu_cmd += " -nographic"
+ qemu_cmd += add_nographic(help)
if params.get("uuid") == "random":
- qemu_cmd += " -uuid %s" % self.uuid
+ qemu_cmd += add_uuid(help, self.uuid)
elif params.get("uuid"):
- qemu_cmd += " -uuid %s" % params.get("uuid")
+ qemu_cmd += add_uuid(help, params.get("uuid"))
# If the PCI assignment step went OK, add each one of the PCI assigned
# devices to the qemu command line.
if self.pci_assignable:
for pci_id in self.pa_pci_ids:
- qemu_cmd += " -pcidevice host=%s" % pci_id
+ qemu_cmd += add_pcidevice(help, pci_id)
+
+ extra_params = params.get("extra_params")
+ if extra_params:
+ qemu_cmd += " %s" % extra_params
return qemu_cmd
--
1.5.4.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [KVM-AUTOTEST PATCH] KVM test: make use of tcpdump optional
2010-05-17 13:29 ` [KVM-AUTOTEST PATCH] KVM test: make use of tcpdump optional Michael Goldish
2010-05-17 13:29 ` [KVM-AUTOTEST PATCH] KVM test: use command line option wrapper functions Michael Goldish
@ 2010-05-17 13:35 ` Lucas Meneghel Rodrigues
2010-05-17 14:32 ` [Autotest] " Michael Goldish
2010-05-25 23:47 ` Lucas Meneghel Rodrigues
2 siblings, 1 reply; 7+ messages in thread
From: Lucas Meneghel Rodrigues @ 2010-05-17 13:35 UTC (permalink / raw)
To: Michael Goldish; +Cc: autotest, kvm
On Mon, 2010-05-17 at 16:29 +0300, Michael Goldish wrote:
> To disable tcpdump, set 'run_tcpdump = no' in a config file.
> If 'run_tcpdump' isn't set at all, it defaults to 'yes'.
>
> (Currently TAP mode cannot be used without tcpdump.)
Maybe we can just tie tcpdump execution to tap mode - if running on tap
mode, enable tcpdump, else, disable it. I'd rather prefer this
approach.
> Signed-off-by: Michael Goldish <mgoldish@redhat.com>
> ---
> client/tests/kvm/kvm_preprocessing.py | 2 +-
> client/tests/kvm/tests_base.cfg.sample | 1 +
> 2 files changed, 2 insertions(+), 1 deletions(-)
>
> diff --git a/client/tests/kvm/kvm_preprocessing.py b/client/tests/kvm/kvm_preprocessing.py
> index 50db65c..e11207a 100644
> --- a/client/tests/kvm/kvm_preprocessing.py
> +++ b/client/tests/kvm/kvm_preprocessing.py
> @@ -196,7 +196,7 @@ def preprocess(test, params, env):
> if "tcpdump" in env and not env["tcpdump"].is_alive():
> env["tcpdump"].close()
> del env["tcpdump"]
> - if "tcpdump" not in env:
> + if "tcpdump" not in env and params.get("run_tcpdump", "yes") == "yes":
> command = "/usr/sbin/tcpdump -npvi any 'dst port 68'"
> logging.debug("Starting tcpdump (%s)...", command)
> env["tcpdump"] = kvm_subprocess.kvm_tail(
> diff --git a/client/tests/kvm/tests_base.cfg.sample b/client/tests/kvm/tests_base.cfg.sample
> index c9dfd0b..1276267 100644
> --- a/client/tests/kvm/tests_base.cfg.sample
> +++ b/client/tests/kvm/tests_base.cfg.sample
> @@ -46,6 +46,7 @@ nic_mode = user
> #nic_mode = tap
> nic_script = scripts/qemu-ifup
> address_index = 0
> +run_tcpdump = yes
>
> # Misc
> run_kvm_stat = yes
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Autotest] [KVM-AUTOTEST PATCH] KVM test: make use of tcpdump optional
2010-05-17 13:35 ` [KVM-AUTOTEST PATCH] KVM test: make use of tcpdump optional Lucas Meneghel Rodrigues
@ 2010-05-17 14:32 ` Michael Goldish
0 siblings, 0 replies; 7+ messages in thread
From: Michael Goldish @ 2010-05-17 14:32 UTC (permalink / raw)
To: Lucas Meneghel Rodrigues; +Cc: autotest, kvm
On 05/17/2010 04:35 PM, Lucas Meneghel Rodrigues wrote:
> On Mon, 2010-05-17 at 16:29 +0300, Michael Goldish wrote:
>> To disable tcpdump, set 'run_tcpdump = no' in a config file.
>> If 'run_tcpdump' isn't set at all, it defaults to 'yes'.
>>
>> (Currently TAP mode cannot be used without tcpdump.)
>
> Maybe we can just tie tcpdump execution to tap mode - if running on tap
> mode, enable tcpdump, else, disable it. I'd rather prefer this
> approach.
Checking for nic_mode == 'tap' is incorrect IMO, because nic_mode is a
VM parameter, not a global parameter.
There can be several VMs, some with nic_mode == 'user' and some with
nic_mode == 'tap', e.g.
nic_mode = user # default value for all VMs
nic_mode_vm2 = tap # specific to vm2 (overrides nic_mode)
so if we went by nic_mode, we wouldn't run tcpdump, which is required by
vm2.
Also, a test is free to start its own VMs. Consider this (somewhat
unlikely) scenario: nic_mode=user, so vm1 uses user mode, and the test
clones it, changes the clone's mode to tap, and starts the clone. If we
went by nic_mode, we wouldn't start tcpdump even though the clone needs it.
>> Signed-off-by: Michael Goldish <mgoldish@redhat.com>
>> ---
>> client/tests/kvm/kvm_preprocessing.py | 2 +-
>> client/tests/kvm/tests_base.cfg.sample | 1 +
>> 2 files changed, 2 insertions(+), 1 deletions(-)
>>
>> diff --git a/client/tests/kvm/kvm_preprocessing.py b/client/tests/kvm/kvm_preprocessing.py
>> index 50db65c..e11207a 100644
>> --- a/client/tests/kvm/kvm_preprocessing.py
>> +++ b/client/tests/kvm/kvm_preprocessing.py
>> @@ -196,7 +196,7 @@ def preprocess(test, params, env):
>> if "tcpdump" in env and not env["tcpdump"].is_alive():
>> env["tcpdump"].close()
>> del env["tcpdump"]
>> - if "tcpdump" not in env:
>> + if "tcpdump" not in env and params.get("run_tcpdump", "yes") == "yes":
>> command = "/usr/sbin/tcpdump -npvi any 'dst port 68'"
>> logging.debug("Starting tcpdump (%s)...", command)
>> env["tcpdump"] = kvm_subprocess.kvm_tail(
>> diff --git a/client/tests/kvm/tests_base.cfg.sample b/client/tests/kvm/tests_base.cfg.sample
>> index c9dfd0b..1276267 100644
>> --- a/client/tests/kvm/tests_base.cfg.sample
>> +++ b/client/tests/kvm/tests_base.cfg.sample
>> @@ -46,6 +46,7 @@ nic_mode = user
>> #nic_mode = tap
>> nic_script = scripts/qemu-ifup
>> address_index = 0
>> +run_tcpdump = yes
>>
>> # Misc
>> run_kvm_stat = yes
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Autotest] [KVM-AUTOTEST PATCH] KVM test: make use of tcpdump optional
2010-05-17 13:29 ` [KVM-AUTOTEST PATCH] KVM test: make use of tcpdump optional Michael Goldish
2010-05-17 13:29 ` [KVM-AUTOTEST PATCH] KVM test: use command line option wrapper functions Michael Goldish
2010-05-17 13:35 ` [KVM-AUTOTEST PATCH] KVM test: make use of tcpdump optional Lucas Meneghel Rodrigues
@ 2010-05-25 23:47 ` Lucas Meneghel Rodrigues
2 siblings, 0 replies; 7+ messages in thread
From: Lucas Meneghel Rodrigues @ 2010-05-25 23:47 UTC (permalink / raw)
To: Michael Goldish; +Cc: autotest, kvm, ryanh
On Mon, 2010-05-17 at 16:29 +0300, Michael Goldish wrote:
> To disable tcpdump, set 'run_tcpdump = no' in a config file.
> If 'run_tcpdump' isn't set at all, it defaults to 'yes'.
>
> (Currently TAP mode cannot be used without tcpdump.)
Ok, I agree with your reasoning, commited as:
http://autotest.kernel.org/changeset/4562
Copying Ryan.
> Signed-off-by: Michael Goldish <mgoldish@redhat.com>
> ---
> client/tests/kvm/kvm_preprocessing.py | 2 +-
> client/tests/kvm/tests_base.cfg.sample | 1 +
> 2 files changed, 2 insertions(+), 1 deletions(-)
>
> diff --git a/client/tests/kvm/kvm_preprocessing.py b/client/tests/kvm/kvm_preprocessing.py
> index 50db65c..e11207a 100644
> --- a/client/tests/kvm/kvm_preprocessing.py
> +++ b/client/tests/kvm/kvm_preprocessing.py
> @@ -196,7 +196,7 @@ def preprocess(test, params, env):
> if "tcpdump" in env and not env["tcpdump"].is_alive():
> env["tcpdump"].close()
> del env["tcpdump"]
> - if "tcpdump" not in env:
> + if "tcpdump" not in env and params.get("run_tcpdump", "yes") == "yes":
> command = "/usr/sbin/tcpdump -npvi any 'dst port 68'"
> logging.debug("Starting tcpdump (%s)...", command)
> env["tcpdump"] = kvm_subprocess.kvm_tail(
> diff --git a/client/tests/kvm/tests_base.cfg.sample b/client/tests/kvm/tests_base.cfg.sample
> index c9dfd0b..1276267 100644
> --- a/client/tests/kvm/tests_base.cfg.sample
> +++ b/client/tests/kvm/tests_base.cfg.sample
> @@ -46,6 +46,7 @@ nic_mode = user
> #nic_mode = tap
> nic_script = scripts/qemu-ifup
> address_index = 0
> +run_tcpdump = yes
>
> # Misc
> run_kvm_stat = yes
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Autotest] [KVM-AUTOTEST PATCH] KVM test: use command line option wrapper functions
2010-05-17 13:29 ` [KVM-AUTOTEST PATCH] KVM test: use command line option wrapper functions Michael Goldish
@ 2010-05-26 13:49 ` Lucas Meneghel Rodrigues
0 siblings, 0 replies; 7+ messages in thread
From: Lucas Meneghel Rodrigues @ 2010-05-26 13:49 UTC (permalink / raw)
To: Michael Goldish; +Cc: autotest, kvm
On Mon, 2010-05-17 at 16:29 +0300, Michael Goldish wrote:
> In order to support multiple versions of qemu which use different command line
> options or syntaxes, wrap all command line options in small helper functions,
> which append text to the command line according to the output of 'qemu -help'.
Applied, thanks!
> Signed-off-by: Michael Goldish <mgoldish@redhat.com>
> ---
> client/tests/kvm/kvm_vm.py | 198 ++++++++++++++++++++++++++++++--------------
> 1 files changed, 135 insertions(+), 63 deletions(-)
>
> diff --git a/client/tests/kvm/kvm_vm.py b/client/tests/kvm/kvm_vm.py
> index 047505a..94bacdf 100755
> --- a/client/tests/kvm/kvm_vm.py
> +++ b/client/tests/kvm/kvm_vm.py
> @@ -186,12 +186,100 @@ class VM:
> nic_model -- string to pass as 'model' parameter for this
> NIC (e.g. e1000)
> """
> - if name is None:
> - name = self.name
> - if params is None:
> - params = self.params
> - if root_dir is None:
> - root_dir = self.root_dir
> + # Helper function for command line option wrappers
> + def has_option(help, option):
> + return bool(re.search(r"^-%s(\s|$)" % option, help, re.MULTILINE))
> +
> + # Wrappers for all supported qemu command line parameters.
> + # This is meant to allow support for multiple qemu versions.
> + # Each of these functions receives the output of 'qemu -help' as a
> + # parameter, and should add the requested command line option
> + # accordingly.
> +
> + def add_name(help, name):
> + return " -name '%s'" % name
> +
> + def add_unix_socket_monitor(help, filename):
> + return " -monitor unix:%s,server,nowait" % filename
> +
> + def add_mem(help, mem):
> + return " -m %s" % mem
> +
> + def add_smp(help, smp):
> + return " -smp %s" % smp
> +
> + def add_cdrom(help, filename, index=2):
> + if has_option(help, "drive"):
> + return " -drive file=%s,index=%d,media=cdrom" % (filename,
> + index)
> + else:
> + return " -cdrom %s" % filename
> +
> + def add_drive(help, filename, format=None, cache=None, werror=None,
> + serial=None, snapshot=False, boot=False):
> + cmd = " -drive file=%s" % filename
> + if format: cmd += ",if=%s" % format
> + if cache: cmd += ",cache=%s" % cache
> + if werror: cmd += ",werror=%s" % werror
> + if serial: cmd += ",serial=%s" % serial
> + if snapshot: cmd += ",snapshot=on"
> + if boot: cmd += ",boot=on"
> + return cmd
> +
> + def add_nic(help, vlan, model=None, mac=None):
> + cmd = " -net nic,vlan=%d" % vlan
> + if model: cmd += ",model=%s" % model
> + if mac: cmd += ",macaddr=%s" % mac
> + return cmd
> +
> + def add_net(help, vlan, mode, ifname=None, script=None,
> + downscript=None):
> + cmd = " -net %s,vlan=%d" % (mode, vlan)
> + if mode == "tap":
> + if ifname: cmd += ",ifname=%s" % ifname
> + if script: cmd += ",script=%s" % script
> + cmd += ",downscript=%s" % (downscript or "no")
> + return cmd
> +
> + def add_floppy(help, filename):
> + return " -fda %s" % filename
> +
> + def add_tftp(help, filename):
> + return " -tftp %s" % filename
> +
> + def add_tcp_redir(help, host_port, guest_port):
> + return " -redir tcp:%s::%s" % (host_port, guest_port)
> +
> + def add_vnc(help, vnc_port):
> + return " -vnc :%d" % (vnc_port - 5900)
> +
> + def add_sdl(help):
> + if has_option(help, "sdl"):
> + return " -sdl"
> + else:
> + return ""
> +
> + def add_nographic(help):
> + return " -nographic"
> +
> + def add_uuid(help, uuid):
> + return " -uuid %s" % uuid
> +
> + def add_pcidevice(help, host):
> + return " -pcidevice host=%s" % host
> +
> + # End of command line option wrappers
> +
> + if name is None: name = self.name
> + if params is None: params = self.params
> + if root_dir is None: root_dir = self.root_dir
> +
> + qemu_binary = kvm_utils.get_path(root_dir, params.get("qemu_binary",
> + "qemu"))
> + # Get the output of 'qemu -help' (log a message in case this call never
> + # returns or causes some other kind of trouble)
> + logging.debug("Getting output of 'qemu -help'")
> + help = commands.getoutput("%s -help" % qemu_binary)
>
> # Start constructing the qemu command
> qemu_cmd = ""
> @@ -199,65 +287,49 @@ class VM:
> if params.get("x11_display"):
> qemu_cmd += "DISPLAY=%s " % params.get("x11_display")
> # Add the qemu binary
> - qemu_cmd += kvm_utils.get_path(root_dir, params.get("qemu_binary",
> - "qemu"))
> + qemu_cmd += qemu_binary
> # Add the VM's name
> - qemu_cmd += " -name '%s'" % name
> + qemu_cmd += add_name(help, name)
> # Add the monitor socket parameter
> - qemu_cmd += " -monitor unix:%s,server,nowait" % self.monitor_file_name
> + qemu_cmd += add_unix_socket_monitor(help, self.monitor_file_name)
>
> for image_name in kvm_utils.get_sub_dict_names(params, "images"):
> image_params = kvm_utils.get_sub_dict(params, image_name)
> if image_params.get("boot_drive") == "no":
> continue
> - qemu_cmd += " -drive file=%s" % get_image_filename(image_params,
> - root_dir)
> - if image_params.get("drive_format"):
> - qemu_cmd += ",if=%s" % image_params.get("drive_format")
> - if image_params.get("drive_cache"):
> - qemu_cmd += ",cache=%s" % image_params.get("drive_cache")
> - if image_params.get("drive_werror"):
> - qemu_cmd += ",werror=%s" % image_params.get("drive_werror")
> - if image_params.get("drive_serial"):
> - qemu_cmd += ",serial=%s" % image_params.get("drive_serial")
> - if image_params.get("image_snapshot") == "yes":
> - qemu_cmd += ",snapshot=on"
> - if image_params.get("image_boot") == "yes":
> - qemu_cmd += ",boot=on"
> + qemu_cmd += add_drive(help,
> + get_image_filename(image_params, root_dir),
> + image_params.get("drive_format"),
> + image_params.get("drive_cache"),
> + image_params.get("drive_werror"),
> + image_params.get("drive_serial"),
> + image_params.get("image_snapshot") == "yes",
> + image_params.get("image_boot") == "yes")
>
> vlan = 0
> for nic_name in kvm_utils.get_sub_dict_names(params, "nics"):
> nic_params = kvm_utils.get_sub_dict(params, nic_name)
> # Handle the '-net nic' part
> - qemu_cmd += " -net nic,vlan=%d" % vlan
> - if nic_params.get("nic_model"):
> - qemu_cmd += ",model=%s" % nic_params.get("nic_model")
> - if nic_params.has_key("address_index"):
> - mac, ip = kvm_utils.get_mac_ip_pair_from_dict(nic_params)
> - if mac:
> - qemu_cmd += ",macaddr=%s" % mac
> + mac = None
> + if "address_index" in nic_params:
> + mac = kvm_utils.get_mac_ip_pair_from_dict(nic_params)[0]
> + qemu_cmd += add_nic(help, vlan, nic_params.get("nic_model"), mac)
> # Handle the '-net tap' or '-net user' part
> - mode = nic_params.get("nic_mode", "user")
> - qemu_cmd += " -net %s,vlan=%d" % (mode, vlan)
> - if mode == "tap":
> - if nic_params.get("nic_ifname"):
> - qemu_cmd += ",ifname=%s" % nic_params.get("nic_ifname")
> - script_path = nic_params.get("nic_script")
> - if script_path:
> - script_path = kvm_utils.get_path(root_dir, script_path)
> - qemu_cmd += ",script=%s" % script_path
> - script_path = nic_params.get("nic_downscript")
> - if script_path:
> - script_path = kvm_utils.get_path(root_dir, script_path)
> - qemu_cmd += ",downscript=%s" % script_path
> - else:
> - qemu_cmd += ",downscript=no"
> + script = nic_params.get("script")
> + downscript = nic_params.get("downscript")
> + if script:
> + script = kvm_utils.get_path(root_dir, script)
> + if downscript:
> + downscript = kvm_utils.get_path(root_dir, downscript)
> + qemu_cmd += add_net(help, vlan, nic_params.get("nic_mode", "user"),
> + nic_params.get("nic_ifname"),
> + script, downscript)
> # Proceed to next NIC
> vlan += 1
>
> mem = params.get("mem")
> if mem:
> - qemu_cmd += " -m %s" % mem
> + qemu_cmd += add_mem(help, mem)
>
> smp = params.get("smp")
> if smp:
> @@ -266,7 +338,7 @@ class VM:
> iso = params.get("cdrom")
> if iso:
> iso = kvm_utils.get_path(root_dir, iso)
> - qemu_cmd += " -drive file=%s,index=2,media=cdrom" % iso
> + qemu_cmd += add_cdrom(help, iso)
>
> # Even though this is not a really scalable approach,
> # it doesn't seem like we are going to need more than
> @@ -274,47 +346,47 @@ class VM:
> iso_extra = params.get("cdrom_extra")
> if iso_extra:
> iso_extra = kvm_utils.get_path(root_dir, iso_extra)
> - qemu_cmd += " -drive file=%s,index=3,media=cdrom" % iso_extra
> + qemu_cmd += add_cdrom(help, iso_extra, 3)
>
> # We may want to add {floppy_otps} parameter for -fda
> - # {fat:floppy:}/path/. However vvfat is not usually recommended
> + # {fat:floppy:}/path/. However vvfat is not usually recommended.
> floppy = params.get("floppy")
> if floppy:
> floppy = kvm_utils.get_path(root_dir, floppy)
> - qemu_cmd += " -fda %s" % floppy
> + qemu_cmd += add_floppy(help, floppy)
>
> tftp = params.get("tftp")
> if tftp:
> tftp = kvm_utils.get_path(root_dir, tftp)
> - qemu_cmd += " -tftp %s" % tftp
> -
> - extra_params = params.get("extra_params")
> - if extra_params:
> - qemu_cmd += " %s" % extra_params
> + qemu_cmd += add_tftp(help, tftp)
>
> for redir_name in kvm_utils.get_sub_dict_names(params, "redirs"):
> redir_params = kvm_utils.get_sub_dict(params, redir_name)
> guest_port = int(redir_params.get("guest_port"))
> host_port = self.redirs.get(guest_port)
> - qemu_cmd += " -redir tcp:%s::%s" % (host_port, guest_port)
> + qemu_cmd += add_tcp_redir(help, host_port, guest_port)
>
> if params.get("display") == "vnc":
> - qemu_cmd += " -vnc :%d" % (self.vnc_port - 5900)
> + qemu_cmd += add_vnc(help, self.vnc_port)
> elif params.get("display") == "sdl":
> - qemu_cmd += " -sdl"
> + qemu_cmd += add_sdl(help)
> elif params.get("display") == "nographic":
> - qemu_cmd += " -nographic"
> + qemu_cmd += add_nographic(help)
>
> if params.get("uuid") == "random":
> - qemu_cmd += " -uuid %s" % self.uuid
> + qemu_cmd += add_uuid(help, self.uuid)
> elif params.get("uuid"):
> - qemu_cmd += " -uuid %s" % params.get("uuid")
> + qemu_cmd += add_uuid(help, params.get("uuid"))
>
> # If the PCI assignment step went OK, add each one of the PCI assigned
> # devices to the qemu command line.
> if self.pci_assignable:
> for pci_id in self.pa_pci_ids:
> - qemu_cmd += " -pcidevice host=%s" % pci_id
> + qemu_cmd += add_pcidevice(help, pci_id)
> +
> + extra_params = params.get("extra_params")
> + if extra_params:
> + qemu_cmd += " %s" % extra_params
>
> return qemu_cmd
>
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2010-05-26 13:49 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-17 13:29 [KVM-AUTOTEST PATCH] KVM test: formatting improvements to scan_results.py Michael Goldish
2010-05-17 13:29 ` [KVM-AUTOTEST PATCH] KVM test: make use of tcpdump optional Michael Goldish
2010-05-17 13:29 ` [KVM-AUTOTEST PATCH] KVM test: use command line option wrapper functions Michael Goldish
2010-05-26 13:49 ` [Autotest] " Lucas Meneghel Rodrigues
2010-05-17 13:35 ` [KVM-AUTOTEST PATCH] KVM test: make use of tcpdump optional Lucas Meneghel Rodrigues
2010-05-17 14:32 ` [Autotest] " Michael Goldish
2010-05-25 23:47 ` Lucas Meneghel Rodrigues
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).