Commit Graph

32905 Commits

Author SHA1 Message Date
Eric Blake
df2ae0d042 snapshot: Allow for post-parse override
Wire up the accessor functions necessary for the testsuite to install
an alternative post-parse handler from normal drivers. I could have
modified the signature for virDomainXMLOptionNew() to take another
parameter, but thought it was easier to add a new set function rather
than chase down all existing callers. Until code actually sets the
override, there is no change in behavior.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
2019-04-16 21:55:59 -05:00
Eric Blake
5ba4d81ce9 snapshot: Factor out post-parse code
Move the non-deterministic code that sets snapshot properties
independently of what the incoming XML described to instead live in a
default post-parse function common to virDomainMoment (as checkpoints
will also reuse it in later patches). This patch is just code motion,
with no difference to any callers; but the next patch will further
refactor things to allow for a per-driver override, used by the
testsuite to perform deterministic post-parse actions for better
coverage of parser/formatter code.

Note that the post-parse code is intentionally not run during a
snapshot redefine, since that code path already requires a valid
snapshot name and creation time from the XML.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
2019-04-16 21:55:59 -05:00
Eric Blake
a007fcab3b snapshot: Don't expose testsuite-only state in snapshot XML
None of the existing drivers actually use the 0-valued 'nostate'
snapshot state; rather, it was a fluke of implementation. In fact,
some drivers, like qemu, actively reject 'nostate' as invalid during a
snapshot redefine. Normally, a driver computes the state post-parse
from the current domain, and thus virDomainSnapshotGetXMLDesc() will
never expose the state. However, since the testsuite lacks any
associated domain to copy state from, and lacks post-parse processing
that normal drivers have, the testsuite output had several spots with
the state, coupled with a regex filter to ignore the oddity.

It is better to follow the lead of other XML defaults, by not
outputting anything during format if post-parse defaults have not been
applied, and rejecting the default value during parsing. The testsuite
needs a bit of an update, by adding another flag for when to simulate
a post-parse action of setting a snapshot state, but none of the
drivers are impacted other than rejecting XML that was previously
already suspicious in nature.

Similarly, don't expose creation time 0 (for now, only possible if a
user redefined a snapshot to claim creation at the Epoch, but also
happens once setting the creation time is deferred to a post-parse
handler).

This is also a step towards cleaning up snapshot_conf.c to separate
its existing post-parse work (namely, setting the creationTime and
default snapshot name) from the pure parsing work, so that we can get
rid of the testsuite hack of regex filtering of the XML and instead
have more accurate testing of our parser/formatter code.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
2019-04-16 21:55:52 -05:00
Eric Blake
a10c6b300e snapshot: Refactor snapshotxml2xml test
Upcoming changes want to separate out a post-parse massaging of
snapshots separate from parsing the XML, so as not to be dependent on
filtering out an ever-changing timestamp from the testsuite. Along the
way, this means we will want to add yet another conditional to the
snapshot xml2xml tests on whether to perform post-processing steps to
canned values. This will be easier to read if we consolidate all the
decisions into a flags variable, instead of adding yet another
boolean.

While at it, drop the redundant inout test of "noparent" (once is
enough).

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
2019-04-16 21:02:21 -05:00
Cole Robinson
84a5e89b31 conf: Add VIR_DOMAIN_DEF_FEATURE_NET_MODEL_STRING
This requires drivers to opt in to handle the raw modelstr
network model, all others will error if a passed in XML value
is not in the model enum.

Enable this feature for libxl/xen/xm and qemu drivers

Acked-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2019-04-16 13:11:08 -04:00
Cole Robinson
17a1bd7eb9 vbox: Convert to net enum model
Convert the vbox driver to net model enum, which requires adding
enum values for Am79C970A, Am79C973, 82540EM, 82545EM, 82543GC. We
preserve the same casing that vbox historically used for these model
names.

Remove the now unused virDomainNetStrcaseeqModelString

Acked-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2019-04-16 13:11:08 -04:00
Cole Robinson
848fdabdba vmx: convert to net model enum
Convert the vmware/vmx driver to net model enum, which requires
adding enum values for vlance, vmxnet, vmxnet2, and vmxnet3.

Acked-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2019-04-16 13:11:08 -04:00
Cole Robinson
79c8bc7d6e conf: Make net model enum compare case insensitive
vbox and vmx drivers do net case insensitive net model comparisons,
so for example 'VMXNET3' and 'vmxnet3' and 'VmxNeT3' in the XML will
translate to the same driver configuration. To convert these drivers
to use net model enum, we will need to do case insensitive comparisons
as well.

Essentially we implement virEnumToString, but with case insensitive
comparison. XML will always be formatted with the enum model string
we track internally, but we will accept any case insensitive variant.

Acked-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2019-04-16 13:11:08 -04:00
Cole Robinson
41b002f934 qemu: Partially convert to net model enum
This converts the qemu driver to the net model enum, for all
the model values that we have hardcoded for various checks,
which adds e1000e, virtio-transitional, virtio-non-transitional,
usb-net, spapr-vlan, lan9118, smc91c111

Because the qemu driver has historically also allowed the raw
model string onto the qemu command line, this isn't a full
conversion. Unwinding that will require more thought. However
for all new driver code we should be adding explicit enum
values for any model name we have special handling for.

Remove the now unused virDomainNetStreqModelString

Acked-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2019-04-16 13:11:08 -04:00
Cole Robinson
c0cf17c280 bhyve: convert to net model enum
The bhyve driver only works with the virtio and e1000 models,
which we already have in the enum. Some error reporting is
slightly downgraded to avoid some subtle usage of modelstr

Acked-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2019-04-16 13:11:08 -04:00
Cole Robinson
0f8358555a vz: convert to net model enum
The vz driver only handles three models: virtio, e1000, and rtl8139.
Add enum values for those models, and convert the vz driver to
handling net->model natively

Acked-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2019-04-16 13:11:08 -04:00
Cole Robinson
d79a2c079c conf: net: Add model enum, and netfront value
This adds a network model enum. The virDomainNetDef property
is named 'model' like most other devices.

When the XML parser or a driver calls NetSetModelString, if
the passed string is in the enum, we will set net->model,
otherwise we copy the string into net->modelstr

Add a single example for the 'netfront' xen model, and wire
that up, just to verify it's all working

Acked-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2019-04-16 13:11:08 -04:00
Cole Robinson
aa3c9f34bf conf: net: Rename 'model' to 'modelstr'
We will be adding a 'model' enum in upcoming patches. Rename
the existing value to make the differentiation clear

Acked-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2019-04-16 13:11:08 -04:00
Cole Robinson
6bf7c67699 conf: net: Add wrapper functions for <model> value
To ease converting the net->model value to an enum, add
the wrapper functions:

virDomainNetGetModelString
virDomainNetSetModelString
virDomainNetStreqModelString
virDomainNetStrcaseeqModelString

Acked-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2019-04-16 13:11:08 -04:00
Cole Robinson
c800e29b87 tests: Add several net model passthrough tests
Examples of passing unknown strings through <interface>
<model type=X/>

Acked-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2019-04-16 13:11:08 -04:00
Cole Robinson
5f18cd03af tests: qemuxml2xml: Convert aarch64-os-firmware-efi to TEST_CAPS
Demostrate DO_TEST_CAPS_ARCH_LATEST by converting the test case
'aarch64-os-firmware-efi'

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2019-04-16 12:44:37 -04:00
Cole Robinson
129da536dc tests: qemuxml2xml: Convert genid* to TEST_CAPS
Convert these test cases to use DO_TEST_CAPS_LATEST

* genid
* genid-auto

This ensures the test infrastructure is working as expected for
a test case with explicit -active and -inactive XML test data

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2019-04-16 12:44:36 -04:00
Cole Robinson
ea5f33b73c tests: qemuxml2xml: Convert os-firmware* to TEST_CAPS
Convert these test cases to use DO_TEST_CAPS_LATEST

* os-firmware-bios
* os-firmware-efi
* os-firmware-efi-secboot

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2019-04-16 12:44:36 -04:00
Cole Robinson
7339f4d79b tests: qemuxml2xml: Convert virtio-*transitional to TEST_CAPS
Convert these test cases to use DO_TEST_CAPS_LATEST

* virtio-transitional
* virtio-non-transitional

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2019-04-16 12:44:36 -04:00
Cole Robinson
bbd1f171d3 tests: qemuxml2xml: Add DO_TEST_CAPS*
Add DO_TEST_CAPS* macros, lifted from qemuxml2argvtest.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2019-04-16 12:44:36 -04:00
Cole Robinson
352dd945cf tests: qemuxml2xml: Set name in testQemuInfo
Use the same pattern that is used in qemuxml2argvtest, setting the
name in a static testQemuInfo instance inside the test macros

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2019-04-16 12:44:36 -04:00
Daniel P. Berrangé
3e213d43b1 network: use virNetDevTapReattachBridge API
Switch over to use the new API for re-attaching the bridge device

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2019-04-16 14:44:53 +01:00
Daniel P. Berrangé
de938b92c9 util: add helper method for re-attaching a tap device to a bridge
Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2019-04-16 14:44:53 +01:00
Daniel P. Berrangé
42a92ee93d network: add missing bandwidth limits for bridge forward type
In the case of a network with forward=bridge, which has a bridge device
listed, we are capable of setting bandwidth limits but fail to call the
function to register them.

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2019-04-16 14:44:53 +01:00
Daniel P. Berrangé
bbe2aa627f conf: simplify link from hostdev back to network device
hostdevs have a link back to the original network device. This is fairly
generic accepting any type of device, however, we don't intend to make
use of this approach in future. It can thus be specialized to network
devices.

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2019-04-16 14:44:53 +01:00
Daniel P. Berrangé
43c402aa16 network: drop back compat code loading actual bridge name
The actual network def was updated to save the bridge name back
in 1.2.11:

  commit a360912179
  Author: Laine Stump <laine@laine.org>
  Date:   Fri Nov 21 12:20:37 2014 -0500

    network: save bridge name in ActualNetDef when actualType==network too

The chance that someone is running libvirt < 1.2.11 and wants
todo a live upgrade to 5.3.0 without a host reboot is essentially
zero. We can thus reasonably drop the back compat code now.

Reviewed-by: Laine Stump <laine@laine.org>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2019-04-16 14:44:53 +01:00
Daniel P. Berrangé
e1d10f8ef2 network: pass a virNetworkPtr to port management APIs
The APIs for allocating/notifying/removing network ports just take
an internal domain interface struct right now. As a step towards
turning these into public facing APIs, add a virNetworkPtr argument
to all of them.

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2019-04-16 14:44:53 +01:00
Daniel P. Berrangé
dd52444f23 network: restrict usage of port management APIs
The port allocation APIs are currently called unconditionally for all
types of NIC, but (mostly) only do anything for NICs with type=network.

The exception is the port allocate API which does some validation even
for NICs with type!=network. Relying on this validation is flawed,
however, since the network driver may not even be installed. IOW virt
drivers must not delegate validation to the network driver for NICs
with type != network.

This change allows us to report errors when the virtual network driver
is not registered.

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2019-04-16 14:44:53 +01:00
Martin Kletzander
545b0574fd docs: Add emulatorsched support to news.xml
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-04-16 13:46:17 +02:00
Martin Kletzander
2b342cda72 qemu: Add support for emulatorsched
This helps in a scenarios where vCPUs run with a priority that is so high they
might starve the emulator thread.  And it also fits with the rest of the
settings.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-04-16 13:46:17 +02:00
Martin Kletzander
842bc56ad2 conf: Add support for emulatorsched
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-04-16 13:46:17 +02:00
Martin Kletzander
c79a39e60c docs: Mention iothreadsched element in the docs and reword
Just one missing occurrence of iothreadsched fixed plus some rewording for this
to make more sense for the readers.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-04-16 13:46:17 +02:00
Martin Kletzander
3217bcc535 conf: Format thread IDs optionally
This will be used later when we want to format emulator scheduler parameters
which don't apply for multiple threads.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-04-16 13:46:17 +02:00
Martin Kletzander
0c010cd103 conf: Parse common scheduler attributes in separate function
This will become useful later when parsing emulatorsched parameters which don't
need the rest of the current function.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-04-16 13:46:17 +02:00
Marc-André Lureau
ad32d76165 qemu: do not set wait:false for client sockets
Qemu commit 767abe7 ("chardev: forbid 'wait' option with client
sockets") effectively deprecates usage of "wait" with client sockets
starting with qemu 4.0, and earlier versions ignored the value.

Cc: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2019-04-16 12:52:03 +02:00
Adrian Brzezinski
70d60b811f news: cleanup in virNetTLSContextNew
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Adrian Brzezinski <redhat@adrb.pl>
2019-04-16 11:23:10 +01:00
Adrian Brzezinski
dc4e9bfb84 rpc: cleanup in virNetTLSContextNew
Failed new gnutls context allocations in virNetTLSContextNew function
results in double free and segfault. Occasional memory leaks may also
occur.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Adrian Brzezinski <redhat@adrb.pl>
2019-04-16 11:22:50 +01:00
Michal Privoznik
c2568c1c5e news: Document firmware autoselection exposure in domcaps
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
2019-04-16 10:52:51 +02:00
Michal Privoznik
abd70ac3ae virSecurityDACRestoreChardevLabel: Restore UNIX sockets too
We're setting seclabels on unix sockets but never restoring them.
Surprisingly, we are doing so in SELinux driver.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-04-16 10:47:51 +02:00
Pino Toscano
3958e3d6a5 docs: document firmware attribute for VMware guests
Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Pino Toscano <ptoscano@redhat.com>
2019-04-15 20:03:55 -04:00
Pino Toscano
b4e34d1083 vmx: write firmware back from autoselection
When writing the VMX file from the domain XML, write the firmware key
according to the firmware autoselection.  Though, at the moment only
'efi' is supported.

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Pino Toscano <ptoscano@redhat.com>
2019-04-15 20:03:55 -04:00
Pino Toscano
9bb6e4e739 vmx: convert firmware config for autoselection
Convert the firmware key to a type of autoselected firmware.

Only the 'efi' firmware is allowed for now, in case the key is present.
It seems VMware (at least ESXi) does not write the key in VMX files when
setting BIOS as firmware.

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Pino Toscano <ptoscano@redhat.com>
2019-04-15 20:03:55 -04:00
Laine Stump
fc79e73836 network: only reload firewall after firewalld is finished restarting
The network driver used to reload the firewall rules whenever a dbus
NameOwnerChanged message for org.fedoraproject.FirewallD1 was
received. Presumably at some point in the past this was successful at
reloading our rules after a firewalld restart. Recently though I
noticed that once firewalld was restarted, libvirt's logs would get this
message:

  The name org.fedoraproject.FirewallD1 was not provided by any .service files

After this point, no networks could be started until libvirtd itself
was restarted.

The problem is that the NameOwnerChanged message is sent twice during
a firewalld restart - once when the old firewalld is stopped, and
again when the new firewalld is started. If we try to reload at the
point the old firewalld is stopped, none of the firewalld dbus calls
will succeed.

The solution is to check the new_owner field of the message - we
should reload our firewall rules only if new_owner is non-empty (it is
set to "" when firewalld is stopped, and some sort of epoch number
when it is again started).

Signed-off-by: Laine Stump <laine@laine.org>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2019-04-15 12:53:38 -04:00
Laine Stump
687f556750 util: eliminate duplicate function virDBusMessageRead
When virDBusMessageRead() and virDBusMessageDecode were first added in
commit 834c9c94, they were identical except that virDBusMessageRead()
would unref the message after decoding it.

This difference was eliminated later in commit dc7f3ffc after it
became apparent that unref-ing the message so soon was never the right
thing to do. The two identical functions remained though, with the
tests and virDBus library itself calling the Decode variant, and all
other users calling the Read variant.

This patch eliminates the duplication, switching all users to
virDBusMessageDecode (and moving the nice API documentation comment
from the Read function up to the Decode function).

Signed-off-by: Laine Stump <laine@laine.org>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2019-04-15 12:47:44 -04:00
Daniel P. Berrangé
4683a609f6 vbox: drop C API definition for release 4.3.4
Support for compiling this version was dropped in an earlier commit.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2019-04-15 17:16:52 +01:00
Daniel P. Berrangé
9a6d16674f vbox: drop C API definition for release 4.3
Support for compiling this version was dropped in an earlier commit.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2019-04-15 17:16:46 +01:00
Daniel P. Berrangé
1aab36e16b vbox: drop C API definition for release 4.2.20
Support for compiling this version was dropped in an earlier commit.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2019-04-15 17:16:44 +01:00
Daniel P. Berrangé
3b111eddb9 vbox: drop C API definition for release 4.2
Support for compiling this version was dropped in an earlier commit.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2019-04-15 17:16:41 +01:00
Daniel P. Berrangé
4e65eda252 vbox: drop C API definition for release 4.1
Support for compiling this version was dropped in an earlier commit.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2019-04-15 17:16:37 +01:00
Daniel P. Berrangé
3e2402e8b8 vbox: drop C API definition for release 4.0
Support for compiling this version was dropped in an earlier commit.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2019-04-15 17:16:31 +01:00