Commit Graph

19460 Commits

Author SHA1 Message Date
Cole Robinson
c180a3dcf7 storage: Don't leave stale state file if pool startup fails
After pool startup we call refreshPool(). If that fails, we leave
a stale pool state file hanging around.

Hit this trying to create a pool with qemu:///session containing
root owned files.
2015-04-28 09:37:57 -04:00
Cole Robinson
b29aff322f storage: Fix autostart dir for qemu:///session 2015-04-28 09:37:57 -04:00
John Ferlan
b515339fe7 qemu: Remove need for qemuMonitorIOThreadInfoFree
Replace with just VIR_FREE.
2015-04-28 06:33:49 -04:00
John Ferlan
69b16513a5 qemu: qemuProcessDetectIOThreadPIDs invert checks
If we received zero iothreads from the monitor, but were perhaps
expecting to receive something, then the code was skipping the check
to ensure what's in the monitor matches our expectations.  So invert
the checks to check that what we get back matches expectations and
then check there are zero iothreads returned.
2015-04-28 06:33:35 -04:00
John Ferlan
4c2ca5664a qemu: Remove need for qemuDomainParseIOThreadAlias
Rather than have a separate routine to parse the alias of an iothread
returned from qemu in order to get the iothread_id value, parse the alias
when returning and just return the iothread_id in qemuMonitorIOThreadInfoPtr

This set of patches removes the function, changes the "char *name" to
"unsigned int" and handles all the fallout.
2015-04-28 06:33:30 -04:00
John Ferlan
e505591e28 conf: Resolve some Coverity errors
Resolve some Coverity errors with IOThread changes

Signed-off-by: John Ferlan <jferlan@redhat.com>
2015-04-28 06:13:34 -04:00
Roman Bogorodskiy
fb9da19e90 conf: explicitly initialize 'cpumask' variable
Build with clang fails with:

  CC       conf/libvirt_conf_la-domain_conf.lo
  conf/domain_conf.c:13377:9: error: variable 'cpumask' is used
  uninitialized whenever 'if' condition is true
  [-Werror,-Wsometimes-uninitialized]
      if (!(tmp = virXMLPropString(node, "cpuset"))) {
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

and many other similar errors regarding the 'cpuset' variable.

Fix by explicitly initializing it with NULL.
2015-04-28 10:30:26 +04:00
Laine Stump
06313277f2 network: check newDef for used bridge names in addition to def
If someone has updated a network to change its bridge name, but the
network is still active (so that bridge name hasn't taken effect yet),
we still want to disallow another network from taking that new name.
2015-04-28 01:23:29 -04:00
Laine Stump
37b8bc6f12 network: check for bridge name conflict with existing devices
Since some people use the same naming convention as libvirt for bridge
devices they create outside the context of libvirt, it is much nicer
if we check for those devices when looking for a bridge device name to
auto-assign to a new network.
2015-04-28 01:21:41 -04:00
Laine Stump
a28d3e485f network: move auto-assign of bridge name from XML parser to net driver
We already check that any auto-assigned bridge device name for a
virtual network (e.g. "virbr1") doesn't conflict with the bridge name
for any existing libvirt network (via virNetworkSetBridgeName() in
conf/network_conf.c).

We also want to check that the name doesn't conflict with any bridge
device created on the host system outside the control of libvirt
(history: possibly due to the ploriferation of references to libvirt's
bridge devices in HOWTO documents all around the web, it is not
uncommon for an admin to manually create a bridge in their host's
system network config and name it "virbrX"). To add such a check to
virNetworkBridgeInUse() (which is called by virNetworkSetBridgeName())
we would have to call virNetDevExists() (from util/virnetdev.c); this
function calls ioctl(SIOCGIFFLAGS), which everyone on the mailing list
agreed should not be done from an XML parsing function in the conf
directory.

To remedy that problem, this patch removes virNetworkSetBridgeName()
from conf/network_conf.c and puts an identically functioning
networkBridgeNameValidate() in network/bridge_driver.c (because it's
reasonable for the bridge driver to call virNetDevExists(), although
we don't do that yet because I wanted this patch to have as close to 0
effect on function as possible).

There are a couple of inevitable changes though:

1) We no longer check the bridge name during
   virNetworkLoadConfig(). Close examination of the code shows that
   this wasn't necessary anyway - the only *correct* way to get XML
   into the config files is via networkDefine(), and networkDefine()
   will always call networkValidate(), which previously called
   virNetworkSetBridgeName() (and now calls
   networkBridgeNameValidate()). This means that the only way the
   bridge name can be unset during virNetworkLoadConfig() is if
   someone edited the config file on disk by hand (which we explicitly
   prohibit).

2) Just on the off chance that somebody *has* edited the file by hand,
   rather than crashing when they try to start their malformed
   network, a check for non-NULL bridge name has been added to
   networkStartNetworkVirtual().

   (For those wondering why I don't instead call
   networkValidateBridgeName() there to set a bridge name if one
   wasn't present - the problem is that during
   networkStartNetworkVirtual(), the lock for the network being
   started has already been acquired, but the lock for the network
   list itself *has not* (because we aren't adding/removing a
   network). But virNetworkBridgeInuse() iterates through *all*
   networks (including this one) and locks each network as it is
   checked for a duplicate entry; it is necessary to lock each network
   even before checking if it is the designated "skip" network because
   otherwise some other thread might acquire the list lock and delete
   the very entry we're examining. In the end, permitting a setting of
   the bridge name during network start would require that we lock the
   entire network list during any networkStartNetwork(), which
   eliminates a *lot* of parallelism that we've worked so hard to
   achieve (it can make a huge difference during libvirtd startup). So
   rather than try to adjust for someone playing against the rules, I
   choose to instead give them the error they deserve.)

3) virNetworkAllocateBridge() (now removed) would leak any "template"
   string set as the bridge name. Its replacement
   networkFindUnusedBridgeName() doesn't leak the template string - it
   is properly freed.
2015-04-28 01:20:11 -04:00
Laine Stump
dcbedfa672 test: Fix actual vs. expected in virtTestCompareFiles
Commit ca329299 added a utility function virtTestCompareFiles() to
eliminate repetitive code in several test programs. It unfortunately
calls virtTestDifference() with the arguments in the wrong order -
strcontent is the "actual" output gathered by the test rig, while
filecontent is the "expected", and virtTestDifference() wants expected
(filecontent) followed by actual (strcontent), but
virtTestCompareFiles() does the opposite, which can make the output a
bit confusing when there is a failure.
2015-04-27 15:12:23 -04:00
John Ferlan
d8082d2d44 qemu: Resolve Coverity DEADCODE
Coverity notes that the switch() used to check 'connected' values has
two DEADCODE paths (_DEFAULT & _LAST).  Since 'connected' is a boolean
it can only be one or the other (CONNECTED or DISCONNECTED), so it just
seems pointless to use a switch to get "all" values.  Convert to if-else
2015-04-27 14:55:35 -04:00
John Ferlan
1f7e811249 virsh: Add iothreadadd and iothreaddel commands
https://bugzilla.redhat.com/show_bug.cgi?id=1161617

Add command to allow adding and removing IOThreads from the domain including
the configuration and live domain.

$ virsh iothreadadd --help
  NAME
    iothreadadd - add an IOThread to the guest domain

  SYNOPSIS
    iothreadadd <domain> <id> [--config] [--live] [--current]

  DESCRIPTION
    Add an IOThread to the guest domain.

  OPTIONS
    [--domain] <string>  domain name, id or uuid
    [--id] <number>  iothread for the new IOThread
    --config         affect next boot
    --live           affect running domain
    --current        affect current domain

$ virsh iothreaddel --help
  NAME
    iothreaddel - delete an IOThread from the guest domain

  SYNOPSIS
    iothreaddel <domain> <id> [--config] [--live] [--current]

  DESCRIPTION
    Delete an IOThread from the guest domain.

  OPTIONS
    [--domain] <string>  domain name, id or uuid
    [--id] <number>  iothread_id for the IOThread to delete
    --config         affect next boot
    --live           affect running domain
    --current        affect current domain

Assuming a running $dom with multiple IOThreads assigned and that
that the $dom has disks assigned to IOThread 1 and IOThread 2:

$ virsh iothreadinfo $dom
 IOThread ID     CPU Affinity
 ---------------------------------------------------
  1               2
  2               3
  3               0-1

$ virsh iothreadadd $dom 1
error: invalid argument: an IOThread is already using iothread_id '1' in iothreadpids

$ virsh iothreadadd $dom 1 --config
error: invalid argument: an IOThread is already using iothread_id '1' in persistent iothreadids

$ virsh iothreadadd $dom 4
$ virsh iothreadinfo $dom
 IOThread ID     CPU Affinity
 ---------------------------------------------------
  1               2
  2               3
  3               0-1
  4               0-3

$ virsh iothreadinfo $dom --config
 IOThread ID     CPU Affinity
 ---------------------------------------------------
  1               2
  2               3
  3               0-1

$ virsh iothreadadd $dom 4 --config
$ virsh iothreadinfo $dom --config
 IOThread ID     CPU Affinity
  ---------------------------------------------------
    1               2
    2               3
    3               0-1
    4               0-3

Assuming the same original configuration

$ virsh iothreaddel $dom 1
error: invalid argument: cannot remove IOThread 1 since it is being used by disk 'vde'

$ virsh iothreaddel $dom 3

$ virsh iothreadinfo $dom
 IOThread ID     CPU Affinity
 ---------------------------------------------------
  1               2
  2               3

$ virsh iothreadinfo $dom --config
 IOThread ID     CPU Affinity
 ---------------------------------------------------
  1               2
  2               3
  3               0-1
2015-04-27 12:36:36 -04:00
John Ferlan
a27ed6e78c qemu: Add support to Add/Delete IOThreads
Add qemuDomainAddIOThread and qemuDomainDelIOThread in order to add or
remove an IOThread to/from the host either for live or config optoins

The implementation for the 'live' option will use the iothreadpids list
in order to make decision, while the 'config' option will use the
iothreadids list.  Additionally, for deletion each may have to adjust
the iothreadpin list.

IOThreads are implemented by qmp objects, the code makes use of the existing
qemuMonitorAddObject or qemuMonitorDelObject APIs.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2015-04-27 12:36:36 -04:00
John Ferlan
c6e2dc800d domain: Introduce virDomainIOThreadSchedDelId
We're about to allow IOThreads to be deleted, but an iothreadid may be
included in some domain thread sched, so add a new API to allow removing
an iothread from some entry.

Then during the writing of the threadsched data and an additional check
to determine whether the bitmap is all clear before writing it out.
2015-04-27 12:36:36 -04:00
John Ferlan
5bb343f355 remote: Add support for AddIOThread and DelIOThread
Add remote support for the add/delete IOThread API's
2015-04-27 12:36:36 -04:00
John Ferlan
130a0ed281 Implement virDomainAddIOThread and virDomainDelIOThread
Add libvirt API's to manage adding and deleting IOThreads to/from the
domain
2015-04-27 12:36:36 -04:00
John Ferlan
4dec8a0160 conf: Adjust the iothreadsched expectations
With iothreadid's allowing any 'id' value for an iothread_id, the
iothreadsched code needs a slight adjustment to allow for "any"
unsigned int value in order to create the bitmap of ids that will
have scheduler adjustments. Adjusted the doc description as well.
2015-04-27 12:36:35 -04:00
John Ferlan
b266486fb9 Move iothreadspin information into iothreadids
Remove the iothreadspin array from cputune and replace with a cpumask
to be stored in the iothreadids list.

Adjust the test output because our printing goes in order of the iothreadids
list now.
2015-04-27 12:36:35 -04:00
John Ferlan
b96254d4a1 conf: Move virDomainPinIsDuplicate and make static
Since it's only ever referenced in domain_conf.c, make the function
static, but also will need to move it to somewhere before it's referenced
rather than forward referencing it.
2015-04-27 12:36:35 -04:00
John Ferlan
8d4614a512 qemu: Use domain iothreadids to IOThread's 'thread_id'
Add 'thread_id' to the virDomainIOThreadIDDef as a means to store the
'thread_id' as returned from the live qemu monitor data.

Remove the iothreadpids list from _qemuDomainObjPrivate and replace with
the new iothreadids 'thread_id' element.

Rather than use the default numbering scheme of 1..number of iothreads
defined for the domain, use the iothreadid's list for the iothread_id

Since iothreadids list keeps track of the iothread_id's, these are
now used in place of the many places where a for loop would "know"
that the ID was "+ 1" from the array element.

The new tests ensure usage of the <iothreadid> values for an exact number
of iothreads and the usage of a smaller number of <iothreadid> values than
iothreads that exist (and usage of the default numbering scheme).
2015-04-27 12:36:35 -04:00
John Ferlan
93383c1ffa conf: Add new domain XML element 'iothreadids'
Adding a new XML element 'iothreadids' in order to allow defining
specific IOThread ID's rather than relying on the algorithm to assign
IOThread ID's starting at 1 and incrementing to iothreads count.

This will allow future patches to be able to add new IOThreads by
a specific iothread_id and of course delete any exisiting IOThread.

Each iothreadids element will have 'n' <iothread> children elements
which will have attribute "id".  The "id" will allow for definition
of any "valid" (eg > 0) iothread_id value.

On input, if any <iothreadids> <iothread>'s are provided, they will
be marked so that we only print out what we read in.

On input, if no <iothreadids> are provided, the PostParse code will
self generate a list of ID's starting at 1 and going to the number
of iothreads defined for the domain (just like the current algorithm
numbering scheme).  A future patch will rework the existing algorithm
to make use of the iothreadids list.

On output, only print out the <iothreadids> if they were read in.
2015-04-27 12:36:35 -04:00
Martin Kletzander
a7f0db6904 Cleanup parameters for mock libraries
All the libraries use same parameters when building, why not have it in
one place at the begining of the Makefile.

This will also ensure no new mock library will have a problem with
missing e.g. MINGW_EXTRA_LDFLAGS.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2015-04-27 16:31:19 +02:00
Michal Privoznik
f58a3a51fc Cleanup srcdir usage
In a lot places we use path like this:

  $(srcdir)/../src/....

when in fact it can be:

  $(top_srcdir)/src/

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-04-27 16:03:31 +02:00
zhang bo
ab7cd11e0b util: fix memleak in virStorageSourceClear
snapshot and configFile are not freed, free them.

Signed-off-by: Zhang Bo <oscar.zhangbo@huawei.com>
2015-04-27 15:37:13 +02:00
Pavel Fedin
9dc57ce2c4 Add missing linker flags for MinGW build
This fix should completely close
https://bugzilla.redhat.com/show_bug.cgi?id=1214605

Signed-off-by: Pavel Fedin <p.fedin@samsung.com>
2015-04-27 15:36:54 +02:00
John Ferlan
0259426060 storage: Resolve Coverity UNINIT
commit id '1e13eff4' didn't init found when changed from a bool to
an int in virStoragePoolFCRefreshThread and Coverity...
2015-04-27 06:57:51 -04:00
Michal Privoznik
4803c855bb openvz: Drop useless domain lookup
The lookup is just for check whether a domain we are about to add does
not already exists. Well, the virDomainObjListAdd() function does that
for us already so there's no need to duplicate the check.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-04-27 11:26:37 +02:00
Martin Kletzander
6957a606a5 Fix check for return value of qemuDomainAgentAvailable()
Commit dcbb243bbc used the return value of
the function as int even though it returns bool.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2015-04-27 10:11:35 +02:00
Zhang Bo
d38d3c25f4 conf: fix memleak in virDomainHostdevDefClear
use virNetworkRouteDefFree() instead of VIR_FREE to free routes, otherwise
the element 'family' would not be freed.

Signed-off-by: Zhang Bo <oscar.zhangbo@huawei.com>
2015-04-27 10:04:38 +02:00
Zhang Bo
7e3faa0959 conf: fix memleak in virDomainNetIpParseXML
use cleanup instead of error, so that the allocated strings could also get freed
when there's no error.

Signed-off-by: Zhang Bo <oscar.zhangbo@huawei.com>
2015-04-27 10:04:38 +02:00
Zhang Bo
768ec8c16d qemu: fix memleak in virCapabilitiesDomainDataLookup
virBufferContentAndReset() doesn't free buf contents, we should use
virBufferFreeAndReset() to get buf freed.

Signed-off-by: Zhang Bo <oscar.zhangbo@huawei.com>
2015-04-27 10:04:38 +02:00
Zhang Bo
0a8bd97afa qemu: fix memleaks in qemuBuildCommandLine
free boot_opts_str and boot_order_str both in normal and error paths.

Signed-off-by: Zhang Bo <oscar.zhangbo@huawei.com>
2015-04-27 10:04:38 +02:00
Zhang Bo
6fabe2f227 util: fix memleak in virFindSCSIHostByPCI
free buf in cleanup.

Signed-off-by: Zhang Bo <oscar.zhangbo@huawei.com>
2015-04-27 10:04:38 +02:00
Zhang Bo
083ac198bc tests: fix some memleaks in tests
Signed-off-by: Zhang Bo <oscar.zhangbo@huawei.com>
2015-04-27 10:04:38 +02:00
Jiri Denemark
659dbba37e qemu: Fix comment for timeDelta
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2015-04-27 09:43:27 +02:00
zhang bo
21b64552fe Fix typo in comment about memory binding
rather then -> rather than

Signed-off-by: YueWenyuan <yuewenyuan@huawei.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2015-04-27 09:05:29 +02:00
Peter Krempa
a03e2d3a99 qemu: Connect to guest agent after channel hotplug
If a user hot-attaches the guest agent channel libvirt would ignore it
until the restart of libvirtd or shutdown/destroy and start of the VM
itself.

This patch adds code that opens or closes the guest agent connection
according to the state of the guest agent channel according to
connect/disconnect events.

To allow opening the channel from the event handler qemuConnectAgent
needed to be exported.
2015-04-26 17:19:22 +02:00
Peter Krempa
e1c04108d7 qemu: agent: Differentiate errors when the agent channel was hotplugged
When the guest agent channel gets hotplugged to a VM, libvirt would
still report that "QEMU guest agent is not configured" rather than
stating that the connection was not established yet.

Currently the code won't be able to connect to the agent after hotplug
but that will change in a later patch.

As the qemuFindAgentConfig() helper is quite helpful in this case move
it to a more usable place and export it.
2015-04-26 17:19:22 +02:00
Peter Krempa
dcbb243bbc qemu: Reuse qemuDomainAgentAvailable in qemuDomainInterfaceAddresses 2015-04-26 17:19:22 +02:00
Peter Krempa
c6351cc689 qemu: Fix domain object leak in qemuDomainInterfaceAddresses
The API didn't use virDomainObjEndAPI to release the domain object thus
it leaked a reference to it.
2015-04-26 17:19:22 +02:00
Peter Krempa
249992876b qemu: agent: Reuse virJSONValueObjectCreateVArgs in qemuAgentMakeCommand
Since the code is now separated into the common helper, we can reuse it
instead of maintaining two copies.
2015-04-26 17:19:22 +02:00
Olaf Hering
bb5fc7214e libxl: remove duplicate check for pci subsystem type
Both attach and detach functions get called only if the type matches.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Cc: Jim Fehlig <jfehlig@suse.com>
2015-04-24 15:22:20 -06:00
Olaf Hering
f54391b447 libxl: use pci init and dispose functions
Rearrange code so that the local variable is always initialized and
disposed.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Cc: Jim Fehlig <jfehlig@suse.com>
2015-04-24 15:02:08 -06:00
Jim Fehlig
247b2c5388 libxl: initialize sdl.opengl defbool in libxlMakeVfb
Commit bf32462b missed initializing sdl.opengl.  Without the
initialization, libvirtd will be terminated by an assert from libxl:

Assertion `!libxl_defbool_is_default(db)' failed.

Reported-by: Olaf Hering <olaf@aepfle.de>
2015-04-24 14:11:26 -06:00
Olaf Hering
bf32462bd3 libxl: initialize vfb defbools in libxlMakeVfb
If the domU configu has sdl enabled libvirtd crashes:
libvirtd[5158]: libvirtd: libxl.c:343: libxl_defbool_val:
Assertion `!libxl_defbool_is_default(db)' failed.

Initialize the relevant defbool variables in libxl_device_vfb.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Cc: Jim Fehlig <jfehlig@suse.com>
2015-04-24 13:17:36 -06:00
Maxim Nestratov
62d1814614 parallels: fix crash in prlsdkAddNet in case of CT definition
Since net->model is not defined for containers we shouldn't touch it.
In case network adapter model is defined, a warning about ignoring
it is shown.

Signed-off-by: Maxim Nestratov <mnestratov@parallels.com>
2015-04-24 21:38:54 +03:00
John Ferlan
6f75779ece virhostdev: Fix comments for virHostdevReAttachPCIDevices
Pushed previous patch (commit id 'd45dadae6') too quickly...

The patch just updates the patch from Laine's suggestions.
2015-04-24 13:38:01 -04:00
Roman Bogorodskiy
0d6563d7f0 bhyve: fix build in tests
Commit ca32929 caused build errors in bhyvexml2argvtest.c because of
some undefined variables.

Pushing under the build breaker rule.
2015-04-24 19:54:12 +03:00
Huanle Han
d45dadae6c hostdev: fix net config restore error
Fix for such a case:
1. Domain A and B xml contain the same SRIOV net hostdev(<interface
type='hostdev' /> with same pci address).
2. virsh start A (Successfully, and configure the SRIOV net with
custom mac)
3. virsh start B (Fail because of the hostdev used by domain A or other
reason.)
In step 3, 'virHostdevNetConfigRestore' is called for the hostdev
which is still used by domain A. It makes the mac/vlan of the SRIOV net
change.

Code Change in this fix:
1. As the pci used by other domain have been removed from
'pcidevs' in previous loop, we only restore the nic config for
the hostdev still in 'pcidevs'(used by this domain)
2. update the comments to make it more clear

Signed-off-by: Huanle Han <hanxueluo@gmail.com>
2015-04-24 12:28:59 -04:00