Commit Graph

16960 Commits

Author SHA1 Message Date
John Ferlan
7712fc7cdb 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.
2014-07-03 17:39:14 -04:00
John Ferlan
1c36b944e2 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.
2014-07-03 17:39:14 -04:00
Eric Blake
40ad7160a2 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>
2014-07-03 14:19:53 -06:00
Eric Blake
47549d5a17 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>
2014-07-03 14:19:51 -06:00
Michal Privoznik
fb8bc6becd tests: Avoid double linking some libraries
The problem is, since 614581f32b domaincapstest is linked with
$(LDADDS) by default. Then, since 94e3f23e8a 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>
2014-07-03 14:58:06 +02:00
Michal Privoznik
94e3f23e8a 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>
2014-07-03 12:22:38 +02:00
Michal Privoznik
cb01d2b5b1 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>
2014-07-03 12:22:38 +02:00
Michal Privoznik
69f92a87c2 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>
2014-07-03 12:22:38 +02:00
Michal Privoznik
4e30af3853 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>
2014-07-03 12:22:37 +02:00
Michal Privoznik
3ecb9e7631 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>
2014-07-03 12:22:37 +02:00
Michal Privoznik
e9f2929f41 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>
2014-07-03 12:22:37 +02:00
Michal Privoznik
f409df4de1 Introduce virConnectGetDomainCapabilities
The API should expose the information contained in virDomainCapsPtr.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2014-07-03 12:22:37 +02:00
Michal Privoznik
614581f32b 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>
2014-07-03 12:22:37 +02:00
Michal Privoznik
15a855ef79 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>
2014-07-03 12:21:00 +02:00
Ján Tomko
5656d9bb7a Remove double OOM error reporting 2014-07-03 10:48:14 +02:00
Ján Tomko
fb11f5b185 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)
2014-07-03 10:48:14 +02:00
Ján Tomko
c997e45408 Add OOM error reporting to a few fucntions
They report errors in all other cases.
2014-07-03 10:48:14 +02:00
Ján Tomko
e12b8000c8 Set errno on OOM in lxcProcReadMeminfo
It sets the errno on all other errors, do it here too.
Also report an error.
2014-07-03 10:48:14 +02:00
Ján Tomko
92a8e72f9d 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)
2014-07-03 10:48:14 +02:00
Ján Tomko
28b9be2481 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.
2014-07-03 10:43:39 +02:00
Ján Tomko
058d89b9df 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.
2014-07-03 10:41:15 +02:00
Ján Tomko
f44e2e8711 Use virStringReplace instead of openvz_replace
This function didn't report an error on OOM. Better delete it
and use virStringReplace instead. :)
2014-07-03 10:41:15 +02:00
Ján Tomko
0979aaf846 Remove useless condition in networkRadvdConfContents
If v6present is false, this code is not reachable.
Also, there is no need to check for errors twice.
2014-07-03 10:41:15 +02:00
Ján Tomko
a1228523ed usb: Remove redundant comment 2014-07-03 10:41:15 +02:00
Ján Tomko
275f022454 More indentation fixes
Reindent nwfilter gentech driver and one block in rbd storage backend.
2014-07-03 10:41:15 +02:00
Ján Tomko
e87ab4c68d Fix indentation in bridge driver 2014-07-03 10:41:15 +02:00
Pavel Hrdina
5098f671f0 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>
2014-07-02 15:42:03 +02:00
Yue wenyuan
636d66e628 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>
2014-07-02 13:19:27 +02:00
Yanbing Du
7e157858b4 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>
2014-07-02 13:01:45 +02:00
Ján Tomko
1cd8f500ee 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.
2014-07-02 10:37:05 +02:00
Mike Perez
d950494129 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>
2014-07-02 09:43:17 +02:00
Ján Tomko
fba6bc47cb 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
2014-07-02 09:22:13 +02:00
Giuseppe Scrivano
72f919f558 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>
2014-07-02 08:17:23 +02:00
Martin Kletzander
1ef6584288 util: unify extra asterisk in viralloc.h
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2014-07-02 08:17:23 +02:00
Martin Kletzander
7a0e366f2b Post-release version bump for new dev cycle
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2014-07-02 08:17:23 +02:00
Daniel Veillard
b083528e56 Release of libvirt-1.2.6 2014-07-02 13:50:18 +08:00
Peter Krempa
42619ed05d 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 35c7701c64
but since it was introduced a few commits before that it was never
released as working.
2014-07-01 17:45:26 +02:00
Peter Krempa
f412fc9ffa 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.
2014-07-01 17:39:50 +02:00
Peter Krempa
88f3f7c390 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
2014-07-01 17:39:50 +02:00
Martin Kletzander
fb62d31151 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>
2014-07-01 17:24:27 +02:00
Michal Privoznik
7315189ec0 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>
2014-07-01 16:46:29 +02:00
Michal Privoznik
e5f5805f62 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>
2014-07-01 16:45:35 +02:00
Ján Tomko
1c7601f5c3 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
2014-07-01 16:33:14 +02:00
Ján Tomko
f638c13ea4 Introduce virFileReadAllQuiet
Just like virFileReadAll, but returns -errno instead
of reporting errors. Useful for ignoring some errors.
2014-07-01 16:32:29 +02:00
Ján Tomko
5de9b50259 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
2014-07-01 16:30:32 +02:00
Ján Tomko
1229ef493f Track privileged state in udev nodedev driver
Remember if libvirtd is running as root or not.
2014-07-01 15:29:46 +02:00
Jim Fehlig
ec7b922576 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.
2014-06-30 18:56:44 -06:00
Jim Fehlig
dc16534213 build: fix 'make syntax-check' after commit c6cf5df3
The commit caused prohibit_long_lines to fail in src/Makefile.am.
2014-06-30 18:48:19 -06:00
Jim Fehlig
c6cf5df32a 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
2014-06-30 16:34:46 -06:00
Dario Faggioli
bfc72e9992 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>
2014-06-30 14:49:22 -06:00