qemu.tests: Use qemu-kvm -M ? to get machine type for physical resource check

The old method to get expect machine type can not fit machine type check for
q35 and pc. So update it by get the machine type string from the output
of qemu-kvm -M ?.

Signed-off-by: Yiqiao Pu <ypu@redhat.com>
virt-libvirt: Extend test-runner default tests

By default, the runner was running all variants of a single test.
This makes it harder to spot certain types of test-specific problems.
Instead, the runner should run a wider variety of tests, spreading
the variant choices across a range of underlying functionality.

Unfortunately, there's not a cleaner way to specify a wide range of
tests w/o simply listing them all.  However, the list can be read
in from a file, which will help keep the maintenance effort low. I
hard-coded list file path as relative to wherever the test runner
module is located, since there's no reason to over complicate it.

I expect this list will change over time, so this is only a reasonable
starting place. Included are about 80 libvirt tests from across the
board, with at least one positive and one negative test for each topic.
I attempted to pick different operational varients from each set so,
for example, it doesn't just exercize the same set of parameters
repeatidly.

Including the install and remove, they all complete on my intel i7 based
laptop in under 30min, which was found to be reasonable.

Signed-off-by: Chris Evich <cevich@redhat.com>
Merge pull request #1084 from cevich/default_set

virt-libvirt: Extend test-runner default tests
Merge pull request #1069 from ypu/machine_type

qemu.tests: Use qemu-kvm -M ? to get machine type for physical resource ...
virttest.utils_env_unittest: Add clean reproducer for the 'RuntimeError' issue

Sometimes, while virt-test is saving Env to a file, the
tcpdump thread writes to the Env dictionary "address_cache",
generating a:

RuntimeError: dictionary changed size during iteration

exception. Of course, any thread that modifies env data
while saving is taking place is going to create this
problem. So I implemented a similar situation in the
Env unittest code, so we have a reproducer, that can
be later fixed to use new Env locking mechanisms.

So, in case it is not clear, this unittest is supposed
to fail right now, and after said locking mechanism
is implemented, the test will start passing.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
virttest.utils_env: Solve the env["address_cache"] RuntimeError issue

There is a background tcpdump thread that records DHCP leases
in the env["address_cache"] dictionary. Sometimes, this thread
might write to this dictionary while the environment object is
being saved, triggering a RuntimeError in virt-test.

So the solution involves:

1) Creating a save lock, (a threading reentrant lock object),
that is acquired by the env.save() method when it wants to
save env.data to a pickle file, and for methods that alter
env.data.

2) Move the tcpdump thread to a env object attribute, rather
than one of the keys of env.data, given that the lock object
can't be pickled.

With the implementation of env.save_lock, we can also fix
the problem identified by the locking unittest. The base of
the solution was Pavel's idea, including a good deal of the
implementation, so kudos to him.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
virttest.utils_env: Add @utils_env.lock_safe decorator

Add a utility method to wrap functions that modify the
contents of env.data. In order to avoid the boring
repetition of code that gets an environment save lock,
perform data change and then release the lock, put that
into the decorator and use it.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
Merge pull request #1091 from autotest/environment-fix-3

Environment RuntimeError fix
qemu.tests: physical_resources_check - Fix undefined variable bug

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
virt: Regex strings must begin with r

Signed-off-by: Chris Evich <cevich@redhat.com>