Commit Graph

20182 Commits

Author SHA1 Message Date
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
Jiri Denemark
528e70a29a qemuxml2argv: Remove Haswell CPU from unrelated tests
Proper Haswell CPU model handling is tested in several
qemuxml2argv-cpu-* which are run in a special environment. Let's remove
the CPU model from other tests to make them less fragile.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2015-06-29 13:28:20 +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
Martin Kletzander
1bcc88bbdd Temporarily disable admin API
Don't listen on the admin socket in the daemon and comment out the
admin devel files out of specfile.

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2015-06-28 11:34:25 +08:00
Martin Kletzander
886eb3c787 spec: Remove admin package specification
Its only file must be included in the daemon package anyway, since the
daemon is linked with the admin library and so then it's just an empty
package until we have virt-admin binary which we can decide later on
whether to just move it to clients or create a new package for it.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2015-06-28 11:34:19 +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
John Ferlan
91b9643845 docs: Clarification for when allowed to use 'lun' for "volume"
While re-reading what I wrote for commit id '785a8940e', I realized
I needed to clarify that being able to present as a 'lun', the mode
property for the pool source element needed to be "host" (or empty)
and not "direct".

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

Signed-off-by: John Ferlan <jferlan@redhat.com>
2015-06-26 16:54:38 -04:00
Laine Stump
10e207bb5b docs: document when pcie-root/dmi-to-pci-bridge support was added
Also move the mention of version numbers for the various PCI
controller models up to the end of the sentence where they are first
given, to avoid confusion.
2015-06-26 13:55:14 -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
1c5e782caa test: qemu: Make sure that wr_highest_offset_valid gets set properly
Remove one instance of the field being present so that the code that
sets that flag can be tested.
2015-06-26 16:41:24 +02: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
c0b7d3126b docs: Don't keep temporary files around
In my previous fix (1310b1358) I've tried to solve an ordering
issue.  Well, while it worked it has a side effect of keeping a
temporary file around. My patch was buggy in that sense. Solve
this by properly marking the dependency without any side effect.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-06-26 12:49:30 +02: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