Commit Graph

16090 Commits

Author SHA1 Message Date
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
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
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
Jiri Denemark
1a0f076dd6 Use correct LDFLAGS for leaseshelper
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-03-03 13:23:46 +01:00
John Ferlan
0b36b0e9ce util: Cleanup error path for virPolkitAgentCreate
More fallout from changing to using virPolkitAgent and handling error
paths.  Needed to clear the 'cmd' once stored and of course add the
virCommandFree(cmd) in the error: label.
2016-03-02 13:59:37 -05:00
Michal Privoznik
f5f1ccbc23 datatypes.c: Replace 'close' with 'closeData'
Older compilers fail to see that 'close' is not used a function
rather than a variable and produce the following error:

cc1: warnings being treated as errors
../../src/datatypes.c: In function 'virConnectCloseCallbackDataReset':
../../src/datatypes.c:149: error: declaration of 'close' shadows a global declaration [-Wshadow]

Replace all the 'close' occurrences with 'closeData' to resolve
this.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-03-02 09:33:28 +01:00
John Ferlan
95aa101795 util: Fix missing initializer for agent
In virPolkitAgentCreate neglected to initialize agent to NULL. If
there was an error in the pipe, then we jump to error and would have
an issue. Found by coverity.
2016-03-01 19:36:37 -05:00
Nikolay Shirokovskiy
b523302c42 libxl: Remove extraneous AFFECT_LIVE and not active check.
libxlDomainPinVcpuFlags calls virDomainLiveConfigHelperMethod which will
call virDomainObjUpdateModificationImpact make the same AFFECT_LIVE flags
and !active check, so remove this duplicated check.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-03-01 10:41:53 -05:00
Nikolay Shirokovskiy
9dc19806f6 conf: Combine if condition in virDomainObjUpdateModificationImpact
Prior to commit id '3d021381' virDomainObjUpdateModificationImpact was
part of virDomainLiveConfigHelperMethod and the *flags if condition
VIR_DOMAIN_AFFECT_CONFIG checked the ->persistent boolean and made the
virDomainObjGetPersistentDef call.

Since the functions were split the ->persistent check is all that remained
and thus could be combined into one if statement.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-03-01 10:41:53 -05:00
Shanzhi Yu
751033a2e4 qemu: enalbe hotplugging of macvtap device with multiqueue
in commit 81a110, multiqueue for macvtap is enabled but forget
to support hotplugging enabled

Signed-off-by: Shanzhi Yu <shyu@redhat.com>
2016-03-01 16:16:58 +01:00
Jiri Denemark
bd7c8a693d qemu: Don't always wait for SPICE to finish migration
When SPICE graphics is configured for a domain but we did not ask the
client to switch to the destination, we should not wait for
SPICE_MIGRATE_COMPLETED event (which will never come).

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-03-01 15:59:00 +01:00
Jiri Denemark
3ecd73c4d8 qemu: Don't try to fetch migration stats on destination
Migration statistics are not available on the destination host and
starting a query job during incoming migration is not allowed. Trying to
do that would result in

    Timed out during operation: cannot acquire state change lock (held
    by remoteDispatchDomainMigratePrepare3Params)

error. We should not even try to start the job.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-03-01 15:59:00 +01:00
Jiri Denemark
65e44a44b2 Fix formatting in remote_protocol-structs
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-03-01 15:57:20 +01:00
Jiri Denemark
254b028943 util: Fix build without polkit
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-03-01 15:51:37 +01:00
Alexander Burluka
4e17ff796f Implement handling of per-domain bandwidth settings
Signed-off-by: Alexander Burluka <aburluka@virtuozzo.com>
2016-03-01 14:30:11 +00:00
Alexander Burluka
ef1fa55e46 Implement qemuSetupGlobalCpuCgroup
This functions setups per-domain cpu bandwidth parameters

Signed-off-by: Alexander Burluka <aburluka@virtuozzo.com>
2016-03-01 14:30:11 +00:00
Alexander Burluka
fbcbd1b252 Add error checking on global quota and period
Signed-off-by: Alexander Burluka <aburluka@virtuozzo.com>
2016-03-01 14:29:06 +00:00
Alexander Burluka
55ecdae0fb Add global quota parameter necessary definitions
This parameter controls the maximum bandwidth to be used
within a period for whole domain.

Signed-off-by: Alexander Burluka <aburluka@virtuozzo.com>
2016-03-01 14:29:06 +00:00
Alexander Burluka
4d92d58f2c Add global period definitions
This parameter represents top level period cgroup
that limits whole domain enforcement period for a quota

Signed-off-by: Alexander Burluka <aburluka@virtuozzo.com>
2016-03-01 14:29:06 +00:00
Nikolay Shirokovskiy
4b4fbfe406 vz: implement connection close notification
Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
2016-03-01 14:18:16 +00:00
Nikolay Shirokovskiy
f484310add daemon: add connection close rpc
Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
2016-03-01 14:18:16 +00:00
Nikolay Shirokovskiy
ec4ef72c13 remote: factor out feature checks on connection open
Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
2016-03-01 14:18:16 +00:00
Nikolay Shirokovskiy
88f09b75eb close callback: move it to driver
Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
2016-03-01 14:17:38 +00:00
Nikolay Shirokovskiy
bb5827950e virConnectCloseCallbackDataDispose: remove unnecessary locks
We don't need locks in dispose functions as they can only
be run in one thread for given object.
2016-03-01 14:16:56 +00:00
Nikolay Shirokovskiy
fa8c164501 close callback API: remove unnecessary locks
closeCallback pointer is immutable (set on connection object creation)
and self-locking.
2016-03-01 14:16:56 +00:00
Nikolay Shirokovskiy
baf47a1f5a virConnectCloseCallbackData: factor out callback disarming 2016-03-01 14:16:56 +00:00
Nikolay Shirokovskiy
42b0f7510d close callback: make unregister clean after connect close event
If connect close is fired then following unregister will fail
as we set callback to NULL and thus callback equality checking
will fail.

Callback is set to NULL to make it fired only one time probabaly.
Instead lets use connection equality to NULL to check if callback
is already fired.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
2016-03-01 14:16:56 +00:00
Nikolay Shirokovskiy
a16cd9a6eb virConnectCloseCallbackData: fix connection object refcount
We have reference to connection object in virConnectCloseCallbackData
object thus we have to refcount it. Obviously we have problems
in dispose and call functions. Let's fix it.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
2016-03-01 14:16:56 +00:00
Nikolay Shirokovskiy
24dbb69f21 factor out virConnectCloseCallbackDataPtr methods
Make register and unregister functions return void because
we can check the state of callback object beforehand via
virConnectCloseCallbackDataGetCallback. This can be done
without race conditions if we use higher level locks for registering
and unregistering. The fact they return void simplifies
task of consistent registering/unregistering.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
2016-03-01 14:16:56 +00:00
Henning Schild
ff16bde100 qemu_cgroup: use virCgroupAddTask instead of virCgroupMoveTask
qemuProcessSetupEmulator runs at a point in time where there is only
the qemu main thread. Use virCgroupAddTask to put just that one task
into the emulator cgroup. That patch makes virCgroupMoveTask and
virCgroupAddTaskStrController obsolete.

Signed-off-by: Henning Schild <henning.schild@siemens.com>
2016-03-01 14:07:27 +00:00
Henning Schild
8e21e8d110 qemu_cgroup: put qemu right into emulator sub-cgroup
Move qemuProcessSetupEmulator up under qemuSetupCgroup. That way
we move the one main thread right into the emulator cgroup, instead
of moving multiple threads later on. And we do not actually want any
threads running in the parent cgroups (cpu cpuacct cpuset).

Signed-off-by: Henning Schild <henning.schild@siemens.com>
2016-03-01 14:07:27 +00:00
Peter Krempa
a06ef20782 qemu: process: Move emulator thread setting code into one function
Similarly to the refactors to iothreads and vcpus, move the code that
initializes the emulator thread settings into single function.
2016-03-01 14:07:27 +00:00
Pavel Hrdina
b4a5fd95f7 qemu: introduce vram64 attribute for QXL video device
This attribute is used to extend secondary PCI bar and expose it to the
guest as 64bit memory.  It works like this: attribute vram is there to
set size of secondary PCI bar and guest sees it as 32bit memory,
attribute vram64 can extend this secondary PCI bar.  If both attributes
are used, guest sees two memory bars, both address the same memory, with
the difference that the 32bit bar can address only the first part of the
whole memory.

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

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2016-03-01 14:17:09 +01:00
Pavel Hrdina
37b746336e qemu_capabilities: introduce QEMU_CAPS_QXL(_VGA)_VRAM64
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2016-03-01 14:17:09 +01:00
Pavel Hrdina
119cd06ef7 domain_conf: always set primary video device as primary
We always place primary video device at first place, to make it easier
to create a qemu command or format an xml, but we should also set the
primary boolean for primary video device to 'true'.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2016-03-01 14:17:09 +01:00
John Ferlan
6fb96a7f8b util: Introduce API's for Polkit text authentication
Introduce virPolkitAgentCreate and virPolkitAgentDestroy

virPolkitAgentCreate will run the polkit pkttyagent image as an asynchronous
command in order to handle the local agent authentication via stdin/stdout.
The code makes use of the pkttyagent --notify-fd mechanism to let it know
when the agent is successfully registered.

virPolkitAgentDestroy will close the command effectively reaping our
child process
2016-03-01 06:50:16 -05:00