Commit Graph

13932 Commits

Author SHA1 Message Date
Michal Privoznik
52430928d1 virNetworkObjList: Derive from virObjectLockableClass
Later we can turn APIs to lock the object if needed instead of
relying on caller to mutually exclude itself (probably done by
locking a big lock anyway).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-03-11 16:58:48 +01:00
Michal Privoznik
5a84a07857 parallels_network: Use virNetworkObjEndAPI
So far, this is pure code replacement. But once we introduce
reference counting to virNetworkObj this will be more handy as
there'll be only one function to change: virNetworkObjEndAPI().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-03-11 16:58:48 +01:00
Michal Privoznik
107c9a561b test_driver: Use virNetworkObjEndAPI
So far, this is pure code replacement. But once we introduce
reference counting to virNetworkObj this will be more handy as
there'll be only one function to change: virNetworkObjEndAPI().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-03-11 16:58:48 +01:00
Michal Privoznik
37c2bad77d bridge_driver: Use virNetworkObjEndAPI
So far, this is pure code replacement. But once we introduce
reference counting to virNetworkObj this will be more handy as
there'll be only one function to change: virNetworkObjEndAPI().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-03-11 16:58:48 +01:00
Michal Privoznik
aa7c7f880e network_conf: Introduce virNetworkObjEndAPI
This is practically copy of qemuDomObjEndAPI. The reason why is
it so widely available is to avoid code duplication, since the
function is going to be called from our bridge driver, test
driver and parallels driver too.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-03-11 16:58:48 +01:00
Michal Privoznik
ea57049156 network_conf: Make virNetworkObj actually virObject
So far it's just a structure which happens to have 'Obj' in its
name, but otherwise it not related to virObject at all. No
reference counting, not virObjectLock(), nothing.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-03-11 16:58:48 +01:00
Michal Privoznik
8529d5ec6b virNetworkObjListPtr: Turn list into a hash table
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-03-11 16:58:48 +01:00
Peter Krempa
d3534a43e6 qemu: monitor: Kill qemuMonitorGetBlockStats(Info,ParamsNumber)
The functions and their QMP and HMP implementations are no longer needed
since everything is now done via the *AllStats functions.
2015-03-11 11:28:04 +01:00
Peter Krempa
e045587dda qemu: blockstats: Refactor qemuDomainBlockStatsFlags
Now that qemuDomainBlocksStatsGather provides functions of both
qemuMonitorGetBlockStatsParamsNumber and qemuMonitorGetBlockStatsInfo we
can reuse it and kill a lot of code.

Additionally as a bonus qemuDomainBlockStatsFlags will now support
summary statistics so add a statement to the virsh man page about that.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1142636
2015-03-11 11:28:04 +01:00
Peter Krempa
cf093414c5 qemu: blockstats: Add support for totalled block statistics
In the LXC driver, if the disk path is not provided the API returns
total statistics for all disks of the domain. With the new text monitor
implementation this can be now done in the qemu driver too.

Add code that wil total the stats for all disks if the path is not
provided.
2015-03-11 11:28:04 +01:00
Peter Krempa
79966411cd qemu: Split out working code qemuDomainBlockStats
Extract the code to look up the disk alias and return the block stats
struct so that it can be reused later in qemuDomainBlockStatsFlags.

The function uses qemuMonitorGetAllBlockStatsInfo instead of
qemuMonitorGetBlockStatsInfo.
2015-03-11 11:28:04 +01:00
Peter Krempa
bdc05128d7 qemu: monitor: Count block stats fields in qemuMonitorGetAllBlockStatsInfo
Our virDomainBlockStatsFlags API uses the old approach where, when it's
called without the typed parameter array, returns the count of parameters
supported by qemu.

The supported parameter count is obtained via separate monitor calls
which is a waste since we can calculate it when gathering the data.

This patch adds code to the qemuMonitorGetAllBlockStatsInfo workers that
allows to track the count of supported fields reported by qemu and will
allow to remove the old duplicate code.
2015-03-11 11:28:04 +01:00
Peter Krempa
4d8ebb7a35 qemu: monitor: Convert common code to a macro
The function that is extracting block stats data from the QMP monitor
reply contains a lot of repeated code. Since I'd be changing each of the
copies in the next patch, lets convert it to a macro right away.
2015-03-11 11:28:04 +01:00
Peter Krempa
f6563bc361 qemu: monitor: Implement HMP version for listing all block device stats
Add a different version of parser for "info blockstats" that basically
parses the same information as the existing copy of the function.

This will allow us to remove the single device version
qemuMonitorGetBlockStatsInfo in the future.

The new implementation uses few new helpers so it should be more
understandable and provides a test case to verify that it works.
2015-03-11 11:28:04 +01:00
Peter Krempa
4f6b6788c4 qemu: blockstats: Switch to caller allocated hash table
Allocate the hash table in the monitor wrapper function instead of the
worker itself so that the text monitor impl that will be added in the
next patch doesn't have to duplicate it.
2015-03-11 11:28:03 +01:00
Peter Krempa
32288fc9b9 qemu: monitor: Drop parsing of 'errs' from block info
The error count statistic is not supported by qemu, so there's no need
to pass the variables around if the result is ignored anyways.
2015-03-11 11:28:03 +01:00
Peter Krempa
7e9fb15145 qemu: Use macro to set block stats typed parameters
All the setters are the same code except for parameter name and
variable, so they can be converted to a macro to save a ton of
duplicated code.
2015-03-11 11:28:03 +01:00
Maxim Nestratov
0473e1bb16 parallels: prevent domain define only if vcpupin is specified
and their settings differ from common cpumask

Signed-off-by: Maxim Nestratov <mnestratov@parallels.com>
2015-03-11 09:00:28 +01:00
Maxim Nestratov
3f2d67bbfa parallels: prevent domain define only if NUMA is really specified
Signed-off-by: Maxim Nestratov <mnestratov@parallels.com>
2015-03-11 09:00:28 +01:00
Maxim Nestratov
2add64a0cf parallels: don't forget to unlock domain in parallelsDomainHasManagedSaveImage
Signed-off-by: Maxim Nestratov <mnestratov@parallels.com>
2015-03-11 09:00:14 +01:00
Maxim Nestratov
a4e0f2343f parallels: cpumask support
Signed-off-by: Maxim Nestratov <mnestratov@parallels.com>
2015-03-11 08:24:42 +01:00
Michael Chapman
616003d6bd domain_conf: fix crash in virDomainObjListFindByUUIDInternal
If a domain object is being removed and looked up concurrently we must
ensure we unlock the object before unreferencing it, since the latter
might free the object.

The flaw was introduced in commit feb1a4d792.

Signed-off-by: Michael Chapman <mike@very.puzzling.org>
2015-03-11 08:20:51 +01:00
Michael Chapman
a6ec4f472d {domain, network}_conf: disable autostart when deleting config
Undefining a running, autostarted domain removes the autostart link, but
dom->autostart is not cleared. If the domain is subsequently redefined,
libvirt thinks it is already autostarted and will not create the link
even if requested:

  # virsh dominfo example | grep Autostart
  Autostart:      enable

  # ls /etc/libvirt/qemu/autostart/example.xml
  /etc/libvirt/qemu/autostart/example.xml

  # virsh undefine example
  Domain example has been undefined

  # virsh define example.xml
  Domain example defined from example.xml

  # virsh dominfo example | grep Autostart
  Autostart:      enable

  # virsh autostart example
  Domain example marked as autostarted

  # ls /etc/libvirt/qemu/autostart/example.xml
  ls: cannot access /etc/libvirt/qemu/autostart/example.xml: No such file or directory

This commit ensures dom->autostart is cleared whenever the config and
autostart link (if present) are removed.

The bridge network driver cleared this flag itself in networkUndefine.
This commit moves this into virNetworkDeleteConfig for symmetry with
virDomainDeleteConfig, and to ensure it is not missed in future network
drivers.

Signed-off-by: Michael Chapman <mike@very.puzzling.org>
2015-03-11 07:16:25 +01:00
Luyao Huang
64595431cd qemu: Remove unnecessary virReportError on networkGetNetworkAddress return
Error messages are already set in all code paths returning -1 from
networkGetNetworkAddress, so we don't want to overwrite them.

Signed-off-by: Luyao Huang <lhuang@redhat.com>
Signed-off-by: John Ferlan <jferlan@redhat.com>
2015-03-10 17:29:28 -04:00
Michal Privoznik
954427c354 virQEMUCapsInitQMP: Don't dispose locked @vm
When creating qemu capabilities, a dummy virDomainObj is created just
because our monitor code expects that. However, the object is created
locked already. Then, under cleanup label, we simply unref the object
which results in whole domain object to be disposed. The object lock
is destroyed subsequently, but hey - it's still locked:

==24845== Thread #14's call to pthread_mutex_destroy failed
==24845==    with error code 16 (EBUSY: Device or resource busy)
==24845==    at 0x4C3024E: pthread_mutex_destroy (in /usr/lib64/valgrind/vgpreload_helgrind-amd64-linux.so)
==24845==    by 0x531F72E: virMutexDestroy (virthread.c:83)
==24845==    by 0x5302977: virObjectLockableDispose (virobject.c:237)
==24845==    by 0x5302A89: virObjectUnref (virobject.c:265)
==24845==    by 0x1DD37866: virQEMUCapsInitQMP (qemu_capabilities.c:3397)
==24845==    by 0x1DD37CC6: virQEMUCapsNewForBinary (qemu_capabilities.c:3481)
==24845==    by 0x1DD381E2: virQEMUCapsCacheLookup (qemu_capabilities.c:3609)
==24845==    by 0x1DD30F8A: virQEMUCapsInitGuest (qemu_capabilities.c:744)
==24845==    by 0x1DD31889: virQEMUCapsInit (qemu_capabilities.c:1020)
==24845==    by 0x1DD7DD36: virQEMUDriverCreateCapabilities (qemu_conf.c:888)
==24845==    by 0x1DDC57C0: qemuStateInitialize (qemu_driver.c:803)
==24845==    by 0x53DC743: virStateInitialize (libvirt.c:777)
==24845==

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-03-10 17:32:12 +01:00
Chen Fan
f276b36d65 qemu: fix memory leak in qemuAgentGetFSInfo
in virDomainFSInfoFree(), don't free the virDomainFSInfo data.

==10670== 80 bytes in 2 blocks are definitely lost in loss record 576 of 793
==10670==    at 0x4A06BC3: calloc (vg_replace_malloc.c:618)
==10670==    by 0x509DEBD: virAlloc (viralloc.c:144)
==10670==    by 0x19FBD558: qemuAgentGetFSInfo (qemu_agent.c:1837)
==10670==    by 0x1A03CF91: qemuDomainGetFSInfo (qemu_driver.c:19238)

Signed-off-by: Chen Fan <chen.fan.fnst@cn.fujitsu.com>
2015-03-10 15:29:28 +01:00
Ján Tomko
7b2f12fe28 Use virBitmapNextClearBit in networkNextClassID
Instead of finding the next clear bit by calling virBitmapGetBit
in a loop, use the virBitmapNextClearBit helper.
2015-03-10 13:45:51 +01:00
Laine Stump
705242f880 qemu: don't fill in nicindexes for session mode libvirtd
Commit 4bbe1029f fixed a problem in commit f7afeddc by moving the call
to virNetDevGetIndex() to a location common to all interface types (so
that the nicindex array would be filled in for macvtap as well as tap
interfaces), but the location was *too* common, as the original call
to virNetDevGetIndex() had been in a section qualified by "if
(cfg->privileged)". The result was that the "fixed" libvirtd would try
to call virNetDevGetIndex() even for session mode libvirtd, and end up
failing with the log message:

  Unable to open control socket: Operation not permitted

To remedy that, this patch qualifies the call to virNetDevGetIndex()
in its new location with cfg->privileged.

This resolves https://bugzilla.redhat.com/show_bug.cgi?id=1198244
2015-03-10 07:53:10 -04:00
Michal Privoznik
a663c34ad0 virnet*: Don't unlock object in dispose
As of bba93d40 all of our RPC objects are derived from
virObjectLockable. However, during rewrite some errors sneaked
in. For instance, the dispose functions to virNetClient and
virNetServerClient objects were not only freeing allocated
memory, but unlocking themselves. This is wrong. Object should
never disappear while locked.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-03-10 12:36:08 +01:00
Pavel Hrdina
b7d027b6a8 net-define: update or unify documentation
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1127045

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2015-03-09 14:48:38 +01:00
Pavel Hrdina
03369d9643 pool-define: update and unify documentation
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1127045

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2015-03-09 14:47:53 +01:00
Pavel Hrdina
0632555927 iface-define: update and unify documentation
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1127045

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2015-03-09 14:47:07 +01:00
Michal Privoznik
367363659b network_conf: Turn struct _virNetworkObjList private
Now that all the code uses accessors, don't expose the structure
anyway.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-03-09 14:03:30 +01:00
Michal Privoznik
88aed14f12 network_conf: Turn virNetworkObjList into virObject
Well, one day this will be self-locking object, but not today.
But lets prepare the code for that! Moreover,
virNetworkObjListFree() is no longer needed, so turn it into
virNetworkObjListDispose().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-03-09 14:03:30 +01:00
Michal Privoznik
58092dfe87 parallels_network: Adapt to new virNetworkObjList accessors
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-03-09 14:03:30 +01:00
Michal Privoznik
d8e01f527b test_driver: Adapt to new virNetworkObjList accessors
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-03-09 14:03:30 +01:00
Michal Privoznik
b61db335f9 bridge_driver: Adapt to new virNetworkObjList accessors
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-03-09 14:03:30 +01:00
Michal Privoznik
292acd202f network_conf: Introduce virNetworkObjListPrune
The API will iterate over the list of network object and remove
desired ones from it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-03-09 14:03:30 +01:00
Michal Privoznik
0ae7def635 network_conf: Introduce virNetworkObjListNumOfNetworks
An accessor following pattern laid out by virDomainObjList* APIs.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-03-09 14:03:30 +01:00
Michal Privoznik
5a13c48b73 network_conf: Introduce virNetworkObjListGetNames
An accessor following pattern laid out by virDomainObjList* APIs.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-03-09 14:03:30 +01:00
Michal Privoznik
454fe219ef network_conf: Introduce virNetworkObjListForEach
This API will be used in the future to call passed callback over
each network object in the list. It's slightly different to its
virDomainObjListForEach counterpart, because virDomainObjList
uses a hash table to store domain object, while virNetworkObjList
uses an array.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-03-09 14:03:30 +01:00
Jiri Denemark
54972be843 sanlock: Don't spam logs with "target pid not found"
Commit v1.2.4-52-gda879e5 fixed issues with domains started before
sanlock driver was enabled by checking whether a running domain is
registered with sanlock and if it's not, sanlock driver is basically
ignored for the domain.

However, it was checking this even for domain which has just been
started and no sanlock_* API was called for them yet. This results in

    cmd 9 target pid 2135544 not found

error messages to appear in sanlock.log whenever we start a new domain.

This patch avoids this useless check for freshly started domains.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2015-03-09 13:36:40 +01:00
Jiri Denemark
6beb75d96d locking: Fix flags in virLockManagerLockDaemonNew
virLockManager*New APIs are never called with
VIR_LOCK_MANAGER_USES_STATE. Moreover, lockd driver does not maintain
any state that would need to be transferred during migration and thus it
should not mention VIR_LOCK_MANAGER_USES_STATE at all.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2015-03-09 13:36:39 +01:00
John Ferlan
86ef105a1d qemu: Change qemuDomainGetEmulatorPinInfo bitmap manipulation
Follow-up to the IOThread review on CPU affinity map manipulation:

http://www.redhat.com/archives/libvir-list/2015-March/msg00294.html

indicates that the GetEmulatorPinInfo could use similar algorithm adjustments
which is what this patch does.
2015-03-09 08:11:49 -04:00
John Ferlan
10f2740ae3 qemu: Change qemuDomainGetVcpuPinInfo bitmap manipulation
Follow-up to the IOThread review on CPU affinity map manipulation:

http://www.redhat.com/archives/libvir-list/2015-March/msg00294.html

indicates that the GetVcpuPinInfo could use similar algorithm adjustments
which is what this patch does.
2015-03-09 08:11:49 -04:00
John Ferlan
fcb13292b1 qemu: Resolve Coverity CHECKED_RETURN issue
By adding a call and check of return of virBitmapToData to the
IOThreads code, my Coverity checker lets me know qemuDomainHelperGetVcpus
also needs to check the status...
2015-03-09 08:11:49 -04:00
John Ferlan
daefe3f300 qemu: Change/Fix IOThread CPU affinity bitmap manipulation
Based on review:

http://www.redhat.com/archives/libvir-list/2015-March/msg00294.html

Adjust how the cpumap and cpumaplen to be returned are generated
2015-03-09 08:11:43 -04:00
John Ferlan
69e5f37c4a Remove ReadOnly check for GetIOThreadsInfo 2015-03-09 06:41:44 -04:00
Michal Privoznik
b39b1397ea domain_conf: Format <pvpanic/> without address correctly
We have something like pvpanic device. However, in some cases it does
not have any address assigned, in which case we produce this ugly XML
(still valid though):

  <devices>
    <emulator>/usr/bin/qemu</emulator>
    ...
    <panic>
    </panic>
  </devices>

Lets format "<panic/>" instead.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-03-06 14:22:45 +01:00
John Ferlan
82649eb7f1 qemu: Implement the qemu driver fetch for IOThreads
Depending on the flags passed, either attempt to return the active/live
IOThread data for the domain or the config data.

The active/live path will call into the Monitor in order to get the
IOThread data and then correlate the thread_id's returned from the
monitor to the currently running system/threads in order to ascertain
the affinity for each iothread_id.

The config path will map each of the configured IOThreads and return
any configured iothreadspin data

Signed-off-by: John Ferlan <jferlan@redhat.com>
2015-03-06 06:49:32 -05:00
John Ferlan
1e5a8ddc81 remote: Implement the remote plumbing for virDomainGetIOThreadsInfo
Implement the remote plumbing for virDomainGetIOThreadsInfo

Signed-off-by: John Ferlan <jferlan@redhat.com>
2015-03-06 06:49:32 -05:00
John Ferlan
11a5a0956f Implement public API for virDomainGetIOThreadsInfo
Add virDomainGetIOThreadInfo in order to return a list of
virDomainIOThreadInfoPtr structures which list the IOThread ID
and the CPU Affinity map for each IOThread for the domain.

For an active domain, the live data will be returned, while for
an inactive domain, the config data will be returned.

The API supports either the --live or --config flag, but not both.

Also added virDomainIOThreadsInfoFree in order to free the cpumap
and the IOThreadInfo structure.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2015-03-06 06:49:32 -05:00
Pavel Hrdina
cf521fc8ba memtune: change the way how we store unlimited value
There was a mess in the way how we store unlimited value for memory
limits and how we handled values provided by user.  Internally there
were two possible ways how to store unlimited value: as 0 value or as
VIR_DOMAIN_MEMORY_PARAM_UNLIMITED.  Because we chose to store memory
limits as unsigned long long, we cannot use -1 to represent unlimited.
It's much easier for us to say that everything greater than
VIR_DOMAIN_MEMORY_PARAM_UNLIMITED means unlimited and leave 0 as valid
value despite that it makes no sense to set limit to 0.

Remove unnecessary function virCompareLimitUlong.  The update of test
is to prevent the 0 to be miss-used as unlimited in future.

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

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2015-03-06 11:52:24 +01:00
Pavel Hrdina
a73395ae66 virutil: introduce helper functions for memory limits
The first one is to truncate the memory limit to
VIR_DOMAIN_MEMORY_PARAM_UNLIMITED if the value is greater and the second
one is to decide whether the memory limit is set or not, unlimited means
that it's not set.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2015-03-06 11:52:23 +01:00
Stefan Berger
9954a8bfc2 qemu: Pass file descriptor when using TPM passthrough
Pass the TPM file descriptor to QEMU via command line.
Instead of passing /dev/tpm0 we now pass /dev/fdset/10 and the additional
parameters -add-fd set=10,fd=20.

This addresses the use case when QEMU is started with non-root privileges
and QEMU cannot open /dev/tpm0 for example.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2015-03-05 18:57:06 -05:00
Stefan Berger
42bee147fe qemu: Move TPM command line build code into own function
Move the TPM command line build code into its own function.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2015-03-05 18:57:06 -05:00
Stefan Berger
a06e9ce11d utils: Implement virCommandPassFDGetFDIndex
Implement virCommandPassFDGetFDIndex to determine the index a given
file descriptor will have when passed to the child process.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2015-03-05 18:57:06 -05:00
Jim Fehlig
3b7f589571 libxl: remove unneeded cleanup_unlock label
In the old days of a global driver lock, it was necessary to unlock
the driver after a domain restore operation.  When the global lock
was removed from the driver, some remnants were left behind in
libxlDomainRestoreFlags.  Remove this unneeded (and incorrect) code.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
2015-03-05 09:05:35 -07:00
Jim Fehlig
b1d159d889 libxl: use libxl_ctx passed to libxlConsoleCallback
Instead of using the libxl_ctx in the libxlDomainObjPrivatePtr,
use the ctx passed to the callback.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
2015-03-05 09:05:34 -07:00
Jim Fehlig
fc3ef44ea4 libxl: remove redundant calls to libxl_evdisable_domain_death
Domain death watch is already disabled in libxlDomainCleanup.  No
need to disable it a second and third time.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
2015-03-05 09:05:34 -07:00
Peter Krempa
7909300498 conf: Remove duplicate entries in <metadata> by namespace
Since the APIs support just one element per namespace and while
modifying an element all duplicates would be removed, let's do this
right away in the post parse callback.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1190590
2015-03-05 16:24:34 +01:00
Michal Privoznik
5aee81a0cb qemu: Allow spaces in disk serial
https://bugzilla.redhat.com/show_bug.cgi?id=1195660

There's been a bug report appearing on the qemu-devel list, that
libvirt is unable to pass spaces in disk serial number [1]. Not only
our RNG schema forbids that, the code is not prepared either. However,
with a bit of escaping (if needed) we can allow spaces there.

1: https://lists.gnu.org/archive/html/qemu-devel/2015-02/msg04041.html

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-03-05 13:35:55 +01:00
Ján Tomko
41c5baeafb Fix build on mingw
Last commit unconditionally included a linux-specific header.

Do not do that.
2015-03-05 12:04:11 +01:00
James Chapman
c9027d8f44 SRIOV NIC offload feature discovery
Adding functionality to libvirt that will allow it
query the ethtool interface for the availability
of certain NIC HW offload features

Here is an example of the feature XML definition:

<device>
<name>net_eth4_90_e2_ba_5e_a5_45</name>
  <path>/sys/devices/pci0000:00/0000:00:03.0/0000:08:00.1/net/eth4</path>
  <parent>pci_0000_08_00_1</parent>
  <capability type='net'>
    <interface>eth4</interface>
    <address>90:e2:ba:5e:a5:45</address>
    <link speed='10000' state='up'/>
    <feature name='rx'/>
    <feature name='tx'/>
    <feature name='sg'/>
    <feature name='tso'/>
    <feature name='gso'/>
    <feature name='gro'/>
    <feature name='rxvlan'/>
    <feature name='txvlan'/>
    <feature name='rxhash'/>
    <capability type='80203'/>
  </capability>
</device>

Signed-off-by: Ján Tomko <jtomko@redhat.com>
2015-03-05 11:31:05 +01:00
Michal Privoznik
6954e7da52 parallels: Cleanup partly opened drivers on connect open failure
Well, the parallelsConnectOpen() joins several sub-driver openings
into one big if condition. If any of sub-driver fails to open, the
whole API finishes immediately. The problem is, sub-drivers may have
left some memory allocated. Fortunately, we have a free function for
that: parallelsConnectClose(). This is, however, not prepared for
partially allocated driver structure. So, prepare the free function
for it and call it at the right place, in the if body.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-03-05 08:38:21 +01:00
Erik Skultety
3fde7986d6 storage: tweak condition to properly test lseek
According to the POSIX standard, off_t (returned by lseek) is defined as
signed integral type no shorter than int. Because our offset variable is defined
as unsigned long long, the original check was passed successfully if UINT64_MAX had
been used as offset value, due to implicit conversion.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1177219
2015-03-04 14:51:44 +01:00
Shanzhi Yu
f7c1410b0e qemu: snapshot: Don't skip check for qcow2 format with network disks
When the domain's source disk type is network, if source protocol is rbd
or sheepdog, the 'if().. break' will end the current case, which lead to
miss check the driver type is raw or qcow2. Libvirt will allow to create
internal snapshot for a running domain with raw format disk which based
on rbd storage.

While both protocols support internal snapshots of the disk qemu is not
able to use it as it requires some place to store the memory image. The
check if the disk is backed by a qcow2 image needs to be executed
always.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1179533
Signed-off-by: Shanzhi Yu <shyu@redhat.com>
2015-03-04 14:13:06 +01:00
Peter Krempa
3923d98e05 qemu: Allow inactive domains in qemuDomainGetControlInfo()
Inactive domains can still be stuck in a job or other problems. Add a
way to detect it.
2015-03-04 10:41:30 +01:00
Peter Krempa
31a55c7cb4 qemu: Properly report error state in qemuDomainGetControlInfo()
Previously when a domain would get stuck in a domain job due to a
programming mistake we'd report the following control state:

$ virsh domcontrol domain
occupied (1424343406.150s)

The timestamp is invalid as the monitor was not entered for that domain.
We can use that to detect that the domain has an active job and report a
better error instead:

$ virsh domcontrol domain
error: internal (locking) error
2015-03-04 10:41:30 +01:00
Michal Privoznik
53cae19561 conf: s/virNetworkFindByName/virNetworkObjFindByName/
It's returning virNetworkObjPtr after all. And it matches the
pattern laid out by domain_conf.h.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-03-04 10:12:16 +01:00
Michal Privoznik
82f240ae56 conf: s/virNetworkFindByUUID/virNetworkObjFindByUUID/
It's returning virNetworkObjPtr after all. And it matches the
pattern laid out by domain_conf.h.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-03-04 10:11:40 +01:00
Michal Privoznik
2ea3ce332b bridge_driver: s/virNetworkObjList/virNetworkObjListPtr/
In order to hide the object internals (and use just accessors
everywhere), lets store a pointer to the object, instead of object
itself.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-03-04 10:11:24 +01:00
Michal Privoznik
c3dfec15ae parallels: s/virNetworkObjList/virNetworkObjListPtr/
In order to hide the object internals (and use just accessors
everywhere), lets store a pointer to the object, instead of object
itself.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-03-04 10:10:50 +01:00
Michal Privoznik
a9ba542272 test_driver: s/virNetworkObjList/virNetworkObjListPtr/
In order to hide the object internals (and use just accessors
everywhere), lets store a pointer to the object, instead of object
itself.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-03-04 10:09:45 +01:00
Michal Privoznik
bbbc7e41e0 virNetworkObjListExport: Pass virNetworkObjListPtr
Instead of copying the whole object onto stack when calling the
function, just pass the pointer to the object and save up some
space on the stack. Moreover, this prepares the code to hide the
virNetworkObjList structure into network_conf.c and use accessors
only.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-03-04 10:09:30 +01:00
Michal Privoznik
5b86f9aa1c virNetworkObjListFree: Accept NULL
All of our vir*Free() functions should accept NULL, even though
that there's no way of actually passing NULL with current code.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-03-04 10:09:10 +01:00
Michal Privoznik
9432ac70b2 virNetworkObjIsDuplicate: s/@doms/@nets/
This is probably a copy-paste error from virDomainObj*
counterpart.  But when speaking of virNetworkObj we should use
variable @nets for an array of networks, rather than @doms. It's
just confusing.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-03-04 10:09:04 +01:00
Michal Privoznik
5c6b8226f3 networkGetNetworkAddress: Drop empty 'error' label
Moreover, there are two points within the function, where we're
missing 'goto cleanup'. Fix this too.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-03-04 10:08:24 +01:00
Michal Privoznik
77ea6f7b0b testNetworkUpdate: Unlock network at the end
Silly this bug went unnoticed so long. At the beginning we try to
find the passed network in the list of network objects. If found,
it's locked and real work takes place. Then, in the end, the
network object is never unlocked.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-03-04 10:08:14 +01:00
Michal Privoznik
7b8c12d8ce bridge_driver: Don't check network active unlocked
Okay, this is mainly for educational purposes since is called
from single point only with all the possible locks held. So
there's no way for other thread to hop in and do something wrong.
Nevertheless, we should not give bad example.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-03-04 10:08:07 +01:00
Michal Privoznik
bf1afdd491 networkLookupByUUID: Improve error message
We have this function networkObjFromNetwork() which for given
virNetworkPtr tries to find corresponding virNetworkObjPtr. If no
object is found, a nice error message is printed out:

  no network with matching uuid '$uuid' ($name)

Let's improve the error message produced by networkLookupByUUID to
follow that logic.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-03-04 10:07:59 +01:00
Michal Privoznik
63889e0c77 qemuProcessReconnect: Fill in pid file path
https://bugzilla.redhat.com/show_bug.cgi?id=1197600

So, libvirt uses pid file to track pid of started qemus. Whenever
a domain is started, its pid is put into corresponding pid file.
The pid file path is generated based on domain name and stored
into domain object internals. However, it's not stored in the
status XML and therefore lost on daemon restarts. Hence, later,
when domain is being shut down, the daemon does not know which
pid file to unlink, and the correct pid file is left behind. To
avoid this, lets generate the pid file path again in
qemuProcessReconnect().

Reported-by: Luyao Huang <lhuang@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-03-03 12:10:15 +01:00
Pavel Hrdina
a16e5f0a91 qemu: check defaultMode for spice graphics independently
Instead of checking defaultMode for every channel that has no mode
configured, test it only once outside of channel loop.  This fixes a bug
that in case all possible channels are fore example set to insecure, but
defaultMode is set to secure, we wouldn't auto-generate TLS port.  This
results in failure while starting a guest.

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

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2015-03-03 11:42:33 +01:00
Pavel Hrdina
e4983952b4 qemu: remove duplicated code for allocating spice ports
We have two different places that needs to be updated while touching
code for allocation spice ports.  Add a bool option to
'qemuProcessSPICEAllocatePorts' function to switch between true and fake
allocation so we can use this function also in qemu_driver to generate
native domain definition.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2015-03-03 11:41:46 +01:00
Martin Kletzander
2fd5880b3b conf: De-duplicate scheduling policy enums
Since adding the support for scheduler policy settings in commit
8680ea97, there are two enums with the same information.  That was
caused by rewriting the patch since first draft.

Find out thanks to clang, but there was no impact whatsoever.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2015-03-03 09:26:59 +01:00
Martin Kletzander
b3ea0a8fb8 qemu: Don't crash in qemuDomainOpenChannel()
The problem here was that when opening a channel, we were checking
whether the channel given is alias (can't be NULL for running domain) or
it's name, which can be NULL (for example with spicevmc).  In case of
such domain qemuDomainOpenChannel() made the daemon crash.
STREQ_NULLABLE() is safe to use since the code in question is wrapped in
"if (name)" and is more readable, so use that instead of checking for
non-NULL "vm->def->channels[i]->target.name".

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2015-03-03 09:26:59 +01:00
John Ferlan
30f69ae86b iscsi: Adjust error message for findStorageSources backend
The virStorageBackendISCSIFindPoolSources API only needs the 'host' name
in order to discover iSCSI pools, it returns the various device paths.
On input, it's also possible to further restrict a search by providing the
port attribute for the host element and the (undocumented) initiator element.

For example:

$  virsh find-storage-pool-sources-as iscsi
error: Failed to find any iscsi pool sources
error: invalid argument: hostname and device path must be specified for iscsi sources

$ virsh find-storage-pool-sources-as iscsi 192.168.122.1
<sources>
  <source>
    <host name='192.168.122.1' port='3260'/>
    <device path='iqn.2013-12.com.example:iscsi-chap-lclpool'/>
  </source>
</sources>
2015-03-02 22:57:27 -05:00
John Ferlan
832a9256b2 disk: Provide a default storage source format type.
https://bugzilla.redhat.com/show_bug.cgi?id=1181062

According to the formatstorage.html description for <source> element
and "format" attribute: "All drivers are required to have a default
value for this, so it is optional."

As it turns out the disk backend did not choose a default value, so I
added a default of "msdos" if the source type is "unknown" as well as
updating the storage.html backend disk volume driver documentation to
indicate the default format is dos.
2015-03-02 22:42:25 -05:00
John Ferlan
e0e290552b disk: Disallow duplicated target 'dev' values
https://bugzilla.redhat.com/show_bug.cgi?id=1142631

This patch resolves a situation where the same "<target dev='$name'...>"
can be used for multiple disks in the domain.

While the $name is "mostly" advisory regarding the expected order that
the disk is added to the domain and not guaranteed to map to the device
name in the guest OS, it still should be unique enough such that other
domblk* type operations can be performed.

Without the patch, the domblklist will list the same Target twice:

$ virsh domblklist $dom
Target     Source
------------------------------------------------
sda        /var/lib/libvirt/images/file.qcow2
sda        /var/lib/libvirt/images/file.img

Additionally, getting domblkstat, domblkerror, domblkinfo, and other block*
type calls will not be able to reference the second target.

Fortunately, hotplug disallows adding a "third" sda value:

$ qemu-img create -f raw /var/lib/libvirt/images/file2.img 10M
$ virsh attach-disk $dom /var/lib/libvirt/images/file2.img sda
error: Failed to attach disk
error: operation failed: target sda already exists

$

BUT, it since 'sdb' doesn't exist one would get the following on the same
hotplug attempt, but changing to use 'sdb' instead of 'sda'

$ virsh attach-disk $dom /var/lib/libvirt/images/file2.img sdb
error: Failed to attach disk
error: internal error: unable to execute QEMU command 'device_add': Duplicate ID 'scsi0-0-1' for device

$

Since we cannot fix this issue at parsing time, the best that can be done so
as to not "lose" a domain is to make the check prior to starting the guest
with the results as follows:

$ virsh start $dom
error: Failed to start domain $dom
error: XML error: target 'sda' duplicated for disk sources '/var/lib/libvirt/images/file.qcow2' and '/var/lib/libvirt/images/file.img'

$

Running 'make check' found a few more instances in the tests where this
duplicated target dev value was being used. These also exhibited some
duplicated 'id=' values (negating the uniqueness argument of aliases) in
the corresponding .args file and of course the *xmlout version of a few
input XML files.
2015-03-02 22:38:36 -05:00
Peter Krempa
8968c4946c conf: numa: Add helper to count total memory size configured in NUMA
The total NUMA memory consists of the sum of individual NUMA node memory
amounts.
2015-03-02 16:42:51 +01:00
Peter Krempa
389634e667 qemu: Forbid setting maximum memory size with the API with NUMA enabled
NUMA enabled guest configuration explicitly specifies memory sizes for
individual nodes. Allowing the virDomainSetMemoryFlags API (and friends)
to change the total doesn't make sense as the individual node configs
are not updated in that case.

Forbid use of the API in case NUMA is specified.
2015-03-02 16:41:32 +01:00
Peter Krempa
812a9e5e66 phyp: Fix error messages mentioning memory
The messages for currentMemory and memory were swapped.
2015-03-02 14:39:58 +01:00
Peter Krempa
1fcb9351d7 storage: sheepdog: Avoid skipping variable initialization
Commit 155ca616eb added a error message
that skips initialization of the 'cmd' variable. Fortunately it was not
released.
2015-03-02 10:09:49 +01:00
Ján Tomko
723522328f Check if domain is running in qemuDomainAgentIsAvailable
If the domain is not running, the agent will not respond.
Do not even try.

https://bugzilla.redhat.com/show_bug.cgi?id=872424
2015-03-02 08:07:56 +01:00
Ján Tomko
fbb94044ea Pass virDomainObjPtr to qemuDomainAgentAvailable
Not just the DomainObj's private data.
2015-03-02 08:07:56 +01:00
Ján Tomko
c8b80b49f6 Check for qemu guest agent availability after getting the job
This way checks requiring the job can be done in qemuDomainAgentAvailable.
2015-03-02 08:07:56 +01:00
Ján Tomko
155ca616eb Allow creating volumes with a backing store but no capacity
The tool creating the image can get the capacity from the backing
storage. Just refresh the volume afterwards.

https://bugzilla.redhat.com/show_bug.cgi?id=958510
2015-03-02 08:07:11 +01:00
Ján Tomko
813e4b7f83 Allow omitting volume capacity when backing store is specified
Add VIR_VOL_XML_PARSE_OPT_CAPACITY flag to virStorageVolDefParseXML.
With this flag, no error is reported when the capacity is missing
if there is a backing store.
2015-03-02 08:07:11 +01:00
Ján Tomko
d3452a3f73 Revert "Restore skipping of setting capacity"
This reverts commit f1856eb622.

Now that we can update capacity from image metadata,
we don't need to skip the update.
2015-03-02 08:07:11 +01:00
Ján Tomko
a760ba3a7f Probe for capacity in virStorageBackendUpdateVolTargetInfo
Instead of just looking at the output of fstat, call
virStorageFileGetMetadata to get the full capacity from
image headers.

Note that the capacity is probed unconditionally. The updateCapacity
bool parameter is ignored and will be removed in the following commit.
2015-03-02 08:07:11 +01:00
Ján Tomko
e3f1d2a820 Allow cloning volumes with no capacity specified
In virStorageVolCreateXML, add VIR_VOL_XML_PARSE_NO_CAPACITY
to the call parsing the XML of the new volume to make the capacity
optional.

If the capacity is omitted, use the capacity of the old volume.
We already do that for values that are less than the original
volume capacity.
2015-03-02 08:07:11 +01:00
Ján Tomko
2bd47d9c64 Allow parsing volumes without specifying the capacity
Add VIR_VOL_XML_PARSE_NO_CAPACITY flag to the volume XML
parser. When set, it allows the capacity element to be omitted.
2015-03-02 08:07:11 +01:00
Ján Tomko
21f58a5854 Parse backingStore before capacity in volume XML
So we can allow omitting the capacity element if backing store is
present.
2015-03-02 08:07:11 +01:00
Ján Tomko
cbd788eba6 Add flags argument to virStorageVolDefParse*
Allow the callers to pass down libvirt-internal flags.
2015-03-02 08:07:11 +01:00
Ján Tomko
000b21da83 Trivially implement VIR_CONNECT_BASELINE_CPU_MIGRATABLE for non-x86 cpus
Assume no features block migration.
2015-03-02 07:59:12 +01:00
Ján Tomko
496156807b Implement VIR_CONNECT_BASELINE_CPU_MIGRATABLE in the x86 cpu driver
Filter out non-migratable features if
VIR_CONNECT_BASELINE_CPU_MIGRATABLE was specified.
2015-03-02 07:59:12 +01:00
Ján Tomko
02c8b66d6a Add VIR_CONNECT_BASELINE_CPU_MIGRATABLE flag
This flag for virConnectBaselineCPU will allow filtering out
CPU features that block migration from the result.

https://bugzilla.redhat.com/show_bug.cgi?id=1171484
2015-03-02 07:59:12 +01:00
Ján Tomko
995ca6cbf3 Use virBufferTrim when generating boot options
Instead of tracking the number of added parameters,
add a comma at the end of each one unconditionally
and trim the trailing one at the end.
2015-03-02 07:39:09 +01:00
Ján Tomko
354425dcd2 Make -boot arg generation more readable
If we combine the boot order on the command line with other
boot options, we prepend order= in front of it.

Instead of checking if the number of added arguments is between
0 and 2, separate the strings for boot order and options
and prepend boot order only if both strings are not empty.
2015-03-02 07:39:09 +01:00
Ján Tomko
92572c3d71 Remove code handling the QEMU_CAPS_DOMID capability
This option is xenner-only (since commit b81a7ece),
and we dropped support for xenner in commit de9be0a.
2015-03-02 07:39:09 +01:00
Ján Tomko
9aa316612a Remove bootloader option from QEMU
It was only supported by xenner (since commit 763a59d8),
for which we removed support in commit de9be0a.

Remove the code generating this command line option,
refuse to parse it and delete the outdated tests.

https://bugzilla.redhat.com/show_bug.cgi?id=1176050
2015-03-02 07:39:09 +01:00
Ján Tomko
c75f42f331 Really fix XML formatting flags in SaveImageUpdateDef
Commit cf2d4c6 used a logical or instead of bitwise or,
effectively passing 1, that is VIR_DOMAIN_XML_INACTIVE.

This was caught by a warning when building with clang.

https://bugzilla.redhat.com/show_bug.cgi?id=1183869
2015-02-27 12:01:31 +01:00
Ján Tomko
8c45e8bec8 Ignore listen attribute of <graphics> for type network listens
Commit 6992994 started filling the listen attribute
of the parent <graphics> elements from type='network' listens.

When this XML is passed to UpdateDevice, parsing fails:
XML error: graphics listen attribute 10.20.30.40 must match
address attribute of first listen element (found none)

Ignore the address in the parent <graphics> attribute
when no type='address' listens are found,
the same we ignore the address for the <listen> subelements
when parsing inactive XML.
2015-02-27 08:27:21 +01:00
Peter Krempa
ef2e6f4089 util: storage: Fix error type in virStorageSourceParseBackingURI
The gluster volume name extraction code was copied from the XML parser
without changing the VIR_ERR_XML_ERROR error code. Use
VIR_ERR_CONFIG_UNSUPPORTED instead.
2015-02-26 11:50:38 +01:00
Peter Krempa
fc56ecd735 util: storagefile: Don't crash on gluster URIs without path
Similar to commit fdb80ed4f6 libvirtd
would crash if a gluster URI without path would be used in the backing
chain of a volume. The crash happens in the gluster specific part of the
parser that extracts the gluster volume name from the path.

Fix the crash by checking that the PATH is NULL.

This patch does not contain a test case as it's not possible to test it
with the current infrastructure as the test suite would attempt to
contact the gluster server in the URI. I'm working on the test suite
addition but that will be post-release material.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1196528
2015-02-26 11:50:38 +01:00
Ján Tomko
b15b21f3a5 conf: error out on missing dhcp host attributes
In virNetworkDHCPHostDefParseXML an error is reported
when partialOkay == true, and none of ip, mac, name
were supplied.

Add the missing goto and error out in this case.
2015-02-26 09:03:09 +01:00
Luyao Huang
719cd2182b conf: error out on invalid host id
https://bugzilla.redhat.com/show_bug.cgi?id=1196503

We already check whether the host id is valid or not, add a jump
to forbid invalid host id.

Signed-off-by: Luyao Huang <lhuang@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2015-02-26 08:52:43 +01:00
Laine Stump
4bbe1029f2 qemu: fix ifindex array reported to systemd
Commit f7afeddc added code to report to systemd an array of interface
indexes for all tap devices used by a guest. Unfortunately it not only
didn't add code to report the ifindexes for macvtap interfaces
(interface type='direct') or the tap devices used by type='ethernet',
it ended up sending "-1" as the ifindex for each macvtap or hostdev
interface. This resulted in a failure to start any domain that had a
macvtap or hostdev interface (or actually any type other than
"network" or "bridge").

This patch does the following with the nicindexes array:

1) Modify qemuBuildInterfaceCommandLine() to only fill in the
nicindexes array if given a non-NULL pointer to an array (and modifies
the test jig calls to the function to send NULL). This is because
there are tests in the test suite that have type='ethernet' and still
have an ifname specified, but that device of course doesn't actually
exist on the test system, so attempts to call virNetDevGetIndex() will
fail.

2) Even then, only add an entry to the nicindexes array for
appropriate types, and to do so for all appropriate types ("network",
"bridge", and "direct"), but only if the ifname is known (since that
is required to call virNetDevGetIndex().
2015-02-25 13:11:14 -05:00
Laine Stump
153b06c6d1 util: check for null ifname inside virNetDevBandwidthSet()
Previously this function relied on having ATTRIBUTE_NONNULL(1) in its
prototype rather than explicitly checking for a null
ifname. Unfortunately, ATTRIBUTE_NONNULL is just a hint to the
optimizer and code analyzers like Coverity, it doesn't actually check
anything at execution time, so the result was possible warnings from
Coverity, along with the possibility of null dereferences when ifname
wasn't available.

This patch removes the ATTRIBUTE_NONNULL from the prototype, and
checks ifname inside the function, logging an error if it's NULL (once
we've determined that the user really is trying to set a bandwidth).
2015-02-25 13:10:34 -05:00
Laine Stump
118b240808 network: only clear bandwidth if it has been set
libvirt was unconditionally calling virNetDevBandwidthClear() for
every interface (and network bridge) of a type that supported
bandwidth, whether it actually had anything set or not. This doesn't
hurt anything (unless ifname == NULL!), but is wasteful.

This patch makes sure that all calls to virNetDevBandwidthClear() are
qualified by checking that the interface really had some bandwidth
setup done, and checks for a null ifname inside
virNetDevBandwidthClear(), silently returning success if it is null
(as well as removing the ATTRIBUTE_NONNULL from that function's
prototype, since we can't guarantee that it is never null,
e.g. sometimes a type='ethernet' interface has no ifname as it is
provided on the fly by qemu).
2015-02-25 13:09:34 -05:00
Yuri Chornoivan
8a833d1eb0 Fix typos in messages
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2015-02-25 14:12:51 +01:00
Ján Tomko
6784acc7b0 Fix error messages in virStorageFileGetMetadataFromFD
Do not use relPath, it has not been filled by virStorageFileMetadataNew.
2015-02-25 12:14:30 +01:00
Ján Tomko
c6807b507a Clarify behavior or virDomainDetachDevice
Document that a complete device definition should be used
and a partial match can lead to the device being detached.

https://bugzilla.redhat.com/show_bug.cgi?id=872028
2015-02-25 10:06:41 +01:00
Ján Tomko
52a166f493 Assign default SCSI controller model before checking attribute validity
If the qemu binary on x86 does not support lsi SCSI controller,
but it supports virtio-scsi, we reject the virtio-specific attributes
for no reason.

Move the default controller assignment before the check.

https://bugzilla.redhat.com/show_bug.cgi?id=1168849
2015-02-25 10:04:58 +01:00
Michal Privoznik
cf2d4c603c qemu: Use correct flags for ABI stability check in SaveImageUpdateDef
https://bugzilla.redhat.com/show_bug.cgi?id=1183869

Soo. you've successfully started yourself a domain. And since you want
to use it on your host exclusively you are confident enough to
passthrough the host CPU model, like this:

  <cpu mode='host-passthrough'/>

Then, after a while, you want to save the domain into a file (e.g.
virsh save dom dom.save). And here comes the trouble. The file consist
of two parts: Libvirt header (containing domain XML among other
things), and qemu migration data. Now, the domain XML in the header is
formatted using special flags (VIR_DOMAIN_XML_SECURE |
VIR_DOMAIN_XML_UPDATE_CPU | VIR_DOMAIN_XML_INACTIVE |
VIR_DOMAIN_XML_MIGRATABLE).

Then, on your way back from the bar, you think of changing something
in the XML in the saved file (we have a command for it after all), say
listen address for graphics console. So you successfully type in the
command:

  virsh save-image-edit dom.save

Change all the bits, and exit the editor. But instead of success
you're left with sad error message:

  error: unsupported configuration: Target CPU model <null> does not
  match source Pentium Pro

Sigh. Digging into the code you see lines, where we check for ABI
stability. The new XML you've produced is compared with the old one
from the saved file to see if qemu ABI will break or not. Wait, what?
We are using different flags to parse the XML you've provided so we
were just lucky it worked in some cases? Yep, that's right.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-02-25 09:28:54 +01:00
Michal Privoznik
0e69d97648 cpu: Format <cpu/> properly
Well, not that we are not formatting invalid XML, rather than not as
beautiful as we can:

  <cpu mode='host-passthrough'>
  </cpu>

If there are no children, let's use the singleton element.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-02-25 09:26:04 +01:00
Michal Privoznik
33912cc03e virCPUDefFormatBufFull: Use our general error handling pattern
Well, so far there are no variables to free, no cleanup work needed on
an error, so bare 'return -1;' after each error is just okay. But this
will change in a while.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-02-25 09:23:45 +01:00
Michal Privoznik
83c5467ee9 util: Introduce virBufferAddBuffer
This API joins the following two lines:

char *s = virBufferContentAndReset(buf1);
virBufferAdd(buf2, s, -1);

into one:

virBufferAddBuffer(buf2, buf1);

With one exception: there's no re-indentation applied to @buf1.
The idea is, that in general both can have different indentation
(like the test I'm adding proves)

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-02-25 09:23:42 +01:00
Pavel Hrdina
efd30e2e1c qemu: fix memory leak while starting a guest
In commit cc41c648 I've re-factored qemuMonitorFindBalloonObjectPath, but
missed that there is a memory leak. The "nextpath" variable is
overwritten while looping in for cycle and we have to free it before next
cycle.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2015-02-24 16:38:50 +01:00
Michal Privoznik
39df9d2f12 network_conf: Forbid commas in DNS TXT
https://bugzilla.redhat.com/show_bug.cgi?id=1151942

While the restriction doesn't have origin in any RFC, it matters
to us while constructing the dnsmasq config file (or command line
previously). For better picture, this is how the corresponding
part of network XML look like:

  <dns>
    <forwarder addr='8.8.4.4'/>
    <txt name='example' value='example value'/>
  </dns>

And this is how the config file looks like then:

  server=8.8.4.4
  txt-record=example,example value

Now we can see why there can't be any commas in the TXT name.
They are used by dnsmasq to separate @name and @value.

Funny, we have it in the documentation, but the code (which was
pushed back in 2011) didn't reflect that.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-02-24 10:07:47 +01:00
Stefan Zimmermann
8e6ee9f280 Rework s390 architecture checking
Making use of the ARCH_IS_S390 macro introduced with
e808357528

Signed-off-by: Stefan Zimmermann <stzi@linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
2015-02-23 14:51:02 -05:00
Stefan Zimmermann
09ab9dcc85 Prevent default creation of usb controller on s390 and s390x
Since s390 does not support usb the default creation of a usb controller
for a domain should not occur.

Also adjust s390 test cases by removing usb device instances since
usb devices are no longer created by default for s390 the s390
test cases need to be adjusted.

Signed-off-by: Stefan Zimmermann <stzi@linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
2015-02-23 14:50:15 -05:00
Cole Robinson
f2f1e388e1 qemu: Fix AAVMF/OVMF #define names
The AAVMF and OVMF names were swapped. Reorder the one usage where it
matters so behavior doesn't change.
2015-02-21 14:44:46 -05:00
Marek Marczykowski
d0106d5828 libxl: support backend domain setting for disk and net devices
This implement handling of <backenddomain name=''/>  parameter introduced
in previous patch.

Works on Xen >= 4.3, because only there libxl supports setting backend
domain by name.  Specifying backend domain by ID or UUID is currently not
supported.

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
2015-02-20 14:50:24 -07:00
Marek Marczykowski
c374353ca0 conf: support backend domain name in disk and network devices
At least Xen supports backend drivers in another domain (aka "driver
domain"). This patch introduces an XML config option for specifying the
backend domain name for <disk> and <interface> devices.  E.g.

  <disk>
    <backenddomain name='diskvm'/>
    ...
  </disk>
  <interface type='bridge'>
    <backenddomain name='netvm'/>
    ...
  </interface>

In the future, same option will be needed for USB devices (hostdev
objects), but for now libxl doesn't have support for PVUSB.

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
2015-02-20 14:50:24 -07:00
Laine Stump
8f8e581a17 network: allow <pf> together with <interface>/<address> in network status
The function that parses the <forward> subelement of a network used to
fail/log an error if the network definition contained both a <pf>
element as well as at least one <interface> or <address> element. That
check was present because the configuration of a network should have
either one <pf>, one or more <interface>, or one or more <address>,
but never combinations of multiple kinds.

This caused a problem when libvirtd was restarted with a network
already active - when a network with a <pf> element is started, the
referenced PF (Physical Function of an SRIOV-capable network card) is
checked for VFs (Virtual Functions), and the <forward> is filled in
with a list of all VFs for that PF either in the form of their PCI
addresses (a list of <address>) or their netdev names (a list of
<interface>); the <pf> element is not removed though. When libvirtd is
restarted, it parses the network status and finds both the original
<pf> from the config, as well as the list of either <address> or
<interface>, fails the parse, and the network is not added to the
active list. This failure is often obscured because the network is
marked as autostart so libvirt immediately restarts it.

It seems odd to me that <interface> and <address> are stored in the
same array rather than keeping two separate arrays, and having
separate arrays would have made the check much simpler. However,
changing to use two separate arrays would have required changes in
more places, potentially creating more conflicts and (more
importantly) more possible regressions in the event of a backport, so
I chose to keep the existing data structure in order to localize the
change.

It appears that this problem has been in the code ever since support
for <pf> was added (0.9.10), but until commit
34cc3b2f10 (first in libvirt 1.2.4)
networks with interface pools were not properly marked as active on
restart anyway, so there is no point in backporting this patch any
further than that.
2015-02-20 15:06:30 -05:00
Peter Krempa
103707d4b7 qemu: caps: Add capability bit for the "pc-dimm" device
The pc-dimm device represents a RAM memory module.
2015-02-20 19:25:09 +01:00
Peter Krempa
e5c7864cfc conf: Hoist validation of memory size into the post parse callback
Later patches will need to access the full definition to do check the
memory size and thus the checking needs to be done after the whole
definition including devices is known.
2015-02-20 19:25:09 +01:00
Peter Krempa
b98596a717 conf: numa: Check ABI stability of NUMA configuration
Add helper to compare initial sizes of indivitual NUMA nodes and the map
of belonging vCPUs. Other configuration is not ABI.
2015-02-20 19:23:38 +01:00
Peter Krempa
e431c3c092 conf: ABI: Hugepage backing definition is not guest ABI
The backing of the vm's memory isn't influencing the guest ABI thus
shouldn't be checked.
2015-02-20 18:19:59 +01:00
Peter Krempa
181742d43f conf: Move all NUMA configuration to virDomainNuma
For historical reasons data regarding NUMA configuration were split
between the CPU definition and numatune. We cannot do anything about the
XML still being split, but we certainly can at least store the relevant
data in one place.

This patch moves the NUMA stuff to the right place.
2015-02-20 17:50:08 +01:00
Peter Krempa
b9ddb25822 conf: numa: Add setter/getter for NUMA node memory size
Add the helpers and refactor places where the value is accessed without
them.
2015-02-20 17:50:08 +01:00
Peter Krempa
7800d473f5 conf: numa: Add accessor to NUMA node's memory access mode 2015-02-20 17:50:08 +01:00
Peter Krempa
d9a779a36e conf: numa: Add accessor for the NUMA node cpu mask
Add virDomainNumaGetNodeCpumask() and refactor a few places that would
get the cpu mask without the helper.
2015-02-20 17:50:08 +01:00
Peter Krempa
be22d07315 conf: numa: Add helper to get guest NUMA node count and refactor users
Add an accessor so that a later refactor is simpler.
2015-02-20 17:50:07 +01:00
Peter Krempa
ba2183a331 qemu: command: Unify retrieval of NUMA cell count in qemuBuildNumaArgStr
The function uses the cell count in 6 places. Add a temp variable to
hold the count as it will greatly simplify the refactor.
2015-02-20 17:50:07 +01:00
Peter Krempa
b83543c563 conf: numa: Don't pass double pointer to virDomainNumatuneParseXML
virDomainNumatuneParseXML now doesn't allocate the def->numa object any
longer so we don't need to pass a double pointer.
2015-02-20 17:50:07 +01:00
Peter Krempa
fa9930720b numa: conf: Tweak parameters of virDomainNumatuneSet
As virDomainNumatuneSet now doesn't allocate the virDomainNuma object
any longer it's not necessary to pass the pointer to a pointer to store
the object as it will not change any longer.

While touching the parameter definitions I've also changed the name of
the parameter to "numa".
2015-02-20 17:50:07 +01:00
Peter Krempa
21008c013c conf: numa: Always allocate the NUMA config
Since our formatter now handles well if the config is allocated and not
filled we can safely always-allocate the NUMA config and remove the
ad-hoc allocation code.

This will help in later patches as the parser will be refactored to just
fill the data.
2015-02-20 17:48:48 +01:00
Peter Krempa
c03411199e conf: Allocate domain definition with the new helper
Use the virDomainDefNew() helper to allocate the definition instead of
doing it via VIR_ALLOC.
2015-02-20 17:43:05 +01:00