]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
10 years agobuild: avoid variable named 'interface', for mingw
Eric Blake [Sat, 28 Mar 2015 20:04:27 +0000 (14:04 -0600)]
build: avoid variable named 'interface', for mingw

Commit 2f36e6944 (re-)introduced a use of an identifier 'interface',
which causes this build failure on mingw:

../../tools/virsh-domain-monitor.c: In function 'cmdDomIfAddr':
../../tools/virsh-domain-monitor.c:2233:17: error: expected identifier or '(' before 'struct'
     const char *interface = NULL;
                      ^

See also commit 6512c8b.  Sadly, I'm not quite sure how to write a
syntax check that can poison the use of this identifier.

* tools/virsh-domain-monitor.c (cmdDomIfAddr): Use ifacestr instead.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agovircgroup: Fix build issue mingw cross compile
John Ferlan [Fri, 27 Mar 2015 16:36:04 +0000 (12:36 -0400)]
vircgroup: Fix build issue mingw cross compile

Commit id '2dbfa716' exposed virCgroupDetectMountsFromFile, but did not
add the corresponding entry in the "#else /* !VIR_CGROUP_SUPPORTED */"
section of the module.

10 years agovircgroup: Fix build issue on mingw cross compile
John Ferlan [Fri, 27 Mar 2015 16:13:56 +0000 (12:13 -0400)]
vircgroup: Fix build issue on mingw cross compile

Commit id 'ba1dfc5' added virCgroupSetCpusetMemoryMigrate and
virCgroupGetCpusetMemoryMigrate, but did not add the corresponding
entry points into the "#else /* !VIR_CGROUP_SUPPORTED */" section

10 years agotests: introduce qemucaps2xmlmock
Pavel Hrdina [Wed, 25 Mar 2015 14:35:46 +0000 (15:35 +0100)]
tests: introduce qemucaps2xmlmock

We need to mock virFileExists to return true for "/dev/kvm" because the
test should not depend on host system.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
10 years agoRevert "qemucaps2xmltest: fix test to successfully run without kvm support"
Pavel Hrdina [Wed, 25 Mar 2015 14:17:13 +0000 (15:17 +0100)]
Revert "qemucaps2xmltest: fix test to successfully run without kvm support"

This reverts commit 49bf09d16cb7050795f6963a2746d686a2fbaece.  That
commit is wrong and doesn't fix the issue.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
10 years agovirnetlink: fix build error
Pavel Hrdina [Fri, 27 Mar 2015 10:06:05 +0000 (11:06 +0100)]
virnetlink: fix build error

Commint 0473b45cc introduced new function virNetlinkDelLink, but in
it's counterpart for non-linux platform there should be ATTRIBUTE_UNUSED
instead of ATTRIBUTE_UNSUPPORTED.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
10 years agoqemu: end the job when try to blockcopy to non-file destination
Shanzhi Yu [Fri, 27 Mar 2015 09:16:41 +0000 (17:16 +0800)]
qemu: end the job when try to blockcopy to non-file destination

Blockcopy to non-file destination is not supported according the code,
but a 'goto endjob' is missed after checking the destination.

This leads to calling drive-mirror with wrong parameters.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1206406
Signed-off-by: Shanzhi Yu <shyu@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
10 years agonodeinfo: Increase the num of CPU thread siblings to a larger value
Wei Huang [Thu, 26 Mar 2015 04:48:13 +0000 (00:48 -0400)]
nodeinfo: Increase the num of CPU thread siblings to a larger value

Current libvirt can only handle up to 1023 bytes when it
reads Linux sysfs topology/thread_siblings. This isn't enough for
Linux distributions that support a large value. This patch fixes
the problem by using VIR_ALLOC()/VIR_FREE(), instead of using a
fixed-size (1024) local char array. In the meanwhile
SYSFS_THREAD_SIBLINGS_LIST_LENGTH_MAX is increased to 8192 which
should be large enough for a foreseeable future.

Signed-off-by: Wei Huang <wei@redhat.com>
10 years agorelaxng: allow : in /dev/disk/by-path names
Eric Blake [Thu, 26 Mar 2015 22:48:07 +0000 (16:48 -0600)]
relaxng: allow : in /dev/disk/by-path names

On IRC, Hydrar pointed a problem where 'virsh edit' failed on
his domain created through an ISCSI pool managed by virt-manager,
all because the XML included a block device with colons in the
name.

* docs/schemas/basictypes.rng (absFilePath): Add colon as safe.
* tests/qemuxml2argvdata/qemuxml2argv-disk-iscsi.xml: New file.
* tests/qemuxml2argvdata/qemuxml2argv-disk-iscsi.args: Likewise.
* tests/qemuxml2argvtest.c (mymain): Test it.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agolibxl: Fix memory leak if pthread_create fails.
Konrad Rzeszutek Wilk [Thu, 26 Mar 2015 01:35:11 +0000 (21:35 -0400)]
libxl: Fix memory leak if pthread_create fails.

If we fail to create the thread we leak the shutdown_info
structure.

Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
10 years agoutil: use netlink to create bridge devices
Laine Stump [Mon, 23 Mar 2015 18:17:44 +0000 (14:17 -0400)]
util: use netlink to create bridge devices

Just as it is possible to delete a bridge device with the netlink
RTM_DELLINK message, one can be created with the RTM_NEWLINK
message. Because of differences in the format of the message, it's not
as straightforward as with virNetlinkDelLink() to create a single
utility function that can be used to create any type of interface, so
the new netlink version of virNetDevBridgeCreate() does its own
construction of the netlink message and calls virNetlinkCommand()
itself.

This doesn't provide any extra functionality, just provides symmetry
with the previous commit.

NB: We *could* alter the API of virNetDevBridgeCreate() to take a MAC
address, and directly program that mac address into the bridge (by
adding an IFLA_ADDRESS attribute, as is done in
virNetDevMacVLanCreate()) rather than separately creating the "dummy
tap" (e.g. virbr0-nic) to maintain a fixed mac address on the bridge,
but the commit history of virnetdevbridge.c shows that the presence of
this dummy tap is essential in some older versions of the kernel
(between 2.6.39 and 3.1 or 3.2, possibly?) to proper operation of IPv6
DAD, and I don't want to take the chance of breaking something that I
don't have the time/setup to test (my RHEL6 box is at kernel
2.6.32-544, and the next lowest kernel I have is 3.17)

10 years agoutil: use netlink to delete bridge devices
Laine Stump [Tue, 17 Mar 2015 19:45:01 +0000 (15:45 -0400)]
util: use netlink to delete bridge devices

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

reported that a stray bridge device was left on the system when a
libvirt network failed to start due to an illegal iptables rule caused
by bad config. Apparently the reason this was happening was that
NetworkManager was noticing immediately when the bridge device was
created and automatically setting it IFF_UP. libvirt would then try to
setup the iptables rules, get an error back, and since libvirt had
never IFF_UPed the bridge, it didn't expect that it needed to set it
~IFF_UP before deleting it during the cleanup process. But the
ioctl(SIOCBRDELBR) ioctl will fail to delete a bridge if it is IFF_UP.

Since that bug was reported, NetworkManager has gotten a bit more
polite in this respect, but just in case something similar happens in
the future, this patch switches to using the netlink RTM_DELLINK
message to delete the bridge - unlike SIOCBRDELBR, it will delete the
requested bridge no matter what the setting of IFF_UP.

10 years agoutil: replace body of virNetDevMacVLanDelete() with virNetlinkDelLink()
Laine Stump [Tue, 17 Mar 2015 18:42:24 +0000 (14:42 -0400)]
util: replace body of virNetDevMacVLanDelete() with virNetlinkDelLink()

These two functions are identical, so no sense in having the
duplication. I resisted the temptation to replace calls to
virNetDevMacVLanDelete() with calls to virNetlinkDelLink() just in
case some mythical future platform has macvtap devices that aren't
managed with netlink (or in case we some day need to do more than just
tell the kernel to delete the device).

10 years agoutil: netlink function to delete any network device
Laine Stump [Tue, 17 Mar 2015 18:27:21 +0000 (14:27 -0400)]
util: netlink function to delete any network device

libvirt has always used the netlink RTM_DELLINK message to delete
macvtap/macvlan devices, but it can actually be used to delete other
types of network devices, such as bonds and bridges. This patch makes
virNetDevMacVLanDelete() available as a generic function so it can
intelligibly be called to delete these other types of interfaces.

10 years agomaint: update to latest gnulib
Eric Blake [Tue, 24 Feb 2015 15:58:46 +0000 (08:58 -0700)]
maint: update to latest gnulib

Usual update to latest gnulib status.  In particular this update
fixes at least one issue that can be seen in libvirt, by silencing
a valgrind detection of uninitialized memory:
https://bugzilla.redhat.com/show_bug.cgi?id=1174147

* .gnulib: Update to latest.
* bootstrap: Resync to gnulib.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agoRename DomainGetIOThreadsInfo to DomainGetIOThreadInfo
Ján Tomko [Wed, 25 Mar 2015 16:02:26 +0000 (17:02 +0100)]
Rename DomainGetIOThreadsInfo to DomainGetIOThreadInfo

While it returns info about multiple threads, the version
without the plural is easier to read.

10 years agoRename qemuMonitorIOThreadsInfo* to qemuMonitorIOThreadInfo*
Ján Tomko [Wed, 25 Mar 2015 15:59:37 +0000 (16:59 +0100)]
Rename qemuMonitorIOThreadsInfo* to qemuMonitorIOThreadInfo*

It only deals with a single thread.

10 years agoRename virDomainIOThreadsInfoFree to virDomainIOThreadInfoFree
Ján Tomko [Wed, 25 Mar 2015 15:47:49 +0000 (16:47 +0100)]
Rename virDomainIOThreadsInfoFree to virDomainIOThreadInfoFree

This function only frees the info for one thread.

10 years agovirsh: rename iothreadsinfo to iothreadinfo
Ján Tomko [Wed, 25 Mar 2015 16:15:04 +0000 (17:15 +0100)]
virsh: rename iothreadsinfo to iothreadinfo

The plural seems unnecessary.

10 years agoqemu: command: Fix property name for start address of a pc-dimm module
Luyao Huang [Thu, 26 Mar 2015 06:30:56 +0000 (14:30 +0800)]
qemu: command: Fix property name for start address of a pc-dimm module

Starting a qemu VM with a memory module that has the base address
specified results in the following error:

 error: internal error: early end of file from monitor: possible problem:
 2015-03-26T03:45:52.338891Z qemu-kvm: -device pc-dimm,node=0,memdev=memdimm0,
 id=dimm0,slot=0,base=4294967296: Property '.base' not found

The correct property name for the base address is 'addr'.

Signed-off-by: Luyao Huang <lhuang@redhat.com>
10 years agoqemu: Give hint about -noTSX CPU model
Jiri Denemark [Tue, 24 Mar 2015 13:12:07 +0000 (14:12 +0100)]
qemu: Give hint about -noTSX CPU model

Because of the microcode update to Haswell/Broadwell CPUs, existing
domains using these CPUs may fail to start even though they used to run
just fine. To help users solve this issue we try to suggest switching to
-noTSX variant of the CPU model:

    virsh # start cd
    error: Failed to start domain cd
    error: unsupported configuration: guest and host CPU are not
    compatible: Host CPU does not provide required features: rtm, hle;
    try using 'Haswell-noTSX' CPU model

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
10 years agocpu: Add {Haswell,Broadwell}-noTSX CPU models
Jiri Denemark [Mon, 23 Mar 2015 16:19:28 +0000 (17:19 +0100)]
cpu: Add {Haswell,Broadwell}-noTSX CPU models

QEMU 2.3 adds these new models to cover Haswell and Broadwell CPUs with
updated microcode. Luckily, they also reverted former the machine type
specific changes to existing models. And since these changes were never
released, we don't need to hack around them in libvirt.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
10 years agoqemu: command: Check for empty network source when formatting drive cmd
Peter Krempa [Tue, 24 Mar 2015 15:16:29 +0000 (16:16 +0100)]
qemu: command: Check for empty network source when formatting drive cmd

Use the virStorageSourceIsEmpty helper to determine whether the drive
source is empty rather than checking for src->path. This will fix start
of VM with empty network cdrom that would not report any error.

10 years agoqemu: command: Report error when formatting network source with protocol _NONE
Peter Krempa [Tue, 24 Mar 2015 15:13:41 +0000 (16:13 +0100)]
qemu: command: Report error when formatting network source with protocol _NONE

The function that formats the string for network drives would return
error code but did not set the error message when called on storage
source with VIR_STORAGE_NET_PROTOCOL_LAST or _NONE.

Report an error in this case if it would ever be called in that way.

10 years agobuild: fix race when creating the cpu_map.xml symlink
Amy Fong [Mon, 23 Mar 2015 17:44:03 +0000 (13:44 -0400)]
build: fix race when creating the cpu_map.xml symlink

In some circumstances where the build tree differs from the source,
libvirt's compile will try to create the symlink for cpu_map.xml before
creating the directory $(abs_builddir)/cpu:

'src/cpu/cpu_map.xml': No such file or directory'

Do not create the symlink, it is no longer needed after
commit e562e82f
    Load CPU map from builddir when run uninstalled

Signed-off-by: Amy Fong <amy.fong@windriver.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
10 years agotests: qemuxml2xml: Test status XML formatting and parsing
Peter Krempa [Tue, 24 Mar 2015 12:25:27 +0000 (13:25 +0100)]
tests: qemuxml2xml: Test status XML formatting and parsing

Recently we've fixed a bug where the status XML could not be parsed as
the parser used absolute path XPath queries. This test enhancement tests
all XML files used in the qemu-xml-2-xml test as a part of a status XML
snippet to see whether they are parsed correctly. The status XML-2-XML is
currently tested in 223 cases with this patch.

10 years agoutil: buffer: Add support for adding text blocks with indentation
Peter Krempa [Tue, 24 Mar 2015 09:53:29 +0000 (10:53 +0100)]
util: buffer: Add support for adding text blocks with indentation

The current auto-indentation buffer code applies indentation only on
complete strings. To allow adding a string containing newlines and
having it properly indented this patch adds virBufferAddStr.

10 years agoDon't validata filesystem target type
Guido Günther [Sat, 21 Mar 2015 10:37:12 +0000 (11:37 +0100)]
Don't validata filesystem target type

When using QEMU's 9pfs the target "dir" element is not necessarily an
absolute path but merely an arbitrary identifier. So validation in that
case currently fails with the misleading

   $ virt-xml-validate /tmp/test.xml
   Relax-NG validity error : Extra element devices in interleave
   /tmp/test.xml:24: element devices: Relax-NG validity error : Element domain failed to validate content
   /tmp/test.xml fails to validate

10 years agorpc: Don't unref identity object while callbacks still can be executed
Peter Krempa [Wed, 25 Mar 2015 07:56:07 +0000 (08:56 +0100)]
rpc: Don't unref identity object while callbacks still can be executed

While this thread is cleaning up the client and connection objects:
 #2  virFileReadAll (path=0x7f28780012b0 "/proc/1319/stat", maxlen=maxlen@entry=1024, buf=buf@entry=0x7f289c60fc40) at util/virfile.c:1287
 #3  0x00007f28adbb1539 in virProcessGetStartTime (pid=<optimized out>, timestamp=timestamp@entry=0x7f289c60fc98) at util/virprocess.c:838
 #4  0x00007f28adb91981 in virIdentityGetSystem () at util/viridentity.c:151
 #5  0x00007f28ae73f17c in remoteClientFreeFunc (data=<optimized out>) at remote.c:1131
 #6  0x00007f28adcb7f33 in virNetServerClientDispose (obj=0x7f28aecad180) at rpc/virnetserverclient.c:858
 #7  0x00007f28adba8eeb in virObjectUnref (anyobj=<optimized out>) at util/virobject.c:265
 #8  0x00007f28ae74ad05 in virNetServerHandleJob (jobOpaque=<optimized out>, opaque=0x7f28aec93ff0) at rpc/virnetserver.c:205
 #9  0x00007f28adbbef4e in virThreadPoolWorker (opaque=opaque@entry=0x7f28aec88030) at util/virthreadpool.c:145

In stack frame #6 the client->identity object got unref'd, but the code
that removes the event callbacks in frame #5 did not run yet as we are
trying to obtain the system identity (frames #4, #3, #2).

In other thead:
 #0  virObjectUnref (anyobj=anyobj@entry=0x7f288c162c60) at util/virobject.c:264
        klass = 0xdeadbeef
        obj = 0x7f288c162c60
 #1  0x00007f28ae71c709 in remoteRelayDomainEventCheckACL (client=<optimized out>, conn=<optimized out>, dom=dom@entry=0x7f28aecaafc0) at remote.c:164
 #2  0x00007f28ae71fc83 in remoteRelayDomainEventTrayChange (conn=<optimized out>, dom=0x7f28aecaafc0, ... ) at remote.c:717
 #3  0x00007f28adc04e53 in virDomainEventDispatchDefaultFunc (conn=0x7f287c0009a0, event=0x7f28aecab1a0, ...) at conf/domain_event.c:1455
 #4  0x00007f28adc03831 in virObjectEventStateDispatchCallbacks (callbacks=<optimized out>, ....) at conf/object_event.c:724
 #5  virObjectEventStateQueueDispatch (callbacks=0x7f288c083730, queue=0x7fff51f90030, state=0x7f288c18da20) at conf/object_event.c:738
 #6  virObjectEventStateFlush (state=0x7f288c18da20) at conf/object_event.c:816
 #7  virObjectEventTimer (timer=<optimized out>, opaque=0x7f288c18da20) at conf/object_event.c:562
 #8  0x00007f28adb859cd in virEventPollDispatchTimeouts () at util/vireventpoll.c:459

Frame #0 is unrefing an invalid identity object while frame #2 hints
that the client is still dispatching the event.

For untrimmed backtrace see the bugzilla attachment.

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

10 years agodaemon: Clear fake domain def object that is used to check ACL prior to use
Peter Krempa [Wed, 25 Mar 2015 07:52:26 +0000 (08:52 +0100)]
daemon: Clear fake domain def object that is used to check ACL prior to use

The fake object is used to pass the domain name and UUID to the ACL code
for events where we don't have the full domain def when dispatching
events. The rest of the entries would be left uninitialized. While this
is not a problem code-wise as the used fields are initialized it looks
ugly in the debugger.

10 years agoutil: identity: Harden virIdentitySetCurrent()
Peter Krempa [Wed, 25 Mar 2015 07:25:45 +0000 (08:25 +0100)]
util: identity: Harden virIdentitySetCurrent()

Don't unref the old identity unless we set the new one correctly and
unref the new one on failure to set it so that we don't leak any
references or use invalid pointers.

10 years agotests: qemuxml2xml: Refactor the qemuxml2xml test
Peter Krempa [Mon, 23 Mar 2015 16:24:43 +0000 (17:24 +0100)]
tests: qemuxml2xml: Refactor the qemuxml2xml test

To allow adding more tests, refactor the XML-2-XML test so that the
files are not reloaded always and clarify the control flow.

Result of this changes is that the active and inactive portions of the
XML are tested in separate steps rather than one test step.

10 years agoqemu: domain: Don't leak device alias list
Peter Krempa [Tue, 24 Mar 2015 13:52:11 +0000 (14:52 +0100)]
qemu: domain: Don't leak device alias list

While adding tests for status XML parsing and formatting I've noticed
that the device alias list is leaked.

==763001== 81 (48 direct, 33 indirect) bytes in 1 blocks are definitely lost in loss record 414 of 514
==763001==    at 0x4C2B8F0: calloc (vg_replace_malloc.c:623)
==763001==    by 0x6ACF70F: virAllocN (viralloc.c:191)
==763001==    by 0x447B64: qemuDomainObjPrivateXMLParse (qemu_domain.c:727)
==763001==    by 0x6B848F9: virDomainObjParseXML (domain_conf.c:15491)
==763001==    by 0x6B84CAC: virDomainObjParseNode (domain_conf.c:15608)

10 years agoqemucaps2xmltest: fix test to successfully run without kvm support
Pavel Hrdina [Wed, 25 Mar 2015 09:40:57 +0000 (10:40 +0100)]
qemucaps2xmltest: fix test to successfully run without kvm support

Function virQEMUCapsInitGuestFromBinary detect kvm support by testing
whether /dev/kvm exists or whether we pass path to kvmbin.  Provide the
path we are testing via kvmbin for testing purpose instead of detecting
presence of /dev/kvm to successfully run the tests on all hosts.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
10 years agoqemu: Report better error when memory device source has wrong NUMA node
Luyao Huang [Wed, 25 Mar 2015 06:34:04 +0000 (14:34 +0800)]
qemu: Report better error when memory device source has wrong NUMA node

When starting a VM with hotpluggable memory devices the user may specify
an invalid source NUMA node. Libvirt would pass through the error from
qemu:

 # virsh start test3
 error: Failed to start domain test3
 error: internal error: process exited while connecting to monitor:
 2015-03-25T01:12:17.205913Z qemu-kvm: -object memory-backend-ram,id=memdimm0
 ,size=536870912,host-nodes=1-3,policy=bind: cannot bind memory to host NUMA nodes:
 Invalid argument

This patch adds a check that allows to report better error:

 # virsh start test3
 error: Failed to start domain test3
 error: configuration unsupported: NUMA node 1 is unavailable

Signed-off-by: Luyao Huang <lhuang@redhat.com>
10 years agoutil: NUMA: Change error code in virNumaNodesetIsAvailable()
Peter Krempa [Wed, 25 Mar 2015 09:05:58 +0000 (10:05 +0100)]
util: NUMA: Change error code in virNumaNodesetIsAvailable()

An invalid nodeset is a configuration problem rather than an internal
error.

10 years agoconf: Add missing apostrophe to error message
Luyao Huang [Tue, 24 Mar 2015 14:12:37 +0000 (22:12 +0800)]
conf: Add missing apostrophe to error message

Signed-off-by: Luyao Huang <lhuang@redhat.com>
10 years agoMakefile: fix typo
Pavel Hrdina [Wed, 25 Mar 2015 10:30:38 +0000 (11:30 +0100)]
Makefile: fix typo

Commit 95695388 introduced new util/virthreadjob.c/h files but the
makefile has type that breaks rpm build.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
10 years agodocs: route element must specify network address
Chen Fan [Wed, 25 Mar 2015 03:48:04 +0000 (11:48 +0800)]
docs: route element must specify network address

because network address is required by route, so
here we should add one avoid user misunderstand.

Signed-off-by: Chen Fan <chen.fan.fnst@cn.fujitsu.com>
10 years agodocs: no 'via' attribute in route element
Chen Fan [Wed, 25 Mar 2015 03:48:03 +0000 (11:48 +0800)]
docs: no 'via' attribute in route element

via -> gateway

Signed-off-by: Chen Fan <chen.fan.fnst@cn.fujitsu.com>
10 years agoqemu: Add timing to domain jobs
Jiri Denemark [Mon, 23 Mar 2015 11:46:45 +0000 (12:46 +0100)]
qemu: Add timing to domain jobs

Whenever we fail to acquire a job, we can report how long ago it was
locked by another API.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
10 years agoqemu: Track the API which started the current job
Jiri Denemark [Mon, 16 Mar 2015 17:18:46 +0000 (18:18 +0100)]
qemu: Track the API which started the current job

This is very helpful when we want to log and report why we could not
acquire a state change lock. Reporting what job keeps it locked helps
with understanding the issue. Moreover, after calling
virDomainGetControlInfo, it's possible to tell whether libvirt is just
stuck somewhere within the API (or it just forgot to cleanup the job) or
whether libvirt is waiting for QEMU to reply.

The error message will look like the following:

    # virsh resume cd
    error: Failed to resume domain cd
    error: Timed out during operation: cannot acquire state change lock
    (held by remoteDispatchDomainSuspend)

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
10 years agoSet thread job for every RPC call
Jiri Denemark [Wed, 11 Mar 2015 12:58:42 +0000 (13:58 +0100)]
Set thread job for every RPC call

Since all APIs are also RPC calls, we automatically get all APIs covered
with thread jobs.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
10 years agovirThreadPool: Set thread worker name
Jiri Denemark [Fri, 20 Mar 2015 16:44:25 +0000 (17:44 +0100)]
virThreadPool: Set thread worker name

Every thread created as a worker thread within a pool gets a name
according to virThreadPoolJobFunc name.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
10 years agovirThread: Set thread job
Jiri Denemark [Fri, 20 Mar 2015 16:43:55 +0000 (17:43 +0100)]
virThread: Set thread job

Automatically assign a job to every thread created by virThreadCreate.
The name of the virThreadFunc function passed to virThreadCreate is used
as the job or worker name in case no name is explicitly passed.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
10 years agoForce usage of virThreadCreate
Jiri Denemark [Fri, 20 Mar 2015 15:25:15 +0000 (16:25 +0100)]
Force usage of virThreadCreate

We want all threads to be set as workers or to have a job assigned to
them, which can easily be achieved in virThreadCreate wrapper to
pthread_create. Let's make sure we always use the wrapper.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
10 years agoAdd support for tracking thread jobs
Jiri Denemark [Mon, 8 Jul 2013 10:27:34 +0000 (12:27 +0200)]
Add support for tracking thread jobs

Each thread can use a thread local variable to keep the name of a job
which is currently running in the job.

The virThreadJobSetWorker API is supposed to be called once by any
thread which is used as a worker, i.e., it is waiting in a pool, woken
up to do a job, and returned back to the pool.

The virThreadJobSet/virThreadJobClear APIs are to be called at the
beginning/end of each job.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
10 years agoPOTFILES.in: Sort
Jiri Denemark [Wed, 11 Mar 2015 09:24:09 +0000 (10:24 +0100)]
POTFILES.in: Sort

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
10 years agoDocument that USB hostdevs do not need nodeDettach
Ján Tomko [Fri, 20 Mar 2015 09:25:13 +0000 (10:25 +0100)]
Document that USB hostdevs do not need nodeDettach

The virNodeDeviceDettach API only works on PCI devices.

Originally added by commit 10d3272e, but the API never
supported USB devices.

Reported by: Martin Polednik <mpolednik@redhat.com>

10 years agorpc: serverclient: Clear pointer with NULL instead of 0
Peter Krempa [Wed, 25 Mar 2015 07:11:12 +0000 (08:11 +0100)]
rpc: serverclient: Clear pointer with NULL instead of 0

10 years agolibxl: remove per-domain libxl_ctx
Jim Fehlig [Wed, 11 Feb 2015 23:40:07 +0000 (16:40 -0700)]
libxl: remove per-domain libxl_ctx

Although needed in the Xen 4.1 libxl days, there is no longer any
benefit to having per-domain libxl_ctx.  On the contrary, their use
makes the code unecessarily complicated and prone to deadlocks under
load.  As suggested by the libxl maintainers, use a single libxl_ctx
as a handle to libxl instead of per-domain ctx's.

One downside to using a single libxl_ctx is there are no longer
per-domain log files for log messages emitted by libxl.  Messages
for all domains will be sent to /var/log/libvirt/libxl/libxl-driver.log.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
10 years agolibxl: make libxlDomainFreeMem static
Jim Fehlig [Wed, 11 Feb 2015 21:47:42 +0000 (14:47 -0700)]
libxl: make libxlDomainFreeMem static

libxlDomainFreeMem() is only used in libxl_domain.c and thus should
be declared static.  While at it, change the signature to take a
libxl_ctx instead of libxlDomainObjPrivatePtr, since only the
libxl_ctx is needed.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
10 years agolibxl: remove unnecessary libxlDomainEventsRegister
Jim Fehlig [Thu, 12 Feb 2015 19:02:27 +0000 (12:02 -0700)]
libxl: remove unnecessary libxlDomainEventsRegister

This function now only enables domain death events.  Simply call
libxl_evenable_domain_death() instead of an unnecessary wrapper.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
10 years agolibxl: use global libxl_ctx in event handler
Jim Fehlig [Wed, 11 Feb 2015 22:22:05 +0000 (15:22 -0700)]
libxl: use global libxl_ctx in event handler

Change the domain event handler code to use the driver-wide
libxl_ctx instead of the domain-specific one.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
10 years agolibxl: move event registration to driver initialization
Jim Fehlig [Thu, 12 Feb 2015 18:37:46 +0000 (11:37 -0700)]
libxl: move event registration to driver initialization

Register a domain event handler with the driver-wide libxl_ctx
during driver initialization.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
10 years agolibxl: Move setup of child processing code to driver initialization
Jim Fehlig [Mon, 2 Feb 2015 23:19:34 +0000 (16:19 -0700)]
libxl: Move setup of child processing code to driver initialization

Informing libxl how to handle its child proceses should be done once
during driver initialization, not once for each domain-specific
libxl_ctx object.  The related libxl documentation in
$xen-src/tools/libxl/libxl_event.h even mentions that "it is best to
call this at initialisation".

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
10 years agolibxl: use driver-wide ctx in fd and timer event handling
Jim Fehlig [Mon, 2 Feb 2015 21:12:58 +0000 (14:12 -0700)]
libxl: use driver-wide ctx in fd and timer event handling

Long ago I incorrectly associated libxl fd and timer registrations
with per-domain libxl_ctx objects.  When creating a libxlDomainObjPrivate,
a libxl_ctx is allocated, and libxl_osevent_register_hooks is called
passing a pointer to the libxlDomainObjPrivate.  When an fd or timer
registration occurred, the registration callback received the
libxlDomainObjPrivate, containing the per-domain libxl_ctx.  This
libxl_ctx was then used when informing libxl about fd events or
timer expirations.

The problem with this approach is that fd and timer registrations do not
share the same lifespan as libxlDomainObjPrivate, and hence the per-domain
libxl_ctx ojects.  The result is races between per-domain libxl_ctx's being
destoryed and events firing on associated fds/timers, typically manifesting
as an assert in libxl

libxl_internal.h:2788: libxl__ctx_unlock: Assertion `!r' failed

There is no need to associate libxlDomainObjPrivate objects with libxl's
desire to use libvirt's event loop.  Instead, the driver-wide libxl_ctx can
be used for the fd and timer registrations.

This patch moves the fd and timer handling code away from the
domain-specific code in libxl_domain.c into libxl_driver.c.  While at it,
function names were changed a bit to better describe their purpose.

The unnecessary locking was also removed since the code simply provides a
wrapper over the event loop interface.  Indeed the locks may have been
causing some deadlocks when repeatedly creating/destroying muliple domains.
There have also been rumors about such deadlocks during parallel OpenStack
Tempest runs.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
10 years agoqemu: fix set vcpus on host without NUMA
Pavel Hrdina [Fri, 20 Mar 2015 14:01:53 +0000 (15:01 +0100)]
qemu: fix set vcpus on host without NUMA

We don't have to modify cpuset.mems on hosts without NUMA.  It also
fixes an error message that you get instead of success if you trying
update vcpus of a guest on a host without NUMA.

error: internal error: NUMA isn't available on this host

Signer-off-by: Pavel Hrdina <phrdina@redhat.com>
10 years agoqemu: cleanup setvcpus
Pavel Hrdina [Tue, 24 Mar 2015 17:22:27 +0000 (18:22 +0100)]
qemu: cleanup setvcpus

Remove unnecessary maximum variable.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
10 years agoqemu: move virDomainLiveConfigHelperMethod right after BeginJob
Pavel Hrdina [Tue, 24 Mar 2015 17:14:12 +0000 (18:14 +0100)]
qemu: move virDomainLiveConfigHelperMethod right after BeginJob

We should call virDomainLiveConfigHelperMethod ASAP because this
function transfers VIR_DOMAIN_AFFECT_CURRENT to VIR_DOMAIN_AFFECT_LIVE
or VIR_DOMAIN_AFFECT_CONFIG.  All other additional checks for those two
flags should consider that the user give us VIR_DOMAIN_AFFECT_CURRENT.

Remove the unnecessary check whether the domain is live in case of
VIR_DOMAIN_VCPU_GUEST because this check is done by
virDomainLiveConfigHelperMethod.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
10 years agoDocument behavior of compat when creating qcow2 volumes
Ján Tomko [Tue, 24 Mar 2015 16:13:24 +0000 (17:13 +0100)]
Document behavior of compat when creating qcow2 volumes

Commit bab2eda changed the behavior for missing compat attribute,
but failed to update the documentation.

Before, the option was omitted from qemu-img command line and the
qemu-img default was used. Now we always specify the compat value
and the default is 0.10.

Reported by Christophe Fergeau
https://bugzilla.gnome.org/show_bug.cgi?id=746660#c4

10 years agoFix typo in error message
Ján Tomko [Mon, 16 Mar 2015 14:55:21 +0000 (15:55 +0100)]
Fix typo in error message

by rewriting it completely from:
error: unsupported configuration: virtio only support device address
type 'PCI'

to:

error: unsupported configuration: virtio disk cannot have an address of type
drive

Since we now support CCW addresses as well.

10 years agoqemu: change accidental VIR_WARNING back to VIR_DEBUG
Laine Stump [Tue, 24 Mar 2015 14:45:09 +0000 (10:45 -0400)]
qemu: change accidental VIR_WARNING back to VIR_DEBUG

While debugging the support for responding to qemu RX_FILTER_CHANGED
events, I had changed the "ignoring this event" log message from
VIR_DEBUG to VIR_WARN, but forgot to change it back before
pushing. Since many guest OSes make enough changes to multicast lists
and/or promiscuous mode settings to trigger this message, it's
starting to show up as a red herring in bug reports.

10 years agoqemucaps2xmltest: fix the test to correspond to new domain formatting
Pavel Hrdina [Tue, 24 Mar 2015 14:22:16 +0000 (15:22 +0100)]
qemucaps2xmltest: fix the test to correspond to new domain formatting

Commit 2360fe5d updated formating of <domain> element but forgot to
update qemucaps2xmldata xml files.  In addition the test code was broken
too.  Update the xml files and return -1 if testCompareXMLToXML fails
together with indentation fix.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
10 years agoconf: fix parsing of NUMA settings in VM status XML
Luyao Huang [Thu, 19 Mar 2015 10:13:04 +0000 (18:13 +0800)]
conf: fix parsing of NUMA settings in VM status XML

Commit 5bba61f changed the XPath strings to be absolute when parsing
the VM NUMA configuration. Unfortunately the <domain> element is not a
top level element when parsing the domain status XML thus the absolute
XPath string doesn't match.

Use the relative string so that the <numa> settings are not lost.

Signed-off-by: Luyao Huang <lhuang@redhat.com>
10 years agoqemu: Implement memory device hotunplug
Peter Krempa [Wed, 21 Jan 2015 16:45:54 +0000 (17:45 +0100)]
qemu: Implement memory device hotunplug

Add code to hot-remove memory devices from qemu. Unfortunately QEMU
doesn't support this right now, so this is just for completenes.

10 years agoqemu: Implement memory device hotplug
Peter Krempa [Sun, 12 Oct 2014 22:28:58 +0000 (00:28 +0200)]
qemu: Implement memory device hotplug

Add code to hot-add memory devices to running qemu instances.

10 years agoqemu: conf: Add support for memory device cold(un)plug
Peter Krempa [Wed, 21 Jan 2015 14:49:44 +0000 (15:49 +0100)]
qemu: conf: Add support for memory device cold(un)plug

Add a few helpers that allow to operate with memory device definitions
on the domain config and use them to implement memory device coldplug in
the qemu driver.

10 years agoqemu: add support for memory devices
Peter Krempa [Fri, 9 Jan 2015 09:40:37 +0000 (10:40 +0100)]
qemu: add support for memory devices

Add support to start qemu instance with 'pc-dimm' device. Thanks to the
refactors we are able to reuse the existing function to determine the
parameters.

10 years agoqemu: migration: Forbid migration with memory modules lacking info
Peter Krempa [Mon, 19 Jan 2015 13:28:14 +0000 (14:28 +0100)]
qemu: migration: Forbid migration with memory modules lacking info

Make sure that libvirt has all vital information needed to reliably
represent configuration of guest's memory devices in case of a
migration.

This patch forbids migration in case the required slot number and module
base address are not present (failed to be loaded from qemu via
monitor).

10 years agoqemu: memdev: Add infrastructure to load memory device information
Peter Krempa [Mon, 19 Jan 2015 12:21:09 +0000 (13:21 +0100)]
qemu: memdev: Add infrastructure to load memory device information

When using 'dimm' memory devices with qemu, some of the information
like the slot number and base address need to be reloaded from qemu
after process start so that it reflects the actual state. The state then
allows to use memory devices across migrations.

10 years agoconf: Add interface to parse and format memory device information
Peter Krempa [Mon, 29 Sep 2014 17:02:04 +0000 (19:02 +0200)]
conf: Add interface to parse and format memory device information

This patch adds code that parses and formats configuration for memory
devices.

A simple configuration would be:
<memory model='dimm'>
  <target>
    <size unit='KiB'>524287</size>
    <node>0</node>
  </target>
</memory>

A complete configuration of a memory device:
<memory model='dimm'>
  <source>
    <pagesize unit='KiB'>4096</pagesize>
    <nodemask>1-3</nodemask>
  </source>
  <target>
    <size unit='KiB'>524287</size>
    <node>1</node>
  </target>
</memory>

This patch preemptively forbids use of the <memory> device in individual
drivers so the users are warned right away that the device is not
supported.

10 years agoconf: Add device address type for dimm devices
Peter Krempa [Tue, 7 Oct 2014 16:11:47 +0000 (18:11 +0200)]
conf: Add device address type for dimm devices

Dimm devices are described by the slot and base address. Add a new
address type to be able to describe such address.

10 years agoqemu: Implement setup of memory hotplug parameters
Peter Krempa [Mon, 6 Oct 2014 12:18:37 +0000 (14:18 +0200)]
qemu: Implement setup of memory hotplug parameters

To enable memory hotplug the maximum memory size and slot count need to
be specified. As qemu supports now other units than mebibytes when
specifying memory, use the new interface in this case.

10 years agoconf: Add support for parsing and formatting max memory and slot count
Peter Krempa [Mon, 11 Aug 2014 15:40:32 +0000 (17:40 +0200)]
conf: Add support for parsing and formatting max memory and slot count

Add a XML element that will allow to specify maximum supportable memory
and the count of memory slots to use with memory hotplug.

To avoid possible confusion and misuse of the new element this patch
also explicitly forbids the use of the maxMemory setting in individual
drivers's post parse callbacks. This limitation will be lifted when the
support is implemented.

10 years agolibxl: Refactor logic in domain post parse callback
Peter Krempa [Mon, 16 Mar 2015 14:33:45 +0000 (15:33 +0100)]
libxl: Refactor logic in domain post parse callback

With the current control flow the post parse callback returned success
right away for fully virtualized VMs. To allow adding additional checks
into the post parse callback tweak the conditions so that the function
doesn't return early except for error cases.

To clarify the original piece of code borrow the wording from the commit
message for the patch that introduced the code.

10 years agoqemu: monitor: Don't leak @props with non-JSON in qemuMonitorAddObject
Peter Krempa [Mon, 16 Mar 2015 14:25:58 +0000 (15:25 +0100)]
qemu: monitor: Don't leak @props with non-JSON in qemuMonitorAddObject

The function comment states that @props is always consumed, even on
failure. This was not true with the failure if the monitor is not using
QMP.

10 years agoqemu: Don't return memory device config on error in qemuBuildMemoryBackendStr
Peter Krempa [Mon, 23 Mar 2015 13:17:42 +0000 (14:17 +0100)]
qemu: Don't return memory device config on error in qemuBuildMemoryBackendStr

In the last section if the function determines that the config is
invalid when QEMU doesn't support the memory device the JSON config
object would be returned even if it doesn't make sense.

Assign the object to be returned only on success.

10 years agoqemu: Set default SCSI controller model for S390 arch
Boris Fiuczynski [Fri, 20 Mar 2015 15:01:10 +0000 (16:01 +0100)]
qemu: Set default SCSI controller model for S390 arch

When no model is specified in the domain definition for
a scsi controller and the architectur is s390 than virtio-scsi
is set as default model.

Signed-off-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Reviewed-by: Daniel Hansel <daniel.hansel@linux.vnet.ibm.com>
Reviewed-by: Stefan Zimmermann <stzi@linux.vnet.ibm.com>
Reviewed-by: Jens Freimann <jfrei@linux.vnet.ibm.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoFix underlinking of libvirt_driver_interface.so
Natanael Copa [Mon, 23 Mar 2015 09:11:14 +0000 (10:11 +0100)]
Fix underlinking of libvirt_driver_interface.so

Always add udev linker flags when WITH_UDEV is enabled to avoid
underlinking.

See commit 43dbcb15 (interface: always build all available backends)

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
10 years agoqemu: skip precreation of network disks
Michael Chapman [Fri, 13 Mar 2015 00:34:58 +0000 (11:34 +1100)]
qemu: skip precreation of network disks

Commit cf54c60699833b3791a5d0eb3eb5a1948c267f6b introduced the ability
to create missing storage volumes during migration. For network disks,
however, we may not necessarily be able to detect whether they already
exist -- there is no straight-forward way to map the disk to a storage
volume, and even if there were it's possible no configured storage pool
actually contains the disk.

It is better to assume the network disk exists in this case, rather than
aborting the migration completely. If the volume really is missing, QEMU
will generate an appropriate error later in the migration.

Signed-off-by: Michael Chapman <mike@very.puzzling.org>
10 years agonetwork_conf: Drop virNetworkObjIsDuplicate
Michal Privoznik [Sat, 14 Mar 2015 10:18:21 +0000 (11:18 +0100)]
network_conf: Drop virNetworkObjIsDuplicate

This function does not make any sense now, that network driver is
(almost) dropped. I mean, previously, when threads were
serialized, this function was there to check, if no other network
with the same name or UUID exists. However, nowadays that threads
can run more in parallel, this function is useless, in fact it
gives misleading return values. Consider the following scenario.
Two threads, both trying to define networks with same name but
different UUID (e.g. because it was generated during XML parsing
phase, whatever). Lets assume that both threads are about to call
networkValidate() which immediately calls
virNetworkObjIsDuplicate().

T1: calls virNetworkObjIsDuplicate() and since no network with
given name or UUID exist, success is returned.
T2: calls virNetworkObjIsDuplicate() and since no network with
given name or UUID exist, success is returned.

T1: calls virNetworkAssignDef() and successfully places its
network into the virNetworkObjList.
T2: calls virNetworkAssignDef() and since network with the same
name exists, the network definition is replaced.

Okay, this is mainly because virNetworkAssignDef() does not check
whether name and UUID matches. Well, lets make it so! And drop
useless function too.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoobjecteventtest: Check for virNetwork* return values
Michal Privoznik [Mon, 16 Mar 2015 15:01:45 +0000 (16:01 +0100)]
objecteventtest: Check for virNetwork* return values

Lets not give a bad example and check for return values of
virNetwork* APIs called within the test. Even though it's
unlikely that any API will fail, it can happen. We're connected
to the test driver after all, and our API sequence is correct. So
test driver should fail only in case of bug or OOM.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agonetworkStateInitialize: Don't lock network driver
Michal Privoznik [Fri, 13 Mar 2015 15:47:06 +0000 (16:47 +0100)]
networkStateInitialize: Don't lock network driver

There's no need to lock the network driver, as network driver
initialization is done prior accepting any client. There's nobody
to hop in and do something over partially initialized driver. Nor
qemu driver is doing that.

==30532== Observed (incorrect) order is: acquisition of lock at 0x1439EF50
==30532==    at 0x4C31A26: pthread_mutex_lock (in /usr/lib64/valgrind/vgpreload_helgrind-amd64-linux.so)
==30532==    by 0x5324895: virMutexLock (virthread.c:88)
==30532==    by 0x5307E86: virObjectLock (virobject.c:323)
==30532==    by 0x5396440: virNetworkObjListForEach (network_conf.c:4511)
==30532==    by 0x19B29308: networkStateInitialize (bridge_driver.c:686)
==30532==    by 0x53E1CCC: virStateInitialize (libvirt.c:777)
==30532==    by 0x11DEB7: daemonRunStateInit (libvirtd.c:906)
==30532==    by 0x5324B6A: virThreadHelper (virthread.c:197)
==30532==    by 0x4C30456: ??? (in /usr/lib64/valgrind/vgpreload_helgrind-amd64-linux.so)
==30532==    by 0xA1EC1F2: start_thread (in /lib64/libpthread-2.19.so)
==30532==    by 0xA4EDC8C: clone (in /lib64/libc-2.19.so)
==30532==
==30532==  followed by a later acquisition of lock at 0x1439CD60
==30532==    at 0x4C31A26: pthread_mutex_lock (in /usr/lib64/valgrind/vgpreload_helgrind-amd64-linux.so)
==30532==    by 0x5324895: virMutexLock (virthread.c:88)
==30532==    by 0x19B27B2C: networkDriverLock (bridge_driver.c:102)
==30532==    by 0x19B27B60: networkGetDnsmasqCaps (bridge_driver.c:113)
==30532==    by 0x19B2856A: networkUpdateState (bridge_driver.c:389)
==30532==    by 0x53963E9: virNetworkObjListForEachHelper (network_conf.c:4488)
==30532==    by 0x52E2224: virHashForEach (virhash.c:521)
==30532==    by 0x539645B: virNetworkObjListForEach (network_conf.c:4512)
==30532==    by 0x19B29308: networkStateInitialize (bridge_driver.c:686)
==30532==    by 0x53E1CCC: virStateInitialize (libvirt.c:777)
==30532==    by 0x11DEB7: daemonRunStateInit (libvirtd.c:906)
==30532==    by 0x5324B6A: virThreadHelper (virthread.c:197)
==30532==
==30532== Required order was established by acquisition of lock at 0x1439CD60
==30532==    at 0x4C31A26: pthread_mutex_lock (in /usr/lib64/valgrind/vgpreload_helgrind-amd64-linux.so)
==30532==    by 0x5324895: virMutexLock (virthread.c:88)
==30532==    by 0x19B27B2C: networkDriverLock (bridge_driver.c:102)
==30532==    by 0x19B28DF9: networkStateInitialize (bridge_driver.c:609)
==30532==    by 0x53E1CCC: virStateInitialize (libvirt.c:777)
==30532==    by 0x11DEB7: daemonRunStateInit (libvirtd.c:906)
==30532==    by 0x5324B6A: virThreadHelper (virthread.c:197)
==30532==    by 0x4C30456: ??? (in /usr/lib64/valgrind/vgpreload_helgrind-amd64-linux.so)
==30532==    by 0xA1EC1F2: start_thread (in /lib64/libpthread-2.19.so)
==30532==    by 0xA4EDC8C: clone (in /lib64/libc-2.19.so)
==30532==
==30532==  followed by a later acquisition of lock at 0x1439EF50
==30532==    at 0x4C31A26: pthread_mutex_lock (in /usr/lib64/valgrind/vgpreload_helgrind-amd64-linux.so)
==30532==    by 0x5324895: virMutexLock (virthread.c:88)
==30532==    by 0x5307E86: virObjectLock (virobject.c:323)
==30532==    by 0x538A09C: virNetworkAssignDef (network_conf.c:527)
==30532==    by 0x5391EB2: virNetworkLoadState (network_conf.c:3008)
==30532==    by 0x53922D4: virNetworkLoadAllState (network_conf.c:3128)
==30532==    by 0x19B2929A: networkStateInitialize (bridge_driver.c:671)
==30532==    by 0x53E1CCC: virStateInitialize (libvirt.c:777)
==30532==    by 0x11DEB7: daemonRunStateInit (libvirtd.c:906)
==30532==    by 0x5324B6A: virThreadHelper (virthread.c:197)
==30532==    by 0x4C30456: ??? (in /usr/lib64/valgrind/vgpreload_helgrind-amd64-linux.so)
==30532==    by 0xA1EC1F2: start_thread (in /lib64/libpthread-2.19.so)

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoFix common misspellings
Martin Kletzander [Thu, 19 Mar 2015 15:53:00 +0000 (16:53 +0100)]
Fix common misspellings

Wikipedia's list of common misspellings [1] has a machine-readable
version.  This patch fixes those misspellings mentioned in the list
which don't have multiple right variants (as e.g. "accension", which can
be both "accession" and "ascension"), such misspellings are left
untouched.  The list of changes was manually re-checked for false
positives.

[1] https://en.wikipedia.org/wiki/Wikipedia:Lists_of_common_misspellings/For_machines

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agoqemu: Migrate memory on numatune change
Martin Kletzander [Wed, 11 Mar 2015 10:17:15 +0000 (11:17 +0100)]
qemu: Migrate memory on numatune change

We've never set the cpuset.memory_migrate value to anything, keeping it
on default.  However, we allow changing cpuset.mems on live domain.
That setting, however, don't have any consequence on a domain unless
it's going to allocate new memory.

I managed to make 'virsh numatune' move all the memory to any node I
wanted even without disabling libnuma's numa_set_membind(), so this
should be safe to use with it as well.

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agocgroup: Add accessors for cpuset.memory_migrate
Martin Kletzander [Wed, 11 Mar 2015 10:15:29 +0000 (11:15 +0100)]
cgroup: Add accessors for cpuset.memory_migrate

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agomaint: update .mailmap for recent contributions
Eric Blake [Fri, 20 Mar 2015 12:16:01 +0000 (06:16 -0600)]
maint: update .mailmap for recent contributions

Deepak Shetty has changed preferred email address since prior
contributions.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agolibxl: use xenlight pkgconfig file if present
Jim Fehlig [Tue, 17 Mar 2015 20:10:28 +0000 (14:10 -0600)]
libxl: use xenlight pkgconfig file if present

xen.git commit babeca32 added a pkgconfig file for libxenlight,
allowing libxl apps to determine the location of Xen binaries
such as firmware blobs, device emulator, etc.

This patch adds support for xenlight.pc in the libxl driver, falling
back to the previous configure logic if not found.  It introduces
LIBXL_FIRMWARE_DIR and LIBXL_EXECBIN_DIR to define the firmware and
libexec_bin locations.  If xenlight.pc does not exist, the defines
are set to the current hardcoded paths.  The capabilities'
<emulator> and <loader> elements are updated to use the paths.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
10 years agoparallels: fix libvirt crash if parallelsNetworkOpen fails
Maxim Nestratov [Thu, 19 Mar 2015 14:43:21 +0000 (17:43 +0300)]
parallels: fix libvirt crash if parallelsNetworkOpen fails

If, by any reason, parallelsNetworkOpen fails it dereferences
newly allocated privconn->networks via virObjectUnref, which in
turn deallocates its memory.
Subsequent call of parallelsNetworkClose calls virObjectUnref
that leads to double memory free. To prevent this we should zero
privconn->networks to make all subsequent virObjectUnref be safe.

Signed-off-by: Maxim Nestratov <mnestratov@parallels.com>
10 years agoqemu: do not overwrite the error in qemuDomainObjExitMonitor
Luyao Huang [Thu, 19 Mar 2015 03:14:39 +0000 (11:14 +0800)]
qemu: do not overwrite the error in qemuDomainObjExitMonitor

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

When qemu exits during startup, libvirt includes the error from
/var/log/libvirt/qemu/vm.log in the error message:

$ virsh start test3
error: Failed to start domain test3
error: internal error: early end of file from monitor: possible problem:
2015-02-27T03:03:16.985494Z qemu-kvm: -numa memdev is not supported by
machine rhel6.5.0

The check for domain liveness added to qemuDomainObjExitMonitor
in commit dc2fd51f sometimes overwrites this error:
$ virsh start test3
error: Failed to start domain test3
error: operation failed: domain is no longer running

Fix the check to only report an error if there is none set.

Signed-off-by: Luyao Huang <lhuang@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
10 years agolibxl: Don't overwrite errors from xenconfig
Jim Fehlig [Wed, 18 Mar 2015 20:53:45 +0000 (14:53 -0600)]
libxl: Don't overwrite errors from xenconfig

When converting domXML from native, the libxl driver was overwriting
useful errors from the xenconfig parsing code with a useless, generic
error.  E.g. "internal error: parsing xm config failed" vs
"internal error: config value usbdevice was malformed".  Remove the
redundant (and useless) error reporting in the libxl driver.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
10 years agoqemu: Fix two issues in qemuDomainSetVcpus error handling
John Ferlan [Wed, 18 Mar 2015 11:10:54 +0000 (07:10 -0400)]
qemu: Fix two issues in qemuDomainSetVcpus error handling

Issue #1 - A call to virBitmapNew did not check if the allocation
failed which could lead to a NULL dereference

Issue #2 - When deleting the pin entries from the config file, the
code loops from the number of elements down to the "new" vcpu count;
however, the pin id values are numbered 0..n-1 not 1..n, so the "first"
pin attempt would never work. Luckily the check was for whether the
incoming 'n' (vcpu id) matched the entry in the array from 0..arraysize
rather than a dereference of the 'n' entry

10 years agodoc: Fix doc for backingStore
Deepak Shetty [Wed, 18 Mar 2015 13:48:22 +0000 (19:18 +0530)]
doc: Fix doc for backingStore

I spent quite some time figuring that backingStore info
isn't included in the dom xml, unless guest is up and
running. Hopefully putting that in the doc should help.

Also, several people have complained that libvirt reports
a backing file as raw, even though they expected it to be
qcow2; where the culprit is usually the user forgetting to
create the file with qemu-img create -o backing_fmt=qcow2.

This patch adds that info to the doc.

Signed-off-by: Deepak C Shetty <deepakcs@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agoqemu: track 'cancelling' migration state
Eric Blake [Fri, 6 Mar 2015 16:30:14 +0000 (09:30 -0700)]
qemu: track 'cancelling' migration state

In qemu 2.3, the migration status will include 'cancelling' in the
window between when an asynchronous cancel has been requested and
when the migration is actually halted.  Previously, qemu hid this
state and reported 'active'.  Libvirt manages the sequence okay
even when the string is unrecognized (that is, it will report an
unknown state:

Migration: [ 69 %]^Cerror: internal error: unexpected migration status in cancelling.

but the migration is still cancelled), but recognizing the string
makes for a smoother user experience.

* src/qemu/qemu_monitor.h
(QEMU_MONITOR_MIGRATION_STATUS_CANCELLING): Add enum.
* src/qemu/qemu_monitor.c (qemuMonitorMigrationStatus): Map it.
* src/qemu/qemu_migration.c (qemuMigrationUpdateJobStatus): Adjust
clients.
* src/qemu/qemu_monitor_json.c
(qemuMonitorJSONGetMigrationStatusReply): Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agoutil: more verbose error when failing to create macvtap device
Laine Stump [Wed, 18 Mar 2015 18:27:05 +0000 (14:27 -0400)]
util: more verbose error when failing to create macvtap device

Investigation of a problem with creating passthrough macvtap devices
(https://bugzilla.redhat.com/show_bug.cgi?id=1185501) has shown that
this slightly more verbose failure message is useful. In particular,
the mac address can be used to determine the domain. You could also
figure this out by looking at preceding messages in a debug log, but
this gets it in a single place.

10 years agoutil: clean up #includes of virnetdevopenvswitch.h
Laine Stump [Tue, 17 Mar 2015 17:46:44 +0000 (13:46 -0400)]
util: clean up #includes of virnetdevopenvswitch.h

virnetdevopenvswitch.h declares a few functions that can be called to
add ports to and remove them from OVS bridges, and retrieve the
migration data for a port. It does not contain any data definitions
that are used by domain_conf.h. But for some reason, domain_conf.h
virnetdevopenvswitch.h should be directly #including it. This adds a
few lines to the project, but saves all the files that don't need it
from the extra computing, and makes the dependencies more clear cut.

10 years agoutil: vhost user: support for bootindex
zhang bo [Fri, 13 Mar 2015 09:17:46 +0000 (17:17 +0800)]
util: vhost user: support for bootindex

Problem Description:
When we set boot order for a vhost-user network interface, we found the boot index
doesn't work.

Cause of the Problem:
In the function qemuBuildVhostuserCommandLine(), it forcely set the arg bootindex of
function qemuBuildNicDevStr() to 0. Thus, the bootindex parameter got missing.

Solution:
Trans the arg bootindex down.

Signed-off-by: Gao Haifeng <gaohaifeng.gao@huawei.com>
Signed-off-by: Zhang Bo <oscar.zhangbo@huawei.com>
10 years agoparallels: don't prevent domain define if VIR_DOMAIN_NET_TYPE_BRIDGE
Maxim Nestratov [Wed, 18 Mar 2015 08:33:57 +0000 (11:33 +0300)]
parallels: don't prevent domain define if VIR_DOMAIN_NET_TYPE_BRIDGE

network adapter is used

10 years agoparallels: switch off offline management feature
Maxim Nestratov [Wed, 18 Mar 2015 08:33:56 +0000 (11:33 +0300)]
parallels: switch off offline management feature

which is on by default when a new VM/CT is created.
We should do this because this feature can't be controlled
by libvirt now and it sets up some iptables rules. So it's
better to do this to avoid potential conflict of different
set of rules or to avoid unexpected behavior.

Signed-off-by: Maxim Nestratov <mnestratov@parallels.com>