Commit Graph

21687 Commits

Author SHA1 Message Date
Daniel P. Berrange
4e461228dd qemu: move functions for handling FD passing
The functions for handling FD passing when building command line
arguments need to be used by many different bits of code, so need
to be at the start of the source file

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2016-03-10 15:41:52 +00:00
Daniel P. Berrange
0192447519 qemu: don't append -chardev arg until after value is formatted
The act of formatting a chardev backend value may need to
append command line arguments for passing FDs. If we append
the -chardev arg before formatting the value, then the
resulting arguments will end up interspersed

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2016-03-10 15:40:54 +00:00
Daniel P. Berrange
06cb0cf7ce qemu: add support for logging chardev output to a file
Honour the <log file='...'/> element in chardevs to output
data to a file. This requires QEMU >= 2.6

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2016-03-10 15:33:51 +00:00
Daniel P. Berrange
00ce10c700 conf: allow use of a logfile with chardev backends
Extend the chardev source XML so that there is a new optional
<log/> element, which is applicable to all character device
backend types. For example, to log output of a TCP backed
serial port

    <serial type='tcp'>
      <source mode='connect' host='127.0.0.1' service='9999'/>
      <protocol type='raw'/>
      <log file='/var/log/libvirt/qemu/demo-serial0.log' append='on'/>
      <target port='0'/>
    </serial>

Not all hypervisors will support use of logfiles.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2016-03-10 15:33:17 +00:00
Daniel P. Berrange
f12bfc5ed5 logging: allow inode/offset params to be NULL
Not all callers of virLogManagerDomainOpenLogFile will
care about getting the current inode/offset, so we should
allow those parameters to be NULL

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2016-03-10 15:33:16 +00:00
Peter Krempa
ab3f1428a6 qemu: cpu: Don't remove pinning of cold-unplugged cpu
After adding support for offline vcpu pinning the code that removes the
pinning for cpu cold-unplug was forgotten. This fixes up commit 02ae21d

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1316371
2016-03-10 15:56:55 +01:00
Peter Krempa
a0143d5242 qemu: Fix memory leak in qemuGetSchedInfo
Memory returned from virStringSplit shall be freed with
virStringFreeList rather than VIR_FREE. Introduced in commit 511e7c5b.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1316433
2016-03-10 13:58:44 +01:00
Peter Krempa
8c7b7c4b0b conf: Fix off-by-one in virDomainDefGetVcpu
Cpus are indexed starting from '0' so the check was invalid.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1316384
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1316420
2016-03-10 13:58:44 +01:00
Peter Krempa
4a39149b69 qemu: Refactor bitmap handling in qemuDomainPinVcpuFlags
Now that the function was extracted we can get rid of some temp
variables. Additionally formatting of the bitmap string for the event
code should be checked.
2016-03-10 13:23:15 +01:00
Peter Krempa
475c530cd3 qemu: vcpupin: Extract live vcpupin setting into a separate function
The function was now beyond maintainability.
2016-03-10 13:23:15 +01:00
Cole Robinson
adefc561cc util: virfile: Only setuid for virFileRemove if on NFS
NFS with root-squash is the only reason we need to do setuid/setgid
crazyness in virFileRemove, so limit that behavior to the NFS case.
2016-03-09 16:07:18 -05:00
Cole Robinson
7cf5343709 util: virfile: Clarify setuid usage for virFileRemove
Break these checks out into their own function, and clearly document
each one. This shouldn't change behavior
2016-03-09 16:06:56 -05:00
Peter Krempa
02ae21deb3 qemu: add support for offline vcpupin
Allow pinning for inactive vcpus. The pinning mask will be automatically
applied as we would apply the default mask in case of a cpu hotplug.

Setting the scheduler settings for a vcpu has the same semantics.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1306556
2016-03-09 10:09:16 +01:00
Peter Krempa
acf521e121 conf: extract ignoring of inactive vcpu pinning information
Introduce VIR_DOMAIN_DEF_FEATURE_OFFLINE_VCPUPIN domain feature flag
whcih will allow to skip ignoring of the pinning information for
hypervisor drivers which will want to implement forward-pinning of
vcpus.
2016-03-09 10:09:16 +01:00
Peter Krempa
185d13b1b0 conf: refactor checking for unsupported memory devices
Introduce a helper to check supported device and domain config and move
the memory hotplug checks to it.

The advantage of this approach is that by default all new features are
considered unsupported by all hypervisors unless specifically changed
rather than the previous approach where every hypervisor would need to
declare that a given feature is unsupported.
2016-03-09 10:09:16 +01:00
Peter Krempa
23eb382128 conf: introduce parser feature flags
To avoid having to forbid new features added to domain XML in post parse
callbacks for individual hypervisor drivers the feature flag mechanism
will allow to add a central check that will be disabled for the drivers
that will add support.

As a first example flag, the 'hasWideSCSIBus' is converted to the new
bitmap.
2016-03-09 10:09:16 +01:00
Peter Krempa
0fe41f1a8a qemu: Report pinning for all vCPUs in qemuDomainGetVcpuPinInfo
The API documentation states that the function is returning pinning for
all vCPUs, so we can actually do so if the user passes a large enough
array.
2016-03-09 10:09:16 +01:00
Peter Krempa
e498e90469 conf: Extract code filling data for virDomainGetVcpuPinInfo
The implementation of the inner guts of the function is similar for all
drivers, so we can add a helper and not have to reimplement it three
times.
2016-03-09 10:09:16 +01:00
Peter Krempa
e7e6980dd8 virsh: vcpupin: Ask for pinning info for all vCPUs
The API docs state that the API queries pinning info for all vCPUs and
thus we should allocate the bitmap even for the inactive ones.

The API will currently return bitmap only for the active vCPUs but that
will change in the future.
2016-03-09 10:09:16 +01:00
Jiri Denemark
cf091094a4 qemu: Add support for job completed event
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-03-08 16:26:01 +01:00
Jiri Denemark
f289300181 Introduce job completed event
The VIR_DOMAIN_EVENT_ID_JOB_COMPLETED event will be triggered once a job
(such as migration) finishes and it will contain statistics for the job
as one would get by calling virDomainGetJobStats. Thanks to this event
it is now possible to get statistics of a completed migration of a
transient domain on the source host.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-03-08 16:26:00 +01:00
Jiri Denemark
a2374edf08 qemu: Do not report completed stats until the job finishes
We would happily report and free statistics of a completed migration
even before it actually completed (on the source host while migration is
in the Finish phase).

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-03-08 16:26:00 +01:00
Jiri Denemark
cb483a68fd qemu: Fix a race when computing migration downtime
Computing a total downtime during a migration requires us to store a
time stamp when guest CPUs get stopped. The value (and all other
statistics) is then transferred to the destination to compute the
downtime. Because the stopped time stamp is stored by a STOP event
handler while the statistics which will be sent over to the destination
are copied synchronously within qemuMigrationWaitForCompletion.

Depending on the timing of STOP and MIGRATION events, we may end up
copying (and transferring) statistics without the stopped time stamp
set. Let's make sure we always use the correct time stamp.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-03-08 16:26:00 +01:00
Jiri Denemark
315808e99e qemu: Don't explicitly stop CPUs after migration
With a very old QEMU which doesn't support events we need to explicitly
call qemuMigrationSetOffline at the end of migration to update our
internal state. On the other hand, if we talk to QEMU using QMP, we
should just wait for the STOP event and let the event handler update the
state and trigger a libvirt event.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-03-08 16:25:59 +01:00
Jiri Denemark
5d01e8666b qemu: Properly update completed migration stats
We should not overwrite all migration statistics on the source with the
numbers sent by the destination since the source may have an updated
view in some cases (such as post-copy migration). It's safer to update
just the timing info we need to get from the destination and be prepared
for the future. And we should only do all this after a successful
migration.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-03-08 16:25:59 +01:00
Jiri Denemark
e031560e87 qemu: Store completed stats at the very end of migration
Statistics for a completed migration only make sense if the migration
was successful. Let's not store them in priv->job.completed until we
are sure it was a success.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-03-08 16:25:47 +01:00
Andrea Bolognani
12a1631440 hostdev: Remove explicit NULL checks
NULL checks are performed implicitly in the rest of the module,
including other allocations in the very same function.
2016-03-08 10:44:01 +01:00
Andrea Bolognani
a54de18a54 hostdev: Fix indentation 2016-03-08 10:44:01 +01:00
Andrea Bolognani
a67b14a975 hostdev: Remove inaccurate comment
The comment claimed that virPCIDeviceReattach() does not reattach
a device to the host driver; except it actually does, so the
comment is just confusing and we're better off removing it.
2016-03-08 10:42:26 +01:00
Andrea Bolognani
be70acb788 hostdev: Make comments easier to change later
Replace the term "loop" with the more generic "step". This allows us
to be more flexible and eg. have a step that consists in a single
function call.

Don't include the number of steps in the first comment of the
function, so that we can add or remove steps without having to worry
about keeping that comment in sync.

For the same reason, remove the summary contained in that comment.

Clean up some weird vertical spacing while we're at it.
2016-03-08 10:42:25 +01:00
Andrea Bolognani
3632185617 tests: hostdev: Group test cases
Instead of considering each single step its own test case, create
high level test cases that reproduce a certain scenario.
2016-03-08 10:42:25 +01:00
Andrea Bolognani
f8388cdce4 tests: hostdev: Add more checks on list size
Always call CHECK_LIST_COUNT() to check the size of both the active
and inactive devices list.
2016-03-08 10:42:25 +01:00
Andrea Bolognani
4a9ea5048c tests: hostdev: Use size_t for count variables
virPCIDeviceListCount()'s return type is size_t, so variables that
store its return value should be of that type.
2016-03-08 10:42:22 +01:00
Andrea Bolognani
ff087d8dae tests: hostdev: Move variable declaration inside CHECK_LIST_COUNT()
The 'actualCount' variable, formerly just 'count', is only used
internally by the macro, so it's better to move its declaration
inside the macro as well: this way, it doesn't have to be declared
by every single user.

The new name is less generic to make clashes less likely.
2016-03-08 10:34:13 +01:00
Andrea Bolognani
dd9f8e0292 tests: hostdev: Use better variable names
Change the extremely generic count1 and count2 to the more
descriptive active_count and inactive_count.
2016-03-08 10:16:43 +01:00
Andrea Bolognani
9f506fdb6b tests: hostdev: Remove magic numbers
When checking the number of devices added to a device list, use the
nhostdevs variable instead of its value, so that the test can keep
working even if more hostdevs are added.
2016-03-08 10:16:43 +01:00
Michal Privoznik
18f231e6ff _virtualboxCreateMachine: Avoid unbounded stack
If the stars are in the right position and you're building with
VBox >= 4.2.0 it will happen that compiler thinks an array
allocated on the stack may be unbounded:

In file included from vbox/vbox_V4_2.c:13:0:
vbox/vbox_tmpl.c: In function '_virtualboxCreateMachine':
vbox/vbox_tmpl.c:2811:1: error: stack usage might be unbounded [-Werror=stack-usage=]
 _virtualboxCreateMachine(vboxGlobalData *data, virDomainDefPtr def, IMachine **machine, char *uuidstr ATTRIBUTE_UNUSED)
 ^

Well, given how the variable is declared, I had some hard time
seeing it is actually bounded. Surprisingly compiler does not
complain because of -Wframe-larger-than. This is because
variable length arrays do not count into that warning.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-03-08 09:53:24 +01:00
John Ferlan
eff43d9aba Add secretObjFromSecret
Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-03-07 15:52:21 -05:00
John Ferlan
0e3e00a183 locking: Use bit shift for flag values not constant values.
So far it hasn't bitten us, but if the next value wasn't 4, then
the logic used to check flag bits would have issues.
2016-03-07 15:48:19 -05:00
Yuri Chornoivan
47b70b8793 Fix minor typos 2016-03-07 18:37:25 +01:00
Shanzhi Yu
347035f959 qemu: improve the error when try to undefine transient network
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1315059

Signed-off-by: Shanzhi Yu <shyu@redhat.com>
2016-03-07 10:15:53 +01:00
Peter Krempa
47fdf9bc3a qemu: rename: Forbid renaming domains with managed save image
The code does not handle renaming of the save state file. In addition to
that the resuming code would need to be tweaked to handle the name
change since the XML is extracted from the save image. The easies option
is to make the rename API even less useful by forbiding this.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1314594
2016-03-07 10:15:37 +01:00
Michal Privoznik
f3c47aafa4 virLXCProcessMonitorInitNotify: Initialize @inode
This is an error message I've just seen. Fix it by initializing
@inode.

  CC       lxc/libvirt_driver_lxc_impl_la-lxc_process.lo
lxc/lxc_process.c: In function 'virLXCProcessMonitorInitNotify':
lxc/lxc_process.c:767:23: error: 'inode' may be used uninitialized in this function [-Werror=maybe-uninitialized]
     virDomainAuditInit(vm, initpid, inode);
                       ^

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-03-04 15:23:16 +01:00
Nikolay Shirokovskiy
390665a9b8 libxl: reuse virDomainObjUpdateModificationImpact
Original current flag expansion does not filter out non
_CONFIG and _LIVE flags explicitly but they are prohibited
earlier by virCheckFlags.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
2016-03-04 07:39:01 -05:00
Nikolay Shirokovskiy
7d3230d36d lxc: reuse virDomainObjUpdateModificationImpact
Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
2016-03-04 07:39:01 -05:00
Nikolay Shirokovskiy
4cf22bdcfd libxl: Use virDomainLiveConfigHelperMethod for libxlDomainSetMemoryFlags
Flag expansion is the same as in virDomainObjUpdateModificationImpact
which virDomainLiveConfigHelperMethod calls internally. The difference
is merely in implementation. Note that VIR_DOMAIN_MEM_CONFIG is the
same as VIR_DOMAIN_AFFECT_CONFIG.  Additionally, the called functions
will properly use flag OR and thus handle the VIR_DOMAIN_MEM_MAXIMUM case.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
2016-03-04 07:39:01 -05:00
Ján Tomko
34111a60f8 tools: do not leak uri in disconnect handler
Commit 035947e introduced a call to virConnectGetURI
without a matching free() in virshCatchDisconnect.

Also fix vshAdmCatchDisconnect where it was copied by
commit 6dd7e42.

https://bugzilla.redhat.com/show_bug.cgi?id=1303891
2016-03-04 08:08:16 +01:00
Michal Privoznik
bde6e002b5 Initialize couple of variables.
While trying to build with -Os couple of compile errors showed
up.

conf/domain_conf.c: In function 'virDomainChrRemove':
conf/domain_conf.c:13666:24: error: 'ret' may be used uninitialized in this function [-Werror=maybe-uninitialized]
     virDomainChrDefPtr ret, **arrPtr = NULL;
                        ^
Compiler fails to see that @ret is used only if set in the loop,
but whatever, there's no harm in initializing the variable.

In vboxAttachDrivesNew and _vboxAttachDrivesOld compiler thinks
that @rc may be used uninitialized. Well, not directly, but maybe
after some optimization. Yet again, no harm in initializing a
variable.

In file included from ./util/virthread.h:26:0,
                 from ./datatypes.h:28,
                 from vbox/vbox_tmpl.c:43,
                 from vbox/vbox_V3_1.c:37:
vbox/vbox_tmpl.c: In function '_vboxAttachDrivesOld':
./util/virerror.h:181:5: error: 'rc' may be used uninitialized in this function [-Werror=maybe-uninitialized]
     virReportErrorHelper(VIR_FROM_THIS, code, __FILE__,              \
     ^
In file included from vbox/vbox_V3_1.c:37:0:
vbox/vbox_tmpl.c:1041:14: note: 'rc' was declared here
     nsresult rc;
              ^
Yet again, one uninitialized variable:

qemu/qemu_driver.c: In function 'qemuDomainBlockCommit':
qemu/qemu_driver.c:17194:9: error: 'baseSource' may be used uninitialized in this function [-Werror=maybe-uninitialized]
         qemuDomainPrepareDiskChainElement(driver, vm, baseSource,
         ^

And another one:

storage/storage_backend_logical.c: In function 'virStorageBackendLogicalMatchPoolSource.isra.2':
storage/storage_backend_logical.c:618:33: error: 'thisSource' may be used uninitialized in this function [-Werror=maybe-uninitialized]
                       thisSource->devices[j].path))
                                 ^

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-03-03 14:39:57 +01:00
Michal Privoznik
be8b536af1 Drop inline keyword from some functions.
While trying to build with -Os I've encountered some build
failures.

util/vircommand.c: In function 'virCommandAddEnvFormat':
util/vircommand.c:1257:1: error: inlining failed in call to 'virCommandAddEnv': call is unlikely and code size would grow [-Werror=inline]
 virCommandAddEnv(virCommandPtr cmd, char *env)
 ^
util/vircommand.c:1308:5: error: called from here [-Werror=inline]
     virCommandAddEnv(cmd, env);
     ^
This function is big enough for the compiler to be not inlined.
This is the error message I'm seeing:

Then virDomainNumatuneNodeSpecified is exported and called from
other places. It shouldn't be inlined then.

In file included from network/bridge_driver_platform.h:30:0,
                 from network/bridge_driver_platform.c:26:
network/bridge_driver_linux.c: In function 'networkRemoveRoutingFirewallRules':
./conf/network_conf.h:350:1: error: inlining failed in call to 'virNetworkDefForwardIf.constprop': call is unlikely and code size would grow [-Werror=inline]
 virNetworkDefForwardIf(const virNetworkDef *def, size_t n)
 ^

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-03-03 14:39:57 +01:00
Jiri Denemark
e53f2dc875 qemu: Check if domain is active in GetControlInfo
Reporting status of a control connection makes no sense for an inactive
domain.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-03-03 13:26:51 +01:00