]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/log
people/liuw/libxenctrl-split/libvirt.git
12 years agoqemu: don't always reserve PCI addresses for implicit controllers
Ján Tomko [Fri, 26 Apr 2013 15:50:36 +0000 (17:50 +0200)]
qemu: don't always reserve PCI addresses for implicit controllers

In the past we automatically added a USB controller and assigned
it a PCI address (0:0:1.2) even on machines without a PCI bus.
This didn't break machines with no PCI bus  because the command
line for it is just '-usb', with no mention of the PCI bus.

The implicit IDE controller (reserved address 0:0:1.1) has
no command line at all.

Commit b33eb0dc removed the ability to reserve PCI addresses
on machines without a PCI bus. This made them stop working,
since there would always be the implicit USB controller.

Skip the reservation of addresses for these controllers when
there is no PCI bus, instead of failing.

12 years agoconf: remove extraneous _TYPE from driver backend enums
Laine Stump [Fri, 26 Apr 2013 20:44:05 +0000 (16:44 -0400)]
conf: remove extraneous _TYPE from driver backend enums

This isn't strictly speaking a bugfix, but I realized I'd gotten a bit
too verbose when I chose the names for
VIR_DOMAIN_HOSTDEV_PCI_BACKEND_TYPE_*. This shortens them all a bit.

12 years agonetwork: support <driver name='vfio'/> in network definitions
Laine Stump [Fri, 26 Apr 2013 20:23:27 +0000 (16:23 -0400)]
network: support <driver name='vfio'/> in network definitions

I remembered to document this bit, but somehow forgot to implement it.

This adds <driver name='kvm|vfio'/> as a subelement to the <forward>
element of a network (this puts it parallel to the match between
mode='hostdev' attribute in a network and type='hostdev' in an
<interface>).

Since it's already documented, only the parser, formatter, backend
driver recognition (it just translates/moves the flag into the
<interface> at the appropriate time), and a test case were needed.

(I used a separate enum for the values both because the original is
defined in domain_conf.h, which is unavailable from network_conf.h,
and because in the future it's possible that we may want to support
other non-hostdev oriented driver names in the network parser; this
makes sure that one can be expanded without the other).

12 years agoqemu: launch bridge helper from libvirtd
Paolo Bonzini [Sat, 20 Apr 2013 09:11:25 +0000 (11:11 +0200)]
qemu: launch bridge helper from libvirtd

<source type='bridge'> uses a helper application to do the necessary
TUN/TAP setup to use an existing network bridge, thus letting
unprivileged users use TUN/TAP interfaces.

However, libvirt should be preventing QEMU from running any setuid
programs at all, which would include this helper program.  From
a security POV, any setuid helper needs to be run by libvirtd itself,
not QEMU.

This is what this patch does.  libvirt now invokes the setuid helper,
gets the TAP fd and then passes it to QEMU in the normal manner.
The path to the helper is specified in qemu.conf.

As a small advantage, this adds a <target dev='tap0'/> element to the
XML of an active domain using <interface type='bridge'>.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agovirnetdevtap: add virNetDevTapGetName
Paolo Bonzini [Sat, 20 Apr 2013 09:11:24 +0000 (11:11 +0200)]
virnetdevtap: add virNetDevTapGetName

This will be used on a tap file descriptor returned by the bridge helper
to populate the <target> element, because the helper does not provide
the interface name.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agoqemu: don't assign a PCI address to 'none' USB controller
Ján Tomko [Fri, 26 Apr 2013 17:52:43 +0000 (19:52 +0200)]
qemu: don't assign a PCI address to 'none' USB controller

Adjust the usb-none test, since it gives the memballoon a lower PCI slot now.
Add a test for 'none' controller on s390, which doesn't have PCI buses.

12 years agofix segfault during virsh save in pv guest
Bamvor Jian Zhang [Fri, 26 Apr 2013 14:53:42 +0000 (22:53 +0800)]
fix segfault during virsh save in pv guest

this patch fix the wrong sequence for fd and timeout register. the sequence
was right in dfa1e1dd for fd register, but it changed in e0622ca2.
in this patch, set priv, xl_priv in info and increase info->priv ref count
before virEventAddHandle. if do this after virEventAddHandle, the fd
callback or fd deregister maybe got the empty priv, xl_priv or wrong ref
count.

after apply this patch, test more than 100 rounds passed compare to fail
within 3 rounds without this patch. each round includes define -> start ->
destroy -> create -> suspend -> resume -> reboot -> shutdown -> save ->
resotre -> dump -> destroy -> create -> setmem -> setvcpus -> destroy.

Signed-off-by: Bamvor Jian Zhang <bjzhang@suse.com>
12 years agoqemu: set qemu process' RLIMIT_MEMLOCK when VFIO is used
Laine Stump [Thu, 25 Apr 2013 16:45:55 +0000 (12:45 -0400)]
qemu: set qemu process' RLIMIT_MEMLOCK when VFIO is used

VFIO requires all of the guest's memory and IO space to be lockable in
RAM. The domain's max_balloon is the maximum amount of memory the
domain can have (in KiB). We add a generous 1GiB to that for IO space
(still much better than KVM device assignment, where the KVM module
actually *ignores* the process limits and locks everything anyway),
and convert from KiB to bytes.

In the case of hotplug, we are changing the limit for the already
existing qemu process (prlimit() is used under the hood), and for
regular commandline additions of vfio devices, we schedule a call to
setrlimit() that will happen after the qemu process is forked.

12 years agoqemu: use new virCommandSetMax(Processes|Files)
Laine Stump [Thu, 25 Apr 2013 16:16:25 +0000 (12:16 -0400)]
qemu: use new virCommandSetMax(Processes|Files)

These were previously being set in a custom hook function, but now
that virCommand directly supports setting them, we can eliminate that
part of the hook and call the APIs directly.

12 years agoutil: new virCommandSetMax(MemLock|Processes|Files)
Laine Stump [Thu, 25 Apr 2013 16:10:10 +0000 (12:10 -0400)]
util: new virCommandSetMax(MemLock|Processes|Files)

This patch adds two sets of functions:

1) lower level virProcessSet*() functions that will immediately set
the RLIMIT_MEMLOCK. RLIMIT_NPROC, or RLIMIT_NOFILE of either the
current process (using setrlimit()) or any other process (using
prlimit()). "current process" is indicated by passing a 0 for pid.

2) functions for virCommand* that will setup a virCommand object to
set those limits at a later time just after it has forked a new
process, but before it execs the new program.

configure.ac has prlimit and setrlimit added to the list of functions
to check for, and the low level functions log an "unsupported" error)
on platforms that don't support those functions.

12 years agoDo proper escaping of cgroup resource partitions
Daniel P. Berrange [Fri, 26 Apr 2013 09:50:24 +0000 (10:50 +0100)]
Do proper escaping of cgroup resource partitions

If a user cgroup name begins with "cgroup.", "_" or with any of
the controllers from /proc/cgroups followed by a dot, then they
need to be prefixed with a single underscore. eg if there is
an object "cpu.service", then this would end up as "_cpu.service"
in the cgroup filesystem tree, however, "waldo.service" would
stay "waldo.service", at least as long as nobody comes up with
a cgroup controller called "waldo".

Since we require a '.XXXX' suffix on all partitions, there is
no scope for clashing with the kernel 'tasks' and 'release_agent'
files.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoEnsure all cgroup partitions have a suffix of ".partition"
Daniel P. Berrange [Fri, 26 Apr 2013 09:23:51 +0000 (10:23 +0100)]
Ensure all cgroup partitions have a suffix of ".partition"

If the partition named passed in the XML does not already have
a suffix, ensure it gets a '.partition' added to each component.
The exceptions are /machine, /user and /system which do not need
to have a suffix, since they are fixed partitions at the top
level.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoChange VM cgroup suffix from '{lxc,qemu}.libvirt' to 'libvirt-{lxc,qemu}'
Daniel P. Berrange [Fri, 26 Apr 2013 08:52:47 +0000 (09:52 +0100)]
Change VM cgroup suffix from '{lxc,qemu}.libvirt' to 'libvirt-{lxc,qemu}'

Recently we changed to create VM cgroups with the naming pattern
$VMNAME.$DRIVER.libvirt. Following discussions with the systemd
community it was decided that only having a single '.' in the
names is preferrable. So this changes the naming scheme to be
$VMNAME.libvirt-$DRIVER. eg for LXC 'mycontainer.libvirt-lxc' or
for KVM 'myvm.libvirt-qemu'.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agotest: Add JSON test for query-tpm-types
Stefan Berger [Fri, 26 Apr 2013 11:13:05 +0000 (07:13 -0400)]
test: Add JSON test for query-tpm-types

Add a test case for query-tpm-models QMP command.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
12 years agovirsh: suppress aliases in group help
Eric Blake [Fri, 26 Apr 2013 10:20:29 +0000 (04:20 -0600)]
virsh: suppress aliases in group help

'virsh help | grep nodedev-det' shows only nodedev-detach, but
'virsh help nodedev | grep nodedev-det' also shows the old alias
nodedev-dettach that we intentionally hid in commit af3f9aab.

See also commit 787f4fe and this bug report:
https://bugzilla.redhat.com/show_bug.cgi?id=956966

* tools/virsh.c (vshCmdGrpHelp): Copy suppression of vshCmdHelp.

Signed-off-by: Eric Blake <eblake@redhat.com>
12 years agosecurity: update hostdev labelling functions for VFIO
Laine Stump [Thu, 25 Apr 2013 10:37:21 +0000 (06:37 -0400)]
security: update hostdev labelling functions for VFIO

Legacy kvm style pci device assignment requires changes to the
labelling of several sysfs files for each device, but for vfio device
assignment, the only thing that needs to be relabelled/chowned is the
"group" device for the group that contains the device to be assigned.

12 years agoutil: new function virPCIDeviceGetVFIOGroupDev
Laine Stump [Thu, 25 Apr 2013 10:34:43 +0000 (06:34 -0400)]
util: new function virPCIDeviceGetVFIOGroupDev

Given a virPCIDevice, this function returns the path for the device
that controls the vfio group the device belongs to,
e.g. "/dev/vfio/15".

12 years agovirsh: use new virNodeDeviceDetachFlags
Laine Stump [Wed, 24 Apr 2013 18:22:36 +0000 (14:22 -0400)]
virsh: use new virNodeDeviceDetachFlags

The virsh nodedev-detach command has a new --driver option. If it's
given virsh will attempt to use the new virNodeDeviceDetachFlags API
instead of virNodeDeviceDettach. Validation of the driver name string
is left to the hypervisor (qemu accepts "kvm" or "vfio". The only
other hypervisor that implements these functions is xen, and it only
accepts NULL).

12 years agoxen: implement virNodeDeviceDetachFlags backend
Laine Stump [Wed, 24 Apr 2013 18:06:42 +0000 (14:06 -0400)]
xen: implement virNodeDeviceDetachFlags backend

This was the only hypervisor driver other than qemu that implemented
virNodeDeviceDettach. It doesn't currently support multiple pci device
assignment driver backends, but it is simple to plug in this new API,
which will make it easier for Xen people to fill it in later when they
decide to support VFIO (or whatever other) device assignment. Also it
means that management applications will have the same API available to
them for both hypervisors on any given version of libvirt.

The only acceptable value for driverName in this case is NULL, since
there is no alternate, and I'm not willing to pick a name for the
default driver used by Xen.

12 years agoqemu: implement virNodeDeviceDetachFlags backend
Laine Stump [Wed, 24 Apr 2013 18:03:39 +0000 (14:03 -0400)]
qemu: implement virNodeDeviceDetachFlags backend

The differences from virNodeDeviceDettach are very minor:

1) Check that the flags are 0.

2) Set the virPCIDevice's stubDriver according to the driverName that
   is passed in.

3) Call virPCIDeviceDetach with a NULL stubDriver, indicating it
   should get the name of the stub driver from the virPCIDevice
   object.

12 years agohypervisor api: implement RPC calls for virNodeDeviceDetachFlags
Laine Stump [Wed, 24 Apr 2013 17:42:04 +0000 (13:42 -0400)]
hypervisor api: implement RPC calls for virNodeDeviceDetachFlags

This requires a custom function for remoteNodeDeviceDetachFlags,
because it is named *NodeDevice, but it goes through the hypervisor
driver rather than nodedevice driver, and so it uses privateData
instead of nodeDevicePrivateData. (It has to go through the hypervisor
driver, because that is the driver that knows about the backend drivers
that will perform the pci device assignment).

12 years agohypervisor api: new virNodeDeviceDetachFlags
Laine Stump [Wed, 24 Apr 2013 16:56:10 +0000 (12:56 -0400)]
hypervisor api: new virNodeDeviceDetachFlags

The existing virNodeDeviceDettach() assumes that there is only a
single PCI device assignment backend driver appropriate for any
hypervisor. This is no longer true, as the qemu driver is getting
support for PCI device assignment via VFIO. The new API
virNodeDeviceDetachFlags adds a driverName arg that should be set to
the exact same string set in a domain <hostdev>'s <driver name='x'/>
element (i.e. "vfio", "kvm", or NULL for default). It also adds a
flags arg for good measure (and because it's possible we may need it
when we start dealing with VFIO's "device groups").

12 years agoqemu: bind/unbind stub driver according to config <driver name='x'/>
Laine Stump [Tue, 23 Apr 2013 18:53:36 +0000 (14:53 -0400)]
qemu: bind/unbind stub driver according to config <driver name='x'/>

If the config for a device has specified <driver name='vfio'/>,
"backend" in the pci part of the hostdev object will be set to
..._VFIO. In this case, when creating a virPCIDevice set the
stubDriver to "vfio-pci", otherwise set it to "pci-stub". We will rely
on the lower levels to report an error if the vfio driver isn't
loaded.

The detach/attach functions in virpci.c will pay attention to the
stubDriver setting in the device, and bind/unbind the appropriate
driver when preparing hostdevs for the domain.

Note that we don't yet attempt to do anything to mark active any other
devices in the same vfio "group" as a single device that is being
marked active. We do need to do that, but in order to get basic VFIO
functionality testing sooner rather than later, initially we'll just
live with more cryptic errors when someone tries to do that.

12 years agopci: keep a stubDriver in each virPCIDevice
Laine Stump [Tue, 23 Apr 2013 18:50:15 +0000 (14:50 -0400)]
pci: keep a stubDriver in each virPCIDevice

This can be set when the virPCIDevice is created and placed on a list,
then used later when traversing the list to determine which stub
driver to bind/unbind for managed devices.

The existing Detach and Attach functions' signatures haven't been
changed (they still accept a stub driver name in the arg list), but if
the arg list has NULL for stub driver and one is available in the
device's object, that will be used. (we may later deprecate and remove
the arg from those functions).

12 years agoqemu: use vfio-pci on commandline when appropriate
Laine Stump [Thu, 25 Apr 2013 11:58:37 +0000 (07:58 -0400)]
qemu: use vfio-pci on commandline when appropriate

The device option for vfio-pci is nearly identical to that for
pci-assign - only the configfd parameter isn't supported (or needed).

Checking for presence of the bootindex parameter is done separately
from constructing the commandline, similar to how it is done for
pci-assign.

This patch contains tests to check for proper commandline
construction. It also includes tests for parser-formatter-parser
roundtrips (xml2xml), because those tests use the same data files, and
would have failed had they been included before now.

qemu: xml/args tests for VFIO hostdev and <interface type='hostdev'/>

These should be squashed in with the patch that adds commandline
handling of vfio (they would fail at any earlier time).

12 years agoconf: formatter/parser/RNG/docs for hostdev <driver name='kvm|vfio'/>
Laine Stump [Fri, 15 Mar 2013 19:15:14 +0000 (15:15 -0400)]
conf: formatter/parser/RNG/docs for hostdev <driver name='kvm|vfio'/>

A domain's <interface> or <hostdev>, as well as a <network>'s
<forward>, can now have an optional <driver name='kvm|vfio'/>
element. As of this patch, there is no functionality behind this new
knob - this patch adds support to the domain and network
formatter/parser, and to the RNG and documentation.

When the backend is added, legacy KVM PCI device assignment will
continue to be used when no driver name is specified (or if <driver
name='kvm'/> is specified), but if driver name is 'vfio', the new UEFI
Secure Boot compatible VFIO device assignment will be used.

Note that the parser doesn't automatically insert the current default
value of this setting. This is done on purpose because the two
possibilities are functionally equivalent from the guest's point of
view, and we want to be able to automatically start using vfio as the
default (even for existing domains) at some time in the future. This
is similar to what was done with the "vhost" driver option in
<interface>.

12 years agoconf: put hostdev pci address in a struct
Laine Stump [Mon, 18 Mar 2013 19:56:12 +0000 (15:56 -0400)]
conf: put hostdev pci address in a struct

There will soon be other items related to pci hostdevs that need to be
in the same part of the hostdevsubsys union as the pci address (which
is currently a single member called "pci". This patch replaces the
single member named pci with a struct named pci that contains a single
member named "addr".

12 years agoqemu: detect vfio-pci device and its bootindex parameter
Laine Stump [Wed, 17 Apr 2013 18:16:28 +0000 (14:16 -0400)]
qemu: detect vfio-pci device and its bootindex parameter

QEMU_CAPS_DEVICE_VFIO_PCI is set if the device named "vfio-pci" is
supported in the qemu binary.

QEMU_CAPS_VFIO_PCI_BOOTINDEX is set if the vfio-pci device supports
the "bootindex" parameter;  for some reason, the bootindex parameter
wasn't included in early versions of vfio support (qemu 1.4) so we
have to check for it separately from vfio itself.

12 years agobuild: avoid unsafe functions in libgen.h
Eric Blake [Thu, 25 Apr 2013 20:24:42 +0000 (14:24 -0600)]
build: avoid unsafe functions in libgen.h

POSIX says that both basename() and dirname() may return static
storage (aka they need not be thread-safe); and that they may but
not must modify their input argument.  Furthermore, <libgen.h>
is not available on all platforms.  For these reasons, you should
never use these functions in a multi-threaded library.

Gnulib instead recommends a way to avoid the portability nightmare:
gnulib's "dirname.h" provides useful thread-safe counterparts.  The
obvious dir_name() and base_name() are GPL (because they malloc(),
but call exit() on failure) so we can't use them; but the LGPL
variants mdir_name() (malloc's or returns NULL) and last_component
(always points into the incoming string without modifying it,
differing from basename semantics only on corner cases like the
empty string that we shouldn't be hitting in the first place) are
already in use in libvirt.  This finishes the swap over to the safe
functions.

* cfg.mk (sc_prohibit_libgen): New rule.
* src/util/vircgroup.c: Fix offenders.
* src/parallels/parallels_storage.c (parallelsPoolAddByDomain):
Likewise.
* src/parallels/parallels_network.c (parallelsGetBridgedNetInfo):
Likewise.
* src/node_device/node_device_udev.c (udevProcessSCSIHost)
(udevProcessSCSIDevice): Likewise.
* src/storage/storage_backend_disk.c
(virStorageBackendDiskDeleteVol): Likewise.
* src/util/virpci.c (virPCIGetDeviceAddressFromSysfsLink):
Likewise.
* src/util/virstoragefile.h (_virStorageFileMetadata): Avoid false
positive.

Signed-off-by: Eric Blake <eblake@redhat.com>
12 years agoFix VIR_DOMAIN_EVENT_ID_PMSUSPEND capitalization in API doc
Christophe Fergeau [Thu, 25 Apr 2013 19:56:08 +0000 (21:56 +0200)]
Fix VIR_DOMAIN_EVENT_ID_PMSUSPEND capitalization in API doc

It was written VIR_DOMAIN_EVENT_ID_PMSuspend

12 years agoImprove /domainsnapshot/disks/disk@snapshot doc
Christophe Fergeau [Thu, 25 Apr 2013 19:40:33 +0000 (21:40 +0200)]
Improve /domainsnapshot/disks/disk@snapshot doc

The previous description was a bit confusing.

12 years agoqemu: fix build error with older platforms
Eric Blake [Thu, 25 Apr 2013 17:22:39 +0000 (11:22 -0600)]
qemu: fix build error with older platforms

Jim Fehlig reported on IRC that older gcc/glibc triggers this warning:

cc1: warnings being treated as errors
qemu/qemu_domain.c: In function 'qemuDomainDefFormatBuf':
qemu/qemu_domain.c:1297: error: declaration of 'remove' shadows a global declaration [-Wshadow]
/usr/include/stdio.h:157: error: shadowed declaration is here [-Wshadow]
make[3]: *** [libvirt_driver_qemu_impl_la-qemu_domain.lo] Error 1

Fix it like we have done in the past (such as commit 2e6322a).

* src/qemu/qemu_domain.c (qemuDomainDefFormatBuf): Avoid shadowing
a function name.

Signed-off-by: Eric Blake <eblake@redhat.com>
12 years agodocs: fix memballoon examples
Ján Tomko [Thu, 25 Apr 2013 16:53:07 +0000 (18:53 +0200)]
docs: fix memballoon examples

Use a pair of 'memballoon' tags instead of single 'watchdog' one.
Add a few missing colons.

12 years agoconf: reject controllers with duplicate indexes
Ján Tomko [Tue, 23 Apr 2013 12:24:32 +0000 (14:24 +0200)]
conf: reject controllers with duplicate indexes

Reject multiple controllers with the same index,
except for USB controllers.
Multi-function USB controllers can have the same index.

12 years agoqemu: auto-add pci-root to 'pc-i440*' machines too
Ján Tomko [Thu, 25 Apr 2013 13:17:12 +0000 (15:17 +0200)]
qemu: auto-add pci-root to 'pc-i440*' machines too

Commit b33eb0d missed this machine type.

12 years agofix typo introduced by 90430791
Bamvor Jian Zhang [Thu, 25 Apr 2013 12:17:43 +0000 (20:17 +0800)]
fix typo introduced by 90430791

Signed-off-by: Bamvor Jian Zhang <bjzhang@suse.com>
12 years agoFix usb master startport parsing
Martin Kletzander [Tue, 23 Apr 2013 14:23:51 +0000 (16:23 +0200)]
Fix usb master startport parsing

When all usb controllers connected to the same bus have <master
startport='x'/> specified, none of them have 'id=usb' assigned and
thus qemu fails due to invalid masterport specification (we use 'usb'
for that purpose).  Adding a check that at least one of the
controllers is specified without <master startport='x'/> and in case
this happens, error out due to invalid configuration.

12 years agoqemu_command.c: Fix whitespacing within for()
Michal Privoznik [Thu, 25 Apr 2013 11:50:31 +0000 (13:50 +0200)]
qemu_command.c: Fix whitespacing within for()

After 9d6e56db the syntax-check was unhappy due to wrong whitespacing:

  src/qemu/qemu_command.c:1637: for ( ; a.slot < QEMU_PCI_ADDRESS_SLOT_LAST; a.slot++) {
  maint.mk: incorrect whitespace around brackets, see HACKING for rules
  make: *** [bracket-spacing-check] Error 1

12 years agoqemu_conf: Don't discard strdup OOM error
Michal Privoznik [Thu, 25 Apr 2013 11:35:10 +0000 (13:35 +0200)]
qemu_conf: Don't discard strdup OOM error

After 78d7c3c5 we are strdup()-ing path to qemu-bridge-helper.
However, the check for its return value is missing. So it is
possible we've ignored the OOM error silently.

12 years agoqemu: auto-add bridges and allow using them
Ján Tomko [Fri, 19 Apr 2013 10:38:53 +0000 (12:38 +0200)]
qemu: auto-add bridges and allow using them

Add a "dry run" address allocation to figure out how many bridges
will be needed for all the devices without explicit addresses.

Auto-add just enough bridges to put all the devices on, or up to the
bridge with the largest specified index.

12 years agoqemu: auto-add pci-root controller for pc machine types
Ján Tomko [Mon, 22 Apr 2013 12:16:13 +0000 (14:16 +0200)]
qemu: auto-add pci-root controller for pc machine types

<controller type='pci' index='0' model='pci-root'/>
is auto-added to pc* machine types.
Without this controller PCI bus 0 is not available and
no PCI addresses are assigned by default.

Since older libvirt supported PCI bus 0 even without
this controller, it is removed from the XML when migrating.

12 years agoqemu: build command line for pci-bridge device
liguang [Thu, 7 Mar 2013 11:03:41 +0000 (12:03 +0100)]
qemu: build command line for pci-bridge device

Signed-off-by: Ján Tomko <jtomko@redhat.com>
12 years agoconf: add PCI controllers
Ján Tomko [Wed, 17 Apr 2013 15:05:15 +0000 (17:05 +0200)]
conf: add PCI controllers

Add new controller type 'pci' with models 'pci-root' and 'pci-bridge'.

12 years agoqemu: call post-parse callbacks when parsing command line too
Ján Tomko [Mon, 22 Apr 2013 11:41:52 +0000 (13:41 +0200)]
qemu: call post-parse callbacks when parsing command line too

Now we set the default disk driver name when parsing
the qemu command line too, hence all the test changes.

Assume format type is 'auto' when none is specified on
qemu command line.

12 years agoqemu: Fix the indention
Osier Yang [Thu, 25 Apr 2013 09:13:33 +0000 (17:13 +0800)]
qemu: Fix the indention

Pushed under trivial rule.

12 years agoqemu: Add command line builder and parser for NVRAM.
Li Zhang [Thu, 25 Apr 2013 08:46:04 +0000 (16:46 +0800)]
qemu: Add command line builder and parser for NVRAM.

This patch is to add command line builder and parser
for NVRAM device, and add test cases.

Signed-off-by: Li Zhang <zhlcindy@linux.vnet.ibm.com>
12 years agoAdd NVRAM device
Li Zhang [Fri, 19 Apr 2013 08:37:51 +0000 (16:37 +0800)]
Add NVRAM device

For pSeries guest in QEMU, NVRAM is one kind of spapr-vio device.
Users are allowed to specify spapr-vio devices'address.
But NVRAM is not supported in libvirt. So this patch is to
add NVRAM device to allow users to specify its address.

In QEMU, NVRAM device's address is specified by
 "-global spapr-nvram.reg=xxxxx".

In libvirt, XML file is defined as the following:

  <nvram>
    <address type='spapr-vio' reg='0x3000'/>
  </nvram>

Signed-off-by: Li Zhang <zhlcindy@linux.vnet.ibm.com>
12 years agoqemuBuildCommandLine: Don't overwrite errors with NWFilter's one
Michal Privoznik [Wed, 24 Apr 2013 12:06:40 +0000 (14:06 +0200)]
qemuBuildCommandLine: Don't overwrite errors with NWFilter's one

Currently, if there has been an error in building command line
process after virtual interfaces has been created, the flow jumps
to 'error' label, where virDomainConfNWFilterTeardown() is
called. This may report an error as well, but should not
overwrite the original cause why we jumped to 'error' label.

12 years agodoc: Clarify usage of SELinux baselabel
Peter Krempa [Wed, 24 Apr 2013 13:25:06 +0000 (15:25 +0200)]
doc: Clarify usage of SELinux baselabel

State what fields are used when generating SELinux labels from a
baselabel.

12 years agoIntroduce a sub-element <driver> for controller
Osier Yang [Wed, 24 Apr 2013 09:24:38 +0000 (17:24 +0800)]
Introduce a sub-element <driver> for controller

Like what we did for "disk", "filesystem" and "interface", this
introduces sub-element <driver> for "controller", and put the "queues"
into it.

12 years agoqemu: Don't require a block or file when looking for an alias
Wido den Hollander [Fri, 5 Apr 2013 16:07:25 +0000 (18:07 +0200)]
qemu: Don't require a block or file when looking for an alias

This for example prohibits you to use iotune for Ceph or Sheepdog devices.

Signed-off-by: Wido den Hollander <wido@widodh.nl>
12 years agoChange the tag name "num_queues" into "queues"
Osier Yang [Wed, 24 Apr 2013 09:24:13 +0000 (17:24 +0800)]
Change the tag name "num_queues" into "queues"

Instead of making a choice between the underscore and camelCase, this
simply changes "num_queues" into "queues", which is also consistent
with Michal's multiple queue support for interface.

12 years agoutil: Error out if the numa nodeset is out of range
Osier Yang [Mon, 22 Apr 2013 07:14:56 +0000 (15:14 +0800)]
util: Error out if the numa nodeset is out of range

Instead of a silent warning, it's better to error out if the
numa nodeset is out of range. Just like for numa node larger
than NUMA_NUM_NODES.

12 years agoselinux: Don't mask errors of virSecuritySELinuxGenNewContext
Peter Krempa [Wed, 24 Apr 2013 12:38:54 +0000 (14:38 +0200)]
selinux: Don't mask errors of virSecuritySELinuxGenNewContext

Since cbe67ff9b0a5a94911afd4d12388bf182bcca86c
virSecuritySELinuxGenNewContext reports good error messages. Fix callers
that mask the errors by generic error message.

12 years agoqemu: Improve handling of channels when generating SPICE command line
Peter Krempa [Tue, 23 Apr 2013 12:23:30 +0000 (14:23 +0200)]
qemu: Improve handling of channels when generating SPICE command line

Improve error reporting and generating of SPICE command line arguments
according to the need to enable TLS. If TLS is disabled, there's no need
to pass the certificate dir to qemu.

This patch resolves:
https://bugzilla.redhat.com/show_bug.cgi?id=953126

12 years agoqemu: Do sensible auto allocation of SPICE port numbers
Peter Krempa [Tue, 23 Apr 2013 05:01:38 +0000 (07:01 +0200)]
qemu: Do sensible auto allocation of SPICE port numbers

With this patch, if the autoport attribute is used, the code will
sensibly auto allocate the ports only if needed.

12 years agoMake driver method names consistent with public APIs
Daniel P. Berrange [Tue, 23 Apr 2013 12:50:18 +0000 (13:50 +0100)]
Make driver method names consistent with public APIs

Ensure that all drivers implementing public APIs use a
naming convention for their implementation that matches
the public API name.

eg for the public API   virDomainCreate make sure QEMU
uses qemuDomainCreate and not qemuDomainStart

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoDedicated name for sub-driver open/close methods
Daniel P. Berrange [Tue, 23 Apr 2013 12:49:21 +0000 (13:49 +0100)]
Dedicated name for sub-driver open/close methods

It will simplify later work if the sub-drivers have dedicated
APIs / field names. ie virNetworkDriver should have
virDrvNetworkOpen and virDrvNetworkClose methods

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoRename 'DeviceMonitor' to 'NodeDeviceDriver'
Daniel P. Berrange [Tue, 23 Apr 2013 10:15:48 +0000 (11:15 +0100)]
Rename 'DeviceMonitor' to 'NodeDeviceDriver'

The driver.h struct for node devices used an inconsistent
naming scheme 'DeviceMonitor' instead of the more usual
'NodeDeviceDriver'. Fix this everywhere it has leaked
out to.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoSanitize whitespace in driver.h
Daniel P. Berrange [Tue, 23 Apr 2013 09:49:27 +0000 (10:49 +0100)]
Sanitize whitespace in driver.h

The driver.h file has no consistent indentation usage across
all the typedefs. Attempts to vertically align struct field
members have also been inconsistently applied. Sanitize the
whitespace used for typedefs & remove all vertical alignment
from structs

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoExtend previous check to validate driver struct field names
Daniel P. Berrange [Mon, 22 Apr 2013 17:26:01 +0000 (18:26 +0100)]
Extend previous check to validate driver struct field names

Ensure that the driver struct field names match the public
API names. For an API virXXXX we must have a driver struct
field xXXXX. ie strip the leading 'vir' and lowercase any
leading uppercase letters.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoEnsure driver method names match public API names
Daniel P. Berrange [Mon, 22 Apr 2013 17:25:01 +0000 (18:25 +0100)]
Ensure driver method names match public API names

Ensure that the virDrvXXX method names exactly match
the public APIs virYYY method names. ie XXX == YYY.
Add a test case to prevent any regressions.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoMake naming of remote procedures match API names exactly
Daniel P. Berrange [Thu, 18 Apr 2013 11:07:23 +0000 (12:07 +0100)]
Make naming of remote procedures match API names exactly

A number of the remote procedure names did not match the
corresponding API names. For example, many lacked the
word 'CONNECT', others re-arranged the names. Update the
procedures so their names exactly match the API names.
Then remove the special case handling of these APIs in
the generator

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoCleanup command line options in gendispatch.pl
Daniel P. Berrange [Thu, 18 Apr 2013 10:29:56 +0000 (11:29 +0100)]
Cleanup command line options in gendispatch.pl

There are many declared options in gendispatch.pl that were
no longer used. Those which were used were obscure '-b', '-k'
and '-d'. Switch to use --mode={debug|client|server}.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoqemu: Split out SPICE port allocation into a separate function
Peter Krempa [Mon, 22 Apr 2013 14:26:57 +0000 (16:26 +0200)]
qemu: Split out SPICE port allocation into a separate function

Later on this function will be used to do more sophisticated checks and
determination if port allocation is needed.

12 years agoqemu: Use switch instead of ifs in qemuBuildGraphicsCommandLine
Peter Krempa [Mon, 22 Apr 2013 13:13:46 +0000 (15:13 +0200)]
qemu: Use switch instead of ifs in qemuBuildGraphicsCommandLine

Switch the function from a bunch of ifs to a switch statement with
correct type and reflow some code.

Also fix comment in enum describing possible graphics types

12 years agoqemu: Split out code to generate VNC command line
Peter Krempa [Mon, 22 Apr 2013 12:39:46 +0000 (14:39 +0200)]
qemu: Split out code to generate VNC command line

Decrease size of qemuBuildGraphicsCommandLine() by splitting out
spice-related code into qemuBuildGraphicsVNCCommandLine().

This patch also fixes 2 possible memory leaks on error path in the code
that was split-out. The buffer containing the already generated options
and a listen address string could be leaked.

Also break a few very long lines and reflow code that fits now.

12 years agoqemu: Split out code to generate SPICE command line
Peter Krempa [Mon, 22 Apr 2013 12:39:46 +0000 (14:39 +0200)]
qemu: Split out code to generate SPICE command line

Decrease size of qemuBuildGraphicsCommandLine() by splitting out
spice-related code into qemuBuildGraphicsSPICECommandLine().

This patch also fixes 2 possible memory leaks on error path in the code
that was split-out. The buffer containing the already generated options
and a listen address string could be leaked.

Also break a few very long lines.

12 years agoqemu: Use -machine accel=tcg|kvm when available
Jiri Denemark [Tue, 23 Apr 2013 14:17:08 +0000 (16:17 +0200)]
qemu: Use -machine accel=tcg|kvm when available

This is a better interface to choose accelerator than guessing whether
we should enable or disable kvm to get the right one.

12 years agoqemu: Move -enable-kvm and friends earlier in the command line
Jiri Denemark [Tue, 23 Apr 2013 14:15:22 +0000 (16:15 +0200)]
qemu: Move -enable-kvm and friends earlier in the command line

12 years agoSwitch to a more extensible annotation system for RPC protocols
Daniel P. Berrange [Wed, 17 Apr 2013 12:04:27 +0000 (13:04 +0100)]
Switch to a more extensible annotation system for RPC protocols

Currently the RPC protocol files can contain annotations after
the protocol enum eg

   REMOTE_PROC_DOMAIN_SNAPSHOT_LIST_CHILDREN_NAMES = 247, /* autogen autogen priority:high */

This is not very extensible as the number of annotations grows.
Change it to use

    /**
     * @generate: both
     * @priority: high
     */
   REMOTE_PROC_DOMAIN_SNAPSHOT_LIST_CHILDREN_NAMES = 247,

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoqemu: Fix setting of memory tunables
Peter Krempa [Wed, 17 Apr 2013 15:50:56 +0000 (17:50 +0200)]
qemu: Fix setting of memory tunables

Refactoring done in 19c6ad9ac7e7eb2fd3c8262bff5f087b508ad07f didn't
correctly take into account the order cgroup limit modification needs to
be done in. This resulted into errors when decreasing the limits.

The operations need to take place in this order:

decrease hard limit
change swap hard limit

or

change swap hard limit
increase hard limit

This patch also fixes the check if the hard_limit is less than
swap_hard_limit to print better error messages. For this purpose I
introduced a helper function virCompareLimitUlong to compare limit
values where value of 0 is equal to unlimited. Additionally the check is
now applied also when the user does not provide all of the tunables
through the API and in that case the currently set values are used.

This patch resolves:
https://bugzilla.redhat.com/show_bug.cgi?id=950478

12 years agologging: Make log regexp more compact (and readable)
Jiri Denemark [Mon, 22 Apr 2013 16:33:01 +0000 (18:33 +0200)]
logging: Make log regexp more compact (and readable)

12 years agoqemu: Ignore libvirt logs when reading QEMU error output
Jiri Denemark [Mon, 22 Apr 2013 16:20:21 +0000 (18:20 +0200)]
qemu: Ignore libvirt logs when reading QEMU error output

When QEMU fails to start, libvirt read its error output and reports it
back in an error message. However, when libvirtd is configured to log
debug messages, one would get the following unhelpful garbage:

    virsh # start cd
    error: Failed to start domain cd
    error: internal error process exited while connecting to monitor: \
      2013-04-22 14:24:54.214+0000: 2194219: debug : virFileClose:72 : \
      Closed fd 21
    2013-04-22 14:24:54.214+0000: 2194219: debug : virFileClose:72 : \
      Closed fd 27
    2013-04-22 14:24:54.215+0000: 2194219: debug : virFileClose:72 : \
      Closed fd 3
    2013-04-22 14:24:54.215+0000: 2194220: debug : virExec:602 : Run \
      hook 0x7feb8f600bf0 0x7feb86ef9300
    2013-04-22 14:24:54.215+0000: 2194220: debug : qemuProcessHook:2507 \
      : Obtaining domain lock
    2013-04-22 14:24:54.216+0000: 2194220: debug : \
      virDomainLockProcessStart:170 : plugin=0x7feb780261f0 \
      dom=0x7feb7802a360 paused=1 fd=0x7feb86ef8ec4
    2013-04-22 14:24:54.216+0000: 2194220: debug : \
      virDomainLockManagerNew:128 : plugin=0x7feb780261f0 \
      dom=0x7feb7802a360 withResources=1
    2013-04-22 14:24:54.216+0000: 2194220: debug : \
      virLockManagerPluginGetDriver:297 : plugin=0x7feb780261f0
    2013-04-22 14:24:54.216+0000: 2194220: debug : \
      virLockManagerNew:321 : driver=0x7feb8ef08640 type=0 nparams=5 \
      params=0x7feb86ef8d60 flags=0
    2013-04-22 14:24:54.216+000

instead of (the output with this patch applied):

    virsh # start cd
    error: Reconnected to the hypervisor
    error: Failed to start domain cd
    error: internal error process exited while connecting to monitor: \
      char device redirected to /dev/pts/33 (label charserial0)
    qemu-system-x86_64: -drive file=/home/vm/systemrescuecd-x86-1.2.0.\
      iso,if=none,id=drive-ide0-1-0,readonly=on,format=raw,cache=none: \
      could not open disk image /home/vm/systemrescuecd-x86-1.2.0.iso: \
      Permission denied

12 years agoqemu: Move QEMU log reading into a separate function
Jiri Denemark [Mon, 22 Apr 2013 16:16:57 +0000 (18:16 +0200)]
qemu: Move QEMU log reading into a separate function

12 years agoupdate input ip processing
Gene Czarcinski [Sun, 21 Apr 2013 14:34:40 +0000 (10:34 -0400)]
update input ip processing

1. Handle invalid ULong prefix specified.
When parsing for @prefix as a ULong, a -2 can be returned
if the specification is not a valid ULong.

2.  Error out if address= is not specified.

3.  Merge netmask process/tests under family tests.

4. Max sure that prefix does not exceed maximum.
.
Signed-off-by: Gene Czarcinski <gene@czarc.net>
12 years agocreate virSocketAddrGetIpPrefix utility function
Gene Czarcinski [Sat, 20 Apr 2013 19:45:46 +0000 (15:45 -0400)]
create virSocketAddrGetIpPrefix utility function

Create the utility function virSocketAddrGetIpPrefix() to
determine the prefix for this network.  The code in this
function was adapted from virNetworkIpDefPrefix().

Update virNetworkIpDefPrefix() in src/conf/network_conf.c
to use the new utility function.

Signed-off-by: Gene Czarcinski <gene@czarc.net>
12 years agoReplace more cases of /system with /machine
Daniel P. Berrange [Mon, 22 Apr 2013 16:11:11 +0000 (17:11 +0100)]
Replace more cases of /system with /machine

The change in commit aed4986322fe77bdf718e31a0587d00f04f3d97a
was incomplete, missing a couple of cases of /system. This
caused failure to start VMs.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agosheepdog: Omit braces with a single-line body
Harry Wei [Mon, 22 Apr 2013 12:33:46 +0000 (20:33 +0800)]
sheepdog: Omit braces with a single-line body

libvirt/HACKING suggests omitting braces with a
single-line body; this patch fixes the coding style
problem for the Sheepdog storage backend driver.

Signed-off-by: Harry Wei <harryxiyou@gmail.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
12 years agoChange default resource partition to /machine
Daniel P. Berrange [Thu, 18 Apr 2013 10:07:17 +0000 (11:07 +0100)]
Change default resource partition to /machine

After discussions with systemd developers it was decided that
a better default policy for resource partitions is to have
3 default partitions at the top level

   /system   - system services
   /machine - virtual machines / containers
   /user    - user login session

This ensures that the default policy isolates guest from
user login sessions & system services, so a mis-behaving
guest can't consume 100% of CPU usage if other things are
contending for it.

Thus we change the default partition from /system to
/machine

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoqemu: Fix the wrong expression
Osier Yang [Mon, 22 Apr 2013 11:40:19 +0000 (19:40 +0800)]
qemu: Fix the wrong expression

Wrong use of the parentheses causes "rc" always having a boolean value,
either "1" or "0", and thus we can't get the detailed error message
when it fails:

Before (I only have 1 node):
% virsh numatune f18 --nodeset 12
error: Unable to change numa parameters
error: unable to set numa tunable: Unknown error -1

After:
virsh numatune f18 --nodeset 12
error: Unable to change numa parameters
error: unable to set numa tunable: Invalid argument

12 years agodocs: fix usage of 'onto'
Eric Blake [Fri, 19 Apr 2013 20:18:14 +0000 (14:18 -0600)]
docs: fix usage of 'onto'

http://www.uhv.edu/ac/newsletters/writing/grammartip2009.07.01.htm
(and several other sites) give hints that 'onto' is best used if
you can also add 'up' just before it and still make sense. In many
cases in the code base, we really want the two-word form, or even
a simplification to just 'on' or 'to'.

* docs/hacking.html.in: Use correct 'on to'.
* python/libvirt-override.c: Likewise.
* src/lxc/lxc_controller.c: Likewise.
* src/util/virpci.c: Likewise.
* daemon/THREADS.txt: Use simpler 'on'.
* docs/formatdomain.html.in: Better usage.
* docs/internals/rpc.html.in: Likewise.
* src/conf/domain_event.c: Likewise.
* src/rpc/virnetclient.c: Likewise.
* tests/qemumonitortestutils.c: Likewise.
* HACKING: Regenerate.

Signed-off-by: Eric Blake <eblake@redhat.com>
12 years agoaudit: properly encode device path in cgroup audit
Eric Blake [Fri, 19 Apr 2013 17:30:44 +0000 (11:30 -0600)]
audit: properly encode device path in cgroup audit

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

Commit d04916fa introduced a regression in audit quality - even
though the code was computing the proper escaped name for a
path, it wasn't feeding that escaped name on to the audit message.
As a result, /var/log/audit/audit.log would mention a pair of
fields class=path path=/dev/hpet instead of the intended
class=path path="/dev/hpet", which in turn caused ausearch to
format the audit log with path=(null).

* src/conf/domain_audit.c (virDomainAuditCgroupPath): Use
constructed encoding.

Signed-off-by: Eric Blake <eblake@redhat.com>
12 years agoqemu: rename CheckSlot to SlotInUse
Ján Tomko [Mon, 15 Apr 2013 17:56:03 +0000 (19:56 +0200)]
qemu: rename CheckSlot to SlotInUse

Also change its return value from int to bool.

12 years agoqemu: switch PCI address set from hash table to an array
Ján Tomko [Mon, 15 Apr 2013 17:53:41 +0000 (19:53 +0200)]
qemu: switch PCI address set from hash table to an array

Each bus is represented as an array of 32 8-bit integers
where each bit represents a PCI function and each byte represents
a PCI slot.

Uses just one bus so far.

12 years agoconf: add model attribute to virDomainDefMaybeAddController
Ján Tomko [Wed, 17 Apr 2013 12:01:21 +0000 (14:01 +0200)]
conf: add model attribute to virDomainDefMaybeAddController

12 years agoqemu: move PCI address check out of qemuPCIAddressAsString
Ján Tomko [Mon, 15 Apr 2013 17:12:37 +0000 (19:12 +0200)]
qemu: move PCI address check out of qemuPCIAddressAsString

Create a new function qemuPCIAddressValidate and call it everywhere
the user might supply an incorrect address:
* qemuCollectPCIAddress for domain definition
* qemuDomainPCIAddressEnsureAddr and ReleaseSlot for hotplug

Slot and function shouldn't be wrong at this point, since values
out of range should be rejected by the XML parser.

12 years agoqemu: QEMU_PCI constant consistency
Ján Tomko [Tue, 5 Mar 2013 12:22:50 +0000 (13:22 +0100)]
qemu: QEMU_PCI constant consistency

Change QEMU_PCI_ADDRESS_LAST_SLOT to the number of slots in the bus,
not the maximum slot value, to match QEMU_PCI_ADDRESS_LAST_FUNCTION
and rename them both to have _LAST at the end.

12 years agoqemu: print PCI address hexadecimally in errors
Ján Tomko [Wed, 3 Apr 2013 16:11:32 +0000 (18:11 +0200)]
qemu: print PCI address hexadecimally in errors

Use the same formatting as we do for XML in error and debug outputs.

12 years agoqemu: make qemuComparePCIDevice aware of multiple buses
Ján Tomko [Wed, 3 Apr 2013 16:09:47 +0000 (18:09 +0200)]
qemu: make qemuComparePCIDevice aware of multiple buses

Bus and domain need to be checked as well, otherwise we might
get false positives when searching for multi-function devices.

12 years agoconf: Reword error message to be more universal
Peter Krempa [Tue, 16 Apr 2013 09:50:10 +0000 (11:50 +0200)]
conf: Reword error message to be more universal

The error message reported when attempting to change/get persistent
configuration of a transient domain suggests that changes are being
made. Reword it to suit getter APIs too.

Before:
$ virsh vcpucount transient-domain --config
error: Requested operation is not valid: cannot change persistent config of a transient domain

After:
$ virsh vcpucount transient-domain --config
error: Requested operation is not valid: transient domains do not have any persistent config

12 years agonetwork: bridge_driver: don't lose transient networks on daemon restart
Peter Krempa [Tue, 16 Apr 2013 16:35:59 +0000 (18:35 +0200)]
network: bridge_driver: don't lose transient networks on daemon restart

Until now tranisent networks weren't really useful as libvirtd wasn't
able to remember them across restarts. This patch adds support for
loading status files of transient networks (that already were generated)
so that the status isn't lost.

This patch chops up virNetworkObjUpdateParseFile and turns it into
virNetworkLoadState and a few friends that will help us to load status
XMLs and refactors the functions that are loading the configs to use
them.

12 years agocpu: Rename PowerPCUpdate and PowerPCDataFree functions
Jiri Denemark [Thu, 20 Dec 2012 11:38:25 +0000 (12:38 +0100)]
cpu: Rename PowerPCUpdate and PowerPCDataFree functions

For consistency with other functions in PowerPC CPU driver, the two
functions are renamed as ppcUpdate and ppcDataFree, respectively.

12 years agocpu: Remove hardcoded list of PowerPC models
Jiri Denemark [Wed, 19 Dec 2012 00:35:51 +0000 (01:35 +0100)]
cpu: Remove hardcoded list of PowerPC models

The cpu_map.xml file is there to separate CPU model definitions from the
code. Having the only interesting data for PowerPC models only in the
source code. This patch moves this data to the XML file and removes the
hardcoded list completely.

12 years agocpu: Reimplement PowerPCDecode
Jiri Denemark [Wed, 19 Dec 2012 00:53:25 +0000 (01:53 +0100)]
cpu: Reimplement PowerPCDecode

PowerPC CPUs are either identical or incompatible and thus we just need
to look up the right model for given PVR without pretending we have
several candidates which we may choose from.

The function is also renamed as ppcDecode to match other functions in
PowerPC CPU driver.

12 years agocpu: Reimplement PowerPCBaseline
Jiri Denemark [Wed, 19 Dec 2012 00:33:01 +0000 (01:33 +0100)]
cpu: Reimplement PowerPCBaseline

Baseline API is supposed to return guest CPU definition that can be used
on any of the provided host CPUs. Since PowerPC CPUs are either
identical or incompatible, the API just needs to check that all provided
CPUs are identical. Previous implementation was completely bogus.

The function is also renamed as ppcBaseline to match other functions in
PowerPC CPU driver.

12 years agocpu: Fix loading PowerPC vendor from cpu_map.xml
Jiri Denemark [Tue, 18 Dec 2012 23:06:45 +0000 (00:06 +0100)]
cpu: Fix loading PowerPC vendor from cpu_map.xml

When ppcVendorLoad fails to parse the vendor element for whatever
reason, it is supposed to ignore it and return 0 rather than -1. The
patch also removes PowerPC vendor string from the XML as it is not
actually used for anything.

12 years agocpu: Fix PowerPCNodeData
Jiri Denemark [Tue, 18 Dec 2012 22:42:34 +0000 (23:42 +0100)]
cpu: Fix PowerPCNodeData

Make getting node CPU data for PowerPC unsupported on other
architectures. The function is also renamed as ppcNodeData to match
other functions in PowerPC CPU driver.

12 years agocpu: Make comparing PowerPC CPUs easier to read
Jiri Denemark [Tue, 18 Dec 2012 22:32:01 +0000 (23:32 +0100)]
cpu: Make comparing PowerPC CPUs easier to read

Revert the condition to make it easier to read. The function is also
renamed as ppcCompare to match other functions in PowerPC CPU driver.

12 years agocpu: Introduce cpuModelIsAllowed internal API
Jiri Denemark [Wed, 19 Dec 2012 11:08:32 +0000 (12:08 +0100)]
cpu: Introduce cpuModelIsAllowed internal API

The API can be used to check if the model is on the supported models
list, which needs to be done in several places.