]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
8 years agoremote: Fix possible use-after-free when sending event message
John Ferlan [Mon, 27 Mar 2017 16:47:37 +0000 (12:47 -0400)]
remote: Fix possible use-after-free when sending event message

Based upon an idea and some research by Wang King <king.wang@huawei.com>
and xinhua.Cao <caoxinhua@huawei.com>.

Since we're assigning the 'client' to our callback event lookaside list,
it's imperative that we grab a reference to the object; otherwise, when
the object is unref'd during virNetServerProcessClients when it's determined
that the virNetServerClientIsClosed and the memory is free'd before perhaps
the object event state callbacks are run.  When a virObjectLock() is run,
before sending the message the following trace occurs;

    #0  0x00007fda223d66d8 in virClassIsDerivedFrom
        (klass=0xdeadbeef, parent=0x7fda24c81b40)
         at util/virobject.c:169
    #1  0x00007fda223d6a1e in virObjectIsClass
        (anyobj=anyobj@entry=0x7fd9e575b400, klass=<optimized out>)
         at util/virobject.c:365
    #2  0x00007fda223d6a44 in virObjectLock
        (anyobj=0x7fd9e575b400)
        at util/virobject.c:317
    #3  0x00007fda22507f71 in virNetServerClientSendMessage
        (client=client@entry=0x7fd9e575b400, msg=msg@entry=0x7fd9ec30de90)
        at rpc/virnetserverclient.c:1422
    #4  0x00007fda230d714d in remoteDispatchObjectEventSend
        (client=0x7fd9e575b400, program=0x7fda24c844e0, procnr=348,
         proc=0x7fda2310e5e0 <xdr_remote_domain_event_callback_tunable_msg>,
         data=0x7ffc3857fdb0)
        at remote.c:3803
    #5  0x00007fda230dd71b in remoteRelayDomainEventTunable
        (conn=<optimized out>, dom=0x7fda27cd7660, params=0x7fda27f3aae0,
         nparams=1,opaque=0x7fd9e6c99e00)
        at remote.c:1033
    #6  0x00007fda224484cb in virDomainEventDispatchDefaultFunc
        (conn=0x7fda27cd0120, event=0x7fda2736ea00, cb=0x7fda230dd610
         <remoteRelayDomainEventTunable>, cbopaque=0x7fd9e6c99e00)
        at conf/domain_event.c:1910
    #7  0x00007fda22446871 in virObjectEventStateDispatchCallbacks
        (callbacks=<optimized out>, callbacks=<optimized out>,
         event=0x7fda2736ea00,state=0x7fda24ca3960)
        at conf/object_event.c:722
    #8  virObjectEventStateQueueDispatch
        (callbacks=0x7fda24c65800, queue=0x7ffc3857fe90, state=0x7fda24ca3960)
        at conf/object_event.c:736
    #9  virObjectEventStateFlush (state=0x7fda24ca3960)
        at conf/object_event.c:814
    #10 virObjectEventTimer (timer=<optimized out>, opaque=0x7fda24ca3960)
        at conf/object_event.c:560
    #11 0x00007fda223ae8b9 in virEventPollDispatchTimeouts ()
        at util/vireventpoll.c:458
    #12 virEventPollRunOnce ()
        at util/vireventpoll.c:654
    #13 0x00007fda223ad1d2 in virEventRunDefaultImpl ()
        at util/virevent.c:314
    #14 0x00007fda225046cd in virNetDaemonRun (dmn=0x7fda24c775c0)
        at rpc/virnetdaemon.c:818
    #15 0x00007fda230d6351 in main (argc=<optimized out>, argv=<optimized out>)
        at libvirtd.c:1623

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agodaemon: Rework remoteClientFreeFunc cleanup loops into C macro
John Ferlan [Mon, 27 Mar 2017 16:47:36 +0000 (12:47 -0400)]
daemon: Rework remoteClientFreeFunc cleanup loops into C macro

Rather than 'n' repetitive code segments, let's create a single macro
which will make the code easier to read.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agodaemon: Remove unnecessary goto error
Wang King [Mon, 24 Apr 2017 04:05:25 +0000 (12:05 +0800)]
daemon: Remove unnecessary goto error

Freeing the dst is unnecessary if the VIR_STRDUP fails, and therefore
we need to remove the error label as well.

8 years agodaemon: Fix domain name leak in error path
Wang King [Mon, 24 Apr 2017 04:05:24 +0000 (12:05 +0800)]
daemon: Fix domain name leak in error path

Domain name is duplicated in make_nonnull_domain, but not freed when
virTypedParamsSerialize returns error.

8 years agoqemu: fix argument of virDomainNetGetActualDirectMode
ZhiPeng Lu [Tue, 25 Apr 2017 06:16:20 +0000 (14:16 +0800)]
qemu: fix argument of virDomainNetGetActualDirectMode

it should be a comparison of modes between new and old devices. So
the argument of the second virDomainNetGetActualDirectMode should be
newdev.

Signed-off-by: ZhiPeng Lu <lu.zhipeng@zte.com.cn>
8 years agoautogen.sh: Improve and generalize
Andrea Bolognani [Wed, 12 Apr 2017 11:09:08 +0000 (13:09 +0200)]
autogen.sh: Improve and generalize

The goal is twofold: firstly, we want to extend the script so
that it can deal with more than a single git submodule, and
secondly we'd like to reduce the amount of duplicated code.
Moreover, since we're making heavy changes to the code anyway,
we might as well make sure it follows a somewhat consistent
coding style too.

To reduce code duplication, we introduce a new --dry-run
option, which can be used by third parties to figure out
whether calling autogen.sh is necessary or not: this allows
us to get rid of the reimplementation of part of the logic
in cfg.mk and guarantee they'll never get out of sync.

Other changes include: making dirty submodules checking and
cleaning entirely independent of other operations; removing
the use of 'set -e' and handling errors explicitly instead;
better parsing of command line arguments.

8 years agoFix minor typos
Yuri Chornoivan [Sat, 22 Apr 2017 19:06:20 +0000 (22:06 +0300)]
Fix minor typos

8 years agoutil: relax virNetDevSetCoalesce() stub
Roman Bogorodskiy [Sun, 23 Apr 2017 14:53:37 +0000 (18:53 +0400)]
util: relax virNetDevSetCoalesce() stub

Currently, virNetDevSetCoalesce() stub is always returning error. As
it's used by virNetDevTapCreateInBridgePort(), it essentially breaks
bridged networking if coalesce is not supported.

To make it work, relax the stub to trigger error only when its
coalesce argument is not NULL, otherwise report success.

8 years agodocs: Utilize our XSLT list generating template more
Erik Skultety [Tue, 21 Mar 2017 15:38:14 +0000 (16:38 +0100)]
docs: Utilize our XSLT list generating template more

Since we do have this template at hand, why not using it wherever
possible (list of supported pool types and remote access section).
Also, perform some stylistic micro adjustments.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
8 years agonodedev: udevProcessPCI: Drop syspath variable
Erik Skultety [Wed, 1 Mar 2017 16:46:53 +0000 (17:46 +0100)]
nodedev: udevProcessPCI: Drop syspath variable

Since we have that information provided by @def which is not a private
object, there is really no need for the variable.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
8 years agoconf: nodedev: Split virNodeDeviceDefFormat into more functions
Erik Skultety [Mon, 6 Mar 2017 15:30:16 +0000 (16:30 +0100)]
conf: nodedev: Split virNodeDeviceDefFormat into more functions

Make the code look cleaner by moving the capability specific bits into
separate functions.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
8 years agonodedev: Make use of the compile-time missing enum in switch error
Erik Skultety [Fri, 24 Feb 2017 09:26:42 +0000 (10:26 +0100)]
nodedev: Make use of the compile-time missing enum in switch error

So udevGetDeviceDetails was one those functions using an enum in a
switch, but since it had a 'default' case, compiler didn't warn about an
unhandled enum. Moreover, the error about an unsupported device type
reported in the default case is unnecessary, since by the time we get
there, udevGetDeviceType (which was called before) already made sure
that any unrecognized device types had been handled properly.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
8 years agorpc: fix keep alive timer segfault
Yi Wang [Tue, 18 Apr 2017 01:55:29 +0000 (09:55 +0800)]
rpc: fix keep alive timer segfault

ka maybe have been freeed in virObjectUnref, application using
virKeepAliveTimer will segfault when unlock ka. We should keep
ka's refs positive before using it.

#0  0x00007fd8f79970e8 in virClassIsDerivedFrom (klass=0xdeadbeef, parent=0x7fd8e8001b80) at util/virobject.c:169
#1  0x00007fd8f799742e in virObjectIsClass (anyobj=anyobj entry=0x7fd8e800b9c0, klass=<optimized out>) at util/virobject.c:365
#2  0x00007fd8f79974e4 in virObjectUnlock (anyobj=0x7fd8e800b9c0) at util/virobject.c:338
#3  0x00007fd8f7ac477e in virKeepAliveTimer (timer=<optimized out>, opaque=0x7fd8e800b9c0) at rpc/virkeepalive.c:177
#4  0x00007fd8f7e5c9cf in libvirt_virEventInvokeTimeoutCallback () from /usr/lib64/python2.7/site-packages/libvirtmod.so
#5  0x00007fd8ff64db94 in PyEval_EvalFrameEx () from /lib64/libpython2.7.so.1.0
#6  0x00007fd8ff64f1ad in PyEval_EvalCodeEx () from /lib64/libpython2.7.so.1.0
#7  0x00007fd8ff64d85f in PyEval_EvalFrameEx () from /lib64/libpython2.7.so.1.0
#8  0x00007fd8ff64d950 in PyEval_EvalFrameEx () from /lib64/libpython2.7.so.1.0
#9  0x00007fd8ff64d950 in PyEval_EvalFrameEx () from /lib64/libpython2.7.so.1.0
#10 0x00007fd8ff64f1ad in PyEval_EvalCodeEx () from /lib64/libpython2.7.so.1.0
#11 0x00007fd8ff5dc098 in function_call () from /lib64/libpython2.7.so.1.0
#12 0x00007fd8ff5b7073 in PyObject_Call () from /lib64/libpython2.7.so.1.0
#13 0x00007fd8ff5c6085 in instancemethod_call () from /lib64/libpython2.7.so.1.0
#14 0x00007fd8ff5b7073 in PyObject_Call () from /lib64/libpython2.7.so.1.0
#15 0x00007fd8ff648ff7 in PyEval_CallObjectWithKeywords () from /lib64/libpython2.7.so.1.0
#16 0x00007fd8ff67d7e2 in t_bootstrap () from /lib64/libpython2.7.so.1.0
#17 0x00007fd8ff358df3 in start_thread () from /lib64/libpthread.so.0
#18 0x00007fd8fe97d3ed in clone () from /lib64/libc.so.6

Signed-off-by: Yi Wang <wang.yi59@zte.com.cn>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agoRemove pointless check for !ret in virDomainNetDefCoalesceParseXML
Martin Kletzander [Sat, 22 Apr 2017 16:34:30 +0000 (18:34 +0200)]
Remove pointless check for !ret in virDomainNetDefCoalesceParseXML

It was left there after removing a macro it was part of in first
version or so.  Now it will always be NULL.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
8 years agoDon't leak str in virDomainNetDefCoalesceParseXML
Martin Kletzander [Sat, 22 Apr 2017 12:39:13 +0000 (14:39 +0200)]
Don't leak str in virDomainNetDefCoalesceParseXML

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
8 years agoutil: allow ignoring SIOCSIFHWADDR when errno is EPERM
Laine Stump [Mon, 17 Apr 2017 14:50:48 +0000 (10:50 -0400)]
util: allow ignoring SIOCSIFHWADDR when errno is EPERM

Commit f4ef3a71 made a variation of virNetDevSetMAC that would return
without logging an error message if errno was set to
EADDRNOTAVAIL. This errno is set by some SRIOV VF drivers (in
particular igbvf) when they fail to set the device's MAC address due
to the PF driver refusing the request. This is useful if we want to
try a different method of setting the VF MAC address before giving up
(Commit 86556e16 actually does this, setting the desired MAC address
to the "admin MAC in the PF, then detaching and reattaching the VF
netdev driver to force a reinit of the MAC address).

During testing of Bug 1442040 t was discovered that the ixgbe driver
returns EPERM in this situation, so this patch changes the exception
case for silent+non-terminal failure to account for this difference.

Completes resolution to: https://bugzilla.redhat.com/1415609 (RHEL 7.4)
                         https://bugzilla.redhat.com/1442040 (RHEL 7.3.z)

8 years agoutil: fix virNetDevSetCoalesce fallback on Win32/FreeBSD
Daniel P. Berrange [Fri, 21 Apr 2017 13:54:04 +0000 (14:54 +0100)]
util: fix virNetDevSetCoalesce fallback on Win32/FreeBSD

The current fallback stub for virNetDevSetCoalesce is inside an
earlier conditional block. This deals with the feature being
missing on older Linux platforms. We need a second fallback stub
though, outside the top level conditional, to ensure builds work
on Win32/FreeBSD platforms too.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
8 years agodocs: fix typo in closing HTML element
Daniel P. Berrange [Fri, 21 Apr 2017 12:07:17 +0000 (13:07 +0100)]
docs: fix typo in closing HTML element

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
8 years agoSet coalesce settings for domain interfaces
Martin Kletzander [Fri, 7 Apr 2017 15:54:12 +0000 (17:54 +0200)]
Set coalesce settings for domain interfaces

This patch makes use of the virNetDevSetCoalesce() function to make
appropriate settings effective for devices that support them.

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
8 years agoconf, docs: Add support for coalesce setting(s)
Martin Kletzander [Fri, 7 Apr 2017 15:46:32 +0000 (17:46 +0200)]
conf, docs: Add support for coalesce setting(s)

We are currently parsing only rx/frames/max because that's the only
value that makes sense for us.  The tun device just added support for
this one and the others are only supported by hardware devices which
we don't need to worry about as the only way we'd pass those to the
domain is using <hostdev/> or <interface type='hostdev'/>.  And in
those cases the guest can modify the settings itself.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
8 years agoutil: Add virNetDevSetCoalesce function
Martin Kletzander [Fri, 7 Apr 2017 15:38:06 +0000 (17:38 +0200)]
util: Add virNetDevSetCoalesce function

That function is able to configure coalesce settings for an interface,
similarly to 'ethtool -C'.  This function also updates back the
structure so that it contains actual data on the device (if the device
doesn't support some settings kernel might just return 0 and not set
whatever is not supported), so this way we'll have up-to-date
information in the live domain XML.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
8 years agoutil: check ifa_addr pointer before accessing its elements
Pavel Hrdina [Fri, 21 Apr 2017 08:50:12 +0000 (10:50 +0200)]
util: check ifa_addr pointer before accessing its elements

Reported by Rafał Wojciechowski <it@rafalwojciechowski.pl>.

Thread 1 (Thread 0x7f194b99d700 (LWP 5631)):
0  virNetDevGetifaddrsAddress (addr=0x7f194b99c7c0, ifname=0x7f193400e2b0 "ovirtmgmt") at util/virnetdevip.c:738
1  virNetDevIPAddrGet (ifname=0x7f193400e2b0 "ovirtmgmt", addr=addr@entry=0x7f194b99c7c0) at util/virnetdevip.c:795
2  0x00007f19467800d6 in networkGetNetworkAddress (netname=<optimized out>, netaddr=netaddr@entry=0x7f1924013f18) at network/bridge_driver.c:4780
3  0x00007f193e43a33c in qemuProcessGraphicsSetupNetworkAddress (listenAddr=0x7f19340f7650 "127.0.0.1", glisten=0x7f1924013f10) at qemu/qemu_process.c:4062
4  qemuProcessGraphicsSetupListen (vm=<optimized out>, graphics=0x7f1924014f10, cfg=0x7f1934119f00) at qemu/qemu_process.c:4133
5  qemuProcessSetupGraphics (flags=17, vm=0x7f19240155d0, driver=0x7f193411f1d0) at qemu/qemu_process.c:4196
6  qemuProcessPrepareDomain (conn=conn@entry=0x7f192c00ab50, driver=driver@entry=0x7f193411f1d0, vm=vm@entry=0x7f19240155d0, flags=flags@entry=17) at qemu/qemu_process.c:4969
7  0x00007f193e4417c0 in qemuProcessStart (conn=conn@entry=0x7f192c00ab50, driver=driver@entry=0x7f193411f1d0, vm=0x7f19240155d0,asyncJob=asyncJob@entry=QEMU_ASYNC_JOB_START, migrateFrom=migrateFrom@entry=0x0, migrateFd=migrateFd@entry=-1, migratePath=migratePath@entry=0x0,snapshot=snapshot@entry=0x0, vmop=vmop@entry=VIR_NETDEV_VPORT_PROFILE_OP_CREATE, flags=17, flags@entry=1) at qemu/qemu_process.c:5553

Man page for getifaddrs also states that the "ifa_addr" may contain
a null pointer which happens if there is an existing network interface
on the host without IP address.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8 years agoIncrease default task limit for libvirtd
Jim Fehlig [Wed, 19 Apr 2017 18:54:33 +0000 (12:54 -0600)]
Increase default task limit for libvirtd

libvirtd can spawn threads/tasks when creating new domains for
some hypervisors such as Xen's libxl driver, quickly reaching
the cgroups pids controller default TasksMax setting of 512. When
the limit is reached, attempting to create additional domains
results in an error from the cgroups pids controller, e.g.

kernel: [71282.213347] cgroup: fork rejected by pids controller in
/system.slice/libvirtd.service

Depending on domain type and configuration, anywhere from 4-7
threads/tasks may be created by libxl when starting a domain.
In order to support 4096 domains, similar to commit 27cd763500,
increase the TasksMax setting in libvirtd.service to
4096 * 8 = 32768 tasks.

8 years agoFix error reporting when poll returns POLLHUP/POLLERR
Daniel P. Berrange [Tue, 18 Apr 2017 15:57:06 +0000 (16:57 +0100)]
Fix error reporting when poll returns POLLHUP/POLLERR

In the RPC client event loop code, if poll() returns only a POLLHUP
or POLLERR status, then we end up reporting a bogus error message:

  error: failed to connect to the hypervisor
  error: An error occurred, but the cause is unknown

We do actually report an error, but we virNetClientMarkClose method
has already captured the error status before we report it, so the
real error gets thrown away. The key fix is to report the error
before calling virNetClientMarkClose(). In changing this, we also
split out reporting of POLLHUP vs POLLERR to make any future bugs
easier to diagnose.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
8 years agoqemu: hotplug: Don't save status XML when monitor is closed
Peter Krempa [Thu, 13 Apr 2017 12:22:16 +0000 (14:22 +0200)]
qemu: hotplug: Don't save status XML when monitor is closed

In the vcpu hotplug code if exit from the monitor failed we would still
attempt to save the status XML. When the daemon is terminated the
monitor socket is closed. In such case, the written status XML would not
contain the monitor path and thus be invalid.

Avoid this issue by only saving status XML on success of the monitor
command.

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

8 years agoqemu: hotplug: Unexport qemuDomainHotplugDelVcpu
Peter Krempa [Thu, 13 Apr 2017 12:12:34 +0000 (14:12 +0200)]
qemu: hotplug: Unexport qemuDomainHotplugDelVcpu

The function is used only in the hotplug module.

8 years agoqemu_domain: use correct default USB controller on ppc64
Pavel Hrdina [Wed, 1 Mar 2017 18:58:22 +0000 (19:58 +0100)]
qemu_domain: use correct default USB controller on ppc64

The history of USB controller for ppc64 guest is complex and goes
back to libvirt 1.3.1 where the fun started.

Prior Libvirt 1.3.1 if no model for USB controller was specified
we've simply passed "-usb" on QEMU command line.

Since Libvirt 1.3.1 there is a patch (8156493d8db) that fixes this
issue by using "-device pci-ohci,..." but it breaks migration with
older Libvirts which was agreed that's acceptable.  However this
patch didn't reflect this change in the domain XML and the model
was still missing.

Since Libvirt 2.2.0 there is a patch (f55eaccb0c5) that fixes the
issue with not setting the USB model into domain XML which we need
to know about to not break the migration and since the default
model was *pci-ohci* it was used as default in this patch as well.

This patch tries to take all the previous changes into account and
also change the default for newly defined domains that don't specify
any model for USB controller.

The VIR_DOMAIN_DEF_PARSE_ABI_UPDATE is set only if new domain is
defined or new device is added into a domain which means that in
all other cases we will use the old *pci-ohci* model instead of the
better and not broken *nec-usb-xhci* model.

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

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8 years agoconf: add a new parse flag VIR_DOMAIN_DEF_PARSE_ABI_UPDATE_MIGRATION
Pavel Hrdina [Thu, 9 Mar 2017 12:57:54 +0000 (13:57 +0100)]
conf: add a new parse flag VIR_DOMAIN_DEF_PARSE_ABI_UPDATE_MIGRATION

So far there is probably no change that is allowed to be done
by the VIR_DOMAIN_DEF_PARSE_ABI_UPDATE flag that would break
guest ABI but this may change in the future.

This introduces new VIR_DOMAIN_DEF_PARSE_ABI_UPDATE_MIGRATION
which should be used only for ABI updates that are "safe" for
persistent migration.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8 years agoRefresh translations from zanata
Daniel P. Berrange [Wed, 19 Apr 2017 15:27:02 +0000 (16:27 +0100)]
Refresh translations from zanata

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
8 years agoqemu: Use more data for comparing CPUs
Jiri Denemark [Tue, 11 Apr 2017 18:46:05 +0000 (20:46 +0200)]
qemu: Use more data for comparing CPUs

With QEMU older than 2.9.0 libvirt uses CPUID instruction to determine
what CPU features are supported on the host. This was later used when
checking compatibility of guest CPUs. Since QEMU 2.9.0 we ask QEMU for
the host CPU data. But the two methods we use usually provide disjoint
sets of CPU features because QEMU/KVM does not support all features
provided by the host CPU and on the other hand it can enable some
feature even if the host CPU does not support them.

So if there is a domain which requires a CPU features disabled by
QEMU/KVM, libvirt will refuse to start it with QEMU > 2.9.0 as its guest
CPU is incompatible with the host CPU data we got from QEMU. But such
domain would happily start on older QEMU (of course, the features would
be missing the guest CPU). To fix this regression, we need to combine
both CPU feature sets when checking guest CPU compatibility.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agocpu: Introduce virCPUGetHostIsSupported
Jiri Denemark [Tue, 11 Apr 2017 18:45:07 +0000 (20:45 +0200)]
cpu: Introduce virCPUGetHostIsSupported

Sometimes we want to call virCPUGetHost only when it is implemented for
a given architecture to avoid logging expected and possibly misleading
errors. The new virCPUGetHostIsSupported API may be used to guard such
calls to virCPUGetHost.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agocpu: Drop feature filtering from virCPUUpdate
Jiri Denemark [Wed, 29 Mar 2017 13:00:21 +0000 (15:00 +0200)]
cpu: Drop feature filtering from virCPUUpdate

Because of the changes done in the previous commit, @host is already a
migratable CPU and there's no need to do any additional filtering.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agoqemu: Pass migratable host CPU model to virCPUUpdate
Jiri Denemark [Wed, 29 Mar 2017 13:31:17 +0000 (15:31 +0200)]
qemu: Pass migratable host CPU model to virCPUUpdate

We already know from QEMU which CPU features will block migration. Let's
use this information to make a migratable copy of the host CPU model and
use it for updating guest CPU specification. This will allow us to drop
feature filtering from virCPUUpdate where it was just a hack.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agoqemu: Prepare qemuCaps for multiple host CPU defs
Jiri Denemark [Tue, 11 Apr 2017 09:14:30 +0000 (11:14 +0200)]
qemu: Prepare qemuCaps for multiple host CPU defs

Soon we will need to store multiple host CPU definitions in
virQEMUCapsHostCPUData and qemuCaps users will want to request the one
they need. This patch introduces virQEMUCapsHostCPUType enum which will
be used for specifying the requested CPU definition.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agoqemu: Move qemuCaps host CPU data in a struct
Jiri Denemark [Fri, 7 Apr 2017 16:15:26 +0000 (18:15 +0200)]
qemu: Move qemuCaps host CPU data in a struct

We need to store several CPU related data structure for both KVM and
TCG. So instead of keeping two different copies of everything let's
make a virQEMUCapsHostCPUData struct and use it twice.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agoqemu: Introduce virQEMUCapsHostCPUDataClear
Jiri Denemark [Fri, 7 Apr 2017 15:43:59 +0000 (17:43 +0200)]
qemu: Introduce virQEMUCapsHostCPUDataClear

To keep freeing of host CPU data in one place.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agoqemu: Move qemuCaps CPU data copying into a separate function
Jiri Denemark [Fri, 7 Apr 2017 15:40:31 +0000 (17:40 +0200)]
qemu: Move qemuCaps CPU data copying into a separate function

This introduces virQEMUCapsHostCPUDataCopy which will later be
refactored a bit and called twice from virQEMUCapsNewCopy.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agoqemu: Introduce virQEMUCapsSetHostModel
Jiri Denemark [Fri, 7 Apr 2017 15:03:38 +0000 (17:03 +0200)]
qemu: Introduce virQEMUCapsSetHostModel

A simple helper as a complement to virQEMUCapsGetHostModel.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agovirt-storage-rbd: fix typo s/RDB/RBD/ in configure check
Daniel P. Berrange [Wed, 19 Apr 2017 14:01:17 +0000 (15:01 +0100)]
virt-storage-rbd: fix typo s/RDB/RBD/ in configure check

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
8 years agovirsh: report errors in virshInit()
Daniel P. Berrange [Wed, 19 Apr 2017 10:42:00 +0000 (11:42 +0100)]
virsh: report errors in virshInit()

There are several functions in virshInit which can fail, especially
when running win32 builds under WINE. Currently virsh just exits
without reporting what error happened.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
8 years agoAdd travis build configuration
Daniel P. Berrange [Fri, 7 Apr 2017 14:15:25 +0000 (15:15 +0100)]
Add travis build configuration

This travis configuration tests libvirt builds on 5 platforms that we don't
exercise in the CentOS CI system.

  - Ubuntu Trusty with GCC
  - Ubuntu Trusty with CLang
  - Ubuntu Precise with GCC
  - Ubuntu Precise with CLang
  - OS-X with CLang

NB, syntax-check fails on OS-X with errors like:

   /bin/sh: /usr/bin/grep: Argument list too long

Presumably their grep impl isn't as good as the GNU one, so this test
config skips syntax-check on OS-X for now.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
8 years agoIgnore SASL deprecation warnings on OS-X
Daniel P. Berrange [Fri, 7 Apr 2017 14:43:38 +0000 (15:43 +0100)]
Ignore SASL deprecation warnings on OS-X

Apple have annotated all SASL functions as deprecated for
unknown reasons. Since they still work, lets just ignore
the warnings. If Apple finally delete the SASL functions
our configure check should already catch that

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
8 years agoFix detection of required RBD version
Daniel P. Berrange [Fri, 7 Apr 2017 14:12:08 +0000 (15:12 +0100)]
Fix detection of required RBD version

If building libvirt against Ubuntu precise, the librbd.h is lacking
many functions that libvirt expects. We have no version check, so
we were enabling RBD even though it cannot compile. This configure
check uses existance of 'rbd_get_features' as an identifier for the
min required version.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
8 years agoPrevent test failures with ebtables/iptables/ip6tables are missing
Daniel P. Berrange [Fri, 7 Apr 2017 14:11:14 +0000 (15:11 +0100)]
Prevent test failures with ebtables/iptables/ip6tables are missing

When running tests in a restricted container (as opposed to a full
OS install), we can't assume ebtables/iptbles/ip6tables are going
to be installed. We must check this and mark the tests as skipped.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
8 years agoannotate all mocked functions with noinline
Daniel P. Berrange [Fri, 7 Apr 2017 14:07:49 +0000 (15:07 +0100)]
annotate all mocked functions with noinline

CLang's optimizer is more aggressive at inlining functions than
gcc and so will often inline functions that our tests want to
mock-override. This causes the test to fail in bizarre ways.

We don't want to disable inlining completely, but we must at
least prevent inlining of mocked functions. Fortunately there
is a 'noinline' attribute that lets us control this per function.

A syntax check rule is added that parses tests/*mock.c to extract
the list of functions that are mocked (restricted to names starting
with 'vir' prefix). It then checks that src/*.h header file to
ensure it has a 'ATTRIBUTE_NOINLINE' annotation. This should prevent
use from bit-rotting in future.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
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.