]> xenbits.xensource.com Git - people/dariof/libvirt.git/log
people/dariof/libvirt.git
11 years agoremote: Fix a segfault in remoteDomainCreateWithFlags master
Alex Jia [Thu, 8 Aug 2013 08:44:57 +0000 (16:44 +0800)]
remote: Fix a segfault in remoteDomainCreateWithFlags

Valgrind defects memory error:

==16759== 1 errors in context 1 of 8:
==16759== Invalid free() / delete / delete[] / realloc()
==16759==    at 0x4A074C4: free (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==16759==    by 0x83CD329: xdr_string (in /usr/lib64/libc-2.17.so)
==16759==    by 0x4D93E4D: xdr_remote_nonnull_string (remote_protocol.c:31)
==16759==    by 0x4D94350: xdr_remote_nonnull_domain (remote_protocol.c:58)
==16759==    by 0x4D976C8: xdr_remote_domain_create_with_flags_ret (remote_protocol.c:1762)
==16759==    by 0x83CC734: xdr_free (in /usr/lib64/libc-2.17.so)
==16759==    by 0x4D7F1E0: remoteDomainCreateWithFlags (remote_driver.c:2441)
==16759==    by 0x4D4BF17: virDomainCreateWithFlags (libvirt.c:9499)
==16759==    by 0x13127A: cmdStart (virsh-domain.c:3376)
==16759==    by 0x12BF83: vshCommandRun (virsh.c:1751)
==16759==    by 0x126FFB: main (virsh.c:3205)
==16759==  Address 0xe1394a0 is not stack'd, malloc'd or (recently) free'd

==16759== 1 errors in context 2 of 8:
==16759== Conditional jump or move depends on uninitialised value(s)
==16759==    at 0x4A07477: free (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==16759==    by 0x83CD329: xdr_string (in /usr/lib64/libc-2.17.so)
==16759==    by 0x4D93E4D: xdr_remote_nonnull_string (remote_protocol.c:31)
==16759==    by 0x4D94350: xdr_remote_nonnull_domain (remote_protocol.c:58)
==16759==    by 0x4D976C8: xdr_remote_domain_create_with_flags_ret (remote_protocol.c:1762)
==16759==    by 0x83CC734: xdr_free (in /usr/lib64/libc-2.17.so)
==16759==    by 0x4D7F1E0: remoteDomainCreateWithFlags (remote_driver.c:2441)
==16759==    by 0x4D4BF17: virDomainCreateWithFlags (libvirt.c:9499)
==16759==    by 0x13127A: cmdStart (virsh-domain.c:3376)
==16759==    by 0x12BF83: vshCommandRun (virsh.c:1751)
==16759==    by 0x126FFB: main (virsh.c:3205)
==16759==  Uninitialised value was created by a stack allocation
==16759==    at 0x4D7F120: remoteDomainCreateWithFlags (remote_driver.c:2423)

How to reproduce?

# virsh start <domain> --paused

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

Signed-off-by: Alex Jia <ajia@redhat.com>
11 years agotests: work with older dbus
Eric Blake [Thu, 8 Aug 2013 19:00:03 +0000 (13:00 -0600)]
tests: work with older dbus

On RHEL 5, with dbus 1.1.2, compilation failed with:

virsystemdmock.c: In function 'dbus_connection_send_with_reply_and_block':
virsystemdmock.c:68: warning: implicit declaration of function 'dbus_message_set_serial'

Fix this by instead bypassing all attempts to use a dbus serial.

* tests/virsystemdmock.c (dbus_message_set_reply_serial): Add new
override.
(dbus_connection_send_with_reply_and_block): No longer bother with
the serial.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agobuild: fix compilation of virt-login-shell.c
Jim Fehlig [Thu, 8 Aug 2013 19:53:25 +0000 (13:53 -0600)]
build: fix compilation of virt-login-shell.c

virt-login-shell.c was failing to compile with

CC       virt_login_shell-virt-login-shell.o
virt-login-shell.c: In function 'main':
virt-login-shell.c:205:5: error: implicit declaration of function 'setlocale' [-Werror=implicit-function-declaration]
virt-login-shell.c:205:5: error: nested extern declaration of 'setlocale' [-Werror=nested-externs]
virt-login-shell.c:205:20: error: 'LC_ALL' undeclared (first use in this function)

11 years agoconfigure: fix formatting of missing pkg-config modules error
Giuseppe Scrivano [Thu, 8 Aug 2013 14:56:59 +0000 (16:56 +0200)]
configure: fix formatting of missing pkg-config modules error

It adds an empty space after the package version.  Previously the error
message looked like:

"You must install the dbus-1 >= 1.0.0pkg-config module to compile libvirt"

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
11 years agoIntroduce a virt-login-shell binary
Dan Walsh [Thu, 8 Aug 2013 15:36:31 +0000 (16:36 +0100)]
Introduce a virt-login-shell binary

Add a virt-login-shell binary that can be set as a user's
shell, such that when they login, it causes them to enter
the LXC container with a name matching their user name.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoEnsure securityfs is mounted readonly in container
Dan Walsh [Thu, 8 Aug 2013 11:51:01 +0000 (12:51 +0100)]
Ensure securityfs is mounted readonly in container

If securityfs is available on the host, we should ensure to
mount it read-only in the container. This will avoid systemd
trying to mount it during startup causing SELinux AVCs.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoqemu: Allow hotplug of multiple SCSI devices
Eric Farman [Thu, 8 Aug 2013 11:26:50 +0000 (13:26 +0200)]
qemu: Allow hotplug of multiple SCSI devices

Hotplugging a single SCSI device works, but adding additional ones
result in an error from QEMU:

[root@gpok197 ~]# virsh attach-device guest01 blah.xml
Device attached successfully
[root@gpok197 ~]# virsh attach-device guest01 blah2.xml
error: Failed to attach device from blah2.xml
error: internal error unable to execute QEMU command 'device_add': Duplicate ID 'hostdev0' for device

The hostdev ID that is created is always set to zero, regardless
of the contents of the XML.  Changing the index in the hotplug case
to a negative one so the next available index is used.

Signed-off-by: Eric Farman <farman@linux.vnet.ibm.com>
Reviewed-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
11 years agoAdd info about access control checks into API reference
Daniel P. Berrange [Wed, 7 Aug 2013 12:03:50 +0000 (13:03 +0100)]
Add info about access control checks into API reference

So that app developers / admins know what access control checks
are performed for each API, this patch extends the API docs
generator to include details of the ACLs for each.

The gendispatch.pl script is extended so that it generates
a simple XML describing ACL rules, eg.

  <aclinfo>
    ...
    <api name='virConnectNumOfDomains'>
      <check object='connect' perm='search_domains'/>
      <filter object='domain' perm='getattr'/>
    </api>
    <api name='virDomainAttachDeviceFlags'>
      <check object='domain' perm='write'/>
      <check object='domain' perm='save' flags='!VIR_DOMAIN_AFFECT_CONFIG|VIR_DOMAIN_AFFECT_LIVE'/>
      <check object='domain' perm='save' flags='VIR_DOMAIN_AFFECT_CONFIG'/>
    </api>
    ...
  </aclinfo>

The newapi.xsl template loads the XML files containing the ACL
rules and generates a short block of HTML for each API describing
the parameter checks and return value filters (if any).

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoFix validation of CA certificate chains
Daniel P. Berrange [Tue, 6 Aug 2013 11:31:20 +0000 (12:31 +0100)]
Fix validation of CA certificate chains

The code added to validate CA certificates did not take into
account the possibility that the cacert.pem file can contain
multiple (concatenated) cert data blocks. Extend the code for
loading CA certs to use the gnutls APIs for loading cert lists.
Add test cases to check that multi-level trees of certs will
validate correctly.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoChange data passed into TLS test cases
Daniel P. Berrange [Tue, 6 Aug 2013 10:35:49 +0000 (11:35 +0100)]
Change data passed into TLS test cases

Currently a 'struct testTLSCertReq' instance is passed into
the TLS test cases. This is not flexible enough to cope with
certificate chains, where one file now corresponds to multiple
certificates. Change the test cases so that we pass in filenames
instead.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoAvoid re-generating certs every time
Daniel P. Berrange [Mon, 5 Aug 2013 16:08:17 +0000 (17:08 +0100)]
Avoid re-generating certs every time

Currently every test case in the TLS test suite generates the
certs fresh. This is a waste of time, since its parameters
don't change across test cases. Create certs once in main
method.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoSplit TLS test into two separate tests
Daniel P. Berrange [Mon, 5 Aug 2013 15:49:24 +0000 (16:49 +0100)]
Split TLS test into two separate tests

The virnettlscontexttest.c tests both virNetTLSContext
and virNetTLSSession functionality. Split into two
separate tests, to make the code size more manageable

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agomaint: avoid C99 loop declaration
Eric Blake [Wed, 7 Aug 2013 22:44:58 +0000 (16:44 -0600)]
maint: avoid C99 loop declaration

Commit 3d0e3c1 reintroduced a problem previously squelched in
commit 7e5aa78.  Add a syntax check this time around.

util/virutil.c: In function 'virGetGroupList':
util/virutil.c:1015: error: 'for' loop initial declaration used outside C99 mode

* cfg.mk (sc_prohibit_loop_var_decl): New rule.
* src/util/virutil.c (virGetGroupList): Fix offender.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agomaint: the compiler is not always named gcc
Eric Blake [Wed, 7 Aug 2013 15:44:52 +0000 (09:44 -0600)]
maint: the compiler is not always named gcc

https://bugzilla.redhat.com/show_bug.cgi?id=994589 complained that
even when using a cross-compiler not named 'gcc', the configure
output confusingly referred to gcc.

* m4/virt-compile-warnings.m4 (LIBVIRT_COMPILE_WARNINGS): Use a
more generic statement in configure output.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoReverse logic allowing partial DHCP host XML
Ján Tomko [Wed, 31 Jul 2013 11:25:59 +0000 (13:25 +0200)]
Reverse logic allowing partial DHCP host XML

Before, missing attributes were only OK when adding entries;
modification and deletion required all of them.

Now, only deletion works with missing attributes, as long as
the host is uniquely identified.

11 years agoRevert "build: fix configure detection of if_bridge.h on RHEL 6"
Daniel P. Berrange [Wed, 7 Aug 2013 10:23:54 +0000 (11:23 +0100)]
Revert "build: fix configure detection of if_bridge.h on RHEL 6"

This reverts commit 2df8d99138dc8396c7d46c3cceca8ce2e93b605a.

The change breaks configure on any recent Fedora platform

11 years agoqemu: support to drop disk with 'optional' startupPolicy
Guannan Ren [Wed, 7 Aug 2013 07:11:15 +0000 (15:11 +0800)]
qemu: support to drop disk with 'optional' startupPolicy

Go through disks of guest, if one disk doesn't exist or its backing
chain is broken, with 'optional' startupPolicy, for CDROM and Floppy
we only discard its source path definition in xml, for disks we drop
it from disk list and free it.

11 years agoconf: add startupPolicy attribute for harddisk
Guannan Ren [Wed, 31 Jul 2013 07:51:44 +0000 (15:51 +0800)]
conf: add startupPolicy attribute for harddisk

Add startupPolicy attribute for harddisk with type "file",
"block" and "dir". 'requisite' is not supported currently for
harddisk.

11 years agonwfilter: Use -m conntrack rather than -m state
Stefan Berger [Wed, 7 Aug 2013 00:30:46 +0000 (20:30 -0400)]
nwfilter: Use -m conntrack rather than -m state

Since iptables version 1.4.16 '-m state --state NEW' is converted to
'-m conntrack --ctstate NEW'. Therefore, when encountering this or later
versions of iptables use '-m conntrack --ctstate'.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
11 years agovirGetGroupList: always include the primary group
Guido Günther [Mon, 5 Aug 2013 09:07:27 +0000 (11:07 +0200)]
virGetGroupList: always include the primary group

The change from initgroups to virGetGroupList/setgroups in
cab36cfe71ba83b71e536ba5c98e596f02b697b0 dropped the primary group from
processes group list iff the passed in group to virGetGroupList differs
from the user's primary group.

So always include the primary group to bring back the old behaviour.

Debian has the kvm group as primary group but uses
libvirt-qemu:libvirt-qemu as user:group to run the kvm process so
without this change the /dev/kvm is inaccessible.

11 years agobuild: fix configure detection of if_bridge.h on RHEL 6
Eric Blake [Tue, 6 Aug 2013 20:15:23 +0000 (14:15 -0600)]
build: fix configure detection of if_bridge.h on RHEL 6

A fresh checkout on a RHEL 6 machine with these packages:
kernel-headers-2.6.32-405.el6.x86_64
glibc-2.12-1.128.el6.x86_64
failed to configure with this message:
checking for linux/if_bridge.h... no
configure: error: You must install kernel-headers in order to compile libvirt with QEMU or LXC support

Digging in config.log, we see that the problem is identical to
what we fixed earlier in commit d12c2811:

configure:98831: checking for linux/if_bridge.h
configure:98853: gcc -std=gnu99 -c -g -O2  conftest.c >&5
In file included from /usr/include/linux/if_bridge.h:17,
                 from conftest.c:559:
/usr/include/linux/in6.h:31: error: redefinition of 'struct in6_addr'
/usr/include/linux/in6.h:48: error: redefinition of 'struct sockaddr_in6'
/usr/include/linux/in6.h:56: error: redefinition of 'struct ipv6_mreq'
configure:98860: $? = 1

I had not hit it earlier because I was using incremental builds,
where config.cache had shielded me from the kernel-headers breakage.

* configure.ac (if_bridge.h): Avoid conflicting type definitions.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoxen: Use internal interfaces in xenDomainUsedCpus
Stefan Bader [Tue, 6 Aug 2013 11:28:58 +0000 (12:28 +0100)]
xen: Use internal interfaces in xenDomainUsedCpus

Since commit 95e18efd most public interfaces (xenUnified...) obtain
a virDomainDefPtr via xenGetDomainDefFor...() which take the unified
lock.
This is already taken before calling xenDomainUsedCpus(), so we get
a deadlock for active guests. Avoid this by splitting up
xenUnifiedDomainGetVcpusFlags() and xenUnifiedDomainGetVcpus() into
public and private function calls (which get the virDomainDefPtr passed)
and use those in xenDomainUsedCpus().

    xenDomainUsedCpus
      ...
      nb_vcpu = xenUnifiedDomainGetMaxVcpus(dom);
        return xenUnifiedDomainGetVcpusFlags(...)
          ...
          if (!(def = xenGetDomainDefForDom(dom)))
            return xenGetDomainDefForUUID(dom->conn, dom->uuid);
              ...
              ret = xenHypervisorLookupDomainByUUID(conn, uuid);
                ...
                xenUnifiedLock(priv);
                name = xenStoreDomainGetName(conn, id);
                xenUnifiedUnlock(priv);
      ...
      if ((ncpus = xenUnifiedDomainGetVcpus(dom, cpuinfo, nb_vcpu,
        ...
        if (!(def = xenGetDomainDefForDom(dom)))
          [again like above]

Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
11 years agoqemu: improve error reporting during PCI address validation
Laine Stump [Mon, 5 Aug 2013 18:52:04 +0000 (14:52 -0400)]
qemu: improve error reporting during PCI address validation

This patch addresses two concerns with the error reporting when an
incompatible PCI address is specified for a device:

1) It wasn't always apparent which device had the problem. With this
patch applied, any error about an incompatible address will always
contain the full address as given in the config, so it will be easier
to determine which device's config aused the problem.

2) In some cases when the problem came from bad config, the error
message was erroneously classified as VIR_ERR_INTERNAL_ERROR. With
this patch applied, the same error message will be changed to indicate
either "internal" or "xml" error depending on whether the address came
from the config, or was automatically generated by libvirt.

Note that in the case of "internal" (due to bad auto-generation)
errors, the PCI address won't be of much use in finding the location
in config to change (because it was automatically generated). Of
course that makes perfect sense, but still the address could provide a
clue about a bug in libvirt attempting to use a type of pci bus that
doesn't have its flags set correctly (or something similar). In other
words, it's not perfect, but it is definitely better.

11 years agoqemu: enable using implicit sata controller in q35 machines
Laine Stump [Sat, 3 Aug 2013 21:37:07 +0000 (17:37 -0400)]
qemu: enable using implicit sata controller in q35 machines

q35 machines have an implicit ahci (sata) controller at 00:1F.2 which
has no "id" associated with it. For this reason, we can't refer to it
as "ahci0". Instead, we don't give an id on the commandline, which
qemu interprets as "use the first ahci controller". We then need to
specify the unit with "unit=%d" rather than adding it onto the bus
arg.

11 years agoqemu_migration: Don't error on tunelled migration with --copy-storage
Michal Privoznik [Mon, 5 Aug 2013 10:05:23 +0000 (12:05 +0200)]
qemu_migration: Don't error on tunelled migration with --copy-storage

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

Since 1.0.3 we are using the new way to copy non shared storage during
migration (the NBD way). However, whether the new or old way is used is
not controllable by user but unconditionally turned on if both sides of
migration support it. Moreover, the implementation is not complete: the
combination for VIR_MIGRATE_TUNNELLED flag is missing (as we need to
open new port on the destination) in which case we just error out. This
is a deadly combination: not letting users choose their destiny and
erroring out. We should not do that but VIR_WARN and turn the NBD off
instead.

11 years agoqemu: properly set/use device alias for pci controllers
Laine Stump [Fri, 2 Aug 2013 17:48:50 +0000 (13:48 -0400)]
qemu: properly set/use device alias for pci controllers

We had been setting the device alias in the devinceinfo for pci
controllers to "pci%u", but then hardcoding "pci.%u" when creating the
device address for other devices using that pci bus. This all worked
just fine until we encountered the built-in "pcie.0" bus (the PCIe
root complex) in Q35 machines.

In order to create the correct commandline for this one case, this
patch:

1) sets the alias for PCI controllers correctly, to "pci.%u" (or
"pcie.%u" for the pcie-root controller)

2) eliminates the hardcoded "pci.%u" for pci controllers when
generatuing device address strings, and instead uses the controller's
alias.

3) plumbs a pointer to the virDomainDef all the way down to
qemuBuildDeviceAddressStr. This was necessary in order to make the
aliase of the controller *used by a device* available (previously
qemuBuildDeviceAddressStr only had the deviceinfo of the device
itself, *not* of the controller it was connecting to). This made for a
larger than desired diff, but at least in the future we won't have to
do it again, since all the information we could possibly ever need for
future enhancements is in the virDomainDef. (right?)

This should be done for *all* controllers, but for now we just do it
in the case of PCI controllers, to reduce the likelyhood of
regression.

11 years agoqemu: fix handling of default/implicit devices for q35
Laine Stump [Fri, 2 Aug 2013 08:55:55 +0000 (04:55 -0400)]
qemu: fix handling of default/implicit devices for q35

This patch adds in special handling for a few devices that need to be
treated differently for q35 domains:

usb - there is no implicit/default usb controller for the q35
machinetype. This is done because normally the default usb controller
is added to a domain by just adding "-usb" to the qemu commandline,
and it's assumed that this will add a single piix3 usb1 controller at
slot 1 function 2. That's not what happens when the machinetype is
q35, though. Instead, adding -usb to the commandline adds 3 usb
(version 2) controllers to the domain at slot 0x1D.{1,2,7}. Rather
than having

  <controller type='usb' index='0'/>

translate into 3 separate devices on the PCI bus, it's cleaner to not
automatically add a default usb device; one can always be added
explicitly if desired. Or we may decide that on q35 machines, 3 usb
controllers will be automatically added when none is given. But for
this initial commit, at least we aren't locking ourselves into
something we later won't want.

video - qemu always initializes the primary video device immediately
after any integrated devices for the machinetype. Unless instructed
otherwise (by using "-device vga..." instead of "-vga" which libvirt
uses in many cases to work around deficiencies and bugs in various
qemu versions) qemu will always pick the first unused slot. In the
case of the "pc" machinetype and its derivatives, this is always slot
2, but on q35 machinetypes, the first free slot is slot 1 (since the
q35's integrated peripheral devices are placed in other slots,
e.g. slot 0x1f). In order to make the PCI address of the video device
predictable, that slot (1 or 2, depending on machinetype) is reserved
even when no video device has been specified.

sata - a q35 machine always has a sata controller implicitly added at
slot 0x1F, function 2. There is no way to avoid this controller, so we
always add it. Note that the xml2xml tests for the pcie-root and q35
cases were changed to use DO_TEST_DIFFERENT() so that we can check for
the sata controller being automatically added. This is especially
important because we can't check for it in the xml2argv output (it has
no effect on that output since it's an implicit device).

ide - q35 has no ide controllers.

isa and smbus controllers - these two are always present in a q35 (at
slot 0x1F functions 0 and 3) but we have no way of modelling them in
our config. We do need to reserve those functions so that the user
doesn't attempt to put anything else there though. (note that the "pc"
machine type also has an ISA controller, which we also ignore).

11 years agoqemu: add dmi-to-pci-bridge controller
Laine Stump [Wed, 31 Jul 2013 01:37:32 +0000 (21:37 -0400)]
qemu: add dmi-to-pci-bridge controller

This PCI controller, named "dmi-to-pci-bridge" in the libvirt config,
and implemented with qemu's "i82801b11-bridge" device, connects to a
PCI Express slot (e.g. one of the slots provided by the pcie-root
controller, aka "pcie.0" on the qemu commandline), and provides 31
*non-hot-pluggable* PCI (*not* PCIe) slots, numbered 1-31.

Any time a machine is defined which has a pcie-root controller
(i.e. any q35-based machinetype), libvirt will automatically add a
dmi-to-pci-bridge controller if one doesn't exist, and also add a
pci-bridge controller. The reasoning here is that any useful domain
will have either an immediate (startup time) or eventual (subsequent
hot-plug) need for a standard PCI slot; since the pcie-root controller
only provides PCIe slots, we need to connect a dmi-to-pci-bridge
controller to it in order to get a non-hot-plug PCI slot that we can
then use to connect a pci-bridge - the slots provided by the
pci-bridge will be both standard PCI and hot-pluggable.

Since pci-bridge devices themselves can not be hot-plugged into a
running system (although you can hot-plug other devices into a
pci-bridge's slots), any new pci-bridge controller that is added can
(and will) be plugged into the dmi-to-pci-bridge as long as it has
empty slots available.

This patch is also changing the qemuxml2xml-pcie test from a "DO_TEST"
to a "DO_DIFFERENT_TEST". This is so that the "before" xml can omit
the automatically added dmi-to-pci-bridge and pci-bridge devices, and
the "after" xml can include it - this way we are testing if libvirt is
properly adding these devices.

11 years agoqemu: add pcie-root controller
Laine Stump [Wed, 10 Jul 2013 19:19:32 +0000 (15:19 -0400)]
qemu: add pcie-root controller

This controller is implicit on q35 machinetypes. It provides 31 PCIe
(*not* PCI) slots as controller 0.

Currently there are no devices that can connect to pcie-root, and no
implicit pci controller on a q35 machine, so q35 is still
unusable. For a usable q35 system, we need to add a
"dmi-to-pci-bridge" pci controller, which can connect to pcie-root,
and provides standard pci slots that can be used to connect other
devices.

11 years agoqemu: enable auto-allocate of all PCI addresses
Laine Stump [Tue, 30 Jul 2013 19:14:09 +0000 (15:14 -0400)]
qemu: enable auto-allocate of all PCI addresses

Previous refactoring of the guest PCI address reservation/allocation
code allowed for slot types other than basic PCI (e.g. PCI express,
non-hotpluggable slots, etc) but would not auto-allocate a slot for a
device that required any type other than a basic hot-pluggable
PCI slot.

This patch refactors the code to be aware of different slot types
during auto-allocation of addresses as well - as long as there is an
empty slot of the required type, it will be found and used.

The piece that *wasn't* added is that we don't auto-create a new PCI
bus when needed for anything except basic PCI devices. This is because
there are multiple different types of controllers that can provide,
for example, a PCI express slot (in addition to the pcie-root
controller, these can also be found on a "root-port" or on a
"downstream-switch-port"). Since we currently don't support any PCIe
devices (except pending support for dmi-to-pci-bridge), we can defer
any decision on what to do about this.

11 years agobuild: fix missing max_queued_clients in augeas test file for libvirtd.conf
Laine Stump [Mon, 5 Aug 2013 19:09:52 +0000 (15:09 -0400)]
build: fix missing max_queued_clients in augeas test file for libvirtd.conf

Broken in commit 1199edb1d4e3ebbc691bd32d3519a3b662225420

11 years agoxen: fix memory corruption in legacy driver
Jim Fehlig [Mon, 5 Aug 2013 16:27:23 +0000 (10:27 -0600)]
xen: fix memory corruption in legacy driver

Commit 632180d1 introduced memory corruption in xenDaemonListDefinedDomains
by starting to populate the names array at index -1, causing all sorts
of havoc in libvirtd such as aborts like the following

*** Error in `/usr/sbin/libvirtd': double free or corruption (out): 0x00007fffe00ccf20 ***
======= Backtrace: =========
/lib64/libc.so.6(+0x7abf6)[0x7ffff3fa0bf6]
/lib64/libc.so.6(+0x7b973)[0x7ffff3fa1973]
/lib64/libc.so.6(xdr_array+0xde)[0x7ffff403cbae]
/usr/sbin/libvirtd(+0x50251)[0x5555555a4251]
/lib64/libc.so.6(xdr_free+0x15)[0x7ffff403ccd5]
/usr/lib64/libvirt.so.0(+0x1fad34)[0x7ffff76b1d34]
/usr/lib64/libvirt.so.0(virNetServerProgramDispatch+0x1fc)[0x7ffff76b16f1]
/usr/lib64/libvirt.so.0(+0x1f214a)[0x7ffff76a914a]
/usr/lib64/libvirt.so.0(+0x1f222d)[0x7ffff76a922d]
/usr/lib64/libvirt.so.0(+0xbcc4f)[0x7ffff7573c4f]
/usr/lib64/libvirt.so.0(+0xbc5e5)[0x7ffff75735e5]
/lib64/libpthread.so.0(+0x7e0f)[0x7ffff48f7e0f]
/lib64/libc.so.6(clone+0x6d)[0x7ffff400e7dd]

Fix by initializing ret to 0 and only setting to error on failure path.

11 years agoIntroduce max_queued_clients
Michal Privoznik [Thu, 25 Jul 2013 12:45:38 +0000 (14:45 +0200)]
Introduce max_queued_clients

This configuration knob lets user to set the length of queue of
connection requests waiting to be accept()-ed by the daemon. IOW, it
just controls the @backlog passed to listen:

  int listen(int sockfd, int backlog);

11 years agoRPC: Don't accept client if it would overcommit max_clients
Michal Privoznik [Thu, 25 Jul 2013 11:27:42 +0000 (13:27 +0200)]
RPC: Don't accept client if it would overcommit max_clients

Currently, even if max_client limit is hit, we accept() incoming
connection request, but close it immediately. This has disadvantage of
not using listen() queue. We should accept() only those clients we
know we can serve and let all other wait in the (limited) queue.

11 years agoqemu: eliminate almost-duplicate code in qemu_command.c
Laine Stump [Sat, 27 Jul 2013 00:42:14 +0000 (20:42 -0400)]
qemu: eliminate almost-duplicate code in qemu_command.c

* The functions qemuDomainPCIAddressReserveAddr and
qemuDomainPCIAddressReserveSlot were very similar (and should have
been more similar) and were about to get more code added to them which
would create even more duplicated code, so this patch gives
qemuDomainPCIAddressReserveAddr a "reserveEntireSlot" arg, then
replaces the body of qemuDomainPCIAddressReserveSlot with a call to
qemuDomainPCIAddressReserveAddr.

You will notice that addrs->lastaddr was previously set in
qemuDomainPCIAddressReserveAddr (but *not* set in
qemuDomainPCIAddressReserveSlot). For consistency and cleanliness of
code, that bit was removed and put into the one caller of
qemuDomainPCIAddressReserveAddr (there is a similar place where the
caller of qemuDomainPCIAddressReserveSlot sets lastaddr). This does
guarantee identical functionality to pre-patch code, but in practice
isn't really critical, because lastaddr is just keeping track of where
to start when looking for a free slot - if it isn't updated, we will
just start looking on a slot that's already occupied, then skip up to
one that isn't.

* qemuCollectPCIAddress was essentially doing the same thing as
qemuDomainPCIAddressReserveAddr, but with some extra special case
checking at the beginning. The duplicate code has been replaced with
a call to qemuDomainPCIAddressReserveAddr. This required adding a
"fromConfig" boolean, which is only used to change the log error
code from VIR_ERR_INTERNAL_ERROR (when the address was
auto-generated by libvirt) to VIR_ERR_XML_ERROR (when the address is
coming from the config); without this differentiation, it would be
difficult to tell if an error was caused by something wrong in
libvirt's auto-allocate code or just bad config.

* the bit of code in qemuDomainPCIAddressValidate that checks the
connect type flags is going to be used in a couple more places where
we don't need to also check the slot limits (because we're generating
the slot number ourselves), so that has been pulled out into a
separate qemuDomainPCIAddressFlagsCompatible function.

11 years agoqemu: rename some functions in qemu_command.c
Laine Stump [Sat, 27 Jul 2013 01:04:18 +0000 (21:04 -0400)]
qemu: rename some functions in qemu_command.c

* qemuDomainPCIAddressSetNextAddr

The name of this function was confusing because 1) other functions in
the file that end in "Addr" are only operating on a single function of
one PCI slot, not the entire slot, while functions that do something
with the entire slot end in "Slot", and 2) it didn't contain a verb
describing what it is doing (the "Set" refers to the set that contains
all PCI buses in the system, used to keep track of which slots in
which buses are already reserved for use).

It is now renamed to qemuDomainPCIAddressReserveNextSlot, which more
clearly describes what it is doing. Arguably, it could have been
changed to qemuDomainPCIAddressSetReserveNextSlot, but 1) the word
"set" is confusing in this context because it could be intended as a
verb or as a noun, and 2) most other functions that operate on a
single slot or address within this set are also named
qemuDomainPCIAddress... rather than qemuDomainPCIAddressSet... Only
the Create, Free, and Grow functions for an address set (which modify the
entire set, not just one element) use "Set" in their name.

* qemuPCIAddressAsString, qemuPCIAddressValidate

All the other functions in this set are named
qemuDomainPCIAddressxxxxx, so I renamed these to be consistent.

11 years agoconf: add default USB controller in qemu post-parse callback
Laine Stump [Fri, 2 Aug 2013 08:13:33 +0000 (04:13 -0400)]
conf: add default USB controller in qemu post-parse callback

The parser shouldn't be doing arch-specific things like adding in
implicit controllers to the config. This should instead be done in the
hypervisor's post-parse callback.

This patch removes the auto-add of a usb controller from the domain
parser, and puts it into the qemu driver's post-parse callback (just
as is already done with the auto-add of the pci-root controller). In
the future, any machine/arch that shouldn't have a default usb
controller added should just set addDefaultUSB = false in this
function.

We've recently seen that q35 and ARMV7L domains shouldn't get a default USB
controller, so I've set addDefaultUSB to false for both of those.

11 years agospec: Explicitly claim ownership of channel subdir
Jiri Denemark [Fri, 2 Aug 2013 14:36:57 +0000 (16:36 +0200)]
spec: Explicitly claim ownership of channel subdir

As both /var/lib/libvirt/qemu and /var/lib/libvirt/qemu/channel/target
are owned by us, the intermediate /var/lib/libvirt/qemu/channel should
be owned by us too.

11 years agoFix crashing upgrading from older libvirts with running guests
Daniel P. Berrange [Fri, 2 Aug 2013 11:12:30 +0000 (12:12 +0100)]
Fix crashing upgrading from older libvirts with running guests

If upgrading from a libvirt that is older than 1.0.5, we can
not assume that vm->def->resource is non-NULL. This bogus
assumption caused libvirtd to crash

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoAvoid crash if NULL is passed for filename/funcname in logging
Daniel P. Berrange [Fri, 2 Aug 2013 11:15:57 +0000 (12:15 +0100)]
Avoid crash if NULL is passed for filename/funcname in logging

The journald code would crash if a NULL was passed for the
filename / funcname in the logging code. This shouldn't
happen in general, but it is better to be safe, since there
have been bugs triggering this.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoEnsure LXC/QEMU APIs set the filename for errors
Daniel P. Berrange [Fri, 2 Aug 2013 11:15:15 +0000 (12:15 +0100)]
Ensure LXC/QEMU APIs set the filename for errors

The virLibConnError macros in libvirt-lxc.c and
libvirt-qemu.c were passing NULL for the filename.
This causes a crash if the logging code is configured
to use journald.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoRemove reference to python/tests from RPM %doc
Daniel P. Berrange [Fri, 2 Aug 2013 10:27:03 +0000 (11:27 +0100)]
Remove reference to python/tests from RPM %doc

The python/tests files were recently deleted, but a reference was
left in the RPM %doc entry

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoqemumonitortestutils: Don't skip va_end() on error path
Peter Krempa [Thu, 1 Aug 2013 14:33:23 +0000 (16:33 +0200)]
qemumonitortestutils: Don't skip va_end() on error path

When allocation of memory failed the error path didn't call va_end()
causing a coverity failure.

Reported by John Ferlan.

11 years agoqemuagenttest: Check invalid response in shutdown test
Peter Krempa [Thu, 1 Aug 2013 14:28:29 +0000 (16:28 +0200)]
qemuagenttest: Check invalid response in shutdown test

The shutdown test utilizes waiting for condition to exit the test. This
addition will return an error for the shutdown command to see if the
condition waiting code will not hang.

11 years agoqemuagenttest: Fix checking of shutdown mode
Peter Krempa [Thu, 1 Aug 2013 14:19:09 +0000 (16:19 +0200)]
qemuagenttest: Fix checking of shutdown mode

Coverity complained about unused variable that contains the shutdown
mode. The original intention was to check it against the requested mode.

Also the fixed check revealed a mistake in the expected shutdown mode.

Reported by John Ferlan.

11 years agobridge driver: extract platform specifics
Roman Bogorodskiy [Wed, 24 Jul 2013 12:22:54 +0000 (16:22 +0400)]
bridge driver: extract platform specifics

* Move platform specific things (e.g. firewalling and route
  collision checks) into bridge_driver_platform
* Create two platform specific implementations:
    - bridge_driver_linux: Linux implementation using iptables,
      it's actually the code moved from bridge_driver.c
    - bridge_driver_nop: dumb implementation that does nothing

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agovalgrind: Adjust filter for _dl_allocate_tls
John Ferlan [Thu, 1 Aug 2013 19:52:46 +0000 (15:52 -0400)]
valgrind: Adjust filter for _dl_allocate_tls

More tests are now using the path - adjust the filter to include any
path from a test through pthread_create to _dl_allocate_tls

11 years agotests: Coverity found new NULL_RETURNS
John Ferlan [Thu, 1 Aug 2013 19:54:51 +0000 (15:54 -0400)]
tests: Coverity found new NULL_RETURNS

Coverity reported the existing missing check of the return value and
subsequent use from a call to virJSONValueFromString() in testJSONAddRemove().

11 years agobuild: fix qemuagenttest build with -O0 in fedora 19.
Jincheng Miao [Thu, 1 Aug 2013 17:05:17 +0000 (01:05 +0800)]
build: fix qemuagenttest build with -O0 in fedora 19.

When building libvirt with -O0 flag in fedora 19, it will fail to
generate qemuagenttest, a link error occurs like:

./.libs/libqemumonitortestutils.a(qemumonitortestutils.o): In function `qemuMonitorTestFree':
libvirt/tests/qemumonitortestutils.c:346: undefined reference to `qemuMonitorClose'
./.libs/libqemumonitortestutils.a(qemumonitortestutils.o): In function `qemuMonitorTestNew':
libvirt/tests/qemumonitortestutils.c:870: undefined reference to `qemuMonitorOpen'
collect2: error: ld returned 1 exit status

Fix it by listing libraries in the correct order to avoid lazy linkage.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agomaint: use modern autoconf idioms
Eric Blake [Wed, 31 Jul 2013 20:52:16 +0000 (14:52 -0600)]
maint: use modern autoconf idioms

Autoconf 2.59 says that AC_OUTPUT with arguments is obsolete,
and we are already using the replacement for some, but not all,
of our output files.

* configure.ac (AC_OUTPUT): Rewrite to use AC_CONFIG_FILES.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoqemu: check presence of each disk and its backing file as well
Guannan Ren [Wed, 31 Jul 2013 07:55:05 +0000 (15:55 +0800)]
qemu: check presence of each disk and its backing file as well

For disk with startupPolicy support, such as cdrom and floppy
when its chain is broken, the startup policy will apply,
otherwise, report an error.

11 years agoqemu: add helper functions for diskchain checking
Guannan Ren [Mon, 29 Jul 2013 12:51:15 +0000 (20:51 +0800)]
qemu: add helper functions for diskchain checking

*src/util/virstoragefile.c: Add a helper function to get
the first name of missing backing files, if the name is NULL,
it means the diskchain is not broken.
*src/qemu/qemu_domain.c: qemuDiskChainCheckBroken(disk) to
check if its chain is broken

11 years agoqemu: refactor qemuDomainCheckDiskPresence for only disk presence check
Guannan Ren [Fri, 26 Jul 2013 12:37:21 +0000 (20:37 +0800)]
qemu: refactor qemuDomainCheckDiskPresence for only disk presence check

Refactor this function to make it focus on disk presence checking,
including diskchain checking, and not only for CDROM and Floppy.
This change is good for the following patches.

11 years agoConfiguring systemd to restart libvirt on failure
Mooli Tayer [Tue, 30 Jul 2013 12:32:59 +0000 (15:32 +0300)]
Configuring systemd to restart libvirt on failure

This will create a respawn behaviour in case libvirt
process exits due to nonzero exit code, is terminated
by a signal, an operation times out or the configured
watchdog timeout is triggered.
see http://www.freedesktop.org/software/systemd/man/systemd.service.html
and https://bugzilla.redhat.com/show_bug.cgi?id=981974

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoxen: Avoid double free of virDomainDef in xenDaemonCreateXML
Stefan Bader [Wed, 31 Jul 2013 09:59:21 +0000 (11:59 +0200)]
xen: Avoid double free of virDomainDef in xenDaemonCreateXML

The virDomainDef is allocated by the caller and also used after
calling to xenDaemonCreateXML. So it must not get freed by the
callee.

Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
11 years agoEnable support for systemd-machined in cgroups creation
Daniel P. Berrange [Mon, 22 Jul 2013 15:34:51 +0000 (16:34 +0100)]
Enable support for systemd-machined in cgroups creation

Make the virCgroupNewMachine method try to use systemd-machined
first. If that fails, then fallback to using the traditional
cgroup setup code path.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoCope with races while killing processes
Daniel P. Berrange [Fri, 26 Jul 2013 15:02:22 +0000 (16:02 +0100)]
Cope with races while killing processes

When systemd is involved in managing processes, it may start
killing off & tearing down croups associated with the process
while we're still doing virCgroupKillPainfully. We must
explicitly check for ENOENT and treat it as if we had finished
killing processes

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoAdd support for systemd cgroup mount
Daniel P. Berrange [Thu, 25 Jul 2013 18:13:44 +0000 (19:13 +0100)]
Add support for systemd cgroup mount

Systemd uses a named cgroup mount for tracking processes. Add
it as another type of controller, albeit one which we have to
special case in a number of places. In particular we must
never create/delete directories there, nor add tasks. Essentially
the systemd mount is to be considered read-only for libvirt.

With this change both the virCgroupDetectPlacement and
virCgroupCopyPlacement methods must be invoked. The copy
placement method will copy setup for resource controllers
only. The detect placement method will probe for any
named controllers, or resource controllers not already
setup.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoAdd APIs for formatting systemd slice/scope names
Daniel P. Berrange [Fri, 26 Jul 2013 14:18:55 +0000 (15:18 +0100)]
Add APIs for formatting systemd slice/scope names

There are some interesting escaping rules to consider when dealing
with systemd slice/scope names. Thus it is helpful to have APIs
for formatting names

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoqemuagenttest: Add tests for CPU plug functions and helpers
Peter Krempa [Tue, 30 Jul 2013 12:09:16 +0000 (14:09 +0200)]
qemuagenttest: Add tests for CPU plug functions and helpers

11 years agoqemuagenttest: Introduce testing of shutdown commands
Peter Krempa [Mon, 29 Jul 2013 15:22:32 +0000 (17:22 +0200)]
qemuagenttest: Introduce testing of shutdown commands

This patch exports a few utility functions and adds testing of shutdown
commands of the guest agent.

11 years agoqemuagenttest: Add testing of agent suspend modes
Peter Krempa [Mon, 29 Jul 2013 13:24:32 +0000 (15:24 +0200)]
qemuagenttest: Add testing of agent suspend modes

11 years agoqemuagenttest: Test the filesystem trimming
Peter Krempa [Mon, 29 Jul 2013 09:02:19 +0000 (11:02 +0200)]
qemuagenttest: Test the filesystem trimming

11 years agotests: Add qemuagenttest
Peter Krempa [Wed, 24 Jul 2013 08:15:37 +0000 (10:15 +0200)]
tests: Add qemuagenttest

Add a basic test framework with two simple tests to test guest agent
interaction.

11 years agoqemumonitortestutils: Add the ability to check arguments of commands
Peter Krempa [Thu, 25 Jul 2013 13:42:38 +0000 (15:42 +0200)]
qemumonitortestutils: Add the ability to check arguments of commands

This patch adds helpers that allow to check for argument values in
commands sent to the monitor.

11 years agoqemumonitortestutils: Improve error reporting from mock qemu monitor
Peter Krempa [Mon, 29 Jul 2013 12:29:15 +0000 (14:29 +0200)]
qemumonitortestutils: Improve error reporting from mock qemu monitor

Use the JSON error messages to report errors back to the caller in
addition to erroring out. The error reported from the event loop from
the mock function of the monitor was later overwritten by the call to
the monitor/agent interaction API. This will also allow testing of error
reporting.

11 years agoqemumonitortestutils: Add instrumentation for guest agent testing
Peter Krempa [Thu, 25 Jul 2013 10:08:25 +0000 (12:08 +0200)]
qemumonitortestutils: Add instrumentation for guest agent testing

Add helper functions to open guest agent connections and a handler for
replying to the "guest-sync" command.

11 years agoqemumonitortestutils: Split lines on \n instead of \r\n
Peter Krempa [Thu, 25 Jul 2013 10:03:29 +0000 (12:03 +0200)]
qemumonitortestutils: Split lines on \n instead of \r\n

The normal monitor uses windows line endings, where the agent monitor
uses only newlines. Change this to tolerate both approaches and allow to
use the utilities for guest agent tests.

11 years agoqemumonitortestutils: Refactor the test helpers to allow reuse
Peter Krempa [Thu, 25 Jul 2013 09:48:11 +0000 (11:48 +0200)]
qemumonitortestutils: Refactor the test helpers to allow reuse

Refactor the test helpers to allow adding callbacks to verify the
monitor responses instead of simple command name checking and clean up
various parts to prepare for adding guest agent tests.

11 years agoqemumonitortestutils: Split up creation of the test to allow reuse
Peter Krempa [Mon, 22 Jul 2013 14:59:22 +0000 (16:59 +0200)]
qemumonitortestutils: Split up creation of the test to allow reuse

The instrumentation for the monitor test can be hacked for qemu agent
testing. Split out the monitor specific stuff to allow using the code in
guest agent tests in the future.

11 years agoqemumonitortestutils: Don't crash on non fully initialized test
Peter Krempa [Mon, 22 Jul 2013 14:57:08 +0000 (16:57 +0200)]
qemumonitortestutils: Don't crash on non fully initialized test

The qemumonitorjsontest crashed when one of the initialization steps
done before starting the worker thread failed. This patch fixes this by
trying to pthread_join() the thread only after it was created.

11 years agoqemumonitortestutils: remove multiline function calls
Peter Krempa [Thu, 25 Jul 2013 09:02:00 +0000 (11:02 +0200)]
qemumonitortestutils: remove multiline function calls

11 years agoqemumonitortestutils: Use VIR_DELETE_ELEMENT and VIR_APPEND_ELEMENT
Peter Krempa [Thu, 18 Jul 2013 15:09:41 +0000 (17:09 +0200)]
qemumonitortestutils: Use VIR_DELETE_ELEMENT and VIR_APPEND_ELEMENT

Simplify the code using the existing helpers instead of open coding the
same functionality.

11 years agoqemumonitortestutils: Use consistent header style and line spacing
Peter Krempa [Thu, 18 Jul 2013 14:17:31 +0000 (16:17 +0200)]
qemumonitortestutils: Use consistent header style and line spacing

11 years agoqemu_agent: Remove obvious comments
Peter Krempa [Thu, 25 Jul 2013 08:59:21 +0000 (10:59 +0200)]
qemu_agent: Remove obvious comments

Most APIs in libvirt report errors, thus no need to state that
explicitly.

11 years agoqemu_agent: Move updater function for VCPU hotplug into qemu_agent.c
Peter Krempa [Tue, 30 Jul 2013 10:04:21 +0000 (12:04 +0200)]
qemu_agent: Move updater function for VCPU hotplug into qemu_agent.c

To allow testing of the cpu updater function, this function needs to be
available separately. Export it from qemu_agent.c where it should
belong.

11 years agoqemu_agent: Output newline at the end of the sync JSON message
Peter Krempa [Wed, 24 Jul 2013 15:52:33 +0000 (17:52 +0200)]
qemu_agent: Output newline at the end of the sync JSON message

Although this isn't apparently needed for the guest agent itself, the
test I will be adding later depends on the newline as a separator of
messages to process.

11 years agoconf: Export virDomainChrSourceDefClear()
Peter Krempa [Mon, 22 Jul 2013 14:45:32 +0000 (16:45 +0200)]
conf: Export virDomainChrSourceDefClear()

11 years agoDon't mark parentIndex with ATTRIBUTE_UNUSED
Ján Tomko [Wed, 31 Jul 2013 07:42:58 +0000 (09:42 +0200)]
Don't mark parentIndex with ATTRIBUTE_UNUSED

parentIndex is used in virNetworkDefUpdateIPDHCPRange

11 years agoadd console support in libxl
Bamvor Jian Zhang [Fri, 26 Jul 2013 03:30:50 +0000 (11:30 +0800)]
add console support in libxl

this patch introduce the console api in libxl driver for both pv and
hvm guest.  and import and update the libxlMakeChrdevStr function
which was deleted in commit dfa1e1dd.

Signed-off-by: Bamvor Jian Zhang <bjzhang@suse.com>
11 years agoutil: add virGetUserDirectoryByUID
Dan Walsh [Tue, 30 Jul 2013 19:55:44 +0000 (15:55 -0400)]
util: add virGetUserDirectoryByUID

This function is needed for virt-login-shell.  Also modify virGirUserDirectory
to use the new function, to simplify the code.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agomaint: fix typo for SENTINEL
Eric Blake [Tue, 30 Jul 2013 16:49:53 +0000 (10:49 -0600)]
maint: fix typo for SENTINEL

* src/openvz/openvz_driver.c: Use correct spelling.
* src/vmware/vmware_conf.c: Likewise.
* src/vmware/vmware_conf.h: Likewise.
* src/vmware/vmware_driver.c: Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agospec: Don't mix commands with macro definitions
Jiri Denemark [Tue, 30 Jul 2013 14:04:48 +0000 (16:04 +0200)]
spec: Don't mix commands with macro definitions

%build section should first define all required macros and then run
commands. Interleaving them makes it harder to spot what commands are
run.

11 years agospec: Use --enable-werror on RHEL
Jiri Denemark [Tue, 30 Jul 2013 14:01:11 +0000 (16:01 +0200)]
spec: Use --enable-werror on RHEL

As RHEL provides a stable tool chain, we don't have to worry about
frequent changes in reported compiler warnings (which prevents us from
enabling -Werror unconditionally).

11 years agospec: RHEL-7 does not have sanlock on i686
Jiri Denemark [Tue, 30 Jul 2013 11:45:04 +0000 (13:45 +0200)]
spec: RHEL-7 does not have sanlock on i686

11 years agospec: Disable libssh2 support for RHEL
Peter Krempa [Mon, 28 Jan 2013 19:17:31 +0000 (20:17 +0100)]
spec: Disable libssh2 support for RHEL

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

Libssh2 isn't reliable enough to support the libvirt transport using it.
The problems include mishandling of "known_hosts" files that may confuse
users.

11 years agotests: Put a mock library at the start of LD_PRELOAD
Jiri Denemark [Tue, 30 Jul 2013 08:41:50 +0000 (10:41 +0200)]
tests: Put a mock library at the start of LD_PRELOAD

This fixes vircgrouptest when run in a sandbox which already overrides
open() and others.

11 years agoSupport apparmor in RPM spec
Daniel P. Berrange [Tue, 30 Jul 2013 11:04:55 +0000 (12:04 +0100)]
Support apparmor in RPM spec

If libapparmor-devel happens to be installed when building the
RPM, it will failed due to unlisted virt-aa-helper in %files.
Add support for apparmor in the spec, so that we can explicitly
turn it on/off, defaulting to off in all distros. This causes
--without-apparmor to be given to configure, preventing the
build failures if the user happens to have libapparmor-devel
present.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoDelete obsolete / unused python test files
Daniel P. Berrange [Tue, 30 Jul 2013 10:24:22 +0000 (11:24 +0100)]
Delete obsolete / unused python test files

The python/tests directory contains a number of so called
"tests" for the python API. These are all hardcoded to
look for Xen and cannot be run in any automated fashion,
and no one is ever manually running them. Given that they
don't meaningully contribute to the test coverage, delete
them.

For some reason these tests were also copied into the
filesystem as part of 'make install'. The change to the
RPM in commit 3347a4203278ec93d7b0ceb88b5ed10e4f14765c
caused a build failure, since it removed the code which
deleted these installed tests.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoFix minor typos in messages and docs
Yuri Chornoivan [Tue, 30 Jul 2013 08:21:11 +0000 (11:21 +0300)]
Fix minor typos in messages and docs

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoRelease of libvirt-1.1.1
Daniel Veillard [Tue, 30 Jul 2013 09:38:35 +0000 (17:38 +0800)]
Release of libvirt-1.1.1

* configure.ac docs/news.html.in: update for the release
* po/*.po*: update localizations and regenerate

11 years agobuild: fix shunloadtest breakage
Eric Blake [Mon, 29 Jul 2013 19:06:27 +0000 (13:06 -0600)]
build: fix shunloadtest breakage

Commit 93ec384 was tested on mingw, but broke the build on Linux:

  CCLD     shunloadtest
shunloadtest.o: In function `main':
/home/eblake/libvirt/tests/shunloadtest.c:106: undefined reference to `virFilePrintf'
...
ssh.o: In function `main':
/home/eblake/libvirt/tests/ssh.c:43: undefined reference to `virFilePrintf'
/home/eblake/libvirt/tests/ssh.c:49: undefined reference to `virFilePrintf'

* tests/testutils.h (fprintf): Provide escape hatch.
* tests/shunloadtest.c: Use it.
* tests/ssh.c: Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoexamples: fix mingw build vs. printf
Eric Blake [Mon, 29 Jul 2013 18:53:36 +0000 (12:53 -0600)]
examples: fix mingw build vs. printf

Mingw *printf is a moving target; newer mingw now provides a version
of asprintf() that fails to understand %lld:

  CC       event_test-event-test.o
../../../../examples/domain-events/events-c/event-test.c: In function 'myDomainEventRTCChangeCallback':
../../../../examples/domain-events/events-c/event-test.c:270:18: error: unknown conversion type character 'l' in format [-Werror=format=]
                  virDomainGetID(dom), offset) < 0)
                  ^

But since our examples already admitted that they were hacking around
a mingw deficiency, it is easier to just use printf() directly, coupled
with <inttypes.h> macros, for a more portable work-around.

* examples/domain-events/events-c/event-test.c
(myDomainEventRTCChangeCallback): Use PRIdMAX instead of asprintf.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agotests: consistently use virFilePrintf
Eric Blake [Mon, 29 Jul 2013 18:01:19 +0000 (12:01 -0600)]
tests: consistently use virFilePrintf

Commit a2619962 introduced virFilePrintf to work around the fact
that gnulib doesn't (yet) provide guarantees about fprintf() vs.
%z, which in turn causes all sorts of mingw compilation errors:

../../tests/testutils.c: In function 'virtTestResult':
../../tests/testutils.c:101:9: error: unknown conversion type character 'z' in format [-Werror=format=]
         fprintf(stderr, "%3zu) %-60s ", testCounter, name);
         ^

Rather than s/fprintf/virFilePrintf/ (and reformatting loads of
lines) across multiple files, it's easier to just hack the entire
testsuite to take advantage of our helper function.

* tests/testutils.c: s/fprintf/virFilePrintf/ for mingw.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agobuild: skip systemd mock on non-Linux
Eric Blake [Mon, 29 Jul 2013 16:47:09 +0000 (10:47 -0600)]
build: skip systemd mock on non-Linux

A cross-compile to mingw failed:

  CC       virsystemdmock_la-virsystemdmock.lo
../../tests/virsystemdmock.c:29:6: error: 'dbus_connection_set_change_sigpipe' redeclared without dllimport attribute: previous dllimport ignored [-Werror=attributes]
 void dbus_connection_set_change_sigpipe(dbus_bool_t will_modify_sigpipe ATTRIBUTE_UNUSED)
      ^

But when you think about it, systemd is Linux-only, and even our
use of LD_PRELOAD to provide mock syscalls is Linux-only.

* tests/virsystemdmock.c: Avoid compilation outside Linux.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoRename VIR_DOMAIN_PAUSED_GUEST_PANICKED to VIR_DOMAIN_PAUSED_CRASHED
Daniel P. Berrange [Mon, 29 Jul 2013 16:54:57 +0000 (17:54 +0100)]
Rename VIR_DOMAIN_PAUSED_GUEST_PANICKED to VIR_DOMAIN_PAUSED_CRASHED

The VIR_DOMAIN_PAUSED_GUEST_PANICKED constant is badly named,
leaking the QEMU event name. Elsewhere in the API we use
'CRASHED' rather than 'PANICKED', and the addition of 'GUEST'
is redundant since all events are guest related.

Thus rename it to VIR_DOMAIN_PAUSED_CRASHED, which matches
with VIR_DOMAIN_RUNNING_CRASHED and VIR_DOMAIN_EVENT_CRASHED.

It was added in commit 14e7e0ae8db9843aea80245a3d9e6cf5f2ef720d
which post-dates v1.1.0, so is safe to rename before 1.1.1

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoRemove VIR_DOMAIN_SHUTDOWN_CRASHED from public API
Daniel P. Berrange [Mon, 29 Jul 2013 16:46:14 +0000 (17:46 +0100)]
Remove VIR_DOMAIN_SHUTDOWN_CRASHED from public API

The VIR_DOMAIN_SHUTDOWN_CRASHED state constant does not appear
to be used in the QEMU code anyway. It also doesn't make much
(any) sense, since the 'shutdown' state is a transient state
between 'running' and 'shutoff' and when a guest crashes, it
does not end up in a 'shutdown' state, only 'shutoff'.

It was added in commit 14e7e0ae8db9843aea80245a3d9e6cf5f2ef720d
which post-dates v1.1.0, so is safe to remove before 1.1.1

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoFix dbus message reading code on big endian hosts
Daniel P. Berrange [Mon, 29 Jul 2013 16:29:00 +0000 (17:29 +0100)]
Fix dbus message reading code on big endian hosts

The way we were casting small (<32bit) integers was broken
on big endian hosts, causing stack smashing. This was detected
in the test suite either by test failures due to incorrect
results, or by libc/gcc abort'ing with its stack canary
triggered.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agospec: Cat test-suite.log if make check fails
Jiri Denemark [Mon, 29 Jul 2013 15:36:20 +0000 (17:36 +0200)]
spec: Cat test-suite.log if make check fails

Current automake enables parallel test by default, which means test
details are only logged in test-suite.log and not printed to stderr.
This patch makes test failures directly visible in RPM build logs even
when parallel tests are turned on.

11 years agobuild: fix another virdbus issue on mingw
Eric Blake [Mon, 29 Jul 2013 15:58:19 +0000 (09:58 -0600)]
build: fix another virdbus issue on mingw

Depending on the set of mingw packages installed, it is possible
that other .c files hit the mingw header pollution from the
virdbus.h file.

In file included from ../../src/rpc/virnetserver.c:39:0:
../../src/util/virdbus.h:41:35: error: expected ';', ',' or ')' before 'struct'
                       const char *interface,
                                   ^

* src/util/virdbus.h (virDBusCallMethod): Match .c file change.

Signed-off-by: Eric Blake <eblake@redhat.com>