]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
8 years agoqemu: convert to typesafe virConf accessors
Daniel P. Berrange [Fri, 8 Jul 2016 10:37:54 +0000 (11:37 +0100)]
qemu: convert to typesafe virConf accessors

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
8 years agolibvirtd: convert to typesafe virConf accessors
Daniel P. Berrange [Fri, 8 Jul 2016 10:37:40 +0000 (11:37 +0100)]
libvirtd: convert to typesafe virConf accessors

The libvirtdconftest was previously used to test data type
handling of the libvirtd config file. Now we're using the
typedef APIs, this test case has little value, and is pretty
hard to fixup with deal with the new APIs.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
8 years agovirconf: add typed value accessor methods
Daniel P. Berrange [Thu, 7 Jul 2016 15:52:47 +0000 (16:52 +0100)]
virconf: add typed value accessor methods

Currently many users of virConf APIs are defining the same
macros for calling virConfValue() and then doing type
checking. To remove this repeated code, add a set of
typesafe accessor methods.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
8 years agovirconf: fix off-by-1 when appending \n to config file
Daniel P. Berrange [Fri, 8 Jul 2016 13:47:20 +0000 (14:47 +0100)]
virconf: fix off-by-1 when appending \n to config file

If the config file does not end with a \n, the parser will append
one. When re-allocating the array though, it is mistakenly assuming
that 'len' is the length including the trailing NUL, but it does
not. So we must add 2 to len, when reallocating, not 1.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
8 years agotests: remove pointless virconftest.sh wrapper
Daniel P. Berrange [Thu, 7 Jul 2016 14:39:00 +0000 (15:39 +0100)]
tests: remove pointless virconftest.sh wrapper

The virconftest is different from all our other tests in that
the C program only tests a single in/out config file pair. It
relies on a shell wrapper to invoke it once for each test
file.

This gets rid of the shell wrapper and makes the C program
actually run over each test file using the normal test pattern.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
8 years agoqemuhotplugtest: Move domain and device XMLs to different directories
Tomasz Flendrich [Thu, 7 Jul 2016 22:53:19 +0000 (00:53 +0200)]
qemuhotplugtest: Move domain and device XMLs to different directories

This way we can safely differentiate what XMLs contain whole domain
definitions and which contain just devices.  Thanks to that we can
test the domain XMLs in virschematest again.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
8 years agoqemuhotplugtest: Move all XMLs to one directory
Tomasz Flendrich [Thu, 7 Jul 2016 22:52:41 +0000 (00:52 +0200)]
qemuhotplugtest: Move all XMLs to one directory

This makes the search for related XMLs easier, plus they are not used in
the xml2argv tests anyway.  This also makes future patches cleaner.
While on that remove unnecessary '-hotplug' from the filenames.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
8 years agoqemuxml2argvmock: Don't leak @netdef->ifname
Michal Privoznik [Sat, 9 Jul 2016 06:57:46 +0000 (08:57 +0200)]
qemuxml2argvmock: Don't leak @netdef->ifname

In the mock, we have a stub for virNetDevTapCreate(). However,
the mocked version does not exactly as it's native counterpart.
The function receives a string, which is an interface name that
caller would like to have, but it's not guaranteed that they will
get just that one. If they don't, the function free()-s the one
passed and returns the new one. Just like the mocked version. But
what is the mocked version missing is the free().

==1068== 6 bytes in 1 blocks are definitely lost in loss record 9 of 132
==1068==    at 0x4C29F80: malloc (vg_replace_malloc.c:296)
==1068==    by 0xDE13356: xmlStrndup (in /usr/lib64/libxml2.so.2.9.4)
==1068==    by 0xAE2333E: virXMLPropString (virxml.c:479)
==1068==    by 0xAE45975: virDomainNetDefParseXML (domain_conf.c:9038)
==1068==    by 0xAE5C0BB: virDomainDefParseXML (domain_conf.c:16734)
==1068==    by 0xAE5EB96: virDomainDefParseNode (domain_conf.c:17444)
==1068==    by 0xAE5EA05: virDomainDefParse (domain_conf.c:17391)
==1068==    by 0xAE5EA93: virDomainDefParseFile (domain_conf.c:17415)
==1068==    by 0x433430: testCompareXMLToArgvFiles (qemuxml2argvtest.c:278)
==1068==    by 0x433A18: testCompareXMLToArgvHelper (qemuxml2argvtest.c:414)
==1068==    by 0x446ED4: virTestRun (testutils.c:179)
==1068==    by 0x43A099: mymain (qemuxml2argvtest.c:1016)

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agoqemuxml2argvtest: Don't leak dummy monitor
Michal Privoznik [Fri, 8 Jul 2016 21:45:22 +0000 (23:45 +0200)]
qemuxml2argvtest: Don't leak dummy monitor

It's just test, but why leak it?

==26971== 20 bytes in 1 blocks are definitely lost in loss record 623 of 704
==26971==    at 0x4C29F80: malloc (vg_replace_malloc.c:296)
==26971==    by 0xE560447: vasprintf (vasprintf.c:76)
==26971==    by 0xAE0DEE2: virVasprintfInternal (virstring.c:480)
==26971==    by 0xAE0DFF7: virAsprintfInternal (virstring.c:501)
==26971==    by 0x4751F3: qemuProcessPrepareMonitorChr (qemu_process.c:2651)
==26971==    by 0x4334B1: testCompareXMLToArgvFiles (qemuxml2argvtest.c:297)
==26971==    by 0x4339AC: testCompareXMLToArgvHelper (qemuxml2argvtest.c:413)
==26971==    by 0x446E7A: virTestRun (testutils.c:179)
==26971==    by 0x445D33: mymain (qemuxml2argvtest.c:2029)
==26971==    by 0x44886F: virTestMain (testutils.c:969)
==26971==    by 0x445D9B: main (qemuxml2argvtest.c:2036)

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agoqemuDomainObjPrivateFree: Free @masterKey too
Michal Privoznik [Fri, 8 Jul 2016 21:37:24 +0000 (23:37 +0200)]
qemuDomainObjPrivateFree: Free @masterKey too

This one's a bit more complicated. In qemuProcessPrepareDomain()
a master key for encrypting secret for ciphered disks is created.
This object lives within qemuDomainObjPrivate object. It is freed
in qemuProcessStop(), but if nobody calls it (for instance like
our qemuxml2argvtest does), the key object leaks.

==17078== 32 bytes in 1 blocks are definitely lost in loss record 633 of 707
==17078==    at 0x4C2C070: calloc (vg_replace_malloc.c:623)
==17078==    by 0xAD924DF: virAllocN (viralloc.c:191)
==17078==    by 0x5050BA6: virCryptoGenerateRandom (qemuxml2argvmock.c:166)
==17078==    by 0x453DC8: qemuDomainMasterKeyCreate (qemu_domain.c:678)
==17078==    by 0x47A36B: qemuProcessPrepareDomain (qemu_process.c:4913)
==17078==    by 0x47C728: qemuProcessCreatePretendCmd (qemu_process.c:5542)
==17078==    by 0x433698: testCompareXMLToArgvFiles (qemuxml2argvtest.c:332)
==17078==    by 0x4339AC: testCompareXMLToArgvHelper (qemuxml2argvtest.c:413)
==17078==    by 0x446E7A: virTestRun (testutils.c:179)
==17078==    by 0x445BD9: mymain (qemuxml2argvtest.c:2022)
==17078==    by 0x44886F: virTestMain (testutils.c:969)
==17078==    by 0x445D9B: main (qemuxml2argvtest.c:2036)

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agoqemuBuildCpuCommandLine: Don't leak @buf
Michal Privoznik [Fri, 8 Jul 2016 16:17:35 +0000 (18:17 +0200)]
qemuBuildCpuCommandLine: Don't leak @buf

Just like every other qemuBuild*CommandLine() function, this uses
a buffer to hold partial cmd line strings too. However, if
there's an error, the control jumps to 'cleanup' label leaving
the buffer behind and thus leaking it.

==2013== 1,006 bytes in 1 blocks are definitely lost in loss record 701 of 711
==2013==    at 0x4C29F80: malloc (vg_replace_malloc.c:296)
==2013==    by 0x4C2C32F: realloc (vg_replace_malloc.c:692)
==2013==    by 0xAD925A8: virReallocN (viralloc.c:245)
==2013==    by 0xAD95EA8: virBufferGrow (virbuffer.c:130)
==2013==    by 0xAD95F78: virBufferAdd (virbuffer.c:165)
==2013==    by 0x5097F5: qemuBuildCpuModelArgStr (qemu_command.c:6339)
==2013==    by 0x509CC3: qemuBuildCpuCommandLine (qemu_command.c:6437)
==2013==    by 0x51142C: qemuBuildCommandLine (qemu_command.c:9174)
==2013==    by 0x47CA3A: qemuProcessCreatePretendCmd (qemu_process.c:5546)
==2013==    by 0x433698: testCompareXMLToArgvFiles (qemuxml2argvtest.c:332)
==2013==    by 0x4339AC: testCompareXMLToArgvHelper (qemuxml2argvtest.c:413)
==2013==    by 0x446E7A: virTestRun (testutils.c:179)

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agovirStorageEncryptionSecretFree: Don't leak secret lookup definition
Michal Privoznik [Fri, 8 Jul 2016 16:09:40 +0000 (18:09 +0200)]
virStorageEncryptionSecretFree: Don't leak secret lookup definition

When storage secret is parsed in virStorageEncryptionSecretParse(),
virSecretLookupParseSecret() which allocates some memory. This is
however never freed.

==21711== 134 bytes in 6 blocks are definitely lost in loss record 70 of 85
==21711==    at 0x4C29F80: malloc (vg_replace_malloc.c:296)
==21711==    by 0xBCA0356: xmlStrndup (in /usr/lib64/libxml2.so.2.9.4)
==21711==    by 0xA9F432E: virXMLPropString (virxml.c:479)
==21711==    by 0xA9D25B0: virSecretLookupParseSecret (virsecret.c:70)
==21711==    by 0xA9D616E: virStorageEncryptionSecretParse (virstorageencryption.c:172)
==21711==    by 0xA9D66B2: virStorageEncryptionParseXML (virstorageencryption.c:281)
==21711==    by 0xA9D68DF: virStorageEncryptionParseNode (virstorageencryption.c:338)
==21711==    by 0xAA12575: virDomainDiskDefParseXML (domain_conf.c:7606)
==21711==    by 0xAA2CAC6: virDomainDefParseXML (domain_conf.c:16658)
==21711==    by 0xAA2FC75: virDomainDefParseNode (domain_conf.c:17472)
==21711==    by 0xAA2FAE4: virDomainDefParse (domain_conf.c:17419)
==21711==    by 0xAA2FB72: virDomainDefParseFile (domain_conf.c:17443)

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agovirsh: allow both --uuid and --name at same time
Chen Hanxiao [Sat, 9 Jul 2016 10:06:55 +0000 (18:06 +0800)]
virsh: allow both --uuid and --name at same time

#virsh list --uuid --name
49c765a0-25e7-40d0-964f-dac99724b32c   c7
918f1dd6-b19f-412b-ba17-d113bad89af8   f23

Signed-off-by: Chen Hanxiao <chenhanxiao@gmail.com>
8 years agoqemu: Use qemuProcessSetupPid() in qemuProcessSetupVcpu()
Martin Kletzander [Mon, 4 Jul 2016 15:14:55 +0000 (17:14 +0200)]
qemu: Use qemuProcessSetupPid() in qemuProcessSetupVcpu()

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
8 years agoqemu: Use qemuProcessSetupPid() in qemuProcessSetupEmulator()
Martin Kletzander [Mon, 4 Jul 2016 15:14:43 +0000 (17:14 +0200)]
qemu: Use qemuProcessSetupPid() in qemuProcessSetupEmulator()

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
8 years agoqemu: Add qemuProcessSetupPid() and use it in qemuProcessSetupIOThread()
Martin Kletzander [Tue, 21 Jun 2016 15:33:06 +0000 (17:33 +0200)]
qemu: Add qemuProcessSetupPid() and use it in qemuProcessSetupIOThread()

Setting up cgroups and other things for all kinds of threads (the
emulator thread, vCPU threads, I/O threads) was copy-pasted every time
new thing was added.  Over time each one of those functions changed a
bit differently.  So create one function that does all that setup and
start using it, starting with I/O thread setup.  That will shave some
duplicated code and maybe fix some bugs as well.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
8 years agoFix logic in qemuDomainObjPrivateXMLParseVcpu
Daniel P. Berrange [Mon, 11 Jul 2016 09:30:03 +0000 (10:30 +0100)]
Fix logic in qemuDomainObjPrivateXMLParseVcpu

The code in qemuDomainObjPrivateXMLParseVcpu for parsing
the 'idstr' string was comparing the overall boolean
result against 0 which was always true

qemu/qemu_domain.c: In function 'qemuDomainObjPrivateXMLParseVcpu':
qemu/qemu_domain.c:1482:59: error: comparison of constant '0' with boolean expression is always false [-Werror=bool-compare]
     if ((idstr && virStrToLong_uip(idstr, NULL, 10, &idx)) < 0 ||
                                                           ^

It was further performing two distinct error checks in
the same conditional and reporting a single error message,
which was misleading in one of the two cases.

This splits the conditional check into two parts with
distinct error messages and fixes the logic error.

Fixes the bug in

  commit 5184f398b40a5e0d7d84b86182edcb2b48ab04ba
  Author: Peter Krempa <pkrempa@redhat.com>
  Date:   Fri Jul 1 14:56:14 2016 +0200

    qemu: Store vCPU thread ids in vcpu private data objects

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
8 years agoqemu: capabilities: Make virHostCPUGetKVMMaxVCPUs() errors fatal
Andrea Bolognani [Mon, 27 Jun 2016 11:53:43 +0000 (13:53 +0200)]
qemu: capabilities: Make virHostCPUGetKVMMaxVCPUs() errors fatal

An error in virHostCPUGetKVMMaxVCPUs() means we've been unable
to access /dev/kvm, or we're running on a platform that doesn't
support KVM in the first place.

If that's the case, we shouldn't ignore the error and report
domcapabilities even though we know the user won't be able to
start any KVM guest.

8 years agoutil: hostcpu: Drop obsolete compatibility code
Andrea Bolognani [Fri, 24 Jun 2016 17:34:37 +0000 (19:34 +0200)]
util: hostcpu: Drop obsolete compatibility code

All Linux releases we support (RHEL6 era) include these
definitions.

8 years agoutil: hostcpu: Add virHostCPUGetKVMMaxVCPUs() stub
Andrea Bolognani [Mon, 27 Jun 2016 11:47:53 +0000 (13:47 +0200)]
util: hostcpu: Add virHostCPUGetKVMMaxVCPUs() stub

If we don't HAVE_LINUX_KVM_H, we can't query /dev/kvm to discover
the limits on the number of vCPUs, so we report an error and
return a negative value instead.

8 years agoqemu: Store vCPU thread ids in vcpu private data objects
Peter Krempa [Fri, 1 Jul 2016 12:56:14 +0000 (14:56 +0200)]
qemu: Store vCPU thread ids in vcpu private data objects

Rather than storing them in an external array store them directly.

8 years agoqemu: Add cpu ID to the vCPU pid list in the status XML
Peter Krempa [Thu, 30 Jun 2016 13:06:46 +0000 (15:06 +0200)]
qemu: Add cpu ID to the vCPU pid list in the status XML

Note the vcpu ID so that once we allow non-contiguous vCPU topologies it
will be possible to pair thread id's with the vcpus.

8 years agoqemu: domain: Extract formating and parsing of vCPU thread ids
Peter Krempa [Thu, 30 Jun 2016 08:35:12 +0000 (10:35 +0200)]
qemu: domain: Extract formating and parsing of vCPU thread ids

Further patches will be adding index and modifying the source variables
so this will make it more clear.

8 years agoqemu: domain: Add vcpu private data structure
Peter Krempa [Wed, 29 Jun 2016 13:40:09 +0000 (15:40 +0200)]
qemu: domain: Add vcpu private data structure

Members will be added in follow-up patches.

8 years agoconf: Add private data for virDomainVcpuDef
Peter Krempa [Wed, 29 Jun 2016 12:55:24 +0000 (14:55 +0200)]
conf: Add private data for virDomainVcpuDef

Allow to store driver specific data on a per-vcpu basis.

Move of the virDomainDef*Vcpus* functions was necessary as
virDomainXMLOptionPtr was declared below this block and I didn't want to
split the function headers.

8 years agoconf: convert def->vcpus to a array of pointers
Peter Krempa [Wed, 29 Jun 2016 12:08:33 +0000 (14:08 +0200)]
conf: convert def->vcpus to a array of pointers

8 years agotests: qemuxml2xml: Format status XML header dynamically
Peter Krempa [Fri, 1 Jul 2016 08:30:53 +0000 (10:30 +0200)]
tests: qemuxml2xml: Format status XML header dynamically

Status XML tests were done by prepending a constant string to an
existing XML. With the planned changes the header will depend on data
present in the definition rather than just on the data that was parsed.

The first dynamic element in the header will be the vcpu thread list.
Reuse and rename qemuXML2XMLPreFormatCallback for gathering the relevant
data when checking the active XML parsing and formating and pass the
bitmap to a newly crated header generator.

8 years agoconf: Don't report errors from virDomainDefGetVcpu
Peter Krempa [Thu, 30 Jun 2016 07:26:04 +0000 (09:26 +0200)]
conf: Don't report errors from virDomainDefGetVcpu

Most callers make sure that it's never called with an out of range vCPU.
Every other caller reports a different error explicitly. Drop the error
reporting and clean up some dead code paths.

8 years agoconf: Rename virDomainVcpuInfoPtr to virDomainVcpuDefPtr
Peter Krempa [Wed, 29 Jun 2016 11:16:22 +0000 (13:16 +0200)]
conf: Rename virDomainVcpuInfoPtr to virDomainVcpuDefPtr

8 years agoconf: Extract code formatting vCPU info
Peter Krempa [Tue, 14 Jun 2016 09:35:39 +0000 (11:35 +0200)]
conf: Extract code formatting vCPU info

8 years agoconf: Annotate that private data for objects are not copied
Peter Krempa [Fri, 1 Jul 2016 14:38:31 +0000 (16:38 +0200)]
conf: Annotate that private data for objects are not copied

Our copy functions format and parse XML thus are not able to copy data.
Annotate the private data pointers that this is happening.

8 years agovirsh: Introduce vshReadlineParse for improved auto-completion
Nishith Shah [Fri, 8 Jul 2016 12:56:05 +0000 (18:26 +0530)]
virsh: Introduce vshReadlineParse for improved auto-completion

The new function works as expected, and matches the current level of
autocomplete offered, along with several other improvements like quotes
handling, multiple command completion and space handling. Now, it is easy
to introduce options completer here.

Signed-off-by: Nishith Shah <nishithshah.2211@gmail.com>
8 years agovirsh: Add option to suppress error in various functions
Nishith Shah [Fri, 8 Jul 2016 12:56:04 +0000 (18:26 +0530)]
virsh: Add option to suppress error in various functions

A bool 'report' has been introduced in various functions, which when set
to true will produce the error it is suppposed to produce, and when
false, will suppress the error. These functions are used in the next
patch for auto-completion.

Signed-off-by: Nishith Shah <nishithshah.2211@gmail.com>
8 years agovirsh: Fix variable types in readline generators
Nishith Shah [Fri, 8 Jul 2016 12:56:03 +0000 (18:26 +0530)]
virsh: Fix variable types in readline generators

Use unsigned int for array indexes and size_t for length variables.

Signed-off-by: Nishith Shah <nishithshah.2211@gmail.com>
8 years agovirsh: Break vshCmddefOptParse into helper functions
Nishith Shah [Fri, 8 Jul 2016 12:56:02 +0000 (18:26 +0530)]
virsh: Break vshCmddefOptParse into helper functions

Decompose vshCmddefOptParse into two helper functions, vshCmddefOptFill
and vshCmddefCheckInternals.

vshCmddefCheckInternals checks if the internal command definitions are
correct or not.

vshCmddefOptFill keeps track of the required options and mandatory
arguments through opts_required and opts_need_arg.

Signed-off-by: Nishith Shah <nishithshah.2211@gmail.com>
8 years agobhyve: implement virConnectGetDomainCapabilities
Fabian Freyer [Fri, 8 Jul 2016 18:53:33 +0000 (20:53 +0200)]
bhyve: implement virConnectGetDomainCapabilities

8 years agobhyve: fix bhyveargv2xml custom loader test
Roman Bogorodskiy [Sun, 10 Jul 2016 21:58:43 +0000 (00:58 +0300)]
bhyve: fix bhyveargv2xml custom loader test

Before pushing this test, I changed the appropriate args file
to pet test-wrap-argv.pl, but forgot to change the xml file, so
update it accordingly.

8 years agobhyve: add tests for bhyveParseCommandLineString
Fabian Freyer [Fri, 24 Jun 2016 18:41:20 +0000 (18:41 +0000)]
bhyve: add tests for bhyveParseCommandLineString

8 years agobhyve: implement argument parser for loader
Fabian Freyer [Wed, 1 Jun 2016 08:03:05 +0000 (10:03 +0200)]
bhyve: implement argument parser for loader

A simple getopt-based argument parser is added for the /usr/sbin/bhyveload
command, loosely based on its argument parser.

The boot disk is guessed by iterating over all
disks and matching their sources. If any non-default arguments are found,
def->os.bootloaderArgs is set accordingly, and the bootloader is treated as a
custom bootloader.

Custom bootloader are supported by setting the def->os.bootloader and
def->os.bootloaderArgs accordingly

grub-bhyve is also treated as a custom bootloader. Since we don't get the
device map in the native format anyways, we can't reconstruct the complete
boot order. While it is possible to check what type the grub boot disk is by
checking if the --root argument is "cd" or "hd0,msdos1", and then just use the
first disk found, implementing the grub-bhyve argument parser as-is in the
grub-bhyve source would mean adding a dependency to argp or duplicating lots
of the code of argp. Therefore it's not really worth implementing that now.

Signed-off-by: Fabian Freyer <fabian.freyer@physik.tu-berlin.de>
8 years agobhyve: implement bhyve argument parser
Fabian Freyer [Wed, 1 Jun 2016 08:01:17 +0000 (10:01 +0200)]
bhyve: implement bhyve argument parser

A simpe getopt-based argument parser is added for the /usr/sbin/bhyve command,
loosely based on its argument parser, which reads the following from the bhyve
command line string:

* vm name
* number of vcpus
* memory size
* the time offset (UTC or localtime)
* features:
  * acpi
  * ioapic: While this flag is deprecated in FreeBSD r257423, keep checking for
    it for backwards compatibiility.
* the domain UUID; if not explicitely given, one will be generated.
* lpc devices: for now only the com1 and com2 are supported. It is required for
   these to be /dev/nmdm[\d+][AB], and the slave devices are automatically
   inferred from these to be the corresponding end of the virtual null-modem
   cable: /dev/nmdm<N>A <-> /dev/nmdm<N>B
* PCI devices:
  * Disks: these are numbered in the order they are found, for virtio and ahci
    disks separately. The destination is set to sdX or vdX with X='a'+index;
    therefore only 'z'-'a' disks are supported.
    Disks are considered to be block devices if the path
    starts with /dev, otherwise they are considered to be files.
  * Networks: only tap devices are supported. Since it isn't possible to tell
    the type of the network, VIR_DOMAIN_NET_TYPE_ETHERNET is assumed, since it
    is the most generic. If no mac is specified, one will be generated.

Signed-off-by: Fabian Freyer <fabian.freyer@physik.tu-berlin.de>
8 years agobhyve: implement virConnectDomainXMLFromNative
Fabian Freyer [Wed, 1 Jun 2016 07:57:43 +0000 (09:57 +0200)]
bhyve: implement virConnectDomainXMLFromNative

First, remove escaped newlines and split up the string into an argv-list for
the bhyve and loader commands, respectively. This is done by iterating over the
string splitting it by newlines, and then re-iterating over each line,
splitting it by spaces.

Since this code reuses part of the code of qemu_parse_command.c
(in bhyveCommandLine2argv), add the appropriate copyright notices.

Signed-off-by: Fabian Freyer <fabian.freyer@physik.tu-berlin.de>
8 years agognulib: add getopt module
Fabian Freyer [Thu, 9 Jun 2016 00:50:35 +0000 (00:50 +0000)]
gnulib: add getopt module

Unconditionally use gnulib's getopt module. This is needed by the bhyve driver
to provide a reentrant interface for getopt.

Several gnulib headers rely on features.h being included by ctype.h to provide
__GNUC_PREREQ, but on systems without glibc, this is not provided. In these
cases __GNUC_PREREQ gets redefined to 0, which causes build errors from checks
in src/internal.h.
Therefore, define __GNUC_PREREQ as early as possible. config-post.h is probably
the first header that is included, before any other headers.

8 years agotests: Add test cases for the empty bitmap
Marc Hartmayer [Wed, 6 Jul 2016 12:02:28 +0000 (14:02 +0200)]
tests: Add test cases for the empty bitmap

As the empty bitmap exists, we should also test it. This patch adds
test cases for the procedures 'virBitmapNextSetBit', 'virBitmapLastSetBit',
'virBitmapNextClearBit'.

Tested-by: Sascha Silbe <silbe@linux.vnet.ibm.com>
Reviewed-by: Sascha Silbe <silbe@linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
8 years agoutil: bitmap: Mention the size == 0 handling
Marc Hartmayer [Wed, 6 Jul 2016 12:02:27 +0000 (14:02 +0200)]
util: bitmap: Mention the size == 0 handling

As there is an explicit constructor for the special case of empty
bitmaps, we should mention that the generic constructors rejects the
creation of empty bitmaps.

Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Reviewed-by: Sascha Silbe <silbe@linux.vnet.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.vnet.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
8 years agoutil: bitmap: clarify virBitmapLastSetBit() behavior for empty bitmaps
Marc Hartmayer [Wed, 6 Jul 2016 12:02:26 +0000 (14:02 +0200)]
util: bitmap: clarify virBitmapLastSetBit() behavior for empty bitmaps

Before the variable 'bits' was initialized with 0 (commit
3470cd860d517760b13e26d97b6a842ff72687a1), the following bug was
possible.

A function call with an empty bitmap leads to undefined
behavior. Because if 'bitmap->map_len == 0' 'unusedBits' will be <= 0
and 'sz == 1'. So the non global and non static variable 'bits' would
have never been set. Consequently the check 'bits == 0' results in
undefined behavior.

This patch clarifies the current version of the function by handling the
empty bitmap explicitly. Also, for an empty bitmap there is obviously no
bit set so we can just return -1 (indicating no bit set) right away. The
explicit check for 'bits == 0' after the loop is unnecessary because we
only get to this point if no set bit was found.

Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Reviewed-by: Sascha Silbe <silbe@linux.vnet.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.vnet.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
8 years agotests: env perl shebang for test-wrap-argv.pl
Fabian Freyer [Fri, 8 Jul 2016 18:47:04 +0000 (20:47 +0200)]
tests: env perl shebang for test-wrap-argv.pl

On some systems perl is not necessarily in /usr/bin/perl. Use the perl version
in the PATH instead.

8 years agoqemu: Drop useless SPICE migration code
Jiri Denemark [Wed, 29 Jun 2016 13:01:17 +0000 (15:01 +0200)]
qemu: Drop useless SPICE migration code

The spiceMigration flag will never be true if there is no SPICE graphics
configured for the domain.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agoqemu: Properly reset spiceMigration flag
Jiri Denemark [Tue, 5 Jul 2016 08:07:24 +0000 (10:07 +0200)]
qemu: Properly reset spiceMigration flag

Otherwise migration during which we didn't send client_migrate_info QMP
command will get stuck waiting for SPICE migration to finish if libvirtd
sent the QMP command in a previous migration attempt.

Broken by bd7c8a69.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agovirtlogd: increase max file size to 2 MB
Daniel P. Berrange [Fri, 1 Jul 2016 16:42:37 +0000 (17:42 +0100)]
virtlogd: increase max file size to 2 MB

People debugging guest OS boot processes and reported that
the default 128 KB size is too small to capture an entire
boot up sequence. Increase the default size to 2 MB which
should allow capturing a full boot up even with verbose
debugging.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
8 years agovirtlogd: make max file size & number of backups configurable
Daniel P. Berrange [Fri, 1 Jul 2016 16:40:55 +0000 (17:40 +0100)]
virtlogd: make max file size & number of backups configurable

Currently virtlogd has a hardcoded max file size of 128kb
and max of 3 backups. This adds two new config parameters
to /etc/libvirt/virtlogd.conf to let these be customized.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
8 years agoqemu: caps: Always assume QEMU_CAPS_SMP_TOPOLOGY
Peter Krempa [Thu, 23 Jun 2016 11:29:16 +0000 (13:29 +0200)]
qemu: caps: Always assume QEMU_CAPS_SMP_TOPOLOGY

Support for SMP topology was added by qemu commit dc6b1c09849484fbbc50
prior to 0.12.0, our minimum supported qemu version.

$ git describe --tags dc6b1c09849484fbbc50803307e4c7a3d81eab62
v0.11.0-rc0-449-gdc6b1c0
$ git describe --tags --contains dc6b1c09849484fbbc50803307e4c7a3d81eab
v0.12.0-rc0~1477

8 years agovirDomainHostdevDefFree: Don't leak privateData
Michal Privoznik [Thu, 7 Jul 2016 09:37:36 +0000 (11:37 +0200)]
virDomainHostdevDefFree: Don't leak privateData

After 27726d8c21 a privateData is allocated in
virDomainHostdevDefAlloc(). However, the counter part - freeing
them in Free() is missing which leads to the following memory
leak:

==6489== 24 bytes in 1 blocks are definitely lost in loss record 684 of 1,003
==6489==    at 0x4C2C070: calloc (vg_replace_malloc.c:623)
==6489==    by 0x54B7C94: virAllocVar (viralloc.c:560)
==6489==    by 0x5517BE6: virObjectNew (virobject.c:193)
==6489==    by 0x1B400121: qemuDomainHostdevPrivateNew (qemu_domain.c:798)
==6489==    by 0x5557B24: virDomainHostdevDefAlloc (domain_conf.c:2152)
==6489==    by 0x5575578: virDomainHostdevDefParseXML (domain_conf.c:12709)
==6489==    by 0x5582292: virDomainDefParseXML (domain_conf.c:16995)
==6489==    by 0x5583C98: virDomainDefParseNode (domain_conf.c:17470)
==6489==    by 0x5583B07: virDomainDefParse (domain_conf.c:17417)
==6489==    by 0x5583B95: virDomainDefParseFile (domain_conf.c:17441)
==6489==    by 0x55A3F24: virDomainObjListLoadConfig (virdomainobjlist.c:465)
==6489==    by 0x55A43E6: virDomainObjListLoadAllConfigs (virdomainobjlist.c:596)

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agoqemu: generate -display none
Paolo Bonzini [Tue, 5 Jul 2016 12:35:28 +0000 (14:35 +0200)]
qemu: generate -display none

This is preferrable to -nographic which (in addition to disabling
graphics output) redirects the serial port to stdio and on OpenBIOS
enables the firmware's serial console.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
8 years agoqemu: detect -display
Paolo Bonzini [Tue, 5 Jul 2016 12:35:27 +0000 (14:35 +0200)]
qemu: detect -display

Add a new capability for the -display command line option, which has
been present since QEMU 1.0.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
8 years agoconf: Isolate virDomainLiveConfigHelperMethod to libxl only
Peter Krempa [Fri, 1 Jul 2016 14:27:31 +0000 (16:27 +0200)]
conf: Isolate virDomainLiveConfigHelperMethod to libxl only

Libxl is the last user and I don't have the toolchain prepared to
compile the libxl driver. Move it to the libxl driver to avoid having to
refactor the code.

8 years agoconf: Don't use virDomainLiveConfigHelperMethod in virDomainObjGetMetadata
Peter Krempa [Fri, 1 Jul 2016 14:19:58 +0000 (16:19 +0200)]
conf: Don't use virDomainLiveConfigHelperMethod in virDomainObjGetMetadata

Few arguments of the function are not necessary any more which leads to
some cleanups. The 'uri' argument had a stray ATTRIBUTE_UNUSED.

8 years agoconf: Don't use virDomainLiveConfigHelperMethod in virDomainObjSetMetadata
Peter Krempa [Fri, 1 Jul 2016 14:19:58 +0000 (16:19 +0200)]
conf: Don't use virDomainLiveConfigHelperMethod in virDomainObjSetMetadata

8 years agoopenvz: Remove use of virDomainLiveConfigHelperMethod
Peter Krempa [Fri, 1 Jul 2016 14:07:51 +0000 (16:07 +0200)]
openvz: Remove use of virDomainLiveConfigHelperMethod

8 years agolxc: Synchronize implementation of qemuDomainSetMemoryParameters
Peter Krempa [Fri, 1 Jul 2016 14:01:26 +0000 (16:01 +0200)]
lxc: Synchronize implementation of qemuDomainSetMemoryParameters

The impls are identical and I don't have a reasonable idea where to
extract it.

This also kills yet another use of virDomainLiveConfigHelperMethod.

8 years agoqemu: driver: Make name of QEMU_SET_MEM_PARAMETER more universal
Peter Krempa [Fri, 1 Jul 2016 13:55:09 +0000 (15:55 +0200)]
qemu: driver: Make name of QEMU_SET_MEM_PARAMETER more universal

Use a VIR_ prefix even when it's a local helper macro. It will be later
synced with the LXC implementation.

8 years agospec: Move virt-admin into its own package
Michal Privoznik [Mon, 27 Jun 2016 08:15:21 +0000 (10:15 +0200)]
spec: Move virt-admin into its own package

The new package for the virt-admin binary is libvirt-admin.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agospec: Split libvirt-client
Michal Privoznik [Sat, 25 Jun 2016 06:37:22 +0000 (08:37 +0200)]
spec: Split libvirt-client

Currently, we have libvirt-client library which serves as a
collection point for all the libraries and client binaries we
have. Therefore we have couple of silly dependencies, for
instance libvirt-daemon depends on libvirt-client. Only because
the shared library is in the client package.
To solve this, new package libvirt-libs is introduced where all
the libraries are going to live. The client package is then set
to depend on this new package, just like the rest of packages
that suffer the same problem.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agovirlog: Introduce virLogFilterListFree
Erik Skultety [Tue, 29 Mar 2016 20:07:23 +0000 (22:07 +0200)]
virlog: Introduce virLogFilterListFree

This is just a convenience method for discarding a list of filters instead of
using a 'for' loop everywhere. It is safe to pass -1 as the number of elements
in the list as well as passing NULL as list reference.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
8 years agovirlog: Introduce virLogFilterFree
Erik Skultety [Mon, 4 Jul 2016 10:16:36 +0000 (12:16 +0200)]
virlog: Introduce virLogFilterFree

Provide a separate method to free a logging filter object. This will come handy
once a method to create an individual logging filter object is introduced.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
8 years agovirlog: Introduce virLogOutputListFree
Erik Skultety [Wed, 30 Mar 2016 12:11:12 +0000 (14:11 +0200)]
virlog: Introduce virLogOutputListFree

This is just a convenience method for discarding a list of outputs instead of
using a 'for' loop everywhere. It is safe to pass -1 as the number of elements
in the list as well as passing NULL as list reference.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
8 years agovirlog: Introduce virLogOutputFree
Erik Skultety [Mon, 4 Jul 2016 10:19:38 +0000 (12:19 +0200)]
virlog: Introduce virLogOutputFree

Provide a separate method to free a logging output object. This will come handy
once a method to create an individual logging output object is introduced.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
8 years agovirlog: Convert virLogFilters to a list of pointers to filters
Erik Skultety [Tue, 29 Mar 2016 13:54:08 +0000 (15:54 +0200)]
virlog: Convert virLogFilters to a list of pointers to filters

Same as with outputs; since the operations will be further divided into smaller
tasks, creating a filter will become a separate operation that will return
a reference to a newly created filter.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
8 years agovirlog: Convert virLogOutputs to a list of pointers to outputs
Erik Skultety [Thu, 17 Mar 2016 13:52:57 +0000 (14:52 +0100)]
virlog: Convert virLogOutputs to a list of pointers to outputs

Right now, we define outputs one after another. However, the correct flow
should be to define a set of outputs as a whole unit. Therefore each output
should be first created, placed into an array/list and the list will be
defined. Output creation should be a separate operation, so an output will be
returned by a reference. From that perspective, it makes perfect sense to
only store pointers to actual outputs.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
8 years agovirlog: Return void instead of int in virLogReset<Foo> methods
Erik Skultety [Wed, 30 Mar 2016 10:25:35 +0000 (12:25 +0200)]
virlog: Return void instead of int in virLogReset<Foo> methods

In this particular case, reset is meant as clearing the whole list of
outputs/filters, not resetting it to a predefined default setting. Looking at
it from that perspective, returning the number of records removed doesn't help
the caller in any way (not that any of the callers would actually check for
it). Well, callers could detect an error from the number of successfully
removed records, but the only thing that can fail in virLogReset is force
closing a file descriptor in which case the error isn't propagated back to
virLogReset anyway. Conclusion: there is no practical use for having a return
type of 'int' rather than 'void' in this case.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
8 years agoqemu: Memory locking is only required for KVM guests on ppc64
Andrea Bolognani [Wed, 29 Jun 2016 08:22:32 +0000 (10:22 +0200)]
qemu: Memory locking is only required for KVM guests on ppc64

Due to the way the hardware works, KVM on ppc64 always requires
memory locking; however, that is not the case for non-KVM ppc64
guests, eg. ppc64 guests that are running on x86_64 with TCG.

Only require memory locking for ppc64 guests if they are using
KVM or, as it's the case for all architectures, they have host
devices assigned using VFIO.

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

8 years agomaint: update to latest gnulib
Martin Kletzander [Mon, 4 Jul 2016 07:46:12 +0000 (09:46 +0200)]
maint: update to latest gnulib

Fix mingw build regarding rpl_{printf,scanf} symbols.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
8 years agoqemu: support setting host-side IP addresses/routes
Laine Stump [Tue, 21 Jun 2016 16:00:45 +0000 (12:00 -0400)]
qemu: support setting host-side IP addresses/routes

For type='ethernet' interfaces only.

(This patch had been pushed earlier in
commit 0b4645a7e061abc8a4be71fe89865cf248ce6e56, but was reverted in
commit 84d47a3cce71175bc1d8af596f835f66f38a190c because it had been
accidentally pushed during the freeze for release 2.0.0)

8 years agolxc: support setting host-side IP addresses/routes
Laine Stump [Fri, 17 Jun 2016 18:52:48 +0000 (14:52 -0400)]
lxc: support setting host-side IP addresses/routes

(This patch had been pushed earlier in
commit cd5c9f21ded4f8e6216eba02b8795f70503ab404, but was reverted in
commit 1549f16832ca23918b651fb4985a2e9f257cd429 because it had been
accidentally pushed during the freeze for release 2.0.0)

8 years agoutil: support setting peer for virNetDevIPInfo addresses
Laine Stump [Fri, 10 Jun 2016 16:37:37 +0000 (12:37 -0400)]
util: support setting peer for virNetDevIPInfo addresses

This will apply to any IP address setting that uses
virNetDevIPInfoAddToDev() (which so far is only the guest-side of LXC
type='ethernet' interfaces).

(This patch had been pushed earlier in
commit cb20f989df393ec97ba65afb06089d0ab87af484, but was reverted in
commit cba06aea8d500d4ea7e2f40272be484027dd3e4a because it had been
accidentally pushed during the freeze for release 2.0.0)

8 years agoconf: support host-side IP/route information in <interface>
Laine Stump [Thu, 9 Jun 2016 19:35:08 +0000 (15:35 -0400)]
conf: support host-side IP/route information in <interface>

This is place as a sub-element of <source>, where other aspects of the
host-side connection to the network device are located (network or
bridge name, udp listen port, etc). It's a bit odd that the interface
we're configuring with this info is itself named in <target dev='x'/>,
but that ship sailed long ago:

    <interface type='ethernet'>
      <mac address='00:16:3e:0f:ef:8a'/>
      <source>
        <ip address='192.168.122.12' family='ipv4'
            prefix='24' peer='192.168.122.1'/>
        <ip address='192.168.122.13' family='ipv4' prefix='24'/>
        <route family='ipv4' address='0.0.0.0'
               gateway='192.168.122.1'/>
        <route family='ipv4' address='192.168.124.0' prefix='24'
               gateway='192.168.124.1'/>
      </source>
    </interface>

In practice, this will likely only be useful for type='ethernet', so
its presence in any other type of interface is currently forbidden in
the generic device Validate function (but it's been put into the
general population of virDomainNetDef rather than the
ethernet-specific union member so that 1) we can more easily add the
capability to other types if needed, and 2) we can retain the info
when set to an invalid interface type all the way through to
validation and report a proper error, rather than just ignoring it
(which is currently what happens for many other type-specific
settings).

(NB: The already-existing configuration of IP info for the guest-side
of interfaces is in subelements directly under <interface>, and the
name of the guest-side interface (when configurable) is in <guest
dev='x'/>).

(This patch had been pushed earlier in
commit fe6a77898a38f491403a70cc49925a584101daee, but was reverted in
commit d658456530c1010a49f45865613ed361a0fcc5b4 because it had been
accidentally pushed during the freeze for release 2.0.0)

8 years agoconf: allow setting peer address in <ip> element of <interface>
Vasiliy Tolstov [Mon, 4 Apr 2016 21:00:03 +0000 (21:00 +0000)]
conf: allow setting peer address in <ip> element of <interface>

The peer attribute is used to set the property of the same name in the
interface IP info:

  <interface type='ethernet'>
    ...
    <ip family='ipv4' address='192.168.122.5'
        prefix='32' peer='192.168.122.6'/>
    ...
  </interface>

Note that this element is used to set the IP information on the
*guest* side interface, not the host side interface - that will be
supported in an upcoming patch.

(This patch now has quite a history: it was originally pushed in
commit 690969af, which was subsequently reverted in commit 1d14b13f,
then reworked and pushed (along with a lot of other related/supporting
patches) in commit 93135abf1; however *that* commit had been
accidentally pushed during dev. freeze for release 2.0.0, so it was
again reverted in commit f6acf039f0).

Signed-off-by: Vasiliy Tolstov <v.tolstov@selfip.ru>
Signed-off-by: Laine Stump <laine@laine.org>
8 years agoutil: new function virNetDevIPInfoAddToDev
Laine Stump [Thu, 16 Jun 2016 16:22:07 +0000 (12:22 -0400)]
util: new function virNetDevIPInfoAddToDev

This patch takes the code out of
lxcContainerRenameAndEnableInterfaces() that adds all IP addresses and
IP routes to the interface, and puts it into a utility function
virNetDevIPInfoAddToDev() in virnetdevip.c so that it can be used by
anyone.

One small change in functionality -
lxcContainerRenameAndEnableInterfaces() previously would add all IP
addresses to the interface while it was still offline, then set the
interface online, and then add the routes. Because I don't want the
utility function to set the interface online, I've moved this up so
the interface is first set online, then IP addresses and routes are
added. This is the same order that the network service from
initscripts (in ifup-ether) does it, so it shouldn't pose any problem
(and hasn't, in the tests that I've run).

(This patch had been pushed earlier in commit
f1e0d0da11c473905470c28a6488bf57d9d0ae6e, but was reverted in commit
05eab47559950403aa67d18b098273269ae6916e because it had been
accidentally pushed during the freeze for release 2.0.0)

8 years agoqemu: Introduce helper qemuDomainSecretDiskCapable
John Ferlan [Fri, 24 Jun 2016 19:47:09 +0000 (15:47 -0400)]
qemu: Introduce helper qemuDomainSecretDiskCapable

Introduce a helper to help determine if a disk src could be possibly used
for a disk secret... Going to need this for hot unplug.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoencryption: Add <cipher> and <ivgen> to encryption
John Ferlan [Wed, 1 Jun 2016 23:21:26 +0000 (19:21 -0400)]
encryption: Add <cipher> and <ivgen> to encryption

For a luks device, allow the configuration of a specific cipher to be
used for encrypting the volume.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoencryption: Add luks parsing for storageencryption
John Ferlan [Wed, 1 Jun 2016 19:01:31 +0000 (15:01 -0400)]
encryption: Add luks parsing for storageencryption

Add parse and format of the luks/passphrase secret including tests for
volume XML parsing.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoutil: Add 'usage' for encryption
John Ferlan [Mon, 30 May 2016 11:47:46 +0000 (07:47 -0400)]
util: Add 'usage' for encryption

In order to use more common code and set up for a future type, modify the
encryption secret to allow the "usage" attribute or the "uuid" attribute
to define the secret. The "usage" in the case of a volume secret would be
the path to the volume as dictated by the backwards compatibility brought
on by virStorageGenerateQcowEncryption where it set up the usage field as
the vol->target.path and didn't allow someone to provide it. This carries
into virSecretObjListFindByUsageLocked which takes the secret usage attribute
value from from the domain disk definition and compares it against the
usage type from the secret definition. Since none of the code dealing
with qcow/qcow2 encryption secrets uses usage for lookup, it's a mostly
cosmetic change. The real usage comes in a future path where the encryption
is expanded to be a luks volume and the secret will allow definition of
the usage field.

This code will make use of the virSecretLookup{Parse|Format}Secret common code.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoconf: Add new secret type "passphrase"
John Ferlan [Wed, 1 Jun 2016 19:00:57 +0000 (15:00 -0400)]
conf: Add new secret type "passphrase"

Add a new secret type known as "passphrase" - it will handle adding the
secret objects that need a passphrase without a specific username.

The format is:

   <secret ...>
     <uuid>...</uuid>
     ...
     <usage type='passphrase'>
       <name>mumblyfratz</name>
     </usage>
   </secret>

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoconf: No need to check for usage fields during Format
John Ferlan [Fri, 24 Jun 2016 14:25:15 +0000 (10:25 -0400)]
conf: No need to check for usage fields during Format

Since the virSecretDefParseUsage ensures each of the fields is present,
no need to check during virSecretDefFormatUsage (also virBufferEscapeString
is a no-op with a NULL argument).

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoAllow custom metadata in network configuration XML
Brandon Bennett [Wed, 22 Jun 2016 22:05:50 +0000 (16:05 -0600)]
Allow custom metadata in network configuration XML

    This replicates the metadata field found in the domain configuration
    and adds it to the network configuration XML.

8 years agoutil: new function virXMLNodeSanitizeNamespaces()
Laine Stump [Fri, 24 Jun 2016 15:19:35 +0000 (11:19 -0400)]
util: new function virXMLNodeSanitizeNamespaces()

This is a generic version of virDomainDefMetadataSanitize() - the same
functionality is now needed for network metadata.

8 years agodocs: remove outdated suggestion to make patches with "diff -urp"/"git diff"
Laine Stump [Wed, 29 Jun 2016 19:36:31 +0000 (15:36 -0400)]
docs: remove outdated suggestion to make patches with "diff -urp"/"git diff"

I can't think of any good reason to do either of those, and having the
examples there will just lead to unusable patch emails from people who
can't be bothered to read the entire page.

8 years agoutil: hostcpu: Only define /dev/kvm path once
Andrea Bolognani [Fri, 24 Jun 2016 17:34:38 +0000 (19:34 +0200)]
util: hostcpu: Only define /dev/kvm path once

Remove the local kvmpath variable from
virHostCPUGetThreadsPerSubcore() and use the file-global
KVM_DEVICE define instead.

8 years agoexamples: check asprintf return value in client_info.c
Ján Tomko [Fri, 1 Jul 2016 12:57:43 +0000 (14:57 +0200)]
examples: check asprintf return value in client_info.c

On error, asprintf returns -1 and the contents of the string
pointer is undefined. In the rest of the libvirt code,
the virAsprintf wrapper takes care of that.

Check the return value and report a generic error, since we
purposefully avoid linking to virutil.

8 years agomingw-libvirt.spec.in: add perl + perl(Getopt::Long) BRs
Daniel P. Berrange [Fri, 1 Jul 2016 13:11:15 +0000 (14:11 +0100)]
mingw-libvirt.spec.in: add perl + perl(Getopt::Long) BRs

The default Fedora build roots for f25 and newer no longer
include perl. We must thus explicitly ask for it as the
RPC gendispatch.pl program needs it, and the Getopt::Long
module. Do this unconditionally since it isn't harmful for
older Fedora

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
8 years agomingw-libvirt.spec.in: fix packaging of admin API and other bugs
Daniel P. Berrange [Fri, 1 Jul 2016 11:41:32 +0000 (12:41 +0100)]
mingw-libvirt.spec.in: fix packaging of admin API and other bugs

When the admin API was enabled no entries were added to the
file list.

The virt-host-validate binary is also no longer built on
win32

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
8 years agoevents: Rename argument uuid->key
Cole Robinson [Thu, 23 Jun 2016 16:14:23 +0000 (12:14 -0400)]
events: Rename argument uuid->key

Since it's not strictly a uuid anymore

8 years agoevents: Add explicit lookup 'key' value
Cole Robinson [Thu, 23 Jun 2016 16:06:39 +0000 (12:06 -0400)]
events: Add explicit lookup 'key' value

This allows event implementations to match on something other
than an object's uuid, like nodedev or interface objects which
don't have a uuid.

8 years agoevents: Pass in UUID as a string
Cole Robinson [Thu, 23 Jun 2016 15:50:05 +0000 (11:50 -0400)]
events: Pass in UUID as a string

This should not have any functional difference, it's just a step
towards matching on non-uuid string keys

8 years agoevents: Cleanup callback variable name
Cole Robinson [Thu, 23 Jun 2016 15:43:24 +0000 (11:43 -0400)]
events: Cleanup callback variable name

In every other instance virObjectEventCallbackPtr is named 'cb',
and in other code 'event' usually means a virObjectEventPtr

8 years agoevents: Add virObjectEventCallbackFree
Cole Robinson [Thu, 23 Jun 2016 15:40:53 +0000 (11:40 -0400)]
events: Add virObjectEventCallbackFree

8 years agoevents: Privatize virObjectEventCallback
Cole Robinson [Thu, 23 Jun 2016 15:29:50 +0000 (11:29 -0400)]
events: Privatize virObjectEventCallback

It's only used in object_event.c, so remove it from the header. We
need to move the _virObjectEventCallback definition earlier as a
result.

8 years agoIntroduce virDomainUSBDeviceDefForeach
Ján Tomko [Thu, 23 Jun 2016 03:04:48 +0000 (05:04 +0200)]
Introduce virDomainUSBDeviceDefForeach

A helper that will execute a callback on every USB device
in the domain definition.

With an ability to skip USB hubs, since we will want to treat
them differently in some cases.

8 years agoAdd USB addresses to qemuhotplug test cases
Ján Tomko [Thu, 23 Jun 2016 05:28:34 +0000 (07:28 +0200)]
Add USB addresses to qemuhotplug test cases

This test assumes the XML will be the same after formatting.
Add USB addresses to it to keep it working when we autoassign them.

8 years agoqemu: Avoid needless copies of static strings
Jiri Denemark [Wed, 29 Jun 2016 15:14:52 +0000 (17:14 +0200)]
qemu: Avoid needless copies of static strings

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agoqemu: Drop emitBootindex parameter
Jiri Denemark [Tue, 28 Jun 2016 21:13:17 +0000 (23:13 +0200)]
qemu: Drop emitBootindex parameter

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