]> git.ipfire.org Git - thirdparty/libvirt.git/log
thirdparty/libvirt.git
8 years agospec: Avoid RPM verification errors on nwfilter XMLs
Jiri Denemark [Wed, 12 Apr 2017 19:36:01 +0000 (21:36 +0200)] 
spec: Avoid RPM verification errors on nwfilter XMLs

/etc/libvirt/nwfilter/*.xml files are installed with no UUID, which
means libvirtd will automatically alter all of them once it starts. Thus
RPM verification will always fail on them. Let's use a trick similar to
the default network XML and store nwfilter XMLs in /usr/share. They will
be copied into /etc in %post. Additionally the /etc files are marked as
%ghost so that they are uninstalled if the RPM package is removed.

Note that the %post script overwrites existing files with new ones on
upgrade, which is what has always been happening.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agonetwork: Use consistent function name prefixes for virnetworkobj
John Ferlan [Wed, 8 Mar 2017 16:41:18 +0000 (11:41 -0500)] 
network: Use consistent function name prefixes for virnetworkobj

Use "virNetworkObj" as a prefix for any external API in virnetworkobj.

Also a couple of functions were local to virnetworkobj.c, so remove their
external defs in virnetworkobj.h.

8 years agonetwork: Rename virNetworkObjAssignDef to virNetworkObjUpdateAssignDef
John Ferlan [Wed, 8 Mar 2017 16:19:20 +0000 (11:19 -0500)] 
network: Rename virNetworkObjAssignDef to virNetworkObjUpdateAssignDef

Rename the API to be a better description of what it does. Besides, a
subsequent patch will rename virNetworkAssignDef to virNetworkObjAssignDef
so rather than make that patch confusing we'll take the intermittent step
in this patch.

8 years agonetwork: Alter coding style of network conf function prototypes
John Ferlan [Wed, 8 Mar 2017 15:52:18 +0000 (10:52 -0500)] 
network: Alter coding style of network conf function prototypes

In an effort to be consistent with the source module, alter the function
prototypes to follow the similar style of source with the "type" on one
line followed by the function name and arguments on subsequent lines with
with argument getting it's own line.

8 years agonetwork: Adjust coding style for network conf sources
John Ferlan [Wed, 8 Mar 2017 15:41:57 +0000 (10:41 -0500)] 
network: Adjust coding style for network conf sources

Alter the format of the code to follow more recent style guidelines of
two empty lines between functions, function decls with "[static] type"
on one line followed by function name with arguments to functions each
on one line.

8 years agonetwork: Introduce virnetworkobj
John Ferlan [Wed, 8 Mar 2017 15:25:24 +0000 (10:25 -0500)] 
network: Introduce virnetworkobj

Move all the virNetworkObj related API/data structures into their own
modules virnetworkobj.{c,h} from the network_conf.{c,h}

Purely code motion at this point plus adjustments to cleanly build

8 years agohyperv: recognize array property as distinct type.
Dawid Zamirski [Tue, 18 Apr 2017 14:56:20 +0000 (10:56 -0400)] 
hyperv: recognize array property as distinct type.

When hyperv code generator for WMI classes identifies common
properties, it needs to take into account array type as a distinct
type, i.e string != string[]. This is the case where v1 of the
Msvm_VirtualSystemSettingData has Notes property as string whereas v2
uses Notes[], therefore they have to be treated as different fields and
cannot be placed in the "common" struct.

8 years agoxenconfig: avoid double free on OOM testing
Jim Fehlig [Thu, 13 Apr 2017 16:39:52 +0000 (10:39 -0600)] 
xenconfig: avoid double free on OOM testing

Fix xlconfig channel tests when OOM testing is enabled.

TEST: xlconfigtest
32) Xen XL-2-XML Format channel-unix                                  ... OK
    Test OOM for nalloc=55 ................................................*** Error in `/home/jfehlig/virt/upstream/libvirt/tests/.libs/xlconfigtest': double free or corruption (fasttop): 0x0000000000679550 ***
...
(gdb) bt
#0  0x00007ffff36875af in raise () from /lib64/libc.so.6
#1  0x00007ffff36889aa in abort () from /lib64/libc.so.6
#2  0x00007ffff36c5150 in __libc_message () from /lib64/libc.so.6
#3  0x00007ffff36cb4f6 in malloc_printerr () from /lib64/libc.so.6
#4  0x00007ffff36cbcee in _int_free () from /lib64/libc.so.6
#5  0x00007ffff782babf in virFree (ptrptr=0x7fffffffdca8) at util/viralloc.c:582
#6  0x000000000042f2f3 in xenParseXLChannel (conf=0x677350, def=0x6815b0) at xenconfig/xen_xl.c:788
#7  0x000000000042f44e in xenParseXL (conf=0x677350, caps=0x6832b0, xmlopt=0x67f6e0) at xenconfig/xen_xl.c:828
#8  0x00000000004105a3 in testCompareFormatXML (
    xlcfg=0x6811e0 "/home/jfehlig/virt/upstream/libvirt/tests/xlconfigdata/test-channel-unix.cfg",
    xml=0x681110 "/home/jfehlig/virt/upstream/libvirt/tests/xlconfigdata/test-channel-unix.xml", replaceVars=false)
    at xlconfigtest.c:152

When a channel is successfully parsed and its path and name fields
assigned from local variables, set the local variables to NULL to
prevent a double free on error.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
8 years agotests: domaincapstest: add test for Q35 machine type
Pavel Hrdina [Thu, 13 Apr 2017 14:13:49 +0000 (16:13 +0200)] 
tests: domaincapstest: add test for Q35 machine type

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8 years agoqemu: report IDE bus in domain capabilities only if it's supported
Pavel Hrdina [Thu, 13 Apr 2017 13:29:16 +0000 (15:29 +0200)] 
qemu: report IDE bus in domain capabilities only if it's supported

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

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8 years agoqemu: use qemuDomainMachineIsPSeries
Pavel Hrdina [Thu, 13 Apr 2017 14:24:45 +0000 (16:24 +0200)] 
qemu: use qemuDomainMachineIsPSeries

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8 years agoqemu: refactor qemuDomainMachine* functions
Pavel Hrdina [Tue, 18 Apr 2017 10:43:58 +0000 (12:43 +0200)] 
qemu: refactor qemuDomainMachine* functions

Introduce new wrapper functions without *Machine* in the function
name that take the whole virDomainDef structure as argument and
call the existing functions with *Machine* in the function name.

Change the arguments of existing functions to *machine* and *arch*
because they don't need the whole virDomainDef structure and they
could be used in places where we don't have virDomainDef.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8 years agoqemu: migration: Skip cache=none check for disks which are storage-migrated
Peter Krempa [Fri, 7 Apr 2017 15:27:17 +0000 (17:27 +0200)] 
qemu: migration: Skip cache=none check for disks which are storage-migrated

Since the disks are copied by qemu, there's no need to enforce
cache=none. Thankfully the code that added qemuMigrateDisk did not break
existing configs, since if you don't select any disk to migrate
explicitly the code behaves sanely.

The logic for determining whether a disk should be migrated is
open-coded since using qemuMigrateDisk twice would be semantically
incorrect.

8 years agovz: support virDomainBlockResize
Konstantin Neumoin [Fri, 14 Apr 2017 14:53:53 +0000 (17:53 +0300)] 
vz: support virDomainBlockResize

Acked-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Signed-off-by: Konstantin Neumoin <kneumoin@virtuozzo.com>
8 years agovz: support virDomainSetVcpus
Konstantin Neumoin [Fri, 14 Apr 2017 14:53:52 +0000 (17:53 +0300)] 
vz: support virDomainSetVcpus

Acked-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Signed-off-by: Konstantin Neumoin <kneumoin@virtuozzo.com>
8 years agopci: recognize/report GEN4 (PCIe 4.0) card 16GT/s Link speed
Shivaprasad G Bhat [Wed, 1 Mar 2017 09:55:58 +0000 (03:55 -0600)] 
pci: recognize/report GEN4 (PCIe 4.0) card 16GT/s Link speed

Without this added enum value, nodedev-dumpxml of a GEN4 (PCIe 4.0)
card will fail (due to the unrecognized link speed), and since
nodedev-detach and nodedev-reattach internally do a dumpxml+parse,
they will also fail. With this patch, all those operations succeed.

Signed-off-by: Shivaprasad G Bhat <sbhat@linux.vnet.ibm.com>
8 years agoDrop autobuild.sh
Andrea Bolognani [Thu, 13 Apr 2017 14:37:22 +0000 (16:37 +0200)] 
Drop autobuild.sh

The Test-AutoBuild project, that this script is supposed to
be used with, hasn't seen any activity in ~6 years; libvirt's
own CI is running on Jenkins with a completely independent
setup that doesn't use the script at all.

8 years agoxenFormatXLDomainDisks: avoid double free on OOM testing
Wim ten Have [Mon, 27 Mar 2017 20:20:19 +0000 (22:20 +0200)] 
xenFormatXLDomainDisks: avoid double free on OOM testing

Fix xlconfigtest runs build for --enable-test-oom on
        Xen XL-2-XML Parse  new-disk

    #0  0x00007ffff3bd791f in raise () from /lib64/libc.so.6
    #1  0x00007ffff3bd951a in abort () from /lib64/libc.so.6
    #2  0x00007ffff3c1b200 in __libc_message () from /lib64/libc.so.6
    #3  0x00007ffff3c2488a in _int_free () from /lib64/libc.so.6
    #4  0x00007ffff3c282bc in free () from /lib64/libc.so.6
    #5  0x00007ffff7864fcb in virFree (ptrptr=ptrptr@entry=0x7fffffffd868) at util/viralloc.c:582
    #6  0x00007ffff78776e5 in virConfFreeValue (val=<optimized out>) at util/virconf.c:178
==> #7  0x0000000000425759 in xenFormatXLDomainDisks (def=0x7fffffffd8c0, def=0x7fffffffd8c0, conf=0x658220)
        at xenconfig/xen_xl.c:1159
    #8  xenFormatXL (def=def@entry=0x66ec20, conn=conn@entry=0x668cf0) at xenconfig/xen_xl.c:1558
    #9  0x000000000040ea1d in testCompareParseXML (replaceVars=<optimized out>,
        xml=0x65f5e0 "/home/wtenhave/WORK/libvirt/history/libvirt/tests/xlconfigdata/test-fullvirt-ovmf.xml",
        xlcfg=0x65f6b0 "/home/wtenhave/WORK/libvirt/history/libvirt/tests/xlconfigdata/test-fullvirt-ovmf.cfg")
        at xlconfigtest.c:105
    #10 testCompareHelper (data=<optimized out>) at xlconfigtest.c:205
    #11 0x000000000041079a in virTestRun (title=title@entry=0x431cf0 "Xen XL-2-XML Parse  fullvirt-ovmf",
        body=body@entry=0x40e720 <testCompareHelper>, data=data@entry=0x7fffffffda50) at testutils.c:247
    #12 0x000000000040ebc2 in mymain () at xlconfigtest.c:256
    #13 0x0000000000411070 in virTestMain (argc=1, argv=0x7fffffffdc08, func=0x40f2c0 <mymain>) at testutils.c:992
    #14 0x00007ffff3bc2401 in __libc_start_main () from /lib64/libc.so.6
    #15 0x000000000040e5da in _start ()

symmetry seems missing its sibbling coded functionality
demonstrated under functions;
        xenFormatXLUSBController()
        xenFormatXLUSB()
        xenFormatXLDomainChannels()
        xenFormatXMDisks

Signed-off-by: Wim ten Have <wim.ten.have@oracle.com>
8 years agovirConfSaveValue: protect against a NULL pointer reference
Wim ten Have [Mon, 27 Mar 2017 20:20:43 +0000 (22:20 +0200)] 
virConfSaveValue: protect against a NULL pointer reference

Fix xlconfigtest runs build for --enable-test-oom on
        Xen XL-2-XML Parse  channel-pty

Program received signal SIGSEGV, Segmentation fault.

    #0  0x00007ffff3c2b373 in __strchr_sse2 () from /lib64/libc.so.6
==> #1  0x00007ffff7875701 in virConfSaveValue (buf=buf@entry=0x7fffffffd8a0, val=val@entry=0x674750) at util/virconf.c:290
    #2  0x00007ffff7875668 in virConfSaveValue (buf=buf@entry=0x7fffffffd8a0, val=<optimized out>) at util/virconf.c:306
    #3  0x00007ffff78757ef in virConfSaveEntry (buf=buf@entry=0x7fffffffd8a0, cur=cur@entry=0x674780) at util/virconf.c:338
    #4  0x00007ffff78783eb in virConfWriteMem (memory=0x665570 "", len=len@entry=0x7fffffffd910, conf=conf@entry=0x65b940)
        at util/virconf.c:1543
    #5  0x000000000040eccb in testCompareParseXML (replaceVars=<optimized out>, xml=<optimized out>,
        xlcfg=0x662c00 "/home/wtenhave/WORK/libvirt/OOMtesting/libvirt-devel/tests/xlconfigdata/test-channel-pty.cfg")
        at xlconfigtest.c:108
    #6  testCompareHelper (data=<optimized out>) at xlconfigtest.c:205
    #7  0x0000000000410b3a in virTestRun (title=title@entry=0x432cc0 "Xen XL-2-XML Parse  channel-pty",
        body=body@entry=0x40e9b0 <testCompareHelper>, data=data@entry=0x7fffffffd9f0) at testutils.c:247
    #8  0x000000000040f322 in mymain () at xlconfigtest.c:278
    #9  0x0000000000411410 in virTestMain (argc=1, argv=0x7fffffffdba8, func=0x40f660 <mymain>) at testutils.c:992
    #10 0x00007ffff3bc0401 in __libc_start_main () from /lib64/libc.so.6
    #11 0x000000000040e86a in _start ()

    (gdb) frame 1
    #1  0x00007ffff7875701 in virConfSaveValue (buf=buf@entry=0x7fffffffd8a0, val=val@entry=0x674750) at util/virconf.c:290
    290                 if (strchr(val->str, '\n') != NULL) {
    (gdb) print *val
    $1 = {type = VIR_CONF_STRING, next = 0x0, l = 0, str = 0x0, list = 0x0}

Signed-off-by: Wim ten Have <wim.ten.have@oracle.com>
8 years agonwfilter: Introduce virNWFilterObjListExport
John Ferlan [Mon, 20 Mar 2017 11:08:46 +0000 (07:08 -0400)] 
nwfilter: Introduce virNWFilterObjListExport

Essentially code motion to move the ListExport function from nwfilter_driver
into virnwfilterobj

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agonwfilter: Introduce virNWFilterObjGetNames
John Ferlan [Sun, 19 Mar 2017 20:24:59 +0000 (16:24 -0400)] 
nwfilter: Introduce virNWFilterObjGetNames

Mostly code motion to move nwfilterConnectListNWFilters into nwfilterobj.c
and rename to virNWFilterObjGetNames.

Also includes a couple of variable name adjustments to keep code consistent
with other drivers.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agonwfilter: Introduce virNWFilterObjNumOfNWFilters
John Ferlan [Sun, 19 Mar 2017 12:20:25 +0000 (08:20 -0400)] 
nwfilter: Introduce virNWFilterObjNumOfNWFilters

Mostly code motion from nwfilter_driver to virnwfilterobj with one caveat
to add the virNWFilterObjListFilter typedef and pass it as an 'aclfilter'
argument to allow for future possible test driver adjustments to count
the number of filters (similar to how node device has done this).

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoconf: Add check for non scsi_host parent during vport delete
John Ferlan [Tue, 4 Apr 2017 18:06:42 +0000 (14:06 -0400)] 
conf: Add check for non scsi_host parent during vport delete

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

If the parent is not a scsi_host, then we can just happily return since
we won't be removing a vport.

Fixes a bug with the following output:

$ virsh pool-destroy host4_hba_pool
error: Failed to destroy pool host4_hba_pool
error: internal error: Invalid adapter name 'pci_0000_10_00_1' for SCSI pool

$

8 years agoconf: Check for storage conflicts across pool types
John Ferlan [Wed, 5 Apr 2017 13:04:54 +0000 (09:04 -0400)] 
conf: Check for storage conflicts across pool types

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

The virStoragePoolObjSourceFindDuplicate logic used by PoolCreateXML
and PoolDefineXML avoids comparing the new definition against "other"
pool types. This can cause unexpected corruption if two different pool
source types used the same source device path. For example, a 'disk'
pool using source type device=/dev/sdc could be unwittingly overwritten
by using /dev/sdc for a 'logical' pool which also uses the source
device path.

So rather than blindly ignoring those checks when def->type !=
pool->def->type - have the pool->def->type switch logic handle the
check for which def->type's should be checked.

8 years agoconf: Introduce virStoragePoolObjSourceMatchTypeDEVICE
John Ferlan [Wed, 5 Apr 2017 12:54:29 +0000 (08:54 -0400)] 
conf: Introduce virStoragePoolObjSourceMatchTypeDEVICE

Refactor virStoragePoolObjSourceFindDuplicate into smaller units
separated by the "supported" pool source type. The ISCSI, FS,
LOGICAL, DISK, and ZFS pools can use "<source>... <device='%s'/>...
</source>".

Alter the logic slightly to return the matching pool or NULL rather
than setting matchpool = pool and break.  Easier to read that way.

8 years agoconf: Introduce virStoragePoolObjSourceMatchTypeISCSI
John Ferlan [Wed, 5 Apr 2017 12:40:10 +0000 (08:40 -0400)] 
conf: Introduce virStoragePoolObjSourceMatchTypeISCSI

In the effort to reduce the virStoragePoolObjSourceFindDuplicate logic,
create a new helper which will handle all the ISCSI type differences.

Alter things just a little bit to return NULL or pool rather than
using breaks and matchpool = pool, then break. Also rather than creating
variables withing the if...else if... conditions, have them all at the
top of the function to make things a bit easier to read.

8 years agoconf: Introduce virStoragePoolObjSourceMatchTypeDIR
John Ferlan [Wed, 5 Apr 2017 12:14:49 +0000 (08:14 -0400)] 
conf: Introduce virStoragePoolObjSourceMatchTypeDIR

Refactor virStoragePoolObjSourceFindDuplicate into smaller units
separated by the "supported" pool source type. The DIR, GLUSTER,
and NETFS pools all can use "<source>... <dir='%s'/>... </source>".

Alter the logic slightly to return the matching pool or NULL rather
than setting matchpool = pool and break.  Easier to read that way.

8 years agoqemu: refactor qemuBuildIOMMUCommandLine
Ján Tomko [Tue, 21 Mar 2017 09:27:34 +0000 (10:27 +0100)] 
qemu: refactor qemuBuildIOMMUCommandLine

Introduce a separate buffer for options and use a helper
variable for def->iommu.

8 years agoqemu: allow conditional device property probing
Ján Tomko [Mon, 20 Mar 2017 15:08:48 +0000 (16:08 +0100)] 
qemu: allow conditional device property probing

Do not probe for devices that QEMU does not know
when probing for device options.

8 years agoSplit out virDomainIOMMUDefFormat
Ján Tomko [Mon, 20 Mar 2017 09:25:34 +0000 (10:25 +0100)] 
Split out virDomainIOMMUDefFormat

Make adding subelements easier.

8 years agoutil: Fix resource leak
Wang King [Wed, 12 Apr 2017 08:44:04 +0000 (16:44 +0800)] 
util: Fix resource leak

The virRotatingFileWriterAppend method leaks the file->entry
on the virRotatingFileWriterEntryNew failing path.

8 years agotools: remove unused assignment statement in virshStorageVolListCollect
Wang King [Thu, 13 Apr 2017 02:16:27 +0000 (10:16 +0800)] 
tools: remove unused assignment statement in virshStorageVolListCollect

Assigning value true to @success if there is no volumes, that stored value is not used.

8 years agotest: Remove unused variate @maxcpu in testDomainGetVcpus
Wang King [Thu, 13 Apr 2017 02:16:07 +0000 (10:16 +0800)] 
test: Remove unused variate @maxcpu in testDomainGetVcpus

Since refactoring by commit id '3dd859c0', @maxcpu is no longer used.

8 years agoesx: Fix memory leak
Wang King [Wed, 12 Apr 2017 10:06:44 +0000 (18:06 +0800)] 
esx: Fix memory leak

Variable def going out of scope leaks the storage def.source.hosts points to.

8 years agoesx: Fix incorrect memory compare size in esxStoragePoolLookupByUUID
Wang King [Thu, 13 Apr 2017 02:15:45 +0000 (10:15 +0800)] 
esx: Fix incorrect memory compare size in esxStoragePoolLookupByUUID

Use MD5_DIGEST_SIZE or VIR_UUID_BUFLEN rather than VIR_UUID_STRING_BUFLEN
when compare @uuid with @md5.

8 years agoconf: remove unused assignment statement in virSysinfoBaseBoardParseXML
Wang King [Thu, 13 Apr 2017 02:16:43 +0000 (10:16 +0800)] 
conf: remove unused assignment statement in virSysinfoBaseBoardParseXML

Assigning value 0 to @nboards in success path, that stored value is not used.

8 years agoutil: add missing equal sign in initialization
Ján Tomko [Thu, 13 Apr 2017 12:02:46 +0000 (14:02 +0200)] 
util: add missing equal sign in initialization

Fix the build with clang:
util/virperf.c:86:27: error: use of GNU 'missing =' extension
    in designator [-Werror,-Wgnu-designator]
    [VIR_PERF_EVENT_MBML] {
                          ^
                          =

8 years agoqemu: migration: Reject migration of an empty disk
Peter Krempa [Fri, 7 Apr 2017 15:39:39 +0000 (17:39 +0200)] 
qemu: migration: Reject migration of an empty disk

If you specify disks to migrate it would be possible to select an empty
drive for migration. Reject such config.

8 years agoqemu: migration: Use virStorageSourceIsEmpty in qemuMigrateDisk
Peter Krempa [Fri, 7 Apr 2017 15:38:36 +0000 (17:38 +0200)] 
qemu: migration: Use virStorageSourceIsEmpty in qemuMigrateDisk

Use the proper check whether a disk is empty.

8 years agoqemu: snapshot: Skip empty drives with internal snapshots
Peter Krempa [Fri, 7 Apr 2017 14:56:49 +0000 (16:56 +0200)] 
qemu: snapshot: Skip empty drives with internal snapshots

The code that validates whether an internal snapshot is possible would
reject an empty but not-readonly drive. Since floppies can have this
property, add a check for emptiness.

8 years agoconf: Keep 'readonly' property when resetting disk source
Peter Krempa [Fri, 7 Apr 2017 11:44:54 +0000 (13:44 +0200)] 
conf: Keep 'readonly' property when resetting disk source

The property is necessary also for the disk using the source (e.g. cdrom)
which needs to be kept readonly.

Commit '462c4b66' was a bit too aggressive in this aspect, since the
readonly flag is set only while parsing.

8 years agoqemu: do not crash on USB address with no port and invalid bus
Ján Tomko [Wed, 12 Apr 2017 10:40:57 +0000 (12:40 +0200)] 
qemu: do not crash on USB address with no port and invalid bus

Properly error out when the user requests a port from a bus
that does not have a controller present in the domain XML.

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

8 years agotest: virsh-optparse: Fix expected test output with new error checking
Peter Krempa [Thu, 13 Apr 2017 08:10:00 +0000 (10:10 +0200)] 
test: virsh-optparse: Fix expected test output with new error checking

Commit 4f4c3b1397c4b5d16af added code to remember errors during freeing
of domain objects. This changed the output when testing scaled numbers
parsing in virsh-optparse. Adjust the expected output.

8 years agoperf: get rid of pointless virPerfGetEvent() method
Daniel P. Berrange [Fri, 16 Dec 2016 10:58:29 +0000 (10:58 +0000)] 
perf: get rid of pointless virPerfGetEvent() method

The virPerfGetEvent method pointlessly checks for a NULL
parameter and the range of an enum value. The whole point
of using an enum is that we can avoid such checks. Just
replace calls to virPerfGetEvent, with perf->events[type]
array access.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
8 years agoperf: get rid of pointless virPerfGetEventAttr() method
Daniel P. Berrange [Fri, 16 Dec 2016 10:54:38 +0000 (10:54 +0000)] 
perf: get rid of pointless virPerfGetEventAttr() method

The virPerfGetEventAttr method contains a totally pointless
loop. Remove it, verify the array size statically, and then
just use an array index to access the perf event.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
8 years agoman: Align vol-resize arguments with the output of help
Martin Kletzander [Wed, 12 Apr 2017 06:43:49 +0000 (08:43 +0200)] 
man: Align vol-resize arguments with the output of help

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
8 years agoqemu: conf: Don't leak 'namespaces' temporary variable while parsing config
Peter Krempa [Wed, 12 Apr 2017 12:54:36 +0000 (14:54 +0200)] 
qemu: conf: Don't leak 'namespaces' temporary variable while parsing config

==20406== 8 bytes in 1 blocks are definitely lost in loss record 24 of 1,059
==20406==    at 0x4C2CF55: calloc (vg_replace_malloc.c:711)
==20406==    by 0x54BF530: virAllocN (viralloc.c:191)
==20406==    by 0x54D37C4: virConfGetValueStringList (virconf.c:1001)
==20406==    by 0x144E4E8E: virQEMUDriverConfigLoadFile (qemu_conf.c:835)
==20406==    by 0x1452A744: qemuStateInitialize (qemu_driver.c:664)
==20406==    by 0x55DB585: virStateInitialize (libvirt.c:770)
==20406==    by 0x124570: daemonRunStateInit (libvirtd.c:881)
==20406==    by 0x5532990: virThreadHelper (virthread.c:206)
==20406==    by 0x8C82493: start_thread (in /lib64/libpthread-2.24.so)
==20406==    by 0x8F7FA1E: clone (in /lib64/libc-2.24.so)

8 years agoqemu: conf: Don't leak snapshot image format conf variable
Peter Krempa [Wed, 12 Apr 2017 12:54:04 +0000 (14:54 +0200)] 
qemu: conf: Don't leak snapshot image format conf variable

==20406== 4 bytes in 1 blocks are definitely lost in loss record 6 of 1,059
==20406==    at 0x4C2AF3F: malloc (vg_replace_malloc.c:299)
==20406==    by 0x8F17D39: strdup (in /lib64/libc-2.24.so)
==20406==    by 0x552C0E0: virStrdup (virstring.c:784)
==20406==    by 0x54D3622: virConfGetValueString (virconf.c:945)
==20406==    by 0x144E4692: virQEMUDriverConfigLoadFile (qemu_conf.c:687)
==20406==    by 0x1452A744: qemuStateInitialize (qemu_driver.c:664)
==20406==    by 0x55DB585: virStateInitialize (libvirt.c:770)
==20406==    by 0x124570: daemonRunStateInit (libvirtd.c:881)
==20406==    by 0x5532990: virThreadHelper (virthread.c:206)
==20406==    by 0x8C82493: start_thread (in /lib64/libpthread-2.24.so)
==20406==    by 0x8F7FA1E: clone (in /lib64/libc-2.24.so)

8 years agovirsh-domain: Refactor cmdTTYConsole
Peter Krempa [Tue, 11 Apr 2017 14:55:31 +0000 (16:55 +0200)] 
virsh-domain: Refactor cmdTTYConsole

Use the new XML helpers and use virXPathString rather than hand-rolling
the code.

8 years agovirsh-domain: Use the virsh wrappers for getting XML to simplify code
Peter Krempa [Tue, 11 Apr 2017 15:33:53 +0000 (17:33 +0200)] 
virsh-domain: Use the virsh wrappers for getting XML to simplify code

Reuse virshDomainGetXML and virshDomainGetXMLFromDom.

8 years agovirsh-domain-monitor: Use the virsh wrappers for getting XML to simplify code
Peter Krempa [Tue, 11 Apr 2017 15:33:53 +0000 (17:33 +0200)] 
virsh-domain-monitor: Use the virsh wrappers for getting XML to simplify code

Reuse virshDomainGetXML and virshDomainGetXMLFromDom.

8 years agovirsh: add helpers for getting domain XML for XPath purposes
Peter Krempa [Tue, 11 Apr 2017 14:51:32 +0000 (16:51 +0200)] 
virsh: add helpers for getting domain XML for XPath purposes

In virsh we quite often get the domain XML just to initialize the XPath
parser so that we can extract information.

Add helpers which will simplify this by wrapping the getting of the XML
and parsing it along with error reporting.

Additionally a second helper also gets the domain object from the
parameters and releases it so that functions which need the XML as only
source of data can be simplified further.

8 years agovsh: Add helper for safe remembering of libvirt errors
Peter Krempa [Tue, 11 Apr 2017 15:23:23 +0000 (17:23 +0200)] 
vsh: Add helper for safe remembering of libvirt errors

Avoid the annoying issue where the public object freeing APIs overwrite
the error set by helper functions, since they don't invoke the callback.

The new helper remembers the error only if no previous error was set.

8 years agovirsh: Add wrapper for virDomainSnapshotFree
Peter Krempa [Tue, 11 Apr 2017 15:21:05 +0000 (17:21 +0200)] 
virsh: Add wrapper for virDomainSnapshotFree

Similarly to virshDomainFree add a wrapper for the snapshot object
freeing function.

8 years agovirsh-util: Add wrapper for virDomainFree
Peter Krempa [Tue, 11 Apr 2017 10:16:52 +0000 (12:16 +0200)] 
virsh-util: Add wrapper for virDomainFree

virDomainFree has it's quirks (does not like NULL pointers, resets
libvirt errors). Replace it by a virsh helper which will allow us to
centrally fix issues with it.

The syntax-check rule will prohibit new uses of virDomainFree.

8 years agovirsh-util: Move domain lookup helpers into virsh-util
Peter Krempa [Tue, 11 Apr 2017 08:18:06 +0000 (10:18 +0200)] 
virsh-util: Move domain lookup helpers into virsh-util

Move virshLookupDomainBy, virshCommandOptDomainBy and
virshCommandOptDomainBy to the helper file. Additionally turn the
virshCommandOptDomainBy macro into a function.

8 years agovirsh: Add new file for utility functions and move a few
Peter Krempa [Mon, 10 Apr 2017 15:06:15 +0000 (17:06 +0200)] 
virsh: Add new file for utility functions and move a few

Don't accumulate helpers in virsh.c

8 years agoqemu: Fix mdev checking for VFIO support
Erik Skultety [Wed, 12 Apr 2017 08:46:35 +0000 (10:46 +0200)] 
qemu: Fix mdev checking for VFIO support

Commit a4a39d90 added a check that checks for VFIO support with mediated
devices. The problem is that the hostdev preparing functions behave like
a fallthrough if device of that specific type doesn't exist. However,
the check for VFIO support was independent of the existence of a mdev
device which caused the guest to fail to start with any device to be
directly assigned if VFIO was disabled/unavailable in the kernel.
The proposed change first ensures that it makes sense to check for VFIO
support in the first place, and only then performs the VFIO support check
itself.

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

Signed-off-by: Erik Skultety <eskultet@redhat.com>
8 years agoutil: systemd: Don't strlen a possibly NULL string
Wang King [Wed, 12 Apr 2017 08:22:57 +0000 (16:22 +0800)] 
util: systemd: Don't strlen a possibly NULL string

Coverity complains about virBufferCurrentContent might be return null
when calling strlen, so check virBufferError first before calling
strlen.

8 years agointerface: Fix resource leak in netcfConnectListAllInterfaces error path
Wang King [Wed, 12 Apr 2017 07:58:23 +0000 (15:58 +0800)] 
interface: Fix resource leak in netcfConnectListAllInterfaces error path

On virGetInterface failure, call virInterfaceDefFree for the @def.

8 years agovirsh: don't leak @cpumap in virshVcpuPinQuery
Wang King [Wed, 12 Apr 2017 07:36:09 +0000 (15:36 +0800)] 
virsh: don't leak @cpumap in virshVcpuPinQuery

==18591== 16 bytes in 1 blocks are definitely lost in loss record 41 of 183
==18591==    at 0x4C2B934: calloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==18591==    by 0x54EBB1C: virAllocN (viralloc.c:191)
==18591==    by 0x1628CA: _vshMalloc (vsh.c:136)
==18591==    by 0x1344C4: virshVcpuPinQuery (virsh-domain.c:6603)
==18591==    by 0x1344C4: cmdVcpuPin (virsh-domain.c:6707)
==18591==    by 0x1631BF: vshCommandRun (vsh.c:1312)
==18591==    by 0x12DBB1: main (virsh.c:961)

8 years agostorage: Create helpers to perform FindByUUID and FindByName
John Ferlan [Tue, 21 Mar 2017 14:53:23 +0000 (10:53 -0400)] 
storage: Create helpers to perform FindByUUID and FindByName

Create a couple of helpers that will perform the same call sequence.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agostorage: Pass driver arg by ref
John Ferlan [Tue, 21 Mar 2017 14:07:46 +0000 (10:07 -0400)] 
storage: Pass driver arg by ref

Alter virStoragePoolObjListExport in order to pass the drivers->pools
by reference

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agostorage: Introduce virStoragePoolObjGetNames
John Ferlan [Tue, 21 Mar 2017 13:15:18 +0000 (09:15 -0400)] 
storage: Introduce virStoragePoolObjGetNames

Mostly code motion to move storageConnectList[Defined]StoragePools
and similar test driver code into virstorageobj.c and rename to
virStoragePoolObjGetNames.

Also includes a couple of variable name adjustments to keep code consistent
with other drivers.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agostorage: Introduce virStoragePoolObjNumOfStoragePools
John Ferlan [Tue, 21 Mar 2017 10:30:46 +0000 (06:30 -0400)] 
storage: Introduce virStoragePoolObjNumOfStoragePools

Unify the NumOf[Defined]StoragePools API into virstorageobj.c from
storage_driver and test_driver.  The only real difference between the
two is the test driver doesn't call using the aclfilter API.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agostorage: Introduce virStoragePoolObjVolumeListExport
John Ferlan [Mon, 20 Mar 2017 17:48:47 +0000 (13:48 -0400)] 
storage: Introduce virStoragePoolObjVolumeListExport

Essentially code motion to move the storage/test driver ListAllVolumes
logic into virstorageobj.c

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agostorage: Introduce virStoragePoolObjVolumeGetNames
John Ferlan [Mon, 20 Mar 2017 16:16:26 +0000 (12:16 -0400)] 
storage: Introduce virStoragePoolObjVolumeGetNames

Mostly code motion to move storagePoolListVolumes code into virstorageobj.c
and rename to virStoragePoolObjVolumeGetNames.

Also includes a couple of variable name adjustments to keep code consistent
with other drivers.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agostorage: Introduce virStoragePoolObjNumOfVolumes
John Ferlan [Mon, 20 Mar 2017 14:13:27 +0000 (10:13 -0400)] 
storage: Introduce virStoragePoolObjNumOfVolumes

Unify the NumOfVolumes API into virstorageobj.c from storage_driver and
test_driver.  The only real difference between the two is the test driver
doesn't call using the aclfilter API.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agotests/testutilsqemu: properly initialize qemu caps for tests
Pavel Hrdina [Tue, 11 Apr 2017 12:02:06 +0000 (14:02 +0200)] 
tests/testutilsqemu: properly initialize qemu caps for tests

This removes the hacky extern global variable and modifies the
test code to properly create QEMU capabilities cache for QEMU
binaries used in our tests.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8 years agotests: unify qemu binary paths for all qemu related tests
Pavel Hrdina [Thu, 6 Apr 2017 16:19:48 +0000 (18:19 +0200)] 
tests: unify qemu binary paths for all qemu related tests

Our test data used a lot of different qemu binary paths and some
of them were based on downstream systems.

Note that there is one file where I had to add "accel=kvm" because
the qemuargv2xml code parses "/usr/bin/kvm" as virt type="kvm".

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8 years agotests: don't use different QEMU binary paths for different virt types
Pavel Hrdina [Thu, 6 Apr 2017 16:33:52 +0000 (18:33 +0200)] 
tests: don't use different QEMU binary paths for different virt types

The virt type for QEMU can be modified by -machine attribute "accel"
so there is no need to have different QEMU binary paths.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8 years agotests/testutilsqemu: introduce QEMUBinList with all qemu binaries for tests
Pavel Hrdina [Tue, 20 Dec 2016 09:10:05 +0000 (10:10 +0100)] 
tests/testutilsqemu: introduce QEMUBinList with all qemu binaries for tests

Let's group all the binaries that we use in our test suite to one array.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8 years agotests/testutilsqemu: extract guest creation into separate functions
Pavel Hrdina [Mon, 19 Dec 2016 22:52:33 +0000 (23:52 +0100)] 
tests/testutilsqemu: extract guest creation into separate functions

All other architectures have separate functions to prepare guest
capabilities, do the same for i686 and x86_64 as well.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8 years agotests: use global virQEMUDriver
Pavel Hrdina [Mon, 19 Dec 2016 22:35:02 +0000 (23:35 +0100)] 
tests: use global virQEMUDriver

Most tests already use global driver variable that is initialized
before any test case is executed, convert these remaining tests to
the same concept.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8 years agotests/qemuxml2xmltest: remove NOP call of virQEMUCapsSetList
Pavel Hrdina [Mon, 19 Dec 2016 22:26:10 +0000 (23:26 +0100)] 
tests/qemuxml2xmltest: remove NOP call of virQEMUCapsSetList

Commit 5572cd7f0e9e deprecated QEMU_CAPS_DEVICE capability but forgot
to remove this call as well.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8 years agotests/qemuxml2argvtest: remove unnecessary machine canonicalization
Pavel Hrdina [Mon, 19 Dec 2016 21:52:08 +0000 (22:52 +0100)] 
tests/qemuxml2argvtest: remove unnecessary machine canonicalization

This is not required to run our tests.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8 years agotests: fix some resource leaks
Pavel Hrdina [Sun, 9 Apr 2017 11:28:07 +0000 (13:28 +0200)] 
tests: fix some resource leaks

Found by running valgrind for these tests.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8 years agorpc: fix resource leak
Pavel Hrdina [Sun, 9 Apr 2017 10:55:09 +0000 (12:55 +0200)] 
rpc: fix resource leak

Commit 252610f7dd1 switched to use hash to store servers.
Function virHashGetItems returns allocated array which needs
to be freed also for successful path, not only if there is
an error.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8 years agosrc: fix multiple resource leaks in loops
Pavel Hrdina [Sun, 9 Apr 2017 10:49:24 +0000 (12:49 +0200)] 
src: fix multiple resource leaks in loops

All of the variables are filled inside a loop and therefore
needs to be also freed in every cycle.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8 years agoconf/domain_capabilities: fix resource leak
Pavel Hrdina [Sun, 9 Apr 2017 10:43:45 +0000 (12:43 +0200)] 
conf/domain_capabilities: fix resource leak

Commit 14319c81a0 introduced CPU host model in domain capabilities
and the *hostmodel* variable is always filled by virCPUDefCopy()
and needs to be freed.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8 years agonodedev: Fix aclfilter check
John Ferlan [Mon, 10 Apr 2017 17:45:27 +0000 (13:45 -0400)] 
nodedev: Fix aclfilter check

For both virNodeDeviceObjNumOfDevices and virNodeDeviceObjGetNames, the
check should be if the aclfilter doesn't exist or if it does exist, then
it must pass

8 years agoconf: Fix virNodeDeviceObjGetNames nnames increment
John Ferlan [Mon, 10 Apr 2017 12:33:08 +0000 (08:33 -0400)] 
conf: Fix virNodeDeviceObjGetNames nnames increment

To be safer, only increment nnames after the VIR_STRDUP is successful.

8 years agorefactoring: Use the return value of virObjectRef directly
Marc Hartmayer [Mon, 3 Apr 2017 08:24:39 +0000 (10:24 +0200)] 
refactoring: Use the return value of virObjectRef directly

Use the return value of virObjectRef directly. This way, it's easier
for another reader to identify the reason why the additional reference
is required.

Signed-off-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.vnet.ibm.com>
8 years agoqemu: remove ATTRIBUTE_UNUSED in qemuProcessHandleMonitorEOF
Marc Hartmayer [Mon, 3 Apr 2017 08:24:38 +0000 (10:24 +0200)] 
qemu: remove ATTRIBUTE_UNUSED in qemuProcessHandleMonitorEOF

This attribute is not needed here, since @mon is in use.

Signed-off-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.vnet.ibm.com>
8 years agoqemu: Implement qemuMonitorRegister()
Marc Hartmayer [Mon, 3 Apr 2017 08:24:37 +0000 (10:24 +0200)] 
qemu: Implement qemuMonitorRegister()

Implement qemuMonitorRegister() as there is already a
qemuMonitorUnregister() function. This way it may be easier to
understand the code paths.

Signed-off-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.vnet.ibm.com>
8 years agoqemu: Turn qemuDomainLogContext into virObject
Marc Hartmayer [Mon, 3 Apr 2017 08:24:36 +0000 (10:24 +0200)] 
qemu: Turn qemuDomainLogContext into virObject

This way qemuDomainLogContextRef() and qemuDomainLogContextFree() is
no longer needed. The naming qemuDomainLogContextFree() was also
somewhat misleading. Additionally, it's easier to turn
qemuDomainLogContext in a self-locking object.

Signed-off-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.vnet.ibm.com>
8 years agoqemu: Fix two use-after-free situations
Marc Hartmayer [Mon, 3 Apr 2017 08:24:35 +0000 (10:24 +0200)] 
qemu: Fix two use-after-free situations

There were multiple race conditions that could lead to segmentation
faults. The first precondition for this is qemuProcessLaunch must fail
sometime shortly after starting the new QEMU process. The second
precondition for the segmentation faults is that the new QEMU process
dies - or to be more precise the QEMU monitor has to be closed
irregularly. If both happens during qemuProcessStart (starting a
domain) there are race windows between the thread with the event
loop (T1) and the thread that is starting the domain (T2).

First segmentation fault scenario:
If qemuProcessLaunch fails during qemuProcessStart the code branches
to the 'stop' path where 'qemuMonitorSetDomainLog(priv->mon, NULL,
NULL, NULL)' will set the log function of the monitor to NULL (done in
T2). In the meantime the event loop of T1 will wake up with an EOF
event for the QEMU monitor because the QEMU process has died. The
crash occurs if T1 has checked 'mon->logFunc != NULL' in qemuMonitorIO
just before the logFunc was set to NULL by T2. If this situation
occurs T1 will try to call mon->logFunc which leads to the
segmentation fault.

Solution:
Require the monitor lock for setting the log function.

Backtrace:
0  0x0000000000000000 in ?? ()
1  0x000003ffe9e45316 in qemuMonitorIO (watch=<optimized out>,
fd=<optimized out>, events=<optimized out>, opaque=0x3ffe08aa860) at
../../src/qemu/qemu_monitor.c:727
2  0x000003fffda2e1a4 in virEventPollDispatchHandles (nfds=<optimized
out>, fds=0x2aa000fd980) at ../../src/util/vireventpoll.c:508
3  0x000003fffda2e398 in virEventPollRunOnce () at
../../src/util/vireventpoll.c:657
4  0x000003fffda2ca10 in virEventRunDefaultImpl () at
../../src/util/virevent.c:314
5  0x000003fffdba9366 in virNetDaemonRun (dmn=0x2aa000cc550) at
../../src/rpc/virnetdaemon.c:818
6  0x000002aa00024668 in main (argc=<optimized out>, argv=<optimized
out>) at ../../daemon/libvirtd.c:1541

Second segmentation fault scenario:
If qemuProcessLaunch fails it will unref the log context and with
invoking qemuMonitorSetDomainLog(priv->mon, NULL, NULL, NULL)
qemuDomainLogContextFree() will be invoked. qemuDomainLogContextFree()
invokes virNetClientClose() to close the client and cleans everything
up (including unref of _virLogManager.client) when virNetClientClose()
returns. When T1 is now trying to report 'qemu unexpectedly closed the
monitor' libvirtd will crash because the client has already been
freed.

Solution:
As the critical section in qemuMonitorIO is protected with the monitor
lock we can use the same solution as proposed for the first
segmentation fault.

Backtrace:
0  virClassIsDerivedFrom (klass=0x3100979797979797,
parent=0x2aa000d92f0) at ../../src/util/virobject.c:169
1  0x000003fffda659e6 in virObjectIsClass (anyobj=<optimized out>,
klass=<optimized out>) at ../../src/util/virobject.c:365
2  0x000003fffda65a24 in virObjectLock (anyobj=0x3ffe08c1db0) at
../../src/util/virobject.c:317
3  0x000003fffdba4688 in
virNetClientIOEventLoop (client=client@entry=0x3ffe08c1db0,
thiscall=thiscall@entry=0x2aa000fbfa0) at
../../src/rpc/virnetclient.c:1668
4  0x000003fffdba4b4c in
virNetClientIO (client=client@entry=0x3ffe08c1db0,
thiscall=0x2aa000fbfa0) at ../../src/rpc/virnetclient.c:1944
5  0x000003fffdba4d42 in
virNetClientSendInternal (client=client@entry=0x3ffe08c1db0,
msg=msg@entry=0x2aa000cc710, expectReply=expectReply@entry=true,
nonBlock=nonBlock@entry=false) at ../../src/rpc/virnetclient.c:2116
6  0x000003fffdba6268 in
virNetClientSendWithReply (client=0x3ffe08c1db0, msg=0x2aa000cc710) at
../../src/rpc/virnetclient.c:2144
7  0x000003fffdba6e8e in virNetClientProgramCall (prog=0x3ffe08c1120,
client=<optimized out>, serial=<optimized out>, proc=<optimized out>,
noutfds=<optimized out>, outfds=0x0, ninfds=0x0, infds=0x0,
args_filter=0x3fffdb64440
<xdr_virLogManagerProtocolDomainReadLogFileArgs>, args=0x3ffffffe010,
ret_filter=0x3fffdb644c0
<xdr_virLogManagerProtocolDomainReadLogFileRet>, ret=0x3ffffffe008) at
../../src/rpc/virnetclientprogram.c:329
8  0x000003fffdb64042 in
virLogManagerDomainReadLogFile (mgr=<optimized out>, path=<optimized
out>, inode=<optimized out>, offset=<optimized out>, maxlen=<optimized
out>, flags=0) at ../../src/logging/log_manager.c:272
9  0x000003ffe9e0315c in qemuDomainLogContextRead (ctxt=0x3ffe08c2980,
msg=0x3ffffffe1c0) at ../../src/qemu/qemu_domain.c:4422
10 0x000003ffe9e280a8 in qemuProcessReadLog (logCtxt=<optimized out>,
msg=msg@entry=0x3ffffffe288) at ../../src/qemu/qemu_process.c:1800
11 0x000003ffe9e28206 in qemuProcessReportLogError (logCtxt=<optimized
out>, msgprefix=0x3ffe9ec276a "qemu unexpectedly closed the monitor")
at ../../src/qemu/qemu_process.c:1836
12 0x000003ffe9e28306 in
qemuProcessMonitorReportLogError (mon=mon@entry=0x3ffe085cf10,
msg=<optimized out>, opaque=<optimized out>) at
../../src/qemu/qemu_process.c:1856
13 0x000003ffe9e452b6 in qemuMonitorIO (watch=<optimized out>,
fd=<optimized out>, events=<optimized out>, opaque=0x3ffe085cf10) at
../../src/qemu/qemu_monitor.c:726
14 0x000003fffda2e1a4 in virEventPollDispatchHandles (nfds=<optimized
out>, fds=0x2aa000fd980) at ../../src/util/vireventpoll.c:508
15 0x000003fffda2e398 in virEventPollRunOnce () at
../../src/util/vireventpoll.c:657
16 0x000003fffda2ca10 in virEventRunDefaultImpl () at
../../src/util/virevent.c:314
17 0x000003fffdba9366 in virNetDaemonRun (dmn=0x2aa000cc550) at
../../src/rpc/virnetdaemon.c:818
18 0x000002aa00024668 in main (argc=<optimized out>, argv=<optimized
out>) at ../../daemon/libvirtd.c:1541

Other code parts where the same problem was possible to occur are
fixed as well (qemuMigrationFinish, qemuProcessStart, and
qemuDomainSaveImageStartVM).

Signed-off-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
Reported-by: Sascha Silbe <silbe@linux.vnet.ibm.com>
8 years agonodedev: Pass driver arg by ref
John Ferlan [Mon, 20 Mar 2017 11:28:30 +0000 (07:28 -0400)] 
nodedev: Pass driver arg by ref

Alter virNodeDeviceObjListExport in order to pass the drivers->devs
by reference

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agonodedev: Introduce virNodeDeviceObjGetNames
John Ferlan [Sun, 19 Mar 2017 19:51:03 +0000 (15:51 -0400)] 
nodedev: Introduce virNodeDeviceObjGetNames

Unify the *ListDevice API into virnodedeviceobj.c from node_device_driver
and test_driver.  The only real difference between the two is that the test
driver doesn't call the aclfilter API. The name of the new API follows that
of other drivers to "GetNames".

NB: Change some variable names to match what they really are - consistency
with other drivers. Also added a clear of the input names.

This also allows virNodeDeviceObjHasCap to be static to virnodedeviceobj

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agonodedev: Introduce virNodeDeviceObjNumOfDevices
John Ferlan [Sun, 19 Mar 2017 11:49:38 +0000 (07:49 -0400)] 
nodedev: Introduce virNodeDeviceObjNumOfDevices

Unify the NumOfDevices API into virnodedeviceobj.c from node_device_driver
and test_driver.  The only real difference between the two is that the test
driver doesn't call the aclfilter API.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agointerface: Clean up Interface section of test_driver
John Ferlan [Thu, 6 Apr 2017 13:46:43 +0000 (09:46 -0400)] 
interface: Clean up Interface section of test_driver

Clean up the code to adhere to more of the standard two spaces between
functions, separate lines for type and function name, one argument per line.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agointerface: Introduce virInterfaceObjGetNames
John Ferlan [Thu, 6 Apr 2017 13:37:57 +0000 (09:37 -0400)] 
interface: Introduce virInterfaceObjGetNames

Unlike other drivers, this is a test driver only API. Still combining
the logic of testConnectListInterfaces and testConnectListDefinedInterfaces
makes things a bit easier in the long run.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agointerface: Introduce virInterfaceObjNumOfInterfaces
John Ferlan [Thu, 6 Apr 2017 13:23:17 +0000 (09:23 -0400)] 
interface: Introduce virInterfaceObjNumOfInterfaces

Unlike other drivers, this is a test driver only API. Still combining
the logic of testConnectNumOfInterfaces and testConnectNumOfDefinedInterfaces
makes things a bit easier in the long run.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agonews: update for Hyper-V 2012+ support.
Dawid Zamirski [Tue, 4 Apr 2017 22:26:16 +0000 (18:26 -0400)] 
news: update for Hyper-V 2012+ support.

8 years agohyperv: update driver documentation.
Dawid Zamirski [Tue, 4 Apr 2017 22:26:15 +0000 (18:26 -0400)] 
hyperv: update driver documentation.

8 years agohyperv: add support for Hyper-V 2012 and newer
Dawid Zamirski [Tue, 4 Apr 2017 22:26:08 +0000 (18:26 -0400)] 
hyperv: add support for Hyper-V 2012 and newer

This patch reworks the Hyper-V driver structs and the code generator
to provide seamless support for both Hyper-V 2008 and 2012 or newer.
This does not implement any new libvirt APIs, it just adapts existing
2008-only driver to also handle 2012 and newer by sharing as much
driver code as possible (currently it's all of it :-)). This is needed
to set the foundation before we can move forward with implementing the
rest of the driver APIs.

With the 2012 release, Microsoft introduced "v2" version of Msvm_* WMI
classes. Those are largely the same as "v1" (used in 2008) but have some
new properties as well as need different wsman request URIs. To
accomodate those differences, most of work went into the code generator
so that it's "aware" of possibility of multiple versions of the same WMI
class and produce C code accordingly.

To accomplish this the following changes were made:

 * the abstract hypervObject struct's data member was changed to a union
   that has "common", "v1" and "v2" members. Those are structs that
   represent WMI classes that we get back from wsman response. The
   "common" struct has members that are present in both "v1" and "v2"
   which the driver API callbacks can use to read the data from in
   version-independent manner (if version-specific member needs to be
   accessed the driver can check priv->wmiVersion and read from "v1" or
   "v2" as needed). Those structs are guaranteed to be  memory aligned
   by the code generator (see the align_property_members implementation
   that takes care of that)
 * the generator produces *_WmiInfo for each WMI class "family" that
   holds an array of hypervWmiClassInfoPtr each providing information
   as to which request URI to use for each "version" of given WMI class
   as well as XmlSerializerInfo struct needed to unserilize WS-MAN
   responsed into the data structs. The driver uses those to make proper
   WS-MAN request depending on which version it's connected to.
 * the generator no longer produces "helper" functions such as
   hypervGetMsvmComputerSystemList as those were originally just simple
   wrappers around hypervEnumAndPull, instead those were hand-written
   now (to keep driver changes minimal). The reason is that we'll have
   more code coming implementing missing libvirt APIs and surely code
   patterns will emerge that would warrant more useful "utility" functions
   like that.
 * a hypervInitConnection was added to the driver which "detects"
   Hyper-V version by testing simple wsman request using v2 then falling
   back to v1, obviously if both fail, the we're erroring out.

To express how the above translates in code:

void
hypervImplementSomeLibvirtApi(virConnectPtr conn, ...)
{
    hypervPrivate *priv = conn->privateData;
    virBuffer query = VIR_BUFFER_INITIALIZER;
    hypervWqlQuery wqlQuery = HYPERV_WQL_QUERY_INITIALIZER;
    Msvm_ComputerSystem *list = NULL; /* typed hypervObject instance */

    /* the WmiInfo struct has the data needed for wsman request and
     * response handling for both v1 and v2 */
    wqlQuery.info = Msvm_ComputerSystem_WmiInfo;
    wqlQuery.query = &query;

    virBufferAddLit(&query, "select * from Msvm_ComputerSystem");

    if (hypervEnumAndPull(priv, &wqlQuery, (hypervObject **) &list) < 0) {
        goto cleanup;
    }

    if (list == NULL) {
        /* none found */
        goto cleanup;
    }

    /* works with v1 and v2 */
    char *vmName = list->data.common->Name;

    /* access property that is in v2 only */
    if (priv->wmiVersion == HYPERV_WMI_VERSION_V2)
        char *foo = list->data.v2->V2Property;
    else
        char *foo = list->data.v1->V1Property;

 cleanup:
    hypervFreeObject(priv, (hypervObject *)list);
}

8 years agohyperv: update hypervObject struct.
Dawid Zamirski [Tue, 4 Apr 2017 22:26:07 +0000 (18:26 -0400)] 
hyperv: update hypervObject struct.

Currently named as hypervObjecUnified to keep code
compilable/functional until all bits are in place.

This struct is a result of unserializing WMI request response.
Therefore, it needs to be able to deal with different "versions" of the
same WMI class. To accomplish this, the "data" member was turned in to
a union which:

* has a "common" member that contains only WMI class fields that are
  safe to access and are present in all "versions". This is ensured by
  the code generator that takes care of proper struct memory alignment
  between "common", "v1", "v2" etc members. This memeber is to be used
  by the driver code wherever the API implementation can be shared for
  all supported hyper-v versions.
* the "v1" and "v2" member can be used by the driver code to handle
  version specific cases.

Example:

Msvm_ComputerSystem *vm = NULL;
...
hypervGetVirtualMachineList(priv, wqlQuery, *vm);
...
/* safe for "v1" and "v2" */
char *vmName = vm->data.common->Name;

/* or if one really needs special handling for "v2" */
if (priv->wmiVersion == HYPERV_WMI_VERSION_V2) {
    char *foo = vm->data.v2->SomeV2OnlyField;
}

In other words, driver should not concern itself with existence of "v1"
or "v2" of WMI class unless absolutely necessary.

8 years agohyperv: introduce hypervWmiClassInfo struct.
Dawid Zamirski [Tue, 4 Apr 2017 22:26:06 +0000 (18:26 -0400)] 
hyperv: introduce hypervWmiClassInfo struct.

This struct is to be used to carry all the information necessary to
issue wsman requests for given WMI class. Those will be defined by the
generator code (as lists) so that they are handy for the driver code to
"extract" needed info depending on which hyper-v we're connected to.
For example:

hypervWmiClassInfoListPtr Msvm_ComputerSystem_WmiInfo = {
    .count = 2
    {
        {
            .name = "Msvm_ComputerSystem",
            .version = "v1",
            .rootUri = "http://asdf.com",
            ...
        },
        {
            .name = "Msvm_ComputerSystem",
            .version = "v2",
            .rootUri = "http://asdf.com/v2",
            ...
        },
    }
};

Then the driver code will grab either "v1" or "v2" to pass info wsman
API, depending on hypervPrivate->wmiVersion value.

8 years agohyperv: store WMI version in hypervPrivate.
Dawid Zamirski [Tue, 4 Apr 2017 22:26:05 +0000 (18:26 -0400)] 
hyperv: store WMI version in hypervPrivate.

Hyper-V 2012+ uses a new "v2" version of Msvm_* WMI classes so we will
store that info in hypervPrivate so that it is easily accessbile in the
driver API callbacks and handled accordingly.

8 years agodisk: Force usage of parted when checking disk format for "bsd"
John Ferlan [Fri, 7 Apr 2017 13:38:44 +0000 (09:38 -0400)] 
disk: Force usage of parted when checking disk format for "bsd"

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

Add "bsd" to the list of format types to not checked during blkid
processing even though it supposedly knows the format - for some
(now unknown) reason it's returning partition table not found. So
let's just let PARTED handle "bsd" too.

Signed-off-by: John Ferlan <jferlan@redhat.com>