Commit Graph

17642 Commits

Author SHA1 Message Date
John Ferlan
30c3982bda qemu: Use qemuAliasFromDisk to generate drive alias
The qemuDomainSnapshotCreateSingleDiskActive open coded generating the
disk drive alias. Let's use the common function.
2016-08-02 10:11:11 -04:00
John Ferlan
f8d49d5b9f qemu: Remove generation of drive alias from qcow passphrase backends
Rather than pass the disks[i]->info.alias to qemuMonitorSetDrivePassphrase
and then generate the "drive-%s" alias from that, let's use qemuAliasFromDisk
prior to the call to generate the drive alias and then pass that along
thus removing the need to generate the alias from the monitor code.
2016-08-02 10:11:11 -04:00
John Ferlan
675a7e4ec1 qemu: Reorder qemuDomainAttachUSBMassStorageDevice failure path
Modify the error/exit path to match what was done for Virtio and SCSI.
If nothing else it'll have a consistent look'n'feel
2016-08-02 10:11:11 -04:00
Jovanka Gulicoska
546fa3ef67 node_device: Implement event queue in udev 2016-08-02 09:52:00 -04:00
Jovanka Gulicoska
bb7513eae2 node_device: implement node device lifecycle event APIs 2016-08-02 09:52:00 -04:00
Jovanka Gulicoska
9b13df379c remote: implement node device lifecycle event APIs 2016-08-02 09:52:00 -04:00
Jovanka Gulicoska
1f12580a64 test: implement node device lifecycle event APIs
Also includes unittests for node device lifecycle events API
2016-08-02 09:52:00 -04:00
Jovanka Gulicoska
9806ae04dd conf: add node_device_event handling
Add node device event handling infrastructure to node_device_event.[ch]
2016-08-02 09:52:00 -04:00
Jovanka Gulicoska
fcabc1ca53 Introduce node device lifecycle event APIs
Node device lifecycle event API entry points for registering and
deregistering node deivce events, as well as types of events
associated with node device.
These entry points will be used for implementing asynchronous
lifecycle events.

Node device API:
virConnectNodeDeviceEventRegisterAny
virConnectNodeDeviceEventDeregisterAny
virNodeDeviceEventLifecycleType which has events CREATED and DELETED
2016-08-02 09:52:00 -04:00
Nikolay Shirokovskiy
b0c144c579 qemu: Set fake reboot flag to false when mode=agent
As commit id 'e2b86f580' notes, when mode=agent possibly setting the
fake reboot flag to true wouldn't be necessary; however, it doesn't
"force" the issue by just ensuring the fake reboot is false, so this
patch adds the explicit setting for the reboot path.

More investigation and details can be found in commit id '8be502fd'
as well as in the archives at:

  https://www.redhat.com/archives/libvir-list/2015-April/msg00715.html
2016-08-02 09:28:32 -04:00
Nikolay Shirokovskiy
3b676eb67f qemu: Set fake reboot flag only in acpi mode for shutdown
Conditional setting of the fake reboot flag should only happen for
the acpi mode shutdown path; however, for the agent mode shutdown,
the fake reboot should be cleared. This patch will essentially revert
commit id '8be502fd', but adds an explicit setting of the flag to false
when using mode=agent while also only conditionally setting the reboot
flag if the guest went away. This also avoids an issue where a shutdown
with reboot semantics is done from agent mode which sets the reboot
flag followed by a shutdown from within the guest which would result
in a reboot due to the fake reboot flag being set. The change will
also properly handle the cases described in the following archive post:

  https://www.redhat.com/archives/libvir-list/2015-April/msg00715.html
2016-08-02 09:28:32 -04:00
John Ferlan
172218a01e libxl: Fix broken build attach/detach controller device
Commit id '44304c6eb' added the API libxlDomainAttachControllerDevice
inside a conditional LIBXL_HAVE_PVUSB, but called that function outside
the conditional in libxlDomainAttachDeviceLive.

Similarly, the API libxlDomainDetachControllerDevice was added inside a
conditional LIBXL_HAVE_PVUSB, but called outside the conditional in
libxlDomainDetachDeviceLive.

This patch adds the conditional LIBXL_HAVE_PVUSB around those two calls
from within the switch.
2016-08-02 09:20:32 -04:00
John Ferlan
1bfdd95641 libxl: Fix broken build from libxlDomainCleanup
Commit id '7d3b2eb5' missed a closing parenthesis on the ignore_value
macro, causing the failure
2016-08-02 09:18:56 -04:00
Erik Skultety
238b20b47f rpc: virnetserver: Remove dead code checking the client limits
Prior to commit 2737aaaf, we allowed every client to connect successfully,
however, if accepting a client would eventually lead to an overcommit of the
limits, we would disconnect it immediately with "Too many active clients,
dropping connection from...". Recent changes refactored the code in a way, that
it is not possible for the client-related callback to be dispatched and the
client to be accepted if the limits wouldn't permit to do so, therefore a check
if a connection should be dropped due to limits violation has become a dead
code that could be removed.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
2016-08-02 14:51:13 +02:00
Erik Skultety
e9ce8a7d24 admin: rpc: virnetserver: Fix updating of the client limits
Commit 2737aaaf changed our policy for accepting new clients in a way, that
instead of accepting new clients only to disconnect them immediately, since
that would overcommit the limit, we temporarily disable polling for the
dedicated file descriptor, so any new connection will queue on the socket.
Commit 8b1f0469 then added the possibility to change the limits during runtime
but it didn't re-enable polling for the previously disabled file descriptor,
thus any new connection would still continue to queue on the socket. This patch
forces an update of the services each time the limits were changed in some way.

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

Signed-off-by: Erik Skultety <eskultet@redhat.com>
2016-08-02 14:51:13 +02:00
Erik Skultety
5b9f735f16 rpc: virnetserver: Add code to CheckLimits to handle suspending of services
So far, virNetServerCheckLimits was only used to possibly re-enable accepting
new clients that might have previously been disabled due to client limits
violation (max_clients, max_anonymous_clients). This patch refactors
virNetServerAddClient, which is currently the only place where the services get
disabled, in order to use the virNetServerCheckLimits helper instead of
checking the limits by itself.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
2016-08-02 14:51:13 +02:00
Erik Skultety
17bc333411 rpc: virnetserver: Move virNetServerCheckLimits which is static up in the file
Since virNetServerAddClient checks for the limits in order to temporarily
suspend the services, thus not accepting any more clients, there is no reason
why virNetServerCheckLimits, which is only responsible for re-enabling
previously disabled services according to the limits, could not do both. To be
able to do that however, it needs to be moved up in the file since it's static
(and because it's just a helper and there's only one caller it should remain
 static).

Signed-off-by: Erik Skultety <eskultet@redhat.com>
2016-08-02 14:51:13 +02:00
Erik Skultety
2e5417bc46 rpc: virnetserver: Rename ClientSetProcessingControls to ClientSetLimits
The original naming was just a leftover that should have been fixed in commit
8b1f0469.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
2016-08-02 14:51:13 +02:00
Cédric Bosdonnat
7d3b2eb58f libxl: add hooks support
Introduce libxl hook and use it for start, prepare, started,
stop, stopped, migrate events.
2016-08-02 14:20:31 +02:00
Cédric Bosdonnat
a9aafc0aa0 libxl: fix segfault in libxlReconnectDomain
In case of error, libxlReconnectDomain may call
virDomainObjListRemoveLocked. However it has no local reference on
the domain object, leading to segfault. Get a reference to the domain
object at the start of the function and release it at the end to avoid
problems.

This commit also factorizes code between the error and normal ends.
2016-08-02 14:20:31 +02:00
Cédric Bosdonnat
db38eb4068 libxl: add a flag to mark guests as tainted by a hook
The migrate hook will affect the migrated guest definition. Allow
these domains be marked as tainted in the libxl driver.
2016-08-02 14:20:31 +02:00
Chunyan Liu
c6f0e177a3 qemuDomainDeviceDefPostParse: add USB controller model check
To sync with virDomainControllerModelUSB, we add two models
in qemuControllerModelUSB 'qusb1' and 'qusb2', but those
models are not supported in qemu driver. So add check in
device post parse to report errors if 'qusb1' and 'qusb2'
are specified.

Signed-off-by: Chunyan Liu <cyliu@suse.com>
2016-08-02 14:02:21 +02:00
Chunyan Liu
9a361bbba8 xenconfig: add conversion of usb controller config to and from xml
libxl configuration files conversion can now handle USB controllers.
When parting libxl config file, USB controllers with type PV are
ignored as those aren't handled.

Signed-off-by: Chunyan Liu <cyliu@suse.com>
2016-08-02 14:02:21 +02:00
Chunyan Liu
f5359e55ec libxl: check available controller and port when hotplugging USB device
When hotplugging a USB device, check if there is an available controller
and port, if not, automatically create a USB controller of version
2.0 and 8 ports.

Signed-off-by: Chunyan Liu <cyliu@suse.com>
2016-08-02 14:02:21 +02:00
Chunyan Liu
44304c6eb7 libxl: support usb controller hotplug
Support USB controller hot-plug and hot-unplug.

 #virsh attach-device dom usbctrl.xml
 #virsh detach-device dom usbctrl.xml
 usbctrl.xml example:
 <controller type='usb' index='0' model='qusb2'>

Signed-off-by: Chunyan Liu <cyliu@suse.com>
2016-08-02 14:02:21 +02:00
Chunyan Liu
770bf992c6 libxl: support USB controllers in creation time
To support USB Controller in xen guest domains, just add
USB controller in domain config xml as following:
<controller type='usb' model='qusb2' ports='4'/>

Signed-off-by: Chunyan Liu <cyliu@suse.com>
2016-08-02 14:02:21 +02:00
Chunyan Liu
be146b349f extend usb controller model to support xen pvusb
According to libxl implementation, it supports pvusb
controller of version 1.1 and version 2.0, and it
supports two types of backend, 'pvusb' (dom0 backend)
and 'qusb' (qemu backend). But currently pvusb backend
is not checked in yet.

To match libxl support, extend usb controller schema
to support two more models: qusb1 (qusb, version 1.1)
and 'qusb2' (qusb version 2.0).

Signed-off-by: Chunyan Liu <cyliu@suse.com>
2016-08-02 14:02:21 +02:00
Peter Krempa
e44cdaf80b qemu: cap: Refactor access to array in virQEMUCapsProbeQMPMachineTypes
Use a temporary pointer rather than always recalculating the index in a
very verbose way.
2016-08-02 13:50:36 +02:00
Peter Krempa
ceec23d97f qemu: caps: Sanitize storage of machine type related data
Add a structure to store the data and use a single array of the
structures rather than having 3 separate arrays with shared indexes.
2016-08-02 13:49:29 +02:00
Peter Krempa
d2d5a91126 qemu: capabilities: Drop unused function virQEMUCapsGetMachineTypes 2016-08-02 13:49:29 +02:00
Martin Kletzander
068fde5fcf storage: Clean up volume wiping
Let's cleanly differentiate what wiping a volume does for ploop and
other volumes so it's more readable what is done for each one instead of
branching out multiple times in different parts of the same function.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-08-02 13:21:01 +02:00
Martin Kletzander
430c4ca771 storage: Use path instead of volume as an argument
Some functions use volume specification merely to use the target path
from it.  Let's change it to pass the path only so that it can be used
for other files than just volumes.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-08-02 13:21:01 +02:00
Martin Kletzander
8929d6d00b storage: Move functions around
This is done in order to call them in next patches from each other and
definitions would be missing otherwise.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-08-02 13:21:01 +02:00
Martin Kletzander
daf01a6125 qemu: Fix domain state after reset
When reset was called from a domain that crashed we didn't change the
crashed state into a paused one which could confuse users.

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-08-02 13:21:01 +02:00
Martin Kletzander
a2b97a8d91 qemu: Fix support for startupPolicy with volume/pool disks
Until now we simply errored out when the translation from pool+volume
failed.  However, we should instead check whether that disk is needed or
not since there is an option for that.

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-08-02 13:21:01 +02:00
Martin Kletzander
779a4ea906 qemu: Remove unnecessary label and its only reference
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-08-02 13:21:01 +02:00
Martin Kletzander
e2705cfb6e qemu: Make qemuDomainCheckDiskStartupPolicy self-contained
There is an error reset following the function and check for
startupPolicy before that.  Let's reflect those things inside that
function so that future code doesn't have to be that complex.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-08-02 13:21:01 +02:00
Yuri Chornoivan
b277a612c0 Fix unbalanced quotation marks 2016-08-02 12:36:21 +02:00
Daniel Veillard
f9243229fd Revert "Fix unbalanced quotation marks"
This reverts commit 6a40801186.
release of 2.1.0 need to go first
2016-08-02 12:34:18 +02:00
Yuri Chornoivan
6a40801186 Fix unbalanced quotation marks 2016-08-02 09:04:39 +02:00
Martin Kletzander
fa4eea8063 storage: Document wiping formatted volume types
When wiping a volume we just rewrite all the data of the volume, not
only the content.  Since format gets overridden, we need to recreate the
volume.  However we can't do that for every possible format out there.
Since it was only coded for the ploop volume type, let's document what
might be the consequences instead of forbidding it for every other
format out there.

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-08-02 07:01:57 +02:00
Boris Fiuczynski
230c631917 qemu: remove panic dev models s390 and pseries when migrating
The panic devices with models s390 and pseries are autogenerated.
For backwards compatibility reasons the devices are to be removed
when migrating.

Signed-off-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2016-08-01 14:15:08 +02:00
Sascha Silbe
a5c420471b qemu: fix domain id after domainCreateWithFlags()
Ever since virDomainCreateWithFlags() was introduced by de3aadaa
[drivers: add virDomainCreateWithFlags if virDomainCreate exists], the
domain ID retrieved with virDomainGetID() was incorrect for several
drivers after virDomainCreateWithFlags() was called. The API consumer
had to look up the domain anew to retrieve the correct ID.

For the ESX driver, this was fixed in 6139b274 [esx: Update ID after
starting a domain]. For the openvz driver, it was fixed in fd81a097
[openvzDomainCreateWithFlags: set domain id to the correct value]. The
test driver, the OpenNebula driver (removed in the meantime) and the
vbox driver were already updating the domain ID correctly in
domainCreate().

Copy over the ID in qemuDomainCreateWithFlags() to fix this for the qemu
driver, too.

Fixes: de3aadaa ("drivers: add virDomainCreateWithFlags if virDomainCreate exists")
Reported-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
Signed-off-by: Sascha Silbe <silbe@linux.vnet.ibm.com>
Tested-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
Reviewed-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
2016-08-01 11:28:20 +02:00
Michal Privoznik
1e05846373 conf: Catch invalid memory model earlier
Consider the following XML snippet:

    <memory model=''>
      <target>
        <size unit='KiB'>523264</size>
        <node>0</node>
      </target>
    </memory>

Whats wrong you ask? The @model attribute. This should result in
an error thrown into users faces during virDomainDefine phase.
Except it doesn't. The XML validation catches this error, but if
users chose to ignore that, they will end up with invalid XML.
Well, they won't be able to start the machine - that's when error
is produced currently. But it would be nice if we could catch the
error like this earlier.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-07-29 11:03:24 +02:00
Erik Skultety
f5f32bcd1b admin: Fix default uri config option name s/admin_uri_default/uri_default
The original name 'admin_uri_default' was introduced to our code by commit
dbecb87f. However, at that time we already had a separate config file for
admin library but the commit mentioned above didn't properly adjust the
config's option name. The result is that when we're loading the config, we
check a non-existent config option (there's not much to do with the URIs
anyway, since we only allow local connection). Additionally, virt-admin's man
page documents, that the default URI can be altered by setting
admin_uri_default option. So the fix proposed by this patch leaves the
libvirt-admin.conf as is and adjusts the naming in the code as well as in the
virt-admin's man page.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
2016-07-29 09:21:09 +02:00
John Ferlan
8ad7eceb20 qemu: Need to free fileprops in error path
The virJSONValueObjectCreate only consumes the object on success, so on
failure we must free - from commit id 'f4441017' (found by Coverity).
2016-07-28 09:25:40 -04:00
John Ferlan
5d8c31c6b2 iscsi: Establish connection to target via static target login
https://bugzilla.redhat.com/show_bug.cgi?id=1356436

Commit id '56057900' altered the discovery of iSCSI node targets by
using the "--op nonpersistent". This caused issues for clean environments
or if by chance a "-m node -o delete" was executed.

Since each iSCSI Storage Pool has the required iSCSI target path, use
that and the virISCSINodeNew API in order to generate the iSCSI node record.
2016-07-28 08:27:13 -04:00
John Ferlan
ae65c908b7 util: Introduce virISCSINodeNew
https://bugzilla.redhat.com/show_bug.cgi?id=1356436

According to RFC 3721 (https://www.ietf.org/rfc/rfc3721.txt), there are
two ways to "discover" targets in/for the iSCSI environment. Discovery
is the process which allows the initiator to find the targets to which
it has access and at least one address at which each target may be
accessed.

The method currently implemented in libvirt using the virISCSIScanTargets
API is known as "SendTargets" discovery. This method is more useful when
the target IP Address and TCP port information are available, e.g. in
libvirt terms the "portal". It returns a list of targets for the portal.
From that list, the target can be found. This operation can also fill an
iSCSI node table into which iSCSI logins may occur. Commit id '56057900'
altered that filling by adding the "--op nonpersistent" since it was
not necessarily desired to perform that for non libvirt related targets.

The second method is "Static Configuration". This method not only needs
the IP Address and TCP port (e.g. portal), but also the iSCSI target name.
In libvirt terms this would be the device path field from the iSCSI pool
<source> XML. This patch implements the second methodology using that
required device path as the targetname.
2016-07-28 08:27:13 -04:00
Daniel P. Berrange
a48c714115 storage: remove "luks" storage volume type
The current LUKS support has a "luks" volume type which has
a "luks" encryption format.

This partially makes sense if you consider the QEMU shorthand
syntax only requires you to specify a format=luks, and it'll
automagically uses "raw" as the next level driver. QEMU will
however let you override the "raw" with any other driver it
supports (vmdk, qcow, rbd, iscsi, etc, etc)

IOW the intention though is that the "luks" encryption format
is applied to all disk formats (whether raw, qcow2, rbd, gluster
or whatever). As such it doesn't make much sense for libvirt
to say the volume type is "luks" - we should be saying that it
is a "raw" file, but with "luks" encryption applied.

IOW, when creating a storage volume we should use this XML

  <volume>
    <name>demo.raw</name>
    <capacity>5368709120</capacity>
    <target>
      <format type='raw'/>
      <encryption format='luks'>
        <secret type='passphrase' uuid='0a81f5b2-8403-7b23-c8d6-21ccd2f80d6f'/>
      </encryption>
    </target>
  </volume>

and when configuring a guest disk we should use

  <disk type='file' device='disk'>
    <driver name='qemu' type='raw'/>
    <source file='/home/berrange/VirtualMachines/demo.raw'/>
    <target dev='sda' bus='scsi'/>
    <encryption format='luks'>
      <secret type='passphrase' uuid='0a81f5b2-8403-7b23-c8d6-21ccd2f80d6f'/>
    </encryption>
  </disk>

This commit thus removes the "luks" storage volume type added
in

  commit 318ebb36f1
  Author: John Ferlan <jferlan@redhat.com>
  Date:   Tue Jun 21 12:59:54 2016 -0400

    util: Add 'luks' to the FileTypeInfo

The storage file probing code is modified so that it can probe
the actual encryption formats explicitly, rather than merely
probing existance of encryption and letting the storage driver
guess the format.

The rest of the code is then adapted to deal with
VIR_STORAGE_FILE_RAW w/ VIR_STORAGE_ENCRYPTION_FORMAT_LUKS
instead of just VIR_STORAGE_FILE_LUKS.

The commit mentioned above was included in libvirt v2.0.0.
So when querying volume XML this will be a change in behaviour
vs the 2.0.0 release - it'll report 'raw' instead of 'luks'
for the volume format, but still report 'luks' for encryption
format.  I think this change is OK because the storage driver
did not include any support for creating volumes, nor starting
guets with luks volumes in v2.0.0 - that only since then.
Clearly if we change this we must do it before v2.1.0 though.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2016-07-27 18:59:15 +01:00
Daniel P. Berrange
970f42ab42 virstoragefile: refactor virStorageFileMatchesNNN methods
Refactor the virStorageFileMatchesNNN methods so that
they don't take a struct FileFormatInfo parameter, but
instead get the actual raw dat items they needs. This
will facilitate reuse in other contexts.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2016-07-27 18:55:33 +01:00
Derbyshev Dmitry
438c204763 qemu: return balloon statistics when all domain statistics reported
To collect all balloon statistics for all guests it was necessary to make
several libvirt requests. Now it's possible to get all balloon statiscs via
single connectGetAllDomainStats call.

Signed-off-by: Derbyshev Dmitry <dderbyshev@virtuozzo.com>
2016-07-27 15:39:47 +02:00
Derbyshev Dmitry
c3e3227ac8 qemu: split qemuDomainMemoryStats into internal and external functions
Is necessary to call it from other contexts, such as qemuDomainGetStatsBalloon.

Signed-off-by: Derbyshev Dmitry <dderbyshev@virtuozzo.com>
2016-07-27 15:39:47 +02:00
Pavel Hrdina
29fca3994b qemu: fix domain memory 'usable' stat
This fixes commit 65bf0446 which introduced 'usable' stat.

Signed-off-by: Derbyshev Dmitry <dderbyshev@virtuozzo.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2016-07-27 15:39:34 +02:00
Prasanna Kumar Kalever
7b7da9e283 qemu: command: Add support for multi-host gluster disks
To allow using failover with gluster it's necessary to specify multiple
volume hosts. Add support for starting qemu with such configurations.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2016-07-27 13:38:53 +02:00
Peter Krempa
f444101729 qemu: command: Add infrastructure for object specified disk sources
To allow richer definitions of disk sources add infrastructure that will
allow to register functionst generating a JSON object based definition.

This infrastructure will then convert the definition to the proper
command line syntax and use it in cases where it's necessary. This will
allow to keep legacy definitions for back-compat when possible and use
the new definitions for the configurations requiring them.
2016-07-27 13:33:10 +02:00
Peter Krempa
74df83a9eb util: qemu: Add support for numbered array members
Add support for converting objects nested in arrays with a numbering
discriminator on the command line. This syntax is used for the
object-based specification of disk source properties.
2016-07-27 13:33:10 +02:00
Peter Krempa
f1bbc7df4a storage: gluster: Support multiple hosts in backend functions
As gluster natively supports multiple hosts for failover reasons we can
easily add the support to the storage driver code in libvirt.

Extract the code setting an individual host into a separate function and
call them in a loop. The new code also tries to keep the debug log
entries sane.
2016-07-27 13:33:10 +02:00
Peter Krempa
1575f3e8d3 qemu: command: Refactor code extracted to qemuBuildDriveSourceStr
Avoid a large block by tweaking the condition skipping empty drives and
split up the switch containing two branches having different purpose.
2016-07-27 13:33:10 +02:00
Peter Krempa
3678d42705 qemu: command: Extract drive source command line formatter
The disk source formatting code grew rather ugly and complex and it will
get worse. Extract it into a separated function to contain the mess.
2016-07-27 13:33:10 +02:00
Peter Krempa
ccaaad62a8 qemu: command: Split out network disk URI building
Extract the code so that it can be called from multiple places. This
also removes a tricky fallthrough in the large switch in
qemuBuildNetworkDriveStr.
2016-07-27 13:33:10 +02:00
Peter Krempa
b8dc04a774 qemu: command: Rename qemuBuildNetworkDriveURI to qemuBuildNetworkDriveStr
The function builds also non-uri strings for the various protocols.
2016-07-27 13:33:10 +02:00
Peter Krempa
bc225b1b5f util: storage: Add JSON backing volume parser for 'ssh' protocol 2016-07-27 13:24:20 +02:00
Peter Krempa
29f06ff548 util: storage: Add 'ssh' network storage protocol
Allow using 'ssh' protocol in backing chains and later for disks
themselves.
2016-07-27 13:24:20 +02:00
Peter Krempa
ba8806c8cc util: storage: Add JSON backing store parser for 'sheepdog' protocol 2016-07-27 13:24:20 +02:00
Peter Krempa
a1674fd9d9 util: storage: Add JSON backing volume parser for 'nbd' protocol 2016-07-27 13:24:20 +02:00
Peter Krempa
3236bb2370 util: storage: Add json pseudo protocol support for iSCSI volumes
iSCSI is a bit odd in this aspect since it only supports URIs but using
the 'filename' property and does not have any alternative syntax.
2016-07-27 13:24:20 +02:00
Peter Krempa
2ed772cd63 util: storage: Add json pseudo protocol support for gluster volumes
Along with the legacy URI based syntax add support for the brand-new
fully object based syntax.
2016-07-27 13:24:20 +02:00
Peter Krempa
ba05b5b7e7 util: storage: Add support for URI based backing volumes in qemu's JSON pseudo-protocol
http(s), ftp(s) and tftp use URIs for volume definitions in the JSON
pseudo protocol so it's pretty straightforward to add support for them.
2016-07-27 13:24:20 +02:00
Peter Krempa
47f292dd35 util: storage: Add support for host device backing specified via JSON
JSON pseudo protocol for qemu allows to explicitly specify devices.
Add convertor to the internal type.
2016-07-27 13:24:20 +02:00
Peter Krempa
e91f767c74 util: storage: Add parser for qemu's json backing pseudo-protocol
Add a modular parser that will allow to parse 'json' backing definitions
that are supported by qemu. The initial implementation adds support for
the 'file' driver.

Due to the approach qemu took to implement the JSON backing strings it's
possible to specify them in two approaches.

The object approach:
    json:{ "file" : { "driver":"file",
                      "filename":"/path/to/file"
                    }
         }

And a partially flattened approach:
    json:{"file.driver":"file"
          "file.filename":"/path/to/file"
         }

Both of the above are supported by qemu and by the code added in this
commit. The current implementation de-flattens the first level ('file.')
if possible and required. Other handling may be added later but
currently only one level was possible anyways.
2016-07-27 13:24:20 +02:00
Peter Krempa
22ad4a7c0a util: json: Make first argument of virJSONValueCopy const
It's just read.
2016-07-27 13:24:20 +02:00
Shivaprasad G Bhat
707063efa8 qemu: Adjust the cur_ballon on coldplug/unplug of dimms
The cur_balloon also increases/decreases with dimm hotplug/unplug.
To be consistent, adjust the value for coldplug too. This was inconsistently
taken care when cur_ballon != memory to begin with. The patch fixes it
irrespective of that.

Signed-off-by: Shivaprasad G Bhat <sbhat@linux.vnet.ibm.com>
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2016-07-27 13:21:39 +02:00
Erik Skultety
c5d0a2a385 virconf: Fix config file path construction
Since commit c4bdff19, the path to the configuration file has been constructed
in the following manner:
 - if no config filename was passed to virConfLoadConfigPath, libvirt.conf was
 used as default
 - otherwise the filename was concatenated with
 "<config_dir>/libvirt/libvirt%s%s.conf" which in admin case resulted in
 "libvirt-libvirt-admin.conf.conf". Obviously, this non-existent config led to
 ignoring  all user settings in libvirt-admin.conf. This patch requires the
 config filename to be always provided as an argument with the concatenation
 being simplified.

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

Signed-off-by: Erik Skultety <eskultet@redhat.com>
2016-07-27 12:13:13 +02:00
Peter Krempa
ca620e35ea util: qemu: Don't generate any extra commas in virQEMUBuildCommandLineJSON
The function would generate a leading comma. Let the callers properly
add commas by formatting the commas at the end and trimming the trailing
one.
2016-07-27 09:40:12 +02:00
Peter Krempa
b7eef33df2 util: qemu: Allow for different approaches to format JSON arrays
For use with memory hotplug virQEMUBuildCommandLineJSONRecurse attempted
to format JSON arrays as bitmap on the command line. Make the formatter
function configurable so that it can be reused with different syntaxes
of arrays such as numbered arrays for use with disk sources.

This patch extracts the code and adds a parameter for the function that
will allow to plug in different formatters.
2016-07-27 09:40:07 +02:00
Peter Krempa
cd86d6f465 util: qemu: Allow nested objects in JSON -> commandline generator
Move the iterator of objects to the recursive function so that nested
objects are supported by flattening the structure with '.' delimiters.
2016-07-27 09:39:58 +02:00
Peter Krempa
25a272ada4 util: qemu: Add support for user-passed strings in JSON->commandline
Until now the JSON->commandline convertor was used only for objects
created by qemu. To allow reusing it with disk formatter we'll need to
escape ',' as usual in qemu commandlines.
2016-07-27 09:39:53 +02:00
Peter Krempa
f0276c3489 util: qemu: Add wrapper for JSON -> commandline conversion
Refactor the command line generator by adding a wrapper (with
documentation) that will handle the outermost object iteration.

This patch also renames the functions and tweaks the error message for
nested arrays to be more universal.

The new function is then reused to simplify qemucommandutiltest.
2016-07-27 09:39:46 +02:00
Peter Krempa
bc4339719e util: json: Make first argument of virJSONValueObjectForeachKeyValue const
The iterator function (second argument) already requires that the object
is handled as 'const' thus we won't modify the object itself.
2016-07-27 09:39:42 +02:00
Peter Krempa
4e3dbfa2a5 tests: Add testing of backing store string parser
As we already test that the extraction of the backing store string works
well additional tests for the backing store string parser can be made
simpler.

Export virStorageSourceNewFromBackingAbsolute and use it to parse the
backing store strings, format them using virDomainDiskSourceFormat and
match them against expected XMLs.
2016-07-27 09:39:33 +02:00
John Ferlan
fc0378a973 Remove unnecessary virDomainDefClearDeviceAliases
Nothing in the code path after the removed call has needs/uses the alias
anyway (as would be the case for command line building or talking to monitor).
The alias is VIR_FREE'd in virDomainDeviceInfoClear which is called for any
device that needs/uses an alias via virDomainDeviceDefFree or virDomainDefFree
as well as during virDomainDeviceInfoFree for host devices.

For persistent domains, the domain definition (including aliases) gets
freed a few screens later when it's replaced with newDef.

For transient domains, the definition is freed/unref'd along with the
virDomainObj a few moments later.
2016-07-26 20:40:49 -04:00
John Ferlan
d95f5beb79 conf: Remove CCW,PCI clear address helpers
Since commit id 'fb06350' these are no longer called, so remove them
2016-07-26 20:40:49 -04:00
Joao Martins
eee7bd4ecb libxl: implement virDomainBlockStats
Introduce initial support for domainBlockStats API call that
allow us to query block device statistics. OpenStack nova
uses this API call to query block statistics, alongside
virDomainMemoryStats and virDomainInterfaceStats.  Note that
this patch only introduces it for VBD for starters. QDisk
would come in a separate patch series.

A new statistics data structure is introduced to fit common
statistics among others specific to the underlying block
backends. For the VBD statistics on linux these are exported
via sysfs on the path:

"/sys/bus/xen-backend/devices/vbd-<domid>-<devid>/statistics"

To calculate the block devno libxlDiskPathToID is introduced.
Each backend implements its own function to extract statistics,
allowing support for multiple backends and different platforms.

VBD stats are exposed in reqs and number of sectors from
blkback, and it's up to us to convert it to sector sizes.
The sector size is gathered through xenstore in the device
backend entry "physical-sector-size".

BlockStatsFlags variant is also implemented which has the
added benefit of getting the number of flush requests.

Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
2016-07-26 15:33:30 -06:00
Henning Schild
e975fd2d42 qemu: rename QEMU_CAPS_MLOCK to QEMU_CAPS_REALTIME_MLOCK
Purely cosmetic change to be consistent with the other names.

Signed-off-by: Henning Schild <henning.schild@siemens.com>
2016-07-26 16:47:49 -04:00
Jovanka Gulicoska
2bfa751344 conf: events: handle NULL uuid
Not all objects have a uuid, such as nodedevs. When we add events
support for them, NULL will be passed here, so handle it.
2016-07-26 13:58:17 -04:00
Anton Khramov
128a8b2c9f network: Added hook for network modification event
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1181539
2016-07-26 12:40:14 -04:00
Derbyshev Dmitry
200a40f94e qemu: expand domain memory statistics with 'last-update' timestamp
QEMU reports timestamp along with other memory statistics, but this information is not saved into domain statistics.
It could be useful to determine if the data reported is fresh or not.
Balloon statistics are not reported in hrf, so no modifications are made in qemu_monitor_text.c.

Signed-off-by: Derbyshev Dmitry <dderbyshev@virtuozzo.com>
2016-07-26 17:30:01 +02:00
Derbyshev Dmitry
65bf044686 qemu: expand domain memory statistics with 'usable'
'memtotal' in virtio drivers and qemu corresponds to 'available' in libvirt.
Because of that, 'stat-available-memory' is renamed into 'usable'.
Balloon statistics are not reported in hrf, so no modifications are made in qemu_monitor_text.c.

Signed-off-by: Derbyshev Dmitry <dderbyshev@virtuozzo.com>
2016-07-26 17:30:01 +02:00
Tomasz Flendrich
1aa5e66cf3 qemu: remove ccwaddrs caching
Dropping the caching of ccw address set.
The cached set is not required anymore, because the set is now being
recalculated from the domain definition on demand, so the cache
can be deleted.
2016-07-26 13:04:46 +02:00
Tomasz Flendrich
be396d955d qemu_hotplug: generate ccw address list on demand
Dropping the caching of ccw address set.
Instead of using the cached address set, functions in qemu_hotplug.c
now recalculate it on demand.
2016-07-26 13:04:46 +02:00
Tomasz Flendrich
af174f6e20 Add qemuDomainCCWAddrSetCreateFromDomain
The address sets (pci, ccw, virtio serial) are currently cached
in qemu private data, but all the information required to recreate
these sets is in the domain definition. Therefore I am removing
the redundant data and adding a way to recalculate these sets.

Add a function that calculates the ccw address set
from the domain definition.
2016-07-26 13:04:46 +02:00
Tomasz Flendrich
19a148b7c8 qemu: remove vioserialaddrs caching
Dropping the caching of virtio serial address set.
The cached set is not required anymore, because the set is now being
recalculated from the domain definition on demand, so the cache
can be deleted.

Credit goes to Cole Robinson.
2016-07-26 13:04:46 +02:00
Tomasz Flendrich
925fa4b905 qemu_hotplug: generate vioserial address list on demand
Dropping the caching of virtio serial address set.
Instead of using the cached address set, a function in qemu_hotplug.c
now recalculates it on demand.

Credit goes to Cole Robinson.
2016-07-26 13:04:46 +02:00
Tomasz Flendrich
40c284f0a6 add virDomainVirtioSerialAddrSetCreateFromDomain
The address sets (pci, ccw, virtio serial) are currently cached
in qemu private data, but all the information required to recreate
these sets is in the domain definition. Therefore I am removing
the redundant data and adding a way to recalculate these sets.

Add a function that calculates the virtio serial address set
from the domain definition.

Credit goes to Cole Robinson.
2016-07-26 13:04:46 +02:00
Ján Tomko
cd6e4e5fe4 cgroup: drop INSERT_ELEMENT usage virCgroupPartitionEscape
Use virAsprintf to prepend an underscore to make the code more
readable.
2016-07-26 10:41:26 +02:00
Andrea Bolognani
cabae63194 util: systemd: Define MSG_NOSIGNAL if needed
The symbol being missing has been reported as causing build
failures on OS X. If it's not already defined, define it to
zero so that it won't have any effect.
2016-07-26 04:51:39 +03:00
Pavel Hrdina
e7093b391d qemu_monitor: search memballoon QOM device path using alias
Commit 4a585a88 introduced searching QOM device path by alias, let's use it for
memballoon too.  This may speedup the search because in most cases we will find
the correct QOM device path directly by using alias without the need for the
recursion code.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2016-07-25 17:07:38 +02:00
Pavel Hrdina
4a585a884f qemu_monitor_json: add support to search QOM device path by device alias
Commit ce745914 introduced detection of actual video ram sizes to fix migration
if QEMU decide to modify the values provided by libvirt.  This works perfectly
for domains with number of video devices up to two.

If there are more than two video devices in the guest all the secondary devices
in the XML will have the same memory values.  This is because our current code
search for QOM device path only by the device type name and all the secondary
video devices has the same name "qxl".

This patch introduces a new search function that will try to search a QOM device
path using also device's alias if the alias is available. After that it will
fallback to the old recursive code if the alias search found no results.

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

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2016-07-25 16:20:56 +02:00
Tomasz Flendrich
18ba452f27 Split qemuDomainDetachDeviceFlags in two
Previously, qemuDomainDetachDeviceFlags was doing two things:
handling the job and detaching devices. Now the second part is
in a new function.
2016-07-25 11:55:18 +02:00
Tomasz Flendrich
8bad904865 Narrow down a parameter in qemuDomainDetachDeviceFlags
This will make splitting up qemuDomainDetachDeviceFlags into two
functions easier.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-07-25 11:54:58 +02:00