]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
9 years agolibxl: honor domainGetXMLDesc() --inactive flag
Jim Fehlig [Wed, 24 Jun 2015 22:15:22 +0000 (16:15 -0600)]
libxl: honor domainGetXMLDesc() --inactive flag

The libxl driver always uses virDomainObj->def when formatting
the domain XML description.  Use virDomainObj->newDef when
--inactive flag is set.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
9 years agolibxl: don't remove persistent domain on start failure
Jim Fehlig [Wed, 24 Jun 2015 21:14:41 +0000 (15:14 -0600)]
libxl: don't remove persistent domain on start failure

libxlDomainCreateXML() would remove a persistent domain if
libxlDomainStart() failed.  Check if domain is persistent
before removing.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
9 years agolibxl: don't overwrite domain state from statedir config
Jim Fehlig [Wed, 24 Jun 2015 21:02:15 +0000 (15:02 -0600)]
libxl: don't overwrite domain state from statedir config

When restarting libvirtd and reconnecting to running domains,
libxlReconnectDomain() would unconditionally set the domain state
to VIR_DOMAIN_RUNNING, overwriting the state maintained in
$statedir/<domname>.xml.  A domain in a paused state would have
the state changed to running, even though it was actually in a
paused state.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
9 years agoqemu: Add missing on_crash lifecycle type
John Ferlan [Mon, 29 Jun 2015 19:22:49 +0000 (15:22 -0400)]
qemu: Add missing on_crash lifecycle type

https://bugzilla.redhat.com/show_bug.cgi?id=1201760

When the domain "<on_crash>coredump-destroy</on_crash>" is set, the
domain wasn't being destroyed, rather it was being rebooted.

Add VIR_DOMAIN_LIFECYCLE_CRASH_COREDUMP_DESTROY to the list of
on_crash types that cause "-no-reboot" to be added to the qemu
command line.

9 years agoUse the correct symbol for 'onCrash'
John Ferlan [Mon, 29 Jun 2015 19:22:28 +0000 (15:22 -0400)]
Use the correct symbol for 'onCrash'

Although defined the same way, fortunately there hadn't been any deviation.
Ensure any assignments to onCrash use VIR_DOMAIN_LIFECYCLE_CRASH_* defs and
not VIR_DOMAIN_LIFECYCLE_* defs

9 years agompath: Don't allow more than one mpath pool at a time
John Ferlan [Wed, 24 Jun 2015 12:45:24 +0000 (08:45 -0400)]
mpath: Don't allow more than one mpath pool at a time

https://bugzilla.redhat.com/show_bug.cgi?id=1232606

Since an mpath pool contains all the Multipath devices on a host, allowing
more than one defined on a host at a time should be disallowed under the
policy of disallowing duplicate source pools for the host.

Adjust to docs to clarify the Multipath target path value usage for both
the storage driver (only 1 pool per host) and formatstorage references
(ignore the target element in favor of the default target mapping of
/dev/mapper).

9 years agompath: Update path in CheckPool function
John Ferlan [Wed, 24 Jun 2015 11:46:47 +0000 (07:46 -0400)]
mpath: Update path in CheckPool function

https://bugzilla.redhat.com/show_bug.cgi?id=1230664

Per the devmapper docs, use "/dev/mapper" or "/dev/dm-n" in order to
determine if a device is under control of DM Multipath.

So add "/dev/mapper" to the virFileExists, leaving the "/dev/mpath"
as a "legacy" option since it appears for a while it was the preferred
mechanism, but is no longer maintained

9 years agoconf: Validate disk lun using correct types
John Ferlan [Fri, 26 Jun 2015 17:48:06 +0000 (13:48 -0400)]
conf: Validate disk lun using correct types

https://bugzilla.redhat.com/show_bug.cgi?id=1201143

The formatdomain.html description for <disk> device 'lun' indicates that
it must be either a type 'block' or type 'network' with protocol 'iscsi';
however, we did not make that check until domain startup.

This caused issues for virt-manager which had an unexpected failure at
run time rather config time.

This patch adds a check in post part disk device checking for the specific
and supported lun types as well as adjusting the test failure to be for
parse config rather than run time.

9 years agoStorage: Introduce shadow vol for refresh while the main vol builds.
Prerna Saxena [Fri, 26 Jun 2015 11:35:11 +0000 (17:05 +0530)]
Storage: Introduce shadow vol for refresh while the main vol builds.

Libvirt periodically refreshes all volumes in a storage pool, including
the volumes being cloned.
While cloning a storage volume from parent, we drop pool locks. Subsequent
volume refresh sometimes changes allocation for an ongoing copy, and leads
to corrupt images.
Fix: Introduce a shadow volume that isolates the volume object under refresh
from the base which has a copy ongoing.

Signed-off-by: Prerna Saxena <prerna@linux.vnet.ibm.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
9 years agoconf: storage: Fix duplicate check for gluster pools
Peter Krempa [Tue, 30 Jun 2015 08:14:17 +0000 (10:14 +0200)]
conf: storage: Fix duplicate check for gluster pools

The pool name has to be the same too to warrant rejecting a pool
definition as duplicate. This regression was introduced in commit
2184ade3a0546b915252cb3b6a5dc88e9a8d2ccf.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1236438

9 years agoqemu: event: Clean up VNC monitor handling
Peter Krempa [Mon, 29 Jun 2015 15:03:14 +0000 (17:03 +0200)]
qemu: event: Clean up VNC monitor handling

Get rid of spice specific stuff from the handler func and save a few
lines by reflowing the conditions.

9 years agoqemu: event: Properly handle spice events
Peter Krempa [Mon, 29 Jun 2015 14:10:51 +0000 (16:10 +0200)]
qemu: event: Properly handle spice events

Spice events have mostly similar information present in the event JSON
but they differ in the name of the element containing the port.

The JSON event also provides connection ID which might be useful in the
future.

This patch splits up the event parser code into two functions and the
SPICE reimplements the event parsing with correct names and drops the
VNC only stuff.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1236585

9 years agoRevert "Introduce QEMU_CAPS_ARM_VIRT_PCI"
Peter Krempa [Mon, 29 Jun 2015 07:44:35 +0000 (09:44 +0200)]
Revert "Introduce QEMU_CAPS_ARM_VIRT_PCI"

The capability was not used up to the feature freeze.

This reverts commit 7f3515b4bb677d0ead1887547efc844e4761268a.

9 years agoqemu: Close the agent connection only on agent channel events
Peter Krempa [Tue, 30 Jun 2015 08:46:50 +0000 (10:46 +0200)]
qemu: Close the agent connection only on agent channel events

processSerialChangedEvent processes events for all channels. Commit
2af51483 broke all agent interaction if a channel other than the agent
closes since it did not check that the event actually originated from
the guest agent channel.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1236924
Fixes up: https://bugzilla.redhat.com/show_bug.cgi?id=890648

9 years agostorage: Set correct vol->type at VolCreate
John Ferlan [Mon, 29 Jun 2015 18:18:49 +0000 (14:18 -0400)]
storage: Set correct vol->type at VolCreate

https://bugzilla.redhat.com/show_bug.cgi?id=1227664

If the requested format type for the new entry in the file system pool
is a 'dir', then be sure to set the vol->type correctly as would be done
when the pool is refreshed.

9 years agoFix typo incomaptible -> incompatible
Andrea Bolognani [Tue, 30 Jun 2015 08:53:55 +0000 (10:53 +0200)]
Fix typo incomaptible -> incompatible

9 years agoqemu: Fix assignment of the default spicevmc channel name
Jiri Denemark [Tue, 30 Jun 2015 08:21:21 +0000 (10:21 +0200)]
qemu: Fix assignment of the default spicevmc channel name

Make sure we only assign the default spicevmc channel name to spicevmc
virtio channels. Caused by commits 3269ee65 and 1133ee2b, which moved
the assignment from XML parsing code to QEMU but failed to keep the
logic.

https://bugzilla.redhat.com/show_bug.cgi?id=1179680

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemuxml2argv: Remove Haswell CPU from unrelated tests
Jiri Denemark [Mon, 29 Jun 2015 11:19:21 +0000 (13:19 +0200)]
qemuxml2argv: Remove Haswell CPU from unrelated tests

Proper Haswell CPU model handling is tested in several
qemuxml2argv-cpu-* which are run in a special environment. Let's remove
the CPU model from other tests to make them less fragile.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoRevert "Change livbirt version to 1.3.0 for the next release"
Martin Kletzander [Fri, 26 Jun 2015 15:26:30 +0000 (17:26 +0200)]
Revert "Change livbirt version to 1.3.0 for the next release"

This reverts commit 9a8d916e89173890d7f7ce538b1ab781192b8440.

Also some changes that were introduced after that commit are fixed to
use 1.2.17 instead of 1.3.0

9 years agoTemporarily disable admin API
Martin Kletzander [Fri, 26 Jun 2015 15:26:29 +0000 (17:26 +0200)]
Temporarily disable admin API

Don't listen on the admin socket in the daemon and comment out the
admin devel files out of specfile.

Library is still being compiled and installed in order to link easily
without any disturbing modifications to the daemon code.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agospec: Remove admin package specification
Martin Kletzander [Fri, 26 Jun 2015 15:26:28 +0000 (17:26 +0200)]
spec: Remove admin package specification

Its only file must be included in the daemon package anyway, since the
daemon is linked with the admin library and so then it's just an empty
package until we have virt-admin binary which we can decide later on
whether to just move it to clients or create a new package for it.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoqemu: Resolve Coverity RESOURCE_LEAK
John Ferlan [Sat, 27 Jun 2015 10:41:59 +0000 (06:41 -0400)]
qemu: Resolve Coverity RESOURCE_LEAK

Commit id '15fa84acb' added the alias fetch, but forgot to free it.

9 years agodocs: Clarification for when allowed to use 'lun' for "volume"
John Ferlan [Fri, 26 Jun 2015 18:09:59 +0000 (14:09 -0400)]
docs: Clarification for when allowed to use 'lun' for "volume"

While re-reading what I wrote for commit id '785a8940e', I realized
I needed to clarify that being able to present as a 'lun', the mode
property for the pool source element needed to be "host" (or empty)
and not "direct".

It was described correctly later in the mode host description, but
this just ensures it's not missed here as well.

Signed-off-by: John Ferlan <jferlan@redhat.com>
9 years agodocs: document when pcie-root/dmi-to-pci-bridge support was added
Laine Stump [Fri, 12 Jun 2015 18:54:23 +0000 (14:54 -0400)]
docs: document when pcie-root/dmi-to-pci-bridge support was added

Also move the mention of version numbers for the various PCI
controller models up to the end of the sentence where they are first
given, to avoid confusion.

9 years agoqemu: ignore assumptions about hotplug requirement when address is from config
Laine Stump [Wed, 10 Jun 2015 18:15:25 +0000 (14:15 -0400)]
qemu: ignore assumptions about hotplug requirement when address is from config

Certain PCI buses don't support hotplug, and when automatically
assigning PCI addresses for devices, libvirt is very conservative in
its assumptions about whether or not a device will need to be
hotplugged/unplugged in the future. But if the user manually assigns
an address, they likely are aware of any hotplug requirements of the
device (or at least they should be).

In short, after this patch, automatically PCI address assignment will
assume that the device must be plugged in to a hot-pluggable slot, but
manually assignment can place the device in any bus that is
compatible, regardless of whether or not it supports hotplug. If the
user makes a mistake and plugs the device into a bus that doesn't
support hotplug, then later tries to do a hot-unplug, qemu will give
an appropriate error.

(in the future we may want to add a "hotpluggable" attribute to all
devices, with default being "yes" for autoassign, and "no" for manual
assign).

9 years agoqemu: always permit PCI devices to be manually assigned to a PCIe bus
Laine Stump [Tue, 9 Jun 2015 17:33:36 +0000 (13:33 -0400)]
qemu: always permit PCI devices to be manually assigned to a PCIe bus

When support for the pcie-root and dmi-to-pci-bridge buses on a Q35
machinetype was added, I was concerned that even though qemu at the
time allowed plugging a PCI device into a PCIe port, that it might not
be supported in the future. To prevent painful backtracking in the
possible future where this happened, I disallowed such connections
except in a few specific cases requested by qemu developers (indicated
in the code with the flag VIR_PCI_CONNECT_TYPE_EITHER_IF_CONFIG).

Now that a couple years have passed, there is a clear message from
qemu that there is no danger in allowing PCI devices to be plugged
into PCIe ports. This patch eliminates
VIR_PCI_CONNECT_TYPE_EITHER_IF_CONFIG and changes the code to always
allow PCI->PCIe or PCIe->PCI connection *when the PCI address is
specified in the config. (For newly added devices that haven't yet
been given a PCI address, the auto-placement still prefers using the
correct type of bus).

9 years agoqemu: refactor qemuBuildControllerDevStr to eliminate future duplicate code
Laine Stump [Tue, 16 Jun 2015 19:22:57 +0000 (15:22 -0400)]
qemu: refactor qemuBuildControllerDevStr to eliminate future duplicate code

The PCI case of the switch statement in this function contains another
switch statement with a case for each model. Currently every model
except pci-root and pcie-root has a check for index > 0 (since only
those two can have index==0), and the function should never be called
for those two anyway. If we move the check for !pci[e]-root to the top
of the pci case, then we can move the check for index > 0 out of the
individual model cases. This will save repeating that check for the
three new controller models about to be added.

9 years agotest: qemu: Make sure that wr_highest_offset_valid gets set properly
Peter Krempa [Fri, 26 Jun 2015 14:40:29 +0000 (16:40 +0200)]
test: qemu: Make sure that wr_highest_offset_valid gets set properly

Remove one instance of the field being present so that the code that
sets that flag can be tested.

9 years agoqemu: monitor: Remove qemuMonitorGetBlockExtent
Peter Krempa [Tue, 23 Jun 2015 12:43:00 +0000 (14:43 +0200)]
qemu: monitor: Remove qemuMonitorGetBlockExtent

Now that qemuMonitorGetAllBlockStatsInfo collects also wr_highest_offset
the whole function can be killed.

9 years agoqemu: Refactor qemuDomainGetBlockInfo
Peter Krempa [Tue, 23 Jun 2015 16:22:54 +0000 (18:22 +0200)]
qemu: Refactor qemuDomainGetBlockInfo

Change the code so that it queries the monitor when the VM is alive.

9 years agoqemu: monitor: Open-code retrieval of wr_highest_offset
Peter Krempa [Tue, 23 Jun 2015 14:58:07 +0000 (16:58 +0200)]
qemu: monitor: Open-code retrieval of wr_highest_offset

Instead of using qemuMonitorJSONDevGetBlockExtent (which I plan to
remove later) extract the data in place.

Additionally add a flag that will be set when the wr_highest_offset was
extracted correctly so that callers can act according to that.

The test case addition should help make sure that everything works.

9 years agoqemu: monitor: Fix indentation in qemuMonitorJSONGetOneBlockStatsInfo
Peter Krempa [Tue, 23 Jun 2015 13:11:17 +0000 (15:11 +0200)]
qemu: monitor: Fix indentation in qemuMonitorJSONGetOneBlockStatsInfo

9 years agointernal: Introduce virCheckNonEmptyStringArgGoto and reuse it
Peter Krempa [Tue, 23 Jun 2015 15:35:16 +0000 (17:35 +0200)]
internal: Introduce virCheckNonEmptyStringArgGoto and reuse it

The helper makes sure that strings passed to APIs are non-NULL and
non-empty. This allows to drop some inlined checks where it does not
make sense.

9 years agovz: Fix build after recent commit
Peter Krempa [Fri, 26 Jun 2015 14:00:15 +0000 (16:00 +0200)]
vz: Fix build after recent commit

Function prlsdkGetStatsParam was missing a prototype or the static
keyword. I went with static since it built successfully.

Pushed as a build breaker fix.

9 years agovz: add memory statistics
Nikolay Shirokovskiy [Fri, 26 Jun 2015 11:24:00 +0000 (14:24 +0300)]
vz: add memory statistics

Implemented counters:
 VIR_DOMAIN_MEMORY_STAT_SWAP_IN
 VIR_DOMAIN_MEMORY_STAT_SWAP_OUT
 VIR_DOMAIN_MEMORY_STAT_MINOR_FAULT
 VIR_DOMAIN_MEMORY_STAT_MAJOR_FAULT
 VIR_DOMAIN_MEMORY_STAT_AVAILABLE
 VIR_DOMAIN_MEMORY_STAT_ACTUAL_BALLOON
 VIR_DOMAIN_MEMORY_STAT_UNUSED

Comments.

1. Use vzDomObjFromDomainRef/virDomainObjEndAPI pair to get domain
object as we use prlsdkGetStatsParam. See previous statistics
comments.

2. Balloon statistics is not applicable to containers. Fault
statistics for containers not provided in PCS6 yet.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
9 years agovz: add vcpu statistics
Nikolay Shirokovskiy [Fri, 26 Jun 2015 11:24:00 +0000 (14:24 +0300)]
vz: add vcpu statistics

Comments.

Replace vzDomObjFromDomain/virObjectUnlock pair
to vzDomObjFromDomainRef/virDomainObjEndAPI as we
use prlsdkGetStatsParam. See previous statistics
comments.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
9 years agovz: cleanup, make in par net device lookup functions
Nikolay Shirokovskiy [Fri, 26 Jun 2015 11:24:00 +0000 (14:24 +0300)]
vz: cleanup, make in par net device lookup functions

Make net device lookup by mac return sdk handle
instead of quite ephemeral enumeration index. After
this change there is no need anymore in special
function of removing device by enumeration index.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
9 years agovz: add net dev statistiscs
Nikolay Shirokovskiy [Fri, 26 Jun 2015 11:24:00 +0000 (14:24 +0300)]
vz: add net dev statistiscs

Populate counters SDK currenly supports:
 rx_bytes
 rx_packets
 tx_bytes
 tx_packets

Comments.

Use vzDomObjFromDomainRef/virDomainObjEndAPI pair to get domain
object as we use prlsdkGetStatsParam that can release domain
object lock and thus we need a reference in case domain
is deleated meanwhile.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
9 years agodocs: Don't keep temporary files around
Michal Privoznik [Fri, 26 Jun 2015 08:49:19 +0000 (10:49 +0200)]
docs: Don't keep temporary files around

In my previous fix (1310b1358) I've tried to solve an ordering
issue.  Well, while it worked it has a side effect of keeping a
temporary file around. My patch was buggy in that sense. Solve
this by properly marking the dependency without any side effect.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agovz_utils: Reformat
Michal Privoznik [Thu, 25 Jun 2015 07:56:56 +0000 (09:56 +0200)]
vz_utils: Reformat

Honour our formatting style. Adjust indentation so it matches the
rest of our code.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agovz_storage: Reformat
Michal Privoznik [Thu, 25 Jun 2015 07:56:56 +0000 (09:56 +0200)]
vz_storage: Reformat

Honour our formatting style. Adjust indentation so it matches the
rest of our code.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agovz_sdk: Reformat
Michal Privoznik [Thu, 25 Jun 2015 07:56:56 +0000 (09:56 +0200)]
vz_sdk: Reformat

Honour our formatting style. Adjust indentation so it matches the
rest of our code.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agovz_network: Reformat
Michal Privoznik [Thu, 25 Jun 2015 07:56:56 +0000 (09:56 +0200)]
vz_network: Reformat

Honour our formatting style. Adjust indentation so it matches the
rest of our code.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agovz_driver: Reformat
Michal Privoznik [Thu, 25 Jun 2015 07:56:56 +0000 (09:56 +0200)]
vz_driver: Reformat

Honour our formatting style. Adjust indentation so it matches the
rest of our code.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoqemuBuildMemoryBackendStr: Honour passed @pagesize
Michal Privoznik [Thu, 25 Jun 2015 15:27:29 +0000 (17:27 +0200)]
qemuBuildMemoryBackendStr: Honour passed @pagesize

So far the argument has not much meaning and was practically ignored.
This is not good since when doing memory hotplug, the size of desired
hugepage backing is passed in that argument. Taking closer look at the
tests I'm fixing reveals the bug. For instance, while the following is
in the test:

    <memory model='dimm'>
      <source>
        <nodemask>1-3</nodemask>
        <pagesize unit='KiB'>4096</pagesize>
      </source>
      <target>
        <size unit='KiB'>524287</size>
        <node>0</node>
      </target>
      <address type='dimm' slot='0' base='0x100000000'/>
    </memory>

the generated commandline corresponding to this XML was:

    -object memory-backend-ram,id=memdimm0,size=536870912,\
    host-nodes=1-3,policy=bind

Have you noticed? Yes, memory-backend-ram! Nothing can be further away
from the right answer. The hugepage backing is requested in the XML
and we happily ignore it. This is just not right. It's
memory-backend-file which should have been used:

    -object memory-backend-file,id=memdimm0,prealloc=yes,\
    mem-path=/dev/hugepages4M/libvirt/qemu,size=536870912,\
    host-nodes=1-3,policy=bind

The problem is, that @pagesize passed to qemuBuildMemoryBackendStr
(where this part of commandline is built) was ignored. The hugepage to
back memory was searched only and only by NUMA nodes pinning. This
works only for regular guest NUMA nodes.

Then, I'm changing the hugepages size in the test XMLs too. This is
simply because in the test suite we create dummy mount points just for
2M and 1G hugepages. And in the test 4M was requested. I'm sticking to
2M, but 1G should just work too.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoqemuBuildMemoryBackendStr: Fix hugepages lookup process
Michal Privoznik [Wed, 24 Jun 2015 16:09:57 +0000 (18:09 +0200)]
qemuBuildMemoryBackendStr: Fix hugepages lookup process

https://bugzilla.redhat.com/show_bug.cgi?id=1196644

This function constructs the backend (host facing) part of the
memory device.  At the beginning, the configured hugepages are
searched to find the best match for given guest NUMA node.
Configured hugepages can have a @nodeset attribute to specify on
which guest NUMA nodes should be the hugepages backing used.
There is, however, one 'corner case'. Users may just tell 'use
hugepages to back all the nodes'. In other words:

  <memoryBacking>
    <hugepages/>
  </memoryBacking>

  <cpu>
    <numa>
      <cell id='0' cpus='0-1' memory='1024000' unit='KiB'/>
    </numa>
  </cpu>

Our code fails in this case. Well, since there's no @nodeset (nor
any <page/> child element to <hugepages/>) we fail to lookup the
default hugepage size to use.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoconf: Format scheduler priority when it is zero
Luyao Huang [Wed, 24 Jun 2015 04:00:36 +0000 (12:00 +0800)]
conf: Format scheduler priority when it is zero

https://bugzilla.redhat.com/show_bug.cgi?id=1235116

According to our XML definition, zero is as valid as any other value.
Mainly because it should be kernel-agnostic.

Signed-off-by: Luyao Huang <lhuang@redhat.com>
9 years agotest: Refactor testNodeGetCPUMap
Peter Krempa [Mon, 22 Jun 2015 14:10:49 +0000 (16:10 +0200)]
test: Refactor testNodeGetCPUMap

Drop locking of the driver since it is not accessed and simplify the
code flow.

9 years agotest: Refactor vcpu pinning and vcpu info retrieval
Peter Krempa [Wed, 17 Jun 2015 09:05:21 +0000 (11:05 +0200)]
test: Refactor vcpu pinning and vcpu info retrieval

Drop internal data structures and use the proper fields in virDomainDef.

This allows to greatly simplify the code and allows to remove the
private data structure that was holding just redundant data.

This patch also fixes the bogous output where we'd report that a fresh
VM without vCPU pinning would not run on all vcpus.

9 years agotest: Refactor testDomainSetVcpusFlags
Peter Krempa [Tue, 16 Jun 2015 17:15:27 +0000 (19:15 +0200)]
test: Refactor testDomainSetVcpusFlags

Remove the bogus flag check and refactor the code by using
virDomainObjGetDefs instead of virDomainObjGetPersistentDef.

9 years agotest: Refactor test driver domain object retrieval
Peter Krempa [Tue, 16 Jun 2015 16:18:03 +0000 (18:18 +0200)]
test: Refactor test driver domain object retrieval

Reuse testDomObjFromDomain to retrieve domain objects in the rest of
the test driver instead of open-coding it in every API.

9 years agotest: Drop locked access to testDriver->domains
Peter Krempa [Mon, 22 Jun 2015 12:33:23 +0000 (14:33 +0200)]
test: Drop locked access to testDriver->domains

Only self-locking APIs are used and the pointer is immutable so there's
no need to lock the driver to access the domain list.

This patch removes locking partially for everything that will not be
converted to testDomObjFromDomain in the next patch.

9 years agotest: Finalize removal of locking from driver->eventState
Peter Krempa [Wed, 24 Jun 2015 10:56:21 +0000 (12:56 +0200)]
test: Finalize removal of locking from driver->eventState

Don't lock the driver when registering event callbacks.

9 years agotest: Refactor test driver event sending
Peter Krempa [Tue, 16 Jun 2015 16:35:57 +0000 (18:35 +0200)]
test: Refactor test driver event sending

Make testObjectEventQueue tolerant to NULL @event and move it so that it
does not require a prototype. Additionally we are now able to remove
locking when accessing driver->eventState, since it's using self-locking
APIs and the pointer is immutable.

9 years agotest: Use atomic access to @nextDomID in struct virTestDriver
Peter Krempa [Wed, 24 Jun 2015 13:08:47 +0000 (15:08 +0200)]
test: Use atomic access to @nextDomID in struct virTestDriver

9 years agotest: Annotate few fields of testDriver structure
Peter Krempa [Wed, 24 Jun 2015 10:46:19 +0000 (12:46 +0200)]
test: Annotate few fields of testDriver structure

Some of the fields are either immutable or self locking, so make a note
of that for future reference.

9 years agotest: Drop unused attribute @path from testDriver struct
Peter Krempa [Wed, 24 Jun 2015 09:25:44 +0000 (11:25 +0200)]
test: Drop unused attribute @path from testDriver struct

It's filled and then freed, but not used anywhere else.

9 years agotest: Extract common parts of test driver data allocation
Peter Krempa [Wed, 24 Jun 2015 09:06:24 +0000 (11:06 +0200)]
test: Extract common parts of test driver data allocation

9 years agotest: Extract code to free testDriver into testDriverFree
Peter Krempa [Mon, 22 Jun 2015 18:13:12 +0000 (20:13 +0200)]
test: Extract code to free testDriver into testDriverFree

Avoid reimplementing it 3 times.

9 years agotest: turn 'defaultConn' into a pointer
Peter Krempa [Mon, 22 Jun 2015 14:49:28 +0000 (16:49 +0200)]
test: turn 'defaultConn' into a pointer

9 years agotest: Drop useless forward declaration
Peter Krempa [Mon, 22 Jun 2015 14:34:22 +0000 (16:34 +0200)]
test: Drop useless forward declaration

9 years agotest: Rename testConn to testDriver
Peter Krempa [Mon, 22 Jun 2015 14:25:16 +0000 (16:25 +0200)]
test: Rename testConn to testDriver

9 years agoqemu: Avoid removing persistent config if migration fails
Luyao Huang [Thu, 25 Jun 2015 01:38:57 +0000 (09:38 +0800)]
qemu: Avoid removing persistent config if migration fails

When migration fails in qemuMigrationPrepareAny, we unconditionally call
qemuDomainRemoveInactive, which should only be called for transient
domains. The check for !vm->persistent was accidentally removed by
commit 540c339.

Signed-off-by: Luyao Huang <lhuang@redhat.com>
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agovz: Adapt to driver rename
Michal Privoznik [Thu, 25 Jun 2015 07:36:41 +0000 (09:36 +0200)]
vz: Adapt to driver rename

In the e6d180f07fb06 commit the parallels driver was renamed to vz.
However, there was a commit merged later, which was sent to the list
before the rename. The other commit is 6de12b026b73. Fix all the
missing renames.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agojson: enhance parser test
Eric Blake [Mon, 22 Jun 2015 21:14:04 +0000 (15:14 -0600)]
json: enhance parser test

We already enable the parser option to detect invalid UTF-8, but
didn't test it.  Also, JSON states that behavior of an object
with a duplicated key is undefined; we chose to reject it, but
were not testing it.

With the enhanced tests in place, we can simplify yajl2
initialization by relying on parser defaults being sane.

* src/util/virjson.c (virJSONValueFromString): Simplify.
* tests/jsontest.c (mymain): Test more bad usage.

Signed-off-by: Eric Blake <eblake@redhat.com>
9 years agojson: even stricter trailing garbage detection
Eric Blake [Mon, 22 Jun 2015 21:01:15 +0000 (15:01 -0600)]
json: even stricter trailing garbage detection

Since older yajl ignores trailing garbage, a client can cause
problems by intentionally ending the wrapper array early. Since
we already track nesting, it's not too much harder to reject
invalid nesting pops.

* src/util/virjson. (_virJSONParser): Add field.
(virJSONValueFromString): Set witness.
(virJSONParserHandleEndArray): Use it to catch abuse.
* tests/jsontest.c (mymain): Test it.

Signed-off-by: Eric Blake <eblake@redhat.com>
9 years agojson: reject trailing garbage
Eric Blake [Mon, 22 Jun 2015 20:18:34 +0000 (14:18 -0600)]
json: reject trailing garbage

Yajl 2 has a nice feature that it can be configured whether to
allow multiple JSON objects parsed from a single stream, defaulting
to off.  And yajl 1.0.12 at least provided a way to tell if all
input bytes were parsed, or if trailing bytes remained after a
valid JSON object was parsed.  But we target RHEL 6 yajl 1.0.7,
which has neither of these.  So fake it by always parsing '[...]'
instead, so that trailing garbage either trips up the array parse,
or is easily detected when unwrapping the result.

* src/util/virjson.c (virJSONValueFromString): With older json,
wrap text to avoid trailing garbage.
* tests/jsontest.c (mymain): Add tests for this.

Signed-off-by: Eric Blake <eblake@redhat.com>
9 years agojson: reject javascript comments
Eric Blake [Mon, 22 Jun 2015 20:18:33 +0000 (14:18 -0600)]
json: reject javascript comments

We have been allowing javascript style comments in JSON ever
since commit 9428f2c (v0.7.5), but qemu doesn't send them, and
they are not strict JSON.  Reject them for now; if we can later
prove that it is worthwhile, we can reinstate it at that point
(or even make it conditional, by adding a bool parameter to
the libvirt entry point).

* src/util/virjson.c (virJSONValueFromString): Don't enable
comment parsing.
* tests/jsontest.c (mymain): Test it.

Signed-off-by: Eric Blake <eblake@redhat.com>
9 years agojson: cope with older yajl semantics
Eric Blake [Mon, 22 Jun 2015 20:18:32 +0000 (14:18 -0600)]
json: cope with older yajl semantics

Commit ceb496e5 fails on RHEL 6, with yajl 1.0.7, because that
version of yajl returns yajl_status_insufficient_data when the
parser is waiting for the rest of a token (this enum value was
dropped in yajl 2, so we have to wrap it).  It also exposes a
problem where older yajl silently ignores trailing garbage after
a successful parse, so this patch works around that by changing
the testsuite.  Another more invasive patch can add tighter
semantics to json parsing, but this is sufficient for a minimal
clean backport.

While touching this, fix up our error message cleanup. Yajl
documents that error messages produced by yajl_get_error()
MUST be cleaned with yajl_free_error(); this is certainly
true if we were to pass non-NULL allocator callbacks during
yajl_alloc(), but probably harmless in our usage of passing
NULL.  But better safe than sorry.

* src/util/virjson.c (virJSONValueFromString): Allow different
error code.  Use canonical cleanup of error message.
(VIR_YAJL_STATUS_OK): New helper macro.
* tests/jsontest.c (mymain): Wrap text to avoid difference in
trailing garbage handling

Signed-off-by: Eric Blake <eblake@redhat.com>
9 years agovz: fix syntax-check errors
Dmitry Guryanov [Wed, 24 Jun 2015 19:36:19 +0000 (22:36 +0300)]
vz: fix syntax-check errors

Remove braces around single-statement blocks in vz_sdk.c

9 years agovz: implementation of attach/detach network devices
Mikhail Feoktistov [Mon, 22 Jun 2015 16:57:00 +0000 (19:57 +0300)]
vz: implementation of attach/detach network devices

In this patch we add VIR_DOMAIN_DEVICE_NET handlers implementation
for domainAttachDevice and domainDetachDevice callbacks.

As soon as we don't support this operation for hypervisor type domains,
we implement this functionality for containers only.

In detach procedure we find network device by MAC address.
Because PrlVmDevNet_GetMacAddress() returns MAC as a UTF-8 encoded
null-terminated string, we use memcmp() to compare it.
Also we remove corresponding virtual network by prlsdkDelNetAdapter call.

9 years agoTest for the new watchdog model diag288
Boris Fiuczynski [Wed, 24 Jun 2015 09:28:44 +0000 (11:28 +0200)]
Test for the new watchdog model diag288

Adding a test for the new watchdog model diag288.

Signed-off-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
9 years agoSupport for the new watchdog model diag288
Boris Fiuczynski [Wed, 24 Jun 2015 09:28:43 +0000 (11:28 +0200)]
Support for the new watchdog model diag288

This patch provides support for the new watchdog model "diag288".

Signed-off-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Reviewed-by: Daniel Hansel <daniel.hansel@linux.vnet.ibm.com>
Reviewed-by: Stefan Zimmermann <stzi@linux.vnet.ibm.com>
Reviewed-by: Tony Krowiak <akrowiak@linux.vnet.ibm.com>
9 years agoTest for the new watchdog action inject-nmi
Boris Fiuczynski [Wed, 24 Jun 2015 09:28:42 +0000 (11:28 +0200)]
Test for the new watchdog action inject-nmi

Adding a test for the new watchdog action "inject-nmi".

Signed-off-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
9 years agoSupport for a new watchdog action inject-nmi
Boris Fiuczynski [Wed, 24 Jun 2015 09:28:41 +0000 (11:28 +0200)]
Support for a new watchdog action inject-nmi

This patch provides support for a new watchdog action "inject-nmi" which
allows to define an inject of a non-maskable interrupt into a guest.

Signed-off-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Reviewed-by: Daniel Hansel <daniel.hansel@linux.vnet.ibm.com>
Reviewed-by: Stefan Zimmermann <stzi@linux.vnet.ibm.com>
Reviewed-by: Tony Krowiak <akrowiak@linux.vnet.ibm.com>
9 years agoscsi: Force error for SCSI pools on virStorageBackendSCSIFindLUs failure
John Ferlan [Tue, 23 Jun 2015 18:40:31 +0000 (14:40 -0400)]
scsi: Force error for SCSI pools on virStorageBackendSCSIFindLUs failure

Related to :

https://bugzilla.redhat.com/show_bug.cgi?id=1171933

Rather than ignore the return status from virStorageBackendSCSIFindLUs,
cause a failure to start the pool if a -1 is returned. Issue was noted
during testing of the bz for iscsi that 'scsi' and 'fc' pools don't fail.

9 years agovircapstest: Properly report error for failed tests
Michal Privoznik [Tue, 23 Jun 2015 11:05:01 +0000 (13:05 +0200)]
vircapstest: Properly report error for failed tests

There are two macros used in the test: CAPSCOMP and CAPS_EXPECT_ERR.
Both run a test case and if a failure occurred, they set the @ret
variable to a value of -1 to indicate an error. Well, that's what they
should do. Due to a typo, they set the variable to a positive one
effectively masking any failed test.

Then, we have couple of tests failing. Fix them too.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoconf: Adjust invalid secrettype setting during parse
John Ferlan [Mon, 15 Jun 2015 14:40:27 +0000 (10:40 -0400)]
conf: Adjust invalid secrettype setting during parse

Commit id '1feaccf0' attempted to handle an empty secrettype value; however,
it made a mistake by processing the secretType as if it was the original
secrettype string.  The 'secretType' is actually whether 'usage' or 'uuid'
was used.

Thus adjust part of the change to make the same check for def->src->type !=
VIR_STORAGE_TYPE_VOLUME before setting auth_secret_usage from the
secrettype field.

Luckily the aforementioned commits misdeed would be overwritten by the
call to virStorageTranslateDiskSourcePool

9 years agoconf: improve the way we format blkiotune and cputune
Luyao Huang [Tue, 23 Jun 2015 13:24:25 +0000 (21:24 +0800)]
conf: improve the way we format blkiotune and cputune

Just refactor existing code to use a child buf instead of
check all element before format <blkiotune> and <cputune>.
This will avoid the more and more bigger element check during
we introduce new elements in <blkiotune> and <cputune> in the
future.

Signed-off-by: Luyao Huang <lhuang@redhat.com>
9 years agodocs: Fix trivial copy-paste error
Martin Kletzander [Wed, 24 Jun 2015 08:16:56 +0000 (10:16 +0200)]
docs: Fix trivial copy-paste error

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoImprove some errors for openconsole/channel
Luyao Huang [Mon, 15 Jun 2015 13:58:36 +0000 (21:58 +0800)]
Improve some errors for openconsole/channel

Functions like virDomainOpenConsole() and virDomainOpenChannel() accept
NULL as a dev_name parameter.  Try using alias for the error message if
dev_name is not specified.

Before:
  error: internal error: character device <null> is not using a PTY

After:
  error: internal error: character device serial0 is not using a PTY

Signed-off-by: Luyao Huang <lhuang@redhat.com>
9 years agoconf: Enforce scheduler name when parsing XML
Peter Krempa [Tue, 23 Jun 2015 12:25:20 +0000 (14:25 +0200)]
conf: Enforce scheduler name when parsing XML

We require the scheduler name attribute in the schemas but the code
would actually be fine when it was omitted. Make it mandatory.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1234729

9 years agodocs: Properly mark acl.html dependencies
Michal Privoznik [Mon, 22 Jun 2015 15:17:38 +0000 (17:17 +0200)]
docs: Properly mark acl.html dependencies

The acl.html file includes aclperms.htmlinc which is generated.
However, acl.html is generated too from acl.html.tmp. And in fact,
this is the place where the aclperms file is needed. Fix the
dependency in Makefile.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agostorage: Force setting of disk format type
John Ferlan [Mon, 8 Jun 2015 12:16:58 +0000 (08:16 -0400)]
storage: Force setting of disk format type

Commit id '832a9256' adjusted the code to recognize when the default
type of "unknown" was provided as the format type and to use "dos" if
found. Since the pool is built with "dos" and it could cause some
confusion when formatting the XML after building by seeing "unknown"
in the output, let's just adjust the pool's setting to "dos" so that
subsequent formats will see the value.

9 years agodocs: Adjust Disk storage rng
John Ferlan [Mon, 8 Jun 2015 12:15:17 +0000 (08:15 -0400)]
docs: Adjust Disk storage rng

Currently the grammar uses "none" for a "valid" Disk Storage Pool
format type; however, virStoragePoolFormatDisk uses "unknown" so
virt-xml-validate will fail to validate when "unknown" is found

9 years agoadmin: Fix mingw build by reordering includes
Martin Kletzander [Tue, 23 Jun 2015 11:22:15 +0000 (13:22 +0200)]
admin: Fix mingw build by reordering includes

By trying to lead the way of clean includes, I sorted the lines
alphabetically and that is a problem for mingw builds with gnulib.
As 'configmake.h' defines DATADIR and 'datatypes.h' transitively
includes 'winsock.h' that uses 'DATADIR' as a name for a struct,
it's enough to reorder those.

Even though this might be worked around in gnulib later on, this
fixes the build for now.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agodocs: Correct typos in scsi hostdev and address elements
Eric Farman [Wed, 17 Jun 2015 03:29:55 +0000 (23:29 -0400)]
docs: Correct typos in scsi hostdev and address elements

The type='scsi' parameter of an address element is ignored
if placed within a hostdev section, and rejected by the XML
schema used by virt-xml-validate. Remove it from the doc,
and correct a typo in the remaining address arguments.

Signed-off-by: Eric Farman <farman@linux.vnet.ibm.com>
Reviewed-by: Matthew Rosato <mjrosato@linux.vnet.ibm.com>
Reviewed-by: Stefan Zimmermann <stzi@linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
9 years agodocs: Fix XML schema handling of LUN address in hostdev tag
Eric Farman [Wed, 17 Jun 2015 03:29:54 +0000 (23:29 -0400)]
docs: Fix XML schema handling of LUN address in hostdev tag

Defining a domain with a SCSI disk attached via a hostdev
tag and a source address unit value longer than two digits
causes an error when editing the domain with virsh edit,
even if no changes are made to the domain definition.
The error suggests invalid XML, somewhere:

  # virsh edit lmb_guest
  error: XML document failed to validate against schema:
  Unable to validate doc against /usr/local/share/libvirt/schemas/domain.rng
  Extra element devices in interleave
  Element domain failed to validate content

The virt-xml-validate tool fails with a similar error:

  # virt-xml-validate lmb_guest.xml
  Relax-NG validity error : Extra element devices in interleave
  lmb_guest.xml:17: element devices: Relax-NG validity error :
  Element domain failed to validate content
  lmb_guest.xml fails to validate

The hostdev tag requires a source address to be specified,
which includes bus, target, and unit address attributes.
According to the SCSI Architecture Model spec (section
4.9 of SAM-2), a LUN address is 64 bits and thus could be
up to 20 decimal digits long.  Unfortunately, the XML
schema limits this string to just two digits.  Similarly,
the target field can be up to 32 bits in length, which
would be 10 decimal digits.

  # lsscsi -xx
  [0:0:19:0x4022401100000000]  disk    IBM      2107900          3.44 /dev/sda
  # lsscsi
  [0:0:19:1074872354]disk    IBM      2107900          3.44  /dev/sda
  # cat lmb_guest.xml
  <domain type='kvm'>
    <name>lmb_guest</name>
    <memory unit='MiB'>1024</memory>
  ...trimmed...
    <devices>
      <controller type='scsi' model='virtio-scsi' index='0'/>
      <hostdev mode='subsystem' type='scsi'>
        <source>
          <adapter name='scsi_host0'/>
          <address bus='0' target='19' unit='1074872354'/>
        </source>
      </hostdev>
  ...trimmed...

Since the reference unit and target fields are used in
several places in the XML schema, create a separate one
specific for SCSI Logical Units that will permit the
greater length.  This permits both the validation utility
and the virsh edit command to succeed when a hostdev
tag is included.

Signed-off-by: Eric Farman <farman@linux.vnet.ibm.com>
Reviewed-by: Matthew Rosato <mjrosato@linux.vnet.ibm.com>
Reviewed-by: Stefan Zimmermann <stzi@linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
9 years agoConvert SCSI logical unit from unsigned int to unsigned long long
Eric Farman [Wed, 17 Jun 2015 03:29:53 +0000 (23:29 -0400)]
Convert SCSI logical unit from unsigned int to unsigned long long

The SCSI Architecture Model defines a logical unit address
as 64-bits in length, so change the field accordingly so
that the entire value could be stored.

Signed-off-by: Eric Farman <farman@linux.vnet.ibm.com>
9 years agoPrint SCSI address attributes bus, target, unit as unsigned integer
Eric Farman [Wed, 17 Jun 2015 03:29:52 +0000 (23:29 -0400)]
Print SCSI address attributes bus, target, unit as unsigned integer

The address elements are all unsigned integers, so we should
use the appropriate print directive when printing it.

Signed-off-by: Eric Farman <farman@linux.vnet.ibm.com>
9 years agoRead SCSI address attributes bus, target, unit as positive integer
Eric Farman [Wed, 17 Jun 2015 03:29:51 +0000 (23:29 -0400)]
Read SCSI address attributes bus, target, unit as positive integer

The SCSI address element attributes bus, target, and unit are expected
to be positive values, so make sure no one provides a negative value since
the value is stored as an unsigned.

Signed-off-by: Eric Farman <farman@linux.vnet.ibm.com>
9 years agoqemu: simplify json parsing
Eric Blake [Sat, 20 Jun 2015 19:40:21 +0000 (13:40 -0600)]
qemu: simplify json parsing

Rather than grabbing an arbitrary JSON value and then checking
if it has the right type, we might as well request the correct
type to begin with.

* src/qemu/qemu_monitor_json.c (qemuMonitorJSONIOProcessEvent)
(qemuMonitorJSONCommandWithFd, qemuMonitorJSONHandleGraphics)
(qemuMonitorJSONGetStatus, qemuMonitorJSONExtractCPUInfo)
(qemuMonitorJSONGetVirtType, qemuMonitorJSONGetBalloonInfo)
(qemuMonitorJSONGetMemoryStats)
(qemuMonitorJSONDevGetBlockExtent)
(qemuMonitorJSONGetOneBlockStatsInfo)
(qemuMonitorJSONGetAllBlockStatsInfo)
(qemuMonitorJSONBlockStatsUpdateCapacityOne)
(qemuMonitorJSONBlockStatsUpdateCapacity)
(qemuMonitorJSONGetBlockExtent)
(qemuMonitorJSONGetMigrationStatusReply)
(qemuMonitorJSONGetDumpGuestMemoryCapability)
(qemuMonitorJSONAddFd, qemuMonitorJSONQueryRxFilterParse)
(qemuMonitorJSONExtractChardevInfo)
(qemuMonitorJSONDiskNameLookupOne)
(qemuMonitorJSONDiskNameLookup)
(qemuMonitorJSONGetAllBlockJobInfo)
(qemuMonitorJSONBlockIoThrottleInfo, qemuMonitorJSONGetVersion)
(qemuMonitorJSONGetMachines, qemuMonitorJSONGetCPUDefinitions)
(qemuMonitorJSONGetCommands, qemuMonitorJSONGetEvents)
(qemuMonitorJSONGetKVMState, qemuMonitorJSONGetObjectTypes)
(qemuMonitorJSONGetObjectListPaths)
(qemuMonitorJSONGetObjectProps, qemuMonitorJSONGetTargetArch)
(qemuMonitorJSONGetMigrationCapabilities)
(qemuMonitorJSONGetStringArray, qemuMonitorJSONAttachCharDev)
(qemuMonitorJSONGetCPUx86Data, qemuMonitorJSONGetIOThreads)
(qemuMonitorJSONGetMemoryDeviceInfo): Use shorter idioms.

Signed-off-by: Eric Blake <eblake@redhat.com>
9 years agojson: make it easier to type-check when getting from object
Eric Blake [Fri, 19 Jun 2015 23:13:03 +0000 (17:13 -0600)]
json: make it easier to type-check when getting from object

While working in qemu_monitor_json, I repeatedly found myself
getting a value then checking if it was an object.  Add some
wrappers to make this task easier.

* src/util/virjson.c (virJSONValueObjectGetByType)
(virJSONValueObjectGetObject, virJSONValueObjectGetArray): New
functions.
(virJSONValueObjectGetString, virJSONValueObjectGetNumberInt)
(virJSONValueObjectGetNumberUint)
(virJSONValueObjectGetNumberLong)
(virJSONValueObjectGetNumberUlong)
(virJSONValueObjectGetNumberDouble)
(virJSONValueObjectGetBoolean): Simplify.
(virJSONValueIsNull): Change return type.
* src/util/virjson.h: Reflect changes.
* src/libvirt_private.syms (virjson.h): Export them.
* tests/jsontest.c (testJSONLookup): New test.

Signed-off-by: Eric Blake <eblake@redhat.com>
9 years agojson: fully parse input string
Eric Blake [Fri, 19 Jun 2015 23:28:22 +0000 (17:28 -0600)]
json: fully parse input string

I was adding a JSON test, and was shocked to find out our parser
treated the input string of "1" as invalid JSON.  It turns out
that YAJL specifically documents that it buffers input, and that
if the last input read could be a prefix to a longer token, then
you have to explicitly tell the parser that the buffer has ended
before that token will be processed.

It doesn't help that yajl 2 renamed the function from what it was
in yajl 1.

* src/util/virjson.c (virJSONValueFromString): Complete parse, in
case buffer ends in possible token prefix.
* tests/jsontest.c (mymain): Expose the problem.

Signed-off-by: Eric Blake <eblake@redhat.com>
9 years agotest: Switch to reference counting with testDomObjFromDomain
Peter Krempa [Tue, 16 Jun 2015 12:05:18 +0000 (14:05 +0200)]
test: Switch to reference counting with testDomObjFromDomain

Retrieve domain objects with reference and release them with
virDomainObjEndAPI.

9 years agotest: Reuse virDomainObjGetOneDef in testDomainGetVcpusFlags
Peter Krempa [Tue, 16 Jun 2015 08:10:59 +0000 (10:10 +0200)]
test: Reuse virDomainObjGetOneDef in testDomainGetVcpusFlags

The test driver copies the domain definition correctly so we can reuse
the helper.

9 years agovirsh: blockcopy: Report error if the copy job fails
Peter Krempa [Fri, 19 Jun 2015 13:43:02 +0000 (15:43 +0200)]
virsh: blockcopy: Report error if the copy job fails

When the block job would fail while watching it using the "--wait"
option for blockcopy, virsh would rather unhelpfully report:

$ virsh blockcopy vm hdc /tmp/raw.img --granularity 4096 --verbose --wait

Now in mirroring phase

Add a special case when the block job vanishes while waiting for it to
finish to improve the message:

$ virsh blockcopy vm hdc /tmp/raw.img --granularity 8192 --verbose --wait
error: Block Copy unexpectedly failed

9 years agovirQEMUCapsComputeCmdFlags: Indent correctly
Michal Privoznik [Mon, 22 Jun 2015 08:54:56 +0000 (10:54 +0200)]
virQEMUCapsComputeCmdFlags: Indent correctly

There's a small formatting problem in the function. One line is
not correctly indented. Fix this.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoqemu: caps: Fix syntax-check failure in version based capabilities
Peter Krempa [Mon, 22 Jun 2015 08:48:30 +0000 (10:48 +0200)]
qemu: caps: Fix syntax-check failure in version based capabilities

A single-line 'if' body should not be encased in curly braces. Our
syntax-check enforces it. Introduced in 7f3515b4bb677d0ead1887547efc844

9 years agoIntroduce QEMU_CAPS_ARM_VIRT_PCI
Pavel Fedin [Thu, 11 Jun 2015 06:40:53 +0000 (09:40 +0300)]
Introduce QEMU_CAPS_ARM_VIRT_PCI

This capability specifies that "virt" machine on ARM has PCI controller. Enabled when version is at least 2.3.0.

Signed-off-by: Pavel Fedin <p.fedin@samsung.com>