Commit Graph

3110 Commits

Author SHA1 Message Date
Ján Tomko
126e6f381a conf: check address type for USB hostdevs
https://bugzilla.redhat.com/show_bug.cgi?id=1225339
2017-08-24 09:28:53 +02:00
Ján Tomko
cdf72e19d9 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.
2017-08-24 09:28:53 +02:00
Ján Tomko
a530078cd2 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.
2017-08-22 17:47:24 +02:00
Ján Tomko
4b759a4041 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.
2017-08-22 17:47:24 +02:00
Ján Tomko
c4480eef08 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.
2017-08-22 17:47:23 +02:00
Pavel Hrdina
1e4cc18890 conf: move chardev validation into virDomainDeviceDefValidateInternal
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2017-08-22 17:44:36 +02:00
Pavel Hrdina
a4ba59ff4b 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>
2017-08-22 17:44:36 +02:00
Pavel Hrdina
9b341bbf41 conf: move FILE chardev source parsing to separate function
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2017-08-22 17:44:36 +02:00
Pavel Hrdina
65f4e2ff27 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>
2017-08-22 17:44:36 +02:00
Pavel Hrdina
2c9b97d842 conf: move UNIX chardev source parsing to separate function
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2017-08-22 17:44:36 +02:00
Pavel Hrdina
34e0eb7dc4 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>
2017-08-22 17:44:36 +02:00
Pavel Hrdina
40b0f40b54 conf: move TCP chardev source parsing to separate function
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2017-08-22 17:44:36 +02:00
Pavel Hrdina
9ed225e910 conf: move mode parsing of chardev source to separate function
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2017-08-22 17:44:36 +02:00
Pavel Hrdina
3672fc99f4 conf: move chardev log parsing to separate function
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2017-08-22 17:44:36 +02:00
Pavel Hrdina
f2be5b38f0 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>
2017-08-22 17:43:51 +02:00
Pavel Hrdina
209fa11b02 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>
2017-08-22 17:28:40 +02:00
Pavel Hrdina
23482e4b1e 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>
2017-08-22 17:28:40 +02:00
Pavel Hrdina
21bfd1e9b9 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>
2017-08-22 17:28:40 +02:00
Pavel Hrdina
7d0ff9430b conf: switch from while to for loop for chardev parsing
This removes one level of indentation.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2017-08-22 17:28:40 +02:00
Ján Tomko
bad14fbbed 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.
2017-08-22 09:44:28 +02:00
Andrea Bolognani
64357c3f93 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>
2017-08-21 13:11:49 +02:00
Andrea Bolognani
c9d75d655a 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>
2017-08-21 13:11:48 +02:00
Peter Krempa
7c5cf4983c 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.
2017-08-18 15:07:44 +02:00
Peter Krempa
e159ddfab8 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.
2017-08-18 15:07:44 +02:00
Peter Krempa
e168bc8a72 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.
2017-08-18 15:07:44 +02:00
Peter Krempa
2f19c9325e 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.
2017-08-18 15:07:44 +02:00
Peter Krempa
7a5f68a1f2 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.
2017-08-18 15:07:44 +02:00
Pavel Hrdina
b71946af5c 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>
2017-08-17 15:42:48 +02:00
Pavel Hrdina
49991b74d9 conf: use virXMLNodeContentString for boot options parsing
Using XPath here doesn't add any benefit.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2017-08-17 15:42:47 +02:00
Pavel Hrdina
422cf16079 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>
2017-08-17 15:42:47 +02:00
Pavel Hrdina
d5b025bb15 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>
2017-08-17 15:42:47 +02:00
Pavel Hrdina
0b36d6cb08 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>
2017-08-17 15:42:47 +02:00
Pavel Hrdina
8cf6eb4612 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>
2017-08-17 15:42:47 +02:00
Pavel Hrdina
dee01fc5a0 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>
2017-08-17 15:42:47 +02:00
Pavel Hrdina
58bf9d1d37 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>
2017-08-17 15:42:47 +02:00
Michal Privoznik
361ff0a088 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>
2017-08-17 14:58:11 +02:00
John Ferlan
6862ad3cd7 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.
2017-08-17 07:28:17 -04:00
John Ferlan
1910abbf47 storage: Alter @aclfilter to just @filter
Rename the variable, recent review requested just use of @filter,
so be consistent throughout.
2017-08-16 14:24:38 -04:00
John Ferlan
8ce0556fc5 secret: Alter @aclfilter to just @filter
Rename the variable, recent review requested just use of @filter,
so be consistent throughout.
2017-08-16 14:24:38 -04:00
John Ferlan
59310792a6 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.
2017-08-16 14:24:38 -04:00
John Ferlan
f4b5844050 nodedev: Alter @aclfilter to just @filter
Rename the variable, recent review requested just use of @filter,
so be consistent throughout.
2017-08-16 14:24:38 -04:00
John Ferlan
63d84f18fa network: Privatize virNetworkObj
Move from virnetworkobj.h into virnetworkobj.c

Signed-off-by: John Ferlan <jferlan@redhat.com>
2017-08-16 14:17:57 -04:00
John Ferlan
80ba4142e1 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>
2017-08-16 14:17:57 -04:00
John Ferlan
8473859a47 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>
2017-08-16 14:17:57 -04:00
John Ferlan
178ac3d133 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>
2017-08-16 14:17:57 -04:00
John Ferlan
7beef70871 network: Have virNetworkObjNew lock the returned object
Forces callers to use the virNetworkObjEndAPI properly.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2017-08-16 14:17:57 -04:00
John Ferlan
26c8fe4990 network: Consistent use of @obj for virnetworkobj
Consistently use @obj for a virNetworkObjPtr.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2017-08-16 14:17:57 -04:00
John Ferlan
bc9868aaf2 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>
2017-08-16 14:17:57 -04:00
John Ferlan
9e8227d76b 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>
2017-08-16 14:17:57 -04:00
John Ferlan
f57d8a7b32 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>
2017-08-16 14:17:57 -04:00