Commit Graph

17572 Commits

Author SHA1 Message Date
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