libvirt.git
2 hours agolxc: completely rework reference counting master
Katerina Koukiou [Fri, 20 May 2016 15:17:01 +0000]
lxc: completely rework reference counting

This patch follows the pattern used in qemu driver regarding
reference counting.
It changes lxcDomObjFromDomain() to ref the domain (using
virDomainObjListFindByUUIDRef()) and adds virDomainObjEndAPI() which
should be the only function in which the return value of
virObjectUnref() is checked.  This makes all reference counting
deterministic and makes the code a bit clearer.

Signed-off-by: Katerina Koukiou <k.koukiou@gmail.com>

3 hours agolxc: use job functions in lxcDomainLxcOpenNamespace & lxcDomainSendProcessSignal
Katerina Koukiou [Fri, 20 May 2016 15:15:01 +0000]
lxc: use job functions in lxcDomainLxcOpenNamespace & lxcDomainSendProcessSignal

Use the recently added job functions in lxcDomainLxcOpenNamespace,
lxcDomainSendProcessSignal.

Signed-off-by: Katerina Koukiou <k.koukiou@gmail.com>

3 hours agoqemucapstest: update caps for qemu-2.6.0
Pavel Hrdina [Sun, 22 May 2016 21:24:25 +0000]
qemucapstest: update caps for qemu-2.6.0

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>

3 hours agoqemucapstest: update caps for qemu-2.5.0
Pavel Hrdina [Sun, 22 May 2016 21:24:07 +0000]
qemucapstest: update caps for qemu-2.5.0

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>

3 hours agoqemucapstest: update caps for qemu-2.4.0
Pavel Hrdina [Sun, 22 May 2016 21:23:47 +0000]
qemucapstest: update caps for qemu-2.4.0

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>

3 hours agoqemucapstest: update caps for qemu-2.1.1
Pavel Hrdina [Sun, 22 May 2016 21:23:11 +0000]
qemucapstest: update caps for qemu-2.1.1

3 hours agoqemucapstest: update caps for qemu-1.6.0
Pavel Hrdina [Sun, 22 May 2016 21:22:50 +0000]
qemucapstest: update caps for qemu-1.6.0

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>

3 hours agoqemucapstest: update caps for qemu-1.5.3
Pavel Hrdina [Sun, 22 May 2016 21:22:18 +0000]
qemucapstest: update caps for qemu-1.5.3

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>

3 hours agoqemucapstest: update caps for qemu-1.4.2
Pavel Hrdina [Sun, 22 May 2016 21:21:39 +0000]
qemucapstest: update caps for qemu-1.4.2

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>

3 hours agoqemucapstest: update caps for qemu-1.3.1
Pavel Hrdina [Sun, 22 May 2016 21:21:09 +0000]
qemucapstest: update caps for qemu-1.3.1

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>

3 hours agoqemucapstest: update caps for qemu-1.2.2
Pavel Hrdina [Sun, 22 May 2016 21:19:51 +0000]
qemucapstest: update caps for qemu-1.2.2

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>

5 hours agonwfilter: fix lock order deadlock
Maxim Nestratov [Sat, 9 Apr 2016 16:14:30 +0000]
nwfilter: fix lock order deadlock

Below is backtraces of two deadlocked threads:

thread #1:
 virDomainConfVMNWFilterTeardown
   virNWFilterTeardownFilter
       lock updateMutex <------------
       _virNWFilterTeardownFilter
            try to lock interface <----------

thread #2:
 learnIPAddressThread
    lock interface <-------
    virNWFilterInstantiateFilterLate
        try to lock updateMutex <----------

The problem is fixed by unlocking interface before calling
virNWFilterInstantiateFilterLate to avoid updateMutex and interface ordering
deadlocks. Otherwise we are going to instantiate the filter while holding
interface lock, which will try to lock updateMutex, and if some other thread
instantiating a filter in parallel is holding updateMutex and is trying to
lock interface, both will deadlock.
Also it is safe to unlock interface before virNWFilterInstantiateFilterLate
because learnIPAddressThread stopped capturing packets and applied necessary
rules on the interface, while instantiating a new filter doesn't require a
locked interface.

Signed-off-by: Maxim Nestratov <mnestratov@virtuozzo.com>

6 hours agomaint: fix syntax-check sc_prohibit_int_ijk exclude rule
Pavel Hrdina [Mon, 23 May 2016 23:00:07 +0000]
maint: fix syntax-check sc_prohibit_int_ijk exclude rule

Fix the regex for excluding files for this syntax-rule.  The rule "include/"
will not work, because we are matching the whole line like this
"^(...|include/|...)$ so we need to use "include/libvirt/libvirt.+".  The second
issue is that we are using only one '$' but there should be two of those at the
end.  The last small adjustment is to escape dots '.' so it match only dot.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>

6 hours agomakefile: fix build on systems where gnutls is not in /usr/include
Pavel Hrdina [Sun, 22 May 2016 13:23:08 +0000]
makefile: fix build on systems where gnutls is not in /usr/include

We need to append GNUTLS_CFLAGS while building utils because virtcrypto
is using it.  This fixes build on freebsd where gnutuls is in
/usr/local/include.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>

18 hours agoqemuxml2argvtest: skip test that depends on gnutls_cipher_encrypt()
Pavel Hrdina [Sun, 22 May 2016 13:20:39 +0000]
qemuxml2argvtest: skip test that depends on gnutls_cipher_encrypt()

Test disk-drive-network-rbd-auth-AES depends on existence of
gnutls_cipher_encrypt() function which was introduced in gnutls 2.10.0.
On systems without this function we should skip this test.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>

21 hours agostorage: Replace VIR_ERROR with standard vir*Error in state driver init
Jovanka Gulicoska [Mon, 23 May 2016 18:36:01 +0000]
storage: Replace VIR_ERROR with standard vir*Error in state driver init

Replace VIR_ERROR with virReportError and virReportSystemError

21 hours agonwfilter: Replace VIR_ERROR with standard vir*Error in state driver init
Jovanka Gulicoska [Mon, 23 May 2016 18:35:59 +0000]
nwfilter: Replace VIR_ERROR with standard vir*Error in state driver init

Replace VIR_ERROR with virReportError

21 hours agolibxl: Replace VIR_ERROR with standard vir*Error in state driver init
Jovanka Gulicoska [Mon, 23 May 2016 18:35:57 +0000]
libxl: Replace VIR_ERROR with standard vir*Error in state driver init

Replace VIR_ERROR with virReportError

21 hours agobhyve: Replace VIR_ERROR with standard vir*Error in state driver init
Jovanka Gulicoska [Mon, 23 May 2016 18:35:56 +0000]
bhyve: Replace VIR_ERROR with standard vir*Error in state driver init

Replace VIR_ERROR with virReportError

22 hours agoqemu: simplify addition of USB controller in qemuParseCommandLine
Laine Stump [Tue, 10 May 2016 16:07:54 +0000]
qemu: simplify addition of USB controller in qemuParseCommandLine

virDomainDefAddUSBController() does everything that the multiple lines
of code were doing.

24 hours agovz: add error code for case if vm is already stopped
Mikhail Feoktistov [Sat, 21 May 2016 14:33:32 +0000]
vz: add error code for case if vm is already stopped

If try to stop VM or container which is already stopped than
Virtuozzo 7 returns code PRL_ERR_INVALID_ACTION_REQUESTED.
Error code PRL_ERR_DISP_VM_IS_NOT_STARTED is used in Virtuozzo 6

32 hours agoRevert "qemu_cgroup: allow access to /dev/dri for virtio-vga"
Ján Tomko [Thu, 19 May 2016 09:29:54 +0000]
Revert "qemu_cgroup: allow access to /dev/dri for virtio-vga"

This reverts commit 3943bdd60c7ff1de00e73f66d907664b74a88a3f.

32 hours agostorage: do not clear vols before volume upload
Ján Tomko [Fri, 20 May 2016 09:42:56 +0000]
storage: do not clear vols before volume upload

Commit 5e54361c added virStoragePoolObjClearVols before refreshPool
to prevent duplicate volume entries.

However it is not needed here because we're not refreshing the pool yet,
just checking for the existence of the refresh callback.

The actual refresh is done via virStorageVolFDStreamCloseCb
in virStorageVolPoolRefreshThread, which already calls
virStoragePoolObjClearVols.

32 hours agoDeprecate QEMU_CAPS_PCIDEVICE
Ján Tomko [Fri, 20 May 2016 12:41:49 +0000]
Deprecate QEMU_CAPS_PCIDEVICE

Before removal of QEMU_CAPS_DEVICE, its only usage was
or'd with QEMU_CAPS_DEVICE.

Now it's unused.

32 hours agoDeprecate QEMU_CAPS_DEVICE
Ján Tomko [Fri, 20 May 2016 12:33:58 +0000]
Deprecate QEMU_CAPS_DEVICE

We support qemu version 0.12.0+, which has it.

32 hours agoDeprecate QEMU_CAPS_DRIVE_READONLY
Ján Tomko [Fri, 20 May 2016 12:25:22 +0000]
Deprecate QEMU_CAPS_DRIVE_READONLY

We have been assuming its support if qemu supports -device,
which all the supported versions do.

33 hours agoqemu: always assume QEMU_CAPS_DRIVE_READONLY
Ján Tomko [Fri, 20 May 2016 11:29:54 +0000]
qemu: always assume QEMU_CAPS_DRIVE_READONLY

We have been always setting the capability on if qemu has
QEMU_CAPS_DEVICE.

33 hours agotests: always assume QEMU_CAPS_DRIVE_READONLY
Ján Tomko [Fri, 20 May 2016 11:49:15 +0000]
tests: always assume QEMU_CAPS_DRIVE_READONLY

33 hours agotests: remove <readonly/> from IDE disks
Ján Tomko [Fri, 20 May 2016 11:50:40 +0000]
tests: remove <readonly/> from IDE disks

Read-only IDE disks are not supported, but the error
is raised only when QEMU_CAPS_DRIVE_READONLY is set.

33 hours agotests: remove disk-drive-fat test
Ján Tomko [Fri, 20 May 2016 12:02:55 +0000]
tests: remove disk-drive-fat test

This test requests a read-only virtual FAT drive on the IDE bus.
Read-only IDE drives are unsupported, but libvirt only displays
the error if it has the QEMU_CAPS_DRIVE_READONLY capability.
Read-write FAT drives are also unsupported.

33 hours agoqemu: assume QEMU_CAPS_DEVICE almost everywhere
Ján Tomko [Fri, 20 May 2016 11:22:26 +0000]
qemu: assume QEMU_CAPS_DEVICE almost everywhere

Remove more checks that are no longer necessary.

33 hours agoqemu_command: assume QEMU_CAPS_DEVICE
Ján Tomko [Fri, 20 May 2016 11:08:45 +0000]
qemu_command: assume QEMU_CAPS_DEVICE

Drop some checks that are no longer necessary as well as
-usbdevice -pcidevice and -soundhw support.

2 days agoutil: fix build without GNUTLS
Mikhail Feoktistov [Sat, 21 May 2016 14:22:06 +0000]
util: fix build without GNUTLS

3 days agotests: qemu: test <address type='pci'/> with aarch64
Cole Robinson [Sun, 15 May 2016 19:11:29 +0000]
tests: qemu: test <address type='pci'/> with aarch64

This is an interesting test case since PCI isn't the default for
aarch64.

3 days agoqemu: auto-assign addresses when <address type='pci'/> is specified
Laine Stump [Tue, 17 May 2016 18:08:13 +0000]
qemu: auto-assign addresses when <address type='pci'/> is specified

Rather than only assigning a PCI address when no address is given at
all, also do it when the config says that the address type is 'pci',
but it gives no address (virDeviceInfoPCIAddressWanted()).

There are also several places after parsing but prior to address
assignment where code previously expected that any info with address
type='pci' would have a *valid* PCI address, which isn't always the
case - now we check not only for type='pci', but also for a valid
address (virDeviceInfoPCIAddressPresent()).

The test case added in this patch was directly copied from Cole's patch titled:

    qemu: Wire up address type=pci auto_allocate

3 days agobhyve: auto-assign addresses when <address type='pci'/> is specified
Laine Stump [Tue, 17 May 2016 18:06:36 +0000]
bhyve: auto-assign addresses when <address type='pci'/> is specified

Rather than only assigning a PCI address when no address is given at
all, also do it when the config says that the address type is 'pci',
but it gives no address.

3 days agoconf: allow type='pci' addresses with no address attributes specified
Laine Stump [Tue, 17 May 2016 18:03:00 +0000]
conf: allow type='pci' addresses with no address attributes specified

Prior to this, <address type='pci'/> wasn't allowed when parsing
(domain+bus+slot+function needed to be a "valid" PCI address, meaning
that at least one of domain/bus/slot had to be non-0), the RNG
required bus to be specified, and if type was set to PCI when
formatting, domain+bus+slot+function would always be output.

This makes all the address attributes optional during parse and RNG
validation, and suppresses domain+bus+slot+function if domain+bus+slot
are all 0 (NB: if d+b+s are all 0, any value for function is
nonsensical as that will never happen in the real world, and after
the next patch we will always assign a real working address to any
empty PCI address before it is ever output to anywhere).

Note that explicitly setting all attributes to 0 is equivalent to
setting none of them, which is okay, since 0000:00:00 is reserved in
any PCI bus setup, and can't be used anyway.

3 days agoconf: new functions to check if PCI address is wanted/present
Laine Stump [Wed, 18 May 2016 16:04:42 +0000]
conf: new functions to check if PCI address is wanted/present

In order to allow <address type='pci'/> with no other attributes to
mean "I want a PCI address, but any PCI address will do" (just as
having no <address> at all usually indicates), we will need to change
several places in the code from a simple "info->type == (or !=)
VIR_DOMAIN_DEVICE_ADDRESS_TYPE_(PCI|NONE)" into something slightly
more complex, this patch adds to new functions that take a
virDomainDeviceInfoPtr and return true/false depending on 1) whether
the current state of the info indicates that we "want" a PCI address
for this device (virDeviceInfoPCIAddressWanted()) and 2) whether this
device already has a valid PCI address
(virDeviceInfoPCIAddressPresent()).

Both of these functions required the simpler check for whether a pci
address is "empty" (i.e. all of its attributes are 0, which can never
happen in a real PCI address, since slot 0 of bus 0 of domain 0 is
always reserved), so that function is also added.

3 days agoconf: move virDomainDeviceInfo definition from domain_conf.h to device_conf.h
Laine Stump [Tue, 17 May 2016 17:55:02 +0000]
conf: move virDomainDeviceInfo definition from domain_conf.h to device_conf.h

Also moves all the subordinate structs. This is necessary due to a new
inline function that will be defined in device_conf.h, and also makes
sense, because it is the *device* info that's in the struct. (Actually
a lot more stuff from domain_conf.h could move to this newer file, but
I didn't want to disturb any more than necessary).

4 days agotests: Link virtestmock with probes
Michal Privoznik [Wed, 18 May 2016 13:31:54 +0000]
tests: Link virtestmock with probes

I've encountered this error while trying out this feature on some
systems:

  $ VIR_TEST_FILE_ACCESS=1 ./virhashtest \
 libvirt.git/tests/.libs/lt-virhashtest: \
symbol lookup error: libvirt.git/tests/.libs/virtestmock.so: \
undefined symbol: libvirt_event_poll_purge_timeout_semaphore

Problem is, linking just libvirt_utils to virmock.la is not
enough. We might need to link libvirt_probes.lo too.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>

4 days agovirtestmock: Mock stat() properly
Michal Privoznik [Tue, 17 May 2016 14:26:53 +0000]
virtestmock: Mock stat() properly

There is a lot to explain, but I try to make it as short as
possible. I'd start by pasting some parts of sys/stat.h:

extern int stat (const char *__restrict __file,
 struct stat *__restrict __buf) __THROW __nonnull ((1, 2));

extern int __REDIRECT_NTH (stat, (const char *__restrict __file,
  struct stat *__restrict __buf), stat64)
     __nonnull ((1, 2));

__extern_inline int
__NTH (stat (const char *__path, struct stat *__statbuf))
{
  return __xstat (_STAT_VER, __path, __statbuf);
}

Only one of these is effective at once, due to some usage of
the mess we are dealing with in here. So, basically, while
compiling or linking stat() in our code can be transformed into
some other func. Or a dragon.
Now, if you read stat(2) manpage, esp. "C library/kernel
differences" section, you'll learn that glibc uses some tricks
for older applications to work. I haven't gotten around actual
code that does this, but based on my observations, if 'stat'
symbol is found, glibc assumes it's dealing with ancient
application. Unfortunately, it can be just ours stat coming from
our mock. Therefore, calling stat() from a test will end up in
our mock. But since glibc is not exposing the symbol anymore, our
call of real_stat() will SIGSEGV immediately as the pointer to
function is NULL. Therefore, we should expose only those symbols
we know glibc has.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>

4 days agotests: Drop VIR_MOCK_CALL_STAT
Michal Privoznik [Mon, 16 May 2016 15:15:46 +0000]
tests: Drop VIR_MOCK_CALL_STAT

It wasn't as great idea as I thought. Thing around stat() are
more complicated than that. Therefore we need to revert
86d1705a8ace349b plus drop use of the macro as introduced in
later patches.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>

4 days agoqemu: Utilize qemu secret objects for RBD auth/secret
John Ferlan [Mon, 11 Apr 2016 15:26:14 +0000]
qemu: Utilize qemu secret objects for RBD auth/secret

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

If they're available and we need to pass secrets to qemu, then use the
qemu domain secret object in order to pass the secrets for RBD volumes
instead of passing the base64 encoded secret on the command line.

The goal is to make AES secrets the default and have no user interaction
required in order to allow using the AES mechanism. If the mechanism
is not available, then fall back to the current plain mechanism using
a base64 encoded secret.

New APIs:

qemu_domain.c:
  qemuDomainGetSecretAESAlias:
    Generate/return the secret object alias for an AES Secret Info type.
    This will be called from qemuDomainSecretAESSetup.

  qemuDomainSecretAESSetup: (private)
    This API handles the details of the generation of the AES secret
    and saves the pieces that need to be passed to qemu in order for
    the secret to be decrypted. The encrypted secret based upon the
    domain master key, an initialization vector (16 byte random value),
    and the stored secret. Finally, the requirement from qemu is the IV
    and encrypted secret are to be base64 encoded.

qemu_command.c:
  qemuBuildSecretInfoProps: (private)
    Generate/return a JSON properties object for the AES secret to
    be used by both the command building and eventually the hotplug
    code in order to add the secret object. Code was designed so that
    in the future perhaps hotplug could use it if it made sense.

  qemuBuildObjectSecretCommandLine (private)
    Generate and add to the command line the -object secret for the
    secret. This will be required for the subsequent RBD reference
    to the object.

  qemuBuildDiskSecinfoCommandLine (private)
    Handle adding the AES secret object.

Adjustments:

qemu_domain.c:
  The qemuDomainSecretSetup was altered to call either the AES or Plain
  Setup functions based upon whether AES secrets are possible (we have
  the encryption API) or not, we have secrets, and of course if the
  protocol source is RBD.

qemu_command.c:
  Adjust the qemuBuildRBDSecinfoURI API's in order to generate the
  specific command options for an AES secret, such as:

    -object secret,id=$alias,keyid=$masterKey,data=$base64encodedencrypted,
            format=base64
    -drive file=rbd:pool/image:id=myname:auth_supported=cephx\;none:\
           mon_host=mon1.example.org\:6321,password-secret=$alias,...

  where the 'id=' value is the secret object alias generated by
  concatenating the disk alias and "-aesKey0". The 'keyid= $masterKey'
  is the master key shared with qemu, and the -drive syntax will
  reference that alias as the 'password-secret'. For the -drive
  syntax, the 'id=myname' is kept to define the username, while the
  'key=$base64 encoded secret' is removed.

  While according to the syntax described for qemu commit '60390a21'
  or as seen in the email archive:

    https://lists.gnu.org/archive/html/qemu-devel/2016-01/msg04083.html

  it is possible to pass a plaintext password via a file, the qemu
  commit 'ac1d8878' describes the more feature rich 'keyid=' option
  based upon the shared masterKey.

Add tests for checking/comparing output.

NB: For hotplug, since the hotplug code doesn't add command line
    arguments, passing the encoded secret directly to the monitor
    will suffice.

4 days agotests: Allow multiple mock libraries
Peter Krempa [Fri, 20 May 2016 14:27:00 +0000]
tests: Allow multiple mock libraries

Make virtTestMain take variable number of libraries to mock.

4 days agoqemu: Introduce qemuDomainSecretSetup
John Ferlan [Wed, 18 May 2016 22:46:40 +0000]
qemu: Introduce qemuDomainSecretSetup

Currently just a shim to call qemuDomainSecretPlainSetup, but soon to be more

4 days agoutil: Introduce virCryptoGenerateRandom
John Ferlan [Thu, 19 May 2016 17:05:36 +0000]
util: Introduce virCryptoGenerateRandom

Move the logic from qemuDomainGenerateRandomKey into this new
function, altering the comments, variable names, and error messages
to keep things more generic.

NB: Although perhaps more reasonable to add soemthing to virrandom.c.
    The virrandom.c was included in the setuid_rpc_client, so I chose
    placement in vircrypto.

4 days agoutil: Introduce encryption APIs
John Ferlan [Wed, 18 May 2016 15:29:06 +0000]
util: Introduce encryption APIs

Introduce virCryptoHaveCipher and virCryptoEncryptData to handle
performing encryption.

 virCryptoHaveCipher:
   Boolean function to determine whether the requested cipher algorithm
   is available. It's expected this API will be called prior to
   virCryptoEncryptdata. It will return true/false.

 virCryptoEncryptData:
   Based on the requested cipher type, call the specific encryption
   API to encrypt the data.

Currently the only algorithm support is the AES 256 CBC encryption.

Adjust tests for the API's

4 days agotests: Add mock for virRandomBytes
John Ferlan [Thu, 12 May 2016 16:15:44 +0000]
tests: Add mock for virRandomBytes

Create a mock for virRandomBytes to generate a not so random value.
This should be usable by other tests that need a not so random number
to be generated by including the virrandommock at preload.

The "random number" generated is based upon the size of the expected
stream of bytes being returned where each byte in the result gets
the index of the array - hence a 4 byte array returns 0x00010203.

4 days agoqemu: parse: Handle suffixes for -m memory
Nishith Shah [Fri, 20 May 2016 07:09:03 +0000]
qemu: parse: Handle suffixes for -m memory

According to QEMU docs, the '-m' option for specifying RAM is by default
in MiB, and a suffix of "M" or "G" may be passed for values in MiB and
GiB respectively. This commit adds support and a test for the same.

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

Signed-off-by: Nishith Shah <nishithshah.2211@gmail.com>

4 days agoqemu: parse: Use qemuParseCommandLineMem for -m memory
Nishith Shah [Fri, 20 May 2016 07:09:02 +0000]
qemu: parse: Use qemuParseCommandLineMem for -m memory

Move the parsing of -m memory to a new function, qemuParseCommandLineMem

Signed-off-by: Nishith Shah <nishithshah.2211@gmail.com>

4 days agoqemu_command: refactor spice channel code
Pavel Hrdina [Wed, 18 May 2016 10:39:34 +0000]
qemu_command: refactor spice channel code

This prepares the code for other listen types.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>

4 days agoqemu_process: separate graphics socket and address generation
Pavel Hrdina [Wed, 18 May 2016 11:27:28 +0000]
qemu_process: separate graphics socket and address generation

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>

4 days agographics: resolve address for listen type network in qemu_process
Pavel Hrdina [Wed, 18 May 2016 08:52:22 +0000]
graphics: resolve address for listen type network in qemu_process

Both VNC and SPICE requires the same code to resolve address for listen
type network.  Remove code duplication and create a new function that
will be used in qemuProcessSetupGraphics().

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>

4 days agoqemu_command: move sasl parameter after port and addr definition
Pavel Hrdina [Wed, 18 May 2016 07:23:22 +0000]
qemu_command: move sasl parameter after port and addr definition

This is required for following patches where new listen types will be
introduced.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>

4 days agodomain_conf: introduce virDomainGraphicsListenDefFormatAddr
Pavel Hrdina [Tue, 17 May 2016 13:22:26 +0000]
domain_conf: introduce virDomainGraphicsListenDefFormatAddr

Move code that decide whether we print the 'listen' attribute or not
into virDomainGraphicsListenDefFormatAddr() function.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>

4 days agographics: rename gListen to glisten
Pavel Hrdina [Tue, 17 May 2016 12:55:55 +0000]
graphics: rename gListen to glisten

We have both in the code.  Let's use only one format.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>

4 days agotests: cleanup vnc auto socket test
Pavel Hrdina [Thu, 19 May 2016 08:53:55 +0000]
tests: cleanup vnc auto socket test

Commit 55320c23 introduced a new test for VNC to test if
vnc_auto_unix_socket is set in qemu.conf, but forget to enable it in
qemuxml2argvtest.c.

This patch also moves the code in qemuxml2xmltest.c next to other VNC
tests and refactor the test so we also check the case for parsing active
XML.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>

4 days agoqemu_domain: add a empty listen type address if we remove socket for VNC
Pavel Hrdina [Thu, 19 May 2016 07:35:02 +0000]
qemu_domain: add a empty listen type address if we remove socket for VNC

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>

4 days agocpu: Fix documentation of cpuGetModels
Jiri Denemark [Fri, 29 Apr 2016 08:41:35 +0000]
cpu: Fix documentation of cpuGetModels

All callers of cpuGetModels expect @models to be NULL-terminated. Once
both x86GetModels and ppc64GetModels were fixed to meet this
expectation, we can explicitly document it.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>

4 days agocpu: Rework CPU map loading
Jiri Denemark [Tue, 17 May 2016 08:59:28 +0000]
cpu: Rework CPU map loading

The architecture specific loaders are now called with a list of all
elements of a given type (rather than a single element at a time). This
avoids the need to reallocate the arrays in CPU maps for each element.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>

4 days agocpu_ppc64: Use array of models in CPU map
Jiri Denemark [Wed, 18 May 2016 13:23:54 +0000]
cpu_ppc64: Use array of models in CPU map

There's no reason for keeping the models in a linked list. Especially
when we know upfront the total number of models we are loading.

As a nice side effect, this fixes ppc64GetModels to always return a
NULL-terminated list of models.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>

4 days agocpu_ppc64: Use array of vendors in CPU map
Jiri Denemark [Tue, 17 May 2016 13:56:53 +0000]
cpu_ppc64: Use array of vendors in CPU map

There's no reason for keeping the vendors in a linked list. Especially
when we know upfront the total number of models we are loading.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>

4 days agocpu_x86: Use array of features in CPU map
Jiri Denemark [Tue, 17 May 2016 13:15:40 +0000]
cpu_x86: Use array of features in CPU map

There's no reason for keeping the features in a linked list. Especially
when we know upfront the total number of features we are loading.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>

4 days agocpu_x86: Use array of vendors in CPU map
Jiri Denemark [Tue, 17 May 2016 12:30:18 +0000]
cpu_x86: Use array of vendors in CPU map

There's no reason for keeping the vendors in a linked list. Especially
when we know upfront the total number of models we are loading.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>

4 days agocpu_x86: Use array of models in CPU map
Jiri Denemark [Wed, 18 May 2016 13:24:05 +0000]
cpu_x86: Use array of models in CPU map

There's no reason for keeping the models in a linked list. Especially
when we know upfront the total number of models we are loading.

As a nice side effect, this fixes x86GetModels to always return a
NULL-terminated list of models.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>

4 days agodocs: fix <spice><gl enable> since version
Ján Tomko [Fri, 20 May 2016 07:14:02 +0000]
docs: fix <spice><gl enable> since version

The support was added by commit 937ebba which was released in
1.3.3.

4 days agoDo not mask QEMU_CAPS_DEVICE in qemuBuildDriveStr
Ján Tomko [Thu, 19 May 2016 17:25:33 +0000]
Do not mask QEMU_CAPS_DEVICE in qemuBuildDriveStr

For some disk types (SD), we want to emit the syntax
we used for disks before -device was available even
if QEMU supports -device.

Use the qemuDiskBusNeedsDeviceArg helper to figure out
whether to use the old or new syntax.

4 days agoIntroduce qemuDiskBusNeedsDeviceArg
Ján Tomko [Thu, 19 May 2016 18:40:00 +0000]
Introduce qemuDiskBusNeedsDeviceArg

Replace the two uses of the withDeviceArg bool in
qemuBuildDiskDriveCommandLine and allow this function to be reused in
qemuBuildDriveStr.

4 days agoAssume QEMU_CAPS_DEVICE in qemuBuildDiskDriveCommandLine
Ján Tomko [Thu, 19 May 2016 17:32:29 +0000]
Assume QEMU_CAPS_DEVICE in qemuBuildDiskDriveCommandLine

We no longer need to handle -usbdevice and the withDeviceArg
logic becomes clearer.

4 days agoRemove DISK_BUS_XEN support from qemuBuildDiskDriveCommandLine
Ján Tomko [Thu, 19 May 2016 18:22:51 +0000]
Remove DISK_BUS_XEN support from qemuBuildDiskDriveCommandLine

We have stopped supporting Xenner some time ago.

4 days agoqemu: always add -nodefaults
Ján Tomko [Thu, 19 May 2016 18:06:17 +0000]
qemu: always add -nodefaults

Since we always asumme support of QEMU_CAPS_DEVICE.

4 days agoqemu: process: Drop !QEMU_CAPS_DEVICE code
Cole Robinson [Fri, 22 Jan 2016 19:09:22 +0000]
qemu: process: Drop !QEMU_CAPS_DEVICE code

Nowadays we only support qemu 0.12.0+ which provides QEMU_CAPS_DEVICE,
so this is all dead code.

4 days agoRemove qemuProcessInitPCIAddresses with dependencies
Ján Tomko [Thu, 19 May 2016 16:56:35 +0000]
Remove qemuProcessInitPCIAddresses with dependencies

It was only called for QEMUs without QEMU_CAPS_DEVICE,
which we no longer support.

4 days agoqemu: driver: Fix function header alignment of some functions
Peter Krempa [Tue, 17 May 2016 08:46:50 +0000]
qemu: driver: Fix function header alignment of some functions

4 days agoconf: disk: Rename virDomainDiskDefValidate to virDomainDiskDefParseValidate
Peter Krempa [Tue, 17 May 2016 06:13:52 +0000]
conf: disk: Rename virDomainDiskDefValidate to virDomainDiskDefParseValidate

Name the validation function distinctively since it's called in the
parser. Later patches will add function that will validate disk
definitions that are invalid but need to be parsed to avoid losing
domains.

4 days agoutil: Remove need for STATIC_ANALYSIS check
John Ferlan [Tue, 17 May 2016 14:16:59 +0000]
util: Remove need for STATIC_ANALYSIS check

Seems recent versions of Coverity have (mostly) resolved the issue using
ternary operations in VIR_FREE (and now VIR_DISPOSE*) macros.  So let's
just remove it and if necessary handle one off issues as the arise.

4 days agoutil: Adjust return for virPCIGetDeviceAddressFromSysfsLink
John Ferlan [Tue, 17 May 2016 13:16:05 +0000]
util: Adjust return for virPCIGetDeviceAddressFromSysfsLink

Rather than return 0/-1 and/or a pointer to some memory, adjust the
helper to just return the allocated structure or NULL on failure.

Adjust the callers in order to handle that

Signed-off-by: John Ferlan <jferlan@redhat.com>

4 days agoutil: Remove need for ret in virPCIGetPhysicalFunction
John Ferlan [Tue, 17 May 2016 14:38:47 +0000]
util: Remove need for ret in virPCIGetPhysicalFunction

Since the callers only ever expect 0 or -1, let's just return that directly

Signed-off-by: John Ferlan <jferlan@redhat.com>

4 days agoutil: Fix error path for virPCIGetVirtualFunctions
John Ferlan [Tue, 17 May 2016 14:31:16 +0000]
util: Fix error path for virPCIGetVirtualFunctions

If we get to the error: label and clear out the *virtual_functions[]
pointers and then return w/ error to the caller - the caller has it's
own cleanup of the same array in the out: label which is keyed off the
value of num_virt_fns, which wasn't reset to 0 in the called function
leading to a possible problem.

Just clear the value (found by Coverity)

Signed-off-by: John Ferlan <jferlan@redhat.com>

4 days agotests: nodeinfotest: Remove virSaveLastError() usage
Cole Robinson [Thu, 19 May 2016 19:25:10 +0000]
tests: nodeinfotest: Remove virSaveLastError() usage

It's overkill here, we can use virGetLast* instead

4 days agoMore usage of virGetLastErrorMessage
Jovanka Gulicoska [Thu, 19 May 2016 19:10:19 +0000]
More usage of virGetLastErrorMessage

Convert to virGetLastErrorMessage() in the rest of the code

4 days agotests: More usage of virGetLastErrorMessage()
Jovanka Gulicoska [Thu, 19 May 2016 19:10:18 +0000]
tests: More usage of virGetLastErrorMessage()

Use virGetLastErrorMessage() instead of virGetLastError() in tests

5 days agotests: Add forgotten backslash
Michal Privoznik [Thu, 19 May 2016 16:50:52 +0000]
tests: Add forgotten backslash

While introducing virtestmock.la, I've forgotten to add '\' at
the end of one line leaving our Makefile.am mangled. Fortunately,
the only thing that comes after is '$(NULL)' so nothing is
terribly broken.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>

5 days agolxc: use job functions in lxcDomain* functions that perform modify actions.
Katerina Koukiou [Mon, 16 May 2016 21:36:54 +0000]
lxc: use job functions in lxcDomain* functions that perform modify actions.

Use the recently added job functions and unlock the virDomainObj while
performing the respective modify operation.
This commit affects lxcDomain{DestroyFlags, Reboot, SetBlkioParameters,
SetMemoryParameters, SetMetadata, SetSchedulerParameterFlags, ShutdownFlags}

Signed-off-by: Katerina Koukiou <k.koukiou@gmail.com>

5 days agolxc: use job functions in lxcDomain* functions that do query operations.
Katerina Koukiou [Mon, 16 May 2016 21:36:53 +0000]
lxc: use job functions in lxcDomain* functions that do query operations.

This commit affects lxcDomain{InterfaceStats, MemoryStats, BlockStats,
BlockStatsFlags}

Signed-off-by: Katerina Koukiou <k.koukiou@gmail.com>

5 days agolxc: add job functions in lxcDomainSetAutostart
Katerina Koukiou [Mon, 16 May 2016 21:36:52 +0000]
lxc: add job functions in lxcDomainSetAutostart

This operation isn't necessarily time consuming, but need to
wait in the queue of modify jobs.

Signed-off-by: Katerina Koukiou <k.koukiou@gmail.com>

5 days agolxc: use job functions in lxcDomain{AttachDeviceFlags, DetachDeviceFlags, UpdateDevic...
Katerina Koukiou [Mon, 16 May 2016 21:36:51 +0000]
lxc: use job functions in lxcDomain{AttachDeviceFlags, DetachDeviceFlags, UpdateDeviceFlags}

These operations aren't necessarily time consuming, but need to
wait in the queue of modify jobs.

Signed-off-by: Katerina Koukiou <k.koukiou@gmail.com>

5 days agolxc: use job functions in lxcDomain{Suspend, Resume}
Katerina Koukiou [Mon, 16 May 2016 21:36:50 +0000]
lxc: use job functions in lxcDomain{Suspend, Resume}

These operations aren't necessarily time consuming, but need to
wait in the queue of modify jobs.

Signed-off-by: Katerina Koukiou <k.koukiou@gmail.com>

5 days agolxc: use job functions in lxcDomainSetMemoryFlags
Katerina Koukiou [Mon, 16 May 2016 21:36:49 +0000]
lxc: use job functions in lxcDomainSetMemoryFlags

Large balloon operation can be time consuming.  Use the recently
added job functions and unlock the virDomainObj while ballooning.

Signed-off-by: Katerina Koukiou <k.koukiou@gmail.com>

5 days agolxc: use job functions in lxcDomain{CreateXMLWithFiles, CreateWithFiles}
Katerina Koukiou [Mon, 16 May 2016 21:36:48 +0000]
lxc: use job functions in lxcDomain{CreateXMLWithFiles, CreateWithFiles}

Creating a large domain could potentially be time consuming.  Use the
recently added job functions and unlock the virDomainObj while
the create operation is in progress.

Signed-off-by: Katerina Koukiou <k.koukiou@gmail.com>

5 days agolxc: Add job support to lxc driver
Katerina Koukiou [Mon, 16 May 2016 21:36:47 +0000]
lxc: Add job support to lxc driver

Follows the pattern used in the libxl driver for managing multiple,
simultaneous jobs within the driver.

Signed-off-by: Katerina Koukiou <k.koukiou@gmail.com>

5 days agoqemu: bulk stats: Don't access possibly blocked storage
Peter Krempa [Wed, 18 May 2016 12:58:25 +0000]
qemu: bulk stats: Don't access possibly blocked storage

If the stats for a block device can't be acquired from qemu we've
fallen back to loading them from the file on the disk in libvirt.

If qemu is not cooperating due to being stuck on an inaccessible NFS
share we would then attempt to read the files and get stuck too with
the VM object locked. All other APIs would eventually get stuck waiting
on the VM lock.

Avoid this problem by skipping the block stats if the VM is online but
the monitor did not provide any stats.

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

5 days agoqemu: driver: Separate bulk stats worker for block devices
Peter Krempa [Wed, 18 May 2016 12:40:10 +0000]
qemu: driver: Separate bulk stats worker for block devices

Extract the fallback path that reloads the stats from disk into a
separate function.

5 days agoqemu: driver: Remove unnecessary flag in qemuDomainGetStatsBlock
Peter Krempa [Wed, 18 May 2016 12:17:07 +0000]
qemu: driver: Remove unnecessary flag in qemuDomainGetStatsBlock

'abbreviated' was true if 'stats' were NULL

5 days agoperf: add support to perf event for MBM
Qiaowei Ren [Fri, 13 May 2016 04:26:07 +0000]
perf: add support to perf event for MBM

Some Intel processor families (e.g. the Intel Xeon processor E5 v3
family) introduced some RDT (Resource Director Technology) features
to monitor or control shared resource. Among these features, MBM
(Memory Bandwidth Monitoring), which is build on the CMT (Cache
Monitoring Technology) infrastructure, provides OS/VMM a way to
monitor bandwidth from one level of cache to another.

With current perf framework, this patch adds support to perf event
for MBM.

Signed-off-by: Qiaowei Ren <qiaowei.ren@intel.com>

5 days agoSeparate virDomainDefParseBootOptions
Ján Tomko [Wed, 11 May 2016 12:17:44 +0000]
Separate virDomainDefParseBootOptions

Split out parsing of most of the <os> subelements into a separate
function.

5 days agovz: cleanup: define vz format of uuids
Nikolay Shirokovskiy [Wed, 18 May 2016 08:11:08 +0000]
vz: cleanup: define vz format of uuids

vz puts uuids into curly braces. Simply introduce new contstant to reflect this
and get rid of magic +2 in code.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>

5 days agovz: implement p2p migration
Nikolay Shirokovskiy [Wed, 18 May 2016 08:11:07 +0000]
vz: implement p2p migration

Peer to peer migration is implemented just as in managed case. Basically
it is copy paste from managed case but with all the branches that are not
applied to vz removed.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>

5 days agovz: implement managed migration
Nikolay Shirokovskiy [Wed, 18 May 2016 08:11:06 +0000]
vz: implement managed migration

The newest version of migration protocol - version 3 with parameters is implemented.
Supported flags is VIR_MIGRATE_PAUSED only. Supported parameters are
VIR_MIGRATE_PARAM_URI and VIR_MIGRATE_PARAM_DEST_NAME. VIR_MIGRATE_PARAM_DEST_XML
is in VZ_MIGRATION_PARAMETERS for technical onyl reasons.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Signed-off-by: Maxim Nestratov <mnestratov@virtuozzo.com>

5 days agovz: fix const correctness case
Nikolay Shirokovskiy [Wed, 18 May 2016 08:11:05 +0000]
vz: fix const correctness case

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>