]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
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

8 years agoperf: add support to perf event for MBM
Qiaowei Ren [Fri, 13 May 2016 04:26:07 +0000 (12:26 +0800)]
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>
8 years agoSeparate virDomainDefParseBootOptions
Ján Tomko [Wed, 11 May 2016 12:17:44 +0000 (14:17 +0200)]
Separate virDomainDefParseBootOptions

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

8 years agovz: cleanup: define vz format of uuids
Nikolay Shirokovskiy [Wed, 18 May 2016 08:11:08 +0000 (11:11 +0300)]
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>
8 years agovz: implement p2p migration
Nikolay Shirokovskiy [Wed, 18 May 2016 08:11:07 +0000 (11:11 +0300)]
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>
8 years agovz: implement managed migration
Nikolay Shirokovskiy [Wed, 18 May 2016 08:11:06 +0000 (11:11 +0300)]
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>
8 years agovz: fix const correctness case
Nikolay Shirokovskiy [Wed, 18 May 2016 08:11:05 +0000 (11:11 +0300)]
vz: fix const correctness case

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
8 years agovz: save session uuid on login
Nikolay Shirokovskiy [Wed, 18 May 2016 08:11:04 +0000 (11:11 +0300)]
vz: save session uuid on login

This session uuid acts as authN token for different multihost vz operations one
of which is migration. Unfortunately we can't get it from server at any time
thus we need to save it at login.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
8 years agovirt-admin: Introduce commands srv-clients-info and srv-clients-set
Erik Skultety [Sat, 9 Apr 2016 16:49:44 +0000 (18:49 +0200)]
virt-admin: Introduce commands srv-clients-info and srv-clients-set

Finally wire-up virAdmServer{Get,Set}ClientLimits APIs into virt-admin client.
Update the virt-admin's man page accordingly.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
8 years agoadmin: Introduce virAdmServerSetClientLimits
Erik Skultety [Mon, 4 Apr 2016 12:24:52 +0000 (14:24 +0200)]
admin: Introduce virAdmServerSetClientLimits

Opposite operation to virAdmServerGetClientLimits. Understandably though,
setting values for current number of clients connected or still waiting
for authentication does not make sense, since changes to these values are event
dependent, i.e. a client connects - counter is increased. Thus only the limits
to maximum clients connected and waiting for authentication can be set. Should
a request for other controls to be set arrive (provided such a setting will
be first introduced to the config), the set of configuration controls can be
later expanded (thanks to typed params). This patch also introduces a
constraint that the maximum number of clients waiting for authentication has to
be less than the overall maximum number of clients connected and any attempt to
violate this constraint will be denied.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
8 years agoadmin: Introduce virAdmServerGetClientLimits
Erik Skultety [Mon, 4 Apr 2016 08:28:22 +0000 (10:28 +0200)]
admin: Introduce virAdmServerGetClientLimits

Enable retrieval of the number of maximum clients connected to all sockets
combined, as well as the number of maximum clients waiting for authentication,
in order to be successfully connected. These are the attributes configurable
through libvirtd.conf, however, it could be handy to not only know values for
these limits, but also the values for the current number of clients
connected and number of clients currently waiting for authentication which are
changing dynamically. This API does both, retrieves the limits as well as the
current dynamic values.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
8 years agoadmin: Introduce some public constants related to server's client limits
Erik Skultety [Wed, 11 May 2016 10:05:15 +0000 (12:05 +0200)]
admin: Introduce some public constants related to server's client limits

In order for typed params validation to pass on daemon side, we should
encourage users to use our exported constants with typed params to diminish
to avoid any potential problems related to argument validity.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
8 years agovirnetserver: Introduce server's client-related limits getters
Erik Skultety [Sat, 9 Apr 2016 17:07:11 +0000 (19:07 +0200)]
virnetserver: Introduce server's client-related limits getters

Add some trivial getters for client related attributes to virnetserver before
any admin method can be introduced.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
8 years agoqemu_cgroup: allow access to /dev/dri for virtio-vga
Ján Tomko [Thu, 19 May 2016 07:29:17 +0000 (09:29 +0200)]
qemu_cgroup: allow access to /dev/dri for virtio-vga

QEMU needs access to the /dev/dri/render* device for
virgl to work.

Allow access to all /dev/dri/* devices for domains with
<video>
  <model type='virtio' heads='1' primary='yes'>
    <acceleration accel3d='yes'/>
  </model>
</video>

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

8 years agoqemu: address: Remove QEMU_CAPS_DEVICE usage
Cole Robinson [Sat, 14 May 2016 20:36:16 +0000 (16:36 -0400)]
qemu: address: Remove QEMU_CAPS_DEVICE usage

All qemu versions we support have QEMU_CAPS_DEVICE, so checking
for it is redundant. Remove the usage.

The code diff isn't clear, but all that code is just inindented
with no other change.

Test cases that hit qemuDomainAssignAddresses but don't have
infrastructure for specifying qemuCaps values see lots of
churn, since now PCI addresses are in the XML output.

8 years agotests: qemuargv2xmltest: Drop disk for s390 aes tests
Cole Robinson [Sat, 14 May 2016 21:28:44 +0000 (17:28 -0400)]
tests: qemuargv2xmltest: Drop disk for s390 aes tests

Upcoming patches are going to make the disk portion of these
test cases fail. In order to make it work, we would need to
extend the qemuargv2xml test infrastructure to handle qemuCaps.
This is worthwhile to do at some point but isn't critical.

Instead just drop the offending portion, which isn't even the
target of the test cases anyways

8 years agoqemu: Call virDomainDefPostParse via CONFIG hotplug
Cole Robinson [Sat, 14 May 2016 19:14:44 +0000 (15:14 -0400)]
qemu: Call virDomainDefPostParse via CONFIG hotplug

hotplug APIs with the AFFECT_CONFIG flag are essentially replicating
'insert <device> into XML document, and redefine XML'. Thinking of
it this way, it's natural that we call virDomainDefPostParse after
manually editing the XML here.

Not only does doing so allow us to drop a bunch of open coded calls
to qemuDomainAssignAddresses, but it also means we are going through
the standard channels for XML validation and potentially catching
errors in user submitted XML.

8 years agoqemu: Assign device addresses in PostParse
Cole Robinson [Sat, 14 May 2016 18:52:45 +0000 (14:52 -0400)]
qemu: Assign device addresses in PostParse

This wires up qemuDomainAssignAddresses into the new
virDomainDefAssignAddressesCallback, so it's always triggered
via virDomainDefPostParse. We are essentially doing this already
with open coded calls sprinkled about.

qemu argv parse output changes slightly since previously it wasn't
hitting qemuDomainAssignAddresses.

8 years agodomain: Add virDomainDefAssignAddressesCallback
Cole Robinson [Sat, 14 May 2016 18:47:23 +0000 (14:47 -0400)]
domain: Add virDomainDefAssignAddressesCallback

This will be called at the end of virDomainDefPostParse to
allow hypervisor drivers to fill in device addresses.

8 years agoRevert "qemu_hotplug: fix checking graphics ports"
Pavel Hrdina [Mon, 16 May 2016 10:59:12 +0000 (12:59 +0200)]
Revert "qemu_hotplug: fix checking graphics ports"

This reverts commit 1ccc7fbff34ea44e5b0cf01a359d127a4c62a695.

We cannot check ports if autoport is set because we set ports to 0 while
parsing device XML.

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

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8 years agovz: drop prlsdkDomainHasSnapshots
Nikolay Shirokovskiy [Mon, 2 May 2016 09:33:08 +0000 (12:33 +0300)]
vz: drop prlsdkDomainHasSnapshots

Let's use introduced domain snapshots infrastructure instead.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
8 years agovz: add domain snapshots functionality
Nikolay Shirokovskiy [Mon, 2 May 2016 09:33:07 +0000 (12:33 +0300)]
vz: add domain snapshots functionality

This solution does not keep snapshots cache because vz sdk lacks good support
for snapshot related events.

Libvirt and vz sdk has different approach to snapshot ids. vz sdk always
auto generate them while libvirt has ability to specify id by user.
Thus I have no other choice rather than simply ignore ids set by user
or generated by libvirt.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Signed-off-by: Maxim Nestratov <mnestratov@virtuozzo.com>
8 years agoiscsi: Remove initiatoriqn from virISCSIScanTargets
John Ferlan [Fri, 13 May 2016 15:38:45 +0000 (11:38 -0400)]
iscsi: Remove initiatoriqn from virISCSIScanTargets

No longer necessary to have it, so remove it.

8 years agoutil: Remove disabling of autologin for iscsi-targets
Fritz Elfert [Fri, 13 May 2016 15:19:09 +0000 (11:19 -0400)]
util: Remove disabling of autologin for iscsi-targets

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

Instead of disabling auto-login of all scsi targets (even those
that do not "belong" to libvirt), use iscsiadm's "--op nonpersistent"
during discovery of iSCSI targets (e.g. "iscsiadm --mode discovery
--type sendtargets") in order to avoid the node database being altered
which led to the need for the "large hammer" approach taken by
commit id '3c12b654'.

This commit removes the virISCSITargetAutologin adjustment (eg. the setting
of node.startup to "manual"). The iscsiadm command has supported this mode
of operation as of commit id 'ad873767' to open-iscsi.

8 years agoiscsi: Add exit status checking for virISCSIGetSession
John Ferlan [Fri, 13 May 2016 17:25:30 +0000 (13:25 -0400)]
iscsi: Add exit status checking for virISCSIGetSession

Utilize the exit status parameter for virCommandRunRegex in order to
check the return error from the 'iscsiadm --mode session' command.
Without this enabled, if there are no sessions running then virCommandRun
would have displayed an error such as:

    2016-05-13 15:17:15.165+0000: 10920: error : virCommandWait:2553 :
               internal error: Child process (iscsiadm --mode session)
               unexpected exit status 21: iscsiadm: No active sessions.

It is possible that for certain paths (when probe is true) we only care
whether it's running or not to make certain decisions.  Spitting out
the error for those paths is unnecessary.

If we do have a situation where probe = false and there's an error,
then display the error from iscsiadm if it's there.

8 years agoutil: Add exitstatus parameter to virCommandRunRegex
John Ferlan [Fri, 13 May 2016 16:36:39 +0000 (12:36 -0400)]
util: Add exitstatus parameter to virCommandRunRegex

Rather than have virCommandRun just spit out the error, allow callers
to decide to pass the exitstatus so the caller can make intelligent
decisions based on the error.

8 years agotests: Try different usable GIC versions
Andrea Bolognani [Tue, 10 May 2016 10:36:10 +0000 (12:36 +0200)]
tests: Try different usable GIC versions

The only case where the hardware capabilities influence the result
is when no <gic/> element was provided.

The test programs now ensure both that the correct GIC version is
picked in that case, and that hardware capabilities are not taken
into account when the user has already picked a GIC version.

8 years agotests: Prepare to have different usable GIC versions
Andrea Bolognani [Tue, 10 May 2016 09:35:43 +0000 (11:35 +0200)]
tests: Prepare to have different usable GIC versions

Now that we choose the GIC version based on hardware features when
no <gic/> element has been provided, we need a way to fake the GIC
capabilities of the host.

Update the qemuxml2argv and qemuxml2xml tests to allow this.

8 years agoqemu: Add virQEMUCapsSetGICCapabilities()
Andrea Bolognani [Tue, 10 May 2016 08:50:34 +0000 (10:50 +0200)]
qemu: Add virQEMUCapsSetGICCapabilities()

For use in the test suite.

8 years agoqemu: Automatically choose usable GIC version
Andrea Bolognani [Mon, 9 May 2016 13:38:55 +0000 (15:38 +0200)]
qemu: Automatically choose usable GIC version

When the <gic/> element in not present in the domain XML, use the
domain capabilities to figure out what GIC version is usable and
choose that one automatically.

This allows guests to be created on hardware that only supports
GIC v3 without having to update virt-manager and similar tools.

Keep using the default GIC version if the <gic/> element has been
added to the domain XML but no version has been specified, as not
to break existing guests.