Commit Graph

13107 Commits

Author SHA1 Message Date
Jim Fehlig
1c0bf509ef libxl: Support user-specified <emulator>
With the introduction of the libxlDomainGetEmulatorType function,
it is trivial to support a user-specfied <emulator> in the libxl
driver.  This patch is based loosely on David Scott's old patch
to do the same

https://www.redhat.com/archives/libvir-list/2013-April/msg02119.html
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
2014-10-30 10:23:18 -06:00
Ján Tomko
b43e6662df Spell TIOCSCTTY right in the error message 2014-10-30 17:14:09 +01:00
Ján Tomko
4abcf04e7c Reject live update of offloading options
https://bugzilla.redhat.com/show_bug.cgi?id=1155441
2014-10-30 13:32:00 +01:00
Martin Kletzander
6c9a8a49c7 conf: forbid negative values in virDomainParseScaledValue
It makes sense for none of the callers to have negative value as an
output and, fortunately, if anyone tried defining domain with negative
memory or any other value parsed by virDomainParseScaledValue(), the
resulting value was 0.  That means we can error out during parsing as
it won't break anything.

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2014-10-30 07:42:28 +01:00
Roman Bogorodskiy
44178b8e80 virutil: fix virGetSCSIHostNumber stub return type
The virGetSCSIHostNumber function return type is int, however
its stubbed version returns NULL. That results in a build fail
on systems that use the stubbed version. Fix by using a proper
return type.
2014-10-30 08:54:17 +03:00
Roman Bogorodskiy
00fa136d0b virnetdev: stub virNetDev{Add,Del}Multi on FreeBSD
Currently, build fails on FreeBSD because its struct ifreq does not
have ifr_hwaddr member. In order to fix that, check if this member
is present, otherwise fall back to the stub version of the
virNetDev{Add,Del}Multi functions.
2014-10-30 07:59:39 +03:00
John Ferlan
9babbaa5fe virnetdev: Resolve Coverity RESOURCE_LEAK
virFileReadAll returns a chunk of memory that needs to be free'd when
done
2014-10-29 18:56:06 -04:00
John Ferlan
f099726c46 virnetdev: Resolve Coverity FORWARD_NULL
The complaint is that if cleanup is called when virFileReadAll fails,
then mcast->entries is NULL and could be dereferenced in the clear
function. After following the code some - I saw that the caller to
the function (virNetDevGetMulticastTable) will also call
virNetDevMcastListClear if this function returns -1, so this
isn't necessary, so I removed the call.
2014-10-29 18:56:06 -04:00
John Ferlan
764deecbd9 virnetdev: Resolve Coverity DEADCODE
Coverity complains that because the for loop is from 0 to 5 (max tokens)
and the impending switch/case statements used each of the #define values
that the 'default' wouldn't reachable. This patch will convert the #define's
into enum's and add the obligatory dead_error_begin marker for these type
situations.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2014-10-29 18:56:06 -04:00
Cédric Bosdonnat
16d2bc8b98 Teach virt-aa-helper to use TEMPLATE.qemu if the domain is kvm or kqemu 2014-10-29 15:11:59 -06:00
Eric Blake
00331bfbc9 qemu: better error message when block job can't succeed
https://bugzilla.redhat.com/show_bug.cgi?id=1140981 reports that
the qemu-kvm shipped as part of RHEL 7.0 intentionally[1] cripples
block jobs by removing the 'block-stream' QMP command, while still
leaving 'block-job-cancel' as an unusable no-op.  Meanwhile, we
already had existing code that checked whether block jobs were
completely missing (such as qemu 0.15), old style (cancel is
synchronous, and all commands spelled with '_'), or new style
(cancel is asynchronous, and all commands spelled with '-'), and
used that three-way probe to give decent error messages.  At the
time that code was added, all existing qemu versions fell in one
of three buckets, and the code was using the presence of
'block-job-cancel' as the witness of which of the three buckets.
But now that RHEL qemu has shipped with intentionally crippled
'block-stream', we have a fourth bucket, which results in ugly
error messages when trying 'virsh blockpull':

 error: Requested operation is not valid: Command 'block-stream' is not found

In reality, the fourth bucket should be treated the same as the
first bucket (no block job support); we can do that by realizing
that no existing build of qemu has working block-stream while
lacking block-job-cancel, so it is easiest to change our witness
to the command that starts a job rather than ends one.  We still
act correctly regarding command spelling and whether cancel is
asynchronous.  And on crippled RHEL builds, we now get the desired:

 error: unsupported configuration: block jobs not supported with this qemu binary

[1] The intentional cripple is limited to qemu-kvm of RHEL; when using
qemu-kvm-rhev of RHEV, block job functionality is supported.  Don't ask
me to explain the "why" behind it all - I'm just dealing with fallout
from someone else's decision.

* src/qemu/qemu_capabilities.h (QEMU_CAPS_BLOCKJOB_SYNC): Tweak comment.
* src/qemu/qemu_capabilities.c (virQEMUCapsCommands): Look for stream
rather than cancel when determining the flavor of block jobs supported.

Signed-off-by: Eric Blake <eblake@redhat.com>
2014-10-29 14:57:44 -06:00
Peter Krempa
98784369fd storage: Fix crash when parsing backing store URI with schema
The code that parses the schema from the URI touches the "hosts[0]"
member of the storage file source structure in case the URI contains a
schema. The hosts array was not yet allocated at the point in the code
where the transport protocol was parsed and set. This lead to a crash of
libvirtd.

Fix the code by allocating the "hosts" array upfront and add a test case
to verify this scenario. (Unfortunately this requires shuffling the test
case numbers too).

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1156288
2014-10-29 17:10:42 +01:00
Eric Blake
85f2d0dd55 maint: add syntax check to prohibit static zero init
Now that all offenders have been cleaned, turn on a syntax-check
rule to prevent future offenders.

* cfg.mk (sc_prohibit_static_zero_init): New rule.
* src/qemu/qemu_driver.c (qemuDomainBlockJobImpl): Avoid false
positive.

Signed-off-by: Eric Blake <eblake@redhat.com>
2014-10-29 09:55:09 -06:00
Eric Blake
ec81cf8942 maint: avoid static zero init in drivers
C guarantees that static variables are zero-initialized.  Some older
compilers (and also gcc -fno-zero-initialized-in-bss) create larger
binaries if you explicitly zero-initialize a static variable.

* src/libxl/libxl_driver.c: Fix initialization.
* src/lxc/lxc_controller.c: Likewise.
* src/openvz/openvz_util.c (openvzKBPerPages): Likewise.
* src/phyp/phyp_driver.c: Likewise.
* src/remote/remote_driver.c: Likewise.
* src/test/test_driver.c: Likewise.
* src/uml/uml_driver.c: Likewise.
* src/vbox/vbox_XPCOMCGlue.c: Likewise.
* src/vbox/vbox_tmpl.c: Likewise.
* src/xen/xen_driver.c: Likewise.
* src/xen/xen_hypervisor.c: Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
2014-10-29 09:55:09 -06:00
Eric Blake
ff99c79195 maint: avoid static zero init in helpers
C guarantees that static variables are zero-initialized.  Some older
compilers (and also gcc -fno-zero-initialized-in-bss) create larger
binaries if you explicitly zero-initialize a static variable.

* src/conf/nwfilter_conf.c: Fix initialization.
* src/cpu/cpu_x86.c: Likewise.
* src/interface/interface_backend_netcf.c: Likewise.
* src/locking/lock_daemon.c: Likewise.
* src/locking/lock_driver_lockd.c: Likewise.
* src/locking/lock_driver_sanlock.c: Likewise.
* src/network/bridge_driver.c: Likewise.
* src/node_device/node_device_udev.c: Likewise.
* src/nwfilter/nwfilter_learnipaddr.c: Likewise.
* src/rpc/virnetserver.c: Likewise.
* src/security/security_selinux.c
(virSecuritySELinuxGenSecurityLabel): Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
2014-10-29 09:55:09 -06:00
Eric Blake
39871fce1a maint: avoid static zero init in core files
C guarantees that static variables are zero-initialized.  Some older
compilers (and also gcc -fno-zero-initialized-in-bss) create larger
binaries if you explicitly zero-initialize a static variable.

* src/libvirt.c: Fix initialization.
* src/util/viralloc.c: Likewise.
* src/util/virdbus.c: Likewise.
* src/util/virevent.c: Likewise.
* src/util/virfile.c (safezero): Likewise.
* src/util/virlog.c: Likewise.
* src/util/virnetlink.c: Likewise.
* src/util/virthread.h (VIR_ONCE_GLOBAL_INIT): Likewise.
* src/util/virprocess.c (virProcessGetStartTime): Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
2014-10-29 09:55:09 -06:00
Eric Blake
0fe384f38e audit: use bool for audit log choice
We weren't ever using the value for anything other than being non-zero.

* src/util/viraudit.h (virAuditLog): Change signature.
* src/util/viraudit.c (virAuditLog): Update user.
* daemon/libvirtd.c (main): Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
2014-10-29 09:55:09 -06:00
Michal Privoznik
233ecdea71 src/Makefile.am: Add forgotten backslash
As I've pushed 5892944f I haven't noticed one small nitpick.
There was this backslash missing on the line 1231 in the
enumeration of libraries to be added to vbox storage driver. This
resulted in nondeterministic build which sometimes succeeded and
sometimes failed.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2014-10-29 04:32:43 +01:00
John Ferlan
3f99d64db8 storage_conf: Resolve libvirtd crash matching scsi_host
https://bugzilla.redhat.com/show_bug.cgi?id=1146837

Resolve a crash in libvirtd resulting from commit id 'a4bd62ad' (1.0.6)
which added parentaddr and unique_id to allow unique identification of
a scsi_host, but assumed that all the pool entries and the incoming
definition would be similarly defined. If the existing pool uses the
'name' attribute and an incoming pool is using the parentaddr/unique_id,
then the code will attempt to compare the existing name string against
the incoming name string which doesn't exist (is NULL) and results in
a core (STREQ).

Conversely, if the existing pool used the parentaddr/unique_id and the
to be defined pool used the name, then the comparison would be against
the parentaddr, but since the incoming pool doesn't have one - that would
leave the comparison against a parentaddr of all 0's and a unique_id of 0,
which will always comparison to fail. This means someone could define the
same source adapter for two pools

In order to resolve this, adjust the code to get the 'host#' to be used
by the storage scsi backend in order to check/start the pool and make sure
the incoming definition doesn't match any of the existing pool defs.
2014-10-28 21:25:33 -04:00
John Ferlan
beff5d4e1b virutil: Introduce virGetSCSIHostNameByParentaddr
Create the function from the code in getAdapterName() in order to return
the "host#" name for the provided parentaddr values.
2014-10-28 21:25:32 -04:00
John Ferlan
55f439599c virutil: Introduce virGetSCSIHostNumber
Create/use virGetSCSIHostNumber to replace the static getHostNumber

Removed the "if (result &&" since result is now required to be non NULL
on input.
2014-10-28 21:25:26 -04:00
John Ferlan
e3a52afcfc qemu-attach: Assign device aliases
https://bugzilla.redhat.com/show_bug.cgi?id=1141621

As part of attach processing, assign the device aliases by calling
qemuAssignDeviceAliases during qemuDomainQemuAttach once all the devices
are found after the qemuParseCommandLinePid processing.

This will alleviate a symptom that caused a libvirtd crash during an
attempted device detach.
2014-10-28 21:12:08 -04:00
John Ferlan
96af61ddc1 hotplug: Check for alias in net detach
https://bugzilla.redhat.com/show_bug.cgi?id=1141621

If the QEMU_CAPS_DEVICE is set, then ensure the host device alias has
been properly set before making the calls to detach the device
2014-10-28 21:12:08 -04:00
John Ferlan
4d8a4165a7 hotplug: Check for alias in chrdev detach
If the QEMU_CAPS_DEVICE is set, then ensure the chr device alias has
been properly set before making the calls to detach the device
2014-10-28 21:12:08 -04:00
John Ferlan
9de26f27cf hotplug: Check for alias in hostdev detach
If the QEMU_CAPS_DEVICE is set, then ensure the host device alias has
been properly set before making the calls to detach the device
2014-10-28 21:12:08 -04:00
John Ferlan
5d02a9a0c5 hotplug: Check for alias in disk detach
If the QEMU_CAPS_DEVICE is set, then ensure the disk device alias has
been properly set in prior to making the calls to detach the device.
2014-10-28 21:12:08 -04:00
John Ferlan
65be7572d2 hotplug: Check for alias in controller detach
In qemuDomainDetachControllerDevice if the info.alias already exists
a call to qemuAssignDeviceControllerAlias would overwrite the existing
so avoid this possibility.
2014-10-28 21:12:08 -04:00
Jincheng Miao
28b7601dc7 remote: fix jump depends on uninitialised value
Currently remote driver only initializes partial fields of
remote_connect_get_all_domain_stats_args. But xdr_array()
will check the uninitialised field 'doms_val'.
For safty reason, memset all fields of args is better.

Fix the following error from valgrind, like:
==30515== 1 errors in context 1 of 3:
==30515== Conditional jump or move depends on uninitialised value(s)
==30515==    at 0x85E9402: xdr_array (xdr_array.c:88)
==30515==    by 0x4FD8FC9: xdr_remote_connect_get_all_domain_stats_args (remote_protocol.c:6473)
==30515==    by 0x4FE72F2: virNetMessageEncodePayload (virnetmessage.c:350)
==30515==    by 0x4FDD21C: virNetClientProgramCall (virnetclientprogram.c:326)
==30515==    by 0x4FB4D01: callFull.isra.2 (remote_driver.c:6667)
==30515==    by 0x4FCBD45: call (remote_driver.c:6689)
==30515==    by 0x4FCBD45: remoteConnectGetAllDomainStats (remote_driver.c:7793)
==30515==    by 0x4FA0E75: virConnectGetAllDomainStats (libvirt.c:21678)
==30515==    by 0x147FD1: cmdDomstats (virsh-domain-monitor.c:2148)
==30515==    by 0x13006B: vshCommandRun (virsh.c:1915)
==30515==    by 0x12A9E1: main (virsh.c:3699)

Signed-off-by: Jincheng Miao <jmiao@redhat.com>
2014-10-29 01:58:53 +01:00
Taowei Luo
2f055b0078 vbox: Remove unused things in vbox_tmpl.c
After rewriting the whole driver, Only version specified code is
remained in vbox_tmpl.c. So, this patch removes those unused macros
header files in vbox_tmpl.c.
2014-10-29 01:21:41 +01:00
Taowei Luo
5892944fc8 vbox: New storage driver
This patch provides the new stroage driver for vbox. The work
is similar with patch 87dea4fc and the next b4022de33.
2014-10-29 01:21:41 +01:00
Taowei Luo
013aa0815c vbox: Rewrite vboxStorageVolGetPath 2014-10-29 01:21:41 +01:00
Taowei Luo
4df7b206aa vbox: Rewrite vboxStorageVolGetXMLDesc 2014-10-29 01:21:41 +01:00
Taowei Luo
80f35e6e8b vbox: Rewrite vboxStorageVolGetInfo 2014-10-29 01:21:41 +01:00
Taowei Luo
1c2c3906a1 vbox: Rewrite vboxStorageVolDelete
The API on IHardDiskAttachment is merged into IMediumAttachment.
So, we don't need it anymore.
2014-10-29 01:21:40 +01:00
Taowei Luo
3d33e38877 vbox: Make IMediumAttachment work with vbox2.2 and 3.0
The GetMedium will always return a IHardDisk object them.
In 2.2 and 3.0, it is what GetHardDisk exactly do. In 3.1 and later,
The IMedium is same as IHardDisk.
2014-10-29 01:21:40 +01:00
Taowei Luo
0cd409cdb3 vbox: Rewrite vboxStorageVolCreateXML
If the <path> in target element is not given, libvirt will put the
new volume in ~/.VirtualBox by default.
2014-10-29 01:21:40 +01:00
Taowei Luo
382e655d16 vbox: Make CreateHardDisk support all vbox versions
The CreateHardDiskMedium only support create HardDisk for medium
type, and it only works when vbox version >= 3.1. This patch make
the function workable with all vbox versions and rename it as
CreateHardDisk.

In vbox 2.2 and 3.0 this function will create a IHardDisk object.
In vbox later than 3.0, this function will create a IMedium object.
2014-10-29 01:21:40 +01:00
Taowei Luo
fc41e00391 vbox: Rewrite vboxStorageVolLookupByPath 2014-10-29 01:21:40 +01:00
Taowei Luo
1599319c7e vbox: Make FindMedium support old vbox versions
In old version, function FindMedium in UIVirtualBox doesn't work
for vbox2.2 and 3.0. We assume it will not be used when vbox in
these versions.

But when rewriting vboxStorageVolLookupByPath, we found it was
compatibe to use FindMedium to get a IHardDisk object, even in
vbox old versions. To achieve this, first make FindMedium call
FindHardDisk when VBOX_API_VERSION < 4000000.
Then change the argument type **IMedium to **IHardDisk. (As the
rules in heriachy, we can't transfer a IHardDisk to match
IMedium in output)

In vbox 2.2 and 3.0, the caller must be aware that they will get
a IHardDisk object in return.
2014-10-29 01:21:40 +01:00
Taowei Luo
f67ae174eb vbox: Rewrite vboxStorageVolLookupByKey 2014-10-29 01:21:40 +01:00
Taowei Luo
8a8fa504aa vbox: Rewrite vboxStorageVolLookupByName 2014-10-29 01:21:40 +01:00
Taowei Luo
c3c8cd4fdc vbox: Rewrite vboxStoragePoolListVolumes 2014-10-29 01:21:39 +01:00
Taowei Luo
ce381d3764 vbox: Rewrite vboxStoragePoolNumOfVolumes
We use typedef IMedium IHardDisk to make IHardDisk hierachy from
IMedium (Actually it did on vbox 2.2 and 3.0's C++ API).
So when calling
    VBOX_MEDIUM_FUNC_ARG*(IHardDisk, func, args)
we can directly replace it to
    gVBoxAPI.UIMedium.func(IHardDisk, args)

When dealing with this two types, we get some rules from it's
hierachy relationship.

When using IHardDisk and IMedium as input, we can't transfer a
IMedium to IHardDisk. Like:
    gVBoxAPI.UIHardDisk.func(IHardDisk *hardDisk, args)
    Here, we can't put a *IMedium as a argument.

When using IHardDisk and IMedium as output, we can't transfer a
IHardDisk to IMedium. Like:
    gVBoxAPI.UIMachine.GetMedium(IMedium **out)
    Here, we can't put a **IHardDisk as a argument. If this case
    do happen, we either change the API to GetHardDisk or write a
    new one.
2014-10-29 01:21:39 +01:00
Taowei Luo
459886d41b vbox: Rewrite vbox-independent functions
This patch rewrites the following functions
    *vboxStorageOpen
    *vboxStorageClose
    *vboxConnectNumOfStoragePools
    *vboxConnectListStoragePools
    *vboxStoragePoolLookupByName

These functions do not call any vbox API, so I directly move it
from vbox_tmpl.c to vbox_storage.c

A small improvement is made on vboxConnectListStoragePools.
The if condition nnames == 1 is modified to nnames > 0. So if the
caller put more than one slot to get active storage pools, the new
function will return exactly one, while the old one would only
return 0.
2014-10-29 01:21:39 +01:00
Taowei Luo
7d5b9419f1 vbox: move common codes to vbox_common.h
There are lots of macro declarations in vbox_common.c,
vbox_network.c, and the coming vbox_storage.c which simply the API
calling. Since they are totally the same. We shouldn't keep three
copies of that, so they are moved to vbox_common.h.

Note: The macros are quite different from those in vbox_tmpl.c,
      because they are using different API.
2014-10-29 01:21:39 +01:00
Taowei Luo
a6b1cde3ca vbox: Remove VBOX_OBJECT_CHECK macro
We should follow the rules that CHECK macro only do checking works.
But this VBOX_OBJECT_CHECK and VBOX_OBJECT_HOST_CHECK declared some
varibles at the same time, which broke the rule. So the patch
removed this macros and dispatched it in source code.

The storage driver is still not rewriten at this point. So, I
remains the VBOX_OBJECT_CHECK macro in vbox_tmpl.c. But this will
finally be removed in patch 'vbox: Remove unused things in vbox_tmpl.c'
2014-10-29 01:21:39 +01:00
Taowei Luo
c5cc26e65d vbox: Fix copyright mistake
I made a mistake on copyright in patch 7f0f415b87.

If I copied codes from one file to another, I should copy the
copyright announcement as well. So this patch makes up the
copyright which I should have added in the previous patch.
2014-10-29 01:21:39 +01:00
Cédric Bosdonnat
90712bb5c0 Renamed internal __mon_yday into mon_yday to avoid conflicts
libc has another constant with the same name, which leads to
redefinition error when building against static libvirt
2014-10-28 14:44:18 -06:00
Michal Privoznik
b7fe5a6555 qemu_agent: Produce more readable error messages
Not every error message from qemu-ga has to have the 'class' field
filled out. For instance, I've seen this error message lately:

  qemuAgentCheckError:1047 : unable to execute QEMU agent command \
  {"execute":"guest-set-time"}: \
  {"error":{"desc":"Invalid parameter type, expected: integer"}}

However, this got translated into rather generic error message:

  internal error: unable to execute QEMU agent command
  'guest-set-time': unknown QEMU command error

So we've dropped better error message in favor of a generic one.
This is due to our code which expects 'class' which is not
present here.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2014-10-28 20:06:27 +01:00
Tony Krowiak
d70cc1fa72 qemu: change macvtap multicast list in response to NIC_RX_FILTER_CHANGED
This patch adds functionality to processNicRxFilterChangedEvent().
The old and new multicast lists are compared and the filters in
the macvtap are programmed to match the guest's filters.

Signed-off-by: Tony Krowiak <akrowiak@linux.vnet.ibm.com>
2014-10-28 14:14:25 -04:00
Tony Krowiak
cc0e8c244d util: Functions to update host network device's multicast filter
This patch provides the utility functions to needed to synchronize the
changes made to a guest domain network device's multicast filter
with the corresponding macvtap device's filter on the host:

* Get/add/remove multicast MAC addresses
* Get the macvtap device's RX filter list

Signed-off-by: Tony Krowiak <akrowiak@linux.vnet.ibm.com>
Signed-off-by: Laine Stump <laine@laine.org>
2014-10-28 14:14:25 -04:00
Eric Blake
2086a9905a qemu: forbid snapshot-delete --children-only on external snapshot
https://bugzilla.redhat.com/show_bug.cgi?id=956506 documents that
given a domain where an internal snapshot parent has an external
snapshot child, we lacked a safety check when trying to use the
--children-only option to snapshot-delete:

$ virsh start dom
$ virsh snapshot-create-as dom internal
$ virsh snapshot-create-as dom external --disk-only
$ virsh snapshot-delete dom external
error: Failed to delete snapshot external
error: unsupported configuration: deletion of 1 external disk snapshots not supported yet
$ virsh snapshot-delete dom internal --children
error: Failed to delete snapshot internal
error: unsupported configuration: deletion of 1 external disk snapshots not supported yet
$ virsh snapshot-delete dom internal --children-only
Domain snapshot internal children deleted

While I'd still like to see patches that actually do proper external
snapshot deletion, we should at least fix the inconsistency in the
meantime.  With this patch:

$ virsh snapshot-delete dom internal --children-only
error: Failed to delete snapshot internal
error: unsupported configuration: deletion of 1 external disk snapshots not supported yet

* src/qemu/qemu_driver.c (qemuDomainSnapshotDelete): Fix condition.

Signed-off-by: Eric Blake <eblake@redhat.com>
2014-10-27 14:04:47 -06:00
Laine Stump
f9f9699f40 util: eliminate "use after free" in callers of virNetDevLinkDump
virNetDevLinkDump() gets a message from netlink into "resp", then
calls nlmsg_parse() to fill the table "tb" with pointers into resp. It
then returns tb to its caller, but not before freeing the buffer at
resp. That means that all the callers of virNetDevLinkDump() are
examining memory that has already been freed. This can be verified by
filling the buffer at resp with garbage prior to freeing it (or, I
suppose, just running libvirtd under valgrind) then performing some
operation that calls virNetDevLinkDump().

The code has been like this ever since virNetDevLinkDump() was written
- the original author didn't notice it, and neither did later
additional users of the function. It has only been pure luck (or maybe
a lack of heavy load, and/or maybe an allocation algorithm in malloc()
that delays re-use of just-freed memory) that has kept this from
causing errors, for example when configuring a PCI passthrough or
macvtap passthrough network interface.

The solution taken in this patch is the simplest - just return resp to
the caller along with tb, then have the caller free it after they are
finished using the data (pointers) in tb. I alternately could have
made a cleaner interface by creating a new struct that put tb and resp
together along with a vir*Free() function for it, but this function is
only used in a couple places, and I'm not sure there will be
additional new uses of virNetDevLinkDump(), so the value of adding a
new type, extra APIs, etc. is dubious.
2014-10-26 12:23:23 -04:00
Shanzhi Yu
22b185343d vbox: network: make sure driver is not NULL in virRegisterNetworkDriver
libvirtd will report below error if it does not make sure driver was not NULL
in virRegisterNetworkDriver

$ libvirtd
2014-10-24 09:24:36.443+0000: 28876: info : libvirt version: 1.2.10
2014-10-24 09:24:36.443+0000: 28876: error : virRegisterNetworkDriver:549 : driver in virRegisterNetworkDriver must not be NULL
2014-10-24 09:24:36.443+0000: 28876: error : virDriverLoadModule:99 : Failed module registration vboxNetworkRegister

Signed-off-by: Shanzhi Yu <shyu@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
2014-10-24 11:16:19 -06:00
Daniel P. Berrange
e8656ce13c Add new driver-*.h files to DRIVER_SOURCES
The recently added driver-*.h files were not listed in the
Makefile.am causing them to be missed when creating dists.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2014-10-24 17:39:48 +01:00
Daniel P. Berrange
0d36a5d05a Fix indentation of sysinfo data
The <sysinfo> data block was indented by 2 spaces too many.
This was missed because we never had any test validating
the XML formatting.
2014-10-24 17:23:52 +01:00
Daniel P. Berrange
0399b188ac Move virConnect/virNode related APIs out of libvirt.c
Introduce a src/libvirt-host.c file to hold all the
methods related to the virConnect type.
2014-10-24 16:59:58 +01:00
Daniel P. Berrange
67c08fccdc Move virDomain related APIs out of libvirt.c
Introduce a src/libvirt-domain.c file to hold all the
methods related to the virDomain type.
2014-10-24 16:59:56 +01:00
Daniel P. Berrange
8444015446 Make virTypedParameterValidateSet non-static
The virTypedParameterValidateSet method will need to be used
from several libvirt-*.c files so must be non-static

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2014-10-24 16:54:48 +01:00
Daniel P. Berrange
36b5d006c1 Move virStorage{Pool,Vol} related APIs out of libvirt.c
Introduce a src/libvirt-storage.c file to hold all the
methods related to the virStorage{Pool,Vol} types.
2014-10-24 16:49:10 +01:00
Daniel P. Berrange
0c94d78bb5 Move virStream related APIs out of libvirt.c
Introduce a src/libvirt-stream.c file to hold all the
methods related to the virStream type.
2014-10-24 16:42:49 +01:00
Daniel P. Berrange
d83ccd6e61 Move virSecret related APIs out of libvirt.c
Introduce a src/libvirt-secret.c file to hold all the
methods related to the virSecret type.
2014-10-24 16:39:05 +01:00
Daniel P. Berrange
e33ed8cdfe Move virNodeDevice related APIs out of libvirt.c
Introduce a src/libvirt-nodedev.c file to hold all the
methods related to the virNodeDevice type.
2014-10-24 16:26:55 +01:00
Daniel P. Berrange
35ed98755f Move virNWFilter related APIs out of libvirt.c
Introduce a src/libvirt-nwfilter.c file to hold all the
methods related to the virNWFilter type.
2014-10-24 16:15:46 +01:00
Daniel P. Berrange
6e01ef230b Move virInterface related APIs out of libvirt.c
Introduce a src/libvirt-interface.c file to hold all the
methods related to the virInterface type.
2014-10-24 16:08:28 +01:00
Daniel P. Berrange
4e00b6bc6a Move virNetwork related APIs out of libvirt.c
Introduce a src/libvirt-network.c file to hold all the
methods related to the virNetwork type.
2014-10-24 16:00:21 +01:00
Daniel P. Berrange
62cf32d0c9 Move virDomainSnapshot related APIs out of libvirt.c
Introduce a src/libvirt-domain-snapshot.c file to hold all the
methods related to the virDomainSnapshot type.
2014-10-24 15:59:22 +01:00
Eric Blake
0be3403db6 hyperv: avoid query memleaks on failure
The function hypervEnumAndPull consumes query on success, but leaked
it on failure.  Rather than having to change all callers (many of
them indirect callers through the generated
hypervGetMsvmComputerSystemList), it was easier to just guarantee
that the buffer is cleaned on return from the function.

* src/hyperv/hyperv_wmi.c (hypervEnumAndPull): Don't leak query on
failure.

Signed-off-by: Eric Blake <eblake@redhat.com>
2014-10-23 17:11:56 -06:00
Daniel P. Berrange
d21d35e335 Split driver.h into multiple parts
With the large number of APIs in libvirt the driver.h file,
it is easy to get lost looking for things. Split each driver
into a separate header file based on the functional driver
groups.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2014-10-23 11:10:05 +01:00
Daniel P. Berrange
931dff992e Rename virDriver to virHypervisorDriver
To prepare for introducing a single global driver, rename the
virDriver struct to virHypervisorDriver and the registration
API to virRegisterHypervisorDriver()
2014-10-23 11:09:54 +01:00
Erik Skultety
43b67f2e71 qemu: Disallow NUMA/network tuning for session mode
Tuning NUMA or network interface parameters requires root
privileges to manage cgroups. Thus an attempt to set some of these
parameters in session mode on a running domain should be invalid
followed by an error. An example might be memory tuning which raises
an error in such case.

The following behavior in session mode will be present after applying
this patch:

  Tuning  |      SET      |   GET  |
----------|---------------|--------|
NUMA      | shut off only | always |
Memory    |     never     | never  |
Interface |     never     | always |

Resolves https://bugzilla.redhat.com/show_bug.cgi?id=1126762
2014-10-22 14:35:06 -04:00
Peter Krempa
19b1ee42b4 qemu: migration: Make check for empty hook XML robust
Also consider whitespace only strings returned from the hook as empty
result.
2014-10-22 17:51:31 +02:00
Peter Krempa
e386779937 qemu: restore: Fix restoring of VM when the restore hook returns empty XML
The documentation for the restore hook states that returning an empty
XML is equivalent with copying the input. There was a bug in the code
checking the returned string by checking the string instead of the
contents. Use the new helper to check if the string is empty.
2014-10-22 17:51:31 +02:00
Peter Krempa
0eeafeedeb util: string: Add helper to check whether string is empty
The helper checks whether a string contains only whitespace or is NULL.
This will be helpful to skip cases where a user string is optional, but
may be provided empty with the same meaning.
2014-10-22 17:51:18 +02:00
Rick Harris
7e037f64c0 Add support for /run/initctl
Newer versions of Debian use '/run/initctl' instead of '/dev/initctl'.
This patch updates the code to search for the FIFO from a list of
well-known locations.
2014-10-22 13:09:49 +01:00
Roman Bogorodskiy
82e4f85ce0 Fix cast errors with clang
Build with clang fails with:

  CC       util/libvirt_util_la-virsocketaddr.lo
util/virsocketaddr.c:904:17: error: cast from 'struct sockaddr *' to
'struct sockaddr_in *' increases required alignment from 1 to 4
[-Werror,-Wcast-align]
        inet4 = (struct sockaddr_in*) res->ai_addr;
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
util/virsocketaddr.c:909:17: error: cast from 'struct sockaddr *' to
'struct sockaddr_in6 *' increases required alignment from 1 to 4
[-Werror,-Wcast-align]
        inet6 = (struct sockaddr_in6*) res->ai_addr;
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 errors generated.

Fix that by replacing virSocketAddrParseInternal() call with
virSocketAddrParse() in the virSocketAddrIsNumericLocalhost() function.
virSocketAddrParse stores an address in virSocketAddr.
virSocketAddr uses a union to store an address, so it doesn't
need casting.
2014-10-22 12:54:38 +04:00
Martin Kletzander
9661ac2f46 qemu: unref cfg after TerminateMachine has been called
Commit 4882618ed1 added the code that
requests driver cfg, but forgot to unref it.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2014-10-21 13:54:09 +02:00
Lubomir Rintel
afe8f4200f qemu: x86_64 is good enough for i686
virt-manager on Fedora sets up i686 hosts with "/usr/bin/qemu-kvm" emulator,
which in turn unconditionally execs qemu-system-x86_64 querying capabilities
then fails:

Error launching details: invalid argument: architecture from emulator 'x86_64' doesn't match given architecture 'i686'

Traceback (most recent call last):
  File "/usr/share/virt-manager/virtManager/engine.py", line 748, in _show_vm_helper
    details = self._get_details_dialog(uri, vm.get_connkey())
  File "/usr/share/virt-manager/virtManager/engine.py", line 726, in _get_details_dialog
    obj = vmmDetails(conn.get_vm(connkey))
  File "/usr/share/virt-manager/virtManager/details.py", line 399, in __init__
    self.init_details()
  File "/usr/share/virt-manager/virtManager/details.py", line 784, in init_details
    domcaps = self.vm.get_domain_capabilities()
  File "/usr/share/virt-manager/virtManager/domain.py", line 518, in get_domain_capabilities
    self.get_xmlobj().os.machine, self.get_xmlobj().type)
  File "/usr/lib/python2.7/site-packages/libvirt.py", line 3492, in getDomainCapabilities
    if ret is None: raise libvirtError ('virConnectGetDomainCapabilities() failed', conn=self)
libvirtError: invalid argument: architecture from emulator 'x86_64' doesn't match given architecture 'i686'

Journal:

Oct 16 21:08:26 goatlord.localdomain libvirtd[1530]: invalid argument: architecture from emulator 'x86_64' doesn't match given architecture 'i686'
2014-10-21 13:36:25 +02:00
Zhou yimin
411cea638f qemu: move setting emulatorpin ahead of monitor showing up
If VM is configured with many devices(including passthrough devices)
and large memory, libvirtd will take seconds(in the worst case) to
wait for monitor. In this period the qemu process may run on any
PCPU though I intend to pin emulator to the specified PCPU in xml
configuration.

Actually qemu process takes high cpu usage during vm startup.
So this is not the strict CPU isolation in this case.

Signed-off-by: Zhou yimin <zhouyimin@huawei.com>
2014-10-21 12:26:38 +02:00
Maxime Leroy
302720742f conf: tests: fix virDomainNetDefFormat for vhost-user in client mode
The mode attribute is required for the source element of vhost-user.
Thus virDomainNetDefFormat should always generate a xml with it and not
only when the mode is server.

The commit fixes the issue. And it adds a vhostuser interface in
'client' mode to qemuxml2argv-net-vhostuser.(args|xml) to test this
usecase.

Signed-off-by: Maxime Leroy <maxime.leroy@6wind.com>
2014-10-20 08:58:09 +02:00
Jim Fehlig
793a91f8e1 libxl: add missing 'break' from commit 1298daca
Add missing 'break's from commit 1298daca, as noted by John Ferlan

https://www.redhat.com/archives/libvir-list/2014-October/msg00430.html
2014-10-16 12:42:13 -06:00
Peter Krempa
e9a1c4384c qemu: Convert qemuDomainUpdateDeviceConfig to typecasted enum 2014-10-15 12:39:30 +02:00
Peter Krempa
fa3701a94c qemu: Convert qemuDomainDetachDeviceConfig to typecasted enum 2014-10-15 12:39:30 +02:00
Peter Krempa
2536b1b952 qemu: Convert qemuDomainAttachDeviceConfig to typecasted enum 2014-10-15 12:39:29 +02:00
Peter Krempa
714dff938c qemu: Convert qemuDomainUpdateDeviceLive to typecasted enum 2014-10-15 12:39:29 +02:00
Peter Krempa
9bb21f4287 qemu: Convert qemuDomainDetachDeviceLive to typecasted enum 2014-10-15 12:39:29 +02:00
Chen Fan
fb41a3eee2 conf: fix an memory leak in virSocketAddrIsNumericLocalhost()
Signed-off-by: Chen Fan <chen.fan.fnst@cn.fujitsu.com>
2014-10-15 11:56:00 +02:00
Peter Krempa
3b9a26a325 conf: Move definition of virDomainParseMemory
Shove it to the top of the file so that it can be reused earlier.
2014-10-15 10:27:51 +02:00
Peter Krempa
0b73366945 Implement empty post parse callbacks for all drivers
To allow easy implementation of a callback check this patch adds empty
post parse callbacks to drivers that were missing them.
2014-10-15 10:27:51 +02:00
Peter Krempa
6908f8cab3 qemu: monitor: Add functions for object hot-add/remove
To allow live modification of device backends in qemu libvirt needs to
be able to hot-add/remove "objects". Add monitor backend functions to
allow this.

This function will be used for hot-add/remove of RNG backends,
IOThreads, memory backing objects, etc.
2014-10-15 10:27:50 +02:00
Peter Krempa
ddf52d01f8 util: json: Add option to skip adding a JSON object if it is NULL
Add a new option specifier that will optionally add a JSON key=value pair
containing a nested object if the added object isn't NULL.
2014-10-15 10:27:50 +02:00
Peter Krempa
81069ae3f5 util: json: Improve handling and docs for adding JSON objects
The JSON structure constructor has an option to add JSON arrays to the
constructed object. The description is inaccurate as it can add any json
object even a dict. Change the docs to cover this option and reject
adding NULL objects.
2014-10-15 10:27:50 +02:00
Peter Krempa
881c46595e util: json: Split out code to create json value objects
Our qemu monitor code has a converter from key-value pairs to a json
value object. I want to re-use the code later and having it part of the
monitor command generator is inflexible. Split it out into a separate
helper.
2014-10-15 10:27:50 +02:00
Peter Krempa
3444fdefb1 qemu: hotplug: Use typecasted switch statement when plugging new devices 2014-10-15 10:27:50 +02:00
Peter Krempa
3d6c07f7f8 conf: Add compile time check that devices were checked for ABI stability
As in the device info iterator add a switch that will force the compiler
to check that new device types are added to the ABI stability checker.
2014-10-15 10:27:50 +02:00
Peter Krempa
e7d67e7bad conf: shmem: Add ABI stability check
Although the device will probably inhibit migration add checks to make
sure that the configuration change gets caught.
2014-10-15 10:27:50 +02:00
Peter Krempa
ac5979edc4 conf: Improve adding of new address types
Use typecasted switch statement and note the type used to select the
address type in a comment.
2014-10-15 10:27:50 +02:00
Cole Robinson
fe6aff3b81 libvirt: Document UNDEFINE_NVRAM in UndefineFlags doc 2014-10-15 10:16:13 +02:00
Chen Fan
bcf54e600f conf: fix a wrong comment in virSocketAddrNumericFamily()
Signed-off-by: Chen Fan <chen.fan.fnst@cn.fujitsu.com>
2014-10-15 10:11:38 +02:00
Chen Fan
5e0561e115 conf: Check whether migration_address is localhost
When enabling the migration_address option, by default it is
set to "127.0.0.1", but it's not a valid address for migration.
so we should add verification and set the default migration_address
to "0.0.0.0".

Signed-off-by: Chen Fan <chen.fan.fnst@cn.fujitsu.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2014-10-15 09:25:33 +02:00