Commit Graph

19797 Commits

Author SHA1 Message Date
Luyao Huang
731d9cf251 qemu: Need to return status of RNG device removal
Commit id '862473fa' neglected to return the status from the
qemuDomainRemoveRNGDevice call in qemuDomainRemoveDevice causing
the function to always fail when receiving an RNG device unplug
event. Additionally the domain status/state would not be updated
in the processDeviceDeletedEvent path.

Signed-off-by: Luyao Huang <lhuang@redhat.com>
2015-06-02 14:03:48 -04:00
Luyao Huang
038a03c7a7 audit: Audit number of iothreads at domain startup
If the domain has IOThreads defined, then audit the number started
at domain startup time.

Signed-off-by: Luyao Huang <lhuang@redhat.com>
2015-06-02 14:03:48 -04:00
Eric Blake
2db6a44798 build: silence ar warnings on rawhide
Newer binutils 'ar' has added an option 'D' for deterministic
builds, and at least on rawhide, this option is enabled by default.
But it conflicts with the 'u' optimization where the linker only
modifies libraries based on file timestamps, but can result in
different library ordering based on which files were touched last.
Thus, it results in some noisy compilation, for every CCLD line:

  CCLD     libvirt_driver_qemu_impl.la
  ar: `u' modifier ignored since `D' is the default (see `U')

Upstream automake has decided that defaulting ARFLAGS to 'cru' is
no longer beneficial, and that switching the default to 'cr' will
both silence the noise and not penalize modern build systems.

https://lists.gnu.org/archive/html/automake-patches/2015-06/msg00000.html

But rather than wait for newer automake to propagate to all systems
that already have newer binutils, we might as well just use the new
default ourselves, even on older platforms.

* configure.ac: Default AR[_]FLAGS to 'cr', not 'cru'.

Signed-off-by: Eric Blake <eblake@redhat.com>
2015-06-02 11:04:58 -06:00
Laine Stump
55ace7c478 util: report all address range errors in virSocketAddrGetRange()
There are now many more reasons that virSocketAddrGetRange() could
fail, so it is much more informative to report the error there instead
of in the caller. (one of the two callers was previously assuming
success, which is almost surely safe based on the parsing that has
already happened to the config by that time, but it still is nicer to
account for an error "just in case")

Part of fix for: https://bugzilla.redhat.com/show_bug.cgi?id=985653
2015-06-02 12:40:07 -04:00
Laine Stump
198d503c64 network: cleanup range loop in networkDnsmasqConfContents
This loop had automatic variable definitions mixed with code. This
patch moves the definitions to the top of the function and puts
cleanup for them at the bottom. No functional change.

Part of fix for: https://bugzilla.redhat.com/show_bug.cgi?id=985653
2015-06-02 12:40:07 -04:00
Laine Stump
1e334a0a00 network: validate DHCP ranges are completely within defined network
virSocketAddrGetRange() has been updated to take the network address
and prefix, and now checks that both the start and end of the range
are within that network, thus validating that the entire range of
addresses is in the network. For IPv4, it also checks that ranges to
not start with the "network address" of the subnet, nor end with the
broadcast address of the subnet (this check doesn't apply to IPv6,
since IPv6 doesn't have a broadcast or network address)

Negative tests have been added to the network update and socket tests
to verify that bad ranges properly generate an error.

This resolves: https://bugzilla.redhat.com/show_bug.cgi?id=985653
2015-06-02 12:40:07 -04:00
Laine Stump
48e8b95d8e test: fix IP address range failure test
This was revealed when I made a cut-paste mistake in an upgrade to
virSocketAddrGetRange(), leading to failure to check for the end
address being outside of the defined network, but a negative test case
that should have caught the error instead returned success.

The problem was that testRange in sockettest.c was written so that
when it expected a failure, even an "unexpected success" would be
considered as an "expected failure" because of the way the check in
testRange was done. testRange had this:

 if (gotsize < 0 || gotsize != size) {
     return pass ? -1 : 0;
 } else {
     return pass ? 0 : -1;
 }

but all the tests that expected a failure give "-1" as the expected
size. So in a case where we expect a failure, we would have pass ==
false and size == -1. If virSocketAddrGetRange() was incorrectly
*successful* (returned some positive number), then "gotsize != size"
would be, e.g. "276 != -1", so we would take the if clause and, since
pass == false, we would return 0 (success i.e. expected failure).

The solution is that in the case where we expect failure, we should
just ignore size - virSocketAddrGetRange() must return -1 in order for
us to report "expected failure == success".

Part of fix for: https://bugzilla.redhat.com/show_bug.cgi?id=985653
2015-06-02 12:40:07 -04:00
Ján Tomko
18eb727fe9 Simplify virNodeCountThreadSiblings
Use a for loop instead of while.

Do not opencode c_isxdigit and virHexToBin.
2015-06-02 16:13:14 +02:00
Ján Tomko
e37bcbd9b8 Report errors in virNodeCountThreadSiblings
Use virFileReadAll which reports an error when the file is larger
than the specified maximum.

https://bugzilla.redhat.com/show_bug.cgi?id=1207849
2015-06-02 16:13:10 +02:00
Andrea Bolognani
815dc963ee virsh: Move error messages inside vshCommandOpt*() functions 2015-06-02 09:20:31 -04:00
Andrea Bolognani
be6ff4da95 virsh: Pass vshControl to all vshCommandOpt*() calls
This will allow us to use vshError() to report errors from inside
vshCommandOpt*(), instead of replicating the same logic and error
messages all over the place.

We also have more context inside the vshCommandOpt*() functions,
for example the actual value used on the command line, which means
we can produce more detailed error messages.

vshCommandOptBool() is the exception here, because it's explicitly
designed not to report any error.
2015-06-02 09:20:31 -04:00
Andrea Bolognani
5eaca29fbb virsh: Make vshCommandOptScaledInt() use vshCommandOpt()
This aligns it to the other vshCommandOpt*() functions.
2015-06-02 09:20:30 -04:00
Andrea Bolognani
e03ef9af7c virsh: Improve vshCommandOptTimeoutToMs()
Use vshCommandOptUInt() instead of parsing the value as a signed
integer and checking whether it's positive afterwards.

Improve comments as well.
2015-06-02 09:20:30 -04:00
Andrea Bolognani
d27160bb82 virsh: Use standard error messages in vshCommandOptTimeoutToMs()
I missed this in the first time around, thanks Michal for noticing.
2015-06-02 09:20:30 -04:00
Andrea Bolognani
779457a19c tests: Add a bunch of new tests to virsh-optparse
The new tests deal with numeric options of three kinds: regular,
scaled and timeouts. For each, both valid and invalid inputs
are provided, hopefully covering all cases: this should allow us
to avoid regressions when changing the relevant code in virsh.
2015-06-02 09:20:30 -04:00
Erik Skultety
c8be606bae storage: RBD: do not return error when deleting non-existent volume
RBD API returns negative value of errno, in that case we can silently
ignore if RBD tries to delete a non-existent volume, just like FS
backend does.
2015-06-02 15:02:10 +02:00
Erik Skultety
4749d82a8b storage: Don't update volume objs list before we successfully create one
We do update pool volume object list before we actually create any
volume. If buildVol fails, we then try to delete the volume in the
storage as well as remove it from our structures. The problem is, that
any backend that supports both buildVol and deleteVol would fail in this
case which is completely unnecessary. This patch causes the update to
take place after we know a volume has been created successfully, thus no
removal in case of a buildVol failure is necessary.

https://bugzilla.redhat.com/show_bug.cgi?id=1223177
2015-06-02 15:02:02 +02:00
Erik Skultety
152e315433 nwfilter: Fix sscanf off-by-one error in virNWFilterSnoopLeaseFileLoad
We allocate 16 bytes for IPv4 address and 55 bytes for interface
key, therefore we should read up to 15/54 bytes and let the last byte
reserved for terminating null byte in sscanf.

https://bugzilla.redhat.com/show_bug.cgi?id=1226400
2015-06-02 10:16:29 +02:00
Peter Krempa
f88750b931 util: process: @pid in virProcessSetAffinity's BSD impl is not unused 2015-06-02 08:38:12 +02:00
Eric Blake
7a562a5e89 maint: update to latest gnulib
Incorporates fixes for cross-compiling to mingw on rawhide, where
gcc 5.1 changes detection of how to properly determine PRIdMAX.
Also picks up some improvements for compilation on Mac OS X.

* .gnulib: Update to latest, for at least mingw.

Signed-off-by: Eric Blake <eblake@redhat.com>
2015-06-01 13:23:18 -06:00
Jim Fehlig
df37c26e73 spec: fixes for recently introduced libxl conf files
Commit 198cc1d3 introduced libxl-lockd and libxl-sanlock config
files but forgot to add them to the spec file.  Follow-up commit
62b18d98 added the files to daemon-driver-libxl, but missed adding
them to the daemon package when configuring libvirt
--without-driver-modules.  In addition, commit 62b18d98 added
libxl-sanlock to daemon-driver-libxl, but it should be included
in lock-sanlock when libvirt is configured --with-sanlock.
2015-06-01 12:01:18 -06:00
Roman Bogorodskiy
f57842ecfd libxl: load on FreeBSD
The libxl tries to check if it's running in dom0 by parsing
/proc/xen/capabilities and if that fails it doesn't load.

There's no procfs interface in Xen on FreeBSD, so this check always
fails.

In addition to checking procfs, check if /dev/xen/xenstored, that's enough to
check if we're running in dom0 in FreeBSD case.
2015-06-01 15:50:25 +03:00
Ján Tomko
0a33bba1ae virsh: make negative values with vol-resize more convenient
When shrinking a volume by a certain size, instead of typing
  vol-resize volume 1G --delta --shrink
we allow the convience of specifying a negative value:
  vol-resize volume -1G --delta --shrink
getting the same results with one more character.

A negative value only makes sense as a delta. Imply the
--delta parameter if the value is negative.

Still require --shrink, because the operation is potentially
destructive.
2015-06-01 13:56:49 +02:00
Andrea Bolognani
778c56f000 qemu: Automatically add <panic> element for pSeries guests.
The guest firmware provides the same functionality as the pvpanic
device, and the relevant element should always be present in the
domain XML to reflect this fact, so add it after parsing the
definition if it wasn't there already.
2015-06-01 06:44:37 -04:00
Andrea Bolognani
7bd769e0ab qemu: Allow panic device for pSeries guests
The guest firmware provides the same functionality as the pvpanic
device, which is not available in QEMU on pSeries, so the domain
XML should be allowed to contain the <panic> element.

On the other hand, unlike the pvpanic device, the guest firmware
can't be configured, so report an error if an address has been
provided in the XML.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1182388
2015-06-01 06:16:29 -04:00
Andrea Bolognani
b4ac4a4057 qemu: Improve error message for missing QEMU_CAPS_DEVICE_PANIC. 2015-06-01 06:16:23 -04:00
John Ferlan
cffc099356 virsh: Fix printing of XML for pool-create-as
https://bugzilla.redhat.com/show_bug.cgi?id=1224088

commit id 'bd00e00e' neglected to add the new adapter source options
into the if condition that allowed printing the <source> XML fields.
The <adapter type='fc_host'.../> doesn't require other options in order
to be complete.
2015-06-01 05:40:45 -04:00
Daniel P. Berrange
9e460562da Post-release version bump to 1.2.17 2015-06-01 10:27:12 +01:00
Daniel Veillard
77fd04aaae Release of libvirt-1.2.16
- docs/news.html.in libvirt.spec.in: update for the release
- po/*.po*: regenerate
2015-06-01 10:30:29 +08:00
Ján Tomko
0a2581a110 Allocate priv->vioserialaddrs unconditionally
When attempting to hotplug a virtio-serial console to a domain
that had no virtio-serial controllers (not even those that
are added by libvirt when some devices need them) at daemon startup,
report a user-friendly error:

error: Failed to attach device from console.xml
error: internal error: no virtio-serial controllers are available

instead of crashing the daemon:

Process terminating with default action of signal 11 (SIGSEGV): dumping core
 Access not within mapped region at address 0x8
   at 0x531028F: virDomainVirtioSerialAddrNext (domain_addr.c:916)
   by 0x531028F: virDomainVirtioSerialAddrAssign (domain_addr.c:1029)
   by 0x1CBF68: qemuDomainAttachChrDevice (qemu_hotplug.c:1565)
   by 0x1BCD5E: qemuDomainAttachDeviceLive (qemu_driver.c:7997)
   by 0x1BCD5E: qemuDomainAttachDeviceFlags (qemu_driver.c:8743)

Introduced in v1.2.14-30-g5903378.
2015-05-29 15:26:25 +02:00
Ján Tomko
5aa72904a7 Properly free the xmlDocPtr when loading pool state
Use xmlFreeDoc instead of plain xmlFree.

4 bytes in 1 blocks are definitely lost in loss record 9 of 1,084
    at 0x4C29F80: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
    by 0x70730D6: xmlStrndup (in /usr/lib64/libxml2.so.2.9.2)
    by 0x701E3DC: xmlNewDoc (in /usr/lib64/libxml2.so.2.9.2)
    by 0x70C39F8: xmlSAX2StartDocument (in /usr/lib64/libxml2.so.2.9.2)
    by 0x7017245: xmlParseDocument (in /usr/lib64/libxml2.so.2.9.2)
    by 0x7017606: xmlDoRead (in /usr/lib64/libxml2.so.2.9.2)
    by 0x5309DAD: virXMLParseHelper (virxml.c:742)
    by 0x5367584: virStoragePoolLoadState (storage_conf.c:1863)
2015-05-29 15:07:31 +02:00
Jim Fehlig
75d650dc5e libxl: support QXL video device
libxl recently gained support for QXL video device.  Support
it in the libxl driver too.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
2015-05-28 12:40:43 -06:00
Jim Fehlig
6baf881441 libxl: support SPICE graphics for HVM domains
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
2015-05-28 12:40:43 -06:00
Jim Fehlig
5a10fb1d2c libxl: change reservedVNCPorts to reservedGraphicsPorts
A later change will use the PortAllocator for SPICE too.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
2015-05-28 12:40:43 -06:00
Jim Fehlig
09f2faf933 libxl: populate build_info vfb in separate function
For HVM domains, vfb info must be populated in the libxl_domain_build_info
struct.  Currently this is done in the libxlMakeVfbList function, but IMO
it would be cleaner to populate the build_info vfb in a separate
libxlMakeBuildInfoVfb function.  libxlMakeVfbList would then handle only
vfb devices, simiar to the other libxlMake<device>List functions.

A future patch will extend libxlMakeBuildInfoVfb to support SPICE.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
2015-05-28 12:40:43 -06:00
John Ferlan
6839b08ba1 storage: Fix problem with disk backend pool allocation calculation
https://bugzilla.redhat.com/show_bug.cgi?id=1224018

The disk pool recalculates the pool allocation, capacity, and available
values each time through processing a newly created disk partition. This
created an issue with the allocation setting since the code used is shared
with the refresh path. Each path calls virStorageBackendDiskReadPartitions
which initializes the pool values and then processes the partition table
from the 'libvirt_parthelper' utility output with the only difference being
create passes a specific volume to be processed while refresh pass a NULL
indicating to process all volumes. That passed volume is check during the
virStorageBackendDiskMakeVol call to see if the current partition described
by the volume key already exists. If it exists, then no adjustments are
made to the allocation and the next entry in the output is checked.

For the create path this resulted in only the most recently created
partition size would be accounted for in the 'allocation' setting. This
patch thus checks whether the incoming volume is NULL before clearing
the pool allocation value.
2015-05-28 13:32:16 -04:00
John Ferlan
48809204d1 storage: Don't adjust pool alloc/avail values for disk backend
Commit id '2ac0e647' for https://bugzilla.redhat.com/show_bug.cgi?id=1206521
was meant to be a generic check for the CreateVol, CreateVolFrom, and
DeleteVol paths to check if the storage backend's changed the pool's view
of allocation or available values.

Unfortunately as it turns out this caused a side effect when the disk backend
created an extended partition there would be no actual storage removed from
the pool, thus the changes would not find any change in allocation or
available and incorrectly update the pool values using the size of the
extended partition. A subsequent refresh of the pool would reset the
values appropriately.

This patch modifies those checks in order to specifically not update the
pool allocation and available for only the disk backend rather than be
generic before and after checks.
2015-05-28 13:32:16 -04:00
John Ferlan
6727bfd728 Revert "storage: Don't duplicate efforts of backend driver"
This reverts commit 2ac0e647bd.
2015-05-28 13:32:16 -04:00
Laine Stump
e983e62514 debug: assure NULLSTR() around all %s args in debug at top of public APIs
There are also a couple that were very uninformatively just logging
the value of the pointer rather than the string itself:

* the "name" arg to virNodeDeviceLookupByName()
* wwnn and wwpn args to virNodeDeviceLookupSCSIHostByWWN()

All char*'s that make sense should now have their contents logged
rather than the pointer, and all %s args should now be inside
NULLSTR().
2015-05-28 13:13:45 -04:00
Laine Stump
06a18bc84b node_device: more informative error log when device isn't found
In a couple of cases, the node device driver (and the test node device
driver which likely copied it) was only logging "Node device not
found" when it couldn't find the requested device. This patch changes
those cases to log the name (and in the case when it's relevant, the
wwnn and wwpn) as well.
2015-05-28 12:48:45 -04:00
Kothapally Madhu Pavan
6074f8316c virsh: Fix to list online cpus using virsh capabilities
Virsh capabilities will list offline cpus as online when
libvirt is compiled with numactl option disabled. This
fix will list correct set of online cpus.
2015-05-28 17:23:53 +02:00
Ján Tomko
61139c4438 Fix the event name in vshEventTrayChangePrint
https://bugzilla.redhat.com/show_bug.cgi?id=1206114#c5

Reported by: zhenfeng wang <zhwang@redhat.com>
2015-05-28 14:14:47 +02:00
Ján Tomko
8b316fe5da Fix shrinking volumes with the delta flag
This never worked.

In 0.9.10 when this API was introduced, it was intended that
the SHRINK flag combined with DELTA would shrink the volume by
the specified capacity (to avoid passing negative numbers).
See commit 055bbf4.

When the SHRINK flag was finally implemented for the first backend
in 1.2.13 (commit aa9aa6a), it was only implemented for the absolute
values and with the delta flag the volume is always extended,
regardless of the SHRINK flag.

Treat the SHRINK flag as a minus sign when used together with DELTA,
to allow shrinking volumes as was documented in the API since 0.9.10.

https://bugzilla.redhat.com/show_bug.cgi?id=1220213
2015-05-28 14:10:32 +02:00
Ján Tomko
7211f66ad7 Simplify allocation check in storageVolResize
Since shrinking a volume below existing allocation is not allowed,
it is not possible for a successful resize with VOL_RESIZE_ALLOCATE
to increase the pool's available value.

Even with the SHRINK flag it is possible to extend the current
allocation or even the capacity. Remove the overflow when
computing delta with this flag and do the check even if the
flag was specified.

https://bugzilla.redhat.com/show_bug.cgi?id=1073305
2015-05-28 14:10:09 +02:00
Maxim Nestratov
30ae685780 parallels: suppress console output from parallels SDK
It is necessary to have unpolluted screen when connecting to
parallels driver via virsh.
Otherwise a lot of unexpected output one will get on the console.

Signed-off-by: Maxim Nestratov <mnestratov@parallels.com>
2015-05-28 12:58:44 +03:00
Lubomir Rintel
efc68de5cd interface: don't error out if a bond has no interfaces
It's not a problem at all and causes virt-manager to break down.

Note: netcf 0.2.8 and earlier generates invalid XML for a bond with no
interfaces anyway, so in that case this error in libvirt is never
reached since we fail earlier.

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
2015-05-27 14:25:45 -04:00
Andrea Bolognani
ceab3979de qemu: Limit rtc-reset-reinjection requirement to x86 only.
The QMP command, like the interrupt reinjection logic it's connected
to, is only implemented in QEMU when TARGET_I386 is defined, so
checking for its availability on any other architecture is pointless.

On the other hand, when we're on x86, we shouldn still make sure that
rtc-reset-reinjection is available and refuse to set the time
otherwise.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1211938
2015-05-27 16:59:25 +02:00
Martin Kletzander
7d0481cb93 storage_fs: Create directory with UID if needed
The code already exists there, it just modified different flags.  I just
noticed this when looking at the code.  This patch is better to view
with bigger context or '-W'.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2015-05-27 16:59:25 +02:00
Zhang Bo
39d0396f39 util: make it more robust to calculate timeout value
When we change system clock to years ago, a certain CPU may use up 100% cputime.
The reason is that in function virEventPollCalculateTimeout(), we assign the
unsigned long long result to an INT variable,
        *timeout = then - now; // timeout is INT, and then/now are long long
        if (*timeout < 0)
            *timeout = 0;
there's a chance that variable @then minus variable @now may be a very large number
that overflows INT value expression, then *timeout will be negative and be assigned to 0.
Next the 'poll' in function virEventPollRunOnce() will get into an 'endless' while loop there.
thus, the cpu that virEventPollRunOnce() thread runs on will go up to 100%.

Although as we discussed before in https://www.redhat.com/archives/libvir-list/2015-May/msg00400.html
it should be prohibited to set-time while other applications are running, but it does
seems to have no harm to make the codes more robust.

Signed-off-by: Wang Yufei <james.wangyufei@huawei.com>
Signed-off-by: Zhang Bo <oscar.zhangbo@huawei.com>
2015-05-27 16:59:18 +02:00
Roman Bogorodskiy
b071ec4347 zfs: fix storagepoolxml2xml test
Commit 7c2d65d dropped setting default mode.

Update zfs tests accordingly.
2015-05-27 14:03:42 +04:00