Commit Graph

2756 Commits

Author SHA1 Message Date
John Ferlan
eabeff8ea3 conf: Introduce virinterfaceobj
Move all the InterfaceObj API's into their own module virinterfaceobj
from the interface_conf

Purely code motion at this point.
2017-03-06 07:07:01 -05:00
John Ferlan
cbcfd09769 node: Replace variable named 'system' with 'syscap'
Changes in commit id 'dec6d9df' caused a compilation failure on a RHEL6
CI build environment. So just replace 'system' with 'syscap' as a name.

cc1: warnings being treated as errors
../../src/conf/node_device_conf.c: In function 'virNodeDevCapSystemParseXML':
../../src/conf/node_device_conf.c:1415: error: declaration of 'system' shadows a global declaration [-Wshadow]
2017-03-04 10:42:33 -05:00
John Ferlan
dec6d9df5f nodedev: Reduce virNodeDevCapDataPtr usage
Replace with more data specific pointer types.
2017-03-03 18:36:09 -05:00
John Ferlan
a6c3382e8e conf: Clean up the _virNodeDevCapData
Rather than a bunch of embedded union structs, let's create structs
for each of the structs within the union and make the struct easier
to read.
2017-03-03 18:36:09 -05:00
John Ferlan
25ad94ecf5 conf: Alter coding style of nodedev function prototypes
In an effort to be consistent with the source module, alter the function
prototypes to follow the similar style of source with the "type" on one
line followed by the function name and arguments on subsequent lines with
with argument getting it's own line.
2017-03-03 18:36:09 -05:00
John Ferlan
0a5cc56d92 conf: Use consistent function name prefixes for virnodedeviceobj
Use "virNodeDeviceObj" as a prefix for any external API in virnodedeviceobj
2017-03-03 18:36:09 -05:00
John Ferlan
29714483a6 conf: Adjust coding style for nodedev conf sources
Alter the format of the code to follow more recent style guidelines of
two empty lines between functions, function decls with "[static] type"
on one line followed by function name with arguments to functions each
on one line.
2017-03-03 18:36:09 -05:00
John Ferlan
bc20200e53 conf: Introduce virnodedeviceobj
Move all the NodeDeviceObj API's into their own module virnodedeviceobj
from the node_device_conf

Purely code motion at this point, plus adjustments to cleanly build.
2017-03-03 18:36:09 -05:00
John Ferlan
ca1f385457 conf: Fix leak in virNodeDeviceDefParseXML
The 'nodes' is overwritten after the first usage and possibly leaked
if any code in the first set of parsing goes to error.

Found by Coverity.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2017-02-27 17:04:33 -05:00
Daniel P. Berrange
5d84f5961b Add ATTRIBUTE_FALLTHROUGH for switch cases without break
In GCC 7 there is a new warning triggered when a switch
case has a conditional statement (eg if ... else...) and
some of the code paths fallthrough to the next switch
statement. e.g.

conf/domain_conf.c: In function 'virDomainChrEquals':
conf/domain_conf.c:14926:12: error: this statement may fall through [-Werror=implicit-fallthrough=]
         if (src->targetTypeAttr != tgt->targetTypeAttr)
            ^
conf/domain_conf.c:14928:5: note: here
     case VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE:
     ^~~~
conf/domain_conf.c: In function 'virDomainChrDefFormat':
conf/domain_conf.c:22143:12: error: this statement may fall through [-Werror=implicit-fallthrough=]
         if (def->targetTypeAttr) {
            ^
conf/domain_conf.c:22151:5: note: here
     default:
     ^~~~~~~

GCC introduced a __attribute__((fallthrough)) to let you
indicate that this is intentionale behaviour rather than
a bug.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2017-02-23 10:11:16 +00:00
Andrea Bolognani
77edbf5127 conf: Make switch statements more strict
When switching over the values in the virDomainControllerModelPCI
enumeration, make sure the proper cast is in place so that the
compiler can warn us when the coverage is not exaustive.

For the same reason, remove the 'default' case from one of the
existing switch statements.
2017-02-22 18:55:55 +01:00
Andrea Bolognani
c6a0fb8e71 conf: Remove dead code
The switch in virDomainPCIControllerModelToConnectType()
had some code that, while techically part of the
_PCIE_SWITCH_DOWNSTREAM_PORT case, was in fact dead due
to the early return.

Get rid of the dead code, and fix the inaccurate function
description while at it.
2017-02-22 18:55:54 +01:00
Michal Privoznik
0888cb6ab4 conf: Don't accept dummy values for <memoryBacking/> attributes
Our virSomeEnumTypeFromString() functions return either the value
of item from the enum or -1 on error. Usually however the value 0
means 'this value is not set in the domain XML, use some sensible
default'. Therefore, we don't accept corresponding string in
domain XML, for instance:

<memoryBacking>
  <source mode="none"/>
  <access mode="default"/>
  <allocation mode="none"/>
</memoryBacking>

should be rejected as invalid XML.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2017-02-22 09:11:33 +01:00
John Ferlan
5ad03b9db2 conf: Fix leak in virNodeDeviceObjListExport
Fix a leak introduced by 4337bc57b when VIR_STRDUP'g the parent.
2017-02-21 10:52:20 -05:00
John Ferlan
0a6cb28b9a conf: Cleanup matchFCHostToSCSIHost
Rather than the inlined VIR_FREE's, use a cleanup: label... Fixes an
issue introduced by 03346def where @name was free'd before usage in
a virAsprintf to format scsi_host_name.
2017-02-21 10:52:20 -05:00
Daniel P. Berrange
f88b6e4285 Format printf format specifier used with niothreadids
The niothreadids struct field is size_t, so must use %zu not %lu
with printf. While they're identical on some platforms, on others
they are different, causing warnings

conf/domain_conf.c: In function 'virDomainDefCheckABIStabilityFlags':
conf/domain_conf.c:19575:26: error: format '%lu' expects argument of type 'long unsigned int', but argument 7 has type 'size_t {aka unsigned int}' [-Werror=format=]
                        _("Target domain iothreads count %lu does not "
                          ^

conf/domain_conf.c: In function 'virDomainDefFormatInternal':
conf/domain_conf.c:23915:46: error: format '%lu' expects argument of type 'long unsigned int', but argument 3 has type 'size_t {aka unsigned int}' [-Werror=format=]
         virBufferAsprintf(buf, "<iothreads>%lu</iothreads>\n",
                                              ^

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2017-02-20 18:24:06 +00:00
Pavel Hrdina
7f602b8291 qemu_driver: move iothread duplicate check into one place
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2017-02-20 18:44:47 +01:00
Pavel Hrdina
c96bd78e4e conf: move iothread XML validation from qemu_command
This will ensure that IOThreads are properly validated while
a domain is defined.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2017-02-20 18:42:24 +01:00
Pavel Hrdina
a4a1ad2066 conf: display all iothread ids in the XML if one of them is not generated
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2017-02-20 18:40:54 +01:00
Pavel Hrdina
3fc6512a3d conf: move iothread parse code into its own function
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2017-02-20 17:30:55 +01:00
Pavel Hrdina
875b77821f conf: remove redundant iothreads variable
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2017-02-20 17:30:55 +01:00
Pavel Hrdina
2b5dcda7a9 conf: fix indentation
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2017-02-20 17:30:54 +01:00
John Ferlan
f3b1b98121 tests: Add createVHBAByNodeDevice-parent-fabric-wwn to fchosttest
Add a test that allows providing the parent fabric_wwn in the input XML
in order to create the vHBA.

This also fixes a mixed setting of the fabric_wwn field from the read
test driver XML strings.
2017-02-19 06:45:09 -05:00
John Ferlan
7ad479d0bd nodedev: Rework virNodeDeviceGetParentHost
Rework the code to perform the various searches by parent, parent_wwnn/
parent_wwpn, parent_fabric_wwn, or vport capable in order to return the
'parent_host' number that is vHBA capable.

The former virNodeDeviceGetParentHost is renamed to add the ByParent
on it fixes an issue where if no parent was supplied in the XML to
create the vHBA, then virNodeDeviceFindByName was called with a NULL
second parameter which had bad results.

The reworked code will make the various calls to fetch the NPIV host
by the passed parameter options or if none are provided find a vport
capable NPIV HBA to perform the create. If the call is from the delete
path, then this option won't be allowed.

Each of virNodeDeviceGetParentHostBy* functions is now static, so
remove them external definitions.

A secondary benefit of this is the test_driver now can make use of
the new API to add some new tests to test the various creation options.
2017-02-19 06:45:09 -05:00
John Ferlan
03346def06 util: Move scsi_host specific functions from virutil
Create a virscsihost.c and place the functions there. That removes the
last #ifdef __linux__ from virutil.c.

Take the opporunity to also change the function names and in one case
the parameters slightly
2017-02-19 06:45:09 -05:00
John Ferlan
d2d74a986d util: Replace virStoragePoolGetVhbaSCSIHostParent
Use the new virNodeDeviceGetParentName instead. Modify the callers to
build the node device scsi_host# name string in order to call the new
function so that proper lookup occurs.
2017-02-19 06:45:09 -05:00
John Ferlan
aa6aa624ad nodedev: Introduce virNodeDeviceGetParentName
Create a function which takes a node device "name" entry to lookup
and returns a string containing the parent name for the node device.
2017-02-19 06:45:09 -05:00
John Ferlan
16416816c1 util: Create a new virvhba module and move/rename API's
Rather than have them mixed in with the virutil apis, create a separate
virvhba.c module and move the vHBA related calls into there. Soon there
will be more added.

Also modify the names of the functions and some arguments to be more
indicative of what is really happening. Adjust the callers respectively.

While I was changing fchosttest, rather than the non-descriptive names
test1...test6, rename them to match what the test is doing.
2017-02-19 06:45:09 -05:00
Roman Bogorodskiy
d3ffa0ece8 nodedev: fix build with clang
Build fails with:

conf/node_device_conf.c:825:62: error: comparison of unsigned enum expression < 0 is always false [-Werror,-Wtautological-compare]
    if ((data->drm.type = virNodeDevDRMTypeFromString(type)) < 0) {
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~
conf/node_device_conf.c:1801:59: error: comparison of unsigned enum expression < 0 is always false [-Werror,-Wtautological-compare]
        if ((type = virNodeDevDevnodeTypeFromString(tmp)) < 0) {
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~
2 errors generated.

Fix by using intermediate variable to store the result similarly
to how it's done for other FromString* calls.
2017-02-18 17:49:27 +04:00
Michal Privoznik
78c018693b nodedev: Introduce new drm cap
After 7f1bdec5fa our nodedev driver is capable of
determining DRM devices (DRM stands for Direct Render Manager not
Digital rights management). There is still one bit missing
though: virConnectListAllNodeDevices() is capable of listing
either all devices or just those with specified capability. Well,
DRM capability is missing there.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2017-02-17 16:09:15 +01:00
Marc-André Lureau
e5bda10141 qemu: add rendernode argument
Add a new attribute 'rendernode' to <gl> spice element.

Give it to QEMU if qemu supports it (queued for 2.9).

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2017-02-17 15:47:58 +01:00
Marc-André Lureau
7f1bdec5fa nodedev: add drm capability
Add a new 'drm' capability for Direct Rendering Manager (DRM) devices,
providing device type information.

Teach the udev backend to populate those devices.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2017-02-17 15:47:58 +01:00
Marc-André Lureau
14a3e7ab5c nodedev: parse <path>
This should have been added with c4a4603de (or 0bdefd9b04).

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2017-02-17 15:47:58 +01:00
Marc-André Lureau
0809508ed2 nodedev: add <devnode> paths
Add new <devnode> top-level <device> element, that list the associated
/dev files. Distinguish the main /dev name from symlinks with a 'type'
attribute of value 'dev' or 'symlink'.

Update a test to check XML schema, and actually add it to the test list
since it was missing.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2017-02-17 15:47:58 +01:00
Marc-André Lureau
7f64435307 nodedev: fix extra space in dump
This is a cosmetic change, shouldn't change XML parsing, and doesn't
break any test.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2017-02-17 15:47:58 +01:00
John Ferlan
4337bc57be nodedev: Return the parent for a virNodeDevicePtr struct
When the 'parent' was added to the virNodeDevicePtr structure
by commit id 'e8a4ea75a' the 'parent' field was not properly filled
in when a virGetNodeDevice call was made within driver/config code.
Only the device name was ever filled in. Fetching the parent required
a second trip via virNodeDeviceGetParent into the node device lookup
code was required in order to retrieve the specific parent field (and
still the parent field was never filled in although it was free'd).

Since we have the data when we initially call virGetNodeDevice from
within driver/node_config code - let's just fill in the parent field
as well for anyone that wants it without requiring another trip into
the node_device lookup just to get the parent.

This will allow API's such as virConnectListAllNodeDevices,
virNodeDeviceLookupByName, and virNodeDeviceLookupSCSIHostByWWN
to retrieve both name and parent in the returned virNodeDevicePtr.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2017-02-16 12:23:04 -05:00
Ján Tomko
4a7773f7ea conf: check port range even for USB hubs
Move the range check introduced by commit 2650d5e into
virDomainUSBAddressFindPort. That way both virDomainUSBAddressRelease
and virDomainUSBAddressSetAddHub can benefit from it.

Reported-by: Michal Privoznik <mprivozn@redhat.com>
2017-02-13 13:08:36 +01:00
Marc Hartmayer
28dd54a5b9 conf: Fix libvirtd free() segfault if virDomainChrSourceDefNew(...) fails
If virDomainChrSourceDefNew(xmlopt) fails, it will lead to free()ing
the uninitialized pointer bus. The fix for this is to initialize bus
with NULL.

Signed-off-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.vnet.ibm.com>
2017-02-09 14:18:51 -05:00
Jaroslav Safka
bc6d3121a4 conf: Add new xml elements for file memorybacking support
This part introduces new xml elements for file based
memorybacking support and their parsing.
(It allows vhost-user to be used without hugepages.)

New xml elements:
<memoryBacking>
  <source type="file|anonymous"/>
  <access mode="shared|private"/>
  <allocation mode="immediate|ondemand"/>
</memoryBacking>
2017-02-09 14:27:19 +01:00
Jaroslav Safka
7c0c5f6d4b qemu, conf: Rename virNumaMemAccess to virDomainMemoryAccess
Rename to avoid duplicate code. Because virDomainMemoryAccess will be
used in memorybacking for setting default behaviour.

NOTE: The enum cannot be moved to qemu/domain_conf because of headers
dependency
2017-02-09 14:27:19 +01:00
Laine Stump
68a42bf6f7 conf: support configuring mtu size in a virtual network
Example:

  <network>
     ...
     <mtu size='9000'/>
     ...

If mtu is unset, it's assumed that we want the default for whatever is
the underlying transport (usually this is 1500).

This setting isn't yet wired in, so it will have no effect.

This partially resolves: https://bugzilla.redhat.com/1224348
2017-02-07 13:52:06 -05:00
Martin Kletzander
eae7cfd42d conf: Add virDomainDiskSetBlockIOTune
That function sets disk->blkdeviotune sensibly.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2017-01-31 20:19:35 +01:00
Ján Tomko
077c6d450f conf: move VIR_DOMAIN_USB_HUB_PORTS to the header file
For reusing in qemu_domain_address.c.
2017-01-31 13:09:08 +01:00
Pavel Hrdina
f19390d2d3 domain_conf: vnc: preserve autoport value if no port was specified
The issue is that if this graphics definition is provided:

  <graphics type='vnc' port='0'/>

it's parsed as:

  <graphics type='vnc' autoport='no'>
    <listen type='address'/>
  </graphics>

but if the resulting XML is parsed again the output is:

  <graphics type='vnc' port='-1' autoport='yes'>
    <listen type='address'/>
  </graphics>

and this should not happen.  The XML have to always remain the same
after it was already parsed by libvirt.

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

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2017-01-27 09:46:03 +01:00
Olga Krishtal
e590d5301e storage: Introduce Virtuozzo vstorage backend
Added general definitions for vstorage pool backend including
the build options to add --with-storage-vstorage checking.
In order to use vstorage as a backend for a storage pool
vstorage tools (vstorage and vstorage-mount) need to be installed.

Signed-off-by: Olga Krishtal <okrishtal@virtuozzo.com>
2017-01-26 10:43:42 -05:00
Michal Privoznik
b020cf73fe domain_conf: Introduce <mtu/> to <interface/>
So far we allow to set MTU for libvirt networks. However, not all
domain interfaces have to be plugged into a libvirt network and
even if they are, they might want to have a different MTU (e.g.
for testing purposes).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2017-01-26 09:59:56 +01:00
Michal Privoznik
eebec1697e virDomainNetDefParseXML: s/ret/rv/
We use @ret to hold the actual return value of the function we
are currently in. To hold a return value of a function called we
use different variables: @rv, @rc, etc. Honour this naming
scheme in virDomainNetDefParseXML too.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2017-01-25 09:18:49 +01:00
Michal Privoznik
0cacdc6f24 virDomainHostdevSubsysSCSIVHostDefParseXML: Don't leak @protocol
==24748== 12 bytes in 2 blocks are definitely lost in loss record 25 of 84
==24748==    at 0x4C2BF80: malloc (vg_replace_malloc.c:296)
==24748==    by 0x1A1E1E78: xmlStrndup (in /usr/lib64/libxml2.so.2.9.4)
==24748==    by 0x18D0495F: virXMLPropString (virxml.c:506)
==24748==    by 0x18D1FB3E: virDomainHostdevSubsysSCSIVHostDefParseXML (domain_conf.c:6280)
==24748==    by 0x18D20350: virDomainHostdevDefParseXMLSubsys (domain_conf.c:6450)
==24748==    by 0x18D34E7D: virDomainHostdevDefParseXML (domain_conf.c:13218)
==24748==    by 0x18D42598: virDomainDefParseXML (domain_conf.c:17745)
==24748==    by 0x18D440A9: virDomainDefParseNode (domain_conf.c:18236)
==24748==    by 0x18D43EFA: virDomainDefParse (domain_conf.c:18180)
==24748==    by 0x18D43FA0: virDomainDefParseFile (domain_conf.c:18206)
==24748==    by 0x44EDA1: testCompareDomXML2XMLFiles (testutils.c:1140)
==24748==    by 0x4365F8: testXML2XMLActive (qemuxml2xmltest.c:59)

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2017-01-20 16:31:05 +01:00
Laine Stump
5949b53aec conf: eliminate virDomainPCIAddressReleaseSlot() in favor of ...Addr()
Surprisingly there was a virDomainPCIAddressReleaseAddr() function
already, but it was completely unused. Since we don't reserve entire
slots at once any more, there is no need to release entire slots
either, so we just replace the single call to
virDomainPCIAddressReleaseSlot() with a call to
virDomainPCIAddressReleaseAddr() and remove the now unused function.

The keen observer may be concerned that ...Addr() doesn't call
virDomainPCIAddressValidate(), as ...Slot() did. But really the
validation was pointless anyway - if the device hadn't been suitable
to be connected at that address, it would have failed validation
before every being reserved in the first place, so by definition it
will pass validation when it is being unplugged. (And anyway, even if
something "bad" happened and we managed to have a device incorrectly
at the given address, we would still want to be able to free it up for
use by a device that *did* validate properly).
2017-01-11 05:00:34 -05:00
Laine Stump
27b0f971c4 conf: rename virDomainPCIAddressReserveSlot() to ...Addr()
This function doesn't actually reserve an entire slot any more, it
reserves a single PCI address, so this name is more appropriate.
2017-01-11 04:58:32 -05:00