Commit Graph

2787 Commits

Author SHA1 Message Date
John Ferlan
a7ce03c736 conf: Convert virStoragePoolSourceAdapter to virStorageAdapter
Move the virStoragePoolSourceAdapter from storage_conf.h and rename
to virStorageAdapter.

Continue with code realignment for brevity and flow.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2017-03-15 21:17:47 -04:00
John Ferlan
0d130a2dde conf: Rework storage_conf to use adapter specific typedefs
Rework the helpers/APIs to use the FCHost and SCSIHost adapter types.
Continue to realign the code for shorter lines.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2017-03-15 21:17:47 -04:00
John Ferlan
decbdc5068 conf: Rework storage_adapter_conf to use adapter specific typedefs
Rework the helpers/APIs to use the FCHost and SCSIHost adapter types.
Continue to realign the code for shorter lines.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2017-03-15 21:17:47 -04:00
John Ferlan
9c286868b1 conf: Split up virStoragePoolSourceAdapter
Create typedef'd substructures and rework typedef to utilize.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2017-03-15 21:17:47 -04:00
John Ferlan
5e0af53512 conf: Extract SCSI adapter type processing into their own helpers
Rather than have lots of ugly inline code, create helpers to try and
make things more readable. While creating the helpers realign the code
as necessary.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2017-03-15 21:17:47 -04:00
John Ferlan
698d5df448 conf: Extract FCHost adapter type processing into their own helpers
Rather than have lots of ugly inline code, create helpers to try and
make things more readable. While creating the helpers realign the code
as necessary.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2017-03-15 21:17:47 -04:00
John Ferlan
1e21c04054 conf: Rename API's in storage_adapter_conf
Rename the API's to remove the storage pool source pieces

Signed-off-by: John Ferlan <jferlan@redhat.com>
2017-03-15 21:17:47 -04:00
John Ferlan
f632e017c0 conf: Introduce storage_adapter_conf
Move code from storage_conf into storage_adapter_conf

Pure code motion

Signed-off-by: John Ferlan <jferlan@redhat.com>
2017-03-15 21:17:47 -04:00
John Ferlan
2dd9b94531 conf: Rework parsing in virStoragePoolDefParseSourceAdapter
Rather than use virXPathString, pass along an virXPathNode and alter
the parsing to use virXMLPropString.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2017-03-15 21:17:47 -04:00
John Ferlan
86e7c59f80 conf: Split out storage pool source adapter helpers
Split out the code that munges through the storage pool adapter into
helpers - it's about to be moved into it's own source file.

This is purely code motion at this point.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2017-03-15 21:17:47 -04:00
John Ferlan
2077ea849b conf: Add missing validate for fchost search fields
Commit id 'bb74a7ffe' added some new fields to search for a fchost by
parent wwnn/wwpn or parent_fabric_name, but neglected to validate that
the data within the fields was valid at parse time. This could lead to
eventual failure at run time, so rather than have the failure then, let's
validate now.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2017-03-15 21:17:47 -04:00
John Ferlan
d21fc70938 conf: Ensure both parent_wwnn/parent_wwpn provided
https://bugzilla.redhat.com/show_bug.cgi?id=1428209

Commit id 'bb74a7ffe' neglected to check that both the parent_wwnn
parent_wwpn are in the XML if one or the other is similar to how
the node device code checked (commit id '2b13361bc').

If only one is provided, the "default" is to use a vHBA capable
adapter (see commit id '78be2e8b'), so the vHBA could start, but
perhaps not on the expected adapter.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2017-03-15 21:17:47 -04:00
Michal Privoznik
e433546bef qemu: Introduce label-size for NVDIMMs
For NVDIMM devices it is optionally possible to specify the size
of internal storage for namespaces. Namespaces are a feature that
allows users to partition the NVDIMM for different uses.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2017-03-15 14:39:22 +01:00
Michal Privoznik
80af11d3dd conf: Introduce @access to <memory/>
Now that NVDIMM has found its way into libvirt, users might want
to fine tune some settings for each module separately. One such
setting is 'share=on|off' for the memory-backend-file object.
This setting - just like its name suggest already - enables
sharing the nvdimm module with other applications. Under the hood
it controls whether qemu mmaps() the file as MAP_PRIVATE or
MAP_SHARED.

Yet again, we have such config knob in domain XML, but it's just
an attribute to numa <cell/>. This does not give fine enough
tuning on per-memdevice basis so we need to have the attribute
for each device too.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2017-03-15 14:18:58 +01:00
Michal Privoznik
b4e8a49f8d Introduce NVDIMM memory model
NVDIMM is new type of memory introduced into QEMU 2.6. The idea
is that we have a Non-Volatile memory module that keeps the data
persistent across domain reboots.

At the domain XML level, we already have some representation of
'dimm' modules. Long story short, NVDIMM will utilize the
existing <memory/> element that lives under <devices/> by adding
a new attribute 'nvdimm' to the existing @model and introduce a
new <path/> element for <source/> while reusing other fields. The
resulting XML would appear as:

    <memory model='nvdimm'>
      <source>
        <path>/tmp/nvdimm</path>
      </source>
      <target>
        <size unit='KiB'>523264</size>
        <node>0</node>
      </target>
      <address type='dimm' slot='0'/>
    </memory>

So far, this is just a XML parser/formatter extension. QEMU
driver implementation is in the next commit.

For more info on NVDIMM visit the following web page:

    http://pmem.io/

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2017-03-15 13:30:58 +01:00
Jiri Denemark
5cbc247e0d Do not format <arch> in guest CPU XML
This element is only allowed for host CPUs.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2017-03-13 23:49:57 +01:00
Jiri Denemark
fafe9d7c74 Enable forgotten VIR_CONNECT_LIST_STORAGE_POOLS_* flags
VIR_CONNECT_LIST_STORAGE_POOLS_VSTORAGE and
VIR_CONNECT_LIST_STORAGE_POOLS_ZFS were added to libvirt but the listing
API was not properly updated to use them.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2017-03-13 09:29:37 +01:00
Fabian Freyer
04664327c6 bhyve: add video support
bhyve supports 'gop' video device that allows clients to connect
to VMs using VNC clients. This commit adds support for that to
the bhyve driver:

 - Introducr 'gop' video device type
 - Add capabilities probing for the 'fbuf' device that's
   responsible for graphics
 - Update command builder routines to let users configure
   domain's VNC via gop graphics.

Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
2017-03-11 23:30:56 +04:00
Pavel Hrdina
c27020dd4f Revert "conf: move iothread XML validation from qemu_command"
This reverts commit c96bd78e4e.

So our code is one big mess and we modify domain definition while
building qemu_command line and our hotplug code share only part
of the parsing and command line building code.  Let's revert
that change because to fix it properly would require refactor and
move a lot of things.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1430275
2017-03-09 17:36:58 +01:00
Pavel Hrdina
cba1672de8 conf: properly skip graphics listen element in migratable XML
We should skip <listen type='socket'/> only if the 'socket' path
is specified because if there is no 'socket' path we need to
keep that element in migratable XML.

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

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2017-03-09 10:22:43 +01:00
Pavel Hrdina
cd4a8b9304 conf: store "autoGenerated" for graphics listen in status XML
When libvirtd is started we call qemuDomainRecheckInternalPaths
to detect whether a domain has VNC socket path generated by libvirt
based on option from qemu.conf.  However if we are parsing status XML
for running domain the existing socket path can be generated also if
the config XML uses the new <listen type='socket'/> element without
specifying any socket.

The current code doesn't make difference how the socket was generated
and always marks it as "fromConfig".  We need to store the
"autoGenerated" value in the status XML in order to preserve that
information.

The difference between "fromConfig" and "autoGenerated" is important
for migration, because if the socket is based on "fromConfig" we don't
print it into the migratable XML and we assume that user has properly
configured qemu.conf on both hosts.  However if the socket is based
on "autoGenerated" it means that a new feature was used and therefore
we need to leave the socket in migratable XML to make sure that if
this feature is not supported on destination the migration will fail.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2017-03-09 10:22:43 +01:00
John Ferlan
62bc956786 conf: Use consistent function name prefixes for virnwfilterobj
Use "virNWFilterObj" as a prefix for any external API in virnwfilterobj
2017-03-07 13:27:25 -05:00
John Ferlan
44242cce02 conf: Alter coding style of nwfilter 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-07 13:27:25 -05:00
John Ferlan
d82aee6add conf: Adjust coding style for nwfilter 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-07 13:27:25 -05:00
John Ferlan
079747a36d conf: Introduce virnwfilterobj
Move all the NWFilterObj API's into their own module virnwfilterobj
from the nwfilter_conf

Purely code motion at this point, plus adjustments to cleanly build.
2017-03-07 13:27:25 -05:00
John Ferlan
cab7b8c276 conf: Change virNWFilterObjDeleteDef to virNWFilterDeleteDef
Rather than pass the nwfilter object, just pass the def to the function
2017-03-07 13:27:25 -05:00
John Ferlan
22426736b9 conf: Change virNWFilterObjSaveDef to virNWFilterSaveDef
There's no need to pass the driver pointer to nwfilter_conf, just
pass the configDir.
2017-03-07 13:27:24 -05:00
Laine Stump
3898526931 make all struct typedefs comply with proposed coding conventions
Proposed formal coding conventions encourage defining typedefs for
vir[Blah] and vir[Blah]Ptr separately from the associated struct named
_vir[Blah]:

    typedef struct _virBlah virBlah;
    typedef virBlah *virBlahPtr;
    struct _virBlah {
    ...
    };

At some point in the past, I had submitted several patches using a
more compact style that I prefer, and they were accepted:

    typedef struct _virBlah {
        ...
    } virBlah, *virBlahPtr;

Since these are by far a minority among all struct definitions, this
patch changes all those definitions to reflect the style prefered by
the proposal so that there is 100% consistency.
2017-03-06 13:00:45 -05:00
John Ferlan
5adbbdc173 conf: Alter coding style of interface 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-06 07:07:01 -05:00
John Ferlan
e858232e4d conf: Use consistent function name prefixes for virinterfaceobj
Use "virInterfaceObj" as a prefix for any external API in virinterfaceobj
2017-03-06 07:07:01 -05:00
John Ferlan
7e702a862d conf: Adjust coding style for interface 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-06 07:07:01 -05:00
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