Commit Graph

26614 Commits

Author SHA1 Message Date
Marc Hartmayer
a9b98ecf4e node_device: Unlock obj in case of an error too
Unlock @obj in case of an error too.

Reviewed-by: Bjoern Walk <bwalk@linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
2017-05-26 10:44:05 -04:00
Marc Hartmayer
3e69217953 node_device: Use the @cap iterator variable
Since the switch statement is already using the deref'd @cap variable
and the VIR_NODE_DEV_CAP_NET case uses it, the SCSI_HOST and PCI_DEV
cases may as well use it too.

Suggested-by: Bjoern Walk <bwalk@linux.vnet.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
2017-05-26 10:44:05 -04:00
Martin Kletzander
a8eba5036c qemu: Report shutdown event details
QEMU will likely report the details of it shutting down, particularly
whether the shutdown was initiated by the guest or host.  We should
forward that information along, at least for shutdown events.  Reset
has that as well, however that is not a lifecycle event and would add
extra constants that might not be used.  It can be added later on.

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2017-05-26 15:01:15 +02:00
Richard W.M. Jones
4c70a6f874 rpc: Allow up to 256K records to be returned per domain from virConnectGetAllDomainStats.
The number of records that virConnectGetAllDomainStats can return per
domain is currently limited to 4096.  This is quite low -- for
example, a single guest with ~320 disks will hit this limit.  This
increases the limit to make it much larger.  Note that
VIR_NET_MESSAGE_MAX still protects the total message size in the case
where there are many domains and many disks per domain.

I tested this using a guest with 500 disks with no issues.

Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1440683
2017-05-26 13:53:41 +01:00
Richard W.M. Jones
b088f85d42 rpc: Double buffer size instead of quadrupling buffer size.
When increasing the buffer size up to VIR_NET_MESSAGE_MAX, we
currently quadruple it each time.  This unfortunately means that we
cannot allow certain buffer sizes -- for example the current
VIR_NET_MESSAGE_MAX == 33554432 can never be "hit" since ‘newlen’
jumps from 16MB to 64MB.

Instead of quadrupling, double it each time.

Thanks: Daniel Berrange.
Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
2017-05-26 13:53:31 +01:00
Peter Krempa
8238fd6624 node: Don't return invalid pointers
Commit 4337bc57be introduced code that would in certain error paths
unref the last reference of a pointer, but return it.

Clear the pointers before returning them.
2017-05-26 14:21:52 +02:00
Yi Wang
d190424105 node_device: fix memory leak in nodeDeviceSysfsGetSCSIHostCaps
@tmp is leaked after the second call to virVHBAGetConfig within
virVHBAIsVportCapable code block because it wasn't freed after making the
first call to the function.

Signed-off-by: Yi Wang <wang.yi59@zte.com.cn>
Signed-off-by: Erik Skultety <eskultet@redhat.com>
2017-05-26 13:16:36 +02:00
Yi Wang
9f4c39f309 util: fix memory leak in virSocketAddrFormatFull
The @ipv6_host allocated in virAsprintf may be lost when virAsprintf
addrstr failed.

Signed-off-by: Yi Wang <wang.yi59@zte.com.cn>
Signed-off-by: Erik Skultety <eskultet@redhat.com>
2017-05-26 12:15:13 +02:00
Julio Faracco
7693f07fee lxc: Fix wrong VIR_FREE after a return statement
There is a VIR_FREE after a return statement. That code section is never
executed and for this reason the "tty" variable is not being freed. This
commit rearranges the logic.

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
2017-05-26 11:38:18 +02:00
Julio Faracco
424a21a9c8 m4: Fix missing with_acl variable
This commit fixes an acl missing variable. The virt-acl.m4 inside the
macro directory does not contain the variable 'with_acl'. So, it is
being set as an empty string "with_acl=''". This is causing a missing
option during the configuration, even if you have acl libs installed.

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
2017-05-26 11:37:44 +02:00
Ján Tomko
381e638d81 qemu: format eim on intel-iommu command line
This option turns on extended interrupt mode,
which allows more than 255 vCPUs.

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

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2017-05-26 08:16:29 +02:00
Ján Tomko
dc61d92758 conf: add eim attribute to <iommu><driver>
Add an attribute to control extended interrupt mode.

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

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2017-05-26 08:11:25 +02:00
John Ferlan
2453501fc8 virsh: Track when create pkttyagent
https://bugzilla.redhat.com/show_bug.cgi?id=1374126

Due to how the processing for authentication using polkit works, the
virshConnect code must first "attempt" an virConnectOpenAuth and then
check for a "special" return error code VIR_ERR_AUTH_UNAVAILABLE in
order to attempt to "retry" the authentication after performing a creation
of a pkttyagent to handle the challenge/response for the client.

However, if pkttyagent creation is not possible for the authentication
being attempted (such as perhaps a "qemu+ssh://someuser@localhost/system"),
then the same failure pattern would be returned and another attempt to
create a pkttyagent would be done. This would continue "forever" until
someone forced quit (e.g. ctrl-c) from virsh as the 'authfail' was not
incremented when creating the pkttyagent.

So add a 'agentCreated' boolean to track if we've attempted to create the
agent at least once and force a failure if that creation returned the same
error pattern.

This resolves a possible never ending loop and will generate an error:

error: failed to connect to the hypervisor
error: authentication unavailable: no polkit agent available to authenticate action 'org.libvirt.unix.manage'

NB: If the authentication was for a sufficiently privileged client, such as
qemu+ssh://root@localhost/system, then the remoteDispatchAuthList "allows"
the authentication to use libvirt since @callerUid would be 0.
2017-05-25 12:19:20 -04:00
Peter Krempa
0d3aff58e7 qemu: Use correct variable in qemuDomainSetBlockIoTune
'param' contains the correct element from 'params'.

If the group name would not be the first parameter libvirtd would crash.

Introduced in c53bd25b13.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1455510
2017-05-25 14:25:23 +02:00
Claudio André
1e988b2356 CI: show the log in case of failure
Disclose the content of the 'test-suite.log' file (if available) in
case of failures inside Travis-CI. This is needed to understand what
happened and to provide hints about the proper fix (if applicable).
2017-05-25 08:58:39 +02:00
Michal Privoznik
411713d440 virDomainDefCheckABIStabilityFlags: move memtune checks into a separate function
The checks are scattered all over the place. Move them into a
single function.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2017-05-25 08:31:37 +02:00
Chen Hanxiao
a495e3f9ea util: display leading zeros of USB vendor/product id's in log messages
Many vendor id's and product id's have leading zeros.  We should show
them in the logs.

Signed-off-by: Chen Hanxiao <chenhanxiao@gmail.com>
Reviewed-by: Laine Stump <laine@laine.org>
2017-05-24 12:23:59 -04:00
Yi Wang
c679e8a41d qemu: Fix memory leak in qemuDomainUpdateMemoryDeviceInfo
The @meminfo allocated in qemuMonitorGetMemoryDeviceInfo() may be
lost when qemuDomainObjExitMonitor() failed.

Signed-off-by: Yi Wang <wang.yi59@zte.com.cn>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2017-05-24 16:57:35 +02:00
John Ferlan
2c8e30ee7e conf: Resolve corner case on fc_host deletion
https://bugzilla.redhat.com/show_bug.cgi?id=1420740

Testing found an inventive way to cause an error at shutdown by providing the
parent name for the fc host creation using the "same name" as the HBA. Since
the code thus assumed the parent host name provided was the parent HBA and
just extracted out the host number and sent that along to the vport_destroy
this avoided checks made for equality.

So just add the equality check to that path to resolve.
2017-05-24 10:14:58 -04:00
Pavel Hrdina
065e89cf8b conf: fix build issue caused by shadowing global declaration
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2017-05-24 14:31:26 +02:00
Peter Krempa
97863780e8 rpc: Bump maximum message size to 32M
While most of the APIs are okay with 16M messages, the bulk stats API
can run into the limit in big configurations. Before we devise a new
plan for this, bump this limit slightly to accomodate some more configs.
2017-05-24 14:02:29 +02:00
Pavel Hrdina
0c53382d82 conf: don't iterate over backcompat console in virDomainChrDefForeach
If the first console is just a copy of the first serial device we
don't need to iterate over the same device twice in order to perform
actions like security labeling, cgroup configuring, etc.

Currently only security SELinux manager was aware of this fact.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2017-05-24 12:50:09 +02:00
Konstantin Neumoin
f8912d0527 vz: minor cleanup in prlsdkDomainSetUserPassword
No need begin job for asynchronous operation.

Signed-off-by: Konstantin Neumoin <kneumoin@virtuozzo.com>
2017-05-24 11:29:39 +02:00
Konstantin Neumoin
af4b0ed03e vz: fix raise in vzDomainBlock
Put domain access after acquiring job condition, otherwise
another job can change it meanwhile.

Signed-off-by: Konstantin Neumoin <kneumoin@virtuozzo.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2017-05-24 11:29:39 +02:00
Konstantin Neumoin
0c5d5cb959 vz: unlock dom until resize operation
We have to use waitDomainJob instead of waitJob, because of it
unlock the domain until job has finished, so domain will be available
for other clients.

Signed-off-by: Konstantin Neumoin <kneumoin@virtuozzo.com>
2017-05-24 11:29:39 +02:00
Peter Krempa
3fe624b268 qemu: Properly check return value of VIR_STRDUP in qemuDomainGetBlockIoTune
Setting the 'group_name' for a disk would falsely trigger a error path
as in commit 4b57f76502 we did not properly check the return value of
VIR_STRDUP.
2017-05-24 10:23:52 +02:00
Jim Fehlig
6de895f64c libxl: add default controllers for USB devices
Attempting to start a domain with USB hostdevs but no USB controllers
fails with the rather cryptic error

libxl: error: libxl_qmp.c:287:qmp_handle_error_response: received an
error message from QMP server: Bus 'xenusb-0.0' not found

This can be fixed by creating default USB controllers. When no USB
controllers are defined, create the number of 8 port controllers
necessary to accommodate the number of defined USB devices.

Note that USB controllers are already created as needed in the
domainAttachDevice code path. E.g. a USB controller will be created,
if necessary, when attaching a USB device with
'virsh attach-device dom usbdev.xml'.
2017-05-23 14:29:16 -06:00
Peter Krempa
5203975f37 qemu: process: Clear priv->namespaces on VM shutdown
Otherwise the private data entry would be kept across instances of the
same VM even if it's not configured to do so.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1453142
2017-05-23 16:24:49 +02:00
Kothapally Madhu Pavan
3c845817b8 qemu: Remove unused variables in qemuDomainUpdateDeviceConfig
priv and qemuCaps variables are not used anymore.

Signed-off-by: Kothapally Madhu Pavan <kmp@linux.vnet.ibm.com>
2017-05-22 19:07:48 +02:00
Laine Stump
77780a29ed Revert "qemu: propagate bridge MTU into qemu "host_mtu" option"
This reverts commit 2841e675.

It turns out that adding the host_mtu field to the PCI capabilities in
the guest bumps the length of PCI capabilities beyond the 32 byte
boundary, so the virtio-net device gets 64 bytes of ioport space
instead of 32, which offsets the address of all the other following
devices. Migration doesn't work very well when the location and length
of PCI capabilities of devices is changed between source and
destination.

This means that we need to make sure that the absence/presence of
host_mtu on the qemu commandline always matches between source and
destination, which means that we need to make setting of host_mtu an
opt-in thing (it can't happen automatically when the bridge being used
has a non-default MTU, which is what commit 2841e675 implemented).

I do want to re-implement this feature with an <mtu auto='on'/>
setting, but probably won't backport that to any stable branches, so
I'm first reverting the original commit, and that revert can be pushed
to the few releases that have been made since the original (3.1.0 -
3.3.0)

Resolves: https://bugzilla.redhat.com/1449346
2017-05-22 12:57:34 -04:00
Jim Fehlig
dbb85e0c15 libxl: add default listen address for VNC and spice
If a VNC listen address is not specified in domXML, libxl
will default to 127.0.0.1, but this is never reflected in the domXML.
In the case of spice, a missing listen address resulted in listening
on all interfaces, i.e. '0.0.0.0'. If not specified, set the listen
address in virDomainGraphicsDef struct to the libxl default when
creating the frame buffer device. Additionally, set default spice
listen address to 127.0.0.1.
2017-05-22 10:20:27 -06:00
Jim Fehlig
975ea20f85 maint: define a macro for IPv4 loopback address
Use a macro instead of hardcoding "127.0.0.1" throughout the
sources.
2017-05-22 10:20:27 -06:00
Daniel P. Berrange
e5ae24bdd2 Provide a useful README file
The current README file contents has almost no useful info, and that
which does exist is very outdated.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2017-05-22 17:01:37 +01:00
Michal Privoznik
9b991d0237 virStreamSparseSendAll: Reset @want in each iteration
There's a slight problem with the current function. Assume we are
currently in a data section and we have say 42 bytes until next
section. Therefore, just before (handler) is called to fill up
the buffer with data, @want is changed to 42 to match the amount
of data left in the current section. However, after hole is
processed, we are back in data section but with incredibly small
@want size. Nobody will ever reset it back. This results in
incredible data fragmentation.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2017-05-22 15:25:39 +02:00
Andrea Bolognani
f9fe0f54ca docs: Update pointer to networking information
Commit 6fb5dd4fd8 removed docs/archnetwork.html.in, but
left behind a pointer to it in docs/formatnetwork.html.in.

Update it so that it points to the wiki, which contains
more detailed and recent information anyway.
2017-05-22 13:22:32 +02:00
Michal Privoznik
0b60f88791 virCapabilitiesInitCaches: Don't leak cache dir
To every virDirOpen we must have VIR_DIR_CLOSE otherwise FD is
leaked.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2017-05-22 12:57:30 +02:00
Ján Tomko
f25f30aff5 Do not release unreserved address in qemuDomainAttachRNGDevice
Only set releaseaddr to true after the address has been
reserved successfully.

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

Reviewed-by: John Ferlan <jferlan@redhat.com>
2017-05-22 10:29:01 +02:00
Peter Krempa
ae3b82266d qemu: hotplug: print correct vcpu when validating hot(un)plug config
The error message would contain first vcpu id after the list of vcpus
selected for modification. To print the proper vcpu id remember the
first vcpu selected to be modified.
2017-05-22 09:14:35 +02:00
Wang King
c4a4c01e6e util: Don't leak @reply in virSystemdGetMachineNameByPID
@reply is a DBusMessage object returned by virDBusCallMethod in
get machine object call path, dereference it before calling
virDBusCallMethod again to get machine name.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2017-05-22 06:48:01 +02:00
Julio Faracco
f7c7f450f3 test: fixing variable names for test suite inside configure.ac.
Both variables for gcov and oom have wrong names inside configure.ac.
For this reason, the Test Suite configuration is not showing the current
configuration.

Before patching:
configure:    windres: no
configure:
configure: Test suite
configure:
configure:          Coverage:
configure:         Alloc OOM:
configure:
configure: Miscellaneous

After patching (using --enable-test-coverage and --enable-test-oom):
configure:    windres: no
configure:
configure: Test suite
configure:
configure:          Coverage: yes
configure:         Alloc OOM: yes
configure:
configure: Miscellaneous

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
2017-05-22 06:14:02 +02:00
Wim ten Have
4cd3f24139 xenconfig: fix handling of NULL disk source
It is possible to crash libvirtd when converting xl native config to
domXML when the xl config contains an empty disk source, e.g. an empty
CDROM. Fix by checking that the disk source is non-NULL before parsing it.

Signed-off-by: Wim ten Have <wim.ten.have@oracle.com>
2017-05-19 08:47:36 -06:00
Michal Privoznik
2f69dd36bb virfiletest: include linux/falloc.h
On systems with older glibc including fcntl.h for getting
FALLOC_FL_PUNCH_HOLE defined is not enough. We must also include
linux/falloc.h.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2017-05-19 14:02:37 +02:00
Michal Privoznik
adbd1626cb virfiletest: Test virFileInData iff SEEK_HOLE is defined
Yet another place where we need to wrap code in
HAVE_DECL_SEEK_HOLE block.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2017-05-19 14:02:37 +02:00
Michal Privoznik
ab26790f07 virfile: Provide stub for virFileInData
Some older systems (such as RHEL6) lack SEEK_HOLE and SEEK_DATA
which virFileInData relies on. Provide a stub for these systems.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2017-05-19 14:02:37 +02:00
Peter Krempa
85d62624c5 conf: Don't assign value from ..TypeFromString directly to enum
Enums are unsigned, so it's impossible to check whether the helper
returned -1 for invalid conversions.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1452454
2017-05-19 12:16:33 +02:00
Felix Geyer
dd875fb326 apparmor, virt-aa-helper: Explicit denies for host devices
Add explicit denies for disk devices to avoid cluttering dmesg with
(acceptable) denials.

Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Guido Günther <agx@sigxcpu.org>
2017-05-19 09:48:23 +02:00
Felix Geyer
95740052ea apparmor, virt-aa-helper: Allow access to libnl-3 config files
Allow access to libnl-3 config files

Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Guido Günther <agx@sigxcpu.org>
2017-05-19 09:48:23 +02:00
Peter Krempa
6ff99e9577 qemu: monitor: Don't bother extracting vCPU halted state in text monitor
The code causes the 'offset' variable to be overwritten (possibly with
NULL if neither of the vCPUs is halted) which causes a crash since the
variable is still used after that part.

Additionally there's a bug, since strstr() would look up the '(halted)'
string in the whole string rather than just the currently processed line
the returned data is completely bogus.

Rather than switching to single line parsing let's remove the code
altogether since it has a commonly used JSON monitor alternative and
the data itself is not very useful to report.

The code was introduced in commit cc5e695bde

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1452106
2017-05-19 09:31:19 +02:00
Julio Faracco
6a12907d86 datatypes: removing unnecessary return statement.
There is a wrong 'return' statement after a 'goto' statement inside the
function virConnectCloseCallbackDataRegister(). This commit only removes
the 'return'.

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
2017-05-18 20:15:45 -04:00
Michal Privoznik
0da4a635bc virStream: Forbid negative seeks
Currently, we don't assign any meaning to that. Our current view
on virStream is that it's merely a pipe. And pipes don't support
seeking.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2017-05-18 15:05:18 +02:00