autotest/virt-test — pull request #1170 by jferlan (2013-12-02 15:27:05+00:00)
Title: virsh_vcpucount: Adjust --guest option testing

Couple of issues here. First there was no check to see if the
guest agent was running in the guest. The test would fail as
written with:

stderr: error: argument unsupported: QEMU guest agent is not configured

So borrow from virsh_snapshot_create_as.py and add code to check
and start the guest agent.

Even though the guest agent was running, the underlying QEMU may not
support the 'guest-get-vcpus' option as it was only added as of 1.5.
The error message received is:

stderr: error: internal error: unable to execute QEMU agent command
'guest-get-vcpus': The command guest-get-vcpus has not been found

So as a secondary fix - add a check for the stderr check and exit with
SKIP rather than FAIL.

The call to make this check is wrapped inside a try/except so that if
there is a failure, the test can reset the environment back to how it
found it.

Use that reset environment method in other test exit paths as well...

Finally fixed a spelling error in the CFG file from "opiton" to "option"