]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
6 years agoqemu: qapi: Return schema entry via argument in virQEMUQAPISchemaTraverse
Peter Krempa [Tue, 9 Apr 2019 11:25:49 +0000 (13:25 +0200)]
qemu: qapi: Return schema entry via argument in virQEMUQAPISchemaTraverse

To allow for boolean query string, let's return the queried schema entry
via argument rather than a return value.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: qapi: Fix return value of impossible case in virQEMUQAPISchemaTraverse
Peter Krempa [Thu, 11 Apr 2019 07:10:39 +0000 (09:10 +0200)]
qemu: qapi: Fix return value of impossible case in virQEMUQAPISchemaTraverse

The return statement after the infinite loop without a break is there to
appease the compiler. Make it return NULL as it would be a failure if
control flow reaches that point.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agotests: qemumonitorjson: Add tests for QAPI schema query
Peter Krempa [Tue, 9 Apr 2019 11:22:32 +0000 (13:22 +0200)]
tests: qemumonitorjson: Add tests for QAPI schema query

While we technically test the query strings in the qemucapabilitiestest
this was done to help refactor and extend the QAPI schema query
infrastructure.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: qapi: Use automatic memory cleanup
Peter Krempa [Tue, 9 Apr 2019 08:36:16 +0000 (10:36 +0200)]
qemu: qapi: Use automatic memory cleanup

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agotests: qemumonitorjson: Rename schema validation test cases
Peter Krempa [Tue, 9 Apr 2019 08:32:33 +0000 (10:32 +0200)]
tests: qemumonitorjson: Rename schema validation test cases

Rename DO_TEST_QAPI_SCHEMA to DO_TEST_QAPI_VALIDATE.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agovirBuffer: Try harder to free buffer
Michal Privoznik [Thu, 18 Apr 2019 12:03:10 +0000 (14:03 +0200)]
virBuffer: Try harder to free buffer

Currently, the way virBufferFreeAndReset() works is it relies on
virBufferContentAndReset() to fetch the buffer content which is
then freed. This works as long as there is no bug in virBuffer*
implementation (not true apparently). Explicitly call free() over
buffer content.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agotests/virhostdevtest: remove virHostdevHostSupportsPassthroughKVM
Daniel Henrique Barboza [Thu, 2 May 2019 12:51:52 +0000 (09:51 -0300)]
tests/virhostdevtest: remove virHostdevHostSupportsPassthroughKVM

virhostdevtest is using pci mock to emulate all PCI attach/detach
operations. This means that that this test does not rely on KVM
support of the host anymore and the tests in this file shouldn't
be affected by it.

Suggested-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
6 years agoqemuConnectOpen: Drop unused @cfg and simplify
Michal Privoznik [Tue, 30 Apr 2019 09:44:22 +0000 (11:44 +0200)]
qemuConnectOpen: Drop unused @cfg and simplify

After 65a372d6e0 the @cfg variable is no longer used. This means
we can drop it and therefore drop 'cleanup' label with it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
6 years agovirbuffer: Use signed integer for storing error
Michal Privoznik [Thu, 18 Apr 2019 12:02:08 +0000 (14:02 +0200)]
virbuffer: Use signed integer for storing error

The @error member can contain a positive value (errno) or a
negative value (-1) to denote a usage error. It doesn't make
much sense to store it as unsigned then.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agovirbuffer: Don't leak memory in virBufferAddBuffer
Michal Privoznik [Thu, 18 Apr 2019 11:59:15 +0000 (13:59 +0200)]
virbuffer: Don't leak memory in virBufferAddBuffer

If an error occurs in a virBuffer* API the idea is to free the
content immediately and set @error member used in error reporting
later. Well, this is not what how virBufferAddBuffer works.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
6 years agotest_driver: provide virDomainGetTime implementation
Ilias Stamatis [Wed, 24 Apr 2019 16:57:57 +0000 (18:57 +0200)]
test_driver: provide virDomainGetTime implementation

Implement testDomainGetTime by returning a fixed timestamp.

Signed-off-by: Ilias Stamatis <stamatis.iliass@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
6 years agomaint: Post-release version bump to 5.4.0
Michal Privoznik [Sat, 4 May 2019 21:39:23 +0000 (23:39 +0200)]
maint: Post-release version bump to 5.4.0

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
6 years agoRelease of libvirt-5.3.0
Daniel Veillard [Sat, 4 May 2019 18:13:03 +0000 (20:13 +0200)]
Release of libvirt-5.3.0

* docs/news.xml: updated for the release

Signed-off-by: Daniel Veillard <veillard@redhat.com>
6 years agoqemu.conf: Make nvram list obsolete
Michal Privoznik [Tue, 16 Apr 2019 15:30:13 +0000 (17:30 +0200)]
qemu.conf: Make nvram list obsolete

Now that libvirt has firmware auto selection feature the nvram
config knob is more or less obsolete. It still makes sense in
cases where distro users are using does not provide FW descriptor
files, therefore I'm not removing it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
6 years agotest: match qemu VIR_DOMAIN_DEF_FEATURE* usage
Cole Robinson [Wed, 17 Apr 2019 14:38:57 +0000 (10:38 -0400)]
test: match qemu VIR_DOMAIN_DEF_FEATURE* usage

Match the XML feature usage of the qemu driver, so the test driver
doesn't reject things like <os firmware='efi'/>.

Particularly VIR_DOMAIN_DEF_FEATURE_NET_MODEL_STRING is needed to
prevent regressions for test suite users with net model strings that
aren't in the virDomainNetModel enum yet

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agospec: fix f28 rpm without firewalld zone
Cole Robinson [Tue, 30 Apr 2019 14:39:31 +0000 (10:39 -0400)]
spec: fix f28 rpm without firewalld zone

Commit 3b71f2e42d added spec handling for with_firewalld_zone. We
now call %firewalld_reload if with_firewalld is set. But the matching
'BuildRequires: firewalld-filesystem' is only applied if
with_firewalld_zone is set.

Fix the former bit to use with_firewalld_zone

Reviewed-by: Laine Stump <laine@laine.org>
Reported-by: Yuval Turgeman <yturgema@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agolib: Preserve error around virDomainNetReleaseActualDevice()
Michal Privoznik [Tue, 30 Apr 2019 14:17:14 +0000 (16:17 +0200)]
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>
6 years agonews: Update for 5.3.0 release
Michal Privoznik [Tue, 30 Apr 2019 12:40:37 +0000 (14:40 +0200)]
news: Update for 5.3.0 release

Some basic features/bugfixes/removed features. Of course we've
done a lot more than recoded here.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
6 years agoRevert "network: use 'bridge' as actual type instead of 'network'"
Daniel P. Berrangé [Tue, 30 Apr 2019 12:26:30 +0000 (13:26 +0100)]
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 518026e15959ab0e19b659a9f2ff502a54946498.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agoRevert "virt drivers: don't handle type=network after resolving actual network type"
Daniel P. Berrangé [Tue, 30 Apr 2019 12:26:25 +0000 (13:26 +0100)]
Revert "virt drivers: don't handle type=network after resolving actual network type"

This reverts commit 2f5e6502e34d9ddba596fa824b2f2f3504b34a99.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agoqemu_command: fix double_close vhostfd in qemuBuildHostdevCommandLine
Jie Wang [Tue, 30 Apr 2019 05:24:15 +0000 (13:24 +0800)]
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>
6 years agoutil: Fix uninitalized variable to avoid garbage value.
Julio Faracco [Tue, 30 Apr 2019 00:29:54 +0000 (21:29 -0300)]
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>
6 years agovirsh: Add source-protocol-ver to pool-define-as docs
John Ferlan [Mon, 29 Apr 2019 11:51:23 +0000 (07:51 -0400)]
virsh: Add source-protocol-ver to pool-define-as docs

Commit a3dbaa364 neglected to add the source-protocol-ver to the
pool-define-as command.

Signed-off-by: John Ferlan <jferlan@redhat.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
6 years agoconf: Fix typo in error message
John Ferlan [Mon, 29 Apr 2019 11:50:49 +0000 (07:50 -0400)]
conf: Fix typo in error message

Fix obvious typo.

Signed-off-by: John Ferlan <jferlan@redhat.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
6 years agodocs: Fix typo in the firmware value
Fabiano Fidêncio [Mon, 29 Apr 2019 10:32:31 +0000 (12:32 +0200)]
docs: Fix typo in the firmware value

firmware attribute from <os/> takes either 'efi' or 'bios' as its
allowed values. However, the current documentation mistakenly mentions
'uefi' instead of 'efi'.

Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
6 years agoqemu: Check for user alias collisions in coldplug
Michal Privoznik [Fri, 26 Apr 2019 13:33:34 +0000 (15:33 +0200)]
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>
6 years agoqemu: On attach to live XML check for user alias collision only live XML
Michal Privoznik [Fri, 26 Apr 2019 13:30:40 +0000 (15:30 +0200)]
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>
6 years agoqemuDomainAttachDeviceLiveAndConfig: Don't overwrite @ret
Michal Privoznik [Fri, 26 Apr 2019 13:16:17 +0000 (15:16 +0200)]
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>
6 years agosrc: Check for virDomainDiskInsert() retval properly
Michal Privoznik [Fri, 26 Apr 2019 13:14:17 +0000 (15:14 +0200)]
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>
6 years agovirsh: Put a new line char after <alias/> in attach-disk
Michal Privoznik [Fri, 26 Apr 2019 12:07:47 +0000 (14:07 +0200)]
virsh: Put a new line char after <alias/> in attach-disk

Each attribute is on its own line. We forgot to add new line
character for <alias/>

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
6 years agocpu_map: Add support for cldemote CPU feature
Jiri Denemark [Thu, 25 Apr 2019 08:58:47 +0000 (10:58 +0200)]
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>
6 years agoutil: hash: Append to hash buckets when adding new entries
Peter Krempa [Tue, 16 Apr 2019 13:11:40 +0000 (15:11 +0200)]
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>
6 years agoqemuDomainPMSuspendForDuration: check for wake-up support
Daniel Henrique Barboza [Wed, 24 Apr 2019 21:16:29 +0000 (18:16 -0300)]
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>
6 years agoqemu_monitor: Introduce handler for 'query-current-machine' command
Michal Privoznik [Wed, 24 Apr 2019 21:16:28 +0000 (18:16 -0300)]
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>
6 years agoqemu_capabilities: Add QEMU_CAPS_QUERY_CURRENT_MACHINE
Daniel Henrique Barboza [Wed, 24 Apr 2019 21:16:27 +0000 (18:16 -0300)]
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>
6 years agovircgroup: no need to ifdef virCgroupFree
Pavel Hrdina [Wed, 24 Apr 2019 13:26:12 +0000 (15:26 +0200)]
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>
6 years agoHandle copying bitmaps to larger data buffers
Allen, John [Mon, 15 Apr 2019 14:43:07 +0000 (14:43 +0000)]
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>
6 years agoconf: add cpu check attribute to ABI check
Nikolay Shirokovskiy [Wed, 24 Apr 2019 09:51:18 +0000 (12:51 +0300)]
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>
6 years agonetworkStartNetworkVirtual: Don't overwrite error in 'err5'
Michal Privoznik [Tue, 23 Apr 2019 14:04:55 +0000 (16:04 +0200)]
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>
6 years agoqemu: monitor: check for common 'Error: ' string
Cole Robinson [Wed, 10 Apr 2019 17:56:54 +0000 (13:56 -0400)]
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>
6 years agoqemu: monitor cleanup delvm error handling
Cole Robinson [Wed, 10 Apr 2019 17:43:39 +0000 (13:43 -0400)]
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>
6 years agoqemu: monitor: cleanup loadvm error handling
Cole Robinson [Wed, 10 Apr 2019 17:52:29 +0000 (13:52 -0400)]
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>
6 years agonetwork: Convert to virErrorRestore/virErrorPreserveLast
Syed Humaid [Wed, 17 Apr 2019 04:11:06 +0000 (08:11 +0400)]
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>
6 years agovmx: Free @firmware in virVMXParseConfig
Michal Privoznik [Sat, 20 Apr 2019 05:01:04 +0000 (07:01 +0200)]
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>
6 years agolibxlDriverConfigDispose: Free @configBaseDir too
Michal Privoznik [Sat, 20 Apr 2019 05:00:49 +0000 (07:00 +0200)]
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>
6 years agoqemucaps2xmltest: Don't leak @binary
Michal Privoznik [Sat, 20 Apr 2019 05:00:14 +0000 (07:00 +0200)]
qemucaps2xmltest: Don't leak @binary

There's no need to keep @binary around.
virQEMUCapsInitGuestFromBinary() duplicates the string anyway.

 1,002 bytes in 36 blocks are definitely lost in loss record 54 of 59
    at 0x483579F: malloc (vg_replace_malloc.c:299)
    by 0x796B1C7: vasprintf (vasprintf.c:73)
    by 0x4C3F2C6: virVasprintfInternal (virstring.c:740)
    by 0x4C3F3DC: virAsprintfInternal (virstring.c:761)
    by 0x13AFC9: testGetCaps (qemucaps2xmltest.c:105)
    by 0x13B200: testQemuCapsXML (qemucaps2xmltest.c:157)
    by 0x13B642: virTestRun (testutils.c:174)
    by 0x13B366: doCapsTest (qemucaps2xmltest.c:191)
    by 0x13FF2B: testQemuCapsIterate (testutilsqemu.c:941)
    by 0x13B427: mymain (qemucaps2xmltest.c:215)
    by 0x13D706: virTestMain (testutils.c:1096)
    by 0x13B489: main (qemucaps2xmltest.c:221)

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
6 years agoqemu_cgroup: Remove unused qemuSetupCpusetMems
Michal Privoznik [Mon, 15 Apr 2019 16:28:41 +0000 (18:28 +0200)]
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>
6 years agoqemu: Set up EMULATOR thread and cpuset.mems before exec()-ing qemu
Michal Privoznik [Wed, 10 Apr 2019 15:14:25 +0000 (17:14 +0200)]
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 7e72ac787848 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 7e72ac787848b7434c9 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>
6 years agoRevert "domain_conf: check device address before attach"
Michal Privoznik [Thu, 11 Apr 2019 13:40:51 +0000 (15:40 +0200)]
Revert "domain_conf: check device address before attach"

This reverts commit f1d6585300001c7b23b8796a0faa4411c3531996.

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>
6 years agoqemu_hotplug: Check for duplicate drive addresses
Michal Privoznik [Thu, 11 Apr 2019 13:45:27 +0000 (15:45 +0200)]
qemu_hotplug: Check for duplicate drive addresses

This tries to fix the same problem as f1d65853000 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>
6 years agoqemuhotplugtest: Don't plug a SCSI disk at unit 7
Michal Privoznik [Thu, 11 Apr 2019 14:23:38 +0000 (16:23 +0200)]
qemuhotplugtest: Don't plug a SCSI disk at unit 7

Unit number 7 is kind of special. It's reserved for SCSI
controller. The comment in virDomainSCSIDriveAddressIsUsed()
summarizes that pretty nicely. Libvirt would never generate
such address.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Tested-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
6 years agoconf: Expose virDomainSCSIDriveAddressIsUsed
Michal Privoznik [Thu, 11 Apr 2019 13:44:14 +0000 (15:44 +0200)]
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>
6 years agonetwork: move re-attach of bridge device out of network driver
Daniel P. Berrangé [Fri, 1 Feb 2019 14:53:12 +0000 (14:53 +0000)]
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>
6 years agovirt drivers: don't handle type=network after resolving actual network type
Daniel P. Berrangé [Wed, 8 Aug 2018 15:27:53 +0000 (16:27 +0100)]
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>
6 years agonetwork: use 'bridge' as actual type instead of 'network'
Daniel P. Berrangé [Mon, 3 Sep 2018 16:48:53 +0000 (17:48 +0100)]
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>
6 years agoconf: don't pass interface type into virNetDevBandwidthParse
Daniel P. Berrangé [Tue, 29 Jan 2019 17:26:40 +0000 (17:26 +0000)]
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>
6 years agonetwork: explain reason for bandwidth floor rejection
Daniel P. Berrangé [Tue, 16 Apr 2019 16:39:12 +0000 (17:39 +0100)]
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>
6 years agonetwork: ensure floor sum is reset to zero when starting networks
Daniel P. Berrangé [Tue, 16 Apr 2019 16:36:57 +0000 (17:36 +0100)]
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>
6 years agolib: domain: Convert to virErrorRestore/virErrorPreserveLast
Syed Humaid [Tue, 16 Apr 2019 18:51:01 +0000 (22:51 +0400)]
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>
6 years agonetwork: stop passing virDomainNetDefPtr into bandwidth functions
Daniel P. Berrangé [Mon, 3 Sep 2018 11:02:22 +0000 (12:02 +0100)]
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>
6 years agonetwork: unconditionally merge port profiles
Daniel P. Berrangé [Mon, 3 Sep 2018 16:33:22 +0000 (17:33 +0100)]
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>
6 years agoutil: add API for copying virtual port profile data
Daniel P. Berrangé [Mon, 3 Sep 2018 16:02:35 +0000 (17:02 +0100)]
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>
6 years agoqemu: Simplify interface handling in qemuConnectDomainXMLToNative()
Michal Privoznik [Wed, 17 Apr 2019 08:14:59 +0000 (10:14 +0200)]
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>
6 years agoqemu: Fix uninitialized variable
Andrea Bolognani [Wed, 17 Apr 2019 07:22:05 +0000 (09:22 +0200)]
qemu: Fix uninitialized variable

It has made Clang very unhappy ever since 6bf7c6769925.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
6 years agovz: fixes: snapshot: Factor out virDomainMomentDef class
Nikolay Shirokovskiy [Fri, 5 Apr 2019 14:50:13 +0000 (17:50 +0300)]
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>
6 years agovz: fixes: snapshot: Switch type of virDomainSnapshotObj.def
Nikolay Shirokovskiy [Fri, 5 Apr 2019 14:49:25 +0000 (17:49 +0300)]
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>
6 years agovz: fix for tracking current snapshot
Nikolay Shirokovskiy [Fri, 5 Apr 2019 14:33:49 +0000 (17:33 +0300)]
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>
6 years agotests: Use TEST_QEMU_CAPS_PATH wherever possible
Andrea Bolognani [Tue, 16 Apr 2019 10:31:00 +0000 (12:31 +0200)]
tests: Use TEST_QEMU_CAPS_PATH wherever possible

After the recent changes, there are only a few places left
where we use the explicit path instead of taking advantage of
the publicly available define; let's get rid of those too.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
6 years agotests: Drop dirname argument from testQemuCapsIterate()
Andrea Bolognani [Tue, 16 Apr 2019 10:33:14 +0000 (12:33 +0200)]
tests: Drop dirname argument from testQemuCapsIterate()

As evidenced by all existing callers, the only directory it makes
sense to use is TEST_QEMU_CAPS_PATH, so let's just bake that into
the function.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
6 years agotests: Drop dirname argument from testQemuGetLatestCapsForArch()
Andrea Bolognani [Tue, 16 Apr 2019 10:26:22 +0000 (12:26 +0200)]
tests: Drop dirname argument from testQemuGetLatestCapsForArch()

As evidenced by all existing callers, the only directory it makes
sense to use is TEST_QEMU_CAPS_PATH, so let's just bake that into
the function.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
6 years agotests: Make TEST_QEMU_CAPS_PATH public
Andrea Bolognani [Tue, 16 Apr 2019 10:22:31 +0000 (12:22 +0200)]
tests: Make TEST_QEMU_CAPS_PATH public

The value (with a slightly different name) is currently private
to testutilsqemu, but since we use this path all over the place
it makes sense to define it publicly and avoid repetition.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
6 years agosnapshot: Use post-parse instead of regex in testsuite
Eric Blake [Tue, 16 Apr 2019 13:00:40 +0000 (08:00 -0500)]
snapshot: Use post-parse instead of regex in testsuite

Now that we can override the post-parse handling, let's update the
testsuite to provide the desired timestamp/name rather than ignoring
the non-deterministic one that was previously being generated. A few
output files need timestamps added now that they are no longer
ignored.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
6 years agosnapshot: Allow for post-parse override
Eric Blake [Tue, 16 Apr 2019 02:59:44 +0000 (21:59 -0500)]
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>
6 years agosnapshot: Factor out post-parse code
Eric Blake [Mon, 15 Apr 2019 22:25:52 +0000 (17:25 -0500)]
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>
6 years agosnapshot: Don't expose testsuite-only state in snapshot XML
Eric Blake [Tue, 16 Apr 2019 22:44:38 +0000 (17:44 -0500)]
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>
6 years agosnapshot: Refactor snapshotxml2xml test
Eric Blake [Mon, 15 Apr 2019 19:49:30 +0000 (14:49 -0500)]
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>
6 years agoconf: Add VIR_DOMAIN_DEF_FEATURE_NET_MODEL_STRING
Cole Robinson [Fri, 18 Jan 2019 20:57:32 +0000 (15:57 -0500)]
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>
6 years agovbox: Convert to net enum model
Cole Robinson [Fri, 18 Jan 2019 19:13:43 +0000 (14:13 -0500)]
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>
6 years agovmx: convert to net model enum
Cole Robinson [Fri, 18 Jan 2019 19:02:07 +0000 (14:02 -0500)]
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>
6 years agoconf: Make net model enum compare case insensitive
Cole Robinson [Wed, 13 Mar 2019 15:02:41 +0000 (11:02 -0400)]
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>
6 years agoqemu: Partially convert to net model enum
Cole Robinson [Fri, 18 Jan 2019 14:59:02 +0000 (09:59 -0500)]
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>
6 years agobhyve: convert to net model enum
Cole Robinson [Fri, 18 Jan 2019 00:59:21 +0000 (19:59 -0500)]
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>
6 years agovz: convert to net model enum
Cole Robinson [Fri, 18 Jan 2019 00:53:14 +0000 (19:53 -0500)]
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>
6 years agoconf: net: Add model enum, and netfront value
Cole Robinson [Fri, 18 Jan 2019 00:12:27 +0000 (19:12 -0500)]
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>
6 years agoconf: net: Rename 'model' to 'modelstr'
Cole Robinson [Fri, 18 Jan 2019 21:32:22 +0000 (16:32 -0500)]
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>
6 years agoconf: net: Add wrapper functions for <model> value
Cole Robinson [Thu, 17 Jan 2019 22:06:28 +0000 (17:06 -0500)]
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>
6 years agotests: Add several net model passthrough tests
Cole Robinson [Fri, 18 Jan 2019 20:46:56 +0000 (15:46 -0500)]
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>
6 years agotests: qemuxml2xml: Convert aarch64-os-firmware-efi to TEST_CAPS
Cole Robinson [Mon, 15 Apr 2019 22:53:55 +0000 (18:53 -0400)]
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>
6 years agotests: qemuxml2xml: Convert genid* to TEST_CAPS
Cole Robinson [Mon, 15 Apr 2019 23:00:46 +0000 (19:00 -0400)]
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>
6 years agotests: qemuxml2xml: Convert os-firmware* to TEST_CAPS
Cole Robinson [Mon, 15 Apr 2019 22:51:11 +0000 (18:51 -0400)]
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>
6 years agotests: qemuxml2xml: Convert virtio-*transitional to TEST_CAPS
Cole Robinson [Mon, 15 Apr 2019 22:46:44 +0000 (18:46 -0400)]
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>
6 years agotests: qemuxml2xml: Add DO_TEST_CAPS*
Cole Robinson [Mon, 15 Apr 2019 22:43:32 +0000 (18:43 -0400)]
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>
6 years agotests: qemuxml2xml: Set name in testQemuInfo
Cole Robinson [Mon, 15 Apr 2019 22:19:19 +0000 (18:19 -0400)]
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>
6 years agonetwork: use virNetDevTapReattachBridge API
Daniel P. Berrangé [Fri, 1 Feb 2019 13:46:33 +0000 (13:46 +0000)]
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>
6 years agoutil: add helper method for re-attaching a tap device to a bridge
Daniel P. Berrangé [Fri, 1 Feb 2019 12:39:25 +0000 (12:39 +0000)]
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>
6 years agonetwork: add missing bandwidth limits for bridge forward type
Daniel P. Berrangé [Tue, 20 Nov 2018 11:30:05 +0000 (11:30 +0000)]
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>
6 years agoconf: simplify link from hostdev back to network device
Daniel P. Berrangé [Thu, 26 Jul 2018 16:24:30 +0000 (17:24 +0100)]
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>
6 years agonetwork: drop back compat code loading actual bridge name
Daniel P. Berrangé [Tue, 2 Apr 2019 17:18:40 +0000 (18:18 +0100)]
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 a3609121799d44898a3e0d0bf92b755e55e7b418
  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>
6 years agonetwork: pass a virNetworkPtr to port management APIs
Daniel P. Berrangé [Thu, 26 Jul 2018 14:32:04 +0000 (15:32 +0100)]
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>
6 years agonetwork: restrict usage of port management APIs
Daniel P. Berrangé [Thu, 26 Jul 2018 10:37:32 +0000 (11:37 +0100)]
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>