]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/log
people/liuw/libxenctrl-split/libvirt.git
10 years agoDon't require iptables-ipv6 on >= F17 and RHEL >= 7
Ján Tomko [Tue, 8 Jul 2014 10:56:59 +0000 (12:56 +0200)]
Don't require iptables-ipv6 on >= F17 and RHEL >= 7

We only need ip6tables, which is now a part of the iptables package:
http://pkgs.fedoraproject.org/cgit/iptables.git/commit/?h=1392835

This needlessly pulls in iptables-services:
https://bugzilla.redhat.com/show_bug.cgi?id=1101510
which can conflict with firewalld:
https://bugzilla.redhat.com/show_bug.cgi?id=1101484

10 years agoutil: cgroup: Add helper to convert device mode to string
Peter Krempa [Fri, 20 Jun 2014 11:33:16 +0000 (13:33 +0200)]
util: cgroup: Add helper to convert device mode to string

Cgroups code uses VIR_CGROUP_DEVICE_* flags to specify the mode but in
the end it needs to be converted to a string. Add a helper to do it and
use it in the cgroup code before introducing it into the rest of the
code.

10 years agoutil: storage: Copy parent's disk metadata to backing chain elements
Peter Krempa [Fri, 27 Jun 2014 12:33:01 +0000 (14:33 +0200)]
util: storage: Copy parent's disk metadata to backing chain elements

When discovering a disk backing chain the parent disk's metadata need to
be populated into the guest images so that each piece of the backing
chain contains a copy of those. This will allow us to refactor the
security driver so that it will not need to carry around the original
disk definition.

10 years agoutil: storage: Add function to transfer config parts to new chain element
Peter Krempa [Wed, 25 Jun 2014 16:48:27 +0000 (18:48 +0200)]
util: storage: Add function to transfer config parts to new chain element

We are going to modify storage source chains in place. Add a helper that
will copy relevant information such as security labels to the new
element if that doesn't contain it.

10 years agoutil: storagefile: Add deep copy for struct virStorageSource
Peter Krempa [Mon, 16 Jun 2014 11:10:42 +0000 (13:10 +0200)]
util: storagefile: Add deep copy for struct virStorageSource

Now that we have pointers to store disk source information and thus can
easily exchange the structs behind we need a function to copy all the
data.

10 years agostorage: Move readonly and shared flags to disk source from disk def
Peter Krempa [Tue, 24 Jun 2014 13:15:55 +0000 (15:15 +0200)]
storage: Move readonly and shared flags to disk source from disk def

In the future we might need to track state of individual images. Move
the readonly and shared flags to the virStorageSource struct so that we
can keep them in a per-image basis.

10 years agoconf: Don't output seclabels for backingStore elements
Peter Krempa [Mon, 30 Jun 2014 09:38:08 +0000 (11:38 +0200)]
conf: Don't output seclabels for backingStore elements

Some of the further changes will propagate seclabels from a disk source
element into the backing store elements. This would change the XML
output of the backing store as the seclabels would be formatted for each
backing store element. Skip the seclabels formatting until we decide
that it's necessary.

10 years agostorage: file: Tolerate NULL src when uninitializing the backend
Peter Krempa [Mon, 30 Jun 2014 14:24:33 +0000 (16:24 +0200)]
storage: file: Tolerate NULL src when uninitializing the backend

Allow de-init of null storage sources.

10 years agoqemu: Add helper to initialize storage file backend with correct uid/gid
Peter Krempa [Mon, 30 Jun 2014 13:48:45 +0000 (15:48 +0200)]
qemu: Add helper to initialize storage file backend with correct uid/gid

Add a wrapper that determines the correct uid and gid for a certain
storage file and domain.

10 years agoqemu: Don't propagate whole disk definition into qemuDomainGetImageIds
Peter Krempa [Mon, 30 Jun 2014 13:40:57 +0000 (15:40 +0200)]
qemu: Don't propagate whole disk definition into qemuDomainGetImageIds

It will help re-using the function.

10 years agoqemu: Add support for networked disks for block pull/block rebase
Peter Krempa [Mon, 28 Apr 2014 13:39:19 +0000 (15:39 +0200)]
qemu: Add support for networked disks for block pull/block rebase

Now that we are able to select images from the backing chain via indexed
access we should also convert possible network sources to
qemu-compatible strings before passing them to qemu.

10 years agoqemu: Add support for networked disks for block commit
Peter Krempa [Mon, 28 Apr 2014 13:39:19 +0000 (15:39 +0200)]
qemu: Add support for networked disks for block commit

Now that we are able to select images from the backing chain via indexed
access we should also convert possible network sources to
qemu-compatible strings before passing them to qemu.

10 years agolib: Introduce flag VIR_DOMAIN_BLOCK_REBASE_RELATIVE
Peter Krempa [Fri, 16 May 2014 13:40:06 +0000 (15:40 +0200)]
lib: Introduce flag VIR_DOMAIN_BLOCK_REBASE_RELATIVE

Introduce flag for the block rebase API to allow the rebase operation to
leave the chain relatively addressed. Also adds a virsh switch to enable
this behavior.

10 years agolib: Introduce flag VIR_DOMAIN_BLOCK_COMMIT_RELATIVE
Peter Krempa [Tue, 13 May 2014 15:59:32 +0000 (17:59 +0200)]
lib: Introduce flag VIR_DOMAIN_BLOCK_COMMIT_RELATIVE

Introduce flag for the block commit API to allow the commit operation to
leave the chain relatively addressed. Also adds a virsh switch to enable
this behavior.

10 years agoqemu: refactor qemuDomainGetBlockInfo to work with remote storage
Peter Krempa [Mon, 7 Jul 2014 10:56:23 +0000 (12:56 +0200)]
qemu: refactor qemuDomainGetBlockInfo to work with remote storage

The qemu block info function relied on working with local storage. Break
this assumption by adding support for remote volumes. Unfortunately we
still need to take a hybrid approach as some of the operations require a
filedescriptor.

Previously you'd get:
 $ virsh domblkinfo gl vda
 error: cannot stat file '/img10': Bad file descriptor

Now you get some stats:
 $ virsh domblkinfo gl vda
 Capacity:       10485760
 Allocation:     197120
 Physical:       197120

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

10 years agostorage: gluster: Optimize header reader functions
Peter Krempa [Mon, 7 Jul 2014 09:52:58 +0000 (11:52 +0200)]
storage: gluster: Optimize header reader functions

The gluster code had two functions for reading volume headers, remove
one and reuse the second one.

10 years agoutil: storage: Allow specifying format for virStorageFileGetMetadataFromBuf
Peter Krempa [Mon, 7 Jul 2014 09:38:28 +0000 (11:38 +0200)]
util: storage: Allow specifying format for virStorageFileGetMetadataFromBuf

To allow reusing this function in the qemu driver we need to allow
specifying the storage format. Also separate return of the backing store
path now isn't necessary.

10 years agoutil: storage: Inline use of virStorageFileGetMetadataFromFDInternal
Peter Krempa [Mon, 7 Jul 2014 09:24:14 +0000 (11:24 +0200)]
util: storage: Inline use of virStorageFileGetMetadataFromFDInternal

There was just one callsite left. Integrate the body to the only calling
function.

10 years agotools/wireshark: fix rpm build
Pavel Hrdina [Tue, 8 Jul 2014 06:33:53 +0000 (08:33 +0200)]
tools/wireshark: fix rpm build

There is a missing include of $(top_srcdir)/include to handle
"libvirt/libvirt.h" header file.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
10 years agoDo not allow changing the UUID of a nwfilter
Hu Jianwei [Mon, 7 Jul 2014 13:55:16 +0000 (15:55 +0200)]
Do not allow changing the UUID of a nwfilter

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

10 years agoLXC: Allow setting max mem lower than current mem
Ján Tomko [Thu, 26 Jun 2014 07:13:25 +0000 (09:13 +0200)]
LXC: Allow setting max mem lower than current mem

For inactive domains, set both current and maximum memory
to the specified 'maximum memory' value.

This matches the behavior of QEMU driver's SetMaxMemory.

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

10 years agovirsh: domain: Use inactive XML when unplugging interface with --config
Peter Krempa [Fri, 4 Jul 2014 13:03:07 +0000 (15:03 +0200)]
virsh: domain: Use inactive XML when unplugging interface with --config

Similary to cmdDetachDisk fetch the inactive definition when --config
is specified as the active may not contain the network interface
if it was plugged with --config.

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

10 years agoaudit: Audit smartcard devices
Peter Krempa [Thu, 3 Jul 2014 10:03:41 +0000 (12:03 +0200)]
audit: Audit smartcard devices

10 years agoaudit: Add auditing for serial/parallel/channel/console character devs
Peter Krempa [Thu, 3 Jul 2014 08:59:58 +0000 (10:59 +0200)]
audit: Add auditing for serial/parallel/channel/console character devs

Add startup auditing and also hotplug auditing for said devices.

10 years agovirt-lxc-convert: make free return values in bytes
Cédric Bosdonnat [Fri, 4 Jul 2014 13:58:39 +0000 (15:58 +0200)]
virt-lxc-convert: make free return values in bytes

Tiny fix for virt-lxc-convert: we are setting memory values in bytes, while
free may give us values in a different unit by default: force free to output
bytes with -b flag.

10 years agoqemu: dump: Report better error when dumping VM with passthrough devices
Peter Krempa [Mon, 7 Jul 2014 08:00:46 +0000 (10:00 +0200)]
qemu: dump: Report better error when dumping VM with passthrough devices

For the regular dump operation we migrate the VM to a file. This won't
work when the VM has passthrough devices assigned. Rather than reporting
a cryptic error from qemu run our check whether it can be migrated.

This does not influence the memory-only dump that is allowed with
passthrough devices.

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

10 years agoLXC: remove duplicate controller check code
Chen Hanxiao [Mon, 7 Jul 2014 06:26:57 +0000 (14:26 +0800)]
LXC: remove duplicate controller check code

We invoked virCgroupHasController twice for checking
VIR_CGROUP_CONTROLLER_DEVICES
in lxcDomainAttachDeviceDiskLive.

Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
10 years agoFree the return value of virFileFindResource
Ján Tomko [Mon, 7 Jul 2014 06:18:44 +0000 (08:18 +0200)]
Free the return value of virFileFindResource

Commits e18a80a and 57e5c3c switched from a getenv wrapper which
does not allocate a string to virFileFindResource which does not,
without freeing it.

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

10 years agodocs: formatdomain.html fixes
Michele Paolino [Fri, 4 Jul 2014 14:12:48 +0000 (16:12 +0200)]
docs: formatdomain.html fixes

Fixed some XML tags in the formatdomain page.

Signed-off-by: Michele Paolino <m.paolino@virtualopensystems.com>
10 years agodocs: Fix broken link in the HACKING page
Michele Paolino [Fri, 4 Jul 2014 14:12:47 +0000 (16:12 +0200)]
docs: Fix broken link in the HACKING page

The link to the page "how to get your code into an open source
project" has been fixed.

Signed-off-by: Michele Paolino <m.paolino@virtualopensystems.com>
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agowireshark: Honor API change coming with 1.12 release
Michal Privoznik [Fri, 4 Jul 2014 05:38:48 +0000 (07:38 +0200)]
wireshark: Honor API change coming with 1.12 release

https://bugs.gentoo.org/show_bug.cgi?id=508336

At wireshark, they have this promise to change public dissector APIs
only with minor version number change. Which they did when releasing
the version of 1.12.

Firstly, they've changed tvb_memdup() in
a0c53ffaa1bb46d8c9db2ec739401aa411c9790e so now it takes four arguments
instead of three. The new argument is placed at the very beginning of
the list of arguments and basically says the scope where we'd like to
allocate the memory. According to the documentation NULL should be the
default value.

Then, the tcp_dissect_pdus() signature changed too. Well, the function
that actually dissects reassembled packets as tcp_dissect_pdus()
reorder TCP packets into one big chunk and then calls a user function
to dissect the PDU at once. The change is dated back to
8081cf1d90397cbbb4404f9720595e1537ed5e14.

Then, WS_DLL_PUBLIC_NOEXTERN was replaced with WS_DLL_PUBLIC_DEF in
5d87a8c46171f572568db5a47c093423482e342f.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agowireshark: Include more of libvirt internals
Michal Privoznik [Fri, 4 Jul 2014 08:23:18 +0000 (10:23 +0200)]
wireshark: Include more of libvirt internals

The rationale is to not duplicate code which is done in
packet-libvirt.h for instance. Moreover, this way we can drop
__attribute_((unused)) used int packet-libvirt.c in favor of
ATTRIBUTE_UNUSED.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoqemu: monitor: Add support for backing name specification for block-stream
Peter Krempa [Fri, 16 May 2014 15:51:21 +0000 (17:51 +0200)]
qemu: monitor: Add support for backing name specification for block-stream

To allow changing the name that is recorded in the top of the current
image chain used in a block pull/rebase operation, we need to specify
the backing name to qemu. This is done via the "backing-file" attribute
to the block-stream commad.

10 years agoqemu: monitor: Add argument for specifying backing name for block commit
Peter Krempa [Tue, 13 May 2014 15:41:33 +0000 (17:41 +0200)]
qemu: monitor: Add argument for specifying backing name for block commit

To allow changing the name that is recorded in the overlay of the TOP
image used in a block commit operation, we need to specify the backing
name to qemu. This is done via the "backing-file" attribute to the
block-commit command.

10 years agoqemu: caps: Add capability for change-backing-file command
Peter Krempa [Mon, 26 May 2014 12:09:22 +0000 (14:09 +0200)]
qemu: caps: Add capability for change-backing-file command

This command allows to change the backing file name recorded in the
metadata of a qcow (or other) image. The capability also notifies that
the "block-stream" and "block-commit" commands understand the
"backing-file" attribute.

10 years agoaudit: disk: Refactor disk auditing to avoid auditing remote storage
Peter Krempa [Thu, 3 Jul 2014 08:28:12 +0000 (10:28 +0200)]
audit: disk: Refactor disk auditing to avoid auditing remote storage

Pass the virStorageSource struct to the auditing function and check if
storage is local before auditing.

10 years agoconf: audit: Split out common steps to audit domain devices
Peter Krempa [Wed, 2 Jul 2014 09:24:24 +0000 (11:24 +0200)]
conf: audit: Split out common steps to audit domain devices

Extract common operations done when creating an audit message to a
separate generic function that can be reused and convert RNG, disk, FS
and net audit to use it.

10 years agoconf: audit: rng: Reorder new and old RNG device definitions
Peter Krempa [Wed, 2 Jul 2014 11:42:54 +0000 (13:42 +0200)]
conf: audit: rng: Reorder new and old RNG device definitions

The audit functions usually take the old definition before the new one
in the argument list. Unify RNG device to use the same order.

10 years agoutil: storage: Add helper to determine whether storage is local
Peter Krempa [Wed, 25 Jun 2014 11:47:32 +0000 (13:47 +0200)]
util: storage: Add helper to determine whether storage is local

There's a lot of places where we skip doing actions based on the
locality of given storage type. The usual pattern is to skip it if:

virStorageSourceGetActualType(src) == VIR_STORAGE_TYPE_NETWORK

Add a simple helper to simplify the pattern to
virStorageSourceIsLocalStorage(src)

10 years agoUtilize virDomainDiskAuth for storage pools
John Ferlan [Thu, 26 Jun 2014 12:18:09 +0000 (08:18 -0400)]
Utilize virDomainDiskAuth for storage pools

Replace the authType, chap, and cephx unions in virStoragePoolSource
with a single pointer to a virStorageAuthDefPtr.  Adjust all users of
the previous chap/cephx and secret unions with the source->auth data.

10 years agoformatdomain: Fix issues found describing auth
John Ferlan [Wed, 25 Jun 2014 16:16:54 +0000 (12:16 -0400)]
formatdomain: Fix issues found describing auth

Fix a couple of typos ('chap' should have been 'iscsi' and there was
a stray 'iqn.2013-07.com.example:iscsi-pool' entry.  Clean up the
description of the <auth> element for the disk

10 years agoUtilize virDomainDiskAuth for domain disk
John Ferlan [Tue, 24 Jun 2014 13:46:23 +0000 (09:46 -0400)]
Utilize virDomainDiskAuth for domain disk

Replace the inline "auth" struct in virStorageSource with a pointer
to a virStorageAuthDefPtr and utilize between the domain_conf, qemu_conf,
and qemu_command sources for finding the auth data for a domain disk

10 years agoqemuargv2xmltest: Resurrect RBD and iSCSI auth
John Ferlan [Wed, 25 Jun 2014 16:16:56 +0000 (12:16 -0400)]
qemuargv2xmltest: Resurrect RBD and iSCSI auth

Ressurect the disk-drive-network-iscsi-auth and disk-drive-network-rbd-auth
tests.  Make adjustments to the args and xml file to be compatible with
other changes made to the non "-auth" so that the only difference is the
authentication information.

Adjust the qemuargv2xmltest.c to filter out "<secret" and "</auth>" since
the args -> xml has no concept of usage it doesn't get printed. This results
in the </auth> being printed on the same line as "<secret" and the secret
XML is not closed - a bit of an issue, but soon to be fixed.

10 years agovirstorage: Introduce virStorageAuthDef
John Ferlan [Mon, 23 Jun 2014 14:40:49 +0000 (10:40 -0400)]
virstorage: Introduce virStorageAuthDef

Introduce virStorageAuthDef and friends.  Future patches will merge/utilize
their view of storage source/pool auth/secret definitions.

New API's include:
    virStorageAuthDefParse:  Parse the "<auth/>" XML data for either the
                             domain disk or storage pool returning a
                             virStorageAuthDefPtr
    virStorageAuthDefCopy:   Copy a virStorageAuthDefPtr - to be used by
                             the qemuTranslateDiskSourcePoolAuth when it
                             copies storage pool auth data into domain
                             disk auth data
    virStorageAuthDefFormat: Common output of the "<auth" in the domain
                             disk or storage pool XML
    virStorageAuthDefFree:   Free memory associated with virStorageAuthDef

Subsequent patches will utilize the new functions for the domain disk and
storage pools.

Future work in the hostdev pass through can then make use of common data
structures and code.

10 years agoblockjob: turn on qemu capability bit for active commit
Eric Blake [Tue, 17 Jun 2014 03:42:49 +0000 (21:42 -0600)]
blockjob: turn on qemu capability bit for active commit

Use the probing functionality added in the last patch to turn on
a capability bit when active commit is present, and gate active
commit on that capability.

For my own reference: the difference between BLOCKJOB_SYNC and
BLOCKJOB_ASYNC is whether qemu generated an event at the
conclusion of blockpull; basically, RHEL 6.2 was the only release
of qemu that has the sync semantics and lacks the event.  RHEL
6.3 added blockcopy, but also picked up on the upstream style
of qemu generating events.  As no one is likely to backport
active commit to RHEL 6.2, it's safe for blockcommit to always
require async blockjob support.

Modifying qemucapabilitiestest is painful; the .replies files would
be so much easier if they had comments correlating which command
generated the given reply.  Maybe I'll fix that up later...

* src/qemu/qemu_capabilities.h (QEMU_CAPS_ACTIVE_COMMIT): New
capability.
* src/qemu/qemu_driver.c (qemuDomainBlockCommit): Use the new bit
* src/qemu/qemu_capabilities.c (virQEMUCaps): Name the new bit.
(virQEMUCapsProbeQMPCommands): Set it.
* tests/qemucapabilitiesdata/caps_1.3.1-1.replies: Update.
* tests/qemucapabilitiesdata/caps_1.4.2-1.replies: Likewise.
* tests/qemucapabilitiesdata/caps_1.5.3-1.replies: Likewise.
* tests/qemucapabilitiesdata/caps_1.6.0-1.replies: Likewise.
* tests/qemucapabilitiesdata/caps_1.6.50-1.replies: Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agoblockjob: allow omitted arguments to QMP block-commit
Eric Blake [Tue, 17 Jun 2014 03:42:49 +0000 (21:42 -0600)]
blockjob: allow omitted arguments to QMP block-commit

We are about to turn on support for active block commit.  Although
qemu 2.0 was the first version to mostly support it, that version
mis-handles 0-length files, and doesn't have anything available for
easy probing.  But qemu 2.1 fixed bugs, and made life simpler by
letting the 'top' argument be optional.  Unless someone begs for
active commit with qemu 2.0, for now we are just going to enable
it only by probing for qemu 2.1 behavior (anyone backporting active
commit can also backport the optional argument behavior).  This
requires qemu.git commit 7676e2c597000eff3a7233b40cca768b358f9bc9.

Although all our actual uses of block-commit supply arguments for
both base and top, we can omit both arguments and use a bogus
device string to trigger an interesting behavior in qemu.  All QMP
commands first do argument validation, failing with GenericError
if a mandatory argument is missing.  Once that passes, the code
in the specific command gets to do further checking, and the qemu
developers made sure that if device is the only supplied argument,
then the block-commit code will look up the device first, with a
failure of DeviceNotFound, before attempting any further argument
validation (most other validations fail with GenericError).  Thus,
the category of error class can reliably be used to decipher
whether the top argument was optional, which in turn implies a
working active commit.  Since we expect our bogus device string to
trigger an error either way, the code is written to return a
distinct return value without spamming the logs.

* src/qemu/qemu_monitor.h (qemuMonitorSupportsActiveCommit): New
prototype.
* src/qemu/qemu_monitor.c (qemuMonitorSupportsActiveCommit):
Implement it.
* src/qemu/qemu_monitor_json.h (qemuMonitorJSONBlockCommit):
Allow NULL for top and base, for probing purposes.
* src/qemu/qemu_monitor_json.c (qemuMonitorJSONBlockCommit):
Likewise, implementing the probe.
* tests/qemumonitorjsontest.c (mymain): Enable...
(testQemuMonitorJSONqemuMonitorSupportsActiveCommit): ...a new test.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agotests: Avoid double linking some libraries
Michal Privoznik [Thu, 3 Jul 2014 12:09:55 +0000 (14:09 +0200)]
tests: Avoid double linking some libraries

The problem is, since 614581f32b domaincapstest is linked with
$(LDADDS) by default. Then, since 94e3f23e8a7 the test may be
conditionally linked with $(qemu_LDADDS) which already contains
$(LDADDS). And some linkers doesn't cope with this nicely:

  CCLD     domaincapstest
../src/libvirt_probes.o:(.probes+0x0): multiple definition of `libvirt_event_poll_add_handle_semaphore'
../src/libvirt_probes.o:(.probes+0x0): first defined here
../src/libvirt_probes.o:(.probes+0x2): multiple definition of `libvirt_event_poll_update_handle_semaphore'
../src/libvirt_probes.o:(.probes+0x2): first defined here
../src/libvirt_probes.o:(.probes+0x4): multiple definition of `libvirt_event_poll_remove_handle_semaphore'
../src/libvirt_probes.o:(.probes+0x4): first defined here
../src/libvirt_probes.o:(.probes+0x6): multiple definition of `libvirt_event_poll_dispatch_handle_semaphore'
../src/libvirt_probes.o:(.probes+0x6): first defined here

And so on.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoqemu: Implement virConnectGetDomainCapabilities
Michal Privoznik [Wed, 25 Jun 2014 16:39:29 +0000 (18:39 +0200)]
qemu: Implement virConnectGetDomainCapabilities

So far only information on disks and host devices are exposed in the
capabilities XML. Well, at least something. Even a new test is
introduced. The qemu capabilities are stolen from already existing
qemucapabilities test. There's one tricky point though. Functions that
checks host's KVM and VFIO capabilities, are impossible to mock
currently. So in the test, we are setting the capabilities by hand.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoqemu_capabilities: Introduce virQEMUCapsGetDefaultMachine
Michal Privoznik [Mon, 30 Jun 2014 14:39:18 +0000 (16:39 +0200)]
qemu_capabilities: Introduce virQEMUCapsGetDefaultMachine

Sometimes it may be useful to get a default machine for given qemu
binary. Fortunately, the default machine is stored always on the first
position in the supported machines array.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoqemu_capabilities: Introduce virQEMUCapsIsMachineSupported
Michal Privoznik [Mon, 30 Jun 2014 14:31:51 +0000 (16:31 +0200)]
qemu_capabilities: Introduce virQEMUCapsIsMachineSupported

This internal API is meant to answer the question 'Is this machine
type supported by given qemu?'.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoqemu_capabilities: Introduce virQEMUCapsCacheLookupByArch
Michal Privoznik [Mon, 30 Jun 2014 14:12:07 +0000 (16:12 +0200)]
qemu_capabilities: Introduce virQEMUCapsCacheLookupByArch

The API may come handy if somebody has an architecture and wants to
look through available qemus if the architecture is supported or not.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agotests: Move qemu caps XML parsing into shared unit
Michal Privoznik [Fri, 27 Jun 2014 14:39:27 +0000 (16:39 +0200)]
tests: Move qemu caps XML parsing into shared unit

Later on, we the qemu capabilities XML parsing code may come handy so
instead of duplicating the code make the already existing one shared.
By the same time, make the function accept file name instead of XML
document stored already in memory.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agovirsh: expose virConnectGetDomainCapabilities
Michal Privoznik [Wed, 25 Jun 2014 15:56:20 +0000 (17:56 +0200)]
virsh: expose virConnectGetDomainCapabilities

The API is exposed under 'domcapabilities' command. Currently, with
the variety of drivers that libvirt supports, none of the command
arguments is obligatory, but all are optional instead.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoIntroduce virConnectGetDomainCapabilities
Michal Privoznik [Wed, 25 Jun 2014 15:05:20 +0000 (17:05 +0200)]
Introduce virConnectGetDomainCapabilities

The API should expose the information contained in virDomainCapsPtr.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoIntroduce domain_capabilities
Michal Privoznik [Wed, 25 Jun 2014 11:24:53 +0000 (13:24 +0200)]
Introduce domain_capabilities

This new module holds and formats capabilities for emulator. If you
are about to create a new domain, you may want to know what is the
host or hypervisor capable of. To make sure we don't regress on the
XML, the formatting is not something left for each driver to
implement, rather there's general format function.

The domain capabilities is a lockable object (even though the locking
is not necessary yet) which uses reference counter.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoxenapiConnectGetCapabilities: Remove unused 'cleanup' label
Michal Privoznik [Thu, 3 Jul 2014 10:21:00 +0000 (12:21 +0200)]
xenapiConnectGetCapabilities: Remove unused 'cleanup' label

In the lastest rework (9e7ecabf) a cleanup label was left over which
results in compilation error.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoRemove double OOM error reporting
Ján Tomko [Fri, 27 Jun 2014 06:44:15 +0000 (08:44 +0200)]
Remove double OOM error reporting

10 years agoRemove double OOM error reporting from JSON monitor
Ján Tomko [Fri, 27 Jun 2014 06:45:14 +0000 (08:45 +0200)]
Remove double OOM error reporting from JSON monitor

The functions called here report an OOM error when the allocation
fails, or quietly return -1 on wrong usage (which is not the case
here)

10 years agoAdd OOM error reporting to a few fucntions
Ján Tomko [Fri, 27 Jun 2014 08:47:11 +0000 (10:47 +0200)]
Add OOM error reporting to a few fucntions

They report errors in all other cases.

10 years agoSet errno on OOM in lxcProcReadMeminfo
Ján Tomko [Fri, 27 Jun 2014 08:47:05 +0000 (10:47 +0200)]
Set errno on OOM in lxcProcReadMeminfo

It sets the errno on all other errors, do it here too.
Also report an error.

10 years agoUse virBufferCheckError everywhere we report OOM error
Ján Tomko [Fri, 27 Jun 2014 08:40:15 +0000 (10:40 +0200)]
Use virBufferCheckError everywhere we report OOM error

Replace:
if (virBufferError(&buf)) {
    virBufferFreeAndReset(&buf);
    virReportOOMError();
    ...
}

with:
if (virBufferCheckError(&buf) < 0)
    ...

This should not be a functional change (unless some callers
misused the virBuffer APIs - a different error would be reported
then)

10 years agoReport errors in virCapabilitiesFormatXML
Ján Tomko [Fri, 27 Jun 2014 07:55:44 +0000 (09:55 +0200)]
Report errors in virCapabilitiesFormatXML

So far, we only report an error if formatting the siblings bitmap
in NUMA topology fails.

Be consistent and always report error in virCapabilitiesFormatXML.

10 years agoIntroduce virBufferCheckError
Ján Tomko [Fri, 27 Jun 2014 07:23:13 +0000 (09:23 +0200)]
Introduce virBufferCheckError

Check if the buffer is in error state and report an error if it is.

This replaces the pattern:
if (virBufferError(buf)) {
    virReportOOMError();
    goto cleanup;
}
with:

if (virBufferCheckError(buf) < 0)
    goto cleanup;

Document typical buffer usage to favor this.
Also remove the redundant FreeAndReset - if an error has
been set via virBufferSetError, the content is already freed.

10 years agoUse virStringReplace instead of openvz_replace
Ján Tomko [Fri, 27 Jun 2014 07:32:38 +0000 (09:32 +0200)]
Use virStringReplace instead of openvz_replace

This function didn't report an error on OOM. Better delete it
and use virStringReplace instead. :)

10 years agoRemove useless condition in networkRadvdConfContents
Ján Tomko [Fri, 27 Jun 2014 09:21:06 +0000 (11:21 +0200)]
Remove useless condition in networkRadvdConfContents

If v6present is false, this code is not reachable.
Also, there is no need to check for errors twice.

10 years agousb: Remove redundant comment
Ján Tomko [Fri, 27 Jun 2014 06:46:26 +0000 (08:46 +0200)]
usb: Remove redundant comment

10 years agoMore indentation fixes
Ján Tomko [Fri, 27 Jun 2014 09:25:05 +0000 (11:25 +0200)]
More indentation fixes

Reindent nwfilter gentech driver and one block in rbd storage backend.

10 years agoFix indentation in bridge driver
Ján Tomko [Mon, 23 Jun 2014 09:51:38 +0000 (11:51 +0200)]
Fix indentation in bridge driver

10 years agoqemu_domain: fix startup policy for disks
Pavel Hrdina [Fri, 27 Jun 2014 14:34:07 +0000 (16:34 +0200)]
qemu_domain: fix startup policy for disks

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

We now support startupPolicy='optional' for disks, but this
should work only for cold boot, not for restore or migrate.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
10 years agoLXC: update comments of lxcDomainCreateXMLWithFiles() and lxcDomainCreateXML()
Yue wenyuan [Wed, 25 Jun 2014 08:16:16 +0000 (16:16 +0800)]
LXC: update comments of lxcDomainCreateXMLWithFiles() and lxcDomainCreateXML()

The comments for lxcDomainCreateXMLWithFiles are out of date. So update them.
And add comments for lxcDomainCreateXML

Signed-off-by: Wang Rui <moon.wangrui@huawei.com>
Signed-off-by: Yue wenyuan <yuewenyuan@huawei.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agovirsh: Allow attach-disk to specify disk target bus
Yanbing Du [Tue, 1 Jul 2014 10:02:03 +0000 (18:02 +0800)]
virsh: Allow attach-disk to specify disk target bus

By default, the bus type is inferred from the style of the device
name('target' in this command), e.g. a device named 'sda' will
typically be exported using a SCSI bus. Actually, not only SCSI bus,
but USB/SATA bus also use this kind of device name. So add '--bus'
option for attach-disk command to allow user specify the target bus.

Signed-off-by: Yanbing Du <ydu@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoFix segfault when starting a domain with no cpu definition
Ján Tomko [Wed, 2 Jul 2014 08:35:31 +0000 (10:35 +0200)]
Fix segfault when starting a domain with no cpu definition

My commit fba6bc4 iterated over the features in cpu definition
without checking if there is one.

10 years agoqemu: Add cmd_per_lun, max_sectors to virtio-scsi
Mike Perez [Thu, 22 May 2014 18:22:52 +0000 (11:22 -0700)]
qemu: Add cmd_per_lun, max_sectors to virtio-scsi

This introduces two new attributes "cmd_per_lun" and "max_sectors" same
with the names QEMU uses for virtio-scsi. An example of the XML:

<controller type='scsi' index='0' model='virtio-scsi' cmd_per_lun='50'
max_sectors='512'/>

The corresponding QEMU command line:

-device virtio-scsi-pci,id=scsi0,cmd_per_lun=50,max_sectors=512,
bus=pci.0,addr=0x3

Signed-off-by: Mike Perez <thingee@gmail.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
10 years agoAdd invariant TSC cpu flag
Ján Tomko [Tue, 6 May 2014 11:55:44 +0000 (13:55 +0200)]
Add invariant TSC cpu flag

Add suport for invariant TSC flag (CPUID 0x80000007, bit 8 of EDX).
If this flag is enabled, the TSC ticks at a constant rate across
all ACPI P-, C- and T-states.

This can be enabled by adding:
<feature name='invtsc'/>
to the <cpu> element.

Migration and saving the domain does not work with this flag.

QEMU support: http://git.qemu.org/?p=qemu.git;a=commitdiff;h=303752a

The feature name "invtsc" differs from the name "" used by the linux kernel:
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/arch/x86/kernel/cpu/powerflags.c?id=30321c7b#n18

10 years agoqemu: raise an error when trying to use readonly ide disks
Giuseppe Scrivano [Mon, 30 Jun 2014 10:05:06 +0000 (12:05 +0200)]
qemu: raise an error when trying to use readonly ide disks

The IDE bus doesn't support readonly disks, so inform the user with an
error message instead of let qemu fail with a more obscure "Device
'ide-hd' could not be initialized" error message.

Closes: https://bugzilla.redhat.com/show_bug.cgi?id=1112939
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
10 years agoutil: unify extra asterisk in viralloc.h
Martin Kletzander [Mon, 30 Jun 2014 07:33:41 +0000 (09:33 +0200)]
util: unify extra asterisk in viralloc.h

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agoPost-release version bump for new dev cycle
Martin Kletzander [Wed, 2 Jul 2014 06:16:13 +0000 (08:16 +0200)]
Post-release version bump for new dev cycle

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agoRelease of libvirt-1.2.6
Daniel Veillard [Wed, 2 Jul 2014 05:50:18 +0000 (13:50 +0800)]
Release of libvirt-1.2.6

10 years agoqemu: copy: Accept 'format' parameter when copying to a non-existing img
Peter Krempa [Tue, 1 Jul 2014 11:52:51 +0000 (13:52 +0200)]
qemu: copy: Accept 'format' parameter when copying to a non-existing img

We have the following matrix of possible arguments handled by the logic
statement touched by this patch:
       | flags & _REUSE_EXT | !(flags & _REUSE_EXT)
-------+--------------------+----------------------
 format| (1)                | (2)
-------+--------------------+----------------------
!format| (3)                | (4)
-------+--------------------+----------------------

In cases 1 and 2 the user provided a format, in cases 3 and 4 not. The
user requests to use a pre-existing image in 1 and 3 and libvirt will
create a new image in 2 and 4.

The difference between cases 3 and 4 is that for 3 the format is probed
from the user-provided image, whereas in 4 we just use the existing disk
format.

The current code would treat cases 1,3 and 4 correctly but in case 2 the
format provided by the user would be ignored.

The particular piece of code was broken in commit 35c7701c64508f975dfeb8
but since it was introduced a few commits before that it was never
released as working.

10 years agostorage: gluster: Fix header reader function
Peter Krempa [Tue, 1 Jul 2014 14:54:11 +0000 (16:54 +0200)]
storage: gluster: Fix header reader function

Advance the right pointer to actually append to the buffer. We were
lucky that all reads were completed in one try.

10 years agoconf: storage: Add volume feature formatter for gluster pools
Peter Krempa [Tue, 1 Jul 2014 14:50:06 +0000 (16:50 +0200)]
conf: storage: Add volume feature formatter for gluster pools

Libvirt didn't output feature flags for images stored on native gluster.
Fix this trivially by adding a feature formatter callback.

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

10 years agobuild: link libvirt_conf with libxml
Martin Kletzander [Tue, 1 Jul 2014 15:09:48 +0000 (17:09 +0200)]
build: link libvirt_conf with libxml

Since there is code using functions from the libxml library,
libvirt_conf should have that in LIBADD so it can be linked against
even without libvirt_util (which usually deals with the error itself,
since libvirt_util has libxml in LIBADD).  The same applies to
storage_backend.c.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agovboxsnapshotxmltest: Don't write to a file in abs_srcdir
Michal Privoznik [Tue, 1 Jul 2014 13:23:36 +0000 (15:23 +0200)]
vboxsnapshotxmltest: Don't write to a file in abs_srcdir

In the test, the snapshot XML is written into a file that's located
under:

  abs_srcdir/vboxsnapshotxmldata/testResult.vbox

However, the abs_srcdir doesn't have to be necessarily writable. It
should have been abs_builddir instead. Moreover, the label in the func
creating the file is called 'fail' while it fulfils the duty of
'cleanup' label.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agosecurityselinuxlabeltest: Don't create dummy file in the srcdir
Michal Privoznik [Tue, 1 Jul 2014 12:52:28 +0000 (14:52 +0200)]
securityselinuxlabeltest: Don't create dummy file in the srcdir

At the very beginning of the test we check if the underlying
filesystem supports extended attributes as they are used to store fake
SELinux labels. In order to check that, a dummy file is created and
semi-random attribute is set. However, the file is created under:

  abs_srcdir "/securityselinuxlabeldata/testxattr"

which has two problems: abs_srcdir is not required to be writable, so
it should have been abs_builddir. The second one is - there's no
"securityselinuxlabeldata" folder under abs_builddir. The problem was
introduced in caf164f1.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoReport one error less when getting net dev speed
Ján Tomko [Mon, 30 Jun 2014 13:00:33 +0000 (15:00 +0200)]
Report one error less when getting net dev speed

virFileReadAll already logs an error. If reading the 'speed' file
fails with EINVAL, we log an error even though we ignore it. If it
fails with other errors, we log two errors.

Use virFileReadAllQuiet - ignore EINVAL and report just one error
in other cases.

Fixes this error on libvirtd startup:
2014-06-30 12:47:14.583+0000: 20971: error : virFileReadAll:1297 :
Failed to read file '/sys/class/net/wlan0/speed': Invalid argument

10 years agoIntroduce virFileReadAllQuiet
Ján Tomko [Mon, 30 Jun 2014 12:59:42 +0000 (14:59 +0200)]
Introduce virFileReadAllQuiet

Just like virFileReadAll, but returns -errno instead
of reporting errors. Useful for ignoring some errors.

10 years agoOnly detect PCI Express devices as root in udev nodedev driver
Ján Tomko [Mon, 30 Jun 2014 13:18:23 +0000 (15:18 +0200)]
Only detect PCI Express devices as root in udev nodedev driver

This stops the error message spam when running unprivileged
libvirtd:
2014-06-30 12:38:47.990+0000: 631: error : virPCIDeviceConfigOpen:300 :
Failed to open config space file
'/sys/bus/pci/devices/0000:00:00.0/config': Permission denied

Reported by Daniel Berrange:
https://www.redhat.com/archives/libvir-list/2014-June/msg01082.html

10 years agoTrack privileged state in udev nodedev driver
Ján Tomko [Mon, 30 Jun 2014 13:16:33 +0000 (15:16 +0200)]
Track privileged state in udev nodedev driver

Remember if libvirtd is running as root or not.

10 years agolibxl: add PV console if not explicitly specified
Jim Fehlig [Mon, 30 Jun 2014 16:20:38 +0000 (10:20 -0600)]
libxl: add PV console if not explicitly specified

Xen PV domains always have a PV console, so add one to the domain
config via post-parse callback if not explicitly specified in
the XML.  The legacy Xen driver behaves similarly, causing a
regression when switching to the new Xen toolstack.  I.e.

  virsh console pv-domain

will no longer work after upgrading a xm/xend stack to xl/libxl.

10 years agobuild: fix 'make syntax-check' after commit c6cf5df3
Jim Fehlig [Tue, 1 Jul 2014 00:48:19 +0000 (18:48 -0600)]
build: fix 'make syntax-check' after commit c6cf5df3

The commit caused prohibit_long_lines to fail in src/Makefile.am.

10 years agovbox: fix linker error
Jim Fehlig [Mon, 30 Jun 2014 22:34:46 +0000 (16:34 -0600)]
vbox: fix linker error

Noticed the following error when building the vbox driver
in the openSUSE build service

CCLD     vboxsnapshotxmltest
/usr/lib64/gcc/x86_64-suse-linux/4.8/../../../../x86_64-suse-linux/bin/ld:
../src/.libs/libvirt_driver_vbox_impl.a
(libvirt_driver_vbox_impl_la-vbox_snapshot_conf.o):
undefined reference to symbol 'xmlXPathRegisterNs@@LIBXML2_2.4.30'
/usr/lib64/libxml2.so: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status

Fixed by adding LIBXML_LIBS to libvirt_driver_vbox_impl_la_LIBADD

10 years agolibxl: don't break the build on Xen>=4.5 because of libxl_vcpu_setaffinity()
Dario Faggioli [Mon, 30 Jun 2014 17:19:01 +0000 (19:19 +0200)]
libxl: don't break the build on Xen>=4.5 because of libxl_vcpu_setaffinity()

libxl interface for vcpu pinning is changing in Xen 4.5. Basically,
libxl_set_vcpuaffinity() now wants one more parameter. That is
representative of 'VCPU soft affinity', which libvirt does not use.

To mark such change, the macro LIBXL_HAVE_VCPUINFO_SOFT_AFFINITY is
defined. Use it as a gate and, if present, re-#define the calls from
the old to the new interface, to avoid breaking the build.

Signed-off-by: Dario Faggioli <dario.faggioli@citrix.com>
Cc: Jim Fehlig <jfehlig@suse.com>
Cc: Ian Campbell <Ian.Campbell@citrix.com>
Cc: Ian Jackson <Ian.Jackson@eu.citrix.com>
10 years agoLXC: throw an error if we failed to get Idmap elements
Chen Hanxiao [Mon, 30 Jun 2014 03:42:43 +0000 (11:42 +0800)]
LXC: throw an error if we failed to get Idmap elements

Throwing an error is much friendly than just
"error: An error occurred, but the cause is unknown"

Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
10 years agoqemu: snapshot: Save persistent domain config when taking external snapshot
Peter Krempa [Mon, 30 Jun 2014 11:44:26 +0000 (13:44 +0200)]
qemu: snapshot: Save persistent domain config when taking external snapshot

Commit 55bbb011b965c7962933604c70f61cef45e8ec04 introduced a regression
where we forgot to save the persistent domain configuration after an
external snapshot. This would make libvirt forget the snapshots and
effectively revert to the previous state in the following scenario:

1) Start VM
2) Take snapshot
3) Destroy VM
4) Restart libvirtd

Also fix spurious blank line added by patch mentioned above.

10 years agobhyve: fix build by fixing typo in variable name
Roman Bogorodskiy [Fri, 27 Jun 2014 15:04:41 +0000 (19:04 +0400)]
bhyve: fix build by fixing typo in variable name

Commit 80d0918b introduced a typo in variable name:

s/failIncomaptible/failIncompatible/

Pushed under the build breaker rule.

10 years agocpu: Add new Broadwell CPU model
Jiri Denemark [Wed, 18 Jun 2014 11:52:13 +0000 (13:52 +0200)]
cpu: Add new Broadwell CPU model

10 years agonet: merge virNetworkGetDHCPLeases and virNetworkGetDHCPLeasesForMAC
Peter Krempa [Thu, 26 Jun 2014 14:08:34 +0000 (16:08 +0200)]
net: merge virNetworkGetDHCPLeases and virNetworkGetDHCPLeasesForMAC

Instead of maintaining two very similar APIs, add the "@mac" parameter
to virNetworkGetDHCPLeases and kill virNetworkGetDHCPLeasesForMAC. Both
of those functions would return data the same way, so making @mac an
optional filter simplifies a lot of stuff.

10 years agoAdd test for type none model dac seclabel
Ján Tomko [Tue, 10 Jun 2014 08:19:40 +0000 (10:19 +0200)]
Add test for type none model dac seclabel

10 years agotest: add user_xattr check for securityselinuxlabeltest
Jincheng Miao [Mon, 9 Jun 2014 11:36:07 +0000 (19:36 +0800)]
test: add user_xattr check for securityselinuxlabeltest

libvirt unit test used setxattr with "user.libvirt.selinux" name to
emulate setfilecon of selinux. But for some old kernel filesystem
(like 2.6.32-431.el6.x86_64), if the filesystem is not mounted with
user_xattr flag, the setxattr with "user.libvirt.selinux" will fail.

So adding testUserXattrEnabled() in securityselinuxlabeltest.c,
if user_xattr is not enabled, skip this case.

The user_xattr is departed in newer kernel, therefore this commit is
only for the compatablity for old kernel.

Signed-off-by: Jincheng Miao <jmiao@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Tested-by: Scott Sullivan <ssullivan@liquidweb.com>
10 years agodocs: publish correct enum values
Eric Blake [Wed, 25 Jun 2014 20:54:36 +0000 (14:54 -0600)]
docs: publish correct enum values

We publish libvirt-api.xml for others to use, and in fact, the
libvirt-python bindings use it to generate python constants that
correspond to our enum values.  However, we had an off-by-one bug
that any enum that relied on C's rules for implicit initialization
of the first enum member to 0 got listed in the xml as having a
value of 1 (and all later members of the enum were equally
botched).

The fix is simple - since we add one to the previous value when
encountering an enum without an initializer, the previous value
must start at -1 so that the first enum member is assigned 0.

The python generator code has had the off-by-one ever since DV
first wrote it years ago, but most of our public enums were immune
because they had an explicit = 0 initializer.  The only affected
enums are:
- virDomainEventGraphicsAddressType (such as
VIR_DOMAIN_EVENT_GRAPHICS_ADDRESS_IPV4), since commit 987e31e
(libvirt v0.8.0)
- virDomainCoreDumpFormat (such as VIR_DOMAIN_CORE_DUMP_FORMAT_RAW),
since commit 9fbaff0 (libvirt v1.2.3)
- virIPAddrType (such as VIR_IP_ADDR_TYPE_IPV4), since commit
03e0e79 (not yet released)

Thanks to Nehal J Wani for reporting the problem on IRC, and
for helping me zero in on the culprit function.

* docs/apibuild.py (CParser.parseEnumBlock): Fix implicit enum
values.

Signed-off-by: Eric Blake <eblake@redhat.com>