Commit Graph

152 Commits

Author SHA1 Message Date
Jiri Denemark
e1ca8ecb46 qemu: Check QEMU error on failed migration
When migration fails, QEMU may provide a description of the error in
the reply to query-migrate QMP command. We can fetch this error and use
it instead of the generic "unexpectedly failed" message.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2017-10-17 10:41:45 +02:00
Peter Krempa
772a6e36a5 tests: qemumonitorjson: Old and empty test case for node name detection
Prior to qemu 2.5 the node names would not be generated, thus would be
missing from 'query-blockstats' and 'query-named-block-nodes'. Test that
the code correctly detects nothing.

Additionally make sure that a VM without disks does not cause problems.

The test case change is necessary as our test file checker does not play
well with empty files.
2017-07-28 17:59:06 +02:00
Peter Krempa
4199a33a19 tests: qemumonitorjson: Test extraction of iSCSI device node names
Test storage was created on a rhel/centos 7 node using targetcli.

Reviewed-by: Eric Blake <eblake@redhat.com>
2017-07-27 10:34:14 +02:00
Peter Krempa
86d8d11c14 tests: qemumonitorjson: Test extraction of LUKS node names
Test file created by:

qemu-img create -f luks /var/lib/libvirt/images/luks 10M \
        -o key-secret=asdf --object secret,id=asdf,format=raw,data=asdf

Used in libvirt as:
 <disk type='file' device='disk'>
   <driver name='qemu' type='raw'/>
   <source file='/var/lib/libvirt/images/luks'/>
   <target dev='vda' bus='virtio'/>
   <encryption format='luks'>
     <secret type='passphrase' uuid='9b2c831a-fdb9-4c09-873c-1959580589e1'/>
   </encryption>
 </disk>

Reviewed-by: Eric Blake <eblake@redhat.com>
2017-07-27 10:34:13 +02:00
Peter Krempa
b717be71dc tests: qemumonitorjson: Add test case for node name detection with blockjob
qemu 2.9 returns an extra layer in the backing data if a block job is
active. Add a test case to see whether our code properly detects and
ignores such layer.

The test data was prepared by creating a backing chain of qcow2 images
(with qemu-img and with libvirt's snapshot feature).

One of the layers was then merged back by doing a block-commit:

virsh blockcommit VM hda --top /var/lib/libvirt/images/b

and then a block-copy job was started and kept in synchronized phase:

virsh blockcopy VM hda /tmp/tgt.img --transient job

Reviewed-by: Eric Blake <eblake@redhat.com>
2017-07-27 10:34:13 +02:00
Peter Krempa
b04a3474e4 tests: qemumonitorjson: Fix 'gluster' node name detection test case
Add the blockstats data and fix the expected output.

Reviewed-by: Eric Blake <eblake@redhat.com>
2017-07-27 10:33:44 +02:00
Peter Krempa
18c5c93dc0 tests: qemumonitorjson: Fix 'relative' node name detection test case
Add the blockstats data and fix the expected output.

Test data was created as:

qemu-img create -f qcow2 img0 10M
qemu-img create -f qcow2 -o "backing_fmt=qcow2,backing_file=img0" img1
qemu-img create -f qcow2 -o "backing_fmt=qcow2,backing_file=img1" img2
...

Reviewed-by: Eric Blake <eblake@redhat.com>
2017-07-27 10:32:22 +02:00
Peter Krempa
9b03ffc7a4 tests: qemumonitorjson: Add data and fix 'same-backing' node detection case
With the new approach we are actually able to correctly detect node
names for the two instances of the same backing file.

Test images were created as:
qemu-img create -f qcow2 /var/lib/libvirt/images/base.qcow2 10M
qemu-img create -f qcow2 \
   -o "backing_fmt=qcow2,backing_file=/var/lib/libvirt/images/base.qcow2 \
   /var/lib/libvirt/images/a.qcow2
qemu-img create -f qcow2 \
   -o "backing_fmt=qcow2,backing_file=/var/lib/libvirt/images/base.qcow2 \
   /var/lib/libvirt/images/b.qcow2

and then used for two separate disks.

Reviewed-by: Eric Blake <eblake@redhat.com>
2017-07-27 10:27:20 +02:00
Peter Krempa
c03e52af57 qemu: block: store and test driver names for detected storage nodes
Store the 'drv' field both for the storage node and for the format node
and format them in the test case.

Reviewed-by: Eric Blake <eblake@redhat.com>
2017-07-27 09:56:41 +02:00
Peter Krempa
acfd2fdcbf tests: qemumonitorjson: Simplify node name detection test
We can now iterate the hash table and print all detected backing chains.
This simplifies calling of the test cases.

Reviewed-by: Eric Blake <eblake@redhat.com>
2017-07-27 09:55:24 +02:00
Peter Krempa
0175dc6ea0 qemu: block: Refactor node name detection code
Remove the complex and unreliable code which inferred the node name
hierarchy only from data returned by 'query-named-block-nodes'. It turns
out that query-blockstats contain the full hierarchy of nodes as
perceived by qemu so the inference code is not necessary.

In query blockstats, the 'parent' object corresponds to the storage
behind a storage volume and 'backing' corresponds to the lower level of
backing chain. Since all have node names this data can be really easily
used to detect node names.

In addition to the code refactoring the one remaining test case needed
to be fixed along.

Reviewed-by: Eric Blake <eblake@redhat.com>
2017-07-27 09:47:40 +02:00
Peter Krempa
f0cbe201b8 tests: qemumontitorjson: temporarily disable node name detection tests
To simplify the refactoring patches disable the tests. This will allow
adding test data later.

Reviewed-by: Eric Blake <eblake@redhat.com>
2017-07-27 09:40:52 +02:00
Peter Krempa
e3b0eb5b1c tests: qemumonitorjson: simplify path handling in testBlockNodeNameDetect
Extract the test prefix path into a variable and reuse
virTestLoadFileJSON to load the sample json files rather than doing it
manually.

Reviewed-by: Eric Blake <eblake@redhat.com>
2017-07-27 09:39:54 +02:00
Peter Krempa
29f771fd66 tests: qemumonitorjson: Drop redundant data from testBlockNodeNameDetectFormat
The node name and backing file name can be inferred from the hierarchy.
This will also help when converting to detect node names using
query-blockstats data.

Reviewed-by: Eric Blake <eblake@redhat.com>
2017-07-27 09:28:48 +02:00
Peter Krempa
f1ce954b32 tests: qemumonitor: Prepare for more test data in testBlockNodeNameDetect
Rename 'json' and related variables to 'nodeNameJson'. Also rename the
test files along. This is a preparation for modifying how we detect node
names which will also require data from 'query-blockstats'.

Reviewed-by: Eric Blake <eblake@redhat.com>
2017-07-27 09:27:58 +02:00
Peter Krempa
2b5d5d68ca tests: qemumonitorjson: Consolidate basic node name detection test cases
Test cases named '1' and '2' differed only in the length of the backing
chain, so remove test case '2' and rename test '1' to 'basic'.

Reviewed-by: Eric Blake <eblake@redhat.com>
2017-07-27 09:25:55 +02:00
Ján Tomko
2277edb964 qemu: handle missing bind host/service on chardev hotplug
On domain startup, bind host or bind service can be omitted
and we will format a working command line.

Extend this to hotplug as well and specify the service to QEMU
even if the host is missing.

https://bugzilla.redhat.com/show_bug.cgi?id=1452441
2017-07-11 15:18:31 +02:00
Peter Krempa
ccac446545 qemu: domain: Use vcpu 'node-id' property and pass it back to qemu
vcpu properties gathered from query-hotpluggable cpus need to be passed
back to qemu. As qemu did not use the node-id property until now and
libvirt forgot to pass it back properly (it was parsed but not passed
around) we did not honor this.

This patch adds node-id to the structures where it was missing and
passes it around as necessary.

The test data was generated with a VM with following config:
    <numa>
      <cell id='0' cpus='0,2,4,6' memory='512000' unit='KiB'/>
      <cell id='1' cpus='1,3,5,7' memory='512000' unit='KiB'/>
    </numa>

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1452053
2017-07-10 13:23:04 +02:00
John Ferlan
466a53af05 tests: Pass BlockIOThrottle arguments by reference not value
Pass the data by reference rather than everything on the stack.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2017-04-04 12:40:27 -04:00
Andrea Bolognani
4ceac4bf29 tests: Rename VIRT_TEST_* macros to VIR_TEST_*
We use the "vir" prefix pretty consistently in our
APIs, both external and internal, which made these
macros stood out.
2017-04-04 17:30:03 +02:00
Peter Krempa
b0aa088fad tests: qemumonitorjson: Test node name detection on networked storage 2017-03-27 10:35:19 +02:00
Peter Krempa
2a50c18fc0 tests: qemumonitorjson: Add relative image names for node name detection
oVirt uses relative names with directories in them. Test such
configuration. Also tests a snapshot done with _REUSE_EXTERNAL and a
relative backing file pre-specified in the qcow2 metadata.
2017-03-27 10:35:19 +02:00
Peter Krempa
b6c5a3f09b tests: qemumonitorjson: Add case for two disks sharing a backing image
Since we have to match the images by filename a common backing image
will break the detection process. Add a test case to see that the code
correctly did not continue the detection process.
2017-03-27 10:35:19 +02:00
Peter Krempa
aece275043 tests: qemumonitorjson: Add long backing chain test case for node name detection 2017-03-27 10:35:19 +02:00
Peter Krempa
217484bdbd tests: qemumonitorjson: Add test case for node name detection code
The code is rather magic so a test case will help making sure that
everything works well. The first case is a simple backing chain.
2017-03-27 10:35:19 +02:00
John Ferlan
3d06cb96fb qemu: Add TLS params to _qemuMonitorMigrationParams
Add the fields to support setting tls-creds and tls-hostname during
a migration (either source or target). Modify the query migration
function to check for the presence and set the field for future
consumers to determine which of 3 conditions is being met (NULL,
present and set to "", or present and sent to something). These
correspond to qemu commit id '4af245dc3' which added support to
default the value to "" and allow setting (or resetting) to ""
in order to disable. This reset option allows libvirt to properly
use the tls-creds and tls-hostname parameters.

Modify code paths that either allocate or use stack space in order
to call qemuMigrationParamsClear or qemuMigrationParamsFree for cleanup.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2017-03-25 08:19:49 -04:00
Jiri Denemark
77c9c4f127 qemu: Ask QEMU for filtered CPU features
qemuMonitorGetGuestCPU can now optionally create CPU data from
filtered-features in addition to feature-words.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2017-03-17 11:50:48 +01:00
Jiri Denemark
f6d55a5f42 cpu: Rework cpuDataFree
The new API is called virCPUDataFree. Individual CPU drivers are no
longer required to implement their own freeing function unless they need
to free architecture specific data from virCPUData.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2017-02-24 14:10:57 +01:00
Peter Krempa
5cd670fea8 qemu: monitor: More strict checking of 'query-cpus' if hotplug is supported
In cases where CPU hotplug is supported by qemu force the monitor to
reject invalid or broken responses to 'query-cpus'. It's expected that
the command returns usable data in such case.
2017-01-18 09:57:06 +01:00
John Ferlan
c53bd25b13 qemu: Add support for parsing iotune group setting
Add support to read/parse the iotune group setting for qemu.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-12-05 18:12:08 -05:00
Jiri Denemark
a1adfb0f06 qemu: Add support for unavailable-features
QEMU 2.8.0 adds support for unavailable-features in
query-cpu-definitions reply. The unavailable-features array lists CPU
features which prevent a corresponding CPU model from being usable on
current host. It can only be used when all the unavailable features are
disabled. Empty array means the CPU model can be used without
modifications.

We can use unavailable-features for providing CPU model usability info
in domain capabilities XML:

    <domainCapabilities>
      ...
      <cpu>
        <mode name='host-passthrough' supported='yes'/>
        <mode name='host-model' supported='yes'>
          <model fallback='allow'>Skylake-Client</model>
          ...
        </mode>
        <mode name='custom' supported='yes'>
          <model usable='yes'>qemu64</model>
          <model usable='yes'>qemu32</model>
          <model usable='no'>phenom</model>
          <model usable='yes'>pentium3</model>
          <model usable='yes'>pentium2</model>
          <model usable='yes'>pentium</model>
          <model usable='yes'>n270</model>
          <model usable='yes'>kvm64</model>
          <model usable='yes'>kvm32</model>
          <model usable='yes'>coreduo</model>
          <model usable='yes'>core2duo</model>
          <model usable='no'>athlon</model>
          <model usable='yes'>Westmere</model>
          <model usable='yes'>Skylake-Client</model>
          ...
        </mode>
      </cpu>
      ...
    </domainCapabilities>

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-11-28 09:11:22 +01:00
Michal Privoznik
c2a5a4e7ea virstring: Unify string list function names
We have couple of functions that operate over NULL terminated
lits of strings. However, our naming sucks:

virStringJoin
virStringFreeList
virStringFreeListCount
virStringArrayHasString
virStringGetFirstWithPrefix

We can do better:

virStringListJoin
virStringListFree
virStringListFreeCount
virStringListHasString
virStringListGetFirstWithPrefix

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-11-25 13:54:05 +01:00
Peter Krempa
b6afa9a8b5 qemu: monitor: Properly propagate the 'qemu_id' field through the matcher
Commit 3f71c79768 added 'qemu_id' field to track the id of the cpu
as reported by query-cpus. The patch did not include changes necessary
to propagate the id through the functions matching the data to the
libvirt cpu structures and thus all vcpus had id 0.
2016-11-22 10:44:17 +01:00
Peter Krempa
62d57d1b23 tests: qemumonitorjson: Rename 'qemu-id' to 'enable-id' in cpu info test
The field is named 'enable_id' in other structures and a patch recently
added 'qemu_id' which has different semantics. To avoid confusion in the
tests rename the field.
2016-11-22 10:23:47 +01:00
Peter Krempa
3f71c79768 qemu: monitor: Extract qemu cpu id along with other data
Storing of the ID will allow simpler extraction of data present only in
query-cpus without the need to call qemuMonitorGetCPUInfo in statistics
paths.
2016-11-21 17:19:48 +01:00
Jiri Denemark
53a5986ad6 cpu: Rename cpuDataFormat
The new name is virCPUDataFormat.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-11-15 15:49:15 +01:00
John Ferlan
223438a245 qemu: Add length for bps/iops throttling parameters to driver
Add support for a duration/length for the bps/iops and friends.

Modify the API in order to add the "blkdeviotune." specific definitions
for the iotune throttling duration/length options

    total_bytes_sec_max_length
    write_bytes_sec_max_length
    read_bytes_sec_max_length
    total_iops_sec_max_length
    write_iops_sec_max_length
    read_iops_sec_max_length
2016-10-25 17:20:13 -04:00
Viktor Mihajlovski
cc5e695bde qemu: Add monitor support for CPU halted state
Extended the qemuMonitorCPUInfo with a halted flag. Extract the halted
flag for both text and JSON monitor.

Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
Signed-off-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
2016-10-24 18:52:36 -04:00
John Ferlan
e5c7ce8cd0 tests: Need to initialize data
If not initialized and the virAsprintf to jsonreply or fulllablel fails,
then the call to qemuMonitorTestFree will take stack data.
2016-10-10 15:40:20 -04:00
Peter Krempa
9bc4179dd4 qemu: monitor: Properly configure backend for UDP chardevs
Since introduction of chardev hotplug the code was wrong for the UDP
case and basically created a TCP socket instead. Use proper objects and
type for UDP.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1377602
2016-10-06 09:13:39 +02:00
Peter Krempa
3da5008125 tests: qemumonitorjsontest: Do some actual testing in qemuMonitorJSONTestAttachChardev
Until now the test was rather useless since it didn't check the
arguments formatted and didn't use properly configured chardev objects.

Add the expected arguments and instrument the test to validate them.
Modify some test cases to actually add valid data.

Note that the UDP test data is currently wrong due to a bug.
2016-10-06 09:13:39 +02:00
Peter Krempa
4c75ba7f37 tests: qemumonitorjson: Don't do multiple tests in one virTestRun
The chardev attach test would do all the tests in one virTestRun
instance. If one sub-test failed then the test would report failure
improperly and the error would be hard to debug since the error pointer
was overwritten.
2016-10-06 09:13:39 +02:00
Nitesh Konkar
4ab456806f Fix coding style issues.
Signed-off-by: Nitesh Konkar <nitkon12@linux.vnet.ibm.com>
2016-09-26 18:07:58 -04:00
Jiri Denemark
d037d8006f qemu: Use virDomainCapsCPUModels for cpuDefinitions
The list of supported CPU models in domain capabilities is stored in
virDomainCapsCPUModels. Let's use the same object for storing CPU models
in QEMU capabilities.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-09-22 15:40:08 +02:00
Peter Krempa
2a0e68be91 qemu: monitor: Add vcpu state information to monitor data
Return whether a vcpu entry is hotpluggable or online so that upper
layers don't have to infer the information from other data.

Advantage is that this code can be tested by unit tests.
2016-09-14 12:55:33 +02:00
Peter Krempa
04fce1d496 tests: cpu-hotplug: Add data for ppc64 without threads enabled
The reported data is unusual so add it to the test suite.
2016-08-24 15:44:47 -04:00
Peter Krempa
1c455c4743 tests: cpu-hotplug: Add data for ppc64 out-of-order hotplug
Test the algorithm that extracts the order in which the vcpu entries
were plugged in on a sample of data created by plugging in vcpus
arbitrarily.
2016-08-24 15:44:47 -04:00
Peter Krempa
d1145aad0b tests: cpu-hotplug: Add data for ppc64 platform including hotplug
Power 8 platform's basic hotpluggable unit is a core rather than a
thread for x86_64 family. This introduces most of the complexity of the
matching code and thus needs to be tested.

The test data contain data captured from in-order cpu hotplug and
unplug operations.
2016-08-24 15:44:47 -04:00
Peter Krempa
22e3bb332e tests: cpu-hotplug: Add data for x86 hotplug with 11+ vcpus
During review it was reported that adding at least 11 vcpus creates a
collision of prefixes in the monitor matching algorithm. Add a test case
to verify that the problem won't happen.
2016-08-24 15:44:47 -04:00
Peter Krempa
f8638471d7 tests: Add test infrastructure for qemuMonitorGetCPUInfo
As the combination algorithm is rather complex and ugly it's necessary
to make sure it works properly. Add test suite infrastructure for
testing it along with a basic test based on x86_64 platform.
2016-08-24 15:44:47 -04:00