Commit Graph

23451 Commits

Author SHA1 Message Date
Michal Privoznik
6fcffcb141 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>
2016-07-07 12:03:46 +02:00
Paolo Bonzini
7a97676b96 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>
2016-07-07 11:51:39 +02:00
Paolo Bonzini
ca57b5d60c 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>
2016-07-07 11:51:39 +02:00
Peter Krempa
f3d3be3d48 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.
2016-07-07 08:57:05 +02:00
Peter Krempa
ef88140725 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.
2016-07-07 08:57:05 +02:00
Peter Krempa
bc472bc2df conf: Don't use virDomainLiveConfigHelperMethod in virDomainObjSetMetadata 2016-07-07 08:57:05 +02:00
Peter Krempa
3bd161f862 openvz: Remove use of virDomainLiveConfigHelperMethod 2016-07-07 08:57:05 +02:00
Peter Krempa
fcc3ccf3cd 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.
2016-07-07 08:57:05 +02:00
Peter Krempa
bcdbab891b 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.
2016-07-07 08:57:05 +02:00
Michal Privoznik
9a6e47c483 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>
2016-07-07 07:22:15 +02:00
Michal Privoznik
70b4f0e719 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>
2016-07-07 07:22:15 +02:00
Erik Skultety
660468b1a3 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>
2016-07-04 16:44:58 +02:00
Erik Skultety
18c3321b8b 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>
2016-07-04 16:44:30 +02:00
Erik Skultety
4b48541249 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>
2016-07-04 16:44:20 +02:00
Erik Skultety
057788c537 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>
2016-07-04 16:43:48 +02:00
Erik Skultety
51b2606fec 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>
2016-07-04 16:43:35 +02:00
Erik Skultety
354cd26d6a 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>
2016-07-04 16:43:28 +02:00
Erik Skultety
9dbd728ada 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>
2016-07-04 16:43:02 +02:00
Andrea Bolognani
cd89d3451b 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
2016-07-04 10:46:27 +02:00
Martin Kletzander
155200f115 maint: update to latest gnulib
Fix mingw build regarding rpl_{printf,scanf} symbols.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-07-04 09:46:12 +02:00
Laine Stump
fe8567f6ad qemu: support setting host-side IP addresses/routes
For type='ethernet' interfaces only.

(This patch had been pushed earlier in
commit 0b4645a7e0, but was reverted in
commit 84d47a3cce because it had been
accidentally pushed during the freeze for release 2.0.0)
2016-07-01 21:13:31 -04:00
Laine Stump
187920273c lxc: support setting host-side IP addresses/routes
(This patch had been pushed earlier in
commit cd5c9f21de, but was reverted in
commit 1549f16832 because it had been
accidentally pushed during the freeze for release 2.0.0)
2016-07-01 21:13:31 -04:00
Laine Stump
d83cac49e3 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 cb20f989df, but was reverted in
commit cba06aea8d because it had been
accidentally pushed during the freeze for release 2.0.0)
2016-07-01 21:13:31 -04:00
Laine Stump
98fa8f3ef6 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 fe6a77898a, but was reverted in
commit d658456530 because it had been
accidentally pushed during the freeze for release 2.0.0)
2016-07-01 21:13:30 -04:00
Vasiliy Tolstov
b81cf13e66 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>
2016-07-01 21:13:30 -04:00
Laine Stump
95309424ba 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
f1e0d0da11, but was reverted in commit
05eab47559 because it had been
accidentally pushed during the freeze for release 2.0.0)
2016-07-01 21:13:30 -04:00
John Ferlan
60c40ce3be 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>
2016-07-01 15:46:57 -04:00
John Ferlan
2552fec248 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>
2016-07-01 15:46:57 -04:00
John Ferlan
9bbf0d7e64 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>
2016-07-01 15:46:52 -04:00
John Ferlan
47e88b33be 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>
2016-07-01 15:46:24 -04:00
John Ferlan
c84380106f 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>
2016-07-01 15:45:41 -04:00
John Ferlan
3977c386f6 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>
2016-07-01 15:38:56 -04:00
Brandon Bennett
47a0866bce 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.
2016-07-01 13:05:25 -04:00
Laine Stump
b874f26b8b util: new function virXMLNodeSanitizeNamespaces()
This is a generic version of virDomainDefMetadataSanitize() - the same
functionality is now needed for network metadata.
2016-07-01 13:04:49 -04:00
Laine Stump
328fccf135 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.
2016-07-01 12:41:10 -04:00
Andrea Bolognani
9c992f437c util: hostcpu: Only define /dev/kvm path once
Remove the local kvmpath variable from
virHostCPUGetThreadsPerSubcore() and use the file-global
KVM_DEVICE define instead.
2016-07-01 17:58:29 +02:00
Ján Tomko
aa7bb4f36d 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.
2016-07-01 15:39:01 +02:00
Daniel P. Berrange
8764c99a40 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>
2016-07-01 14:11:15 +01:00
Daniel P. Berrange
8050f60450 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>
2016-07-01 12:41:32 +01:00
Cole Robinson
5684680fd0 events: Rename argument uuid->key
Since it's not strictly a uuid anymore
2016-07-01 07:15:38 -04:00
Cole Robinson
37d1c246e5 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.
2016-07-01 07:15:38 -04:00
Cole Robinson
d7c96a7245 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
2016-07-01 07:15:38 -04:00
Cole Robinson
7926c5a5be events: Cleanup callback variable name
In every other instance virObjectEventCallbackPtr is named 'cb',
and in other code 'event' usually means a virObjectEventPtr
2016-07-01 07:15:38 -04:00
Cole Robinson
593269a2a5 events: Add virObjectEventCallbackFree 2016-07-01 07:15:38 -04:00
Cole Robinson
d3a492a883 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.
2016-07-01 07:15:38 -04:00
Ján Tomko
492b3bfda1 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.
2016-07-01 12:25:18 +02:00
Ján Tomko
3681e0a9fe 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.
2016-07-01 12:25:18 +02:00
Jiri Denemark
60f35e263f qemu: Avoid needless copies of static strings
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-07-01 12:20:54 +02:00
Jiri Denemark
77437410d7 qemu: Drop emitBootindex parameter
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-07-01 12:20:54 +02:00
Jiri Denemark
0dd67acfa7 qemu: Use bootindex whenever possible
I'm not sure why our code claimed "-boot menu=on" cannot be used in
combination with per-device bootindex, but it was proved wrong about
four years ago by commit 8c952908. Let's always use bootindex when QEMU
supports it.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-07-01 12:20:54 +02:00