misc: handle scientific notation in readspeed

When the amount of bytes is low and the speed is high the elapsed time
is expressed using the scientific notation.

In this patch:
* handle dd errors
* minor fix to make _readfile prettier

Bug-Url: http://bugzilla.redhat.com/show_bug.cgi?id=948232
Change-Id: I05168fe44e987e684c42392b1e64f1885533cc7d
Signed-off-by: Federico Simoncelli <fsimonce@redhat.com>
Reviewed-on: http://gerrit.ovirt.org/15433
Reviewed-by: Dan Kenigsberg <danken@redhat.com>
Tested-by: Dan Kenigsberg <danken@redhat.com>
Improve __prefetch logging.

Related-To: https://bugzilla.redhat.com/show_bug.cgi?id=967296

Change-Id: I2c00fc114a8582aad15280f502a8a035d22af2a4
Signed-off-by: Eduardo <ewarszaw@redhat.com>
Reviewed-on: http://gerrit.ovirt.org/15483
Reviewed-by: Dan Kenigsberg <danken@redhat.com>
Tested-by: Elad Ben Aharon <eladba1990@gmail.com>
fix testBuildCmdLine not to be upstream-specific

A certain downstream product would like to change SMBIOS_PRODUCT without
failing the unit test.

Change-Id: Icf2fff6d0de0c97b83f800a9264753f4478b6094
Signed-off-by: Dan Kenigsberg <danken@redhat.com>
Reviewed-on: http://gerrit.ovirt.org/15507
Reviewed-by: Antoni Segura Puimedon <asegurap@redhat.com>
Add "service-reload" command to vdsm-tool service module

"vdsm-tool service-reload XXXd" will notify the system service to reload
its configurations

Change-Id: I97d818fc1bec005f0a2470525080dfcec43d5aa4
Signed-off-by: Zhou Zheng Sheng <zhshzhou@linux.vnet.ibm.com>
Reviewed-on: http://gerrit.ovirt.org/14727
Reviewed-by: Dan Kenigsberg <danken@redhat.com>
multipath.py: use vdsm.tool.service to restart multipathd

multipath.py restart and reload multipathd using service command
directly. This patch uses vdsm-tool service module to manage the system
service improves portability. It covers SysV, SystemD and Upstart as
well as possible daemon names in various systems (multipathd is named
multipath-tools in Ubuntu).

Change-Id: I1130a4baf770b805aaea8de97556d18a2da86207
Signed-off-by: Zhou Zheng Sheng <zhshzhou@linux.vnet.ibm.com>
Reviewed-on: http://gerrit.ovirt.org/14728
Reviewed-by: Aravinda VK <avishwan@redhat.com>
Reviewed-by: Ewoud Kohl van Wijngaarden <ewoud@kohlvanwijngaarden.nl>
Reviewed-by: Dan Kenigsberg <danken@redhat.com>
iscsi: report hba sessions as fiber channel

At the moment the engine doesn't support static (unmanaged) iscsi
connections therefore it's safer to maintain the old behavior and
report the HBA iscsi sessions as if they were fiber channel devices.

Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=967605
Change-Id: I9b87aafc89a502c872ceec6a55b49d9e49d1ee9f
Signed-off-by: Federico Simoncelli <fsimonce@redhat.com>
Reviewed-on: http://gerrit.ovirt.org/15161
NetReload: netmodels for delNetwork

This patch re-implements the delNetwork logic using the network
entities defined in netmodels.

Change-Id: I9e11fd923a4f5d07d069193278f3eadc94f327ec
Signed-off-by: Mark Wu <wudxw@linux.vnet.ibm.com>
Signed-off-by: Antoni S. Puimedon <asegurap@redhat.com>
Reviewed-on: http://gerrit.ovirt.org/14873
Reviewed-by: Dan Kenigsberg <danken@redhat.com>
vdsm: vmChannels: Do not use epoll unregister

We don't use epoll.unregister for the deregistration from epoll anymore.
According to the epoll documentation, epoll will remove the fd when the
fd was closed.
Since we're always closing the sockets where this is used and we
otherwise might run into race conditions we're no longer calling
epoll.unregister to avoid attempts to unregister fds which might no
longer belong to us.

The problem on this race condition is that we're handling file descriptors
by numbers. When we're ending the GuestAgent by calling stop() it will send
the fd to the listener thread by inserting it into a queue so the listener
can handle it the next time. However we're immediately closing the socket and
the OS is free to reuse the fd. By the time we're going to unregister the fd
from epoll the fd might have been already reused for our process by the OS
because it reassigns the lowest available fileno.

To solve this issue we're using the capability of epoll to detect closed
fds and rely on it's mechanism to unregister them. By that we're not running
into the issue of unregistering the fd from fd which might have been already
already assigned to a different object.

Change-Id: Iacb8dee05e179405d7946bef7329ca406223744a
Signed-off-by: Vinzenz Feenstra <vfeenstr@redhat.com>
Reviewed-on: http://gerrit.ovirt.org/15393
Reviewed-by: Dan Kenigsberg <danken@redhat.com>
Reviewed-by: Lee Yarwood <lyarwood@redhat.com>
Move removing libvirt network to configurator

This patch adds a wrapper for the configWriter.removeLibvirtNetwork()
in configurator and call it in delNetwork because we should try to
avoid using ConfigWriter directly in configNetwork.py

Change-Id: Id254a05bb428fde0b5321e33a31d79dddc1ce1ba
Signed-off-by: Mark Wu <wudxw@linux.vnet.ibm.com>
Reviewed-on: http://gerrit.ovirt.org/15417
Reviewed-by: Antoni Segura Puimedon <asegurap@redhat.com>
Reviewed-by: Dan Kenigsberg <danken@redhat.com>
gluster: fix remove disabled hook exception handling error

Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=971775
Change-Id: Ie37e27f2a42e663c74fa2f8a3f43f31b28a72840
Signed-off-by: Timothy Asir <tjeyasin@redhat.com>
Reviewed-on: http://gerrit.ovirt.org/15506
Reviewed-by: Aravinda VK <avishwan@redhat.com>
Reviewed-by: Dan Kenigsberg <danken@redhat.com>
Simplify setNewMtu()

It will update the interface's MTU only if its user being removed has
the maximum MTU.

Change-Id: I32e8e0d45b7887af8fd1b003fd4c358826b77289
Signed-off-by: Mark Wu <wudxw@linux.vnet.ibm.com>
Signed-off-by: Antoni S. Puimedon <asegurap@redhat.com>
Reviewed-on: http://gerrit.ovirt.org/15355
Reviewed-by: Giuseppe Vallarelli <gvallare@redhat.com>
Reviewed-by: Dan Kenigsberg <danken@redhat.com>
fix for after_vm_dehibernate hook not being called

Due to what seems to be a copy-paste or typo problem, the
after_vm_hibernate hook was called instead of after_vm_dehibernate
hook after the vm is being dehibernated. This patch correct that call.

Change-Id: I6851c1253efe2fc4a9fbf4568b930b598df45680
Signed-off-by: Arik Hadas <ahadas@redhat.com>
Reviewed-on: http://gerrit.ovirt.org/15656
Reviewed-by: Michal Skrivanek <michal.skrivanek@redhat.com>
Reviewed-by: Dan Kenigsberg <danken@redhat.com>
QoS feature: Adds bandwitdh elem to a network interface definition.

NetworkInterfaceDevice can now generate xml definition for shaping
incoming and outgoing traffic supported attributes are the following
ones: average, burst and peak.

Change-Id: Iec7c61d2713270dc8e46ee01f155e2ad54c748a5
Signed-off-by: Giuseppe Vallarelli <gvallare@redhat.com>
Reviewed-on: http://gerrit.ovirt.org/15445
Reviewed-by: Dan Kenigsberg <danken@redhat.com>
vdsm-tool: avoid service action redirections

Some smart init system will redirect actions to other init system when
the service is not managed natively. This behaviour interferes the
parsing of the service action output.

Add a decorator _XXXNative to check if a service is managed by a certain
init system. _XXXNative tag is then added to every action function to
avoid execution of an action on a service that is not managed by that
particular init system, so as to avoid redirections.

An environment variable is also added for SysV actions to prevent
redirection to SystemD, this is specific for those systems with
co-existence of SystemD and SysV, and is no harm to those systems with
only SysV or with co-existence of Upstart and SysV.

Change-Id: Idff541a724e3e2d2167b1f235af5ed04a3dc2ee0
Signed-off-by: Zhou Zheng Sheng <zhshzhou@linux.vnet.ibm.com>
Reviewed-on: http://gerrit.ovirt.org/15099
Reviewed-by: Dan Kenigsberg <danken@redhat.com>
vdsm-tool: extend "service" module to check existence of a service

Add a service-is-managed command to check if a service is managed by
either of the supported init systems. With the decorator _XXXNative in
previous commit, the implementation of service-is-managed command is
straight forward: just add _XXXNative tag to a action function that
always succeeds.

Change-Id: I23a7d98e39eaacd5f2dfa817bfae6defb5fc9ebe
Signed-off-by: Zhou Zheng Sheng <zhshzhou@linux.vnet.ibm.com>
Reviewed-on: http://gerrit.ovirt.org/15100
Reviewed-by: Dan Kenigsberg <danken@redhat.com>
vdsmd.init: ajust libvirt log file

Nowadays VDSM configure libvirt daemon to log into /var/log/libvirtd.log.
This patch will make vdsm set the log file into the current default
location for libvirt logs /var/log/libvirt/libvirtd.conf.

Change-Id: Iee325d456cc3d184c0084c4bf547bc126a00938a
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=755548
Signed-off-by: Douglas Schilling Landgraf <dougsland@redhat.com>
Reviewed-on: http://gerrit.ovirt.org/14842
Reviewed-by: Dan Kenigsberg <danken@redhat.com>
Added 3.2 to SupportedENGINES in dsaversion

Change-Id: Ia3a0bd0edecd24a00edc0a5b07cad59d2c27bd7e
Signed-off-by: Assaf Muller <amuller@redhat.com>
Reviewed-on: http://gerrit.ovirt.org/15663
Reviewed-by: Dan Kenigsberg <danken@redhat.com>
Added 3.3 to SupportedENGINES in dsaversion

Change-Id: I16b668f4d494c1c63fe89f8c54e5c13b94dc2911
Signed-off-by: Amador Pahim <apahim@redhat.com>
Reviewed-on: http://gerrit.ovirt.org/15675
Reviewed-by: Douglas Schilling Landgraf <dougsland@redhat.com>
Reviewed-by: Dan Kenigsberg <danken@redhat.com>
introducing virtio-scsi support

Drive class:
* makeName - map 'scsi' to 'sd'
* getXML:
- added 'sgio' flag [1]
- device='lun' is used instead of device='disk' for supporting
  LUN passthrough (which can be used with virtio-scsi).
  Hence, adding 'driver' tag similarly to 'disk' device.

LibvirtVm class:
* getUnderlyingDriveInfo - get/set 'sgio' attribute.

TestLibvirtvm class:
* testControllerXML - test 'virtio-scsi' controller
* testDriveXML:
- test virtio-scsi image disk
- test virtio-scsi LUN passthrough

API Schema:
* Updated:
- VmDiskDeviceInterface
- VmDiskDeviceType
- VmControllerDevice

[1] 'sgio': SCSI Generic IO - filtered/unfiltered
(indicates whether the kernel will filter unprivileged
SG_IO commands for the disk).

Change-Id: If624064269328253dbc3cb32a72e20f01cdb0958
Signed-off-by: Daniel Erez <derez@redhat.com>
Reviewed-on: http://gerrit.ovirt.org/14681
Reviewed-by: Federico Simoncelli <fsimonce@redhat.com>
BZ#836161 - Remove code obsoleted by deleteImage() rewrite.

This is a separate patch for improved readability.

Related to BZ#910013, BZ#905938, BZ#875708, BZ#864073

Change-Id: Icf01de7dc8bf0a903ebf94d9e33ffad9a195b7de
Signed-off-by: Eduardo <ewarszaw@redhat.com>
Reviewed-on: http://gerrit.ovirt.org/8507
Reviewed-by: Sergey Gotliv <sgotliv@redhat.com>
Reviewed-by: Ayal Baron <abaron@redhat.com>
Reviewed-by: Allon Mureinik <amureini@redhat.com>
Tested-by: Elad Ben Aharon <eladba1990@gmail.com>
Reviewed-by: Dan Kenigsberg <danken@redhat.com>