Commit Graph

19251 Commits

Author SHA1 Message Date
Michal Privoznik
149a62bc83 virCgroupNew: Enhance debug message
When creating new internal representation of cgroups, all passed
arguments are logged. Well, except for two: pid and pointer for
return value. Lets log them too.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-03-30 15:20:24 +02:00
Michal Privoznik
0a09bcdc7f virCgroupNewPartition: Fix comment
The function has no argument named @name rather than @path
instead.  The comment is, however, referring to @name while it
should have been referring to @path really.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-03-30 15:20:20 +02:00
Eric Blake
75d56f51f7 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>
2015-03-28 14:12:55 -06:00
John Ferlan
cf6ab17e45 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.
2015-03-27 18:09:07 -04:00
John Ferlan
38efd52584 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
2015-03-27 18:09:07 -04:00
Pavel Hrdina
eb05cb0d5c 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>
2015-03-27 16:55:33 +01:00
Pavel Hrdina
a894d61ba1 Revert "qemucaps2xmltest: fix test to successfully run without kvm support"
This reverts commit 49bf09d16c.  That
commit is wrong and doesn't fix the issue.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2015-03-27 16:55:33 +01:00
Pavel Hrdina
0614976bc9 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>
2015-03-27 11:06:05 +01:00
Shanzhi Yu
c5fbad6623 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>
2015-03-27 10:30:50 +01:00
Wei Huang
c13de01691 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>
2015-03-27 10:20:56 +01:00
Eric Blake
dfc708750b 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>
2015-03-26 16:57:26 -06:00
Konrad Rzeszutek Wilk
95003cd511 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>
2015-03-26 14:22:36 -06:00
Laine Stump
fc7b23db02 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)
2015-03-26 15:33:05 -04:00
Laine Stump
09778e0908 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.
2015-03-26 15:31:34 -04:00
Laine Stump
e849062a64 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).
2015-03-26 15:30:46 -04:00
Laine Stump
0473b45cc1 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.
2015-03-26 15:29:42 -04:00
Eric Blake
df60346ca2 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>
2015-03-26 09:41:55 -06:00
Ján Tomko
a96b68e7a4 Rename DomainGetIOThreadsInfo to DomainGetIOThreadInfo
While it returns info about multiple threads, the version
without the plural is easier to read.
2015-03-26 16:11:10 +01:00
Ján Tomko
9e48f6cf9f Rename qemuMonitorIOThreadsInfo* to qemuMonitorIOThreadInfo*
It only deals with a single thread.
2015-03-26 16:11:10 +01:00
Ján Tomko
cf8b828a72 Rename virDomainIOThreadsInfoFree to virDomainIOThreadInfoFree
This function only frees the info for one thread.
2015-03-26 16:11:10 +01:00
Ján Tomko
fa67489d76 virsh: rename iothreadsinfo to iothreadinfo
The plural seems unnecessary.
2015-03-26 13:49:49 +01:00
Luyao Huang
a0bbdcd788 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>
2015-03-26 09:22:21 +01:00
Jiri Denemark
53c8062f7e 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>
2015-03-26 09:20:00 +01:00
Jiri Denemark
c563b50605 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>
2015-03-26 09:19:59 +01:00
Peter Krempa
82f349a3a8 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.
2015-03-26 08:24:46 +01:00
Peter Krempa
df9361859d 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.
2015-03-26 08:24:46 +01:00
Amy Fong
237ffd1b1d 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>
2015-03-25 18:48:00 +01:00
Peter Krempa
02f0f1ccc7 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.
2015-03-25 15:42:52 +01:00
Peter Krempa
6ff59cbc83 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.
2015-03-25 15:42:52 +01:00
Guido Günther
db1edae895 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
2015-03-25 15:15:17 +01:00
Peter Krempa
a98129c0ee 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
2015-03-25 13:37:42 +01:00
Peter Krempa
6ca857c7c8 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.
2015-03-25 13:37:41 +01:00
Peter Krempa
ad886fa6c8 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.
2015-03-25 13:37:41 +01:00
Peter Krempa
785fd9fa12 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.
2015-03-25 13:35:42 +01:00
Peter Krempa
9d574aa2c9 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)
2015-03-25 13:27:22 +01:00
Pavel Hrdina
49bf09d16c 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>
2015-03-25 12:28:56 +01:00
Luyao Huang
726072f0d2 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>
2015-03-25 12:24:40 +01:00
Peter Krempa
8ad871f39e util: NUMA: Change error code in virNumaNodesetIsAvailable()
An invalid nodeset is a configuration problem rather than an internal
error.
2015-03-25 12:24:40 +01:00
Luyao Huang
225f7bf75c conf: Add missing apostrophe to error message
Signed-off-by: Luyao Huang <lhuang@redhat.com>
2015-03-25 12:24:40 +01:00
Pavel Hrdina
3edbfc882a 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>
2015-03-25 11:30:38 +01:00
Chen Fan
f276f0557e 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>
2015-03-25 10:43:23 +01:00
Chen Fan
1c19c5eff6 docs: no 'via' attribute in route element
via -> gateway

Signed-off-by: Chen Fan <chen.fan.fnst@cn.fujitsu.com>
2015-03-25 10:43:23 +01:00
Jiri Denemark
f6fbd36fd4 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>
2015-03-25 10:00:54 +01:00
Jiri Denemark
b79f25e881 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>
2015-03-25 10:00:54 +01:00
Jiri Denemark
667cce7b60 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>
2015-03-25 10:00:54 +01:00
Jiri Denemark
d20f5dde29 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>
2015-03-25 10:00:53 +01:00
Jiri Denemark
55ebc93a08 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>
2015-03-25 10:00:53 +01:00
Jiri Denemark
23d0c979f7 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>
2015-03-25 10:00:53 +01:00
Jiri Denemark
956953884e 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>
2015-03-25 10:00:53 +01:00
Jiri Denemark
61dda4f9ab POTFILES.in: Sort
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2015-03-25 10:00:53 +01:00