Commit Graph

18044 Commits

Author SHA1 Message Date
Michal Privoznik
401702d92e docs: Document NVRAM behavior on transient domains
Since 1.2.8 it's possible to use OVMF on domains. Moreover, it's
possible to have libvirt create NVRAM file per domain. Later,
when domain is undefined, the file is removed too. However,
things are a bit complicated when domain's transient. There's no
undefine to transient domains. There are two options: 1) leave
the file behind and let mgmt app remove it. 2) remove it
automatically as domain dies.
But, in some scenarios mgmt app may want to preserve the file,
copy it somewhere safe, and then copy it back when the domain is
starting again. And this wouldn't be possible with case 2). So,
even though case 1) leaves some files behind (possibly undeleted
for a long time), the files themselves are small (128K each). And
data loss is worse than full disk, isn't it?

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2014-11-19 09:06:02 +01:00
Daniel P. Berrange
6c79469ccc Remove left over debug in hvsupport.pl script 2014-11-18 17:54:23 +00:00
John Ferlan
121fc4f9f3 qemu: Resolve Coverity UNINIT
For some reason, commit id '72b4151f' triggered a Coverity uninitialized
'reply' variable check when referenced within the for loop.

It seems Coverity doesn't know that flags will have to be either AFFECT_LIVE
or AFFECT_CONFIG after the virDomainLiveConfigHelperMethod call.

By adding a "sa_assert()" to confirm that fact, Coverity is happy again.
2014-11-15 08:09:53 -05:00
Luyao Huang
72b4151f85 qemu: Fix get blkiodevtune for a disk that has been hot unplugged
https://bugzilla.redhat.com/show_bug.cgi?id=1164080

After a disk is hotunplugged a subsequent call to qemuDomainGetBlockIoTune
to get the --config settings of that disk will fail because the disk is no
longer found by qemuDiskPathToAlias causing an unexpected failure.

Since only the --live flag needs to have the disk device pointer, move the
fetch inside the (flags & VIR_DOMAIN_AFFECT_LIVE) condition. This will also
affect the results if no flags are provided or the --current flag is provided.

Signed-off-by: Luyao Huang <lhuang@redhat.com>
2014-11-14 17:30:55 -05:00
John Ferlan
5c08b12521 qemu: Add tests for new blkdeviotune arguments
The recent commit to add support for block_set_io_throttle parameters
from version 1.7 of qemu did not add any tests - this adds the tests

Signed-off-by: John Ferlan <jferlan@redhat.com>
2014-11-14 12:03:52 -05:00
John Ferlan
a01eea3020 qemu: Add checks for blkdeviotune 'size_iops_sec' and adjust error
Seems the 'size_iops_sec' was a late add and the checks for whether
the field was defined, but unsupported and the maximum size of the
field were not being made.

Also, adjust blkdeviotune support error message for grammar, spelling
(paramater), and remove the "(need QEMU 1.7 or superior)".  None of
our other similar error messages list which QEMU version is required.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2014-11-14 11:57:03 -05:00
Martin Kletzander
995ef7804c bracket-spacing: Add syntax-check for unnecessary curly brackets
We're looking for three consecutive lines, first one is a if/for/while
with a condition and start of body, second one is a body with one and
only semicolon and third is end of the body by itself.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2014-11-14 17:13:36 +01:00
Martin Kletzander
343e53abdc bracket-spacing-check: Print out more specific error message
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2014-11-14 17:13:36 +01:00
Martin Kletzander
5e1af759cf bracket-spacing: Remove pointless cycles
Change while () { smth; last; } to if () { smth; } as 'last' in perl is
analogous to 'break' in C.  These are probably copy-paste leftovers from
creating new syntax-check rules.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2014-11-14 17:13:36 +01:00
Martin Kletzander
d697de90c0 bracket-spacing: Don't modify current line
In bracket-spacing.pl, the current $line is being modified in $data.
That, however, spoils that $data for another check.  Introduce new
$tmpdata variable that can be used for temporary modifications.  The
difference between $data and $line is that $data are as much cleaned as
possible from non-code blocks and these changes must be kept.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2014-11-14 17:13:36 +01:00
Martin Kletzander
a9d07d33a0 docs: Adjust contributor guidelines about curly brackets
After recent discussion it looks like curly brackets around one-line
bodies are preferred if the preceding condition is, itself, multiline.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2014-11-14 17:13:36 +01:00
Martin Kletzander
f5e65e4b71 Remove unnecessary curly brackets in tests/
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2014-11-14 17:13:36 +01:00
Martin Kletzander
91cc3d9570 Remove unnecessary curly brackets in tools/
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2014-11-14 17:13:36 +01:00
Martin Kletzander
4fab120923 Remove unnecessary curly brackets in rest of src/
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2014-11-14 17:13:36 +01:00
Martin Kletzander
8c38594b35 Remove unnecessary curly brackets in rest of src/[o-u]*/
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2014-11-14 17:13:36 +01:00
Martin Kletzander
138c2aee01 Remove unnecessary curly brackets in rest of src/[a-n]*/
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2014-11-14 17:13:36 +01:00
Martin Kletzander
677ddc828a Remove unnecessary curly brackets in src/vbox/
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2014-11-14 17:13:35 +01:00
Martin Kletzander
1b7f8ca6bd Remove unnecessary curly brackets in src/util/
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2014-11-14 17:13:35 +01:00
Martin Kletzander
c651e08c94 Remove unnecessary curly brackets in src/test/test_driver.c
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2014-11-14 17:13:01 +01:00
Martin Kletzander
e7a1da8aeb Remove unnecessary curly brackets in src/storage/
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2014-11-14 17:13:01 +01:00
Martin Kletzander
5cca4cd16f Remove unnecessary curly brackets in src/qemu/
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2014-11-14 17:13:01 +01:00
Martin Kletzander
df6c14e6a8 Remove unnecessary curly brackets in src/node_device/
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2014-11-14 17:13:01 +01:00
Martin Kletzander
f9674bf277 Remove unnecessary curly brackets in src/hyperv/
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2014-11-14 17:13:01 +01:00
Martin Kletzander
7b9710f818 Remove unnecessary curly brackets in src/conf/
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2014-11-14 17:13:01 +01:00
Martin Kletzander
3d45429ef1 Remove unnecessary curly brackets in src/vmx/vmx.c
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2014-11-14 17:13:00 +01:00
Martin Kletzander
247ad91541 Remove unnecessary curly brackets in rest of src/esx/
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2014-11-14 17:13:00 +01:00
Martin Kletzander
090cb1e63c Remove unnecessary curly brackets in src/esx/esx_driver.c
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2014-11-14 17:13:00 +01:00
Martin Kletzander
cfd9c02802 Remove unnecessary curly brackets in daemon/ and examples/
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2014-11-14 17:13:00 +01:00
Martin Kletzander
e09f9e4c32 virsh: Convert EDIT_NOT_CHANGED macro to do-while block.
This macro is being used as an inline body after an if and might get
pretty confusing.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2014-11-14 17:13:00 +01:00
Martin Kletzander
9fdb2b55d5 virt-aa-helper: Trick invalid syntax-check
Rule sc_prohibit_newline_at_end_of_diagnostic for syntax-check does
check for passing strings ending with '\n' two lines after known
functions.  This is, of course subject to false positives, so for the
sake of future changes, trick that syntax-check by adding one more line
with a comment.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2014-11-14 17:13:00 +01:00
Daniel P. Berrange
dc33e6e4a5 Re-add use of locking with iptables/ip6tables/ebtables
A previous commit introduced use of locking with invocation
of iptables in the viriptables.c module

  commit ba95426d6f
  Author: Serge Hallyn <serge.hallyn@ubuntu.com>
  Date:   Fri Nov 1 12:36:59 2013 -0500

    util: use -w flag when calling iptables

This only ever had effect with the virtual network driver,
as it was not wired up into the nwfilter driver. Unfortunately
in the firewall refactoring the use of the -w flag was
accidentally lost.

This patch introduces it to the virfirewall.c module so that
both the virtual network and nwfilter drivers will be using
it. It also ensures that the equivalent --concurrent flag
to ebtables is used.
2014-11-14 15:15:16 +00:00
Jiri Denemark
ae3e29e6e7 qemu: Don't try to parse -help for new QEMU
Since QEMU 1.2.0, we switched to QMP probing instead of parsing -help
(and other commands, such as -cpu ?) output. However, if QMP probing
failed, we still tried starting QEMU with various options and parsing
the output, which was guaranteed to fail because the output changed.
Let's just refuse parsing -help for QEMU >= 1.2.0.

https://bugzilla.redhat.com/show_bug.cgi?id=1160318
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2014-11-13 21:25:50 +01:00
Jiri Denemark
ab393383c8 qemu: Always set migration capabilities
We used to set migration capabilities only when a user asked for them in
flags. This is fine when migration succeeds since the QEMU process is
killed in the end but in case migration fails or if it's cancelled, some
capabilities may remain turned on with no way to turn them off. To fix
that, migration capabilities have to be turned on if requested but
explicitly turned off in case they were not requested but QEMU supports
them.

https://bugzilla.redhat.com/show_bug.cgi?id=1163953
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2014-11-13 20:33:28 +01:00
Martin Kletzander
6b99642f0a virsh: Error out if VSH_OT_STRING option has VSH_OFLAG_REQ flag
Recent commit 12bd207e21 fixed few
VSH_OT_STRING options that should've been VSH_OT_DATA.  That lead me to
this commit that enforces people to check that newly added options have
proper type.  Thanks to virsh erroring out with error message, this will
immediately show up in 'make check' thanks to our virsh-synopsis test.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2014-11-13 15:44:23 +01:00
Martin Kletzander
6beb173df7 virsh: Enforce proper ordering of options
Even though vshCmddefOptParse() tried returning -1 if there was an
optional option specification that preceded a required one, it failed to
check that for boolean type options and options with VSH_OFLAG_REQ_OPT
flag set.  On the other hand, it makes sense that VSH_OT_ARGV is
specified at the end of the option list.

Returning -1 enforces the proper ordering thanks to virsh-synopsis test
in 'make check'.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2014-11-13 15:44:23 +01:00
Martin Kletzander
11d9dd1ad8 virsh: Reorder some options
According to comments in parsing functions, optional options should be
specified *after* required ones.  It makes sense and help output looks
cleaner.  The only exceptions are options with type == VSH_OT_ARGV.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2014-11-13 15:44:23 +01:00
Conrad Meyer
cdbb21bc59 drvbhyve: Use boot-order for grub-bhyve boot device
Rather than just picking the first CD (or failing that, HDD) we come
across, if the user has picked a boot device ordering with <boot
order=''>, respect that (and just try to boot the lowest-index device).

Adds two sets of tests to bhyve2xmlargv; 'grub-bootorder' shows that we
pick a user-specified device over the first device in the domain;
'grub-bootorder2' shows that we pick the first (lowest index) device.
2014-11-13 15:40:48 +01:00
Erik Skultety
c87f268a36 lxc: fix setmem effect on a running LXC machine
When user calls setmem on a running LXC machine, we do update its cgroup
entry, however we neither update domain's runtime XML nor
we update our internal structures and this patch fixes it.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1131919
2014-11-13 15:11:59 +01:00
Conrad Meyer
0dba4a4d42 drvbhyve: Clean-up some used ATTRIBUTE_UNUSEDs. 2014-11-13 14:05:10 +01:00
Daniel P. Berrange
47fb613873 Fix API docs for header file re-organization
The API docs generators were broken by the header file
re-organization. Specifically

 * html/libvirt-libvirt.html was empty (and should be deleted)
 * Makefile.am didn't install html/libvirt-libvirt-*.html
 * hvsupport.html was mostly empty
 * sitemap.html.in didn't list the new html/*.html files
2014-11-13 10:20:26 +00:00
Pavel Hrdina
41127244fb nwfilter: fix deadlock caused updating network device and nwfilter
Commit 6e5c79a1 tried to fix deadlock between nwfilter{Define,Undefine}
and starting of guest, but this same deadlock exists for
updating/attaching network device to domain.

The deadlock was introduced by removing global QEMU driver lock because
nwfilter was counting on this lock and ensure that all driver locks are
locked inside of nwfilter{Define,Undefine}.

This patch extends usage of virNWFilterReadLockFilterUpdates to prevent
the deadlock for all possible paths in QEMU driver. LXC and UML drivers
still have global lock.

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

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2014-11-13 10:45:19 +01:00
Michal Privoznik
54ddc08ddb qemuPrepareNVRAM: Save domain conf only if domain's persistent
In one of my previous patches (3a3c3780b) I've tried to fix the
problem of nvram path disappearing on a domain that's been
started and shut down again. I fixed this by explicitly saving
domain's config file.  However, I did a bit of clumsy without
realizing we have a transient domains for which we don't save the
config file. Hence, any domain using UEFI became persistent.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2014-11-13 09:35:25 +01:00
Michal Privoznik
8d659b177f qemuxml2argvtest: Run some test only on Linux
As I was reviewing bhyve commits, I've noticed qemuxml2argvtest
failing for some test cases. This is not bug in qemu driver code
rather than being unable to load qemuxml2argvmock on non-Linux
platforms. For instance:

318) QEMU XML-2-ARGV numatune-memnode
... libvirt:  error : internal error: NUMA node 0 is unavailable
FAILED

Rather than disabling qemuxml2argvtest on BSD (we do compile qemu
driver there) disable only those test cases which require mocking.
To achieve that goal new DO_TEST_LINUX() macro is introduced which
invokes the test case on Linux only and consume arguments on other
systems.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2014-11-12 16:57:19 +01:00
John Ferlan
5530f248db storage: Introduce 'managed' for the fchost parent
https://bugzilla.redhat.com/show_bug.cgi?id=1160926

Introduce a 'managed' attribute to allow libvirt to decide whether to
delete a vHBA vport created via external means such as nodedev-create.
The code currently decides whether to delete the vHBA based solely on
whether the parent was provided at creation time. However, that may not
be the desired action, so rather than delete and force someone to create
another vHBA via an additional nodedev-create allow the configuration of
the storage pool to decide the desired action.

During createVport when libvirt does the VPORT_CREATE, set the managed
value to YES if not already set to indicate to the deleteVport code that
it should delete the vHBA when the pool is destroyed.

If libvirtd is restarted all the memory only state was lost, so for a
persistent storage pool, use the virStoragePoolSaveConfig in order to
write out the managed value.

Because we're now saving the current configuration, we need to be sure
to not save the parent in the output XML if it was undefined at start.
Saving the name would cause future starts to always use the same parent
which is not the expected result when not providing a parent. By not
providing a parent, libvirt is expected to find the best available
vHBA port for each subsequent (re)start.

At deleteVport, use the new managed value to decide whether to execute
the VPORT_DELETE.  Since we no longer save the parent in memory or in
XML when provided, if it was not provided, then we have to look it up.
2014-11-12 10:18:28 -05:00
John Ferlan
523c6908f8 storage: Introduce virStoragePoolSaveConfig
https://bugzilla.redhat.com/show_bug.cgi?id=1160926

Introduce the ability to save a configuration of a persistent configuration
that may be changed by storage pool backend activity, such as start or stop
2014-11-12 10:18:28 -05:00
John Ferlan
5b226fcdc6 storage: Don't use a stack copy of the adapter
https://bugzilla.redhat.com/show_bug.cgi?id=1160926

Passing a copy of the storage pool adapter to a function just changes the
copy of the fields in the particular function and then when returning to
the caller those changes are discarded.  While not yet biting us in the
storage clean-up case, it did cause an issue for the fchost storage pool
startup case, createVport.  The issue was at startup, if no parent is found
in the XML, the code will search for the 'best available' parent and then
store that in the in memory copy of the adapter.  Of course, in this case
it was a copy, so when returning to the virStorageBackendSCSIStartPool that
change was discarded (or lost) from the pool->def->source.adapter which
meant at shutdown (deleteVport), the code assumed no adapter was passed
and skipped the deletion, leaving the vHBA created by libvirt still defined
requiring an additional stop of a nodedev-destroy to remove.

Adjusted the createVport to take virStoragePoolDefPtr instead of the
adapter copy. Then use the virStoragePoolSourceAdapterPtr when processing.
A future patch will need the 'def' anyway, so this just sets up for that.
2014-11-12 10:18:28 -05:00
John Ferlan
42a021c120 storage: Ensure fc_host parent matches wwnn/wwpn
https://bugzilla.redhat.com/show_bug.cgi?id=1160565

The existing code assumed that the configuration of a 'parent' attribute
was correct for the createVport path. As it turns out, that may not be
the case which leads errors during the deleteVport path because the
wwnn/wwpn isn't associated with the parent.

With this change the following is reported:

error: Failed to start pool fc_pool_host3
error: XML error: Parent attribute 'scsi_host4' does not match parent 'scsi_host3' determined for the 'scsi_host16' wwnn/wwpn lookup.

for XML as follows:

  <pool type='scsi'>
    <name>fc_pool</name>
    <source>
      <adapter type='fc_host' parent='scsi_host4' wwnn='5001a4aaf3ca174b' wwpn='5001a4a77192b864'/>
    </source>

Where 'nodedev-dumpxml scsi_host16' provides:

  <device>
    <name>scsi_host16</name>
    <path>/sys/devices/pci0000:00/0000:00:04.0/0000:10:00.0/host3/vport-3:0-11/host16</path>
    <parent>scsi_host3</parent>
    <capability type='scsi_host'>
      <host>16</host>
      <unique_id>13</unique_id>
      <capability type='fc_host'>
        <wwnn>5001a4aaf3ca174b</wwnn>
        <wwpn>5001a4a77192b864</wwpn>
...

The patch also adjusts the description of the storage pool to describe the
restrictions.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2014-11-12 10:18:28 -05:00
John Ferlan
844c1d7e32 storage: Check for valid fc_host parent at startup
https://bugzilla.redhat.com/show_bug.cgi?id=1160565

If a 'parent' attribute is provided for the fchost, then at startup
time check to ensure it is a vport capable scsi_host. If the parent
is not vport capable, then disallow the startup. The following is the
expected results:

error: Failed to start pool fc_pool
error: XML error: parent 'scsi_host2' specified for vHBA is not vport capable

where the XML for the fc_pool is:

    <pool type='scsi'>
      <name>fc_pool</name>
      <source>
        <adapter type='fc_host' parent='scsi_host2' wwnn='5001a4aaf3ca174b' wwpn='5001a4a77192b864'/>
      </source>
...

and 'scsi_host2' is not vport capable.

Providing an incorrect parent and a correct wwnn/wwpn could lead to
failures at shutdown (deleteVport) where the assumption is the parent
is for the fchost.

NOTE: If the provided wwnn/wwpn doesn't resolve to an existing scsi_host,
      then we will be creating one with code (virManageVport) which
      assumes the parent is vport capable.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2014-11-12 10:18:27 -05:00
Matthias Gatto
6c1347ec06 qemu: Resolve Coverity DEADCODE.
reported here: http://www.redhat.com/archives/libvir-list/2014-November/msg00327.html

I could have just remove bool supportMaxOptions variable, but
if I had do this, we could not check anymore if the nparams variable is
superior to QEMU_NB_BLOCK_IO_TUNE_PARAM_MAX.

v2: change following this proposal:
http://www.redhat.com/archives/libvir-list/2014-November/msg00379.html
2014-11-12 09:43:55 -05:00
Matthias Gatto
5fb007b035 qemu: Fix copy_paste_error in qemuBuildDriveStr.
Fix for this: http://www.redhat.com/archives/libvir-list/2014-November/msg00324.html

Signed-off-by: Matthias Gatto <matthias.gatto@outscale.com>
2014-11-12 09:43:49 -05:00