Commit Graph

2339 Commits

Author SHA1 Message Date
Peter Krempa
b50b4ef30c qemu: command: Switch to bytes when formatting size for memory backends
QEMU's command line visitor as well as the JSON interface take bytes by
default for memory object sizes. Convert mebibytes to bytes so that we
can later refactor the existing code for hotplug purposes.
2015-01-31 08:53:22 +01:00
Peter Krempa
a47174c508 qemu: command: Unify values for boolean values when formating memory backends
QEMU's qapi visitor code allows yes/on/y for true and no/off/n for false
value of boolean properities. Unify the used style so that we can
generate it later and fix test cases.
2015-01-31 08:53:22 +01:00
Peter Krempa
172100ac85 qemu: command: Shuffle around formating of alias for memory backend objs
Move the alias as the second formated argument and tweak the tests so
that a future refactor that will change the order doesn't break tests.
2015-01-31 08:53:22 +01:00
Peter Krempa
331b2583ec qemu: command: Add helper to format -object strings from JSON representation
Unlike -device, qemu uses a JSON object to add backend "objects" via the
monitor rather than the string that would be passed on the commandline.

To be able to reuse code parts that configure backends for various
devices, this patch adds a helper that will allow generating the command
line representations from the JSON property object.
2015-01-31 08:53:22 +01:00
Peter Krempa
d793aeedf2 test: utils: Add helpers for automatic numbering of test cases
Adding or reordering test cases is usually a pain due to static test
case names that are then passed to virtTestRun(). To ease the numbering
of test cases, this patch adds two simple helpers that generate the test
names according to the order they are run. The test name can be
configured via the reset function.

This will allow us to freely add test cases in middle of test groups
without the need to re-number the rest of test cases.
2015-01-31 08:53:21 +01:00
Michal Privoznik
bbd3eb5098 conf: Don't mangle vcpu placement randomly
https://bugzilla.redhat.com/show_bug.cgi?id=1170492

In one of our previous commits (dc8b7ce7) we've done a functional
change even though it was intended as pure refactor. The problem is,
that the following XML:

 <vcpu placement='static' current='2'>6</vcpu>
 <cputune>
   <emulatorpin cpuset='1-3'/>
 </cputune>
 <numatune>
   <memory mode='strict' placement='auto'/>
 </numatune>

gets translated into this one:

 <vcpu placement='auto' current='2'>6</vcpu>
 <cputune>
   <emulatorpin cpuset='1-3'/>
 </cputune>
 <numatune>
   <memory mode='strict' placement='auto'/>
 </numatune>

We should not change the vcpu placement mode. Moreover, we're doing
something similar in case of emulatorpin and iothreadpin. If they were
set, but vcpu placement was auto, we've mistakenly removed them from
the domain XML even though we are able to set them independently on
vcpus.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-01-30 13:51:22 +01:00
Michal Privoznik
5222256849 schemas: Allow all generic elements and attributes for all interfaces
There are some interface types (notably 'server' and 'client')
which instead of allowing the default set of elements and
attributes (like the rest do), try to enumerate only the elements
they know of. This way it's, however, easy to miss something. For
instance, the <address/> element was not mentioned at all. This
resulted in a strange behavior: when such interface was added
into XML, the address was automatically generated by parsing
code. Later, the formatted XML hasn't passed the RNG schema. This
became more visible once we've turned on the XML validation on
domain XML changes: appending an empty line at the end of
formatted XML (to trick virsh think the XML had changed) made
libvirt to refuse the very same XML it formatted.

Instead of trying to find each element and attribute we are
missing in the schema, lets just allow all the elements and
attributes like we're doing that for the rest of types. It's no
harm if the schema is wider than our parser allows.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-01-29 16:23:15 +01:00
Michal Privoznik
436dcf0b74 qemu: Add AAVMF to the list of known UEFIs
Well, even though users can pass the list of UEFI:NVRAM pairs at the
configure time, we may maintain the list of widely available UEFI
ourselves too. And as arm64 begin to rises, OVMF was ported there too.
With a slight name change - it's called AAVMF, with AAVMF_CODE.fd
being the UEFI firmware and AAVMF_VARS.fd being the NVRAM store file.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-01-29 15:20:47 +01:00
Michal Privoznik
bc03a23149 qemu: Allow UEFI paths to be specified at compile time
Up until now there are just two ways how to specify UEFI paths to
libvirt. The first one is editing qemu.conf, the other is editing
qemu_conf.c and recompile which is not that fancy. So, new
configure option is introduced: --with-loader-nvram which takes a
list of pairs of UEFI firmware and NVRAM store. This way, the
compiled in defaults can be passed during compile time without
need to change the code itself.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-01-29 15:20:42 +01:00
Daniel P. Berrange
f7afeddce9 qemu: report TAP device indexes to systemd
Record the index of each TAP device created and report them to
systemd, so they show up in machinectl status for the VM.
2015-01-27 13:57:02 +00:00
Daniel P. Berrange
55ea7be7d9 Removing probing of secondary drivers
For stateless, client side drivers, it is never correct to
probe for secondary drivers. It is only ever appropriate to
use the secondary driver that is associated with the
hypervisor in question. As a result the ESX & HyperV drivers
have both been forced to do hacks where they register no-op
drivers for the ones they don't implement.

For stateful, server side drivers, we always just want to
use the same built-in shared driver. The exception is
virtualbox which is really a stateless driver and so wants
to use its own server side secondary drivers. To deal with
this virtualbox has to be built as 3 separate loadable
modules to allow registration to work in the right order.

This can all be simplified by introducing a new struct
recording the precise set of secondary drivers each
hypervisor driver wants

struct _virConnectDriver {
    virHypervisorDriverPtr hypervisorDriver;
    virInterfaceDriverPtr interfaceDriver;
    virNetworkDriverPtr networkDriver;
    virNodeDeviceDriverPtr nodeDeviceDriver;
    virNWFilterDriverPtr nwfilterDriver;
    virSecretDriverPtr secretDriver;
    virStorageDriverPtr storageDriver;
};

Instead of registering the hypervisor driver, we now
just register a virConnectDriver instead. This allows
us to remove all probing of secondary drivers. Once we
have chosen the primary driver, we immediately know the
correct secondary drivers to use.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2015-01-27 12:02:04 +00:00
Michal Privoznik
c6ec7c6b0b tests: Check for virQEMUDriverConfigNew return value
The function may return NULL if something went wrong. In some places
in the tests we are not checking the return value rather than
accessing the pointer directly resulting in SIGSEGV.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-01-26 17:34:33 +01:00
Ján Tomko
b54f48812d Fix a memory leak in virCgroupGetPercpuStats
Coverity reports that my commit af1c98e introduced
two memory leaks:
the cpumap if ncpus == 0 in virCgroupGetPercpuStats
and the params array in the test of the function.
2015-01-26 16:13:06 +01:00
Ján Tomko
d66e136bd5 Fix build with older gcc
My commit af1c98e4 broke the build on RHEL-6:
vircgrouptest.c: In function 'testCgroupGetPercpuStats':
vircgrouptest.c:566: error: nested extern declaration of
'_gl_verify_function2' [-Wnested-externs]

The only thing that needs checking is that the array size
is at least EXPECTED_NCPUS, to prevent access beyond the array.

We can ensure the minimum size also by specifying the array
size upfront.
2015-01-23 10:35:20 +01:00
Ján Tomko
af1c98e406 Fix virCgroupGetPercpuStats with non-continuous present CPUs
Per-cpu stats are only shown for present CPUs in the cgroups,
but we were only parsing the largest CPU number from
/sys/devices/system/cpu/present and looking for stats even for
non-present CPUs.
This resulted in:
internal error: cpuacct parse error
2015-01-22 17:01:11 +01:00
Ján Tomko
280ece4af9 qemu: format server interface without a listen address
https://bugzilla.redhat.com/show_bug.cgi?id=1130390

The listen address is not mandatory for <interface type='server'>
but when it's not specified, we've been formatting it as:
-netdev socket,listen=(null):5558,id=hostnet0
which failed with:
Device 'socket' could not be initialized

Omit the address completely and only format the port in the listen
attribute.

Also fix the schema to allow specifying a model.
2015-01-21 13:22:36 +01:00
Jim Fehlig
e274d5882e tests: fix xlconfigtest build failure
When libvirt is configured --without-xen, building the xlconfigtest
fails with

  CCLD   xlconfigtest
  /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/crt1.o
  In function `_start': (.text+0x20): undefined reference to `main'
  collect2: error: ld returned 1 exit status

Introduced in commit 4ed5fb91 by too much copy and paste from
xmconfigtest.
2015-01-20 21:03:09 -07:00
Josh Stone
298fa4858c network: Let domains be restricted to local DNS
This adds a new "localOnly" attribute on the domain element of the
network xml.  With this set to "yes", DNS requests under that domain
will only be resolved by libvirt's dnsmasq, never forwarded upstream.

This was how it worked before commit f69a6b987d, and I found that
functionality useful.  For example, I have my host's NetworkManager
dnsmasq configured to forward that domain to libvirt's dnsmasq, so I can
easily resolve guest names from outside.  But if libvirt's dnsmasq
doesn't know a name and forwards it to the host, I'd get an endless
forwarding loop.  Now I can set localOnly="yes" to prevent the loop.

Signed-off-by: Josh Stone <jistone@redhat.com>
2015-01-20 01:07:18 -05:00
Gary R Hook
e11490e358 Make ZFS storage pool XML tests optional
Do not run ZFS tests when ZFS is unsupported in the environment.

The recent patch b4af40226d adds tests
to storagepoolxml2xmltest for the optional ZFS feature. When ZFS is
not included in the configuration these tests should not / cannot be
run. Modify the test source file to check for use of the feature and
compile in the tests accordingly.

Signed-off-by: Gary R Hook <gary.hook@nimboxx.com>
2015-01-19 15:03:01 +01:00
Ján Tomko
bc378060f7 Add an XML test for host-model CPU with features
This was broken in a dowstream build due to a missing backport:
https://bugzilla.redhat.com/show_bug.cgi?id=1182448
2015-01-19 10:11:15 +01:00
Dmitry Guryanov
c8a6f844c3 add ploop fs driver type
Ploop is a pseudo device which makeit possible to access
to an image in a file as a block device. Like loop devices,
but with additional features, like snapshots, write tracker
and without double-caching.

It used in PCS for containers and in OpenVZ. You can manage
ploop devices and images with ploop utility
(http://git.openvz.org/?p=ploop).

Signed-off-by: Dmitry Guryanov <dguryanov@parallels.com>
2015-01-16 14:07:46 +01:00
Martin Kletzander
6514c04c18 qemu: Add support for enabling/disabling PMU
This is used as a boolean parameter for the '-cpu' option.

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2015-01-16 13:43:46 +01:00
Martin Kletzander
199390117c docs, schema, conf: Add support for PMU feature
Just a new feature that can be turned on/off.

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2015-01-16 13:43:46 +01:00
Erik Skultety
78f911d7d0 Add XML test for too many PCI devices on default PCI bus 2015-01-16 10:59:26 +01:00
Cédric Bosdonnat
a117652917 Use the network route definitions for domains 2015-01-16 10:14:03 +01:00
Daniel P. Berrange
318df5a05f Add support for systemd-machined CreateMachineWithNetwork
systemd-machined introduced a new method CreateMachineWithNetwork
that obsoletes CreateMachine. It expects to be given a list of
VETH/TAP device indexes for the host side device(s) associated
with a container/machine.

This falls back to the old CreateMachine method when the new
one is not supported.
2015-01-15 11:07:07 +00:00
Ján Tomko
a5e5996b91 Mark the domain as active in qemuhotplugtest
This will allow us to call qemuDomainObjIsActive() in
the tested functions to check if the domain has crashed.
2015-01-14 19:30:32 +01:00
Kiarie Kahurani
4ed5fb9193 tests: Tests for the xen-xl parser
Add disk and spice config tests for the xen_xl config parser

Signed-off-by: Kiarie Kahurani <davidkiarie4@gmail.com>
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
2015-01-14 08:28:50 -07:00
Michal Privoznik
a605025c21 conf: Increase virNetDevBandwidthParse intelligence
There's this function virNetDevBandwidthParse which parses the
bandwidth XML snippet. But it's not clever much. For the
following XML it allocates the virNetDevBandwidth structure even
though it's completely empty:

    <bandwidth>
    </bandwidth>

Later in the code there are some places where we check if
bandwidth was set or not. And since we obtained pointer from the
parsing function we think that it is when in fact it isn't.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-01-13 18:24:15 +01:00
Daniel P. Berrange
0ecd685109 Give virDomainDef parser & formatter their own flags
The virDomainDefParse* and virDomainDefFormat* methods both
accept the VIR_DOMAIN_XML_* flags defined in the public API,
along with a set of other VIR_DOMAIN_XML_INTERNAL_* flags
defined in domain_conf.c.

This is seriously confusing & error prone for a number of
reasons:

 - VIR_DOMAIN_XML_SECURE, VIR_DOMAIN_XML_MIGRATABLE and
   VIR_DOMAIN_XML_UPDATE_CPU are only relevant for the
   formatting operation
 - Some of the VIR_DOMAIN_XML_INTERNAL_* flags only apply
   to parse or to format, but not both.

This patch cleanly separates out the flags. There are two
distint VIR_DOMAIN_DEF_PARSE_* and VIR_DOMAIN_DEF_FORMAT_*
flags that are used by the corresponding methods. The
VIR_DOMAIN_XML_* flags received via public API calls must
be converted to the VIR_DOMAIN_DEF_FORMAT_* flags where
needed.

The various calls to virDomainDefParse which hardcoded the
use of the VIR_DOMAIN_XML_INACTIVE flag change to use the
VIR_DOMAIN_DEF_PARSE_INACTIVE flag.
2015-01-13 16:26:12 +00:00
Daniel P. Berrange
e34473c1da Decouple CPU XML formatting from domain XML public API flags
The virCPUDefFormat* methods were relying on the VIR_DOMAIN_XML_*
flag definitions. It is not desirable for low level internal
functions to be coupled to flags for the public API, since they
may need to be called from several different contexts where the
flags would not be appropriate.
2015-01-13 16:19:56 +00:00
Martin Kletzander
adff345e1e qemu: Allow enabling/disabling features with host-passthrough
QEMU supports feature specification with -cpu host and we just skip
using that.  Since QEMU developers themselves would like to use this
feature, this patch modifies the code to work.

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2015-01-13 08:51:01 +01:00
Jim Fehlig
cb4befc748 Revert "tests: Tests for the xen-xl parser"
This reverts commit 6b818d3b09.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
2015-01-12 10:15:09 -07:00
Michal Privoznik
d776e995e3 qemuxml2argvtest: Fix test after change of qxl vgamem_mb default
Well, apparently it's possible for a patch to sneak in through
review process and break 'make check'. It happened just lately
with 0e502466ac which changed the default of vgamem_mb for
qxl device. However, there were left some domain XMLs within our
test suite relying on the old default. These should be updated to
match the change.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-01-12 15:47:52 +01:00
Geoff Hickey
bb072e8a38 vmx: Fix a VMX parsing problem
VMware ESX does not always set the "serialX.fileType" tag in VMX files. The
default value for this tag is "device", and when adding a new serial port
of this type VMware will omit the fileType tag. This caused libvirt to
fail to parse the VMX file. Fixed by making this tag optional and using
"device" as a default value. Also updated vmx2xmltest to test for this
case.

Signed-off-by: Eric Blake <eblake@redhat.com>
2015-01-07 17:17:00 -07:00
Stefan Berger
3a3b3691d1 nwfilter: Add support for icmpv6 filtering
Make use of the ebtables functionality to be able to filter certain
parameters of icmpv6 packets. Extend the XML parser for icmpv6 types,
type ranges, codes, and code ranges. Extend the nwfilter documentation,
schema, and test cases.

Being able to filter icmpv6 types and codes helps extending the DHCP
snooper for IPv6 and filtering at least some parameters of IPv6's NDP
(Neighbor Discovery Protocol) packets. However, the filtering will not
be as good as the filtering of ARP packets since we cannot
check on IP addresses in the payload of the NDP packets.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2015-01-07 11:41:49 -05:00
Cédric Bosdonnat
430e939127 lxc conf2xml: convert lxc.network.ipv[46].gateway 2015-01-05 20:24:17 +01:00
Cédric Bosdonnat
c9a641f1e5 Domain network devices can now have a <route> element
Network interfaces devices and host devices with net capabilities can
now have IPv4 and/or an IPv6 routes configured.
2015-01-05 20:24:17 +01:00
Cédric Bosdonnat
7100be40a5 lxc conf2xml: convert ip addresses for hostdev NICs 2015-01-05 20:24:17 +01:00
Cédric Bosdonnat
2811cc611e Allow network capabilities hostdev to configure IP addresses 2015-01-05 20:24:17 +01:00
Cédric Bosdonnat
12a75f371c lxc conf2xml: convert IP addresses 2015-01-05 20:24:17 +01:00
Cédric Bosdonnat
aa2cc72100 Domain conf: allow more than one IP address for net devices
Add the possibility to have more than one IP address configured for a
domain network interface. IP addresses can also have a prefix to define
the corresponding netmask.
2015-01-05 20:24:04 +01:00
Chunyan Liu
262d913ffc Add tests to xmconfigtest
Add tests to testing HVM default features (pae, acpi, apic)
conversion from xm config to libvirt xml. If no pae|acpi|apic
specified in xm config, after conversion, libvirt xml should
by default include:
 <features>
   <pae/>
   <apic/>
   <acpi/>
 </features>

Signed-off-by: Chunyan Liu <cyliu@suse.com>
2015-01-04 11:10:14 -07:00
Kiarie Kahurani
6b818d3b09 tests: Tests for the xen-xl parser
add tests for the xen_xl config parser

Signed-off-by: Kiarie Kahurani <davidkiarie4@gmail.com>
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
2015-01-03 22:41:26 -07:00
Michal Privoznik
2360fe5d24 capabilities: Format <domain/> properly
The <domain/> element under /capabilities/guest/arch/ can have no
child elements. If that's the case we format:

        <domain type='xen'>
        </domain>

instead of simpler:

        <domain type='xen'/>

This commit fixes that.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2014-12-24 18:01:44 +01:00
Martin Kletzander
42dc7a471d tests: Set up two more overrides for root builders
There are two more places after commit 3865941b that need to be adapted
in order to get rid of some test failures when building as root.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2014-12-23 06:10:55 +01:00
Stefan Berger
3865941be1 test: fix nwfilter tests following changes in virfirewall.c
Some of the nwfilter tests are now failing since --concurrent shows
up in the ebtables command. To avoid this, implement a function
preventing the probing for lock support in the eb/iptables tools
and use it in the tests.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2014-12-22 16:57:21 -05:00
Michal Privoznik
f309db1f4d qemu: Create memory-backend-{ram,file} iff needed
Libvirt BZ: https://bugzilla.redhat.com/show_bug.cgi?id=1175397
QEMU BZ:    https://bugzilla.redhat.com/show_bug.cgi?id=1170093

In qemu there are two interesting arguments:

1) -numa to create a guest NUMA node
2) -object memory-backend-{ram,file} to tell qemu which memory
region on which host's NUMA node it should allocate the guest
memory from.

Combining these two together we can instruct qemu to create a
guest NUMA node that is tied to a host NUMA node. And it works
just fine. However, depending on machine type used, there might
be some issued during migration when OVMF is enabled (see QEMU
BZ). While this truly is a QEMU bug, we can help avoiding it. The
problem lies within the memory backend objects somewhere. Having
said that, fix on our side consists on putting those objects on
the command line if and only if needed. For instance, while
previously we would construct this (in all ways correct) command
line:

    -object memory-backend-ram,size=256M,id=ram-node0 \
    -numa node,nodeid=0,cpus=0,memdev=ram-node0

now we create just:

    -numa node,nodeid=0,cpus=0,mem=256

because the backend object is obviously not tied to any specific
host NUMA node.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2014-12-19 07:44:44 +01:00
Martin Kletzander
d2632d60aa storage: unify permission formatting
Volume and pool formatting functions took different approaches to
unspecified uids/gids.  When unknown, it is always parsed as -1, but one
of the functions formatted it as unsigned int (wrong) and one as
int (better).  Due to that, our two of our XML files from tests cannot
be parsed on 32-bit machines.

RNG schema needs to be modified as well, but because both
storagepool.rng and storagevol.rng need same schema for permission
element, save some space by moving it to storagecommon.rng.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2014-12-16 15:47:56 +01:00
Michal Privoznik
311b4a677f qemu: Allow system pages to <memoryBacking/>
https://bugzilla.redhat.com/show_bug.cgi?id=1173507

It occurred to me that OpenStack uses the following XML when not using
regular huge pages:

  <memoryBacking>
    <hugepages>
      <page size='4' unit='KiB'/>
    </hugepages>
  </memoryBacking>

However, since we are expecting to see huge pages only, we fail to
startup the domain with following error:

  libvirtError: internal error: Unable to find any usable hugetlbfs
  mount for 4 KiB

While regular system pages are not huge pages technically, our code is
prepared for that and if it helps OpenStack (or other management
applications) we should cope with that.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2014-12-15 13:36:47 +01:00
Michal Privoznik
ca4f9518b8 virconf: Introduce VIR_CONF_ULONG
https://bugzilla.redhat.com/show_bug.cgi?id=1160995

In our config files users are expected to pass several integer values
for different configuration knobs. However, majority of them expect a
nonnegative number and only a few of them accept a negative number too
(notably keepalive_interval in libvirtd.conf).
Therefore, a new type to config value is introduced: VIR_CONF_ULONG
that is set whenever an integer is positive or zero. With this
approach knobs accepting VIR_CONF_LONG should accept VIR_CONF_ULONG
too.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2014-12-15 10:34:18 +01:00
Ján Tomko
15abebdecb Ignore CPU features without a model for host-passthrough
This fixes reverting to snapshots created by older libvirt
and allows libvirt not to lose track of a domain that
has this in its live status XML (such as a domain
restored from managedsave)

https://bugzilla.redhat.com/show_bug.cgi?id=1030793
https://bugzilla.redhat.com/show_bug.cgi?id=1151885
2014-12-11 12:03:36 +01:00
John Ferlan
048237e3db tests: Fix sharable typo 2014-12-09 10:02:20 -05:00
Laine Stump
40961978ee conf: new network bridge device attribute macTableManager
The macTableManager attribute of a network's bridge subelement tells
libvirt how the bridge's MAC address table (used to determine the
egress port for packets) is managed. In the default mode, "kernel",
management is left to the kernel, which usually determines entries in
part by turning on promiscuous mode on all ports of the bridge,
flooding packets to all ports when the correct destination is unknown,
and adding/removing entries to the fdb as it sees incoming traffic
from particular MAC addresses.  In "libvirt" mode, libvirt turns off
learning and flooding on all the bridge ports connected to guest
domain interfaces, and adds/removes entries according to the MAC
addresses in the domain interface configurations. A side effect of
turning off learning and unicast_flood on the ports of a bridge is
that (with Linux kernel 3.17 and newer), the kernel can automatically
turn off promiscuous mode on one or more of the bridge's ports
(usually only the one interface that is used to connect the bridge to
the physical network). The result is better performance (because
packets aren't being flooded to all ports, and can be dropped earlier
when they are of no interest) and slightly better security (a guest
can still send out packets with a spoofed source MAC address, but will
only receive traffic intended for the guest interface's configured MAC
address).

The attribute looks like this in the configuration:

  <network>
    <name>test</name>
    <bridge name='br0' macTableManager='libvirt'/>
    ...

This patch only adds the config knob, documentation, and test
cases. The functionality behind this knob is added in later patches.
2014-12-08 14:41:37 -05:00
Daniel P. Berrange
25bf888a66 Report original error when QMP probing fails with new QEMU
If probing capabilities via QMP fails, we now have a check
that prevents us falling back to -help parsing. Unfortunately
the error message

  "Failed to probe capabilities for /usr/bin/qemu-kvm:
   unsupported configuration: QEMU 2.1.2 is too new for help parsing"

is proving rather unhelpful to the user. We need to be telling
them why QMP failed (the root cause), rather than they can't
use -help (the side effect).

To do this we should capture stderr during QMP probing, and
if -help parsing then sees a new QEMU version, we know that
QMP should have worked, and so we can show the messages from
stderr. The message thus becomes

  "Failed to probe capabilities for /usr/bin/qemu-kvm:
   internal error: QEMU / QMP failed: Could not access
   KVM kernel module: No such file or directory
   failed to initialize KVM: No such file or directory"
2014-12-05 10:57:46 +00:00
Martin Kletzander
44015a2937 tests: Fix misplaced parenthesis in qemumonitorjsontest
When trying clang, it found out that we were comparing sizeof with 0
even though we wanted to check the return value of memcmp.  That showed
us that the test was wrong and it needs a fix as well.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2014-12-04 11:43:22 +01:00
Peter Krempa
421406808a network: dnsmasq: Don't format lease file path
Now that we don't use the leases file at all for leases just don't
format it into the config and use the leaseshelper to do all the
lifting.
2014-12-03 14:22:40 +01:00
Martin Kletzander
04c383ea7a tests: fix documentation for mocking methods
It looks like it was copy-pasted, so in case anyone wonders what some of
those methods do without looking at them, and for the sake of
completeness, fix them.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2014-11-27 11:17:56 +01:00
Eric Blake
96e0d6774f dbus: fix arrays of bools
Commit 2aa167ca tried to fix the DBus interaction code to allow
callers to use native types instead of 4-byte bools.  But in
fixing the issue, I missed the case of an arrayref; Conrad Meyer
shows the following valid complaint issued by clang:

  CC       util/libvirt_util_la-virdbus.lo
util/virdbus.c:956:13: error: cast from 'bool *' to 'dbus_bool_t *' (aka 'unsigned int *') increases required alignment from 1 to 4 [-Werror,-Wcast-align]
            GET_NEXT_VAL(dbus_bool_t, bool_val, bool, "%d");
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
util/virdbus.c:858:17: note: expanded from macro 'GET_NEXT_VAL'
            x = (dbustype *)(*xptrptr + (*narrayptr - 1));              \
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1 error generated.

But fixing that points out that we have NEVER supported arrayrefs
of sub-int types (byte, i16, u16, and now bool).  Again, while raw
types promote, arrays do not; so the macros HAVE to deal with both
size possibilities rather than assuming that an arrayref uses the
same sizing as the promoted raw type.

Obviously, our testsuite wasn't covering as much as it should have.

* src/util/virdbus.c (GET_NEXT_VAL): Also fix array cases.
(SET_NEXT_VAL): Fix uses of sub-int arrays.
* tests/virdbustest.c (testMessageArray, testMessageArrayRef):
Test it.

Signed-off-by: Eric Blake <eblake@redhat.com>
2014-11-25 08:47:12 -07:00
Pavel Hrdina
742d49fa17 qemu-command: introduce new vgamem attribute for QXL video device
Add attribute to set vgamem_mb parameter of QXL device for QEMU. This
value sets the size of VGA framebuffer for QXL device. Default value in
QEMU is 8MB so reuse it also in libvirt to not break things.

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

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2014-11-24 22:20:13 +01:00
Pavel Hrdina
24c6ca860e qemu-command: use vram attribute for all video devices
So far we didn't have any option to set video memory size for qemu video
devices. There was only the vram (ram for QXL) attribute but it was valid
only for the QXL video device.

To provide this feature to users QEMU has a dedicated device attribute
called 'vgamem_mb' to set the video memory size. We will use the 'vram'
attribute for setting video memory size for other QEMU video devices.

For the cirrus device we will ignore the vram value because it has
hardcoded video size in QEMU.

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

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2014-11-24 22:18:18 +01:00
Pavel Hrdina
f480a87aa6 caps: introduce new QEMU capability for vgamem_mb device property
Allow setting vgamem size for video devices.

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

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2014-11-24 22:05:56 +01:00
Pavel Hrdina
c32cfc6d3f QXL: fix setting ram and vram values for QEMU QXL device
QEMU has two different type of QXL display device. The first "qxl-vga"
is for primary video device and second "qxl" is for secondary video
device.

There are also two different ways how to specify those devices on qemu
command line, the first one and obsolete is using "-vga" option and the
current new one is using "-device" option. The "-vga" could be used only
to setup primary video device, so the "-vga qxl" equal to
"-device qxl-vga". Unfortunately the "-vga qxl" doesn't support setting
additional parameters for the device and "-global" option must be used
for this purpose. It's mandatory to use "-global qxl-vga...." to set the
parameters of primary video device previously defined with "-vga qxl".

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

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2014-11-24 22:05:56 +01:00
Pavel Hrdina
81ba2298b2 video: cleanup usage of vram attribute and update documentation
The vram attribute was introduced to set the video memory but it is
usable only for few hypervisors excluding QEMU/KVM and the old XEN
driver. Only in case of QEMU the vram was used for QXL.

This patch updates the documentation to reflect current code in libvirt
and also changes the cases when we will set the default vram attribute.
It also fixes existing strange default value for VGA devices 9MB to 16MB
because the video ram should be rounded to power of two.

The change of default value could affect migrations but I found out that
QEMU always round the video ram to power of two internally so it's safe
to change the default value to the next closest power of two and also
silently correct every domain XML definition. And it's also safe because
we don't pass the value to QEMU.

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

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2014-11-24 22:05:55 +01:00
Pavel Hrdina
ff28ebf136 internal: add macro to round value to the next closest power of 2
There are two special cases, if the input number is 0 or the number is
larger then 2^31 (for 32bit unsigned int). For the special cases the
return value is 0 because they cannot be rounded.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2014-11-24 22:05:55 +01:00
Tomoki Sekiyama
733b56a4b9 qemu: add test for qemuAgentGetFSInfo
Add test cases for qemuAgentGetFSInfo, with a sample agent response for
the qemu-get-fsinfo command and a configuration xml.

Signed-off-by: Tomoki Sekiyama <tomoki.sekiyama@hds.com>
2014-11-24 10:29:16 -05:00
Peter Krempa
4d7eb90311 qemu: chardev: Extract more information about character devices
Improve the monitor function to also retrieve the guest state of
character device (if provided) so that we can refresh the state of
virtio-serial channels and perhaps react to changes in the state in
future patches.

This patch changes the returned data from qemuMonitorGetChardevInfo to
return a structure containing the pty path and the state for all the
character devices.

The change to the testsuite makes sure that the data is parsed
correctly.
2014-11-24 08:58:30 +01:00
Peter Krempa
b7d1bee2b9 storage: rbd: Implement support for passing config file option
To be able to express some use cases of the RBD backing with libvirt, we
need to be able to specify a config file for the RBD client to qemu as
that is one of the commonly used options.
2014-11-21 14:37:03 +01:00
Peter Krempa
0255660658 storage: rbd: qemu: Add support for specifying internal RBD snapshots
Some storage systems have internal support for snapshots. Libvirt should
be able to select a correct snapshot when starting a VM.

This patch adds a XML element to select a storage source snapshot for
the RBD protocol which supports this feature.
2014-11-21 14:37:02 +01:00
Peter Krempa
930b77598b storage: Allow parsing of RBD backing strings when building backing chain
As we now have a common function to parse backing store string for RBD
backing store we can reuse it in the backing store walker so that we
don't fail on files backed by RBD storage.

This patch also adds a few tests to verify that the parsing works as
expected.
2014-11-21 14:37:02 +01:00
Peter Krempa
162e1ac6fa tests: Reflow the expected output from RBD disk test
Addition of tested cases to the test will be more obvious.
2014-11-21 14:37:02 +01:00
Peter Krempa
e650f30b93 test: virstoragetest: Add testing of network disk details
To be able to fully test parsing of networked storage strings we need to
add a few fields for: hostname, protocol and auth string.
2014-11-21 14:37:01 +01:00
Peter Krempa
24c25a68c2 conf: Add channel state for virtio channels to the XML
To track state of virtio channels this patch adds a new output-only
attribute called 'state' to the <target> element of virtio channels.

This will be later populated with the guest state of the channel.
2014-11-21 11:00:11 +01:00
Peter Krempa
e9a4506963 qemu: monitor: Rename and improve qemuMonitorGetPtyPaths
To unify future additions that require information from "query-chardev"
rename qemuMonitorGetPtyPaths and friends to qemuMonitorGetChardevInfo
and move the allocation of the returned hash into the top level
function.
2014-11-21 11:00:10 +01:00
Peter Krempa
c5942a9faa test: xml2xml: Print full filenames if xml2xml test fails
To simplify looking for a problem instrument the XML comparator function
with possibility to print the filename of the failed/expected XML
output.

This is necessary as the VIR_TEST_DIFFERENT macro possibly tests two XML
files for the inactive/active state and the resulting error may not be
obvious.
2014-11-21 11:00:10 +01:00
Eric Blake
2aa167cafd virdbus: don't force users to pass int for bool values
Use of an 'int' to represent a 'bool' value is confusing.  Just
because dbus made the mistake of cementing their 4-byte wire
format of dbus_bool_t into their API doesn't mean we have to
repeat the mistake.  With a little bit of finesse, we can
guarantee that we provide a large-enough value to the DBus
code, while still copying only the relevant one-byte bool
to the client code, and isolate the rest of our code base from
the DBus stupidity.

* src/util/virdbus.c (GET_NEXT_VAL): Add parameter.
(virDBusMessageIterDecode): Adjust all clients.
* src/util/virpolkit.c (virPolkitCheckAuth): Use nicer type.
* tests/virdbustest.c (testMessageSimple, testMessageStruct):
Test new behavior.

Signed-off-by: Eric Blake <eblake@redhat.com>
2014-11-19 08:20:39 -07: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
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
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
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
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
Conrad Meyer
a52b56b3fd bhyvexml2argv: Add test for grub console support 2014-11-12 09:55:22 +01:00
Conrad Meyer
cf133ed1c6 bhyvexml2argv: Add tests for domain-configured bootloader, args 2014-11-12 09:55:22 +01:00
Conrad Meyer
f2ce9d3645 bhyvexml2argv: Add loader argv tests. 2014-11-12 09:55:22 +01:00
Matthias Gatto
d506a51aeb 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>
2014-11-10 17:18:17 +01:00
Matthias Gatto
c5b71619bd 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>
2014-11-10 15:48:59 +01:00
Matthias Gatto
e34ffa96fb 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>
2014-11-10 15:48:59 +01:00
Prerna Saxena
e3c44f0d36 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>
2014-11-10 14:55:45 +01:00
Prerna Saxena
12c381114c 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>
2014-11-07 09:20:40 +01:00
Boris Fiuczynski
b84be34f43 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>
2014-11-06 15:13:55 +01:00
Martin Kletzander
c63ef0452b 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>
2014-11-06 15:13:55 +01:00
Erik Skultety
9a8fc3efc2 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.
2014-11-06 14:28:37 +01:00
Chen Fan
902864184e 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>
2014-11-04 07:03:36 +01:00
Chen Fan
d2460f85d3 bitmap: add virBitmapLastSetBit for finding the last bit position of bitmap
Signed-off-by: Chen Fan <chen.fan.fnst@cn.fujitsu.com>
2014-11-04 07:03:36 +01:00
Martin Kletzander
11a48758a7 qemu: make advice from numad available when building commandline
Particularly in qemuBuildNumaArgStr(), there was a need for the advice
due to memory backing, which needs to know the nodeset it will be pinned
to.  With newer qemu this caused the following error when starting
domain:

  error: internal error: Advice from numad is needed in case of
  automatic numa placement

even when starting perfectly valid domain, e.g.:

  ...
  <vcpu placement='auto'>4</vcpu>
  <numatune>
    <memory mode='strict' placement='auto'/>
  </numatune>
  <cpu>
    <numa>
      <cell id='0' cpus='0' memory='524288'/>
      <cell id='1' cpus='1' memory='524288'/>
    </numa>
  </cpu>
  ...

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2014-11-03 16:43:22 +01:00
Peter Krempa
95a5683592 test: Add test to verify helpers used for backing file name parsing
Add two test cases to verify that the helpers split and parse the
backing store components properly.
2014-10-29 17:10:42 +01:00
Peter Krempa
98784369fd storage: Fix crash when parsing backing store URI with schema
The code that parses the schema from the URI touches the "hosts[0]"
member of the storage file source structure in case the URI contains a
schema. The hosts array was not yet allocated at the point in the code
where the transport protocol was parsed and set. This lead to a crash of
libvirtd.

Fix the code by allocating the "hosts" array upfront and add a test case
to verify this scenario. (Unfortunately this requires shuffling the test
case numbers too).

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1156288
2014-10-29 17:10:42 +01:00
Eric Blake
a396c11e92 maint: avoid static zero init in tests
C guarantees that static variables are zero-initialized.  Some older
compilers (and also gcc -fno-zero-initialized-in-bss) create larger
binaries if you explicitly zero-initialize a static variable.

* tests/eventtest.c: Fix initialization.
* tests/testutils.c: Likewise.
* tests/virhostdevtest.c: Likewise.
* tests/virportallocatortest.c: Likewise.
* tests/virscsitest.c: Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
2014-10-29 09:55:09 -06:00
Julio Faracco
f2a2d0e9ab tests: Add SELINUX_LIBS to fix viridentitytest linker bug
In a clean build system (Ubuntu 14.04), the viridentitytest failed to compile.
Even if all the SELINUX libraries and depedencies are installed. See the error
message below:

[...]
  CC       viridentitytest.o
  CCLD     viridentitytest
/usr/bin/ld: viridentitytest.o: undefined reference to symbol
                                                       'security_disable'
//lib/x86_64-linux-gnu/libselinux.so.1: error adding symbols: DSO missing
                                                           from command line
collect2: error: ld returned 1 exit status
make: *** [viridentitytest] Error 1

Simply adding the variable SELINUX_LIBS in viridentitytest rules of
Makefile.am to include SELINUX libraries into viridentitytest solved that
compilation issue.

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
2014-10-24 12:01:10 -06:00
Daniel P. Berrange
0d36a5d05a Fix indentation of sysinfo data
The <sysinfo> data block was indented by 2 spaces too many.
This was missed because we never had any test validating
the XML formatting.
2014-10-24 17:23:52 +01:00
Maxime Leroy
e80be99ffa tests: fix incorrect caps for shmem-invalid-size, shmem-small-size
VIR_TEST_DEBUG=2 ./qemuxml2argvtest generates the following output:

409) QEMU XML-2-ARGV shmem-invalid-size
... Got expected error: unsupported configuration: ivshmem device is not \
	 supported with this QEMU binary
OK
410) QEMU XML-2-ARGV shmem-small-size
... Got expected error: unsupported configuration: ivshmem device is not \
supported with this QEMU binary
OK

We should have:

409) QEMU XML-2-ARGV shmem-invalid-size
... Got expected error: XML error: shmem size must be a power of two
OK
410) QEMU XML-2-ARGV shmem-small-size
... Got expected error: XML error: shmem size must be at least 1 MiB
OK

This commit fixes the issue by providing QEMU_CAPS_DEVICE_IVSHMEM caps
for shmem-invalid-size, shmem-small-size test.

Signed-off-by: Maxime Leroy <maxime.leroy@6wind.com>
2014-10-20 09:01:27 +02:00
Maxime Leroy
302720742f conf: tests: fix virDomainNetDefFormat for vhost-user in client mode
The mode attribute is required for the source element of vhost-user.
Thus virDomainNetDefFormat should always generate a xml with it and not
only when the mode is server.

The commit fixes the issue. And it adds a vhostuser interface in
'client' mode to qemuxml2argv-net-vhostuser.(args|xml) to test this
usecase.

Signed-off-by: Maxime Leroy <maxime.leroy@6wind.com>
2014-10-20 08:58:09 +02:00
Chen Fan
24c1603762 conf: add check if migration_host is a localhost address
Signed-off-by: Chen Fan <chen.fan.fnst@cn.fujitsu.com>

Signed-off-by: Ján Tomko <jtomko@redhat.com>
2014-10-15 09:25:33 +02:00
Chen Fan
69f7b67d55 migration: add migration_host support for IPv6 address without brackets
if specifying migration_host to an Ipv6 address without brackets,
it was resolved to an incorrect address, such as:
    tcp:2001:0DB8::1428:4444,
but the correct address should be:
    tcp:[2001:0DB8::1428]:4444
so we should add brackets when parsing it.

Signed-off-by: Chen Fan <chen.fan.fnst@cn.fujitsu.com>
2014-10-15 09:25:33 +02:00
Ján Tomko
6c31911a96 Introduce virStringStripIPv6Brackets
Helper function to strip the brackets from an IPv6 address.
Tested by viruritest.
2014-10-15 09:25:33 +02:00
Laine Stump
ab989962d4 qemu: qemuMonitorQueryRxFilter - retrieve guest netdev rx-filter
This function can be called at any time to get the current status of a
guest's network device rx-filter. In particular it is useful to call
after libvirt recieves a NIC_RX_FILTER_CHANGED event - this event only
tells you that something has changed in the rx-filter, the details are
retrieved with the query-rx-filter monitor command (only available in
the json monitor). The command sent to the qemu monitor looks like this:

  {"execute":"query-rx-filter", "arguments": {"name":"net2"} }'

and the results will look something like this:

{
    "return": [
        {
            "promiscuous": false,
            "name": "net2",
            "main-mac": "52:54:00:98:2d:e3",
            "unicast": "normal",
            "vlan": "normal",
            "vlan-table": [
                42,
                0
            ],
            "unicast-table": [

            ],
            "multicast": "normal",
            "multicast-overflow": false,
            "unicast-overflow": false,
            "multicast-table": [
                "33:33:ff:98:2d:e3",
                "01:80:c2:00:00:21",
                "01:00:5e:00:00:fb",
                "33:33:ff:98:2d:e2",
                "01:00:5e:00:00:01",
                "33:33:00:00:00:01"
            ],
            "broadcast-allowed": false
        }
    ],
    "id": "libvirt-14"
}

This is all parsed from JSON into a virNetDevRxFilter object for
easier consumption. (unicast-table is usually empty, but is also an
array of mac addresses similar to multicast-table).

(NB: LIBNL_CFLAGS was added to tests/Makefile.am because virnetdev.h
now includes util/virnetlink.h, which includes netlink/msg.h when
appropriate. Without LIBNL_CFLAGS, gcc can't find that file (if
libnl/netlink isn't available, LIBNL_CFLAGS will be empty and
virnetlink.h won't try to include netlink/msg.h anyway).)
2014-10-06 13:32:38 -04:00
Laine Stump
07450cd429 conf: add trustGuestRxFilters attribute to network and domain interface
This new attribute will control whether or not libvirt will pay
attention to guest notifications about changes to network device mac
addresses and receive filters. The default for this is 'no' (for
security reasons). If it is set to 'yes' *and* the specified device
model and connection support it (currently only macvtap+virtio) then
libvirt will watch for NIC_RX_FILTER_CHANGED events, and when it
receives one, it will issue a query-rx-filter command, retrieve the
result, and modify the host-side macvtap interface's mac address and
unicast/multicast filters accordingly.

The functionality behind this attribute will be in a later patch. This
patch merely adds the attribute to the top-level of a domain's
<interface> as well as to <network> and <portgroup>, and adds
documentation and schema/xml2xml tests. Rather than adding even more
test files, I've just added the net attribute in various applicable
places of existing test files.
2014-10-06 11:49:10 -04:00
Martin Kletzander
b90a9a6374 qemu: Build command line for ivshmem device
This patch implements support for the ivshmem device in QEMU.

Signed-off-by: Maxime Leroy <maxime.leroy@6wind.com>
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2014-10-03 22:43:09 +02:00
Maxime Leroy
e3d478eb51 qemu: add capability probing for ivshmem device
Ivshmem is supported by QEMU since 0.13 release.

Signed-off-by: Maxime Leroy <maxime.leroy@6wind.com>
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2014-10-03 22:43:08 +02:00
Martin Kletzander
540a84ec89 docs, conf, schema: add support for shmem device
This patch adds parsing/formatting code as well as documentation for
shared memory devices.  This will currently be only accessible in QEMU
using it's ivshmem device, but is designed as generic as possible to
allow future expansion for other hypervisors.

In the devices section in the domain XML users may specify:

- For shmem device using a server:

 <shmem name='shmem0'>
   <server path='/tmp/socket-ivshmem0'/>
   <size unit='M'>32</size>
   <msi vectors='32' ioeventfd='on'/>
 </shmem>

- For ivshmem device not using an ivshmem server:

 <shmem name='shmem1'>
   <size unit='M'>32</size>
 </shmem>

Most of the configuration is made optional so it also allows
specifications like:

 <shmem name='shmem1/>
 <shmem name='shmem2'>
   <server/>
 </shmem>

Signed-off-by: Maxime Leroy <maxime.leroy@6wind.com>
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2014-10-03 22:43:08 +02:00
Cole Robinson
445a09bdc9 qemu: Don't compare CPU against host for TCG
Right now when building the qemu command line, we try to do various
unconditional validations of the guest CPU against the host CPU. However
this checks are overly applied. The only time we should use the checks
are:

- The user requests host-model/host-passthrough, or

- When KVM is requsted. CPU features requested in TCG mode are always
  emulated by qemu and are independent of the host CPU, so no host CPU
  checks should be performed.

Right now if trying to specify a CPU for arm on an x86 host, it attempts
to do non-sensical validation and falls over.

Switch all the test cases that were intending to test CPU validation to
use KVM, so they continue to test the intended code.

Amend some aarch64 XML tests with a CPU model, to ensure things work
correctly.
2014-10-03 11:30:29 -04:00
Jincheng Miao
e029088802 conf: report error in virCPUDefParseXML
When detected invalid 'memAccess', virCPUDefParseXML should report error.

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

Signed-off-by: Jincheng Miao <jmiao@redhat.com>
2014-09-26 16:03:14 +02:00
Daniel P. Berrange
308c0c5a95 Convert polkit code to use DBus API instead of CLI helper
Spawning the pkcheck program every time a permission check is
required is hugely expensive on CPU. The pkcheck program is just
a dumb wrapper for the DBus API, so rewrite the code to use the
DBus API directly. This also simplifies error handling a bit.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2014-09-24 15:29:22 +01:00
Daniel P. Berrange
88a2dc1f4c Support passing dict by reference for dbus messages
Currently DBus dict values must be passed inline

   virDBusMessageEncode("a{ss}",
                        3,
                        "key1", "val1",
                        "key2", "val2",
                        "key3", "val3");
   virDBusMessageDecode("a{ss}",
                        3,
                        &key1, &val1,
                        &key2, &val2,
                        &key3, &val3);

This allows them to be passed by reference

   const char **dictin = {
      "key1", "val1",
      "key2", "val2",
      "key3", "val3"
   };
   char **dictout;
   size_t ndictout;

   virDBusMessageEncode("a&{ss}",
                        ARRAY_CARDINALITY(dict) / 2,
                        dictin);
   virDBusMessageDecode("a&{ss}",
                        &ndictout,
                        &dictout);

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2014-09-24 15:29:22 +01:00
Ján Tomko
2d79e1752a qemu: wire up virtio-net segment offloading options
Format the segment offloading options specified by
<driver>
  <host .../>
  <guest .../>
</driver>
on virtio-net command line.
2014-09-24 16:16:45 +02:00
Ján Tomko
5b3536ae90 conf: add options for disabling segment offloading
Add options for tuning segment offloading:
<driver>
  <host csum='off' gso='off' tso4='off' tso6='off'
        ecn='off' ufo='off'/>
  <guest csum='off' tso4='off' tso6='off' ecn='off' ufo='off'/>
</driver>
which control the respective host_ and guest_ properties
of the virtio-net device.
2014-09-24 16:16:45 +02:00
Peter Krempa
b8549877a1 util: storage: Allow metadata crawler to report useful errors
Add a new parameter to virStorageFileGetMetadata that will break the
backing chain detection process and report useful error message rather
than having to use virStorageFileChainGetBroken.

This patch just introduces the option, usage will be provided
separately.
2014-09-24 09:28:29 +02:00
Jiri Denemark
b3fd95e368 qemu: Add RDMA migration capabilities 2014-09-23 08:11:49 +02:00
John Ferlan
58abf1bb36 hostdev: Add "rawio" attribute to _virDomainHostdevSubsysSCSI
Add the 'rawio' attribute to match _virDomainDiskDef and process the
hostdev XML similarly to the disk XML for a lun which supports/requires rawio
2014-09-19 07:47:46 -04:00
Pavel Hrdina
da7799d879 Move the FIPS detection from capabilities
We are not detecting the presence of FIPS from QEMU, but from procfs and
that means it's not QEMU capability. It was decided that we will pass
this flag to QEMU even if it's not supported by old QEMU binaries.

This patch also reverts changes done by commit a21cfb0f to
qemucapabilitestest and implements a new test case in qemuxml2argvtest.

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

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2014-09-19 09:08:23 +02:00
Roman Bogorodskiy
b4af40226d storage: zfs: implement pool build and delete
- Provide an implementation for buildPool and deletePool operations
   for the ZFS storage backend.
 - Add VIR_STORAGE_POOL_SOURCE_DEVICE flag to ZFS pool poolOptions
   as now we can specify devices to build pool from
 - storagepool.rng: add an optional 'sourceinfodev' to 'sourcezfs' and
   add an optional 'target' to 'poolzfs' entity
 - Add a couple of tests to storagepoolxml2xmltest
2014-09-18 18:08:29 +04:00
Roman Bogorodskiy
3b3947ea37 Fix build in qemu_capabilities
Commit f05b6a91 added virQEMUDriverConfigPtr argument to the
virQEMUCapsFillDomainCaps function and it uses forward declaration
of virQEMUDriverConfig and virQEMUDriverConfigPtr that casues clang
build to fail:

gmake[3]: Entering directory `/usr/home/novel/code/libvirt/src'
  CC       qemu/libvirt_driver_qemu_impl_la-qemu_capabilities.lo
In file included from qemu/qemu_capabilities.c:43:
In file included from qemu/qemu_hostdev.h:27:
qemu/qemu_conf.h:63:37: error: redefinition of typedef 'virQEMUDriverConfig'
is a C11 feature [-Werror,-Wtypedef-redefinition]
typedef struct _virQEMUDriverConfig virQEMUDriverConfig;
                                    ^
qemu/qemu_capabilities.h:328:37: note: previous definition is here
typedef struct _virQEMUDriverConfig virQEMUDriverConfig;
                                    ^

Fix that by passing loader and nloader config attributes directly
instead of passing complete config.
2014-09-18 13:37:12 +04:00
Roman Bogorodskiy
d0d344cfdb bhyve: tests: fix build
Commit b20d39a introduced a new argument for the
virNetDevTapCreateInBridgePort function, however, its mock
in bhyve tests wasn't updated, so the build failed.

Fix build by adding this new argument to the mock version.
2014-09-18 13:37:12 +04:00
Michal Privoznik
281f70013e qemu: Honor hugepages for UMA domains
https://bugzilla.redhat.com/show_bug.cgi?id=1135396

There are two ways how to tell qemu to use huge pages. The first one
is suitable for domains with NUMA nodes: the path to hugetlbfs mount
is appended to NUMA node definition on the command line. The second
one is suitable for UMA domains: here there's this global '-mem-path'
argument that accepts path to the hugetlbfs mount point. However, the
latter case was not used for all the cases that it should be. For
instance:

  <memoryBacking>
    <hugepages>
      <page size='2048' unit='KiB' nodeset='0'/>
    </hugepages>
  </memoryBacking>

didn't trigger the '-mem-path' so the huge pages - despite being
configured - were not used at all.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2014-09-17 18:33:33 +02:00
Michal Privoznik
ec982f6d92 conf: Disallow nonexistent NUMA nodes for hugepages
As of 136ad4974 it is possible to specify different huge pages per
guest NUMA node. However, there's no check if nodeset specified in
./hugepages/page contains only those guest NUMA nodes that exist.
In other words with current code it is possible to define meaningless
combination:

  <memoryBacking>
    <hugepages>
      <page size='1048576' unit='KiB' nodeset='0,2-3'/>
      <page size='2048' unit='KiB' nodeset='1,4'/>
    </hugepages>
  </memoryBacking>
  <vcpu placement='static'>4</vcpu>
  <cpu>
    <numa>
      <cell id='0' cpus='0' memory='1048576'/>
      <cell id='1' cpus='1' memory='1048576'/>
      <cell id='2' cpus='2' memory='1048576'/>
      <cell id='3' cpus='3' memory='1048576'/>
    </numa>
  </cpu>

Notice the node 4 in <hugepages/>?

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2014-09-17 18:33:33 +02:00
Michal Privoznik
b3f42da6b7 domaincapstest: Run cleanly on systems missing OVMF firmware
As of f05b6a918e the test produces the list of paths that can
be passed to <loader/> and libvirt knows about them. However,
during the process of generating the list the paths are checked
for their presence. This may produce different results on
different systems.  Therefore, the path - if missing - is
added to pretend it's there.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2014-09-17 17:42:47 +02:00
Michal Privoznik
f05b6a918e domaincaps: Expose UEFI binary path, if it exists
Check to see if the UEFI binary mentioned in qemu.conf actually
exists, and if so expose it in domcapabilities like

<loader ...>
  <value>/path/to/ovmf</value>
</loader>

We introduce some generic domcaps infrastructure for handling
a dynamic list of string values, it may be of use for future bits.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2014-09-17 16:29:49 +02:00
Michal Privoznik
2b2e4a7acf qemu_capabilities: Change virQEMUCapsFillDomainCaps signature
Up till now the virQEMUCapsFillDomainCaps() was type of void as
there was no way for it to fail. This is, however, going to
change in the next commit.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2014-09-17 16:27:06 +02:00
Martin Kletzander
c7abf2c856 qemu: add support for shared memory mapping
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2014-09-17 16:10:26 +02:00
Martin Kletzander
def6b35989 docs, conf, schema: add support for shared memory mapping
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2014-09-17 16:10:26 +02:00
Michal Privoznik
4f76621c0e domaincaps: Expose UEFI capability
As of 542899168c we learned libvirt to use UEFI for domains.
However, management applications may firstly query if libvirt
supports it. And this is where virConnectGetDomainCapabilities()
API comes handy.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2014-09-17 09:42:33 +02:00
Ján Tomko
af8b4a2e6f conf: add backend element to interfaces
For tuning the network, alternative devices
for creating tap and vhost devices can be specified via:
<backend tap='/dev/net/tun' vhost='/dev/net-vhost'/>
2014-09-16 15:38:34 +02:00
Erik Skultety
e6fc664618 network: check negative values in bridge queues
We already are checking for negative value, reporting an error, but
using wrong function and the check only succeeds when a value that
cannot be converted to number successfully is encountered. This patch
provides just a minor change in call of the right version
of function virStrToLong.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1138539
2014-09-16 10:34:37 +02:00
Eric Blake
7e8feed4a7 cputune: allow interleaved xml
I noticed this with the recent iothread pinning code, but the
problem existed longer than that. The XML validation required
users to supply <cputune> children in a strict order, even though
there was no conceptual reason why they can't occur in any order.

docs/ changes best viewed with -w

* docs/schemas/domaincommon.rng (cputune): Add interleave.
* tests/qemuxml2argvdata/qemuxml2argv-cputune-iothreads.xml: Swap
up order, copying canonical form...
* tests/qemuxml2xmloutdata/qemuxml2xmlout-cputune-iothreads.xml:
...here.
* tests/qemuxml2xmltest.c (mymain): Mark the difference.

Signed-off-by: Eric Blake <eblake@redhat.com>
2014-09-15 18:59:40 -06:00
John Ferlan
938fb12fad domain_conf: Add iothreadpin to cputune
https://bugzilla.redhat.com/show_bug.cgi?id=1101574

Add an option 'iothreadpin' to the <cpuset> to allow for setting the
CPU affinity for each IOThread.

The iothreadspin will mimic the vcpupin with respect to being able to
assign each iothread to a specific CPU, although iothreads ids start
at 1 while vcpu ids start at 0. This matches the iothread naming scheme.
2014-09-15 13:19:01 -04:00
John Ferlan
4cf6bfab4c qemu: Issue query-iothreads and to get list of active IOThreads
Generate infrastructure and test to handle fetching the QMP
IOThreads data.
2014-09-15 13:18:56 -04:00
John Ferlan
07334ccbac Resolve Coverity CHECKED_RETURN
Coverity complained that checking the return of virDomainCreate()
was not consistent amongst the callers - so added the return check
to the objecteventtest.c and adjust the virt-login-shell to compare
< 0 rather than just non zero for the failure condition.
2014-09-15 10:44:27 -04:00
Eric Blake
eef91f9470 blockcopy: add qemu implementation of new tunables
Upstream qemu 1.4 added some drive-mirror tunables not present
when it was first introduced in 1.3.  Management apps may want
to set these in some cases (for example, without tuning
granularity down to sector size, a copy may end up occupying
more bytes than the original because an entire cluster is
copied even when only a sector within the cluster is dirty,
although tuning it down results in more CPU time to do the
copy).  I haven't personally needed to use the parameters, but
since they exist, and since the new API supports virTypedParams,
we might as well expose them.

Since the tuning parameters aren't often used, and omitted from
the QMP command when unspecified, I think it is safe to rely on
qemu 1.3 to issue an error about them being unsupported, rather
than trying to create a new capability bit in libvirt.

Meanwhile, all versions of qemu from 1.4 to 2.1 have a bug where
a bad granularity (such as non-power-of-2) gives a poor message:
error: internal error: unable to execute QEMU command 'drive-mirror': Invalid parameter 'drive-virtio-disk0'

because of abuse of QERR_INVALID_PARAMETER (which is supposed to
name the parameter that was given a bad value, rather than the
value passed to some other parameter).  I don't see that a
capability check will help, so we'll just live with it (and it
has since been improved in upstream qemu).

* src/qemu/qemu_monitor.h (qemuMonitorDriveMirror): Add
parameters.
* src/qemu/qemu_monitor.c (qemuMonitorDriveMirror): Likewise.
* src/qemu/qemu_monitor_json.h (qemuMonitorJSONDriveMirror):
Likewise.
* src/qemu/qemu_monitor_json.c (qemuMonitorJSONDriveMirror):
Likewise.
* src/qemu/qemu_driver.c (qemuDomainBlockCopyCommon): Likewise.
(qemuDomainBlockRebase, qemuDomainBlockCopy): Adjust callers.
* src/qemu/qemu_migration.c (qemuMigrationDriveMirror): Likewise.
* tests/qemumonitorjsontest.c (qemuMonitorJSONDriveMirror): Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
2014-09-12 08:11:11 -06:00
Daniel P. Berrange
47ffd5e8fd tests: Add more test suite mock helpers
Rename the VIR_MOCK_IMPL* macros to VIR_MOCK_WRAP*
and add new VIR_MOCK_IMPL macros which let you directly
implement overrides in the preloaded source.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
2014-09-11 15:40:50 -06:00
Daniel P. Berrange
973173e6bf util: Allow port allocator to skip bind() check
Test suites using the port allocator don't want to have different
behaviour depending on whether a port is in use on the host. Add
a VIR_PORT_ALLOCATOR_SKIP_BIND_CHECK which test suites can use
to skip the bind() test. The port allocator will thus only track
ports in use by the test suite process itself. This is fine when
using the port allocator to generate guest configs which won't
actually be launched

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
2014-09-11 15:40:14 -06:00
John Ferlan
a893b20eed tests: Resolve Coverity DEADCODE
Coverity complains that the various checks for autoincrement and changed
variables are DEADCODE - seems to me to be a false positive - so mark it.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2014-09-11 08:10:13 -04:00
Michal Privoznik
742b08e30f qemu: Automatically create NVRAM store
When using split UEFI image, it may come handy if libvirt manages per
domain _VARS file automatically. While the _CODE file is RO and can be
shared among multiple domains, you certainly don't want to do that on
the _VARS file. This latter one needs to be per domain. So at the
domain startup process, if it's determined that domain needs _VARS
file it's copied from this master _VARS file. The location of the
master file is configurable in qemu.conf.

Temporary, on per domain basis the location of master NVRAM file can
be overridden by this @template attribute I'm inventing to the
<nvram/> element. All it does is holding path to the master NVRAM file
from which local copy is created. If that's the case, the map in
qemu.conf is not consulted.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Acked-by: Laszlo Ersek <lersek@redhat.com>
2014-09-10 09:38:07 +02:00
Michal Privoznik
542899168c qemu: Implement extended loader and nvram
QEMU now supports UEFI with the following command line:

  -drive file=/usr/share/OVMF/OVMF_CODE.fd,if=pflash,format=raw,unit=0,readonly=on \
  -drive file=/usr/share/OVMF/OVMF_VARS.fd,if=pflash,format=raw,unit=1 \

where the first line reflects <loader> and the second one <nvram>.
Moreover, these two lines obsolete the -bios argument.

Note that UEFI is unusable without ACPI. This is handled properly now.
Among with this extension, the variable file is expected to be
writable and hence we need security drivers to label it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Acked-by: Laszlo Ersek <lersek@redhat.com>
2014-09-10 09:38:07 +02:00
Michal Privoznik
68bf13dbef conf: Extend <loader/> and introduce <nvram/>
Up to now, users can configure BIOS via the <loader/> element. With
the upcoming implementation of UEFI this is not enough as BIOS and
UEFI are conceptually different. For instance, while BIOS is ROM, UEFI
is programmable flash (although all writes to code section are
denied). Therefore we need new attribute @type which will
differentiate the two. Then, new attribute @readonly is introduced to
reflect the fact that some images are RO.

Moreover, the OVMF (which is going to be used mostly), works in two
modes:
1) Code and UEFI variable store is mixed in one file.
2) Code and UEFI variable store is separated in two files

The latter has advantage of updating the UEFI code without losing the
configuration. However, in order to represent the latter case we need
yet another XML element: <nvram/>. Currently, it has no additional
attributes, it's just a bare element containing path to the variable
store file.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Acked-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2014-09-10 09:38:07 +02:00
Eric Blake
b7e73585a8 blockcopy: allow block device destination
To date, anyone performing a block copy and pivot ends up with
the destination being treated as <disk type='file'>.  While this
works for data access for a block device, it has at least one
noticeable shortcoming: virDomainGetBlockInfo() reports allocation
differently for block devices visited as files (the size of the
device) than for block devices visited as <disk type='block'>
(the maximum sector used, as reported by qemu); and this difference
is significant when trying to manage qcow2 format on block devices
that can be grown as needed.

Of course, the more powerful virDomainBlockCopy() API can already
express the ability to set the <disk> type.  But a new API can't
be backported, while a new flag to an existing API can; and it is
also rather inconvenient to have to resort to the full power of
generating XML when just adding a flag to the older call will do
the trick.  So this patch enhances blockcopy to let the user flag
when the resulting XML after the copy must list the device as
type='block'.

* include/libvirt/libvirt.h.in (VIR_DOMAIN_BLOCK_REBASE_COPY_DEV):
New flag.
* src/libvirt.c (virDomainBlockRebase): Document it.
* tools/virsh-domain.c (opts_block_copy, blockJobImpl): Add
--blockdev option.
* tools/virsh.pod (blockcopy): Document it.
* src/qemu/qemu_driver.c (qemuDomainBlockRebase): Allow new flag.
(qemuDomainBlockCopy): Remember the flag, and make sure it is only
used on actual block devices.
* tests/qemuxml2argvdata/qemuxml2argv-disk-mirror.xml: Test it.

Signed-off-by: Eric Blake <eblake@redhat.com>
2014-09-05 13:13:50 -06:00
Ján Tomko
de0aeafe9c Don't include non-migratable features in host-model
Commit fba6bc4 introduced support for the 'invtsc' feature,
which blocks migration. We should not include it in the
host-model CPU by default, because it's intended to be used
with migration.

https://bugzilla.redhat.com/show_bug.cgi?id=1138221
2014-09-05 12:45:19 +02:00
Michal Privoznik
36cc189a46 tests: Add test cases for previous commit
This commit is rather big. Firstly, the in memory config
representation is adjusted like if security_driver was set to "none".
The rest is then just adaptation to the new code that will generate
different seclabels.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2014-09-05 08:35:34 +02:00
Eric Blake
625e04a86e maint: use hanging curly braces
Our style overwhelmingly uses hanging braces (the open brace
hangs at the end of the compound condition, rather than on
its own line), with the primary exception of the top level function
body.  Fix the few remaining outliers, before adding a syntax
check in a later patch.

* src/interface/interface_backend_netcf.c (netcfStateReload)
(netcfInterfaceClose, netcf_to_vir_err): Correct use of { in
compound statement.
* src/conf/domain_conf.c (virDomainHostdevDefFormatSubsys)
(virDomainHostdevDefFormatCaps): Likewise.
* src/network/bridge_driver.c (networkAllocateActualDevice):
Likewise.
* src/util/virfile.c (virBuildPathInternal): Likewise.
* src/util/virnetdev.c (virNetDevGetVirtualFunctions): Likewise.
* src/util/virnetdevmacvlan.c
(virNetDevMacVLanVPortProfileCallback): Likewise.
* src/util/virtypedparam.c (virTypedParameterAssign): Likewise.
* src/util/virutil.c (virGetWin32DirectoryRoot)
(virFileWaitForDevices): Likewise.
* src/vbox/vbox_common.c (vboxDumpNetwork): Likewise.
* tests/seclabeltest.c (main): Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
2014-09-04 15:18:43 -06:00