Commit Graph

21196 Commits

Author SHA1 Message Date
Jim Fehlig
f5eacf2a9a libxl: MigratePerform: properly cleanup after libxlDomObjFromDomain
libxlDomObjFromDomain to returns locked and ref counted virDomainObj but
libxlDomainMigratePerform3Params only unlocks the object on exit. Convert
it to use the virDomainObjEndAPI function for cleanup.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-03-16 11:14:58 -06:00
Jim Fehlig
99486799c3 libxl: MigrateConfirm: Dont unlock virDomainObj in helper function
The libxlDomainMigrateConfirm3Params API locks and ref counts the associated
virDomainObj but relies on the helper function libxlDomainMigrationConfirm
to unlock the object. Unref'ing the object is not done in either function.
libxlDomainMigrationConfirm is also used by libxlDomainMigratePerform3Params
for p2p migration, but in that case the lock/ref and unref/unlock are
properly handled in the API entry point.

Remove the unlock from libxlDomainMigrationConfirm and adjust
libxlDomainMigrateConfirm3Params to properly unref/unlock the virDomainObj
on success and error paths.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-03-16 11:14:57 -06:00
Jim Fehlig
64370c4b81 libxl: MigrateBegin: Dont call EndAPI in helper function
The libxlDomainMigrateBegin3Params API locks and ref counts the associated
virDomainObj but relies on the helper function libxlDomainMigrationBegin
to unref/unlock the object. libxlDomainMigrationBegin is also used by
libxlDomainMigratePerform3Params for p2p migration, but in that case the
lock/ref and unref/unlock are properly handled in the API entry point. So
p2p migrations suffer a double unref/unlock in the Perform API.

Remove the unref/unlock (virDomainObjEndAPI) from libxlDomainMigrationBegin
and adjust libxlDomainMigrateBegin3Params to properly unref/unlock
the virDomainObj on success and error paths.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-03-16 11:14:57 -06:00
Michal Privoznik
b133fac356 qemu: Build usb controller command line more wisely
https://bugzilla.redhat.com/show_bug.cgi?id=1552127

When building command line for USB controllers we have to do more
than just put controller's alias onto the command line. QEMU has
concept of these joined USB controllers. For instance ehci and
uhci controllers need to create the same USB bus. To achieve that
the slave controller needs to refer the master controller. This
worked until we've introduced user aliases because both master
and slave had the same alias. With user aliases slave can have
different alias than master. Therefore, when generating command
line for slave we need to look up the master's alias.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2018-03-16 16:37:14 +01:00
Farhan Ali
c8935705f1 qemu: Use correct bus type for input devices
commit 7210cef452 'qemu: build command line for virtio input devices'
introduced an error, by checking if input bus type is
VIR_DOMAIN_DISK_BUS_VIRTIO.

Fix it by using the correct bus type for input devices.

Signed-off-by: Farhan Ali <alifm@linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-03-16 09:42:58 -04:00
Farhan Ali
21c6ec2ff7 qemu: Fix comment for 'qemuValidateDevicePCISlotsChipsets'
Commit id '177db487' renamed 'qemuValidateDevicePCISlotsChipsets' to
'qemuDomainValidateDevicePCISlotsChipsets', but didn't adjust comment.

Signed-off-by: Farhan Ali <alifm@linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-03-16 09:42:52 -04:00
Michal Privoznik
72d3301db1 virnetlink: Provide virNetlinkGetNeighbor non-Linux stub
This function is exported and therefore we have to have
implementation for all platforms.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2018-03-16 09:02:42 +01:00
Michal Privoznik
9304d916a3 virarptable: Avoid cast align warnings
We have to use VIR_WARNINGS_NO_CAST_ALIGN to avoid clang warning
about increased required alignment caused by some netlink macros.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2018-03-16 09:02:34 +01:00
Marc Hartmayer
1bc7e2b8b5 remote: Set eventID explicitly to an invalid value
Set the eventID for remoteRelayDomainQemuMonitorEvent explicitly to an
invalid value. Although the value is not used by
remoteRelayDomainQemuMonitorEvent, but it might be less prone to
errors for further refactorings.

Signed-off-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-03-15 17:12:28 -04:00
Marc Hartmayer
8bd0261a72 stream: Access stream->prog instead of a hard-coded global variable
Use stream->prog instead of a hard-coded "remoteProgram" since at
stream creation in daemonCreateClientStream "remoteProgram" is used
so we should use that especially since these functions are intended
as generic helpers for streams.

Signed-off-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-03-15 17:12:28 -04:00
Marc Hartmayer
9f24004b82 remote: remove unneeded global variables
Remove unneeded global variables and convert them into local variables
where they're needed.

Signed-off-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-03-15 17:12:28 -04:00
Marc Hartmayer
1ee9c384da test: fix error path in testConnectOpen
In case of an error do the cleanup of the private data of the
connection.

Signed-off-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-03-15 17:12:28 -04:00
Marc Hartmayer
bc0f82adf8 test: introduce testDriverCloseInternal
Refactor testConnectClose as it's then obvious that conn->privateData
is set to NULL in all cases. In addition, 'testConnectCloseInternal'
can be better reused.

Signed-off-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-03-15 17:12:28 -04:00
Marc Hartmayer
55130c0b63 test: rename defaultConn to defaultPrivconn
Rename the variable @defaultConn to @defaultPrivconn as it doesn't
point to a default connection but to the private data used for the
shared default connection of the test driver.

Signed-off-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-03-15 17:12:28 -04:00
Marc Hartmayer
81b2a8e024 test: testConnectClose: Set privateData to NULL in all cases
Set privateData to NULL also for a connection that uses @defaultConn
as privateData regardless of whether @defaultConn was freed or
not. @defaultConn is shared between multiple connections and it's
ensured that there will be no memory leak by counting references.

Signed-off-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-03-15 17:12:28 -04:00
Marc Hartmayer
5428389b2b test: testConnectAuthenticate: Take the lock when accessing mutable values
Signed-off-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-03-15 17:12:28 -04:00
Marc Hartmayer
ba8bd17a6a test: testOpenFromFile: return VIR_DRV_OPEN_SUCCESS in case of success
Signed-off-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-03-15 17:12:28 -04:00
Marc Hartmayer
d8a24044b7 test: testOpenDefault: introduce cleanup path
The two code paths have some cleanup in common so lets refactor it.

Signed-off-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-03-15 17:12:28 -04:00
Marc Hartmayer
d1c89c9b2d driver: Add typedef for the anonymous enum used for driver features
Add typedef for the anonymous enum used for the driver features. This
allows the usage of the type in a switch statement and taking
advantage of the compilers feature to detect uncovered cases.

Signed-off-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-03-15 17:12:28 -04:00
Andrea Bolognani
b6f6a0d984 python3: Fix sort function
This deals with cls.version possibly being None.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2018-03-15 17:48:47 +01:00
Andrea Bolognani
b98d4244c6 python3: Open files in text instead of binary mode
We use text operations on the contents after reading them.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2018-03-15 17:48:45 +01:00
Andrea Bolognani
e379dcce57 python3: Replace keys() + sort() with sorted()
The keys() method no longer returns a list, so converting the
return value would be necessary before calling sort() on it;
alternatively, we can just call sorted(), which returns a
sorted list.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2018-03-15 17:48:43 +01:00
Andrea Bolognani
b207817b49 python3: Use the print() function
It has replaced the 'print' statement.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2018-03-15 17:47:14 +01:00
Jim Fehlig
fb327ac2c3 lockd: fix typo in virtlockd-admin.socket
Commit ce7ae55ea1 introduced a typo in virtlockd-admin socket file

/usr/lib/systemd/system/virtlockd-admin.socket:7: Unknown lvalue
'Server' in section 'Socket'

Change 'Server' to 'Service'.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2018-03-15 09:06:28 -06:00
Michal Privoznik
3ee5f8115d virarptable: Include rtnetlink.h only on Linux
And at the same time, do that from .c rather than .h file.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Chen Hanxiao<chenhanxiao@gmail.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2018-03-15 14:59:12 +01:00
Michal Privoznik
944adb3106 src: Don't add virarptable.c to setuid library
The setuid-rpc-client.la is intended to be small and contain only
bare minimum of source files. virarptable.c is not one of them.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Chen Hanxiao<chenhanxiao@gmail.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2018-03-15 14:59:12 +01:00
Chen Hanxiao
e24d4c9051 qemu: introduce qemuARPGetInterfaces to get IP from host's arp table
introduce VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_ARP to get ip address
of VM from the message of netlink RTM_GETNEIGH

Signed-off-by: Chen Hanxiao <chenhanxiao@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2018-03-15 11:22:42 +01:00
Chen Hanxiao
a176d67cdf util: introduce helper to parse message from RTM_GETNEIGH query
introduce helper to parse RTM_GETNEIGH query message and
store it in struct virArpTable.

Signed-off-by: Chen Hanxiao <chenhanxiao@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2018-03-15 11:22:42 +01:00
Chen Hanxiao
414e61109c util: introduce virNetlinkGetNeighbor to get neighbor table entry
use RTM_GETNEIGH to query arp table entry by netlink socket

Signed-off-by: Chen Hanxiao <chenhanxiao@gmail.com>
2018-03-15 11:22:42 +01:00
Peter Krempa
892e37d5a4 qemu: hotplug: Clean up memory backing files after failed memory hotplug
Libvirt provides full path to the backing file since commit
fec8f9c49a. This made qemu create the backend object but did not
delete it. This was fixed for unplug case in 4d83a6722f but not in case
of failure to hotplug the frontend. We'd leave the files behind which
would make memory unusable in case of hugepages.

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

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-03-15 10:04:40 +01:00
Jiri Denemark
6c2e34e1a7 qemu: Switch context for job related private XML parsing
Having to repeat "./job[1]/" XPath prefix for every single element or
attribute we want to parse is suboptimal. And even more so once we
further extract code from qemuDomainObjPrivateXMLParseJob into separate
functions.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2018-03-15 09:32:14 +01:00
Jiri Denemark
0a3a96b5c3 qemu: Parse all job related private XML in dedicated function
Commit dc567cc22b introduced qemuDomainObjPrivateXMLParseJob, but forgot
to move "./job[1]/@type" parsing into it.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2018-03-15 09:24:20 +01:00
Michal Privoznik
92a5d12157 daemonStreamHandleWriteData: Preserve error when aborting stream
The daemonStreamHandleWriteData() function is called whenever
server side of stream is able to receive some data. Nevertheless,
it calls virStreamSend() (to pass data down to virFDStream) and
depending on its return value it may abort the stream. However,
the functions it called when doing so are public APIs and as such
reset any error set previously. Therefore, if there was any error
in writing data to stream (i.e. repored in virStreamSend) it is
reset before virNetServerProgramSendReplyError() can get to it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2018-03-15 08:25:59 +01:00
Michal Privoznik
bc01d903c2 virsysinfo: Use more virSkipSpacesBackwards()
Some fields reported by dmidecode have plenty of useless spaces
(in fact some have nothing but spaces). To deal with this we have
introduced virSkipSpacesBackwards() and use it in
virSysinfoParseX86Processor() and virSysinfoParseX86Memory().
However, other functions (e.g. virSysinfoParseX86Chassis()) don't
use it at all and thus we are reporting nonsense:

  <sysinfo type='smbios'>
    <chassis>
      <entry name='manufacturer'>FUJITSU</entry>
      <entry name='version'>                      </entry>
      <entry name='serial'>                </entry>
      <entry name='asset'>                                        </entry>
      <entry name='sku'>Default string</entry>
    </chassis>
  </sysinfo>

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2018-03-14 17:43:40 +01:00
Daniel P. Berrangé
fbf31e1a4c qemu: avoid denial of service reading from QEMU guest agent (CVE-2018-1064)
We read from the agent until seeing a \r\n pair to indicate a completed
reply or event. To avoid memory denial-of-service though, we must have a
size limit on amount of data we buffer. 10 MB is large enough that it
ought to cope with normal agent replies, and small enough that we're not
consuming unreasonable mem.

This is identical to the flaw we had reading from the QEMU monitor
as CVE-2018-5748, so rather embarrassing that we forgot to fix
the agent code at the same time.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-03-14 12:16:42 +00:00
Ján Tomko
0d4b988b3e Merge WITH_POLKIT1 and WITH_POLKIT
There is just one polkit now.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
2018-03-14 12:46:26 +01:00
Ján Tomko
ab20f5059c Do not generate polkit rules file
This essentially reverts commit <e1019e9>, which added
an extra step for generating the policy file.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
2018-03-14 12:46:26 +01:00
Ján Tomko
af41cf5957 Remove Policy-Kit support
Policy-Kit has been replaced by polkit (referred to, respectively,
as POLKIT0 and POLKIT1 in our Makefiles).

The last build fix with old Policy-Kit was in May 2013:
commit <442eb2ba> and build with -Wunused-label was broken
since April 2016: commit <8437130>

Signed-off-by: Ján Tomko <jtomko@redhat.com>
2018-03-14 12:46:26 +01:00
Peter Krempa
07141541fb conf: Extract parsing of storage source related data
Split out the parser and separate it from the private data part so that
it can be later reused in other parts of the code.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-03-14 12:19:44 +01:00
Peter Krempa
b17573fe09 conf: Parse and validate disk source seclabels together with the source
Since seclabels are formatted along with the source element and will
also make sense to be passed for the backing chain we should parse them
in the place where we parse the disk source. Same applies for
validation.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-03-14 12:19:44 +01:00
Peter Krempa
3960aeb7a6 conf: Separate seclabel validation from parsing
Rather than checking that the security label is legal when parsing it
move the code into a separate function.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-03-14 12:19:44 +01:00
Peter Krempa
28e1068c4f conf: Validate disk source configuration also for the backing store
Since we already parse the <backingStore> of a disk source, we should
also validate the configuration for the whole backing chain and not only
for the top level image.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-03-14 12:19:44 +01:00
Peter Krempa
c4e7c1f212 conf: disk: Separate virStorageSource formatting
Move out formatting of 'startuPolicy' which is a property of the disk
out of the <source> element. Extracting the code formating the content
and attributes will also allow reuse in other parts of the code.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-03-14 12:19:44 +01:00
Peter Krempa
2bbbc9798d conf: Refactor formatting of startupPolicy in virDomainDiskSourceFormatInternal
Move it to a single location which also allows to get rid of the
temporrary variable.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-03-14 12:19:44 +01:00
Peter Krempa
8f5138829f conf: Remove virDomainDiskSourceDefFormatSeclabel
The wrapper functionality can be moved to the only user
virDomainDiskSourceFormatInternal. Also removes comment which does not
reflect the truth any more.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-03-14 12:19:44 +01:00
Peter Krempa
6bec169759 conf: Refactor seclabel formatting in virDomainDiskSourceFormatInternal
Call the formatter function only once.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-03-14 12:19:44 +01:00
Peter Krempa
bbacd6b113 conf: Remove unnecessary condition from virDomainDiskSourceFormatInternal
Now that the function is using virXMLFormatElement we don't need to
conditionally format anything, since we'll format the element according
to the presence of content.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-03-14 12:19:44 +01:00
Michal Privoznik
ca250269b0 virSecurityDACChownListFree: Don't leak list->items array
We're freeing individual items in it but not the array itself.

==19200== 40 bytes in 1 blocks are definitely lost in loss record 847 of 1,059
==19200==    at 0x4C2D12F: realloc (vg_replace_malloc.c:785)
==19200==    by 0x52C5532: virReallocN (viralloc.c:245)
==19200==    by 0x52C5628: virExpandN (viralloc.c:294)
==19200==    by 0x52C58FC: virInsertElementsN (viralloc.c:436)
==19200==    by 0x542856B: virSecurityDACChownListAppend (security_dac.c:115)
==19200==    by 0x54286B4: virSecurityDACTransactionAppend (security_dac.c:167)
==19200==    by 0x542902F: virSecurityDACSetOwnershipInternal (security_dac.c:560)
==19200==    by 0x54295D6: virSecurityDACSetOwnership (security_dac.c:650)
==19200==    by 0x542AEE0: virSecurityDACSetInputLabel (security_dac.c:1472)
==19200==    by 0x542B61D: virSecurityDACSetAllLabel (security_dac.c:1693)
==19200==    by 0x542DD67: virSecurityManagerSetAllLabel (security_manager.c:869)
==19200==    by 0x54279C2: virSecurityStackSetAllLabel (security_stack.c:361)

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2018-03-13 15:38:17 +01:00
Michal Privoznik
fb0bdb6167 virSysinfoParseX86Chassis: Store asset tag into correct pointer
Probably due to copy-paste error we're storing asset tag into
def->sku which we even use in the next step to store SKU number
and thus the asset tag leaks.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2018-03-13 15:38:17 +01:00
Michal Privoznik
a02a52751f qemuAssignDeviceInputAlias: Be tolerant to pre-existent alias
https://bugzilla.redhat.com/show_bug.cgi?id=1554876

This is missing in 6bc4a371cf and therefore we are effectively
overwriting user provided aliases for <input/> devices.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2018-03-13 15:17:19 +01:00