Commit Graph

14984 Commits

Author SHA1 Message Date
Jiri Denemark
7298abcfd2 cpu_map.xml: Expand 486 CPU model
Inheritance among CPU model is cool but it makes reviewing CPU model
definitions and comparing them to CPU models from QEMU rather hard and
unpleasant. Let's define all CPU models from scratch.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2015-07-02 10:09:39 +02:00
Jiri Denemark
eb9274b345 cpu_map.xml: Sort features in x86 CPU models
Sorted feature list is easier to review or compare.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2015-07-02 10:09:39 +02:00
John Ferlan
78f1aca076 phyp: Resolve Coverity FORWARD_NULL
Commit id 'cd490086' added a VIR_FORCE_CLOSE of the 'sock', but it
was after the VIR_FREE() of phyp_driver, resulting in a possible/likely
NULL dereference.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2015-07-01 12:15:20 -04:00
John Ferlan
c50c664de5 util: Resolve Coverity FORWARD_NULL
Convert virPCIDriverDir to return the buffer allocated (or not) and make the
appropriate check in the caller.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2015-07-01 12:15:16 -04:00
John Ferlan
e3939e86ba util: Resolve Coverity FORWARD_NULL
Convert virPCIDriverFile to return the buffer allocated (or not) and make the
appropriate check in the caller.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2015-07-01 12:15:12 -04:00
John Ferlan
d7ddb4c2f0 util: Resolve Coverity FORWARD_NULL
Convert virPCIFile to return the buffer allocated (or not) and make the
appropriate check in the caller.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2015-07-01 12:15:08 -04:00
Michal Privoznik
302146b16d lxc: Don't pass a local variable address randomly
So, recently I was testing the LXC driver. You know, startup some
domains. But to my surprise, I was not able to start a single one:

  virsh # start --console test
  error: Reconnected to the hypervisor
  error: Failed to start domain test
  error: internal error: guest failed to start: unexpected exit status 125

So I've start digging. It turns out, that in virExec(), when I printed
out the @cmd, I got strange values: *(cmd->outfdptr) was certainly not
valid FD number: it has random value of several millions. This
obviously made prepareStdFd(childout, STDOUT_FILENO) fail (line 611).
But outfdptr is set in virCommandSetOutputFD(). The only place within
LXC driver where the function is called is in
virLXCProcessBuildControllerCmd(). If you take a closer look at the
function it looks like this:

static virCommandPtr
virLXCProcessBuildControllerCmd(virLXCDriverPtr driver,
                                ..
                                int logfd,
                                const char *pidfile)
{
    ...
    virCommandSetOutputFD(cmd, &logfd);
    virCommandSetErrorFD(cmd, &logfd);
    ...
}

Yes, you guessed it. @logfd is passed into the function by value.
However, in the function we try to get its address (an address of a
local variable) which is no longer valid once function is finished and
stack is cleaned. Therefore when cmd->outfdptr is evaluated at any
point after this function, we may get a random number, depending on
what's currently on the stack. Of course, this may work sometimes too
- it depends on the compiler how it arranges the code, when the stack
is wiped out.

In order to fix this, lets pass a pointer to @logfd instead of
figuring out (wrong) its value in a function.

The bug was introduced in e1de5521.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-07-01 17:49:35 +02:00
John Ferlan
ebd62ebaaa qemu: Resolve Coverity DEADCODE
Commit id 'f967e7a6' didn't place the closing parentheses quite right
causing DEADCODE errors since the rc setting/comparison was wrong.
2015-07-01 06:28:12 -04:00
Peter Krempa
4b48ba4af5 conf: qemu: Taint VMs using custom device tree blob
Using a custom device tree image may cause unexpected behavior in
architectures that use this approach to detect platform devices. Since
usually the device tree is generated by qemu and thus it's not normally
used let's taint VMs using it to make it obvious as a possible source of
problems.
2015-07-01 10:34:25 +02:00
Peter Krempa
91081979dd qemu: Audit memory size with memory hotplug operations
The memory device hot(un)plug was missing calls to the auditing code.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1226234
2015-07-01 10:19:54 +02:00
Peter Krempa
1a13677460 conf: audit: Audit physical memory size rather than balloon request
Since the balloon driver does not guarantee that it returns memory to
the host, using the value in the audit message is not a good idea.

This patch removes auditing from updating the balloon size and reports
the total physical size at startup.
2015-07-01 10:18:10 +02:00
Jiri Denemark
ffbafd4e88 qemu: Avoid using ".(null)" in UNIX socket path
The code which generates paths for UNIX socket blindly used target name
without checking if it was set. Thus for the following device XML

    <channel type='unix'>
      <source mode='bind'/>
      <target type='virtio'/>
    </channel>

we would generate "/var/lib/libvirt/qemu/channel/target/NAME.(null)"
path which works but is not really correct. Let's not use the
".target_name" suffix at all if target name is not set.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2015-07-01 09:47:32 +02:00
Peter Krempa
18c9d1578b qemu: agent: Don't automatically disable CPU0 via guest agent
While CPU0 was made unpluggable in Linux a while ago it's not desirable
to unplug it since some parts of the kernel (suspend-to-ram) still
depend on it.

This patch fixes the vCPU selection code in libvirt so that it will not
be disabled.
2015-07-01 09:38:02 +02:00
Luyao Huang
91c9e4d920 qemu: End job even if exiting monitor after OpenGraphics(FD) fails
Signed-off-by: Luyao Huang <lhuang@redhat.com>
2015-07-01 08:36:48 +02:00
Ján Tomko
224456fc4a qemu: properly free addresses on non-serial chardev unplug
The target type comparison in qemuDomainDetachChrDevice
used the VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE enum, so virtio-serial
addresses were not freed properly for channel devices.

Call qemuDomainReleaseDeviceAddress uncoditionally and decide
based on the address type instead of the target/device types.
2015-07-01 08:09:43 +02:00
Luyao Huang
f967e7a669 qemu: fix address allocation on chardev attach
Also check the device type when deciding what type the address should
be. Commit 9807c47 (aiming to fix another error in address allocation)
only checked the target type, but its value is different for different
device types. This resulted in an error when trying to attach
a channel with target type 'virtio':

error: Failed to attach device from channel-file.xml
error: internal error: virtio serial device has invalid address type

Make the logic for releasing the address dependent only on
* the address type
* whether it was allocated earlier
to avoid copying the device and target type checks.

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

Signed-off-by: Luyao Huang <lhuang@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2015-07-01 08:09:43 +02:00
Jim Fehlig
04597f8f0d libxl: Set def->vcpus after successfully modifying live vcpu count
def->vcpus was never updated after successfully changing the live
vcpu count of a domain. Subsequent queries for vcpu info would
return incorrect results.  E.g.:

virsh vcpucount test
maximum      config         4
maximum      live           4
current      config         4
current      live           4

virsh setvcpus test 2

virsh vcpucount test
maximum      config         4
maximum      live           4
current      config         4
current      live           4

After patch, live current config is reported correctly:

virsh vcpucount test
maximum      config         4
maximum      live           4
current      config         4
current      live           2

While fixing this, noticed that the live config was not saved
to cfg->stateDir via virDomainSaveStatus. Save the live config
and change error handling of virDomainSave{Config,Status} to
log a message via VIR_WARN, instead of failing the entire
DomainSetVcpusFlags operation.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
2015-06-30 11:02:30 -06:00
Jim Fehlig
33be48d78e 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>
2015-06-30 11:02:30 -06:00
Jim Fehlig
4b53d0d4ac 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>
2015-06-30 11:02:30 -06:00
Jim Fehlig
29b154e29a 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>
2015-06-30 11:02:29 -06:00
John Ferlan
0b32838394 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.
2015-06-30 11:32:50 -04:00
John Ferlan
5cd985221b 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
2015-06-30 11:32:50 -04:00
John Ferlan
a77056bdb5 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).
2015-06-30 11:21:42 -04:00
John Ferlan
dbad001899 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
2015-06-30 08:47:02 -04:00
John Ferlan
c79ebf53b5 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.
2015-06-30 08:39:32 -04:00
Prerna Saxena
7e7dee4389 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>
2015-06-30 14:29:38 +02:00
Peter Krempa
ea1c7b652b 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
2184ade3a0.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1236438
2015-06-30 14:02:17 +02:00
Peter Krempa
15632a312e 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.
2015-06-30 13:50:52 +02:00
Peter Krempa
8df888a532 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
2015-06-30 13:50:45 +02:00
Peter Krempa
4e5d03957a Revert "Introduce QEMU_CAPS_ARM_VIRT_PCI"
The capability was not used up to the feature freeze.

This reverts commit 7f3515b4bb.
2015-06-30 13:31:18 +02:00
Peter Krempa
f1caa42777 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
2015-06-30 13:18:02 +02:00
John Ferlan
e66a4c0b53 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.
2015-06-30 06:49:49 -04:00
Andrea Bolognani
bb66d93c11 Fix typo incomaptible -> incompatible 2015-06-30 12:26:25 +02:00
Jiri Denemark
365b454ed9 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>
2015-06-30 10:31:29 +02:00
Martin Kletzander
f7d8aa44b0 Revert "Change livbirt version to 1.3.0 for the next release"
This reverts commit 9a8d916e89.

Also some changes that were introduced after that commit are fixed to
use 1.2.17 instead of 1.3.0
2015-06-28 11:34:30 +08:00
John Ferlan
782355a711 qemu: Resolve Coverity RESOURCE_LEAK
Commit id '15fa84acb' added the alias fetch, but forgot to free it.
2015-06-27 06:41:59 -04:00
Laine Stump
9a12b6cd8c 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).
2015-06-26 13:54:16 -04:00
Laine Stump
1e15be1bbc 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).
2015-06-26 13:51:33 -04:00
Laine Stump
1074fc5061 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.
2015-06-26 13:45:40 -04:00
Peter Krempa
78aefb5275 qemu: monitor: Remove qemuMonitorGetBlockExtent
Now that qemuMonitorGetAllBlockStatsInfo collects also wr_highest_offset
the whole function can be killed.
2015-06-26 16:41:24 +02:00
Peter Krempa
15fa84acbb qemu: Refactor qemuDomainGetBlockInfo
Change the code so that it queries the monitor when the VM is alive.
2015-06-26 16:41:24 +02:00
Peter Krempa
0d130a011c 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.
2015-06-26 16:41:24 +02:00
Peter Krempa
21578858c7 qemu: monitor: Fix indentation in qemuMonitorJSONGetOneBlockStatsInfo 2015-06-26 16:05:10 +02:00
Peter Krempa
14062e6fe5 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.
2015-06-26 16:05:10 +02:00
Peter Krempa
d637017f9b 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.
2015-06-26 16:00:15 +02:00
Nikolay Shirokovskiy
bb7d275d15 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>
2015-06-26 16:39:28 +03:00
Nikolay Shirokovskiy
b2f73ee22e 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>
2015-06-26 16:39:28 +03:00
Nikolay Shirokovskiy
b6c11c3910 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>
2015-06-26 16:39:28 +03:00
Nikolay Shirokovskiy
b249069d53 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>
2015-06-26 16:39:28 +03:00
Michal Privoznik
c3c16e694c 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>
2015-06-26 09:28:28 +02:00
Michal Privoznik
2bdcbb4ecc 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>
2015-06-26 09:28:28 +02:00
Michal Privoznik
dc1b034527 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>
2015-06-26 09:28:28 +02:00
Michal Privoznik
a35d2ce0c0 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>
2015-06-26 09:28:28 +02:00
Michal Privoznik
ed025db700 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>
2015-06-26 09:28:28 +02:00
Michal Privoznik
70d75ffc79 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>
2015-06-26 09:23:06 +02:00
Michal Privoznik
f8e9deb1d4 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>
2015-06-26 09:15:26 +02:00
Luyao Huang
786539d6bf 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>
2015-06-25 23:25:30 +02:00
Peter Krempa
774fd39984 test: Refactor testNodeGetCPUMap
Drop locking of the driver since it is not accessed and simplify the
code flow.
2015-06-25 15:09:11 +02:00
Peter Krempa
3dd859c0c2 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.
2015-06-25 15:09:02 +02:00
Peter Krempa
b69ffc5746 test: Refactor testDomainSetVcpusFlags
Remove the bogus flag check and refactor the code by using
virDomainObjGetDefs instead of virDomainObjGetPersistentDef.
2015-06-25 15:05:26 +02:00
Peter Krempa
d73561301e 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.
2015-06-25 14:22:17 +02:00
Peter Krempa
21be8e8ecc 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.
2015-06-25 14:09:48 +02:00
Peter Krempa
caf5aef4c5 test: Finalize removal of locking from driver->eventState
Don't lock the driver when registering event callbacks.
2015-06-25 14:09:48 +02:00
Peter Krempa
678059c064 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.
2015-06-25 14:09:48 +02:00
Peter Krempa
c1a34c87ea test: Use atomic access to @nextDomID in struct virTestDriver 2015-06-25 14:09:48 +02:00
Peter Krempa
beba6a0ec8 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.
2015-06-25 14:09:48 +02:00
Peter Krempa
64eaac81e5 test: Drop unused attribute @path from testDriver struct
It's filled and then freed, but not used anywhere else.
2015-06-25 14:09:48 +02:00
Peter Krempa
81be22617f test: Extract common parts of test driver data allocation 2015-06-25 14:09:48 +02:00
Peter Krempa
8b43335abb test: Extract code to free testDriver into testDriverFree
Avoid reimplementing it 3 times.
2015-06-25 14:09:48 +02:00
Peter Krempa
c54cfc4505 test: turn 'defaultConn' into a pointer 2015-06-25 14:09:47 +02:00
Peter Krempa
2d0d07fe5b test: Drop useless forward declaration 2015-06-25 14:09:47 +02:00
Peter Krempa
d0782da94e test: Rename testConn to testDriver 2015-06-25 14:09:47 +02:00
Luyao Huang
09444724bc 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>
2015-06-25 10:18:39 +02:00
Michal Privoznik
84d0286ef0 vz: Adapt to driver rename
In the e6d180f07f 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 6de12b026b. Fix all the
missing renames.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-06-25 09:36:41 +02:00
Eric Blake
cb005533ab 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>
2015-06-25 09:11:15 +02:00
Eric Blake
7e191fd939 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>
2015-06-25 09:11:15 +02:00
Eric Blake
7cd991b74c 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>
2015-06-25 09:11:15 +02:00
Eric Blake
54dbba5bc3 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>
2015-06-25 09:11:15 +02:00
Eric Blake
f2acaebd40 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>
2015-06-25 09:11:15 +02:00
Dmitry Guryanov
39618d4088 vz: fix syntax-check errors
Remove braces around single-statement blocks in vz_sdk.c
2015-06-24 22:36:19 +03:00
Mikhail Feoktistov
6de12b026b 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.
2015-06-24 18:39:01 +03:00
Boris Fiuczynski
b831c5b801 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>
2015-06-24 15:26:31 +02:00
Boris Fiuczynski
1238dc29af 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>
2015-06-24 15:26:31 +02:00
John Ferlan
1b695be173 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.
2015-06-24 09:18:59 -04:00
John Ferlan
13c59ac906 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
2015-06-24 06:20:52 -04:00
Luyao Huang
5d8ef8ad67 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>
2015-06-24 11:32:09 +02:00
Luyao Huang
898e76f0aa 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>
2015-06-24 10:11:56 +02:00
Peter Krempa
dc7339fc4f 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
2015-06-23 19:16:13 +02:00
John Ferlan
31d3af6fea 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.
2015-06-23 09:25:24 -04:00
Martin Kletzander
976abdf669 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>
2015-06-23 13:22:15 +02:00
Eric Farman
22b8a61756 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>
2015-06-22 16:03:33 -04:00
Eric Farman
3b7983ad6d 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>
2015-06-22 16:03:33 -04:00
Eric Farman
f714f52882 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>
2015-06-22 16:03:33 -04:00
Eric Blake
40783db3f9 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>
2015-06-22 10:38:39 -06:00
Eric Blake
58fd670335 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>
2015-06-22 10:38:21 -06:00
Eric Blake
ceb496e5f0 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>
2015-06-22 10:38:21 -06:00
Peter Krempa
207afcf677 test: Switch to reference counting with testDomObjFromDomain
Retrieve domain objects with reference and release them with
virDomainObjEndAPI.
2015-06-22 14:25:01 +02:00
Peter Krempa
0cce10714f test: Reuse virDomainObjGetOneDef in testDomainGetVcpusFlags
The test driver copies the domain definition correctly so we can reuse
the helper.
2015-06-22 14:24:56 +02:00
Michal Privoznik
50a9099262 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>
2015-06-22 10:59:06 +02:00
Peter Krempa
a08e796bba 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 7f3515b4bb
2015-06-22 10:48:30 +02:00
Pavel Fedin
7f3515b4bb 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>
2015-06-21 16:06:47 -04:00
Ian Campbell
cc99d240f5 libxl: avoid freeing an uninitialised bitmap
If vm->def->cputune.nvcpupin is 0 in libxlDomainSetVcpuAffinities (as
seems to be the case on arm) then the VIR_FREE after cleanup: would be
operating on an uninitialised pointer in map.map.

Fix this by using libxl_bitmap_init and libxl_bitmap_dispose in the
appropriate places (like VIR_FREE, libxl_bitmap_dispose is also
idempotent, so there is no double free on exit from the loop).

libxl_bitmap_dispose is slightly preferable since it also sets
map.size back to 0, avoiding a potential source of confusion.

This fixes the crashes we've been seeing in the Xen automated tests on
ARM.

I had a glance at the handful of other users of libxl_bitmap and none
of them looked to have a similar issue.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
2015-06-19 13:10:45 -06:00
Vasiliy Tolstov
ee4d2908dd update sheepdog client] update sheepdog client path
Nnever sheepdog versions have dog client binary
while old have collie. Check them both.

Signed-off-by: Vasiliy Tolstov <v.tolstov@selfip.ru>
2015-06-19 16:05:04 +02:00
Jiri Denemark
d823fa6f64 qemu: cancel drive mirrors when p2p connection breaks
When a connection to the destination host during a p2p migration drops,
we know we will have to cancel the migration; it doesn't make sense to
waste resources by trying to finish the migration. We already do so
after sending "migrate" command to QEMU and we should do it while
waiting for drive mirrors to become ready too.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2015-06-19 15:19:49 +02:00
Jiri Denemark
d29c45587b qemu: Refactor qemuMigrationWaitForCompletion
Checking status of all part of migration and aborting it when something
failed is a complex thing which makes the waiting loop hard to read.
This patch moves all the checks into a separate function similarly to
what was done for drive mirror loops.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2015-06-19 15:15:12 +02:00
Jiri Denemark
92b5bcccaa qemu: Don't pass redundant job name around
Instead of passing current job name to several functions which already
know what the current job is we can generate the name where we actually
need to use it.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2015-06-19 15:15:12 +02:00
Jiri Denemark
c1a7f199e8 qemu: Refactor qemuMigrationUpdateJobStatus
Once we start waiting for migration events instead of polling
query-migrate, priv->job.current will not be regularly updated anymore
because we will get the current status directly from the events. Thus
virDomainGetJob{Info,Stats} will have to query QEMU, but they can't just
blindly update priv->job.current structure. This patch introduces
qemuMigrationFetchJobStatus which just fills in a caller supplied
structure and makes qemuMigrationUpdateJobStatus a tiny wrapper around
it.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2015-06-19 15:15:12 +02:00
Jiri Denemark
30d94bcdec qemu: Refactor qemuDomainGetJob{Info,Stats}
Move common parts of qemuDomainGetJobInfo and qemuDomainGetJobStats into
a separate API (qemuDomainGetJobStatsInternal).

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2015-06-19 15:15:12 +02:00
Jiri Denemark
2ad46e5b0e qemu: Do not poll for spice migration status
QEMU_CAPS_SEAMLESS_MIGRATION capability says QEMU supports
SPICE_MIGRATE_COMPLETED event. Thus we can just drop all code which
polls query-spice and replace it with waiting for the event.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2015-06-19 15:15:11 +02:00
Jiri Denemark
bfbbb78ca3 qemu_monitor: Wire up SPICE_MIGRATE_COMPLETED event
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2015-06-19 15:15:11 +02:00
Jiri Denemark
d814c70b3b qemu: Use domain condition for asyncAbort
To avoid polling for asyncAbort flag changes.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2015-06-19 15:15:11 +02:00
Jiri Denemark
e8f263e0d0 qemu: Cancel disk mirrors after libvirtd restart
When libvirtd is restarted during migration, we properly cancel the
ongoing migration (unless it managed to almost finished before the
restart). But if we were also migrating storage using NBD, we would
completely forget about the running disk mirrors.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2015-06-19 15:15:11 +02:00
Jiri Denemark
3a18bd2d7a qemu: Refactor qemuMonitorBlockJobInfo
"query-block-jobs" QMP command returns all running block jobs at once,
while qemuMonitorBlockJobInfo would only report one. This is not very
nice in case we need to check several block jobs. This patch refactors
the monitor code to always parse all block jobs and store them in a
hash.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2015-06-19 15:15:11 +02:00
Jiri Denemark
40cd0290dc qemu: Make qemuMigrationCancelDriveMirror usable without async job
We don't have an async job when reconnecting to existing domains after
libvirtd restart.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2015-06-19 15:15:10 +02:00
Jiri Denemark
3a0f39bcd8 Pass domain object to private data formatter/parser
So that they can format private data (e.g., disk private data) stored
elsewhere in the domain object.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2015-06-19 15:15:10 +02:00
Jiri Denemark
b247d47f39 qemu: Don't mess with disk->mirrorState
This patch reverts commit 76c61cdca2.

VIR_DOMAIN_DISK_MIRROR_STATE_ABORT says we asked for a block job to be
aborted rather than saying it was aborted. Let's just use
VIR_DOMAIN_DISK_MIRROR_STATE_NONE consistently whenever a block job
finishes since no caller depends on VIR_DOMAIN_DISK_MIRROR_STATE_ABORT
(anymore) to check whether a block job failed or it was cancelled.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2015-06-19 15:15:10 +02:00
Jiri Denemark
a9ba39a1a7 qemu: Abort migration early if disk mirror failed
Abort migration as soon as we detect that some of the disk mirrors
failed. There's no sense in trying to finish memory migration first.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2015-06-19 15:15:10 +02:00
Jiri Denemark
cebb110f73 qemu: Cancel storage migration in parallel
Instead of cancelling disk mirrors sequentially, let's just call
block-job-cancel for all migrating disks and then wait until all
disappear.

In case we cancel disk mirrors at the end of successful migration we
also need to check all block jobs completed successfully. Otherwise we
have to abort the migration.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2015-06-19 15:15:10 +02:00
Jiri Denemark
4172b96a3e qemu: Use domain condition for synchronous block jobs
By switching block jobs to use domain conditions, we can drop some
pretty complicated code in NBD storage migration.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2015-06-19 15:15:10 +02:00
Jiri Denemark
39564891f8 qemu: Properly report failed migration
Because we are polling we may detect some errors after we asked QEMU for
migration status even though they occurred before. If this happens and
QEMU reports migration completed successfully, we would happily report
the migration succeeded even though we should have cancelled it because
of the other error.

In practise it is not a big issue now but it will become a much bigger
issue once the check for storage migration status is moved inside the
loop in qemuMigrationWaitForCompletion.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2015-06-19 15:13:16 +02:00
Jiri Denemark
e2cc0e667e qemu: Introduce qemuBlockJobUpdate
The wrapper is useful for calling qemuBlockJobEventProcess with the
event details stored in disk's privateData, which is the most likely
usage of qemuBlockJobEventProcess.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2015-06-19 15:13:16 +02:00
Jiri Denemark
e0713c4bed conf: Introduce per-domain condition variable
Complex jobs, such as migration, need to monitor several events at once,
which is impossible when each of the event uses its own condition
variable. This patch adds a single condition variable to each domain
object. This variable can be used instead of the other event specific
conditions.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2015-06-19 15:13:16 +02:00
Michal Privoznik
355d8f470f virNetServerServiceClose: Don't leak sockets
Well, if a server is being destructed, all underlying services and
their sockets should disappear with it. But due to bug in our
implementation this is not the case. Yes, we are closing the sockets,
but that's not enough. We must also:

1) Unregister them from the event loop
2) Unref the service for each socket

The last step is needed, because each socket callback holds a
reference to the service object. Since in the first step we are
unregistering the callbacks, they no longer need the reference.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-06-19 11:19:50 +02:00
Michal Privoznik
9ee5a79830 virNetSocket: Fix @watch corner case
Although highly unlikely, nobody says that virEventAddHandle()
can't return 0 as a handle to socket callback. It can't happen
with our default implementation since all watches will have value
1 or greater, but users can register their own callback functions
(which can re-use unused watch IDs for instance). If this is the
case, weird things may happen.

Also, there's a little bug I'm fixing too, upon
virNetSocketRemoveIOCallback(), the variable holding callback ID
was not reset. Therefore calling AddIOCallback() once again would
fail. Not that we are doing it right now, but we might.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-06-19 11:19:49 +02:00
Michal Privoznik
899e49a2e6 virNetSocketRemoveIOCallback: Be explicit about unref
When going through the code I've notice that
virNetSocketAddIOCallback() increases the reference counter of
@socket. However, its counter part RemoveIOCallback does not. It took
me a while to realize this disproportion. The AddIOCallback registers
our own callback which eventually calls the desired callback and then
unref the @sock. Yeah, a bit complicated but it works. So, lets note
this hard learned fact in a comment in RemoveIOCallback().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-06-19 11:19:24 +02:00
Peter Krempa
1d0fc8083c lib: setvcpus: Remove bogus flag check
Since VIR_DOMAIN_AFFECT_CURRENT is 0 the flag check does not make sense
as masking @flags with 0 will always equal to false.
2015-06-19 10:14:58 +02:00
John Ferlan
5c9fc1c11f scsi: Adjust return status from getBlockDevice
https://bugzilla.redhat.com/show_bug.cgi?id=1224233

Currently it's not possible to determine the difference between a
fatal memory allocation or failure to open/read the directory error
with a perhaps less fatal, I didn't find the "block" device in the
directory (which may be a disk entry without a block device).

In the case of the latter, we shouldn't cause failure to continue
searching in the caller (virStorageBackendSCSIFindLUs), rather we
should allow trying reading the next directory entry.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-06-18 17:14:00 +02:00
Pavel Boldin
93a19e283e qemu: migration: selective block device migration
https://bugzilla.redhat.com/show_bug.cgi?id=1203032

Implement a `migrate_disks' parameters for the QEMU driver. This multi-
value parameter can be used to explicitly specify what block devices
are to be migrated using the NBD server. Tunnelled migration using NBD
is to be done.

Signed-off-by: Pavel Boldin <pboldin@mirantis.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-06-18 16:46:09 +02:00
Pavel Boldin
5eb03b6ea0 util: add virTypedParamsAddStringList
The `virTypedParamsAddStringList' function provides interface to add a
NULL-terminated array of string values as a multi-value to the params.

Signed-off-by: Pavel Boldin <pboldin@mirantis.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-06-18 16:46:09 +02:00
Pavel Boldin
952907f540 util: virTypedParams{Filter,GetStringList}
Add multikey API:

 * virTypedParamsFilter that filters all the parameters with specified name.
 * virTypedParamsGetStringList that returns a list with all the values for
   specified name and string type.

Signed-off-by: Pavel Boldin <pboldin@mirantis.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-06-18 16:46:09 +02:00
Pavel Boldin
e9ef856520 util: multi-value parameters in virTypedParamsAdd*
Allow multi-value parameters to be build using virTypedParamsAdd*
functions by removing check for duplicates.

Signed-off-by: Pavel Boldin <pboldin@mirantis.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-06-18 16:46:09 +02:00
Pavel Boldin
a5250449de util: multi-value virTypedParameter
The `virTypedParamsValidate' function now can be instructed to allow
multiple entries for some of the keys. For this flag the type with
the `VIR_TYPED_PARAM_MULTIPLE' flag.

Add unit tests for this new behaviour.

Signed-off-by: Pavel Boldin <pboldin@mirantis.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-06-18 16:46:09 +02:00
Michal Privoznik
cb7297c150 qemuMigrationDriveMirror: Force raw format for NBD
When playing with disk migration lately, I've noticed this warning in
domain logs:

WARNING: Image format was not specified for 'nbd://masina:49153/drive-virtio-disk0' and probing guessed raw.
         Automatically detecting the format is dangerous for raw images, write operations on block 0 will be restricted.
         Specify the 'raw' format explicitly to remove the restrictions.

So I started digging into qemu source code to see what has triggered
the warning. I'd expect qemu to know formats of guest's disks since we
tell them on command line. This lead me to qmp_drive_mirror() where
the following can be found:

    if (!has_format) {
        format = mode == NEW_IMAGE_MODE_EXISTING ? NULL : bs->drv->format_name;
    }

So, format is automatically initialized from the disk iff mode !=
"existing". Unfortunately, in migration we are tied to use this mode
(NBD doesn't support creating new images). Therefore the only way to
avoid this warning is to pass format. The discussion on the mail-list [1]
resulted in the code that always forces NBD export as "raw" format.

[1] https://www.redhat.com/archives/libvir-list/2015-June/msg00153.html
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Pavel Boldin <pboldin@mirantis.com>
2015-06-18 16:46:09 +02:00
Michal Privoznik
9c5efd1afd qemuMigrationBeginPhase: Fix function header indentation
This function is returning a string (domain XML). Since d3ce7363
when it was first introduced, it was indented incorrectly:

static char
*qemuMigrationBeginPhase(..)

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-06-18 16:46:09 +02:00
Michal Privoznik
1049a8d8b4 virDomainDiskGetSource: Mark passed disk as 'const'
The disk is not changed anywhere in the function. Mark this fact
in the function header too.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-06-18 16:46:09 +02:00
Peter Krempa
87837b487b qemu: Fix double space in error message in qemuDomainGetVcpusFlags 2015-06-18 15:31:52 +02:00
Peter Krempa
99e4c1d6fd qemu: Jump to correct label in qemuDomainPinIOThread
If virDomainObjGetDefs used in qemuDomainPinIOThread would fail the code
would jump to the 'cleanup' label after acquiring the job, thus the VM
would be locked forever.

Introduced in commit cac6d639.
2015-06-18 15:29:20 +02:00
Peter Krempa
dd03d77309 conf: Move vcpu info parsing code into a separate function 2015-06-18 15:13:46 +02:00
Peter Krempa
0b416434f8 qemu: 'privileged' flag is not really configuration
The privileged flag will not change while the configuration might
change. Make the 'privileged' flag member of the driver again and mark
it immutable. Should that ever change add an accessor that will group
reads of the state.
2015-06-18 15:13:45 +02:00
Peter Krempa
58edccb4a5 qemu: Reuse virDomainObjGetDefs in qemuDomainGetMemoryParameters
Simplify the code by restructuring control flow and reusing the better
helper.
2015-06-18 15:13:45 +02:00
Peter Krempa
68ba0d8a89 qemu: Refactor qemuDomainGetMemoryParameters
Replace the for loops with case inside with temp variables and a macro.
2015-06-18 15:13:45 +02:00
Peter Krempa
809ba20ebe qemu: Refactor qemuDomainSetNumaParameters
Use virDomainObjGetDefs and sanitize the control flow.
2015-06-18 15:13:45 +02:00
Peter Krempa
caa6cd39cc qemu: Simplify qemuDomainSetInterfaceParameters by using virDomainObjGetDefs 2015-06-18 15:13:45 +02:00
Peter Krempa
875a731d21 qemu: Simplify qemuDomainGetVcpusFlags by using virDomainObjGetOneDef
virDomainObjGetOneDef is simpler to use than virDomainObjGetDefs
2015-06-18 15:13:45 +02:00
Peter Krempa
f3a7006545 qemu: Simplify qemuDomainGetEmulatorPinInfo by using virDomainObjGetOneDef
virDomainObjGetOneDef is simpler to use than virDomainObjGetDefs
2015-06-18 15:13:45 +02:00
Peter Krempa
2881c381a0 qemu: Simplify qemuDomainGetVcpuPinInfo by using virDomainObjGetOneDef
virDomainObjGetOneDef is simpler to use than virDomainObjGetDefs
2015-06-18 15:13:45 +02:00
Peter Krempa
3f0fe2dcb2 qemu: Simplify qemuDomainGetNumaParameters by using virDomainObjGetOneDef 2015-06-18 15:13:45 +02:00
Peter Krempa
7d91a2d944 qemu: Simplify qemuDomainGetInterfaceParameters by using virDomainObjGetOneDef 2015-06-18 15:13:45 +02:00
Peter Krempa
47171cd1a6 conf: Introduce helper to help getting correct def for getter functions
virDomainObjGetOneDef will help to retrieve the correct definition
pointer from @vm in cases where VIR_DOMAIN_AFFECT_LIVE and
VIR_DOMAIN_AFFECT_CONFIG are mutually exclusive. The function simply
returns the correct pointer. This similarly to virDomainObjGetDefs will
greatly simplify the code.
2015-06-18 15:13:44 +02:00
Peter Krempa
63aaf69bbe conf: Fix virDomainObjGetDefs when getting persistent config on a live vm
If @flags contains only VIR_DOMAIN_AFFECT_CONFIG and @vm is active, the
function would return the active config rather than the persistent one
that it should return. This happened due to the fact that
virDomainObjGetDefs was checking the updated flags which may not contain
VIR_DOMAIN_AFFECT_LIVE if it is not requested even if @vm is active.

Additionally the function would not take the flags into account when
setting the pointers which was later used to determine whether the code
needs to update the given configuration.

The mistake was caught by the virt-test suite.
2015-06-18 15:13:44 +02:00
James Cowgill
f486bb0494 qemu: implement address for isa-serial
I needed to specify the iobase address for certain exotic mips configurations.

Signed-off-by: James Cowgill <james410@cowgill.org.uk>
2015-06-18 08:17:20 -04:00
Luyao Huang
cb7e13ffbf qemu: Add a check for slot and base dimm address conflicts
When hotplugging a memory device, there wasn't a check to determine
if there is a conflict with the address space being used by the to
be added memory device and any existing device which is disallowed by qemu.

This patch adds a check to ensure the new device address doesn't
conflict with any existing device.

Signed-off-by: Luyao Huang <lhuang@redhat.com>
2015-06-18 08:08:42 -04:00
Peter Krempa
4002395dd7 rpc: Actually increase reference count on @srv in virNetDaemonAddServer
VIR_APPEND_ELEMENT would clear @srv to NULL after it successfully
inserted it thus the reference count could not be increased afterwards.

Switch to VIR_APPEND_ELEMENT_COPY. This fixes crash after terminating
the daemon.
2015-06-18 13:32:37 +02:00
Mikhail Feoktistov
0c151004bc parallels: Fix false error messages in libvirt log
There was many errors in libvirt.log caused by prlsdkDelNet function because
job variable was always initialized as PRL_INVALID_HANDLE
In this patch job variable gets return value of PrlSrv_DeleteVirtualNetwork function()
2015-06-18 14:08:55 +03:00
Mikhail Feoktistov
fad9b77e0d parallels: Fix initialization of buflen variable in each loop iteration
We need to initialize buflen every time when we get network adapter's
friendly name because we call PrlVmDev_GetFriendlyName in a loop
2015-06-18 14:08:48 +03:00
Ján Tomko
6fab625f96 remove redundant condition
If the address type is SPAPRVIO, it will match the != NONE condition.
2015-06-18 12:13:00 +02:00
Michal Privoznik
a9a27e602c virSysinfo: Introduce SMBIOS type 2 support
https://bugzilla.redhat.com/show_bug.cgi?id=1220527

This type of information defines attributes of a system
baseboard. With one exception: board type is yet not implemented
in qemu so it's not introduced here either.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-06-18 10:10:26 +02:00
Jiri Denemark
beca509e43 qemu: Report all supported machine types in capabilities
Some machine types are only reported as canonical names for other
machine types, which make it a bit harder to find what machine types are
supported by a specific QEMU binary. Ideally, one would just use
/capabilities/guest/arch[@name='...']/machine/text() XPath to get a list
of all supported machine types, but it doesn't work right now.

For example, we report

    <machine canonical='pc-i440fx-2.3' maxCpus='255'>pc</machine>

in guest capabilities, but the corresponding

    <machine maxCpus='255'>pc-i440fx-2.3</machine>

is missing.

This is a result of QMP probing. With "-machine ?" parsing QEMU sends
us two lines:

pc                   Standard PC (i440FX + PIIX, 1996) (alias of pc-i440fx-2.3)
pc-i440fx-2.3        Standard PC (i440FX + PIIX, 1996) (default)

while query-machines QMP command reports both in the same entry:

{"name": "pc-i440fx-2.3", "is-default": true, "cpu-max": 255, "alias": "pc"}

Let's make sure we always report separate <machine/> for both the
canonical name and its alias and using the canonical name as the default
machine type (i.e., inserting it before its alias) in case is-default is
true.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2015-06-18 09:49:33 +02:00
Laine Stump
307081796e nodedev: update netdev feature bits before each dumpxml
As with several other attributes of devices (link status, sriov VF
list, IOMMU group list), the detdev feature bits aren't automatically
updated in the nodedev driver's cache when they change. In order to
get a properly up-to-date list when getting the XML of a device, we
must reget them in update-caps prior to each dumpxml.

This resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1232880
2015-06-17 13:51:33 -04:00
Maxim Nestratov
9156991668 parallels: substitute parallels with vz spec file and Makefile
Since we have changed the name of the driver to vz, let's
reference it as vz everywhere.

Signed-off-by: Maxim Nestratov <mnestratov@parallels.com>
2015-06-17 15:07:55 +03:00
Maxim Nestratov
e6d180f07f parallels: rename all parallels files and driver directory to vz
This patch moves all src/parallels/parallels* files to vz/vz*
and fixes build accordingly.
No functional changes.

Signed-off-by: Maxim Nestratov <mnestratov@parallels.com>
2015-06-17 15:07:55 +03:00
Maxim Nestratov
df75e5f624 parallels: substitute parallels with vz in strings
Here we stop referencing vz driver by different names
in error messages. 'parallels driver', 'Parallels Cloud
Server', 'Parallels driver' all become just 'vz driver'.
No functional changes. Only renaming and a bit of rewording.

Signed-off-by: Maxim Nestratov <mnestratov@parallels.com>
2015-06-17 15:07:55 +03:00
Maxim Nestratov
9c70b91ea8 parallels: change parallels prefixes to vz
This patch changes all parallels/vz driver structure and
function prefixes from parallels to vz.
No functional changes.

Signed-off-by: Maxim Nestratov <mnestratov@parallels.com>
2015-06-17 15:07:54 +03:00
Erik Skultety
4e6ee877d4 virfile: virDirCreate: Insert blank lines to assure slightly better readability 2015-06-16 16:26:20 +02:00
Erik Skultety
e9478d9a8b util: virfile: Fix 'unknown cause' error if NFS mount point creation fails
This happens if user requires creation of a directory with specified
UID/GID permissions. To accomplish this, we use fork approach and
set particular UID/GID permissions in child process. However, child
process doesn't have a valid descriptor to a logfile (this is prohibited
explicitly) and since parent process doesn't handle negative exit codes from
child in any way, 'uknown cause' error is returned to the user.

Commit 92d9114e tweaked the way we handle child errors when using fork
approach to set specific permissions (features originally introduced
by 98f6f381). The same logic should be used to create directories with
specified permissions as well.

https://bugzilla.redhat.com/show_bug.cgi?id=1230137
2015-06-16 16:26:20 +02:00
Erik Skultety
fdcb057a28 util: virDirCreate: Child now exits with positive errno-code
Previous patch of this series proposed a fix to virDirCreate, so that parent
process reports an error if child process failed its task.
However our logic still permits the child to exit with negative errno followed
by a check of the status on the parent side using WEXITSTATUS which, being
POSIX compliant, takes the lower 8 bits of the exit code and returns is to
the caller. However, by taking 8 bits from a negative exit code
(two's complement) the status value we read and append to stream is
'2^8 - abs(original exit code)' which doesn't quite reflect the real cause when
compared to the meaning of errno values.
2015-06-16 16:26:20 +02:00
Eric W. Biederman
24710414d4 lxc: set nosuid+nodev+noexec flags on /proc/sys mount
Future kernels will mandate the use of nosuid+nodev+noexec
flags when mounting the /proc/sys filesystem. Unconditionally
add them now since they don't harm things regardless and could
mitigate future security attacks.
2015-06-16 14:44:36 +01:00
John Ferlan
ad5fd9b87b util: Fix Coverity RESOURCE_LEAK
Commit id 'e44b0269c9' in advertently checked !dir before calling closedir
2015-06-16 09:15:10 -04:00
Martin Kletzander
4ec52c364b lxc: Rename daemon to dmn
On older systems it shadows global declaration of daemon() function.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2015-06-16 14:59:33 +02:00
Martin Kletzander
58031cb4b5 netserver: Remove duplicate forward declaration
Commit fa14207368 added forward
declaration of virNetServerPtr into virnetserver.h even though we are
keeping these in virnetserverprogram.h due to older compilers having
problems with duplicate ones.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2015-06-16 14:58:00 +02:00
Martin Kletzander
40082a7000 Revert "rpc: Add virNetServerGetNClients"
This reverts commit 6bda9f8aa2.

I mistakenly pushed it along with the Admin API series.
2015-06-16 14:09:09 +02:00
Martin Kletzander
2cc6c652cf Revert "admin: Add virAdmHello function"
This reverts commit 5792fabb7b.

I mistakenly pushed it along with the Admin API series.
2015-06-16 14:08:59 +02:00
Martin Kletzander
9a8d916e89 Change livbirt version to 1.3.0 for the next release
Since the background for Admin API is merged upstream, we are bumping
the minor release version as discussed previously

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2015-06-16 13:46:22 +02:00
Martin Kletzander
5792fabb7b admin: Add virAdmHello function
Just one of the simplest functions that returns string "Clients: X"
where X is the number of connected clients to daemon's first
subserver (the original one), so it can be tested using virsh, ipython,
etc.

The subserver is gathered by incrementing its reference
counter (similarly to getting qemu capabilities), so there is no
deadlock with admin subserver in this API.

Here you can see how functions should be named in the client (virAdm*)
and server (adm*).

There is also a parameter @flags that must be 0, which helps testing
proper error propagation into the client.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2015-06-16 13:46:21 +02:00
Martin Kletzander
6bda9f8aa2 rpc: Add virNetServerGetNClients
This function accesses the number of connected clients while properly
locking the server it returns the data about.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2015-06-16 13:46:21 +02:00
Martin Kletzander
55e0c840af Add libvirt-admin library
Initial scratch of the admin library.  It has its own virAdmConnectPtr
that inherits from virAbstractConnectPtr and thus trivially supports
error reporting.

There's pkg-config file added and spec-file adjusted as well.

Since the library should be "minimalistic" and not depend on any other
library, the list of files is especially crafted for it.  Most of them
could've been put to it's own sub-libraries that would be LIBADD'd to
libvirt_util, libvirt_net_rpc and libvirt_setuid_rpc_client to minimize
the number of object files being built, but that's a refactoring that
isn't the orginal aim of this commit.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2015-06-16 13:46:20 +02:00
Martin Kletzander
653acbfd62 Add admin error domain
Just the addition of VIR_FROM_ADMIN to the enum of error domains.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2015-06-16 13:46:20 +02:00
Martin Kletzander
fb5a0d3388 Build client headers for admin protocol
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2015-06-16 13:46:20 +02:00
Martin Kletzander
8c8bed02af Add admin protocol
For now there are only CONNECT_OPEN and CONNECT_CLOSE procedures.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2015-06-16 13:46:20 +02:00
Martin Kletzander
87c2687943 Teach gendispatch how to handle admin dispatching files
Since this is just a new option for gendispatch, it looks more like a
cleanup.  The only differences handled by it are connect pointers,
private pointers and API naming customs.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2015-06-16 13:46:20 +02:00
Martin Kletzander
fa14207368 Move daemon-related parts of virNetServer to virNetDaemon
This allows to have more servers in one daemon which helps isolating
some resources.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2015-06-16 13:46:19 +02:00
Cédric Bosdonnat
387cb8c6b2 lxc: properly clean up qemu-nbd
Add the qemu-nbd tasks to the container cgroup to make sure those will
be killed when the container is stopped. In order to reliably get the
qemu-nbd tasks PIDs, we use /sys/devices/virtual/block/<DEV>/pid as
qemu-nbd is daemonizing itself.
2015-06-16 12:38:11 +02:00
Cédric Bosdonnat
e44b0269c9 Add virProcessGetPids to get all tasks of a process
This function gets all the PIDs listed in /proc/PID/task. This will be
needed at least to move all qmeu-nbd tasks to the container cgroup.
2015-06-16 12:38:03 +02:00
John Ferlan
29230951f1 storage: Generate correct parameters for CIFS
https://bugzilla.redhat.com/show_bug.cgi?id=1186969

When generating the path to the dir for a CIFS/Samba driver, the code
would generate a source path for the mount using "%s:%s" while the
mount.cifs expects to see "//%s/%s". So check for the cifsfs and
format the source path appropriately.

Additionally, since there is no means to authenticate, the mount
needs a "-o guest" on the command line in order to anonymously mount
the Samba directory.
2015-06-15 17:25:47 -04:00
John Ferlan
257250f764 storage: Adjust command arglist for gluster
In order for the glusterfs boolean to be set, the pool->def->type must be
VIR_STORAGE_POOL_NETFS, thus the check within virCommandNewArgList whether
pool->def->type is VIR_STORAGE_POOL_FS will never be true, so remove it
2015-06-15 17:25:47 -04:00
Martin Kletzander
fcc2aab688 rpc: Fix possible crash when MDNSAddEntry fails
If virNetServerMDNSAddEntry() fails when adding a service to a server,
it doesn't decrease the number of services.  Hence access to their
members segfaults (e.g. when free()-ing the sruct).

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2015-06-15 17:12:59 +02:00
Martin Kletzander
5e55534b9a build: Remove unnecessarily repeated rules for syms -> def
Suggested-by: Michal Prívozník <mprivozn@redhat.com>
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2015-06-15 17:12:59 +02:00
Boris Fiuczynski
840eca32ab qemu: monitor: Add memory balloon support for virtio-ccw
The search for the memory balloon driver object is extended by a
second known name "virtio-balloon-ccw" in support for virtio-ccw.

Signed-off-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Reviewed-by: Daniel Hansel <daniel.hansel@linux.vnet.ibm.com>
Reviewed-by: Eric Farman <farman@linux.vnet.ibm.com>
Reviewed-by: Stefan Zimmermann <stzi@linux.vnet.ibm.com>
2015-06-15 17:05:32 +02:00
Peter Krempa
4ed2b9a7e4 qemu: emulatorpin: Don't reset pinning when pinning to all cpus
Similarly to a02a161bb8 remove the default
pinning assumption from emulatorpin.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1227180
2015-06-15 16:18:49 +02:00
Michal Privoznik
c4bdfafcbb getOldStyleBlockDevice: Adjust formatting
Instead of initializing return value to zero (success) and overwriting
it on every failure just before the control jumps onto 'out' label,
let's initialize to an error value and set to zero only when we are
sure about the success. Just follow the pattern we have in the rest of
the code.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-06-15 14:13:39 +02:00
Michal Privoznik
71b66bec2b getNewStyleBlockDevice: Adjust formatting
Instead of initializing return value to zero (success) and overwriting
it on every failure just before the control jumps onto 'out' label,
let's initialize to an error value and set to zero only when we are
sure about the success. Just follow the pattern we have in the rest of
the code.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-06-15 14:13:34 +02:00
John Ferlan
84020f9a39 storage: Disallow wiping an extended disk partition
https://bugzilla.redhat.com/show_bug.cgi?id=1225694

Check if the disk partition to be wiped is the extended partition, if
so then disallow it. Do this via changing the wipeVol backend to check
the volume before passing to the common virStorageBackendVolWipeLocal
2015-06-15 07:45:06 -04:00
Ján Tomko
243bbcc5db qemu caps: spell queue 2015-06-15 13:32:44 +02:00
John Ferlan
4fce9e8479 qemu: Do not support 'serial' scsi-block 'lun' devices
https://bugzilla.redhat.com/show_bug.cgi?id=1021480

Seems the property has been deprecated for qemu, although seemingly ignored.

This patch enforces from a libvirt perspective that a scsi-block 'lun'
device should not provide the 'serial' property.
2015-06-15 07:30:29 -04:00
John Ferlan
1feaccf000 storage: Need to set secrettype for direct iscsi disk volume
https://bugzilla.redhat.com/show_bug.cgi?id=1200206

Commit id '1b4eaa61' added the ability to have a mode='direct' for
an iscsi disk volume.  It relied on virStorageTranslateDiskSourcePool
in order to copy any disk source pool authentication information to
the direct disk volume, but it neglected to also copy the 'secrettype'
field which ends up being used in the domain volume formatting code.
Adding a secrettype for this case will allow for proper formatting later
and allow disk snapshotting to work properly

Additionally libvirtd restart processing would fail to find the domain
since the translation processing code is run after domain xml processing,
so handle the the case where the authdef could have an empty secrettype
field when processing the auth and additionally ignore performing the
actual and expected auth secret type checks for a DISK_VOLUME since that
data will be reassembled later during translation processing of the
running domain.
2015-06-15 07:14:40 -04:00
Michal Privoznik
f886701290 virCapabilitiesDomainDataLookup: Produce saner error message
During a review, I've noticed this error message that was eventually
produced when I was trying to define a domain:

error: invalid argument: could not find capabilities for arch=mips64el
domaintype=(null)

Look at the (null). Why is it there? Well, during XML parsing, we try
to look up the default emulator for given OS type and possibly virt
type too. And this is the problem, because if we don't want to look up
by virt type, a -1 is passed to note this fact. Later, the code
handles -1 just right. Except for error message. When it is
constructed (in a very fabulous way I must say), the value is compared
to zero, not -1. And since we don't have any translation from -1 to a
virt type string, we just print (null).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-06-15 07:29:37 +02:00
Anthony PERARD
bcf1349bb1 libxl: Add timestamp to the libxl driver log.
Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
2015-06-12 19:13:59 -06:00
zhang bo
798461a1a3 qemu: update netdevs of the same mac addrs correctly
If a guest has multiple network devices with the same MAC address,
when we online update the second device, libvirtd always updates
the first one.

commit def31e4c forgot to fix the online updating scenario. We need to
use virDomainNetFindIdx() to find the correct network device.

Signed-off-by: Zhou Yimin <zhouyimin@huawei.com>
Signed-off-by: Zhang Bo <oscar.zhangbo@huawei.com>
2015-06-12 13:04:39 -04:00
John Ferlan
785a8940ef scsi: Need to translate disk source pool in config attach path
https://bugzilla.redhat.com/show_bug.cgi?id=1228007

When attaching a scsi volume lun via the attach-device --config or
--persistent options, there was no translation of the source pool
like there was for the live path, thus the attempt to modify the config
would fail since not enough was known about the disk.
2015-06-12 12:20:36 -04:00
Michal Privoznik
c1dff918c9 virsysinfo: s/system/sysdef/
A variable can't be named system, obviously. Well, it can if the
compiler is new enough to distinguish a variable named system and a
function call system(). And some older systems, don't have wise
compiler.

  CC     util/libvirt_util_la-virsysinfo.lo
cc1: warnings being treated as errors
../../src/util/virsysinfo.c: In function 'virSysinfoParseSystem':
../../src/util/virsysinfo.c:649: error: declaration of 'system' shadows a global declaration [-Wshadow]
/usr/include/stdlib.h:717: error: shadowed declaration is here [-Wshadow]
make[3]: *** [util/libvirt_util_la-virsysinfo.lo] Error 1

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-06-12 17:43:38 +02:00
Michal Privoznik
87c81cd5ee qemuBuildDriveStr: s/virBufferEscapeString/virBufferAsprintf/
We are using it to print a value that can't be NULL and does not need
any escaping anyway.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-06-12 16:44:24 +02:00
Michal Privoznik
c88bf57262 virQEMUCapsArch: openrisc vs or32
With a few exceptions, we assume that qemu binary for given
architecture has form of qemu-system-$arch. Well, openrisc is yet
another exception. It's binary is called qemu-system-or32.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-06-12 16:44:24 +02:00
Michal Privoznik
0b92974c15 virSysinfoDef: Exempt SYSTEM variables
Move all the system_* fields into a separate struct. Not only this
simplifies the code a bit it also helps us to identify whether BIOS
info is present. We don't have to check all the four variables for
being not-NULL, but we can just check the pointer to the struct.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-06-12 10:42:39 +02:00
Michal Privoznik
3f9cae18fe virSysinfoDef: Exempt BIOS variables
Move all the bios_* fields into a separate struct. Not only this
simplifies the code a bit it also helps us to identify whether BIOS
info is present. We don't have to check all the four variables for
being not-NULL, but we can just check the pointer to the struct.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-06-12 10:42:34 +02:00
Martin Kletzander
d9a610f90c util: add virJSONValueCopy
Faster version of virJSONValueFromString(virJSONValueToString()).

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2015-06-11 15:39:30 +02:00
Maxime Leroy
366c22f2bc qemu: add multiqueue vhost-user support
This patch adds the support of queues attribute of the driver element
for vhost-user interface type. Example:

<interface type='vhostuser'>
      <mac address='52:54:00:ee:96:6d'/>
      <source type='unix' path='/tmp/vhost2.sock' mode='client'/>
      <model type='virtio'/>
      <driver queues='4'/>
</interface>

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

Signed-off-by: Maxime Leroy <maxime.leroy@6wind.com>
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2015-06-11 14:28:29 +02:00
Martin Kletzander
7971723b98 qemu: Add capability for vhost-user multiqueue
The support for this was added in QEMU with commit
830d70db692e374b55555f4407f96a1ceefdcc97.  Unfortunately we have to do
another ugly version-based capability check.  The other option would be
not to check for the capability at all and leave that to qemu as it's
done with multiqueue tap devices.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2015-06-11 14:18:41 +02:00
Martin Kletzander
181e02dfda conf: Ignore multiqueue with one queue.
Multi != One.  And indeed, libvirt behaves the same way for queues='1'
as without such setting.  Let's make it clear in the XML.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2015-06-11 14:17:46 +02:00
Peter Krempa
b0d2e31c5f util: Make virProcessGetAffinity more readable and fix coverity warning
Store the cpu count in an intermediate variable and reuse it rather than
caluclating the index.

Additionally add a coverity silencing comment.
2015-06-11 13:59:28 +02:00
Daniel P. Berrange
43c0a84cda rpc: add API for checking IPv4/6 availability
The socket test suite has a function for checking if IPv4
or IPv6 are available, and returning a free socket. The
first bit of that will be needed in another test, so pull
that logic out into a separate helper method.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2015-06-11 12:11:18 +01:00
Daniel P. Berrange
d587704cc7 rpc: allow selection of TCP address family
By default, getaddrinfo() will return addresses for both
IPv4 and IPv6 if both protocols are enabled, and so the
RPC code will listen/connect to both protocols too. There
may be cases where it is desirable to restrict this to
just one of the two protocols, so add an 'int family'
parameter to all the TCP related APIs.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2015-06-11 12:11:18 +01:00
Michal Privoznik
1c24cfe9d8 virNumaSetPagePoolSize: Produce friendlier error message
https://bugzilla.redhat.com/show_bug.cgi?id=1224587

The function takes two important arguments (among many others): @node
and @page_size. From these two a path under /sys is constructed. The
path is then used to read and write the desired size of huge pages
pool. However, if the path does not exists due to either @node or
@page_size having nonexistent value (e.g. there's no such NUMA node or
no page size like -2), an cryptic error message is produced:

  virsh # allocpages --pagesize 2049 --pagecount 8 --cellno -2
  error: Failed to open file '/sys/devices/system/node/node-2/hugepages/hugepages-2049kB/nr_hugepages': No such file or directory

Add two more checks to catch this and therefore produce much more
friendlier error messages.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-06-10 17:27:16 +02:00
John Ferlan
c178d38b8f logical: Fix typo in error message 2015-06-09 18:21:57 -04:00
Shivaprasad G Bhat
310c98d0c4 network: escape quotes for dsmasq conf contents
dnsmasq conf file contents needs to have quotes escaped for it to
work.  Because of this, the network-create/start for a network with
quotes in the name fails. The patch escapes strings for the entries
that go into the conf file.

Signed-off-by: Shivaprasad G Bhat <sbhat@linux.vnet.ibm.com>
2015-06-09 13:56:00 -04:00
Dmitry Guryanov
ad658a6015 parallels: fix formatting errors in parallels driver
This patch fixes several formatting errors, which I
missed before pushing previous patches. Mostly because
of missing cppi package.
2015-06-09 17:04:24 +03:00
Maxim Nestratov
67913bc6dc parallels: treat block devices as disks for containers
We are going to add block devices as disks for containers
not as filesystems.

Signed-off-by: Maxim Nestratov <mnestratov@parallels.com>
2015-06-09 16:45:16 +03:00
Maxim Nestratov
3fd2dd5484 parallels: report SATA bus type for container block devices disks
As we can add disks based on block devices to containers and bus type
doesn't have any meaning here, let us report always SATA for them.

Signed-off-by: Maxim Nestratov <mnestratov@parallels.com>
2015-06-09 16:45:16 +03:00
Maxim Nestratov
0b7b76cc45 parallels: process '/' mount point correctly for containers
Since we are going to add block devices as root disks we have
to specify root mount point for boot block devices. But we
shouldn't do this if a filesystem disk with such
target mount point already exists.

Signed-off-by: Maxim Nestratov <mnestratov@parallels.com>
2015-06-09 16:45:16 +03:00
Maxim Nestratov
022ece9bdc parallels: add isCt parameter to prlsdkGetDiskInfo and prlsdkAddDisk
Signed-off-by: Maxim Nestratov <mnestratov@parallels.com>
2015-06-09 16:45:15 +03:00
Nikolay Shirokovskiy
489c81c00c parallels: add block device statistics to driver
Statistics provided through PCS SDK. As we have only async interface in SDK we
need to be subscribed to statistics in order to get it. Trivial solution on
every stat request to subscribe, wait event and then unsubscribe will lead to
significant delays in case of a number of successive requests, as the event
will be delivered on next PCS server notify cycle. On the other hand we don't
want to keep unnesessary subscribtion. So we take an hibrid solution to
subcsribe on first request and then keep a subscription while requests are
active. We populate cache of statistics on subscribtion events and use this
cache to serve libvirts requests.

 * Cache details.
Cache is just handle to last arrived event, we call this cache
as if this handle is valid it is used to serve synchronous
statistics requests. We use number of successive events count
to detect that user lost interest to statistics. We reset this
count to 0 on every request. If more than PARALLELS_STATISTICS_DROP_COUNT
successive events arrive we unsubscribe. Special value of -1
of this counter is used to differentiate between subscribed/unsubscribed state
to protect from delayed events.

Values of PARALLELS_STATISTICS_DROP_COUNT and PARALLELS_STATISTICS_TIMEOUT are
just drop-ins, choosen without special consideration.

 * Thread safety issues
Use parallelsDomObjFromDomainRef in parallelsDomainBlockStats as
we could wait on domain lock down on stack in prlsdkGetStatsParam
and if we won't keep reference we could get dangling pointer
on return from wait.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@parallels.com>
2015-06-09 16:43:10 +03:00
Andrea Bolognani
b378c0f10a qemu: Capitalize "storage" in qemuDomainAttachUSBMassStorageDevice()
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2015-06-09 13:16:29 +02:00
Cole Robinson
daf2f51445 qemu: caps: Advertise arm 32-on-64 KVM option
We need to use qemu-system-aarch64 to run armv7l KVM VMs on an aarch64
host.
2015-06-08 17:56:31 -04:00
Cole Robinson
667370d67e qemu: caps: qemu-system-aarch64 supports armv7l
And it always has, so advertise it similarly to i686
2015-06-08 17:51:06 -04:00
Cole Robinson
29ce1693fa qemu: command: Support arm 32-on-64 KVM with -cpu aarch64=off
qemu 2.3.0 added the -cpu host,aarch64=off option, which allows using
qemu-system-aarch64 KVM to run armv7l VMs.

Add a capabilities check for it, wire it up in qemu_command, and test
the command line generation.
2015-06-08 17:51:06 -04:00
Nikolay Shirokovskiy
65a0b334f9 parallels: return only success from PCS event handler
2 reasons to to this.
1. PCS SDK really don't care of handler return value.
2. It hard to imagine how notifier can handle
subscriber failures. Even if there are some situations
we probably will use some special error codes and
not just throw error codes we get from SDK itself.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@parallels.com>
2015-06-08 20:13:33 +03:00
Nikolay Shirokovskiy
c71f5f8cee parallels: simplify event types discrimination
Use issuer type instead of event type to group
vm related events. This saves us from
explicit enumeration of all vm event types in
prlsdkHandleVmEvent.
2015-06-08 20:13:29 +03:00
Roman Bogorodskiy
5ceb34eea0 util: process: fix build on FreeBSD
Commit 825df8c3 refactored virProcess{Set,Get}Affinity routines,
however broke BSD implementation because of the incorrect variable
name. Fix build by using a proper variable name.

Pushing as trivial and build break fix.
2015-06-08 11:27:39 +04:00
Peter Krempa
679576cf8c util: Properly return error from virGetUserID and virGetGroupID stubs
The stubs for the two functions that are compiled on platforms that
don't have HAVE_GETPWUID_R and friends defined do not return error but
report an error message. The calling code then assumes that the @uid or
@gid arguments were filled, which is not the case in the stubs.
2015-06-08 09:32:24 +02:00
Ján Tomko
568aba8811 Turn qemuMonitorFindBalloonObjectPath into a void function
We were effectively ignoring its errors anyway.
2015-06-05 16:19:21 +02:00
Ján Tomko
19c633c678 Do not access the domain definition in qemuMonitorFindBalloonObjectPath
The monitor code does not hold the virDomainObjPtr lock and should
not access the defitinion.
2015-06-05 16:19:07 +02:00
Ján Tomko
084ad13774 Only call SetMemoryStatsPeriod for virtio memballoon 2015-06-05 16:19:00 +02:00
Ján Tomko
bf42e6d848 Check for balloon model in qemuDomainSetMemoryStatsPeriod
There's no point in calling the monitor if there is no balloon.
2015-06-05 16:17:49 +02:00
Ján Tomko
09ebc10fe1 Only call qemuMonitorGetMemoryStats for virtio memballoon
There is nothing to get from the monitor for model='none'.
2015-06-05 16:06:05 +02:00
Ján Tomko
4bfc58b58d Invert the condition in qemuDomainMemoryStats
It only makes sense if qemuMonitorGetMemoryStats is called,
but the following patch will make that call conditional.
2015-06-05 16:06:01 +02:00
Ján Tomko
4bcdd9cc9e Add endjob label to qemuDomainMemoryStats
Reduce the indentation level.
2015-06-05 16:05:44 +02:00
Ján Tomko
c09e1729df Remove path argument from qemuMonitorJSONFindLinkPath
All the callers use "/" anyway.
2015-06-05 16:01:23 +02:00
Ján Tomko
5aca919b6c Introduce qemuMonitorJSONFindLinkPath
When traversing through the QOM tree, we're looking for
a link to a device, e.g.:
link<virtio-balloon-pci>

Introduce a helper that will format the link name at the start,
instead of doing it every time while recursing through the tree.
2015-06-05 16:00:51 +02:00
Ján Tomko
88710cee75 Move qemuMonitorFindObjectPath to qemu_monitor_json
This function is specific to the JSON monitor.
2015-06-05 15:55:22 +02:00
Daniel P. Berrange
ccb05762ad rpc: Fix reference counting around virNetSocketAddIOCallback
Ref service passed as a parameter to the callback.  And don't unref the
socket that is part of the service being passed at another point in code.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2015-06-05 13:48:05 +02:00
Daniel P. Berrange
2128d2e920 rpc: Don't use unrelated value as privateData of client
Append privateData of the client only if there are any, otherwise the
previous value (socket data) will get there again.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2015-06-05 13:48:05 +02:00
Daniel P. Berrange
404094187a rpc: Make virNetServerAddClient function dynamic
As opposed to 'static'; by exporting it (privately).

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2015-06-05 13:48:05 +02:00
Martin Kletzander
9cb18291af mdns: Set error when failing due to missing avahi
When building without avahi support, we used VIR_DEBUG() to note that to
the user.  However, functions that fail because of that (return NULL/-1)
did not set the error message.  This was the only file that forgot to do
such thing.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2015-06-05 13:41:35 +02:00
John Ferlan
94a1579b0a storage: Add check for valid FS types in checkPool callback
https://bugzilla.redhat.com/show_bug.cgi?id=1181087

The virStorageBackendFileSystemIsMounted is called from three source paths
checkPool, startPool, and stopPool. Both start and stop validate the FS
fields before calling *IsMounted; however the check path there is no call.
This could lead the code into returning a true in "isActive" if for some
reason the target path for the pool was mounted. The assumption being
that if it was mounted, then we believe we started/mounted it.

It's also of note that commit id '81165294' added an error message for
the start/mount path regarding that the target is already mounted so
fail the start. That check was adjusted by commit id '13fde7ce' to
only message if actually mounted.

At one time this led to the libvirtd restart autostart code to declare
that the pool was active even though the startPool would inhibit startup
and the stopPool would inhibit shutdown. The autostart path changed as
of commit id '2a31c5f0' as part of the keep storage pools started between
libvirtd restarts.

This patch adds the same check made prior to start/mount and stop/unmount
to ensure we have a valid configuration before attempting to see if the
target is already mounted to declare "isActive" or not. Finding an improper
configuration will now cause an error at checkPool, which should make it
so we can no longer be left in a situation where the pool was started and
we have no way to stop it.
2015-06-05 06:25:43 -04:00
John Ferlan
fcf0fd52cb storage: FS backend adjust error message on error path
https://bugzilla.redhat.com/show_bug.cgi?id=1181087

Currently the assumption on the error message is that there are
no source device paths defined when the number of devices check
fails, but in reality the XML could have had none or it could have
had more than the value supported. Adjust the error message accordingly
to make it clearer what the error really is.
2015-06-05 06:25:19 -04:00
John Ferlan
5a8c98dbd9 storage: Refactor storage pool type checks
Refactor the code for both startPool (*Mount) and stopPool (*Unmount) code
paths by introducing virStorageBackendFileSystemIsValid.
2015-06-05 06:24:59 -04:00
John Ferlan
325a8134f9 storage: Remove extraneous @conn from function comments
Over time the parameters changed, but the comment wasn't updated
2015-06-05 06:07:50 -04:00
Peter Krempa
0f3e5325f5 qemu: Update balloon info only if job is allowed
In qemuDomainUpdateCurrentMemorySize I misplaced the actual update of
the balloon size to a place where it may not be initialized. Move it a
few lines above.
2015-06-04 14:04:48 +02:00
Peter Krempa
f9ab9effc5 conf: Fix mistakes in pointer usage in virDomainObjGetDefs
Coverity rightfully determined that in commit 3d021381c7
I made a mistake in the first check if @persDef is not NULL is
dereferencing it rather than checking.

Additionally if the vm is online the code would set @liveDef twice
rather than modifying @persDef. Fix both mistakes.
2015-06-04 14:03:38 +02:00
Martin Kletzander
f833c70b85 qemu: Check for qemu capability when calling virDomainGetBlockIoTune()
When getting block device I/O tuning data there is no check for whether
QEMU supports such options and the call fails on
qemuMonitorGetBlockIoThrottle() when getting the particular throttle
data.  So try reporting a better error when blkdeviotune is not
supported.

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2015-06-04 11:30:41 +02:00
Peter Krempa
50a9d0e67d qemu: Refactor qemuDomainSetVcpusFlags by reusing virDomainObjGetDefs 2015-06-04 10:52:32 +02:00