Commit Graph

24192 Commits

Author SHA1 Message Date
Michal Privoznik
2a1ae8fba7 lib: Preserve error around virDomainNetReleaseActualDevice()
This function is calling public API virNetworkLookupByName()
which resets the error. Therefore, if
virDomainNetReleaseActualDevice() is used in cleanup path it
actually resets the original error that got us jump into
'cleanup' label.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2019-04-30 17:00:46 +02:00
Daniel P. Berrangé
04e4307d34 Revert "network: use 'bridge' as actual type instead of 'network'"
This caused the live XML to report the 'bridge' type instead of the
'network' type, which is a behavioural regression.

It also breaks 'virsh domif-setlink', 'virsh update-device' and
'virsh domiftune'

This reverts commit 518026e159.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2019-04-30 14:42:34 +01:00
Daniel P. Berrangé
e007e8ba3a Revert "virt drivers: don't handle type=network after resolving actual network type"
This reverts commit 2f5e6502e3.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2019-04-30 14:42:22 +01:00
Jie Wang
5d5e7875cd qemu_command: fix double_close vhostfd in qemuBuildHostdevCommandLine
vhostfd passed to cmd->passfd in virCommandPassFD, virCommandFree will
always close cmd->passfd when qemuBuildSCSIVHostHostdevDevStr failed.

Signed-off-by: Jie Wang <wangjie88@huawei.com>
2019-04-30 11:10:36 +02:00
Julio Faracco
596aa144c4 util: Fix uninitalized variable to avoid garbage value.
This commit is similar with 692400f4. It fixes an uninitialized
variable to avoid garbage value. This case, returns 0 jiffies if an
error occurs with virNetDevBridgeGet.

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
2019-04-30 09:44:21 +02:00
John Ferlan
a536088e51 conf: Fix typo in error message
Fix obvious typo.

Signed-off-by: John Ferlan <jferlan@redhat.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
2019-04-29 14:29:11 -04:00
Michal Privoznik
572c50849c qemu: Check for user alias collisions in coldplug
https://bugzilla.redhat.com/show_bug.cgi?id=1697676

If an user tries to attach a device with colliding user alias
then we attach it happily and thus leave domain unable to start.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2019-04-26 15:47:40 +02:00
Michal Privoznik
57eb2936f3 qemu: On attach to live XML check for user alias collision only live XML
When attaching a device to live XML we don't care (well,
shouldn't care) that there's already a device in inactive XML
that has the same user alias.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2019-04-26 15:47:36 +02:00
Michal Privoznik
c4c44b535b qemuDomainAttachDeviceLiveAndConfig: Don't overwrite @ret
If we're attaching a device to both inactive and live XML then
@ret is overwritten which may result in incorrect return value.
For instance, if attaching to inactive XML succeeds, @ret is
assigned value of zero and control proceeds to attaching the
device to live XML. Here, if say
virDomainDeviceValidateAliasForHotplug() fails the control jumps
over to 'cleanup' label and zero is returned indicating success.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2019-04-26 15:16:17 +02:00
Michal Privoznik
08193fdbf5 src: Check for virDomainDiskInsert() retval properly
Our coding style specifies that only negative values are considered as
error. Check for return value of virDomainDiskInsert() properly,
following the style. Not that the function can now return anything other
than 0 or -1, but it just triggers my OCD.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2019-04-26 15:14:17 +02:00
Jiri Denemark
8feeee9ee2 cpu_map: Add support for cldemote CPU feature
Added in QEMU by v2.12.0-481-g0da0fb0628 (released in 3.0).

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-04-25 16:26:46 +02:00
Peter Krempa
4b99ba98d0 util: hash: Append to hash buckets when adding new entries
In cases when the hash function for a name collides with other entry
already in the hash we prepend to the bucket. This creates a 'stack
effect' on the buckets if we then iterate through the hash. Normally
this is not a problem, but in tests we want deterministic results.

Since it does not matter where we add the entry and it's usually more
probable that a different entry will be accessed next change it to
append to the end of the bucket. Luckily we already iterate throught the
bucket once thus we can easily find the last entry and just connect the
new entry after it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2019-04-25 13:28:16 +02:00
Daniel Henrique Barboza
cc1d1dbbd5 qemuDomainPMSuspendForDuration: check for wake-up support
If the current QEMU guest can't wake up from suspend properly,
and we are able to determine that, avoid suspending the guest
at all. To be able to determine this support, QEMU needs to
implement the 'query-current-machine' QMP call. This is reflected
by the QEMU_CAPS_QUERY_CURRENT_MACHINE cap.

If the cap is enabled, a new function qemuDomainProbeQMPCurrentMachine
is called. This is wrapper for qemuMonitorGetCurrentMachineInfo,
where the 'wakeup-suspend-support' flag is retrieved from
'query-current-machine'. If wakeupSuspendSupport is true,
proceed with the regular flow of qemuDomainPMSuspendForDuration.

The absence of QEMU_CAPS_QUERY_CURRENT_MACHINE indicates that
we're dealing with a QEMU version older than 4.0 (which implements
the required QMP API). In this case, proceed as usual with the
suspend logic of qemuDomainPMSuspendForDuration, since we can't
assume whether the guest has support or not.

Fixes: https://bugs.launchpad.net/ubuntu/+source/qemu/+bug/1759509
Reported-by: Balamuruhan S <bala24@linux.vnet.ibm.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2019-04-25 11:43:53 +02:00
Michal Privoznik
70a4e3ee07 qemu_monitor: Introduce handler for 'query-current-machine' command
So far, this command returns a structure with only one member:
'wakeup-suspend-support'. But that's okay. It's what we are after
anyway.

Based-on-work-of: Daniel Henrique Barboza <danielhb413@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2019-04-25 11:43:53 +02:00
Daniel Henrique Barboza
dca1b1d007 qemu_capabilities: Add QEMU_CAPS_QUERY_CURRENT_MACHINE
QEMU commit 46ea94ca9cf ("qmp: query-current-machine with
wakeup-suspend-support") added a new QMP command called
'query-current-machine' that retrieves guest parameters that
can vary in the same machine model (e.g. ACPI support for x86 VMs
depends on the '--no-acpi' option). Currently, this API has a single
flag, 'wakeup-suspend-support', that indicates whether the guest has
the capability of waking up from suspended state.

Introduce a libvirt capability that reflects whether qemu has the
monitor command.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2019-04-25 11:43:53 +02:00
Pavel Hrdina
9470815d54 vircgroup: no need to ifdef virCgroupFree
virCgroup struct is always defined and the free function is not calling
anything that would require OS supporting cgroups.

This fixes an issue if we try to start a VM with QEMU binary that
doesn't support QXL.  The start operation will fail in
qemuProcessStartValidateVideo() which will set correct error message,
but later in one of the cleanup paths we will call
qemuDomainObjPrivateDataClear() which always calls virCgroupFree()
and that will fail on OS that doesn't support cgroups and it will
set a new error which will be eventually reported to user.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2019-04-25 11:43:07 +02:00
Allen, John
51f9f80d35 Handle copying bitmaps to larger data buffers
If a bitmap of a shorter length than the data buffer is passed to
virBitmapToDataBuf, it will read off the end of the bitmap and copy junk
into the returned buffer. Add a check to only copy the length of the
bitmap to the buffer.

The problem can be observed after setting a vcpu affinity using the vcpupin
command on a system with a large number of cores:
  # virsh vcpupin example_domain 0 0
  # virsh vcpupin example_domain 0
     VCPU   CPU Affinity
    ---------------------------
     0      0,192,197-198,202

Signed-off-by: John Allen <john.allen@amd.com>
2019-04-25 10:18:48 +02:00
Nikolay Shirokovskiy
055af76f16 conf: add cpu check attribute to ABI check
Different check values are not ABI compatible. For example
if on migration we change 'full' to 'partial' then guest cpu
on destination can be different.

Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
2019-04-25 10:02:23 +03:00
Michal Privoznik
1cc1b8360b networkStartNetworkVirtual: Don't overwrite error in 'err5'
If there's an error when setting up QoS on a bridge the control
jumps over to 'err5' label. Here, the virNetDevBandwidthClear()
is called to clear out any partially set QoS. This function can
also report an error which would overwrite the actual error that
caused us jumping here. Use virErrorPreserveLast() to preserve
the original error.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2019-04-24 09:33:45 +02:00
Cole Robinson
77bca8b730 qemu: monitor: check for common 'Error: ' string
qemu 4.0.0 will prefix most errors with 'Error: ', so consider any
string instance of that an error.

This fixes savevm failure detection when migration is blocked due to
usage of nested VMX

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

Acked-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2019-04-23 11:05:44 -04:00
Cole Robinson
d9ed7bb1dd qemu: monitor cleanup delvm error handling
Drop redundant NULL checks, and add an error string prefix

Acked-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2019-04-23 11:05:44 -04:00
Cole Robinson
a82c182171 qemu: monitor: cleanup loadvm error handling
Drop redundant NULL checks, add error string prefixes, consolidate
a few indentical reports.

Acked-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2019-04-23 11:05:43 -04:00
Syed Humaid
e9d4912cc0 network: Convert to virErrorRestore/virErrorPreserveLast
Replaced usage of virSaveLastError and virSetError/virFreeError with
virErrorPreserveLast and virErrorRestore respectively.

Signed-off-by: Syed Humaid <syedhumaidbinharoon@gmail.com>
2019-04-23 15:40:59 +02:00
Michal Privoznik
528e26e77f vmx: Free @firmware in virVMXParseConfig
The @firmware string is allocated, but never freed.

 4 bytes in 1 blocks are definitely lost in loss record 1 of 44
    at 0x483579F: malloc (vg_replace_malloc.c:299)
    by 0x76FB469: strdup (strdup.c:42)
    by 0x497B6DE: virStrdup (virstring.c:966)
    by 0x48F6FD3: virConfGetValueString (virconf.c:908)
    by 0x4B3E9B6: virVMXGetConfigStringHelper (vmx.c:736)
    by 0x4B3EA6B: virVMXGetConfigString (vmx.c:756)
    by 0x4B41AEA: virVMXParseConfig (vmx.c:1832)
    by 0x10B8E4: testCompareFiles (vmx2xmltest.c:79)
    by 0x10BAB8: testCompareHelper (vmx2xmltest.c:124)
    by 0x10D058: virTestRun (testutils.c:174)
    by 0x10CDDA: mymain (vmx2xmltest.c:288)
    by 0x10F11C: virTestMain (testutils.c:1096)

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Pino Toscano <ptoscano@redhat.com>
2019-04-23 10:59:01 +02:00
Michal Privoznik
4f18b2d755 libxlDriverConfigDispose: Free @configBaseDir too
Allocated in libxlDriverConfigNew(), the @configBaseDir is never
freed.

 13 bytes in 1 blocks are definitely lost in loss record 36 of 125
    at 0x483579F: malloc (vg_replace_malloc.c:299)
    by 0x8012469: strdup (strdup.c:42)
    by 0x52926DE: virStrdup (virstring.c:966)
    by 0x11D46B: libxlDriverConfigNew (libxl_conf.c:1749)
    by 0x114D78: testCompareXMLToDomConfig (libxlxml2domconfigtest.c:62)
    by 0x1152A3: testCompareXMLToDomConfigHelper (libxlxml2domconfigtest.c:160)
    by 0x115925: virTestRun (testutils.c:174)
    by 0x1154A4: mymain (libxlxml2domconfigtest.c:216)
    by 0x1179E9: virTestMain (testutils.c:1096)
    by 0x1154FD: main (libxlxml2domconfigtest.c:224)

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2019-04-20 07:50:45 +02:00
Michal Privoznik
918e8d6867 qemu_cgroup: Remove unused qemuSetupCpusetMems
This function is not used anymore. Let's remove it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2019-04-18 17:59:19 +02:00
Michal Privoznik
0eaa4716e1 qemu: Set up EMULATOR thread and cpuset.mems before exec()-ing qemu
It's funny how this went unnoticed for such a long time. Long
story short, if a domain is configured with
VIR_DOMAIN_NUMATUNE_MEM_STRICT libvirt doesn't really honour
that. This is because of 7e72ac7878 after which libvirt allowed
qemu to allocate memory just anywhere and only after that it used
some magic involving cpuset.memory_migrate and cpuset.mems to
move the memory to desired NUMA nodes. This was done in order to
work around some KVM bug where KVM would fail if there wasn't a
DMA zone available on the NUMA node. Well, while the work around
might stopped libvirt tickling the KVM bug it also caused a bug
on libvirt side: if there is not enough memory on configured NUMA
node(s) then any attempt to start a domain must fail. Because of
the way we play with guest memory domains can start just happily.

The solution is to move the child we've just forked into emulator
cgroup, set up cpuset.mems and exec() qemu only after that.

This basically reverts 7e72ac7878 which was a workaround
for kernel bug. This bug was apparently fixed because I've tested
this successfully with recent kernel.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2019-04-18 17:53:42 +02:00
Michal Privoznik
22dc3e94c2 Revert "domain_conf: check device address before attach"
This reverts commit f1d6585300.

Turns out, this caused a regression. There is this (perhaps less
known) semantic of virDomainAttachDevice() where if the device
the API is trying to attach is a CDROM/floppy that is already in
the domain the attach request is handled as 'change the media in
the drive'.

We have a better fix anyways.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Tested-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
2019-04-18 17:09:40 +02:00
Michal Privoznik
ddc72f9902 qemu_hotplug: Check for duplicate drive addresses
This tries to fix the same problem as f1d6585300 but it's doing
so in a less invasive way.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Tested-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
2019-04-18 17:09:02 +02:00
Michal Privoznik
89237d534f conf: Expose virDomainSCSIDriveAddressIsUsed
This function checks if given drive address is already present in
passed domain definition. Expose the function as it will be used
shortly.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Tested-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
2019-04-18 17:04:33 +02:00
Daniel P. Berrangé
b806a60eaf network: move re-attach of bridge device out of network driver
During initial NIC setup the hypervisor drivers are responsible for
attaching the TAP device to the bridge device. Any fixup after libvirtd
restarts should thus also be their responsibility.

Reviewed-by: Laine Stump <laine@laine.org>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2019-04-18 13:10:26 +01:00
Daniel P. Berrangé
2f5e6502e3 virt drivers: don't handle type=network after resolving actual network type
The call to resolve the actual network type will turn any NICs with
type=network into one of the other types. Thus there should be no need
to handle type=network in later switch() statements jumping off the
actual type.

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2019-04-18 13:10:06 +01:00
Daniel P. Berrangé
518026e159 network: use 'bridge' as actual type instead of 'network'
Ports allocated on virtual networks with type=nat|route|open all get
given an actual type of 'network'.

Only ports in networks with type=bridge use an actual type of 'bridge'.

This distinction makes little sense since the virtualization drivers
will treat both actual types in exactly the same way, as they're all
just bridge devices a VM needs to be connected to.

This doesn't affect user visible XML since the "actual" device XML
is internal only, but we need code to convert the data upgrades.

Reviewed-by: Laine Stump <laine@laine.org>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2019-04-18 13:10:00 +01:00
Daniel P. Berrangé
e2c5f0f6cf conf: don't pass interface type into virNetDevBandwidthParse
The virNetDevBandwidthParse method uses the interface type to decide
whether to allow use of the "floor" parameter. Using the interface
type is not convenient as callers may not have that available, but
still wish to allow use of "floor". Switch to an explicit boolean
to control its usage.

Reviewed-by: Laine Stump <laine@laine.org>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2019-04-18 11:27:09 +01:00
Daniel P. Berrangé
9900da3c93 network: explain reason for bandwidth floor rejection
Reword error messages to make it clear that the combined floor settings
of all NICs are exceeding the network inbound peak/average
settings. Including the actual values being checked helps to diagnose
what is actually wrong.

Reviewed-by: Laine Stump <laine@laine.org>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2019-04-18 11:18:43 +01:00
Daniel P. Berrangé
557a96e0f4 network: ensure floor sum is reset to zero when starting networks
In extreme cases libvirt can get mixed up about what VMs are running and
attached to a network leading to the cached floor sum value being
outdated. When this happens the only option is to destroy the network
and then restart libvirtd. If we set floor sum back to zero when
starting the network, we avoid the need for a libvirtd restart at least.

Reviewed-by: Laine Stump <laine@laine.org>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2019-04-18 11:18:31 +01:00
Syed Humaid
aa9d4d27c1 lib: domain: Convert to virErrorRestore/virErrorPreserveLast
Replaced all virSaveLastError and virSetError/virFreeError usages to
virErrorPreserveLast and virErrorRestore respectively.

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Syed Humaid <syedhumaidbinharoon@gmail.com>
2019-04-17 10:19:49 -04:00
Daniel P. Berrangé
d0a160d645 network: stop passing virDomainNetDefPtr into bandwidth functions
The networkPlugBandwidth & networkUnplugBandwidth methods currently take
a virDomainNetDefPtr. To remove the dependency on the domain config
struct, pass individual parameters instead.

Reviewed-by: Laine Stump <laine@laine.org>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2019-04-17 14:12:56 +01:00
Daniel P. Berrangé
85f915d8be network: unconditionally merge port profiles
All but one of the network types supports port profiles. Rather than
duplicating the code to merge profiles 3 times, do it once and then
later report an error if used from the wrong place.

Reviewed-by: Laine Stump <laine@laine.org>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2019-04-17 14:12:56 +01:00
Daniel P. Berrangé
80772a58b6 util: add API for copying virtual port profile data
Reviewed-by: Laine Stump <laine@laine.org>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2019-04-17 14:12:56 +01:00
Michal Privoznik
4bdce1219f qemu: Simplify interface handling in qemuConnectDomainXMLToNative()
Firstly, VIR_STRDUP() accepts NULL, so there is no need to check
if the string we want to duplicate is not-NULL. Secondly,
virDomainNetSetModelString() also accepts NULL. Thirdly, we have
VIR_AUTOFREE().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-04-17 10:47:23 +02:00
Andrea Bolognani
3c32f9ec42 qemu: Fix uninitialized variable
It has made Clang very unhappy ever since 6bf7c67699.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
2019-04-17 09:33:28 +02:00
Nikolay Shirokovskiy
e149443b8b vz: fixes: snapshot: Factor out virDomainMomentDef class
Fix for commit ffc0fbebe refactoring snapshot code.

Reviewed-by: Cole Robinson <crobinso@redhat.com>
ACKed-by: Maxim Nestratov <mnestratov@virtuozzo.com>
Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
2019-04-17 10:07:31 +03:00
Nikolay Shirokovskiy
17b9149b33 vz: fixes: snapshot: Switch type of virDomainSnapshotObj.def
Fix for commit 1ab05da22 refactoring snapshot code.

Reviewed-by: Cole Robinson <crobinso@redhat.com>
ACKed-by: Maxim Nestratov <mnestratov@virtuozzo.com>
Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
2019-04-17 10:07:28 +03:00
Nikolay Shirokovskiy
be2bff3d0a vz: fix for tracking current snapshot
f1056279 removed virDomainSnapshotDef.current and leaved
using vm->current_snapshot only. Later 4819f54bd moved current snapshot
tracking to virDomainSnapshotObjList. As vz driver never used
vm->current_snaphot this patch includes fixes after both commits.

Reviewed-by: Cole Robinson <crobinso@redhat.com>
ACKed-by: Maxim Nestratov <mnestratov@virtuozzo.com>
Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
2019-04-17 10:06:20 +03:00
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
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