]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
8 years agoqemu: process: Fix and improve disk data extraction
Peter Krempa [Thu, 19 May 2016 13:29:02 +0000 (15:29 +0200)]
qemu: process: Fix and improve disk data extraction

Extract information for all disks and update tray state and source only
for removable drives. Additionally store whether a drive is removable
and whether it has a tray.

8 years agoqemu: Move and rename qemuDomainCheckEjectableMedia to qemuProcessRefreshDisks
Peter Krempa [Mon, 23 May 2016 12:00:35 +0000 (14:00 +0200)]
qemu: Move and rename qemuDomainCheckEjectableMedia to qemuProcessRefreshDisks

Move it to a more sane place since it's refreshing data about disks.

8 years agoqemu: Extract more information about qemu drives
Peter Krempa [Thu, 19 May 2016 12:57:41 +0000 (14:57 +0200)]
qemu: Extract more information about qemu drives

Extract whether a given drive has a tray and whether there is no image
inserted.

Negative logic for the image insertion is chosen so that the flag is set
only if we are certain of the fact.

8 years agoqemu: Move struct qemuDomainDiskInfo to qemu_domain.h
Peter Krempa [Fri, 20 May 2016 05:21:04 +0000 (07:21 +0200)]
qemu: Move struct qemuDomainDiskInfo to qemu_domain.h

8 years agoxenconfig: xm: check for driver on disk format
Joao Martins [Tue, 24 May 2016 10:56:08 +0000 (11:56 +0100)]
xenconfig: xm: check for driver on disk format

When reviewing libxl vif typename series[0] I found a bug
on xen-xm formatter where "virsh domxml-to-native xen-xm file.xml"
can lead to a NULL dereference if the disk driver isn't specified.
Fix this by checking for driver before writing/testing it down.

[0] https://www.redhat.com/archives/libvir-list/2016-April/msg01434.html

Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
8 years agolxc: support <interface type='ethernet'>
Laine Stump [Fri, 13 May 2016 17:20:54 +0000 (13:20 -0400)]
lxc: support <interface type='ethernet'>

This is identical to type='bridge', but without the "connect to a
bridge" part, so it can be handled by using the same functions (and
often even the same cases in switch statements), after renaming
virLXCProcessSetupInterfaceBridged() to virLXCProcessInterfaceTap()
and enhancing it to skip bridge-related items when brname == NULL.

To be truly useful, we need to support setting the ip address on the
host side veth as well as guest side veth (already supported for
type='bridge'), as well as setting the peer address for both.

The <script> element (supported by type='ethernet' in qemu) isn't
supported in this patch. An error is logged at domain start time if it
is encountered. This may be changed in a later patch.

8 years agolxc: completely rework reference counting
Katerina Koukiou [Fri, 20 May 2016 15:17:01 +0000 (18:17 +0300)]
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>
8 years agolxc: use job functions in lxcDomainLxcOpenNamespace & lxcDomainSendProcessSignal
Katerina Koukiou [Fri, 20 May 2016 15:15:01 +0000 (18:15 +0300)]
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>
8 years agoqemucapstest: update caps for qemu-2.6.0
Pavel Hrdina [Sun, 22 May 2016 21:24:25 +0000 (23:24 +0200)]
qemucapstest: update caps for qemu-2.6.0

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8 years agoqemucapstest: update caps for qemu-2.5.0
Pavel Hrdina [Sun, 22 May 2016 21:24:07 +0000 (23:24 +0200)]
qemucapstest: update caps for qemu-2.5.0

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8 years agoqemucapstest: update caps for qemu-2.4.0
Pavel Hrdina [Sun, 22 May 2016 21:23:47 +0000 (23:23 +0200)]
qemucapstest: update caps for qemu-2.4.0

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8 years agoqemucapstest: update caps for qemu-2.1.1
Pavel Hrdina [Sun, 22 May 2016 21:23:11 +0000 (23:23 +0200)]
qemucapstest: update caps for qemu-2.1.1

8 years agoqemucapstest: update caps for qemu-1.6.0
Pavel Hrdina [Sun, 22 May 2016 21:22:50 +0000 (23:22 +0200)]
qemucapstest: update caps for qemu-1.6.0

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8 years agoqemucapstest: update caps for qemu-1.5.3
Pavel Hrdina [Sun, 22 May 2016 21:22:18 +0000 (23:22 +0200)]
qemucapstest: update caps for qemu-1.5.3

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8 years agoqemucapstest: update caps for qemu-1.4.2
Pavel Hrdina [Sun, 22 May 2016 21:21:39 +0000 (23:21 +0200)]
qemucapstest: update caps for qemu-1.4.2

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8 years agoqemucapstest: update caps for qemu-1.3.1
Pavel Hrdina [Sun, 22 May 2016 21:21:09 +0000 (23:21 +0200)]
qemucapstest: update caps for qemu-1.3.1

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8 years agoqemucapstest: update caps for qemu-1.2.2
Pavel Hrdina [Sun, 22 May 2016 21:19:51 +0000 (23:19 +0200)]
qemucapstest: update caps for qemu-1.2.2

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8 years agonwfilter: fix lock order deadlock
Maxim Nestratov [Sat, 9 Apr 2016 16:14:30 +0000 (19:14 +0300)]
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>
8 years agomaint: fix syntax-check sc_prohibit_int_ijk exclude rule
Pavel Hrdina [Mon, 23 May 2016 23:00:07 +0000 (01:00 +0200)]
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>
8 years agomakefile: fix build on systems where gnutls is not in /usr/include
Pavel Hrdina [Sun, 22 May 2016 13:23:08 +0000 (15:23 +0200)]
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>
8 years agoqemuxml2argvtest: skip test that depends on gnutls_cipher_encrypt()
Pavel Hrdina [Sun, 22 May 2016 13:20:39 +0000 (15:20 +0200)]
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>
8 years agostorage: Replace VIR_ERROR with standard vir*Error in state driver init
Jovanka Gulicoska [Mon, 23 May 2016 18:36:01 +0000 (20:36 +0200)]
storage: Replace VIR_ERROR with standard vir*Error in state driver init

Replace VIR_ERROR with virReportError and virReportSystemError

8 years agonwfilter: Replace VIR_ERROR with standard vir*Error in state driver init
Jovanka Gulicoska [Mon, 23 May 2016 18:35:59 +0000 (20:35 +0200)]
nwfilter: Replace VIR_ERROR with standard vir*Error in state driver init

Replace VIR_ERROR with virReportError

8 years agolibxl: Replace VIR_ERROR with standard vir*Error in state driver init
Jovanka Gulicoska [Mon, 23 May 2016 18:35:57 +0000 (20:35 +0200)]
libxl: Replace VIR_ERROR with standard vir*Error in state driver init

Replace VIR_ERROR with virReportError

8 years agobhyve: Replace VIR_ERROR with standard vir*Error in state driver init
Jovanka Gulicoska [Mon, 23 May 2016 18:35:56 +0000 (20:35 +0200)]
bhyve: Replace VIR_ERROR with standard vir*Error in state driver init

Replace VIR_ERROR with virReportError

8 years agoqemu: simplify addition of USB controller in qemuParseCommandLine
Laine Stump [Tue, 10 May 2016 16:07:54 +0000 (12:07 -0400)]
qemu: simplify addition of USB controller in qemuParseCommandLine

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

8 years agovz: add error code for case if vm is already stopped
Mikhail Feoktistov [Sat, 21 May 2016 14:33:32 +0000 (10:33 -0400)]
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

8 years agoRevert "qemu_cgroup: allow access to /dev/dri for virtio-vga"
Ján Tomko [Thu, 19 May 2016 09:29:54 +0000 (11:29 +0200)]
Revert "qemu_cgroup: allow access to /dev/dri for virtio-vga"

This reverts commit 3943bdd60c7ff1de00e73f66d907664b74a88a3f.

8 years agostorage: do not clear vols before volume upload
Ján Tomko [Fri, 20 May 2016 09:42:56 +0000 (11:42 +0200)]
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.

8 years agoDeprecate QEMU_CAPS_PCIDEVICE
Ján Tomko [Fri, 20 May 2016 12:41:49 +0000 (14:41 +0200)]
Deprecate QEMU_CAPS_PCIDEVICE

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

Now it's unused.

8 years agoDeprecate QEMU_CAPS_DEVICE
Ján Tomko [Fri, 20 May 2016 12:33:58 +0000 (14:33 +0200)]
Deprecate QEMU_CAPS_DEVICE

We support qemu version 0.12.0+, which has it.

8 years agoDeprecate QEMU_CAPS_DRIVE_READONLY
Ján Tomko [Fri, 20 May 2016 12:25:22 +0000 (14:25 +0200)]
Deprecate QEMU_CAPS_DRIVE_READONLY

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

8 years agoqemu: always assume QEMU_CAPS_DRIVE_READONLY
Ján Tomko [Fri, 20 May 2016 11:29:54 +0000 (13:29 +0200)]
qemu: always assume QEMU_CAPS_DRIVE_READONLY

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

8 years agotests: always assume QEMU_CAPS_DRIVE_READONLY
Ján Tomko [Fri, 20 May 2016 11:49:15 +0000 (13:49 +0200)]
tests: always assume QEMU_CAPS_DRIVE_READONLY

8 years agotests: remove <readonly/> from IDE disks
Ján Tomko [Fri, 20 May 2016 11:50:40 +0000 (13:50 +0200)]
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.

8 years agotests: remove disk-drive-fat test
Ján Tomko [Fri, 20 May 2016 12:02:55 +0000 (14:02 +0200)]
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.

8 years agoqemu: assume QEMU_CAPS_DEVICE almost everywhere
Ján Tomko [Fri, 20 May 2016 11:22:26 +0000 (13:22 +0200)]
qemu: assume QEMU_CAPS_DEVICE almost everywhere

Remove more checks that are no longer necessary.

8 years agoqemu_command: assume QEMU_CAPS_DEVICE
Ján Tomko [Fri, 20 May 2016 11:08:45 +0000 (13:08 +0200)]
qemu_command: assume QEMU_CAPS_DEVICE

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

8 years agoutil: fix build without GNUTLS
Mikhail Feoktistov [Sat, 21 May 2016 14:22:06 +0000 (10:22 -0400)]
util: fix build without GNUTLS

8 years agotests: qemu: test <address type='pci'/> with aarch64
Cole Robinson [Sun, 15 May 2016 19:11:29 +0000 (15:11 -0400)]
tests: qemu: test <address type='pci'/> with aarch64

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

8 years agoqemu: auto-assign addresses when <address type='pci'/> is specified
Laine Stump [Tue, 17 May 2016 18:08:13 +0000 (14:08 -0400)]
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

8 years agobhyve: auto-assign addresses when <address type='pci'/> is specified
Laine Stump [Tue, 17 May 2016 18:06:36 +0000 (14:06 -0400)]
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.

8 years agoconf: allow type='pci' addresses with no address attributes specified
Laine Stump [Tue, 17 May 2016 18:03:00 +0000 (14:03 -0400)]
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.

8 years agoconf: new functions to check if PCI address is wanted/present
Laine Stump [Wed, 18 May 2016 16:04:42 +0000 (12:04 -0400)]
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.

8 years agoconf: move virDomainDeviceInfo definition from domain_conf.h to device_conf.h
Laine Stump [Tue, 17 May 2016 17:55:02 +0000 (13:55 -0400)]
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).

8 years agotests: Link virtestmock with probes
Michal Privoznik [Wed, 18 May 2016 13:31:54 +0000 (15:31 +0200)]
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>
8 years agovirtestmock: Mock stat() properly
Michal Privoznik [Tue, 17 May 2016 14:26:53 +0000 (16:26 +0200)]
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>
8 years agotests: Drop VIR_MOCK_CALL_STAT
Michal Privoznik [Mon, 16 May 2016 15:15:46 +0000 (17:15 +0200)]
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>
8 years agoqemu: Utilize qemu secret objects for RBD auth/secret
John Ferlan [Mon, 11 Apr 2016 15:26:14 +0000 (11:26 -0400)]
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.

8 years agotests: Allow multiple mock libraries
Peter Krempa [Fri, 20 May 2016 14:27:00 +0000 (16:27 +0200)]
tests: Allow multiple mock libraries

Make virtTestMain take variable number of libraries to mock.

8 years agoqemu: Introduce qemuDomainSecretSetup
John Ferlan [Wed, 18 May 2016 22:46:40 +0000 (18:46 -0400)]
qemu: Introduce qemuDomainSecretSetup

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

8 years agoutil: Introduce virCryptoGenerateRandom
John Ferlan [Thu, 19 May 2016 17:05:36 +0000 (13:05 -0400)]
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.

8 years agoutil: Introduce encryption APIs
John Ferlan [Wed, 18 May 2016 15:29:06 +0000 (11:29 -0400)]
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

8 years agotests: Add mock for virRandomBytes
John Ferlan [Thu, 12 May 2016 16:15:44 +0000 (12:15 -0400)]
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.

8 years agoqemu: parse: Handle suffixes for -m memory
Nishith Shah [Fri, 20 May 2016 07:09:03 +0000 (07:09 +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>
8 years agoqemu: parse: Use qemuParseCommandLineMem for -m memory
Nishith Shah [Fri, 20 May 2016 07:09:02 +0000 (07:09 +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>
8 years agoqemu_command: refactor spice channel code
Pavel Hrdina [Wed, 18 May 2016 10:39:34 +0000 (12:39 +0200)]
qemu_command: refactor spice channel code

This prepares the code for other listen types.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8 years agoqemu_process: separate graphics socket and address generation
Pavel Hrdina [Wed, 18 May 2016 11:27:28 +0000 (13:27 +0200)]
qemu_process: separate graphics socket and address generation

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8 years agographics: resolve address for listen type network in qemu_process
Pavel Hrdina [Wed, 18 May 2016 08:52:22 +0000 (10:52 +0200)]
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>
8 years agoqemu_command: move sasl parameter after port and addr definition
Pavel Hrdina [Wed, 18 May 2016 07:23:22 +0000 (09:23 +0200)]
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>
8 years agodomain_conf: introduce virDomainGraphicsListenDefFormatAddr
Pavel Hrdina [Tue, 17 May 2016 13:22:26 +0000 (15:22 +0200)]
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>
8 years agographics: rename gListen to glisten
Pavel Hrdina [Tue, 17 May 2016 12:55:55 +0000 (14:55 +0200)]
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>
8 years agotests: cleanup vnc auto socket test
Pavel Hrdina [Thu, 19 May 2016 08:53:55 +0000 (10:53 +0200)]
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>
8 years agoqemu_domain: add a empty listen type address if we remove socket for VNC
Pavel Hrdina [Thu, 19 May 2016 07:35:02 +0000 (09:35 +0200)]
qemu_domain: add a empty listen type address if we remove socket for VNC

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8 years agocpu: Fix documentation of cpuGetModels
Jiri Denemark [Fri, 29 Apr 2016 08:41:35 +0000 (10:41 +0200)]
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>
8 years agocpu: Rework CPU map loading
Jiri Denemark [Tue, 17 May 2016 08:59:28 +0000 (10:59 +0200)]
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>
8 years agocpu_ppc64: Use array of models in CPU map
Jiri Denemark [Wed, 18 May 2016 13:23:54 +0000 (15:23 +0200)]
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>
8 years agocpu_ppc64: Use array of vendors in CPU map
Jiri Denemark [Tue, 17 May 2016 13:56:53 +0000 (15:56 +0200)]
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>
8 years agocpu_x86: Use array of features in CPU map
Jiri Denemark [Tue, 17 May 2016 13:15:40 +0000 (15:15 +0200)]
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>
8 years agocpu_x86: Use array of vendors in CPU map
Jiri Denemark [Tue, 17 May 2016 12:30:18 +0000 (14:30 +0200)]
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>
8 years agocpu_x86: Use array of models in CPU map
Jiri Denemark [Wed, 18 May 2016 13:24:05 +0000 (15:24 +0200)]
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>
8 years agodocs: fix <spice><gl enable> since version
Ján Tomko [Fri, 20 May 2016 07:14:02 +0000 (09:14 +0200)]
docs: fix <spice><gl enable> since version

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

8 years agoDo not mask QEMU_CAPS_DEVICE in qemuBuildDriveStr
Ján Tomko [Thu, 19 May 2016 17:25:33 +0000 (19:25 +0200)]
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.

8 years agoIntroduce qemuDiskBusNeedsDeviceArg
Ján Tomko [Thu, 19 May 2016 18:40:00 +0000 (20:40 +0200)]
Introduce qemuDiskBusNeedsDeviceArg

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

8 years agoAssume QEMU_CAPS_DEVICE in qemuBuildDiskDriveCommandLine
Ján Tomko [Thu, 19 May 2016 17:32:29 +0000 (19:32 +0200)]
Assume QEMU_CAPS_DEVICE in qemuBuildDiskDriveCommandLine

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

8 years agoRemove DISK_BUS_XEN support from qemuBuildDiskDriveCommandLine
Ján Tomko [Thu, 19 May 2016 18:22:51 +0000 (20:22 +0200)]
Remove DISK_BUS_XEN support from qemuBuildDiskDriveCommandLine

We have stopped supporting Xenner some time ago.

8 years agoqemu: always add -nodefaults
Ján Tomko [Thu, 19 May 2016 18:06:17 +0000 (20:06 +0200)]
qemu: always add -nodefaults

Since we always asumme support of QEMU_CAPS_DEVICE.

8 years agoqemu: process: Drop !QEMU_CAPS_DEVICE code
Cole Robinson [Fri, 22 Jan 2016 19:09:22 +0000 (14:09 -0500)]
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.

8 years agoRemove qemuProcessInitPCIAddresses with dependencies
Ján Tomko [Thu, 19 May 2016 16:56:35 +0000 (18:56 +0200)]
Remove qemuProcessInitPCIAddresses with dependencies

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

8 years agoqemu: driver: Fix function header alignment of some functions
Peter Krempa [Tue, 17 May 2016 08:46:50 +0000 (10:46 +0200)]
qemu: driver: Fix function header alignment of some functions

8 years agoconf: disk: Rename virDomainDiskDefValidate to virDomainDiskDefParseValidate
Peter Krempa [Tue, 17 May 2016 06:13:52 +0000 (08:13 +0200)]
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.

8 years agoutil: Remove need for STATIC_ANALYSIS check
John Ferlan [Tue, 17 May 2016 14:16:59 +0000 (10:16 -0400)]
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.

8 years agoutil: Adjust return for virPCIGetDeviceAddressFromSysfsLink
John Ferlan [Tue, 17 May 2016 13:16:05 +0000 (09:16 -0400)]
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>
8 years agoutil: Remove need for ret in virPCIGetPhysicalFunction
John Ferlan [Tue, 17 May 2016 14:38:47 +0000 (10:38 -0400)]
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>
8 years agoutil: Fix error path for virPCIGetVirtualFunctions
John Ferlan [Tue, 17 May 2016 14:31:16 +0000 (10:31 -0400)]
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>
8 years agotests: nodeinfotest: Remove virSaveLastError() usage
Cole Robinson [Thu, 19 May 2016 19:25:10 +0000 (15:25 -0400)]
tests: nodeinfotest: Remove virSaveLastError() usage

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

8 years agoMore usage of virGetLastErrorMessage
Jovanka Gulicoska [Thu, 19 May 2016 19:10:19 +0000 (21:10 +0200)]
More usage of virGetLastErrorMessage

Convert to virGetLastErrorMessage() in the rest of the code

8 years agotests: More usage of virGetLastErrorMessage()
Jovanka Gulicoska [Thu, 19 May 2016 19:10:18 +0000 (21:10 +0200)]
tests: More usage of virGetLastErrorMessage()

Use virGetLastErrorMessage() instead of virGetLastError() in tests

8 years agotests: Add forgotten backslash
Michal Privoznik [Thu, 19 May 2016 16:50:52 +0000 (18:50 +0200)]
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>
8 years agolxc: use job functions in lxcDomain* functions that perform modify actions.
Katerina Koukiou [Mon, 16 May 2016 21:36:54 +0000 (00:36 +0300)]
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>
8 years agolxc: use job functions in lxcDomain* functions that do query operations.
Katerina Koukiou [Mon, 16 May 2016 21:36:53 +0000 (00:36 +0300)]
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>
8 years agolxc: add job functions in lxcDomainSetAutostart
Katerina Koukiou [Mon, 16 May 2016 21:36:52 +0000 (00:36 +0300)]
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>
8 years agolxc: use job functions in lxcDomain{AttachDeviceFlags, DetachDeviceFlags, UpdateDevic...
Katerina Koukiou [Mon, 16 May 2016 21:36:51 +0000 (00:36 +0300)]
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>
8 years agolxc: use job functions in lxcDomain{Suspend, Resume}
Katerina Koukiou [Mon, 16 May 2016 21:36:50 +0000 (00:36 +0300)]
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>
8 years agolxc: use job functions in lxcDomainSetMemoryFlags
Katerina Koukiou [Mon, 16 May 2016 21:36:49 +0000 (00:36 +0300)]
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>
8 years agolxc: use job functions in lxcDomain{CreateXMLWithFiles, CreateWithFiles}
Katerina Koukiou [Mon, 16 May 2016 21:36:48 +0000 (00:36 +0300)]
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>
8 years agolxc: Add job support to lxc driver
Katerina Koukiou [Mon, 16 May 2016 21:36:47 +0000 (00:36 +0300)]
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>
8 years agoqemu: bulk stats: Don't access possibly blocked storage
Peter Krempa [Wed, 18 May 2016 12:58:25 +0000 (14:58 +0200)]
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

8 years agoqemu: driver: Separate bulk stats worker for block devices
Peter Krempa [Wed, 18 May 2016 12:40:10 +0000 (14:40 +0200)]
qemu: driver: Separate bulk stats worker for block devices

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

8 years agoqemu: driver: Remove unnecessary flag in qemuDomainGetStatsBlock
Peter Krempa [Wed, 18 May 2016 12:17:07 +0000 (14:17 +0200)]
qemu: driver: Remove unnecessary flag in qemuDomainGetStatsBlock

'abbreviated' was true if 'stats' were NULL