]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
7 years agovz: build fix
Nikolay Shirokovskiy [Thu, 24 Aug 2017 07:08:35 +0000 (10:08 +0300)]
vz: build fix

6e6faf6d changed vzDomObjAlloc signature in source but not in header file.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
7 years agoconf: check address type for USB hostdevs
Ján Tomko [Wed, 23 Aug 2017 14:32:28 +0000 (16:32 +0200)]
conf: check address type for USB hostdevs

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

7 years agoconf: move hostdev address validation to virDomainHostdevDefValidate
Ján Tomko [Wed, 23 Aug 2017 14:27:36 +0000 (16:27 +0200)]
conf: move hostdev address validation to virDomainHostdevDefValidate

For selected hostdev types, we validate that the address type
matches the subsystem type when parsing the XML.

Move it to the validation phase, to allow extending the checks
to other subsystem types without making existing domains disappear.

7 years agotests: Fix leak in securityselinuxtest
John Ferlan [Wed, 23 Aug 2017 16:32:23 +0000 (12:32 -0400)]
tests: Fix leak in securityselinuxtest

If we jump to the error: label and @secbuf is allocated, then it's not
free'd at all.

Found by Coverity

7 years agovz: support disabled items in vz boot order
Nikolay Shirokovskiy [Fri, 30 Jun 2017 06:34:27 +0000 (09:34 +0300)]
vz: support disabled items in vz boot order

At the time the check was written virtuozzo did not use disabled items in boot
order configuration. Boot items were always enabled. Now they can be disabled
as well. Supporting such items is easy - they just should be ignored.

7 years agodocs: Define anchors correctly in pci-hotplug
Andrea Bolognani [Wed, 23 Aug 2017 11:55:01 +0000 (13:55 +0200)]
docs: Define anchors correctly in pci-hotplug

HTML5 obsoletes the 'name' attribute in favor of 'id',
and our TOC generator apparently follows the recommendation
to the letter, resulting in a broken TOC if you use the
old-school attribute.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
7 years agoconf: do not count per-device boot elements when parsing <os><boot>
Ján Tomko [Fri, 18 Aug 2017 15:55:54 +0000 (17:55 +0200)]
conf: do not count per-device boot elements when parsing <os><boot>

When parsing bootable devices, we maintain a bitmap of used
<boot order=""> elements. Use it in the post-parse function
to figure out whether the user tried to mix per-device and
per-domain boot elements.

This removes the need to count them twice.

7 years agoconf: create a thin wrapper above virDomainDefPostParse
Ján Tomko [Tue, 22 Aug 2017 11:38:35 +0000 (13:38 +0200)]
conf: create a thin wrapper above virDomainDefPostParse

Rename the original function to virDomainDefPostParseInternal
to allow adding arguments that will be only used by the internal
version.

7 years agoconf: rename virDomain*PostParseInternal to virDomain*PostParseCommon
Ján Tomko [Tue, 22 Aug 2017 11:29:24 +0000 (13:29 +0200)]
conf: rename virDomain*PostParseInternal to virDomain*PostParseCommon

These functions contain the post-parse steps common for all drivers.
Rename it to use the 'Common' prefix, instead of the vagueness
of 'Internal', leaving 'Internal' available for other vague uses.

7 years agoconf: move chardev validation into virDomainDeviceDefValidateInternal
Pavel Hrdina [Fri, 18 Aug 2017 20:00:12 +0000 (22:00 +0200)]
conf: move chardev validation into virDomainDeviceDefValidateInternal

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
7 years agoconf: separate PTY chardev source parsing
Pavel Hrdina [Fri, 18 Aug 2017 16:19:48 +0000 (18:19 +0200)]
conf: separate PTY chardev source parsing

There is no reason why to share the same code for PTY and other file
based chardev source types.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
7 years agoconf: move FILE chardev source parsing to separate function
Pavel Hrdina [Fri, 18 Aug 2017 16:17:28 +0000 (18:17 +0200)]
conf: move FILE chardev source parsing to separate function

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
7 years agoconf: assign parsed strings directly into chardev source definition
Pavel Hrdina [Fri, 18 Aug 2017 16:12:08 +0000 (18:12 +0200)]
conf: assign parsed strings directly into chardev source definition

Since the source element is parsed only once for these type of
character devices we don't have to use temporary variable and
check whether the variable was already set.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
7 years agoconf: move UNIX chardev source parsing to separate function
Pavel Hrdina [Fri, 18 Aug 2017 17:25:11 +0000 (19:25 +0200)]
conf: move UNIX chardev source parsing to separate function

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
7 years agoconf: move UDP chardev source parsing to separate function
Pavel Hrdina [Fri, 18 Aug 2017 17:05:20 +0000 (19:05 +0200)]
conf: move UDP chardev source parsing to separate function

The extra check whether (connect|bind)(Host|Service) was set is
required because for UDP chardev there can be two source elements.
Without the check there could be a memory leak.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
7 years agoconf: move TCP chardev source parsing to separate function
Pavel Hrdina [Fri, 18 Aug 2017 17:01:13 +0000 (19:01 +0200)]
conf: move TCP chardev source parsing to separate function

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
7 years agoconf: move mode parsing of chardev source to separate function
Pavel Hrdina [Fri, 18 Aug 2017 15:32:27 +0000 (17:32 +0200)]
conf: move mode parsing of chardev source to separate function

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
7 years agoconf: move chardev log parsing to separate function
Pavel Hrdina [Fri, 18 Aug 2017 15:19:26 +0000 (17:19 +0200)]
conf: move chardev log parsing to separate function

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
7 years agoconf: move chardev protocol parsing to separate function
Pavel Hrdina [Fri, 18 Aug 2017 13:37:08 +0000 (15:37 +0200)]
conf: move chardev protocol parsing to separate function

In order to ensure that the default protocol is RAW, explicitly
assigning VIR_DOMAIN_CHR_TCP_PROTOCOL_RAW = 0.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
7 years agoconf: error out for multiple protocol elements while parsing chardev
Pavel Hrdina [Fri, 18 Aug 2017 13:17:34 +0000 (15:17 +0200)]
conf: error out for multiple protocol elements while parsing chardev

Remove check whether a variable was already set because the element
is parsed only once now.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
7 years agoconf: error out for multiple log elements while parsing chardev
Pavel Hrdina [Fri, 18 Aug 2017 13:15:28 +0000 (15:15 +0200)]
conf: error out for multiple log elements while parsing chardev

Remove check whether a variable was already set because the element
is parsed only once now.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
7 years agoconf: error out for multiple source elements while parsing chardev
Pavel Hrdina [Fri, 18 Aug 2017 15:14:34 +0000 (17:14 +0200)]
conf: error out for multiple source elements while parsing chardev

Currently we accept and correctly parse this chardev XML:

  ...
  <channel type='tcp'>
    <source mode='connect'/>
    <source mode='bind' host='localhost'/>
    <source service='4567'/>
    <target type='virtio' name='test'/>
  </channel>
  ...

The parsed formatted XML is:

  ...
  <channel type='tcp'>
    <source mode='connect' host='localhost' service='4567'/>
    <target type='virtio' name='test'/>
  </channel>
  ...

That behavior is super wrong and should not be allowed.  If you notice
the current parse takes the first found attribute and uses that value,
so for example from the "<source mode='bind' host='localhost'/>" only
the "host" attribute is used.  It works the same way for all possible
attributes that we are able to parse for source element.

This patch enforces providing only one source element for all character
devices, only for UDP type we allow to provide two source elements
since you can specify both modes.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
7 years agoconf: switch from while to for loop for chardev parsing
Pavel Hrdina [Fri, 18 Aug 2017 15:12:59 +0000 (17:12 +0200)]
conf: switch from while to for loop for chardev parsing

This removes one level of indentation.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
7 years agotests: introduce genericxml test for UNIX chardev
Pavel Hrdina [Thu, 17 Aug 2017 12:55:11 +0000 (14:55 +0200)]
tests: introduce genericxml test for UNIX chardev

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
7 years agotests: introduce genericxml test for UDP chardev
Pavel Hrdina [Thu, 17 Aug 2017 12:26:36 +0000 (14:26 +0200)]
tests: introduce genericxml test for UDP chardev

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
7 years agotests: introduce genericxml test for TCP chardev
Pavel Hrdina [Thu, 17 Aug 2017 10:45:48 +0000 (12:45 +0200)]
tests: introduce genericxml test for TCP chardev

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
7 years agoconf: useserial: drop useless check for serial devices
Ján Tomko [Fri, 18 Aug 2017 15:05:35 +0000 (17:05 +0200)]
conf: useserial: drop useless check for serial devices

Since its introduction in commit 874e65aa, if someone requests:
<os><bios useserial="yes"/><os/>
we report an error if we cannot successfully count the number
of serial devices via an XPath query.

Instead of fixing the check (and moving it to the validation phase,
to prevent existing domains from disappearing), drop it completely.
For QEMU, the number of serials is checked when building the command
line.

7 years agoDon't autogenerate seclabels of type 'none'
Jim Fehlig [Wed, 16 Aug 2017 21:46:55 +0000 (15:46 -0600)]
Don't autogenerate seclabels of type 'none'

When security drivers are active but confinement is not enabled,
there is no need to autogenerate <seclabel> elements when starting
a domain def that contains no <seclabel> elements. In fact,
autogenerating the elements can result in needless save/restore and
migration failures when the security driver is not active on the
restore/migration target.

This patch changes the virSecurityManagerGenLabel function in
src/security_manager.c to only autogenerate a <seclabel> element
if none is already defined for the domain *and* default
confinement is enabled. Otherwise the needless <seclabel>
autogeneration is skipped.

Resolves: https://bugzilla.opensuse.org/show_bug.cgi?id=1051017

7 years agoFix building domain def in securityselinuxtest
Jim Fehlig [Wed, 16 Aug 2017 21:45:54 +0000 (15:45 -0600)]
Fix building domain def in securityselinuxtest

The virDomainDef created by testBuildDomainDef in securityselinuxtest
adds a seclabel but does not increment nseclabels. Also, it should
populate seclabel->model with 'selinux'.

While at it, use the secdef itself to populate values instead of
the indirection through def->seclabels[0].

7 years agotools: Fix docs in libvirt-guests configuration file
Lily Zhu [Mon, 14 Aug 2017 16:39:36 +0000 (00:39 +0800)]
tools: Fix docs in libvirt-guests configuration file

It was not entirely clear that PARALLEL_SHUTDOWN setting is applied only
when the desired action is "shutdown".

Signed-off-by: Lily Zhu <lizhu@redhat.com>
7 years agodocs: Improve PCI topology and hotplug guidelines
Andrea Bolognani [Thu, 17 Aug 2017 12:11:56 +0000 (14:11 +0200)]
docs: Improve PCI topology and hotplug guidelines

Address some minor flaws in the original document that
were pointed out during review.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
7 years agoconf: Use the correct limit for the number of PHBs
Andrea Bolognani [Thu, 17 Aug 2017 15:19:57 +0000 (17:19 +0200)]
conf: Use the correct limit for the number of PHBs

I mistakenly thought pSeries guests supported 32 PHBs,
but it turns out they only support 31. Validate the
target index accordingly.

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

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
7 years agoconf: Move target index validation
Andrea Bolognani [Thu, 17 Aug 2017 14:22:14 +0000 (16:22 +0200)]
conf: Move target index validation

Validation should happen after parsing, so the proper
location for it is virDomainControllerDefValidate()
rather than virDomainControllerDefParseXML().

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
7 years agotests: Improve target index validation coverage
Andrea Bolognani [Thu, 17 Aug 2017 14:45:28 +0000 (16:45 +0200)]
tests: Improve target index validation coverage

Split one of the existing tests to ensure both configuration
errors it contained cause a failure, and introduce a new
test case.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
7 years agoqemu: Implement postParse callback skipping on config reload
Peter Krempa [Wed, 16 Aug 2017 14:00:25 +0000 (16:00 +0200)]
qemu: Implement postParse callback skipping on config reload

Use the new facility which allows to ignore failures in post parse
callbacks if they are not fatal so that VM configs are not lost if the
emulator binary is missing.

If qemuCaps can't be populated on daemon restart skip certain portions
of the post parse callbacks during config reload and re-run the callback
during VM startup.

This fixes VMs vanishing if the emulator binary was broken or
uninstalled and libvirtd was restarted.

7 years agoqemu: domain: Don't set default USB model if qemuCaps is missing
Peter Krempa [Wed, 16 Aug 2017 13:54:10 +0000 (15:54 +0200)]
qemu: domain: Don't set default USB model if qemuCaps is missing

qemuDomainControllerDefPostParse assigns the default USB controller
model when it was not specified by the user. Skip this step if @qemuCaps
is missing so that we don't fill wrong data. This will then be fixes by
re-running the post parse callback.

7 years agoqemu: domain: Don't return default NIC model if @qemuCaps are missing
Peter Krempa [Wed, 16 Aug 2017 13:49:15 +0000 (15:49 +0200)]
qemu: domain: Don't return default NIC model if @qemuCaps are missing

Return NULL in qemuDomainDefaultNetModel if qemuCaps is missing and the
network card model would be determined by the capabilities.

7 years agoqemu: capabilities: Tolerate missing @qemuCaps in virQEMUCapsSupportsGICVersion
Peter Krempa [Wed, 16 Aug 2017 13:44:35 +0000 (15:44 +0200)]
qemu: capabilities: Tolerate missing @qemuCaps in virQEMUCapsSupportsGICVersion

Report the given GIC version as unsupported if @qemuCapsi is NULL. This
will be helpful to run post parse callbacks even if qemu is not
currently installed.

7 years agoqemu: capabilities: Tolerate missing @qemuCaps in virQEMUCapsGetCanonicalMachine
Peter Krempa [Wed, 16 Aug 2017 13:37:18 +0000 (15:37 +0200)]
qemu: capabilities: Tolerate missing @qemuCaps in virQEMUCapsGetCanonicalMachine

If qemuCaps are not present, just return the original machine type name.

This will help in situations when qemuCaps is not available in the post
parse callback.

7 years agoconf: add infrastructure for tolerating certain post parse callback failures
Peter Krempa [Tue, 15 Aug 2017 16:41:59 +0000 (18:41 +0200)]
conf: add infrastructure for tolerating certain post parse callback failures

Some failures of the post parse callback can be tolerated. This is
specifically desired when loading the configs of existing VMs. In such
case the post parse callback should not really be modifying anything
in the definition.

This patch adds a parse flag VIR_DOMAIN_DEF_PARSE_ALLOW_POST_PARSE_FAIL
which will allow the callbacks to report non-fatal failures by returning
a positive return value. In such case the field 'postParseFailed' in the
domain definition is set to true, to notify the drivers that the
callback failed and possibly needs to be re-run.

7 years agoconf: Return any non-zero value from virDomainDeviceInfoIterateInternal callback
Peter Krempa [Tue, 15 Aug 2017 16:09:32 +0000 (18:09 +0200)]
conf: Return any non-zero value from virDomainDeviceInfoIterateInternal callback

Post parse callbacks will need to be able to signal that they failed
non-fatally. This means that we need to return the value returned by the
callback without modification.

7 years agoqemu: domain: Don't re-allocate qemuCaps in post parse callbacks
Peter Krempa [Tue, 15 Aug 2017 13:25:23 +0000 (15:25 +0200)]
qemu: domain: Don't re-allocate qemuCaps in post parse callbacks

The domain post parse callback, domain address callback and the domain
device callback (for every single device) would each grab qemuCaps for
the current emulator. This is quite wasteful. Use the new callback to do
this just once.

7 years agoconf: Add callbacks that allocate per-def private data
Peter Krempa [Tue, 15 Aug 2017 13:18:51 +0000 (15:18 +0200)]
conf: Add callbacks that allocate per-def private data

Some drivers use def-specific private data across callbacks (e.g.
qemuCaps in the qemu driver). Currently it's mostly allocated in every
single callback. This is rather wasteful, given that every single call
to the device callback allocates it.

The new callback will allocate the data (if not provided externally) and
then use it for the VM, address and device post parse callbacks.

7 years agoqemu: Move assignment of default emulator to the basic post parse callback
Peter Krempa [Tue, 15 Aug 2017 13:16:20 +0000 (15:16 +0200)]
qemu: Move assignment of default emulator to the basic post parse callback

7 years agoconf: Add 'basic' post parse callback
Peter Krempa [Tue, 15 Aug 2017 13:11:45 +0000 (15:11 +0200)]
conf: Add 'basic' post parse callback

Add yet another post parse callback, which is executed prior the real
one without @parseOpaque. This is meant to set basics before
@parseOpaque (in case of the qemu driver qemuCaps) can be allocated.

This callback will allow to optimize passing of custom parseOpaque
through the callbacks.

7 years agoconf: domainlist: Explicitly report failure to load domain config
Peter Krempa [Thu, 10 Aug 2017 15:18:52 +0000 (17:18 +0200)]
conf: domainlist: Explicitly report failure to load domain config

When dropping a domain report which one was dropped so that it's not
necessary to rummage through the logs.

7 years agoqemu: don't check whether offline migration is safe
Pavel Hrdina [Thu, 17 Aug 2017 16:36:46 +0000 (18:36 +0200)]
qemu: don't check whether offline migration is safe

Offline migration transfers only the domain definition.

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

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
7 years agoutil: string: Introduce virStringHasChars
Peter Krempa [Wed, 26 Apr 2017 14:26:53 +0000 (16:26 +0200)]
util: string: Introduce virStringHasChars

The helper returns true if a string contains any of the given chars.
virStringHasControlChars can be reimplemented using that helper.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
7 years agonodedev: Introduce udevHandleOneDevice
Erik Skultety [Tue, 25 Jul 2017 15:41:31 +0000 (17:41 +0200)]
nodedev: Introduce udevHandleOneDevice

Let this new method handle the device object we obtained from the
monitor in order to enhance readability.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
7 years agonodedev: udev: Remove the udevEventHandleCallback on fatal error
Erik Skultety [Wed, 28 Jun 2017 13:39:51 +0000 (15:39 +0200)]
nodedev: udev: Remove the udevEventHandleCallback on fatal error

So we have a sanity check for the udev monitor fd. Theoretically, it
could happen that the udev monitor fd changes (due to our own wrongdoing,
hence the 'sanity' here) and if that happens it means we are handling an
event from a different entity than we think, thus we should remove the
handle if someone somewhere somehow hits this hypothetical case.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
7 years agonodedev: mdev: Report an error when mdev path resolution fails
Erik Skultety [Tue, 20 Jun 2017 14:50:26 +0000 (16:50 +0200)]
nodedev: mdev: Report an error when mdev path resolution fails

It might happen that virFileResolveLinkHelper fails on the lstat system
call. virFileResolveLink expects the caller to report an error when it
fails, however this wasn't the case for udevProcessMediatedDevice.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
7 years agovirt-aa-helper: locking loader/nvram for qemu 2.10
Christian Ehrhardt [Thu, 17 Aug 2017 08:55:43 +0000 (10:55 +0200)]
virt-aa-helper: locking loader/nvram for qemu 2.10

Testing qemu-2.10-rc3 shows issues like:
  qemu-system-aarch64: -drive file=/home/ubuntu/vm-start-stop/vms/
  7936-0_CODE.fd,if=pflash,format=raw,unit=1: Failed to unlock byte 100

There is an apparmor deny due to qemu now locking those files:
 apparmor="DENIED" operation="file_lock" [...]
 name="/home/ubuntu/vm-start-stop/vms/7936-0_CODE.fd"
 name="/var/lib/uvtool/libvirt/images/kvmguest-artful-normal.qcow"
 [...] comm="qemu-system-aarch64" requested_mask="k" denied_mask="k"

The profile needs to allow locking for loader and nvram files via
the locking (k) rule.

Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
7 years agovirt-aa-helper: locking disk files for qemu 2.10
Christian Ehrhardt [Thu, 10 Aug 2017 09:19:19 +0000 (11:19 +0200)]
virt-aa-helper: locking disk files for qemu 2.10

Testing qemu-2.10-rc2 shows issues like:
  qemu-system-x86_64: -drive file=/var/lib/uvtool/libvirt/images/kvmguest- \
  artful-normal.qcow,format=qcow2,if=none,id=drive-virtio-disk0:
  Failed to lock byte 100

It seems the following qemu commit changed the needs for the backing
image rules:

(qemu) commit 244a5668106297378391b768e7288eb157616f64
Author: Fam Zheng <famz@redhat.com>
    file-posix: Add image locking to perm operations

The block appears as:
 apparmor="DENIED" operation="file_lock" [...]
 name="/var/lib/uvtool/libvirt/images/kvmguest-artful-normal.qcow"
 [...] comm="qemu-system-x86" requested_mask="k" denied_mask="k"

With that qemu change in place the rules generated for the image
and backing files need the allowance to also lock (k) the files.

Disks are added via add_file_path and with this fix rules now get
that permission, but no other rules are changed, example:
  -  "/var/lib/uvtool/libvirt/images/kvmguest-artful-normal-a2.qcow" rw,
  +  "/var/lib/uvtool/libvirt/images/kvmguest-artful-normal-a2.qcow" rwk

Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
7 years agoconf: use virXMLPropString and virXMLNodeContentString for vcpu parsing
Pavel Hrdina [Wed, 16 Aug 2017 08:45:14 +0000 (10:45 +0200)]
conf: use virXMLPropString and virXMLNodeContentString for vcpu parsing

XPath is good for random search of elements, not for accessing
attributes of one node.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
7 years agoconf: use virXMLNodeContentString for boot options parsing
Pavel Hrdina [Wed, 16 Aug 2017 08:28:16 +0000 (10:28 +0200)]
conf: use virXMLNodeContentString for boot options parsing

Using XPath here doesn't add any benefit.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
7 years agoconf: use virXMLPropStringLimit where it makes sense
Pavel Hrdina [Tue, 15 Aug 2017 13:31:06 +0000 (15:31 +0200)]
conf: use virXMLPropStringLimit where it makes sense

The XPath call for these cases is more expensive than accessing the
XML dom node directly.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
7 years agoconf: use virXMLPropString for actual network parsing
Pavel Hrdina [Wed, 16 Aug 2017 12:01:54 +0000 (14:01 +0200)]
conf: use virXMLPropString for actual network parsing

XPath is good for random search of elements, not for accessing
attributes of one node.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
7 years agoconf: use virXMLPropString for boot parsing
Pavel Hrdina [Wed, 16 Aug 2017 08:23:20 +0000 (10:23 +0200)]
conf: use virXMLPropString for boot parsing

XPath is good for random search of elements, not for accessing
attributes of one node.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
7 years agoconf: use virXMLPropString for network parsing
Pavel Hrdina [Wed, 16 Aug 2017 08:20:30 +0000 (10:20 +0200)]
conf: use virXMLPropString for network parsing

XPath is good for random search of elements, not for accessing
attributes of one node.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
7 years agoconf: use virXMLPropString for IOMMU def parsing
Pavel Hrdina [Tue, 15 Aug 2017 13:52:38 +0000 (15:52 +0200)]
conf: use virXMLPropString for IOMMU def parsing

XPath is good for random search of elements, not for accessing
attributes of one node.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
7 years agoconf: use virXMLPropString for virDomainVirtioOptionsParseXML
Pavel Hrdina [Tue, 15 Aug 2017 11:51:37 +0000 (13:51 +0200)]
conf: use virXMLPropString for virDomainVirtioOptionsParseXML

XPath is good for random search of elements, not for accessing
attributes of one node.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
7 years agoutil: introduce virXMLNodeContentString
Pavel Hrdina [Wed, 16 Aug 2017 08:26:09 +0000 (10:26 +0200)]
util: introduce virXMLNodeContentString

It's equivalent of calling virXPathString("string(.)", ctxt) but it
doesn't have to use the XPath resolving and parsing.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
7 years agoutil: introduce virXMLPropStringLimit
Pavel Hrdina [Tue, 15 Aug 2017 13:20:55 +0000 (15:20 +0200)]
util: introduce virXMLPropStringLimit

The virXMLPropStringLimit is an equivalent of virXPathStringLimit
which should be preferred if you already have a XML dom node or
if you need to parse more than one property.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
7 years agonetwork: Use self inflating bitmap for class IDs
Michal Privoznik [Wed, 16 Aug 2017 10:55:03 +0000 (12:55 +0200)]
network: Use self inflating bitmap for class IDs

Back in the day when I was implementing QoS for networks there
were no self inflating virBitmaps. Only the static ones.
Therefore, I had to allocate the whole 8KB of memory in order to
keep track of used/unused class IDs. This is rather wasteful
because nobody is ever gonna use that much classes (kernel
overhead would drastically lower the bandwidth). Anyway, now that
we have self inflating bitmaps we can start small and allocate
more if there's need for it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agonetwork: Use @nnames instead of @got
John Ferlan [Tue, 15 Aug 2017 20:48:37 +0000 (16:48 -0400)]
network: Use @nnames instead of @got

To make it clearer, let's use @nnames instead of @got for counting the
names in the @names array.  Keeps things consistent and clear.

7 years agotests: add qemu x86 kvm 32-on-64 test
Cole Robinson [Thu, 13 Jul 2017 15:32:41 +0000 (11:32 -0400)]
tests: add qemu x86 kvm 32-on-64 test

There's some specific logic in qemuBuildCpuCommandLine to support
auto adding -cpu qemu 32 for arch=i686 with an x86_64 qemu binary.
Add a test case for it

7 years agostorage: Alter @aclfilter to just @filter
John Ferlan [Wed, 16 Aug 2017 13:26:59 +0000 (09:26 -0400)]
storage: Alter @aclfilter to just @filter

Rename the variable, recent review requested just use of @filter,
so be consistent throughout.

7 years agosecret: Alter @aclfilter to just @filter
John Ferlan [Wed, 16 Aug 2017 13:26:41 +0000 (09:26 -0400)]
secret: Alter @aclfilter to just @filter

Rename the variable, recent review requested just use of @filter,
so be consistent throughout.

7 years agonwfilter: Alter @aclfilter to just @filter
John Ferlan [Wed, 16 Aug 2017 13:26:07 +0000 (09:26 -0400)]
nwfilter: Alter @aclfilter to just @filter

Rename the variable, recent review requested just use of @filter,
so be consistent throughout.

NB: Also change the virNWFilterPtr to be @nwfilter to not conflict
with the renamed variable.

7 years agonodedev: Alter @aclfilter to just @filter
John Ferlan [Wed, 16 Aug 2017 13:23:27 +0000 (09:23 -0400)]
nodedev: Alter @aclfilter to just @filter

Rename the variable, recent review requested just use of @filter,
so be consistent throughout.

7 years agonetwork: Privatize virNetworkObj
John Ferlan [Fri, 12 May 2017 12:40:04 +0000 (08:40 -0400)]
network: Privatize virNetworkObj

Move from virnetworkobj.h into virnetworkobj.c

Signed-off-by: John Ferlan <jferlan@redhat.com>
7 years agonetwork: Modify naming for virNetworkObjList* fetching APIs
John Ferlan [Wed, 10 May 2017 12:58:38 +0000 (08:58 -0400)]
network: Modify naming for virNetworkObjList* fetching APIs

Use the structure names in the @data setup - makes it easier than
going back to find the struct fields to make sure the order of the
data is correct.

Signed-off-by: John Ferlan <jferlan@redhat.com>
7 years agonetwork: Use @maxnames instead of @nnames
John Ferlan [Wed, 26 Jul 2017 14:18:39 +0000 (10:18 -0400)]
network: Use @maxnames instead of @nnames

To be consistent with the API definition, use the @maxnames instead
of @nnames when describing/comparing against the maximum names to
be provided for the *ConnectList[Defined]Networks APIs.

Signed-off-by: John Ferlan <jferlan@redhat.com>
7 years agonetwork: Move virObjectRef during AssignDef processing
John Ferlan [Wed, 26 Jul 2017 13:43:12 +0000 (09:43 -0400)]
network: Move virObjectRef during AssignDef processing

Move the virObjectRef in virNetworkObjAssignDefLocked to after
the virHashAddEntry to make it "clearer" why the @ref is being
incremented. Upon return from the ObjNew we will have 1 ref on
the object already, adding it to the hash table requires the
increment.

Signed-off-by: John Ferlan <jferlan@redhat.com>
7 years agonetwork: Have virNetworkObjNew lock the returned object
John Ferlan [Wed, 10 May 2017 12:40:40 +0000 (08:40 -0400)]
network: Have virNetworkObjNew lock the returned object

Forces callers to use the virNetworkObjEndAPI properly.

Signed-off-by: John Ferlan <jferlan@redhat.com>
7 years agonetwork: Consistent use of @obj for virnetworkobj
John Ferlan [Wed, 10 May 2017 11:59:48 +0000 (07:59 -0400)]
network: Consistent use of @obj for virnetworkobj

Consistently use @obj for a virNetworkObjPtr.

Signed-off-by: John Ferlan <jferlan@redhat.com>
7 years agonetwork: Introduce virNetworkObjIsPersistent
John Ferlan [Wed, 10 May 2017 11:29:57 +0000 (07:29 -0400)]
network: Introduce virNetworkObjIsPersistent

In preparation to privatize the virNetworkObj - create an accessor function
to get the current @persistent value.  Also change the value to a bool rather
than an unsigned int (since that's how it's generated anyway).

Signed-off-by: John Ferlan <jferlan@redhat.com>
7 years agonetwork: Introduce virNetworkObj{Is|Set}Active
John Ferlan [Wed, 10 May 2017 11:22:15 +0000 (07:22 -0400)]
network: Introduce virNetworkObj{Is|Set}Active

In order to privatize the virNetworkObj create accessors in virnetworkobj
in order to handle the get/set of the active value.

Also rather than an unsigned int, convert it to a boolean to match other
drivers representation and the reality of what it is.

Signed-off-by: John Ferlan <jferlan@redhat.com>
7 years agonetwork: Introduce virNetworkObj{Is|Set}Autostart
John Ferlan [Wed, 10 May 2017 11:12:27 +0000 (07:12 -0400)]
network: Introduce virNetworkObj{Is|Set}Autostart

In preparation for privatizing the virNetworkObj structure, create
accessors for the obj->autostart.

Signed-off-by: John Ferlan <jferlan@redhat.com>
7 years agonetwork: Add virNetworkObj Get/Set API's for @def and @newDef
John Ferlan [Tue, 9 May 2017 22:38:58 +0000 (18:38 -0400)]
network: Add virNetworkObj Get/Set API's for @def and @newDef

In preparation for making the object private, create a couple of API's
to get the obj->def & obj->newDef and set the obj->def.

While altering networkxml2conftest.c to use the virNetworkObjSetDef
API, fix the name of the variable from @dev to @def

Signed-off-by: John Ferlan <jferlan@redhat.com>
7 years agonetwork: Add virNetworkObj Get/Set API's for @floor_sum
John Ferlan [Tue, 9 May 2017 21:57:41 +0000 (17:57 -0400)]
network: Add virNetworkObj Get/Set API's for @floor_sum

In preparation for making the object private, create a couple of API's
to get/set the obj->floor_sum.

Signed-off-by: John Ferlan <jferlan@redhat.com>
7 years agonetwork: Introduce virNetworkObjGetClassIdMap
John Ferlan [Tue, 9 May 2017 21:41:23 +0000 (17:41 -0400)]
network: Introduce virNetworkObjGetClassIdMap

In preparation for privatizing virNetworkObj, create accessor function to
fetch the @classIdMap.

Signed-off-by: John Ferlan <jferlan@redhat.com>
7 years agonetwork: Alter virNetworkObj @class_id to be @classIdMap
John Ferlan [Wed, 26 Jul 2017 12:01:55 +0000 (08:01 -0400)]
network: Alter virNetworkObj @class_id to be @classIdMap

Change the variable name to be a bit more descriptive and less confusing
when used with the data.network.actual->class_id.

Signed-off-by: John Ferlan <jferlan@redhat.com>
7 years agonetwork: Add virNetworkObj Get/Set API's for @dnsmasqPid and @radvdPid
John Ferlan [Tue, 9 May 2017 21:22:43 +0000 (17:22 -0400)]
network: Add virNetworkObj Get/Set API's for @dnsmasqPid and @radvdPid

In preparation for making the object private, create/use a couple of API's
to get/set the obj->dnsmasqPid and obj->radvdPid.

NB: Since the pid's can sometimes changed based on intervening functions,
be sure to always fetch the latest value.

Signed-off-by: John Ferlan <jferlan@redhat.com>
7 years agonetwork: Unconditionally initialize macmap when stopping virtual network
John Ferlan [Wed, 26 Jul 2017 11:42:51 +0000 (07:42 -0400)]
network: Unconditionally initialize macmap when stopping virtual network

Since we can only ever have one reference to obj->macmap, rather
than only clearing obj->macmap during virNetworkObjUnrefMacMap
(e.g. virtual network from networkShutdownNetwork), let's just
unconditionally clear the obj->macmap to ensure that some future
change that created it's own reference to obj->macmap wouldn't
have that reference disappear if virNetworkObjDispose got called.

Signed-off-by: John Ferlan <jferlan@redhat.com>
7 years agonetwork: Move macmap mgmt from bridge_driver to virnetworkobj
John Ferlan [Tue, 9 May 2017 20:51:05 +0000 (16:51 -0400)]
network: Move macmap mgmt from bridge_driver to virnetworkobj

In preparation for having a private virNetworkObj - let's create/move some
API's that handle the obj->macmap. The API's will be renamed to have a
virNetworkObj prefix to follow conventions and the arguments slightly
modified to accept what's necessary to complete their task.

Signed-off-by: John Ferlan <jferlan@redhat.com>
7 years agonetwork: Move and rename networkMacMgrFileName
John Ferlan [Wed, 26 Jul 2017 10:59:19 +0000 (06:59 -0400)]
network: Move and rename networkMacMgrFileName

Move networkMacMgrFileName into src/util/virmacmap.c and rename to
virMacMapFileName. We're about to move some more MacMgr processing
files into virnetworkobj and it doesn't make sense to have this helper
in the driver or in virnetworkobj.

Signed-off-by: John Ferlan <jferlan@redhat.com>
7 years agonetwork: Use consistent naming in bridge_driver for virNetwork objects
John Ferlan [Tue, 9 May 2017 19:18:31 +0000 (15:18 -0400)]
network: Use consistent naming in bridge_driver for virNetwork objects

Use @obj for a virNetworkObjPtr

Use @net for a virNetworkPtr

Signed-off-by: John Ferlan <jferlan@redhat.com>
7 years agonetwork: Perform some formatting cleanup in bridge_driver.h
John Ferlan [Wed, 26 Jul 2017 10:39:19 +0000 (06:39 -0400)]
network: Perform some formatting cleanup in bridge_driver.h

Alter prototypes to utilize some more recent guidelines.

Signed-off-by: John Ferlan <jferlan@redhat.com>
7 years agolibvirtd.conf: Drop max_requests
Michal Privoznik [Tue, 15 Aug 2017 08:34:45 +0000 (10:34 +0200)]
libvirtd.conf: Drop max_requests

Since its introduction in f61341173bdaa2e0 it was never
implemented nor there are plans to implement it. Drop it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
7 years agoqemu: Fix bug assuming usage of default UUID for certificate passphrase
John Ferlan [Fri, 21 Jul 2017 21:25:57 +0000 (17:25 -0400)]
qemu: Fix bug assuming usage of default UUID for certificate passphrase

If an environment specific _tls_x509_cert_dir is provided, then
do not VIR_STRDUP the defaultTLSx509secretUUID as that would be
for the "default" environment and not the vnc, spice, chardev, or
migrate environments. If the environment needs a secret to decode
it's certificate, then it must provide the secret. If the secrets
happen to be the same, then configuration would use the same UUID
as the default (but we cannot assume that nor can we assume that
the secret would be necessary).

7 years agoutil: Add object checking for virObject{Ref|Unref}
John Ferlan [Fri, 31 Mar 2017 15:35:05 +0000 (11:35 -0400)]
util: Add object checking for virObject{Ref|Unref}

Rather than assuming that what's passed to virObject{Ref|Unref}
would be a virObjectPtr as long as it's not NULL, let's do the
similar checks virObjectIsClass in order to prevent a possible
increment or decrement to some field at the obj->u.s.refs offset.

Signed-off-by: John Ferlan <jferlan@redhat.com>
7 years agoutil: Add magic number check for object validity
John Ferlan [Mon, 31 Jul 2017 22:58:55 +0000 (18:58 -0400)]
util: Add magic number check for object validity

The virObjectIsClass API has only ever checked object validity
based on if the @obj is not NULL and it was derived from some class.
While this has worked well in general, there is one additional
check that could be made prior to calling virClassIsDerivedFrom
which loops through the classes checking the magic number against
the klass expected magic number.

If by chance a non virObject is passed, rather than assuming the
void * @obj is a _virObject and thus offsetting to obj->klass,
obj->magic, and obj->parent, let's check that the void * @obj
has at least the "base part" of the magic number in the right
place and generate a more specific VIR_WARN message if not.

There are many consumers to virObjectIsClass, include the locking
primitives virObject{Lock|Unlock}, virObjectRWLock{Read|Write},
and virObjectRWUnlock. For those callers, the locking call will
not fail, but it also will not attempt a virMutex* call which
will "most likely" fail since the &obj->lock is used.

In order to avoid some possible future wrap on the 0xCAFExxxx
value, add a check during initialization that some new class
won't cause the wrap. Should be good for a few years at least!

It is still left up to the caller to handle the failed API calls
just as it would be if it passed a NULL opaque pointer anyobj.

7 years agoutil: Create common error path for invalid object
John Ferlan [Fri, 28 Jul 2017 15:09:31 +0000 (11:09 -0400)]
util: Create common error path for invalid object

If virObjectIsClass fails "internally" to virobject.c, create a
macro to generate the VIR_WARN describing what the problem is.
Also improve the checks and message a bit to indicate which was
the failure - whether the obj was NULL or just not the right class

Signed-off-by: John Ferlan <jferlan@redhat.com>
7 years agoutil: Introduce and use virObjectRWUnlock
John Ferlan [Fri, 28 Jul 2017 16:03:50 +0000 (12:03 -0400)]
util: Introduce and use virObjectRWUnlock

Rather than overload virObjectUnlock as commit id '77f4593b' has
done, create a separate virObjectRWUnlock API that will force the
consumers to make the proper decision regarding unlocking the
RWLock's. Similar to the RWLockRead and RWLockWrite, use the
virObjectGetRWLockableObj helper. This restores the virObjectUnlock
code to using the virObjectGetLockableObj.

Signed-off-by: John Ferlan <jferlan@redhat.com>
7 years agoutil: Introduce virObjectGetRWLockableObj
John Ferlan [Fri, 28 Jul 2017 14:27:11 +0000 (10:27 -0400)]
util: Introduce virObjectGetRWLockableObj

Introduce a helper to handle the error path more cleanly. The same
as virObjectGetLockableObj in order to essentially follow the original
logic of commit 'b545f65d' to ensure that the input argument at least
has some validity before using.

Signed-off-by: John Ferlan <jferlan@redhat.com>
7 years agoutil: Only have virObjectLock handle virObjectLockable
John Ferlan [Fri, 28 Jul 2017 14:14:40 +0000 (10:14 -0400)]
util: Only have virObjectLock handle virObjectLockable

Now that virObjectRWLockWrite exists to handle the virObjectRWLockable
objects, let's restore virObjectLock to only handle virObjectLockable
class locks. There still exists the possibility that the input @anyobj
isn't a valid object and the resource isn't truly locked, but that
also exists before commit id '77f4593b'.

This also restores some logic that commit id '77f4593b' removed
with respect to a common code path that commit id '10c2bb2b' had
introduced as virObjectGetLockableObj. This code path merely does
the same checks as the original virObjectLock commit 'b545f65d',
but in callable/reusable helper to ensure the @obj at least has
some validity before using.

Signed-off-by: John Ferlan <jferlan@redhat.com>
7 years agoutil: Introduce and use virObjectRWLockWrite
John Ferlan [Fri, 28 Jul 2017 14:06:55 +0000 (10:06 -0400)]
util: Introduce and use virObjectRWLockWrite

Instead of making virObjectLock be the entry point for two
different types of locks, let's create a virObjectRWLockWrite API
which will only handle the virObjectRWLockableClass objects.

Use the new virObjectRWLockWrite for the virdomainobjlist code
in order to handle the Add, Remove, Rename, and Load operations
that need to be very synchronous.

Signed-off-by: John Ferlan <jferlan@redhat.com>
7 years agoutil: Rename virObjectLockRead to virObjectRWLockRead
John Ferlan [Fri, 28 Jul 2017 13:57:04 +0000 (09:57 -0400)]
util: Rename virObjectLockRead to virObjectRWLockRead

Since the class it represents is based on virObjectRWLockableClass
and in order to make sure we differentiate just in case anyone somehow
believes they could use virObjectLockRead for a virObjectLockableClass,
let's rename the API to use the RW in the name. Besides the RW locks
refer to pthread_rwlock_{init|rdlock|wrlock|unlock|destroy} while the
other locks refer to pthread_mutex_{init|lock|unlock|destroy}.

Signed-off-by: John Ferlan <jferlan@redhat.com>
7 years agoqemu: fix nwfilter deadlock in qemuProcessReconnect
Pavel Hrdina [Mon, 7 Aug 2017 12:42:58 +0000 (14:42 +0200)]
qemu: fix nwfilter deadlock in qemuProcessReconnect

The correct lock order is:

  nwfilter driver lock (not used in this code path)
  nwfilter update lock
  virt driver lock (not used in this code path)
  domain object lock

but the current code have this order:

  domain object lock
  nwfilter update lock

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>