]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
10 years agoRe-add use of locking with iptables/ip6tables/ebtables
Daniel P. Berrange [Tue, 11 Nov 2014 12:34:57 +0000 (12:34 +0000)]
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 ba95426d6f39aec1da6e069dd7222f7a8c6a5862
  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.

10 years agoqemu: Don't try to parse -help for new QEMU
Jiri Denemark [Wed, 12 Nov 2014 15:49:59 +0000 (16:49 +0100)]
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>
10 years agoqemu: Always set migration capabilities
Jiri Denemark [Mon, 10 Nov 2014 13:46:26 +0000 (14:46 +0100)]
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>
10 years agovirsh: Error out if VSH_OT_STRING option has VSH_OFLAG_REQ flag
Martin Kletzander [Tue, 11 Nov 2014 11:03:11 +0000 (12:03 +0100)]
virsh: Error out if VSH_OT_STRING option has VSH_OFLAG_REQ flag

Recent commit 12bd207e217f3c5dc2272a5ea943b81067bd8034 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>
10 years agovirsh: Enforce proper ordering of options
Martin Kletzander [Tue, 11 Nov 2014 10:01:05 +0000 (11:01 +0100)]
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>
10 years agovirsh: Reorder some options
Martin Kletzander [Tue, 11 Nov 2014 09:45:24 +0000 (10:45 +0100)]
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>
10 years agodrvbhyve: Use boot-order for grub-bhyve boot device
Conrad Meyer [Wed, 12 Nov 2014 22:31:53 +0000 (17:31 -0500)]
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.

10 years agolxc: fix setmem effect on a running LXC machine
Erik Skultety [Fri, 24 Oct 2014 09:17:20 +0000 (11:17 +0200)]
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

10 years agodrvbhyve: Clean-up some used ATTRIBUTE_UNUSEDs.
Conrad Meyer [Wed, 12 Nov 2014 21:11:33 +0000 (16:11 -0500)]
drvbhyve: Clean-up some used ATTRIBUTE_UNUSEDs.

10 years agoFix API docs for header file re-organization
Daniel P. Berrange [Tue, 11 Nov 2014 16:28:26 +0000 (16:28 +0000)]
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

10 years agonwfilter: fix deadlock caused updating network device and nwfilter
Pavel Hrdina [Wed, 5 Nov 2014 13:28:57 +0000 (14:28 +0100)]
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>
10 years agoqemuPrepareNVRAM: Save domain conf only if domain's persistent
Michal Privoznik [Wed, 12 Nov 2014 17:09:46 +0000 (18:09 +0100)]
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>
10 years agoqemuxml2argvtest: Run some test only on Linux
Michal Privoznik [Wed, 12 Nov 2014 09:26:43 +0000 (10:26 +0100)]
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>
10 years agostorage: Introduce 'managed' for the fchost parent
John Ferlan [Mon, 10 Nov 2014 16:19:51 +0000 (11:19 -0500)]
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.

10 years agostorage: Introduce virStoragePoolSaveConfig
John Ferlan [Mon, 10 Nov 2014 17:23:46 +0000 (12:23 -0500)]
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

10 years agostorage: Don't use a stack copy of the adapter
John Ferlan [Mon, 10 Nov 2014 16:34:57 +0000 (11:34 -0500)]
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.

10 years agostorage: Ensure fc_host parent matches wwnn/wwpn
John Ferlan [Thu, 6 Nov 2014 17:22:58 +0000 (12:22 -0500)]
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>
10 years agostorage: Check for valid fc_host parent at startup
John Ferlan [Thu, 6 Nov 2014 17:32:46 +0000 (12:32 -0500)]
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>
10 years agoqemu: Resolve Coverity DEADCODE.
Matthias Gatto [Wed, 12 Nov 2014 15:53:01 +0000 (16:53 +0100)]
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

10 years agoqemu: Fix copy_paste_error in qemuBuildDriveStr.
Matthias Gatto [Wed, 12 Nov 2014 13:04:15 +0000 (14:04 +0100)]
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>
10 years agobhyvexml2argv: Add test for grub console support
Conrad Meyer [Sat, 8 Nov 2014 16:48:36 +0000 (11:48 -0500)]
bhyvexml2argv: Add test for grub console support

10 years agobhyve: Add console support for grub-bhyve bootloader
Conrad Meyer [Sat, 8 Nov 2014 16:48:35 +0000 (11:48 -0500)]
bhyve: Add console support for grub-bhyve bootloader

This enables booting interactive GRUB menus (e.g. install CDs) with
libvirt-bhyve.

Caveat: A terminal other than the '--console' option to 'virsh start'
(e.g. 'cu -l /dev/nmdm0B -s 115200') must be used to connect to
grub-bhyve because the bhyve loader path is synchronous and must occur
before the VM actually starts.

Changing the bhyveProcessStart logic around to accommodate '--console'
for interactive loader use seems like a significant project and probably
not worth it, if UEFI/BIOS support for bhyve is "coming soon."

10 years agobhyve: Probe grub-bhyve for --cons-dev capability
Conrad Meyer [Tue, 11 Nov 2014 15:35:06 +0000 (10:35 -0500)]
bhyve: Probe grub-bhyve for --cons-dev capability

10 years agobhyvexml2argv: Add tests for domain-configured bootloader, args
Conrad Meyer [Sat, 8 Nov 2014 16:48:33 +0000 (11:48 -0500)]
bhyvexml2argv: Add tests for domain-configured bootloader, args

10 years agodomaincommon.rng: Add 'bootloader' to os=hvm schema for Bhyve
Conrad Meyer [Sat, 8 Nov 2014 16:48:32 +0000 (11:48 -0500)]
domaincommon.rng: Add 'bootloader' to os=hvm schema for Bhyve

Additionally, make the <bootloader> tag optional (for bhyveload with
custom arguments) (also, matches the actual parser).

10 years agobhyvexml2argv: Add loader argv tests.
Conrad Meyer [Sat, 8 Nov 2014 16:48:31 +0000 (11:48 -0500)]
bhyvexml2argv: Add loader argv tests.

10 years agobhyve: Support /domain/bootloader configuration for non-FreeBSD guests.
Conrad Meyer [Sat, 8 Nov 2014 16:48:30 +0000 (11:48 -0500)]
bhyve: Support /domain/bootloader configuration for non-FreeBSD guests.

We still default to bhyveloader(1) if no explicit bootloader
configuration is supplied in the domain.

If the /domain/bootloader looks like grub-bhyve and the user doesn't
supply /domain/bootloader_args, we make an intelligent guess and try
chainloading the first partition on the disk (or a CD if one exists,
under the assumption that for a VM a CD is likely an install source).

Caveat: Assumes the HDD boots from the msdos1 partition. I think this is
a pretty reasonable assumption for a VM. (DrvBhyve with Bhyveload
already assumes that the first disk should be booted.)

I've tested both HDD and CD boot and they seem to work.

10 years agoDo not crash on gluster snapshots with no host name
Ján Tomko [Wed, 12 Nov 2014 08:34:28 +0000 (09:34 +0100)]
Do not crash on gluster snapshots with no host name

virStorageFileBackendGlusterInit did not check nhosts.

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

10 years agoDisplay nicer error message for unsupported chardev hotplug
Ján Tomko [Mon, 10 Nov 2014 15:52:49 +0000 (16:52 +0100)]
Display nicer error message for unsupported chardev hotplug

Use the device type name if we know it instead of its number,
even if we can't hotplug it:
qemuMonitorJSONAttachCharDevCommand:6094 : operation failed: Unsupported
char device type '10'

10 years agoFix virDomainChrEquals for spicevmc
Ján Tomko [Mon, 10 Nov 2014 15:40:49 +0000 (16:40 +0100)]
Fix virDomainChrEquals for spicevmc

virDomainChrSourceDefIsEqual should return 'true' for
identical SPICEVMC chardevs, and those that have no source
specification.

After this change, a failed hotplug no longer leaves a stale
pointer in the domain definition.

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

10 years agoqemu: fix domain startup failing with 'strict' mode in numatune
Wang Rui [Mon, 10 Nov 2014 13:53:19 +0000 (21:53 +0800)]
qemu: fix domain startup failing with 'strict' mode in numatune

If the memory mode is specified as 'strict' and with one node, we
get the following error when starting domain.

error: Unable to write to '$cgroup_path/cpuset.mems': Device or resource busy

XML is configured with numatune as follows:
  <numatune>
    <memory mode='strict' nodeset='0'/>
  </numatune>

It's broken by Commit 411cea638f6ec8503b7142a31e58b1cd85dbeaba
which moved qemuSetupCgroupForEmulator() before setting cpuset.mems
in qemuSetupCgroupPostInit.

Directory '$cgroup_path/emulator/' is created in qemuSetupCgroupForEmulator.
But '$cgroup_path/emulator/cpuset.mems' it not set and has a default value
(all nodes, such as 0-1). Then we setup '$cgroup_path/cpuset.mems' to the
nodemask (in this case it's '0') in qemuSetupCgroupPostInit. It must fail.

This patch makes '$cgroup_path/emulator/cpuset.mems' is set before
'$cgroup_path/cpuset.mems'. The action is similar with that in
qemuDomainSetNumaParamsLive.

Signed-off-by: Wang Rui <moon.wangrui@huawei.com>
10 years agolxc: don't setup cpuset.mems if memory mode in numatune is not 'strict'
Wang Rui [Mon, 10 Nov 2014 13:53:18 +0000 (21:53 +0800)]
lxc: don't setup cpuset.mems if memory mode in numatune is not 'strict'

If the memory mode in numatune is not 'strict', we should not setup
cpuset.mems. Before commit 1a7be8c600905aa07ac2d78293336ba8523ad48e
we have checked the memory mode in virDomainNumatuneGetNodeset. This
patch adds the check as before.

Signed-off-by: Wang Rui <moon.wangrui@huawei.com>
10 years agoqemu: don't setup cpuset.mems if memory mode in numatune is not 'strict'
Wang Rui [Mon, 10 Nov 2014 13:53:17 +0000 (21:53 +0800)]
qemu: don't setup cpuset.mems if memory mode in numatune is not 'strict'

If the memory mode in numatune is specified as 'preferred' with one node
(such as nodeset='0'), domain's memory is not all in node 0 absolutely.
Assumption that node 0 doesn't have enough memory, memory can be allocated
on node 1 when qemu process startup. Then if we set cpuset.mems to '0',
it may invoke OOM.

Commit 1a7be8c600905aa07ac2d78293336ba8523ad48e changed the former logic of
checking memory mode in virDomainNumatuneGetNodeset. This patch adds the
check as before.

Signed-off-by: Wang Rui <moon.wangrui@huawei.com>
10 years agoFix invalid log, misused option types and a typo
Hao Liu [Tue, 11 Nov 2014 02:12:20 +0000 (10:12 +0800)]
Fix invalid log, misused option types and a typo

This patch fixes the following issues.

1)  When an invalid wwn is introduced, libvirt reports
    "Malformed wwn: %s". The template won't be replaced.

2)  "target" option for dompmsuspend and "xml" option for
    save-image-define are required options and should use
    VSH_OT_DATA instead of VSH_OT_STRING as an option type.

3)  A typo.

Signed-off-by: Hao Liu <hliu@redhat.com>
10 years agophyp: Fix NULL dereference in phypConnectOpen
Martin Kletzander [Fri, 7 Nov 2014 18:52:33 +0000 (19:52 +0100)]
phyp: Fix NULL dereference in phypConnectOpen

Coverity found out that commit cd490086 caused a possible NULL pointer
dereference.  This is due to the fact, that phyp_driver is NULL at the
time of closing the socket, instead of connection_data, which kept the
socket before the mentioned commit, could not be NULL.

However, internal_socket is still the local socket that can be
closed, even unconditionally, if we initialize it to -1.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agovirsh: Add bps_max and friends to virsh
Matthias Gatto [Wed, 29 Oct 2014 12:16:05 +0000 (13:16 +0100)]
virsh: Add bps_max and friends to virsh

Add the new throttle options to virsh, and send them to libvirt.

Signed-off-by: Matthias Gatto <matthias.gatto@outscale.com>
10 years agoqemu: Add bps_max and friends to qemu command generation
Matthias Gatto [Wed, 29 Oct 2014 12:16:04 +0000 (13:16 +0100)]
qemu: Add bps_max and friends to qemu command generation

Check the arability of the options with the current qemu binary,
add them in the varable opt if yes, print a message if not.

Signed-off-by: Matthias Gatto <matthias.gatto@outscale.com>
10 years agoqemu: Add bps_max and friends QMP suport
Matthias Gatto [Wed, 29 Oct 2014 12:16:03 +0000 (13:16 +0100)]
qemu: Add bps_max and friends QMP suport

Detect if the the qemu binary currently in use support the bps_max option,
If yes add it to the command, if not, just ignore the option.
We don't print error here, because the check for invalide arguments
has alerady been made in qemu_driver.c

Signed-off-by: Matthias Gatto <matthias.gatto@outscale.com>
10 years agoqemu: Add bps_max and friends qemu driver
Matthias Gatto [Mon, 10 Nov 2014 15:19:09 +0000 (16:19 +0100)]
qemu: Add bps_max and friends qemu driver

Add support for bps_max and friends in the driver part.
In the part checking if a qemu is running, check if the running binary
support bps_max, if not print an error message, if yes add it to
"info" variable

Signed-off-by: Matthias Gatto <matthias.gatto@outscale.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoqemu: Add Qemu capability for bps_max and friends
Matthias Gatto [Wed, 29 Oct 2014 12:16:01 +0000 (13:16 +0100)]
qemu: Add Qemu capability for bps_max and friends

Add the capability to detect if the qemu binary have the capability
to use bps_max and friends
Add a value in the enum virQEMUCapsFlags for the qemu capability.
Set it with virQEMUCapsSet if the binary suport bps_max and they friends.

Signed-off-by: Matthias Gatto <matthias.gatto@outscale.com>
10 years agoqemu: Modify the structure _virDomainBlockIoTuneInfo.
Matthias Gatto [Wed, 29 Oct 2014 12:16:00 +0000 (13:16 +0100)]
qemu: Modify the structure _virDomainBlockIoTuneInfo.

Modify the structure _virDomainBlockIoTuneInfo to support these the new
options.
Change the initialization of the variable expectedInfo in qemumonitorjsontest.c
to avoid compiling problem.
Add documentation about the new xml options

Signed-off-by: Matthias Gatto <matthias.gatto@outscale.com>
10 years agoqemu: Add define for the new throttle options
Matthias Gatto [Wed, 29 Oct 2014 12:15:59 +0000 (13:15 +0100)]
qemu: Add define for the new throttle options

Add defines for the new options total_bytes_sec_max, write_bytes_sec_max,
read_bytes_sec_max, total_iops_sec_max, write_iops_sec_max, read_iops_sec_max,
size_iops_sec.

Signed-off-by: Matthias Gatto <matthias.gatto@outscale.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agonodeinfo: report error when failure in nodeSetMemoryParameters
Jincheng Miao [Fri, 7 Nov 2014 10:27:00 +0000 (11:27 +0100)]
nodeinfo: report error when failure in nodeSetMemoryParameters

nodeSetMemoryParameters() will call nodeSetMemoryParameterValue()
to set parameters. But it just filter the return code '-2' as
failure. Indeed we should report error when rc is negative.

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

Signed-off-by: Jincheng Miao <jmiao@redhat.com>
10 years agocpu_conf: Allow specification of 'units' for @memory on numa nodes.
Prerna Saxena [Mon, 10 Nov 2014 11:52:58 +0000 (17:22 +0530)]
cpu_conf: Allow specification of 'units' for @memory on numa nodes.

CPU numa topology implicitly allows memory specification in 'KiB'.

Enabling this to accept the 'unit' in which memory needs to be specified.
This now allows users to specify memory in units of choice, and
lists the same in 'KiB' -- just like other 'memory' elements in XML.

    <numa>
      <cell cpus='0-3' memory='1024' unit='MiB' />
      <cell cpus='4-7' memory='1024' unit='MiB' />
    </numa>

Also augment test cases to correctly model NUMA memory specification.
This adds the tag 'unit="KiB"' for memory attribute in NUMA cells.

Signed-off-by: Prerna Saxena <prerna@linux.vnet.ibm.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoconf: Expose virDomainParseMemory for use outside domain_conf
Prerna Saxena [Mon, 10 Nov 2014 11:52:05 +0000 (17:22 +0530)]
conf: Expose virDomainParseMemory for use outside domain_conf

Commit 01b4de2b9f5ca82 abstracts virDomainParseMemory()
for use by other functions in domain_conf.c
Extend the same for use, for functions outside of this file.

Signed-off-by: Prerna Saxena <prerna@linux.vnet.ibm.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoesx: Simplify VI (vSphere) API and VMware product version handling
Matthias Bolte [Sat, 18 Oct 2014 22:11:13 +0000 (00:11 +0200)]
esx: Simplify VI (vSphere) API and VMware product version handling

Store version numbers in this format

version = 1000000 * major + 1000 * minor + micro

produced by virParseVersionString instead of dedicated enums.

Split the complex esxVI_ProductVersion enum into a simpler
esxVI_ProductLine enum and a product version number.

Relax API and product version number checks to accept everything that
is equal or greater than the supported minimum version. VMware ESX
went through 3 major versions and the vSphere API always stayed
backward compatible. This commit assumes that this will also be true
for future VMware ESX versions.

Also reword error messages in esxConnectTo* to say what was expected
and what was found instead (suggested by Richard W.M. Jones).

10 years agodomain_conf: Use virDomainParseMemory more widely
Michal Privoznik [Fri, 7 Nov 2014 14:14:11 +0000 (15:14 +0100)]
domain_conf: Use virDomainParseMemory more widely

As reviewing patches upstream it occurred to me, that we have two
functions doing nearly the same: virDomainParseMemory which
expects XML in the following format:

  <memory unit='MiB'>1337</memory>

The other function being virDomainHugepagesParseXML expecting the
following format:

  <someElement size='1337' unit='MiB'/>

It wouldn't matter to have two functions handle two different
scenarios like this if we could only not copy code that handles
32bit arches around. So this code merges the common parts into
one by inventing new @units_xpath argument to
virDomainParseMemory which allows overriding the default location
of @unit attribute in XML. With this change both scenarios above
can be parsed with virDomainParseMemory.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoTransform VIR_ERROR into VIR_WARN in detect_scsi_host_caps
Cédric Bosdonnat [Tue, 4 Nov 2014 14:12:39 +0000 (15:12 +0100)]
Transform VIR_ERROR into VIR_WARN in detect_scsi_host_caps

If detect_scsi_host_caps reports errors but keeps libvirtd going on
startup, the user is misled by the error messages. Transforming them
into warning still shows the problems, but indicates this is not fatal.

10 years agovbox: Remove useless condition branches
Martin Kletzander [Thu, 6 Nov 2014 15:44:19 +0000 (16:44 +0100)]
vbox: Remove useless condition branches

These were probably left there after some code movement.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agovirnuma: add nodeset NULL check in virNumaSetupMemoryPolicy
Chen Fan [Fri, 7 Nov 2014 08:54:56 +0000 (16:54 +0800)]
virnuma: add nodeset NULL check in virNumaSetupMemoryPolicy

Introduced by commit c63ef0452b, when nodeset is NULL, validation will
pass in virNumaSetupMemoryPolicy, but virBitmapNextSetBit must ensure
bitmap is not NULL, otherwise that might cause a segmentation fault.
This patch fixes it.

Signed-off-by: Chen Fan <chen.fan.fnst@cn.fujitsu.com>
10 years agoRemove use of networkPrivateData from netcf driver
Daniel P. Berrange [Thu, 23 Oct 2014 14:17:18 +0000 (15:17 +0100)]
Remove use of networkPrivateData from netcf driver

The shared netcf driver is stateful and inside the daemon so
there is no need to use the networkPrivateData field to get the
driver handle. Just access the global driver handle directly.

10 years agoRemove use of networkPrivateData from network driver
Daniel P. Berrange [Thu, 23 Oct 2014 14:17:18 +0000 (15:17 +0100)]
Remove use of networkPrivateData from network driver

The shared network driver is stateful and inside the daemon so
there is no need to use the networkPrivateData field to get the
driver handle. Just access the global driver handle directly.

Many places already directly accessed the global driver handle
in any case, so the code could never work without relying on
this.

10 years agoRemove use of storagePrivateData from storage driver
Daniel P. Berrange [Thu, 23 Oct 2014 14:17:18 +0000 (15:17 +0100)]
Remove use of storagePrivateData from storage driver

The shared storage driver is stateful and inside the daemon so
there is no need to use the storagePrivateData field to get the
driver handle. Just access the global driver handle directly.

10 years agoUpdate Test driver to always use privateData
Daniel P. Berrange [Thu, 23 Oct 2014 13:33:11 +0000 (14:33 +0100)]
Update Test driver to always use privateData

Since the secondary drivers are only active when the primary
driver is also the Test driver, there is no need to use the
different type specific privateData fields.

10 years agoUpdate Parallels driver to always use privateData
Daniel P. Berrange [Thu, 23 Oct 2014 13:33:11 +0000 (14:33 +0100)]
Update Parallels driver to always use privateData

Since the secondary drivers are only active when the primary
driver is also the Parallels driver, there is no need to use the
different type specific privateData fields. The object that was
being stored in the storagePrivateData can easily be kept in the
parallelsConn struct instead.

10 years agoRemove abuse of networkPrivateData in phyp driver
Daniel P. Berrange [Thu, 23 Oct 2014 13:54:41 +0000 (14:54 +0100)]
Remove abuse of networkPrivateData in phyp driver

For inexplicable reasons the phyp driver defined two separate
structs for holding its private data. One it keeps in privateData
and the other it keeps in networkPrivateData. It uses them both
from all API driver methods. Merge the two separate structs
into one to remove this horrible abuse.

10 years agoMove phyp internal info out of the header file
Daniel P. Berrange [Thu, 23 Oct 2014 13:46:25 +0000 (14:46 +0100)]
Move phyp internal info out of the header file

The phyp_driver.h file has various declarations that are only
ever used from phyp_driver.c, so they should be in the .c file
only.

10 years agoUpdate Hyper-V driver to always use privateData
Daniel P. Berrange [Thu, 23 Oct 2014 13:33:11 +0000 (14:33 +0100)]
Update Hyper-V driver to always use privateData

Since the secondary drivers are only active when the primary
driver is also the Hyper-V driver, there is no need to use the
different type specific privateData fields.

10 years agoUpdate ESX driver to always use privateData
Daniel P. Berrange [Thu, 23 Oct 2014 13:33:11 +0000 (14:33 +0100)]
Update ESX driver to always use privateData

Since the secondary drivers are only active when the primary
driver is also the ESX driver, there is no need to use the
different type specific privateData fields.

10 years agoUpdate remote driver to always use privateData
Daniel P. Berrange [Thu, 23 Oct 2014 13:33:11 +0000 (14:33 +0100)]
Update remote driver to always use privateData

Since the secondary drivers are only active when the primary
driver is also the remote driver, there is no need to use the
different type specific privateData fields.

10 years agoClean up remote driver connection open code
Daniel P. Berrange [Thu, 23 Oct 2014 13:25:07 +0000 (14:25 +0100)]
Clean up remote driver connection open code

The remote driver has had a long term hack to deal with the fact
that the old Xen driver worked outside libvirtd, but the rest
of the drivers worked inside. So you could have a local hypervisor
driver but everything else go via the remote driver. The Xen driver
long ago moved inside libvirtd, so this hack is no longer needed.
Thus we should open use the remote driver for secondary drivers
if the primary driver is already the remote driver.

10 years agodoc: fix mismatched ACL attribute name
Luyao Huang [Fri, 7 Nov 2014 09:35:33 +0000 (17:35 +0800)]
doc: fix mismatched ACL attribute name

As documented in https://bugzilla.redhat.com/show_bug.cgi?id=1161358,
the ACL attribute should be named: interface_macaddr

Signed-off-by: Luyao Huang <lhuang@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agoTest: Add a testcase for PowerPC compat mode cpu specification.
Prerna Saxena [Tue, 4 Nov 2014 17:32:15 +0000 (23:02 +0530)]
Test: Add a testcase for PowerPC compat mode cpu specification.

This introduces a testcase for PowerPC compat mode cpu specification.

Signed-off-by: Prerna Saxena <prerna@linux.vnet.ibm.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
10 years agodocs: Add documentation for compat mode.
Prerna Saxena [Tue, 4 Nov 2014 17:30:36 +0000 (23:00 +0530)]
docs: Add documentation for compat mode.

Add documentation to explain how compat-mode can be invoked with libvirt
running on PowerPC architecture.
It also mentions that this change is available libvirt 1.2.11 onwards.

Signed-off-by: Prerna Saxena <prerna@linux.vnet.ibm.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoPowerPC:Improve PVR handling to fall back to cpu generation.
Prerna Saxena [Tue, 4 Nov 2014 17:28:33 +0000 (22:58 +0530)]
PowerPC:Improve PVR handling to fall back to cpu generation.

IBM Power processors differ uniquely across generations (such as power6,
power7, power8). Each generation signifies a new PowerISA version
that exhibits features unique to that generation.
The higher 16 bits of PVR for IBM Power processors encode the CPU
generation, while the CPU chip (sub)version is encoded in lower 16 bits.

For all practical purposes of launching a VM, we care about the
generation which the vCPU will belong to, and not specifically the chip
version. This patch updates the libvirt PVR check to reflect this
relationship. It allows libvirt to select the right CPU generation
in case the exact match for a a specific CPU is not found.
Hence, there will no longer be a need to add each PowerPC CPU model to
cpu_map.xml; just adding entry for the matching ISA generation will
suffice.

It also contains changes to cpu_map.xml since processor generations
as understood by QEMU compat mode go as "power6", "power7" or "power8"
[Reference : QEMU commit 8dfa3a5e85 ]

Signed-off-by: Prerna Saxena <prerna@linux.vnet.ibm.com>
Signed-off-by: Pradipta Kr. Banerjee <bpradip@in.ibm.com>
Signed-off-by: Anton Blanchard <anton@samba.org>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoPowerPC : Add support for launching VM in 'compat' mode.
Prerna Saxena [Tue, 4 Nov 2014 17:22:44 +0000 (22:52 +0530)]
PowerPC : Add support for launching VM in 'compat' mode.

PowerISA allows processors to run VMs in binary compatibility ("compat")
mode supporting an older version of ISA. QEMU has recently added support to
explicitly denote a VM running in compatibility mode through commit 6d9412ea
8dfa3a5e85. Now, a "compat" mode VM can be run by invoking this qemu
commandline on a POWER8 host:  -cpu host,compat=power7.

This patch allows libvirt to exploit cpu mode 'host-model' to describe this
new mode for PowerKVM guests. For example, when a user wants to request a
power7 vm to run in compatibility mode on a Power8 host, this can be
described in XML as follows :

  <cpu mode='host-model'>
    <model>power7</model>
  </cpu>

Signed-off-by: Prerna Saxena <prerna@linux.vnet.ibm.com>
Signed-off-by: Li Zhang <zhlcindy@linux.vnet.ibm.com>
Signed-off-by: Pradipta Kr. Banerjee <bpradip@in.ibm.com>
Acked-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoCpu: Add support for Power LE Architecture.
Prerna Saxena [Tue, 4 Nov 2014 17:21:26 +0000 (22:51 +0530)]
Cpu: Add support for Power LE Architecture.

This adds support for PowerPC Little Endian architecture.,
and allows libvirt to spawn VMs based on 'ppc64le' architecture.

Signed-off-by: Pradipta Kr. Banerjee <bpradip@in.ibm.com>
Signed-off-by: Prerna Saxena <prerna@linux.vnet.ibm.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
10 years agogitignore: use wildcard for configure's temporary files
Martin Kletzander [Thu, 6 Nov 2014 15:53:28 +0000 (16:53 +0100)]
gitignore: use wildcard for configure's temporary files

Pushed as trivial and pre-ACK'd here:

https://www.redhat.com/archives/libvir-list/2014-November/msg00180.html

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agoFix build-time pkg-config files in VPATH
Jiri Denemark [Thu, 6 Nov 2014 09:59:44 +0000 (10:59 +0100)]
Fix build-time pkg-config files in VPATH

Since libvirt.h was split into several files, it is impossible to
compile anything against a VPATH-built libvirt. In VPATH, only libvirt.h
is in build/include/libvirt while all other libvirt-*.h files are in
source/include/libvirt.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
10 years agovirnetdevbandwidth: Include virutil.h
Michal Privoznik [Thu, 6 Nov 2014 14:30:13 +0000 (15:30 +0100)]
virnetdevbandwidth: Include virutil.h

One of the latest patches (9a8fc3efc2470) introduced call of
geteuid(). However, not all systems have the function
implemented, e.g. mingw. Therefore, we fail to build on those
system. The fix consist of including virutil.h which defines
geteuid in needed. Sigh.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoqemu: Update fsfreeze status on domain state transitions
Michal Privoznik [Mon, 3 Nov 2014 11:57:44 +0000 (12:57 +0100)]
qemu: Update fsfreeze status on domain state transitions

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

As of b6d4dad1 (1.2.5) libvirt keeps track if domain disks have been
frozen. However, this falls into that set of information which don't
survive domain restart. Therefore, we need to clear the flag upon some
state transitions. Moreover, once we clear the flag we must update the
status file too.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoqemu: Allow use of iothreads for virtio ccw disk definitions
Boris Fiuczynski [Thu, 6 Nov 2014 14:04:05 +0000 (15:04 +0100)]
qemu: Allow use of iothreads for virtio ccw disk definitions

Extending the iothread disk support from pci to pci and ccw.

Signed-off-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Reviewed-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com>
10 years agoqemu: Correct disk type checking logic for iothreads
Boris Fiuczynski [Thu, 6 Nov 2014 14:04:04 +0000 (15:04 +0100)]
qemu: Correct disk type checking logic for iothreads

Finding the right type of disk should check for virtio as bus and
pci as device address type.

Signed-off-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Reviewed-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
10 years agovirsh: fix net-dhcp-leases no output in quiet mode
Luyao Huang [Sat, 1 Nov 2014 10:41:20 +0000 (18:41 +0800)]
virsh: fix net-dhcp-leases no output in quiet mode

When run net-dhcp-leases in quiet mode, cannot get
any output.

 # virsh -q net-dhcp-leases default

Signed-off-by: Luyao Huang <lhuang@redhat.com>
10 years agonetwork: fix call virNetworkEventLifecycleNew when networkStartNetwork fail
Luyao Huang [Sat, 1 Nov 2014 10:03:23 +0000 (18:03 +0800)]
network: fix call virNetworkEventLifecycleNew when networkStartNetwork fail

When start a network fail, libvirt still call virNetworkEventLifecycleNew
to send a event.

Signed-off-by: Luyao Huang <lhuang@redhat.com>
10 years agonuma: fix assumption in virNumaNodeIsAvailable()
Martin Kletzander [Thu, 6 Nov 2014 11:17:10 +0000 (12:17 +0100)]
numa: fix assumption in virNumaNodeIsAvailable()

When compiled without full numa support, the stub function for
virNumaNodeIsAvailable() just checks whether specified node is in range
<0, max); where max is maximum NUMA node available on the host.  But
because the maximum node number is the highest usabe number (and not the
count of nodes), the check is incorrect as it should check whether the
specified node is in range <0, max> instead.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agonuma: split util/ and conf/ and support non-contiguous nodesets
Martin Kletzander [Thu, 6 Nov 2014 11:16:54 +0000 (12:16 +0100)]
numa: split util/ and conf/ and support non-contiguous nodesets

This is a reaction to Michal's fix [1] for non-NUMA systems that also
splits out conf/ out of util/ because libvirt_util shouldn't require
libvirt_conf if it is the other way around.  This particular use case
worked, but we're trying to avoid it as mentioned [2], many times.

The only functions from virnuma.c that needed numatune_conf were
virDomainNumatuneNodesetIsAvailable() and virNumaSetupMemoryPolicy().
The first one should be in numatune_conf as it works with
virDomainNumatune, the second one just needs nodeset and mode, both of
which can be passed without the need of numatune_conf.

Apart from fixing that, this patch also fixes recently added
code (between commits d2460f85^..5c8515620) that doesn't support
non-contiguous nodesets.  It uses new function
virNumaNodesetIsAvailable(), which doesn't need a stub as it doesn't use
any libnuma functions, to check if every specified nodeset is available.

[1] https://www.redhat.com/archives/libvir-list/2014-November/msg00118.html
[2] http://www.redhat.com/archives/libvir-list/2011-June/msg01040.html

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agoadd temporary compilation files into .gitignore
Martin Kletzander [Thu, 6 Nov 2014 11:17:19 +0000 (12:17 +0100)]
add temporary compilation files into .gitignore

When using git-status during configure phase, three additional files are
shown as untracked.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agoIface: disallow network tuning in session mode globally
Erik Skultety [Thu, 6 Nov 2014 11:38:52 +0000 (12:38 +0100)]
Iface: disallow network tuning in session mode globally

Patch 43b67f2e disallowed network tuning only with qemu driver, however
this patch moved the check for root privileges into
virNetDevBandwidthSet function, so the call should now
fail in all possible cases. A mock function was created so that the test
suite doesn't fail because of unsufficient privileges.

10 years agoqemu: revert patch - bandwidth tuning in session mode
Erik Skultety [Thu, 6 Nov 2014 11:38:51 +0000 (12:38 +0100)]
qemu: revert patch - bandwidth tuning in session mode

Since there was a valid note to patch 43b67f2e about the best spot to
check for bandwidth set call while having libvirt daemon run in session
mode, this patch reverts previous changes dealing with bandwith
(also reverts adding variable @cfg in qemuDomainGetNumaParameters which
 does not have any use at the moment, but getting and unreferencing
 driver's config) in qemu_driver.c and qemu_command.c. There will be
another patch in the series which introduces the fix itself.

10 years agoFree job statistics from the migration cookie
Ján Tomko [Thu, 6 Nov 2014 11:24:46 +0000 (12:24 +0100)]
Free job statistics from the migration cookie

==404== 232 bytes in 1 blocks are definitely lost in loss record 669 of 758
==404==    at 0x4C2B934: calloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==404==    by 0x52A2BF3: virAlloc (viralloc.c:144)
==404==    by 0x1D49AD70: qemuMigrationCookieAddStatistics (qemu_migration.c:554)
==404==    by 0x1D49AD70: qemuMigrationBakeCookie (qemu_migration.c:1228)
==404==    by 0x1D4A43B8: qemuMigrationFinish (qemu_migration.c:5002)
==404==    by 0x1D4C9339: qemuDomainMigrateFinish3Params (qemu_driver.c:11526)

Introduced by commit 5d6fb96

10 years agovirsh: Fix types for option bandwidth in block*
Hao Liu [Thu, 6 Nov 2014 08:01:00 +0000 (09:01 +0100)]
virsh: Fix types for option bandwidth in block*

Bandwidth options in blockcommit, blockcopy, blockjob and blockpull
are parsed by vshCommandOptULWrap() and should be shown as a number
type option.

And a typo is fixed.

Signed-off-by: Hao Liu <hliu@redhat.com>
10 years agoprivate.syms: Export virDomainNumatuneSpecifiedMaxNode
Michal Privoznik [Wed, 5 Nov 2014 16:58:30 +0000 (17:58 +0100)]
private.syms: Export virDomainNumatuneSpecifiedMaxNode

As of 90286418 the function is introduced. However, it's missing
an entry in the libvirt_private.syms so it can't be mocked.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agovirnuma: Add some more comments
Michal Privoznik [Wed, 5 Nov 2014 16:51:27 +0000 (17:51 +0100)]
virnuma: Add some more comments

Well, in fact only add comments to mark ifdef,
else and endif sections.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoCVE-2014-7823: dumpxml: security hole with migratable flag
Eric Blake [Sat, 1 Nov 2014 04:14:07 +0000 (22:14 -0600)]
CVE-2014-7823: dumpxml: security hole with migratable flag

Commit 28f8dfd (v1.0.0) introduced a security hole: in at least
the qemu implementation of virDomainGetXMLDesc, the use of the
flag VIR_DOMAIN_XML_MIGRATABLE (which is usable from a read-only
connection) triggers the implicit use of VIR_DOMAIN_XML_SECURE
prior to calling qemuDomainFormatXML.  However, the use of
VIR_DOMAIN_XML_SECURE is supposed to be restricted to read-write
clients only.  This patch treats the migratable flag as requiring
the same permissions, rather than analyzing what might break if
migratable xml no longer includes secret information.

Fortunately, the information leak is low-risk: all that is gated
by the VIR_DOMAIN_XML_SECURE flag is the VNC connection password;
but VNC passwords are already weak (FIPS forbids their use, and
on a non-FIPS machine, anyone stupid enough to trust a max-8-byte
password sent in plaintext over the network deserves what they
get).  SPICE offers better security than VNC, and all other
secrets are properly protected by use of virSecret associations
rather than direct output in domain XML.

* src/remote/remote_protocol.x (REMOTE_PROC_DOMAIN_GET_XML_DESC):
Tighten rules on use of migratable flag.
* src/libvirt-domain.c (virDomainGetXMLDesc): Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agoqemuDomainUpdateDeviceConfig: Allow startupPolicy update
Michal Privoznik [Tue, 28 Oct 2014 18:50:43 +0000 (19:50 +0100)]
qemuDomainUpdateDeviceConfig: Allow startupPolicy update

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

Users might want to update startupPolicy via the
virDomainUpdateDeviceFlags API too. This patch
implements the feature on config layer.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoremote: Fix memory leak in remoteConnectGetAllDomainStats
Peter Krempa [Wed, 5 Nov 2014 11:34:51 +0000 (12:34 +0100)]
remote: Fix memory leak in remoteConnectGetAllDomainStats

The remote call actually doesn't free the arguments array so we leak
memory in case a domain list is specified. As the remote domain list
array consists only of stolen pointers from the actual domain objects
it's sufficient just to free the array.

Valgrind message:
==1081452== 64 bytes in 1 blocks are definitely lost in loss record 632 of 726
==1081452==    at 0x4C296D0: calloc (vg_replace_malloc.c:618)
==1081452==    by 0x4EA5CB4: virAllocN (viralloc.c:191)
==1081452==    by 0x505D21E: remoteConnectGetAllDomainStats (remote_driver.c:7785)
==1081452==    by 0x50081AA: virDomainListGetStats (libvirt-domain.c:11080)
==1081452==    by 0x155249: cmdDomstats (virsh-domain-monitor.c:2147)
==1081452==    by 0x12FB73: vshCommandRun (virsh.c:1935)
==1081452==    by 0x133FEB: main (virsh.c:3719)

10 years agoMemory: Use consistent type for all memory elements.
Prerna Saxena [Fri, 31 Oct 2014 10:37:21 +0000 (16:07 +0530)]
Memory: Use consistent type for all memory elements.

Domain memory elements such as max_balloon and cur_balloon are
implemented as 'unsigned long long', whereas the 'memory' element
in NUMA cells is implemented as 'unsigned int'.

Use the same data type (unsigned long long) for 'memory' element
in NUMA cells.

Signed-off-by: Prerna Saxena <prerna@linux.vnet.ibm.com>
10 years agoRequire at least one console for LXC domain
Ján Tomko [Fri, 31 Oct 2014 08:51:23 +0000 (09:51 +0100)]
Require at least one console for LXC domain

A domain without a console quietly dies soon after start,
because we try to set /dev/null as a controlling TTY
2014-10-30 15:10:59.705+0000: 1: error : lxcContainerSetupFDs:283 :
ioctl(TIOCSCTTY) failed: Inappropriate ioctl for device

Report an error early instead of trying to start it.

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

10 years agoDo not probe for power mgmt capabilities in lxc emulator
Ján Tomko [Fri, 31 Oct 2014 09:02:22 +0000 (10:02 +0100)]
Do not probe for power mgmt capabilities in lxc emulator

It fails after 30 seconds with this error:
error : virDBusCall:1429 : error from service: CanSuspend:
Did not receive a reply. Possible causes include: the remote
application did not send a reply, the message bus security
policy blocked the reply, the reply timeout expired, or the
network connection was broken.

Only probe for the power mgmt capabilities when driver is non-NULL.
This speeds up domain startup by 30 seconds.

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

10 years agoutil: fix releasing pidfile in cleanup
Martin Kletzander [Tue, 4 Nov 2014 09:46:41 +0000 (10:46 +0100)]
util: fix releasing pidfile in cleanup

Coverity found out the very obvious problem in the code.  That is that
virPidFileReleasePath() was called only if
virPidFileAcquirePath() returned 0.  But virPidFileAcquirePath() doesn't
return only 0 on success, but the FD that needs to be closed.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agoqemu: stop NBD server after successful migration
Weiwei Li [Tue, 4 Nov 2014 09:52:10 +0000 (10:52 +0100)]
qemu: stop NBD server after successful migration

In qemuMigrationFinish mig->nbd can not be initialized by
qemuMigrationEatCookie without the QEMU_MIGRATION_COOKIE_NBD flag.
That causes qemuMigrationStopNBDServer to return early without
stopping the NBD server properly.

Signed-off-by: Weiwei Li <nuonuoli@tencent.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
10 years agovirnuma: use virNumaNodesetIsAvailable checking nodeset in virNumaSetupMemoryPolicy
Chen Fan [Tue, 4 Nov 2014 02:44:41 +0000 (10:44 +0800)]
virnuma: use virNumaNodesetIsAvailable checking nodeset in virNumaSetupMemoryPolicy

Signed-off-by: Chen Fan <chen.fan.fnst@cn.fujitsu.com>
10 years agonumatune: add check for numatune nodeset range
Chen Fan [Tue, 4 Nov 2014 02:44:40 +0000 (10:44 +0800)]
numatune: add check for numatune nodeset range

There was no check for 'nodeset' attribute in numatune-related
elements.  This patch adds validation that any nodeset specified does
not exceed maximum host node.

Signed-off-by: Chen Fan <chen.fan.fnst@cn.fujitsu.com>
10 years agobitmap: add virBitmapLastSetBit for finding the last bit position of bitmap
Chen Fan [Tue, 4 Nov 2014 02:44:39 +0000 (10:44 +0800)]
bitmap: add virBitmapLastSetBit for finding the last bit position of bitmap

Signed-off-by: Chen Fan <chen.fan.fnst@cn.fujitsu.com>
10 years agoexamples: add systemtap script to ease lock debugging
Martin Kletzander [Wed, 13 Aug 2014 13:52:34 +0000 (15:52 +0200)]
examples: add systemtap script to ease lock debugging

As discussed before, this simple script should help with debugging
deadlocks, although there are still some caveats.  RWLocks are not
handled by this and if your deadlock if very racy, it may not lock
up when running with this script due to the slowdown.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agoqemu: avoid rare race when undefining domain
Martin Kletzander [Thu, 30 Oct 2014 13:38:35 +0000 (14:38 +0100)]
qemu: avoid rare race when undefining domain

When one domain is being undefined and at the same time started, for
example, there is a possibility of a rare problem occuring.

 - Thread 1 does virDomainUndefine(), has the lock, checks that the
   domain is active and because it's not, calls
   virDomainObjListRemove().

 - Thread 2 does virDomainCreate() and tries to lock the domain.

 - Thread 1 needs to lock domain list in order to remove the domain from
   it, but must unlock domain first (proper order is to lock domain list
   first and the domain itself second).

 - Thread 2 grabs the lock, starts the domain and releases the lock.

 - Thread 1 grabs the lock and removes the domain from list.

With this patch:

 - qemuDomainRemoveInactive() creates a QEMU_JOB_MODIFY if that's
   possible, but since it must remove the domain from list either way,
   it continues even when starting the job failed.

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agovirsh: don't list unknown domains
Martin Kletzander [Thu, 30 Oct 2014 13:39:04 +0000 (14:39 +0100)]
virsh: don't list unknown domains

When the list of domains is fetched and being printed, but in the
meantime one domain was undefined before its status was fetched, the
output then includes domain with "no state".  With this patch, such
domain is skipped over as consecutive 'virsh list --all' (or the same
one ran a second later) wouldn't list it anyway.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agolxc: improve error message for invalid blkiotune settings
Martin Kletzander [Wed, 29 Oct 2014 15:36:39 +0000 (16:36 +0100)]
lxc: improve error message for invalid blkiotune settings

Before:
  $ virsh blkiotune dummy --device-read-bytes-sec /dev/sda,-1
  error: Unable to change blkio parameters
  error: invalid argument: unable to parse blkio device
  'device_read_bytes_sec' '/dev/sda,-1'

After:
  $ virsh blkiotune dummy --device-read-bytes-sec /dev/sda,-1
  error: Unable to change blkio parameters
  error: invalid argument: invalid value '-1' for parameter
  'device_read_bytes_sec' of device '/dev/sda'

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agoqemu: improve error message for invalid blkiotune settings
Martin Kletzander [Wed, 29 Oct 2014 15:36:39 +0000 (16:36 +0100)]
qemu: improve error message for invalid blkiotune settings

Before:
  $ virsh blkiotune dummy --device-read-bytes-sec /dev/sda,-1
  error: Unable to change blkio parameters
  error: invalid argument: unable to parse blkio device
  'device_read_bytes_sec' '/dev/sda,-1'

After:
  $ virsh blkiotune dummy --device-read-bytes-sec /dev/sda,-1
  error: Unable to change blkio parameters
  error: invalid argument: invalid value '-1' for parameter
  'device_read_bytes_sec' of device '/dev/sda'

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>