]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
10 years agoconf: numa: Improve error message in case a numa node doesn't have cpus
Peter Krempa [Wed, 11 Feb 2015 16:38:29 +0000 (17:38 +0100)]
conf: numa: Improve error message in case a numa node doesn't have cpus

Currently the code would exit without reporting an error as
virBitmapParse reports one only if it fails to parse the bitmap, whereas
the code was jumping to the error label even in case 0 cpus were
correctly parsed in the map.

10 years agoconf: numa: Recalculate rather than remember total NUMA cpu count
Peter Krempa [Thu, 12 Feb 2015 08:37:13 +0000 (09:37 +0100)]
conf: numa: Recalculate rather than remember total NUMA cpu count

It's easier to recalculate the number in the one place it's used as
having a separate variable to track it. It will also help with moving
the NUMA code to the separate module.

10 years agoconf: Move enum virMemAccess to the NUMA code and rename it
Peter Krempa [Wed, 11 Feb 2015 14:40:27 +0000 (15:40 +0100)]
conf: Move enum virMemAccess to the NUMA code and rename it

Name it virNumaMemAccess and add it to conf/numa_conf.[ch]

Note that to avoid a circular dependency the type of the NUMA cell
memAccess variable was changed to int. It will be turned back later
after the circular dependency will not exist.

10 years agoconf: numa: Rename virDomainNumatune to virDomainNuma
Peter Krempa [Wed, 11 Feb 2015 13:54:59 +0000 (14:54 +0100)]
conf: numa: Rename virDomainNumatune to virDomainNuma

The structure will gradually become the only place for NUMA related
config, thus rename it appropriately.

10 years agoconf: Move NUMA cell formatter to numa_conf
Peter Krempa [Wed, 11 Feb 2015 13:26:19 +0000 (14:26 +0100)]
conf: Move NUMA cell formatter to numa_conf

Move the code that formats the /domain/cpu/numa element to numa_conf as
it belongs there.

10 years agoconf: numa: Don't duplicate NUMA cell cpumask
Peter Krempa [Wed, 11 Feb 2015 13:06:20 +0000 (14:06 +0100)]
conf: numa: Don't duplicate NUMA cell cpumask

The mask was stored both as a bitmap and as a string. The string is used
for XML output only. Remove the string, as it can be reconstructed from
the bitmap.

The test change is necessary as the bitmap formatter doesn't "optimize"
using the '^' operator.

10 years agoconf: Refactor virDomainNumaDefCPUParseXML
Peter Krempa [Wed, 11 Feb 2015 12:31:09 +0000 (13:31 +0100)]
conf: Refactor virDomainNumaDefCPUParseXML

Rewrite the function to save a few local variables and reorder the code
to make more sense.

Additionally the ncells_max member of the virCPUDef structure is used
only for tracking allocation when parsing the numa definition, which can
be avoided by switching to VIR_ALLOC_N as the array is not resized
after initial allocation.

10 years agoconf: Move NUMA cell parsing code from cpu conf to numa conf
Peter Krempa [Wed, 11 Feb 2015 11:27:53 +0000 (12:27 +0100)]
conf: Move NUMA cell parsing code from cpu conf to numa conf

For weird historical reasons NUMA cells are added as a subelement of
<cpu> while the actual configuration is done in <numatune>.

This patch splits out the cell parser code from cpu config to NUMA
config. Note that the changes to the code are minimal just to make it
work and the function will be refactored in the next patch.

10 years agoconf: Move numatune_conf to numa_conf
Peter Krempa [Wed, 11 Feb 2015 09:08:35 +0000 (10:08 +0100)]
conf: Move numatune_conf to numa_conf

For a while now there are two places that gather information about NUMA
related guest configuration. While the XML can't be changed we can at
least store the data in one place in the definition.

Rename the numatune_conf.[ch] files to numa_conf as later patches will
move the rest of the definitions from the cpu definition to this one.

10 years agovirsh: fix vcpupin info
Pavel Hrdina [Fri, 20 Feb 2015 07:21:05 +0000 (08:21 +0100)]
virsh: fix vcpupin info

The "virDomainGetInfo" will get for running domain only live info and for
offline domain only config info. There was no way how to get config info
for running domain. We will use "vshCPUCountCollect" instead to get the
correct cpu count that we need to pass to "virDomainGetVcpuPinInfo".

Also cleanup some unnecessary variables and checks that are done by
drivers.

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

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
10 years agovirQEMUCapsCacheLookupCopy: Filter qemuCaps based on machineType
Michal Privoznik [Thu, 12 Feb 2015 13:50:31 +0000 (14:50 +0100)]
virQEMUCapsCacheLookupCopy: Filter qemuCaps based on machineType

Not all machine types support all devices, device properties, backends,
etc. So until we create a matrix of [machineType, qemuCaps], lets just
filter out some capabilities before we return them to the consumer
(which is going to make decisions based on them straight away).
Currently, as qemu is unable to tell which capabilities are (not)
enabled for given machine types, it's us who has to hardcode the matrix.
One day maybe the hardcoding will go away and we can create the matrix
dynamically on the fly based on a few monitor calls.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agovirQEMUCapsCacheLookupCopy: Pass machine type
Michal Privoznik [Thu, 12 Feb 2015 12:48:42 +0000 (13:48 +0100)]
virQEMUCapsCacheLookupCopy: Pass machine type

It will come handy in the near future when we will filter some
capabilities based on it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agovirsh-edit: Make force editing usable
Martin Kletzander [Thu, 19 Feb 2015 13:16:39 +0000 (14:16 +0100)]
virsh-edit: Make force editing usable

When editing a domain with 'virsh edit' and failing validation, the
usual message pops up:

  Failed. Try again? [y,n,f,?]:

Turning off validation can be useful, mainly for testing (but other
purposes too), so this patch adds support for relaxing definition in
virsh-edit and makes 'virsh edit <domain>' more usable.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agoparallels: Set the first HDD from XML as bootable
Mikhail Feoktistov [Tue, 17 Feb 2015 11:52:33 +0000 (14:52 +0300)]
parallels: Set the first HDD from XML as bootable

1. Delete all boot devices for VM instance
2. Find the first HDD from XML and set it as bootable

Now we support only one boot device and it should be HDD.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoparallels: Use IS_CT() macro instead of STREQ("exe")
Mikhail Feoktistov [Tue, 17 Feb 2015 11:52:32 +0000 (14:52 +0300)]
parallels: Use IS_CT() macro instead of STREQ("exe")

10 years agoparallels: code aligment
Mikhail Feoktistov [Tue, 17 Feb 2015 11:52:31 +0000 (14:52 +0300)]
parallels: code aligment

10 years agoSearch for schemas and cpu_map.xml in source tree
Jiri Denemark [Fri, 13 Feb 2015 13:25:27 +0000 (14:25 +0100)]
Search for schemas and cpu_map.xml in source tree

Not all files we want to find using virFileFindResource{,Full} are
generated when libvirt is built, some of them (such as RNG schemas) are
distributed with sources. The current API was not able to find source
files if libvirt was built in VPATH.

Both RNG schemas and cpu_map.xml are distributed in source tarball.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
10 years agoqemuMigrationDriveMirror: Listen to events
Michal Privoznik [Tue, 10 Feb 2015 15:25:27 +0000 (16:25 +0100)]
qemuMigrationDriveMirror: Listen to events

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

When migrating with storage, libvirt iterates over domain disks and
instruct qemu to migrate the ones we are interested in (shared, RO and
source-less disks are skipped). The disks are migrated in series. No
new disk is transferred until the previous one hasn't been quiesced.
This is checked on the qemu monitor via 'query-jobs' command. If the
disk has been quiesced, it practically went from copying its content
to mirroring state, where all disk writes are mirrored to the other
side of migration too. Having said that, there's one inherent error in
the design. The monitor command we use reports only active jobs. So if
the job fails for whatever reason, we will not see it anymore in the
command output. And this can happen fairly simply: just try to migrate
a domain with storage. If the storage migration fails (e.g. due to
ENOSPC on the destination) we resume the host on the destination and
let it run on partly copied disk.

The proper fix is what even the comment in the code says: listen for
qemu events instead of polling. If storage migration changes state an
event is emitted and we can act accordingly: either consider disk
copied and continue the process, or consider disk mangled and abort
the migration.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoqemuProcessHandleBlockJob: Take status into account
Michal Privoznik [Tue, 10 Feb 2015 15:24:45 +0000 (16:24 +0100)]
qemuProcessHandleBlockJob: Take status into account

Upon BLOCK_JOB_COMPLETED event delivery, we check if the job has
completed (in qemuMonitorJSONHandleBlockJobImpl()). For better image,
the event looks something like this:

"timestamp": {"seconds": 1423582694, "microseconds": 372666}, "event":
"BLOCK_JOB_COMPLETED", "data": {"device": "drive-virtio-disk0", "len":
8412790784, "offset": 409993216, "speed": 8796093022207, "type":
"mirror", "error": "No space left on device"}}

If "len" does not equal "offset" it's considered an error, and we can
clearly see "error" field filled in. However, later in the event
processing this case was handled no differently to case of job being
aborted via separate API. It's time that we start differentiate these
two because of the future work.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoqemuProcessHandleBlockJob: Set disk->mirrorState more often
Michal Privoznik [Tue, 10 Feb 2015 14:32:59 +0000 (15:32 +0100)]
qemuProcessHandleBlockJob: Set disk->mirrorState more often

Currently, upon BLOCK_JOB_* event, disk->mirrorState is not updated
each time. The callback code handling the events checks if a blockjob
was started via our public APIs prior to setting the mirrorState.
However, some block jobs may be started internally (e.g. during
storage migration), in which case we don't bother with setting
disk->mirror (there's nothing we can set it to anyway), or other
fields. But it will come handy if we update the mirrorState in these
cases too. The event wasn't delivered just for fun - we've started the
job after all.

So, in this commit, the mirrorState is set to whatever job status
we've obtained. Of course, there are some actions on some statuses
that we want to perform. But instead of if {} else if {} else {} ...
enumeration, let's move to switch().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoqemu: Exit job on error path of qemuDomainSetVcpusFlags()
Peter Krempa [Wed, 18 Feb 2015 17:05:21 +0000 (18:05 +0100)]
qemu: Exit job on error path of qemuDomainSetVcpusFlags()

Commit e105dc981438bc33fa771bd67cece6234dbf6c8d moved some code but
didn't adjust the jump labels so that the job would be terminated.

10 years agodaemon: Fix segfault by reloading daemon right after start
Pavel Hrdina [Wed, 18 Feb 2015 15:10:58 +0000 (16:10 +0100)]
daemon: Fix segfault by reloading daemon right after start

Libvirt could crash with segfault if user issue "service reload" right
after "service start". One possible way to crash libvirt is to run reload
during initialization of QEMU driver.

It could happen when qemu driver will initialize qemu_driver_lock but
don't have a time to set it's "config" and the SIGHUP arrives. The
reload handler tries to get qemu_drv->config during "virStorageAutostart"
and dereference it which ends with segfault.

Let's ignore all reload requests until all drivers are initialized. In
addition set driversInitialized before we enter virStateCleanup to
ignore reload request while we are shutting down.

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

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
10 years agodocs: clarify nat range behavior
Ján Tomko [Wed, 18 Feb 2015 14:36:45 +0000 (15:36 +0100)]
docs: clarify nat range behavior

All the addresses from the range are used, not just those
that are in use on the host.

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

10 years agodocs: add page about virtlockd setup
Daniel P. Berrange [Mon, 16 Feb 2015 11:58:32 +0000 (11:58 +0000)]
docs: add page about virtlockd setup

Introduce some basic docs describing the virtlockd setup.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
10 years agodocs: split out sanlock setup docs
Daniel P. Berrange [Fri, 13 Feb 2015 17:02:44 +0000 (17:02 +0000)]
docs: split out sanlock setup docs

In preparation for adding docs about virtlockd, split out
the sanlock setup docs into a separate page.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
10 years agoqemu_cgroup: initialize mem_mask to NULL
Pavel Hrdina [Tue, 17 Feb 2015 13:08:22 +0000 (14:08 +0100)]
qemu_cgroup: initialize mem_mask to NULL

If 'virNumaGetHostNodeset()' fails then the error path will try to free
uninitialized pointer mem_mask. Introduced by commit af2a1f058.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
10 years agoPowerPC : Forbid NULL CPU model with 'host-model' mode.
Prerna Saxena [Sun, 15 Feb 2015 04:24:15 +0000 (09:54 +0530)]
PowerPC : Forbid NULL CPU model with 'host-model' mode.

PowerPC : Forbid NULL CPU model with 'host-model' mode in qemu command line.

This ensures that an XML such as following:
...
  <cpu mode='host-model'>
    <model fallback='allow'/>
  </cpu>
...

will not generate a '-cpu host,compat=(null)' command line with qemu-system-ppc64.

Signed-off-by: Prerna Saxena <prerna@linux.vnet.ibm.com>
10 years agoPowerPC : Make 'qemu-system-ppc64' the default emulator on ppc64[le].
Prerna Saxena [Sun, 15 Feb 2015 04:18:00 +0000 (09:48 +0530)]
PowerPC : Make 'qemu-system-ppc64' the default emulator on ppc64[le].

PowerPC : Explicitly associate 'qemu-system-ppc64' as the
 default emulator for all 64-bit PowerPC guests ( both Big & Little Endian )

Signed-off-by: Prerna Saxena <prerna@linux.vnet.ibm.com>
10 years agoqemu: fix vm deadlock when try to use numatune in session mode
Luyao Huang [Tue, 17 Feb 2015 03:37:52 +0000 (11:37 +0800)]
qemu: fix vm deadlock when try to use numatune in session mode

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

Commit 43b67f introduced a deadlock issue when we use numatune
to change numa settings to a vm in session mode.

Jump to endjob instead of jump to cleanup.

Signed-off-by: Luyao Huang <lhuang@redhat.com>
10 years agoqemuBuildMemoryBackendStr: Report backend requirement more appropriately
Michal Privoznik [Thu, 12 Feb 2015 16:43:27 +0000 (17:43 +0100)]
qemuBuildMemoryBackendStr: Report backend requirement more appropriately

So, when building the '-numa' command line, the
qemuBuildMemoryBackendStr() function does quite a lot of checks to
chose the best backend, or to check if one is in fact needed. However,
it returned that backend is needed even for this little fella:

  <numatune>
    <memory mode="strict" nodeset="0,2"/>
  </numatune>

This can be guaranteed via CGroups entirely, there's no need to use
memory-backend-ram to let qemu know where to get memory from. Well, as
long as there's no <memnode/> element, which explicitly requires the
backend. Long story short, we wouldn't have to care, as qemu works
either way. However, the problem is migration (as always). Previously,
libvirt would have started qemu with:

  -numa node,memory=X

in this case and restricted memory placement in CGroups. Today, libvirt
creates more complicated command line:

  -object memory-backend-ram,id=ram-node0,size=X
  -numa node,memdev=ram-node0

Again, one wouldn't find anything wrong with these two approaches.
Both work just fine. Unless you try to migrated from the older libvirt
into the newer one. These two approaches are, unfortunately, not
compatible. My suggestion is, in order to allow users to migrate, lets
use the older approach for as long as the newer one is not needed.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoqemuxml2argvtest: Fake response from numad
Michal Privoznik [Thu, 12 Feb 2015 16:39:34 +0000 (17:39 +0100)]
qemuxml2argvtest: Fake response from numad

Well, we can pretend that we've asked numad for its suggestion and let
qemu command line be built with that respect. Again, this alone has no
big value, but see later commits which build on the top of this.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agonumatune_conf: Expose virDomainNumatuneNodeSpecified
Michal Privoznik [Thu, 12 Feb 2015 16:37:46 +0000 (17:37 +0100)]
numatune_conf: Expose virDomainNumatuneNodeSpecified

This function is going to be needed in the near future.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agovirsh: fix IP address in vncdisplay for listen type='network'
Luyao Huang [Sun, 15 Feb 2015 08:49:09 +0000 (16:49 +0800)]
virsh: fix IP address in vncdisplay for listen type='network'

Just like the fix for domdisplay in commit 1ba815.

10 years agolibxl: Resolve Coverity CHECKED_RETURN
John Ferlan [Fri, 13 Feb 2015 20:09:09 +0000 (15:09 -0500)]
libxl: Resolve Coverity CHECKED_RETURN

Periodically my Coverity scan will return a checked_return failure
for libxlDomainShutdownThread call to libxlDomainStart. Followed the
libxlAutostartDomain example in order to check the status, emit a
message, and continue on.

10 years agosecurity: Resolve Coverity RESOURCE_LEAK
John Ferlan [Fri, 13 Feb 2015 19:15:26 +0000 (14:15 -0500)]
security: Resolve Coverity RESOURCE_LEAK

Introduced by commit id 'c3d9d3bb' - return from virSecurityManagerCheckModel
wasn't VIR_FREE()'ing the virSecurityManagerGetNested allocated memory.

10 years agolxc: Fix container cleanup for LXCProcessStart
Luyao Huang [Wed, 4 Feb 2015 13:42:56 +0000 (21:42 +0800)]
lxc: Fix container cleanup for LXCProcessStart

Jumping to the cleanup label prior to starting the container failed to
properly clean everything up that is handled by the virLXCProcessCleanup
which is called if virLXCProcessStop is called on failure after the
container properly starts. Most importantly is prior to this patch none
of the stop/release hooks, host device reattachment, and network cleanup
(that is reverse of virLXCProcessSetupInterfaces).

Signed-off-by: Luyao Huang <lhuang@redhat.com>
10 years agolxc: Modify/add some debug messages
John Ferlan [Thu, 12 Feb 2015 19:32:39 +0000 (14:32 -0500)]
lxc: Modify/add some debug messages

Modify the VIR_DEBUG message in virLXCProcessCleanup to make it clearer
about the path.  Also add some more VIR_DEBUG messages in virLXCProcessStart
in order to help debug error flow.

10 years agolxc: Move console checks in LXCProcessStart
Luyao Huang [Thu, 12 Feb 2015 19:43:26 +0000 (14:43 -0500)]
lxc: Move console checks in LXCProcessStart

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

Move the two console checks - one for zero nconsoles present and the
other for an invalid console type to earlier in the processing rather than
getting after performing some setup that has to be undone for what amounts
to an invalid configuration.

This resolves the above bug since it's not not possible to have changed
the security labels when we cause the configuration check failure.

10 years agosecurity: Refactor virSecurityManagerGenLabel
Erik Skultety [Thu, 12 Feb 2015 17:32:41 +0000 (18:32 +0100)]
security: Refactor virSecurityManagerGenLabel

if (mgr == NULL || mgr->drv == NULL)
    return ret;

This check isn't really necessary, security manager cannot be a NULL
pointer as it is either selinux (by default) or 'none', if no other driver is
set in the config. Even with no config file driver name yields 'none'.

The other hunk checks for domain's security model validity, but we should
also check devices' security model as well, therefore this hunk is moved into
a separate function which is called by virSecurityManagerCheckAllLabel that
checks both the domain's security model and devices' security model.

https://bugzilla.redhat.com/show_bug.cgi?id=1165485
Signed-off-by: Ján Tomko <jtomko@redhat.com>
10 years agosecurity: introduce virSecurityManagerCheckAllLabel function
Erik Skultety [Thu, 12 Feb 2015 17:32:40 +0000 (18:32 +0100)]
security: introduce virSecurityManagerCheckAllLabel function

We do have a check for valid per-domain security model, however we still
do permit an invalid security model for a domain's device (those which
are specified with <source> element).
This patch introduces a new function virSecurityManagerCheckAllLabel
which compares user specified security model against currently
registered security drivers. That being said, it also permits 'none'
being specified as a device security model.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1165485
Signed-off-by: Ján Tomko <jtomko@redhat.com>
10 years agoWire up mrg_rxbuf option for qemu
Ján Tomko [Fri, 6 Feb 2015 14:40:19 +0000 (15:40 +0100)]
Wire up mrg_rxbuf option for qemu

<interface ...>
  ...
  <model type='virtio'/>
  <driver ...>
    <host mrg_rxbuf='off'/>
  </driver>
</interface>

will result in:
-device virtio-net-pci,mrg_rxbuf=off,...

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

10 years agoAdd mrg_rxbuf option to virtio interfaces
Ján Tomko [Fri, 6 Feb 2015 14:35:57 +0000 (15:35 +0100)]
Add mrg_rxbuf option to virtio interfaces

Add an XML attribute to allow disabling merge of rx buffers
on the host:
<interface ...>
  ...
  <model type='virtio'/>
  <driver ...>
    <host mrg_rxbuf='off'/>
  </driver>
</interface>

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

10 years agovirsh attach-interface: Allow macvtap hotplug
Michal Privoznik [Mon, 9 Feb 2015 15:17:51 +0000 (16:17 +0100)]
virsh attach-interface: Allow macvtap hotplug

Our hotplug code supports macvtap insertion to guests. However, we
somehow forgot about 'attach-interface' (which tries to build XML from
passed arguments and use virDomainAttachDeviceFlags()).
New type is accessible under 'direct' type, to keep the same type as
used in domain XML.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agovirsh attach-interface: Use virDomainNetType{From,To}String()
Michal Privoznik [Mon, 9 Feb 2015 15:04:58 +0000 (16:04 +0100)]
virsh attach-interface: Use virDomainNetType{From,To}String()

Instead of verbose string to enum conversion (if STREQ() else if
STREQ() else if STREQ() ...) lets use virDomainNetType{From,To}String.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agovirsh attach-interface: Use enum instead of arbitrary integers
Michal Privoznik [Mon, 9 Feb 2015 14:53:54 +0000 (15:53 +0100)]
virsh attach-interface: Use enum instead of arbitrary integers

The type of interface to attach is held in the variable 'typ'.
Depending on interface type selected by user, the variable is set
either to 1 (network), or 2 (bridge). Lets use already existing
enum from domain_conf.h instead: virDomainNetType.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agolibvirt_private.syms: Expose virDomainNetTypeFromString
Michal Privoznik [Mon, 9 Feb 2015 15:07:30 +0000 (16:07 +0100)]
libvirt_private.syms: Expose virDomainNetTypeFromString

The enum converters are defined in the domain_conf.h (so
accessible widely across the code), but on the symbol layer, only
virDomainNetTypeToString was exposed. However, FromString variant
is going to be needed shortly.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agovirprocess: fix MinGW build and RHEL-5 build
Pavel Hrdina [Thu, 12 Feb 2015 12:46:08 +0000 (13:46 +0100)]
virprocess: fix MinGW build and RHEL-5 build

Commit b6a2828e introduced new functions to set process scheduler. There
is a small typo in ELSE path for systems where scheduler is not
available.

Also some of the definitions were introduced later in kernel. For
example RHEL-5 is running on kernel 2.6.18, but SCHED_IDLE was introduces
in 2.6.23 [1] and SCHED_BATCH in 2.6.16 [1]. We should not count only on
existence of function sched_setscheduler(), we must also check for
existence of used macros as they might not be defined.

[1] see 'man 7 sched'

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
10 years agoFix a syntax error in the description text of libvirtd.conf
Zhang Bo [Thu, 12 Feb 2015 04:22:40 +0000 (12:22 +0800)]
Fix a syntax error in the description text of libvirtd.conf

not yet not -> not yet.

Signed-off-by: Zhang Bo <oscar.zhangbo@huawei.com>
10 years agodocs: Fix version reference in vcpu/iothread scheduling
Martin Kletzander [Thu, 12 Feb 2015 12:29:08 +0000 (13:29 +0100)]
docs: Fix version reference in vcpu/iothread scheduling

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agoAllow shrinking of file based volumes
Daniel P. Berrange [Thu, 15 Jan 2015 16:40:31 +0000 (16:40 +0000)]
Allow shrinking of file based volumes

While the main storage driver code allows the flag
VIR_STORAGE_VOL_RESIZE_SHRINK to be set, none of the backend
drivers are supporting it. At the very least this can work
for plain file based volumes since we just ftruncate() them
to the new size. It does not work with qcow2 volumes, but we
can arguably delegate to qemu-img for error reporting for that
instead of second guessing this for ourselves:

$ virsh vol-resize --shrink /home/berrange/VirtualMachines/demo.qcow2 2G
error: Failed to change size of volume 'demo.qcow2' to 2G

error: internal error: Child process (/usr/bin/qemu-img resize /home/berrange/VirtualMachines/demo.qcow2 2147483648) unexpected exit status 1: qemu-img: qcow2 doesn't support shrinking images yet
qemu-img: This image does not support resize

See also https://bugzilla.redhat.com/show_bug.cgi?id=1021802

10 years agoqemu: do upfront check for vcpupids being null when querying pinning
Daniel P. Berrange [Tue, 10 Feb 2015 16:23:16 +0000 (16:23 +0000)]
qemu: do upfront check for vcpupids being null when querying pinning

The qemuDomainHelperGetVcpus attempted to report an error when the
vcpupids info was NULL. Unfortunately earlier code would clamp the
value of 'maxinfo' to 0 when nvcpupids was 0, so the error reporting
would end up being skipped.

This lead to 'virsh vcpuinfo <dom>' just returning an empty list
instead of giving the user a clear error.

10 years agoqemu: fix setting of VM CPU affinity with TCG
Daniel P. Berrange [Tue, 10 Feb 2015 15:59:57 +0000 (15:59 +0000)]
qemu: fix setting of VM CPU affinity with TCG

If a previous commit I fixed the incorrect handling of vcpu pids
for TCG mode QEMU:

  commit b07f3d821dfb11a118ee75ea275fd6ab737d9500
  Author: Daniel P. Berrange <berrange@redhat.com>
  Date:   Thu Dec 18 16:34:39 2014 +0000

    Don't setup fake CPU pids for old QEMU

    The code assumes that def->vcpus == nvcpupids, so when we setup
    fake CPU pids for old QEMU with nvcpupids == 1, we cause the
    later code to read off the end of the array. This has fun results
    like sche_setaffinity(0, ...) which changes libvirtd's own CPU
    affinity, or even better sched_setaffinity($RANDOM, ...) which
    changes the affinity of a random OS process.

The intent was that this would merely disable the ability to set
per-vCPU affinity. It should still have been possible to set VM
level host CPU affinity.

Unfortunately, when you set  <vcpu cpuset='0-1'>4</vcpu>, the XML
parser will internally take this & initialize an entry in the
def->cputune.vcpupin array for every VCPU. IOW this is implicitly
being treated as

  <cputune>
    <vcpupin cpuset='0-1' vcpu='0'/>
    <vcpupin cpuset='0-1' vcpu='1'/>
    <vcpupin cpuset='0-1' vcpu='2'/>
    <vcpupin cpuset='0-1' vcpu='3'/>
  </cputune>

Even more fun, the faked cputune elements are hidden from view when
querying the live XML, because their cpuset mask is the same as the
VM default cpumask.

The upshot was that it was impossible to set VM level CPU affinity.

To fix this we must update qemuProcessSetVcpuAffinities so that it
only reports a fatal error if the per-VCPU cpu mask is different
from the VM level cpu mask.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
10 years agolibxl: disable VNC and SDL until explicitly enabled
Marek Marczykowski-Górecki [Tue, 10 Feb 2015 02:36:47 +0000 (03:36 +0100)]
libxl: disable VNC and SDL until explicitly enabled

When initializing a libxl_domain_build_info struct with
libxl_domain_build_info_init(), VNC is enabled by default.  As a
result, VMs configured with no graphics still have VNC enabled.
This behavior is a regression wrt to the legacy Xen driver.

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
10 years agolibxl: pass ipaddr to libxl toolstack
Marek Marczykowski-Górecki [Tue, 10 Feb 2015 02:17:23 +0000 (03:17 +0100)]
libxl: pass ipaddr to libxl toolstack

Do not silently ignore its value. LibXL support only one address, so
refuse multiple IPs.

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
10 years agoqemu: Add support for setting vCPU and I/O thread scheduler setting
Martin Kletzander [Thu, 8 Jan 2015 14:37:50 +0000 (15:37 +0100)]
qemu: Add support for setting vCPU and I/O thread scheduler setting

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agodocs, schema, conf: Add support for setting scheduler parameters of guest threads
Martin Kletzander [Thu, 8 Jan 2015 12:54:21 +0000 (13:54 +0100)]
docs, schema, conf: Add support for setting scheduler parameters of guest threads

In order for QEMU vCPU (and other) threads to run with RT scheduler,
libvirt needs to take care of that so QEMU doesn't have to run privileged.

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agoutil: Add virProcessSetScheduler() function for scheduler settings
Martin Kletzander [Thu, 8 Jan 2015 14:36:54 +0000 (15:36 +0100)]
util: Add virProcessSetScheduler() function for scheduler settings

This function uses sched_setscheduler() function so it works with
processes and threads as well (even threads not created by us, which is
what we'll need in the future).

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agodomain: include portgroup in interface status xml
Laine Stump [Tue, 10 Feb 2015 21:17:11 +0000 (16:17 -0500)]
domain: include portgroup in interface status xml

Prior to commit 7d5bf484747 (first appearing in libvirt 1.2.2), the
status XML of a domain's interface was missing a lot of important
information; mainly it just output the config of the interface, plus
the name of the tap device and qemu device alias. Commit 7d5bf484747
changed the status XML to include many important bits of information
that were required to make network "hook" scripts useful - bandwidth
information, vlan tag, the name of the bridge (or physical device in
the case of macvtap) that the tap/macvtap device was attached to - the
commit log for 7d5bf484747 has a very detailed explanation of the
change. For quick reference - in the example given there, prior to the
change, status XML looked like figure [C]:

      <interface type='network'>
        <source network='testnet' portgroup='admin'/>
        <target dev='macvtap0'/>
        <alias name='net0'/>
        <address type='pci' domain='0x0000' bus='0x00'
                 slot='0x03' function='0x0'/>
      </interface>

and after the change, it looked like figure [E]:

      <interface type='direct'>
        <source dev='p4p1_0' mode='bridge'/>
        <bandwidth>
            <inbound average='1000' peak='5000' burst='1024'/>
            <outbound average='128' peak='256' burst='256'/>
        </bandwidth>
        <target dev='macvtap0'/>
        <alias name='net0'/>
        <address type='pci' domain='0x0000' bus='0x00'
                 slot='0x03' function='0x0'/>
      </interface>

You'll notice that bandwidth info, physdev, and macvtap mode have been
added, but the network and portgroup names are now missing - I didn't
think that this information was of any use once the needed
bandwidth/vlan/etc config had been pulled from the network/portgroup.

I was wrong.

A few months after that change a user on IRC asked what happened to
portgroup in the status XML and described how he used it (more or less
as a tag to decide what external information to use in a hook script
that was run at startup/migration time - see
http://wiki.libvirt.org/page/OVS_and_PVLANS ). At that time I planned
to make a patch to re-add portgroup, but life intervened as that was
just prior to a transatlantic move involving several weeks of
"vacation". During this time I somehow forgot to make the patch, and
also mistakenly remembered that I *had* made it.

Subsequent to this, as a part of mprivozn's work to add support for
network-specific hooks, I did re-add the output of the network name in
status XML, but once again completely forgot about portgroup. This was
in commit a3609121 (first appearing in libvirt 1.2.11). This made the
status XML from the above example look like this:

      <interface type='direct'>
        <source network='testnet' dev='p4p1_0' mode='bridge'/>
        <bandwidth>
            <inbound average='1000' peak='5000' burst='1024'/>
            <outbound average='128' peak='256' burst='256'/>
        </bandwidth>
        <target dev='macvtap0'/>
        <alias name='net0'/>
        <address type='pci' domain='0x0000' bus='0x00'
                 slot='0x03' function='0x0'/>
      </interface>

*This* patch just adds the portgroup back to the status XML, so the
 same example interface will look like this:

      <interface type='direct'>
        <source network='testnet' portgroup='admin'
                dev='p4p1_0' mode='bridge'/>
        <bandwidth>
            <inbound average='1000' peak='5000' burst='1024'/>
            <outbound average='128' peak='256' burst='256'/>
        </bandwidth>
        <target dev='macvtap0'/>
        <alias name='net0'/>
        <address type='pci' domain='0x0000' bus='0x00'
                 slot='0x03' function='0x0'/>
      </interface>

The result is that the status XML now contains all information about
how the interface is setup (bandwidth, physical device, tap device,
etc), in addition to pointers to its origin (the network and
portgroup).

10 years agodomain: avoid potential memory leak in virDomainGraphicsListenSet*()
Laine Stump [Tue, 10 Feb 2015 19:04:40 +0000 (14:04 -0500)]
domain: avoid potential memory leak in virDomainGraphicsListenSet*()

virDomainGraphicsListenSetAddress() and
virDomainGraphicsListenSetNetwork() both set their respective char* to
NULL directly when asked to set it to NULL, which is okay as long as
it's already set to NULL. If these functions are ever called to clear
a listen object that has a valid string in address or network, it will
end up leaking the old value. Currently that doesn't happen, so this
is just a preemptive strike.

10 years agodomain: backfill listen address to parent <graphics> listen attribute
Laine Stump [Tue, 10 Feb 2015 18:49:16 +0000 (13:49 -0500)]
domain: backfill listen address to parent <graphics> listen attribute

Prior to 0.9.4, libvirt only supported a single listen, and it had to
be an IP address:

   <graphics listen='1.2.3.4' ..../>

Starting with 0.9.4, a graphics element could have a <listen>
subelement (actually the grammar supports multiples, but all of the
drivers only support a single <listen> per <graphics>), and that
listen element can be of type='address' or type='network'. For
type='address', <listen> also has an attribute called 'address' which
contains the IP address for listening:

    <graphics ....>
      <listen type='address' address='1.2.3.4' .../>
    </graphics>

type can also be "network", and in that case listen will have a
"network" attribute which will contain the name of a libvirt
network:

    <graphics ....>
      <listen type='network' network='testnet' .../>
    </graphics>

At domain start (or migrate) time, libvirt will attempt to
find an IP address associated with that network (e.g. the IP address
of the bridge device used by the network, or the physical device
listed in <forward dev='physdev'/>) and fill in that address in the
status XML:

    <graphics ....>
      <listen type='network' network='testnet' address='1.2.3.4' .../>
    </graphics>

In the case that a <graphics> element has a <listen> subelement of
type='address', that listen subelement's "address" attribute is
backfilled into the parent graphics element's "listen" *attribute* for
backward compatibility (so that a management application unaware of
the separate <listen> element can still learn the listen
address). This backfill should be done with the IP learned from
type='network' as well, and that's what this patch does:

    <graphics listen='1.2.3.4' ....>
      <listen type='network' network='testnet' address='1.2.3.4' .../>
    </graphics>

This is a continuation of the fix for:

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

10 years agovirsh: fix IP address in domdisplay for listen type='network'
Luyao Huang [Tue, 10 Feb 2015 09:35:56 +0000 (17:35 +0800)]
virsh: fix IP address in domdisplay for listen type='network'

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

virsh's domdisplay command looks in /domain/devices/graphics/@listen
of the domain's XML for the listen address, however for listen
type='network' (added in libvirt 0.9.4), the <graphics> element
doesn't have a listen attribute, but has a <listen> subelement,
*still* with no address (this is the inactive XML):

 <graphics type='spice' autoport='yes' keymap='en-us'>
  <listen type='network' network='default'/>
 </graphics>

However, at domain start time the <listen> subelement gets its address
attribute filled in once libvirt figures out the IP address associated
with the named network (this is the status XML):

 <graphics type='spice' port='5901' autoport='yes' keymap='en-us'>
  <listen type='network' address='192.168.122.1' network='default'/>
 </graphics>

So in these cases, we need to look at
/domain/devices/graphics/listen/@address instead.

Even though another patch is being pushed that will backfill
listen/@address into @listen, this patch is still useful, as it fixes
domdisplay for cases of a new virsh (with this patch) connecting to a
libvirtd that is newer than 0.9.4 but doesn't have the followup patch.

Signed-off-by: Luyao Huang <lhuang@redhat.com>
Signed-off-by: Laine Stump <laine@laine.org>
10 years agobhyvexml2argvmock: change int to size_t for tapfdSize
Pavel Hrdina [Tue, 10 Feb 2015 09:50:38 +0000 (10:50 +0100)]
bhyvexml2argvmock: change int to size_t for tapfdSize

Commit c5b6a4a5 forget to update also this mock function.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
10 years agoqemu: qemuOpenFileAs - set flag VIR_FILE_OPEN_FORCE_MODE
John Ferlan [Mon, 26 Jan 2015 19:28:25 +0000 (14:28 -0500)]
qemu: qemuOpenFileAs - set flag VIR_FILE_OPEN_FORCE_MODE

In the event we're falling into the code that tries to create the file
in a forked environment (VIR_FILE_OPEN_FORK) we pass different mode bits,
but those are never set because the virFileOpenForceOwnerMode has a check
if the OPEN_FORCE_MODE bit is set before attempting to change the mode.

Since this is a special case it seems reasonable to set u+rw,g+rw,o

10 years agovirfile: Adjust error path for virFileOpenForked
John Ferlan [Wed, 28 Jan 2015 17:34:54 +0000 (12:34 -0500)]
virfile: Adjust error path for virFileOpenForked

Rather than have a dummy waitpid loop and return of the failure status
from recvfd, adjust the logic to save the recvfd error & fd and then
in priority order:

- if waitpid failed, use that errno value
- waitpid succeeded, but if the child exited abnormally, report failure
(use EACCES to report as return failure, since either EACCES or EPERM is
what caused us to fall into the fork+setuid path)
- waitpid succeeded, but if the child reported non-zero status, report
failure (use the errno value that the child encoded into exit status)
- waitpid succeeded, but if recvfd failed, report recvfd_errno
- waitpid and recvfd succeeded, use the fd

NOTE: Original logic to retry the open and force owner mode was
"documented" as only being attempted if we had already tried opening
with the fork+setuid, but checked flags vs. VIR_FILE_OPEN_NOFORK which
is counter to how we would get to that point. So that code was removed.

10 years agoqemu: fix crash when migrateuri has no scheme
Luyao Huang [Wed, 11 Feb 2015 08:30:32 +0000 (16:30 +0800)]
qemu: fix crash when migrateuri has no scheme

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

When we attempt to migrate a vm with a migrateuri that has no scheme:

 # virsh migrate test4 --live qemu+ssh://lhuang/system --migrateuri 127.0.0.1

target libvirtd will crash because uri->scheme is NULL in
qemuMigrationPrepareDirect on this line:

     if (STRNEQ(uri->scheme, "tcp") &&

Add a value check before this line. Also fix a bug like this in
doNativeMigrate, that could only happen when destination libvirtd
returned an incorrect URI.

Signed-off-by: Luyao Huang <lhuang@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
10 years agoconf: Fix libvirtd crash and memory leak caused by virDomainVcpuPinDel()
Zhang Bo [Wed, 11 Feb 2015 08:48:24 +0000 (16:48 +0800)]
conf: Fix libvirtd crash and memory leak caused by virDomainVcpuPinDel()

The function virDomainVcpuPinDel() used vcpupin_list to stand for
def->cputune.vcpupin, which made the codes more readable.
However, in this function, it will realloc vcpupin_list later.
As the definition of realloc(), it may free vcpupin_list and then
points it to a new-realloced address, but def->cputune.vcpupin doesn't
point to the new address(it's freed however).
Thus,
1) When we refer to the def->cputune.vcpupin afterwards, which was freed
by realloc(), an INVALID READ occurs, and libvirtd may crash.
2) As no one will use vcpupin_list any more, and no one frees it(it's just
alloced by realloc()), memory leak occurs.

Part of the valgrind logs are shown as below:
==1837== Thread 15:
==1837== Invalid read of size 8
==1837==    at 0x5367337: virDomainDefFormatInternal (domain_conf.c:18392)
        which is : virBufferAsprintf(buf, "<vcpupin vcpu='%u' ",
                          def->cputune.vcpupin[i]->vcpuid);
==1837==    by 0x536966C: virDomainObjFormat (domain_conf.c:18970)
==1837==    by 0x5369743: virDomainSaveStatus (domain_conf.c:19166)
==1837==    by 0x117B26DC: qemuDomainPinVcpuFlags (qemu_driver.c:4586)
==1837==    by 0x53EA313: virDomainPinVcpuFlags (libvirt.c:9803)
==1837==    by 0x14CB7D: remoteDispatchDomainPinVcpuFlags (remote_dispatch.h:6762)
==1837==    by 0x14CC81: remoteDispatchDomainPinVcpuFlagsHelper (remote_dispatch.h:6740)
==1837==    by 0x5464C30: virNetServerProgramDispatchCall (virnetserverprogram.c:437)
==1837==    by 0x546507A: virNetServerProgramDispatch (virnetserverprogram.c:307)
==1837==    by 0x171B83: virNetServerProcessMsg (virnetserver.c:172)
==1837==    by 0x171E6E: virNetServerHandleJob (virnetserver.c:193)
==1837==    by 0x5318E78: virThreadPoolWorker (virthreadpool.c:145)
==1837==  Address 0x12ea2870 is 0 bytes inside a block of size 16 free'd
==1837==    at 0x4C291AC: realloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==1837==    by 0x52A3D14: virReallocN (viralloc.c:245)
==1837==    by 0x52A3DFB: virShrinkN (viralloc.c:372)
==1837==    by 0x52A3F57: virDeleteElementsN (viralloc.c:503)
==1837==    by 0x533939E: virDomainVcpuPinDel (domain_conf.c:15405)  //doReset为true时才会进到。
==1837==    by 0x117B2642: qemuDomainPinVcpuFlags (qemu_driver.c:4573)
==1837==    by 0x53EA313: virDomainPinVcpuFlags (libvirt.c:9803)
==1837==    by 0x14CB7D: remoteDispatchDomainPinVcpuFlags (remote_dispatch.h:6762)
==1837==    by 0x14CC81: remoteDispatchDomainPinVcpuFlagsHelper (remote_dispatch.h:6740)
==1837==    by 0x5464C30: virNetServerProgramDispatchCall (virnetserverprogram.c:437)
==1837==    by 0x546507A: virNetServerProgramDispatch (virnetserverprogram.c:307)
==1837==    by 0x171B83: virNetServerProcessMsg (virnetserver.c:172)

Steps to reproduce the problem:
1) use virDomainPinVcpuFlags() to pin a guest's vcpu to all the pcpus
of the host.

This patch uses def->cputune.vcpupin instead of vcpupin_list to do the
realloc() job, to avoid invalid read or memory leaking.

Signed-off-by: Zhang Bo <oscar.zhangbo@huawei.com>
Signed-off-by: Yue Wenyuan <yuewenyuan@huawei.com@huawei.com>
10 years agoconf: forbid seclabel duplicates for domain devices
Erik Skultety [Tue, 10 Feb 2015 16:17:35 +0000 (17:17 +0100)]
conf: forbid seclabel duplicates for domain devices

Parser checks for per-domain seclabel duplicates, so it would be nice if
it checked for per-device seclabel duplicates the same way

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

10 years agoschema: allow multiple seclabel for devices in domaincommon.rng
Erik Skultety [Tue, 10 Feb 2015 16:17:36 +0000 (17:17 +0100)]
schema: allow multiple seclabel for devices in domaincommon.rng

In our RNG schema we do allow multiple (different) seclabels per-domain,
but don't allow this for devices, yet we neither have a check in our XML parser,
nor in a post-parse callback. In that case we should allow multiple
(different) seclabels for devices as well.

10 years agoFix qemu job handling in SetSchedulerParameters
Ján Tomko [Tue, 10 Feb 2015 13:36:03 +0000 (14:36 +0100)]
Fix qemu job handling in SetSchedulerParameters

Commit c5ee5cf added a job to SetSchedulerParameters, but
forgot to change one label in the SCHED_RANGE_CHECK macro.

10 years agoqemu: Implement random number generator hotunplug
Luyao Huang [Sat, 17 Jan 2015 05:09:38 +0000 (13:09 +0800)]
qemu: Implement random number generator hotunplug

Signed-off-by: Luyao Huang <lhuang@redhat.com>
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
10 years agoqemu: Implement random number generator hotplug
Luyao Huang [Sat, 17 Jan 2015 05:09:37 +0000 (13:09 +0800)]
qemu: Implement random number generator hotplug

Export the required helpers and add backend code to hotplug RNG devices.

Signed-off-by: Luyao Huang <lhuang@redhat.com>
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
10 years agoqemu: Implement random number generator cold (un)plug
Peter Krempa [Thu, 5 Feb 2015 12:46:06 +0000 (13:46 +0100)]
qemu: Implement random number generator cold (un)plug

Add support for using the attach/detach device APIs on the inactive
configuration to add RNG devices.

10 years agoconf: Add helpers to insert/remove/find RNG devices in domain def
Luyao Huang [Sat, 17 Jan 2015 05:09:32 +0000 (13:09 +0800)]
conf: Add helpers to insert/remove/find RNG devices in domain def

The helpers will be useful when implementing hotplug and coldplug of
random number generator devices.

Signed-off-by: Luyao Huang <lhuang@redhat.com>
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
10 years agoaudit: export virDomainAuditRNG
Luyao Huang [Sat, 17 Jan 2015 05:09:36 +0000 (13:09 +0800)]
audit: export virDomainAuditRNG

Signed-off-by: Luyao Huang <lhuang@redhat.com>
10 years agoqemu: command: Refactor creation of RNG device commandline
Peter Krempa [Tue, 3 Feb 2015 09:31:33 +0000 (10:31 +0100)]
qemu: command: Refactor creation of RNG device commandline

As the RNG device is using an -object as backend refactor the code to
use the JSON to commandline generator so that we can reuse the code
later in hotplug.

10 years agoqemu: command: Break some very long lines in qemuBuildRNGDevStr()
Peter Krempa [Tue, 3 Feb 2015 09:26:40 +0000 (10:26 +0100)]
qemu: command: Break some very long lines in qemuBuildRNGDevStr()

10 years agoqemu: command: Shuffle around formatting of alias for RNG device backend
Peter Krempa [Tue, 3 Feb 2015 09:14:42 +0000 (10:14 +0100)]
qemu: command: Shuffle around formatting of alias for RNG device backend

Move the alias name right after the object type for rng-egd backend so
that we can later use the JSON to commandline generator to create the
command line.

10 years agoqemu: command: Make RNG backend device IDs unique
Luyao Huang [Sat, 17 Jan 2015 05:09:34 +0000 (13:09 +0800)]
qemu: command: Make RNG backend device IDs unique

Libvirt didn't prefix the random number generator backend object alias
with any string thus the device alias and object alias were identical.

To avoid possible problems, rename the alias for the backend object and
tweak tests to comply with the change.

Signed-off-by: Luyao Huang <lhuang@redhat.com>
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
10 years agoqemu: refactor qemuBuildRNGDeviceArgs to allow reuse in RNG hotplug
Luyao Huang [Sat, 17 Jan 2015 05:09:31 +0000 (13:09 +0800)]
qemu: refactor qemuBuildRNGDeviceArgs to allow reuse in RNG hotplug

Rename qemuBuildRNGDeviceArgs to qemuBuildRNGDevStr and change the
return type so that it can be reused in the device hotplug code later.

Signed-off-by: Luyao Huang <lhuang@redhat.com>
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
10 years agoqemu: Add helper to assign RNG device aliases
Luyao Huang [Sat, 17 Jan 2015 05:09:30 +0000 (13:09 +0800)]
qemu: Add helper to assign RNG device aliases

This function is used to assign an alias for a RNG device. It will be
later reused when hotplugging RNGs.

Signed-off-by: Luyao Huang <lhuang@redhat.com>
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
10 years agoconf: Introduce helper to find duplicate device address
Peter Krempa [Wed, 21 Jan 2015 14:41:44 +0000 (15:41 +0100)]
conf: Introduce helper to find duplicate device address

When adding devices to the definition it's useful to check whether the
devices don't reside on a conflicting address. This patch adds a helper
that iterates all device info and compares the addresses with the given
info.

10 years agoconf: disallow invalid values for video attributes
Martin Kletzander [Tue, 10 Feb 2015 07:55:06 +0000 (08:55 +0100)]
conf: disallow invalid values for video attributes

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agoS390: Documentation for ccw address type
Stefan Zimmermann [Wed, 4 Feb 2015 14:00:09 +0000 (15:00 +0100)]
S390: Documentation for ccw address type

Change the wording in the device-address-part of the docmunentation since
the ccw bus address support added to the optional address parameter of
virsh attach-disk for S390.

Signed-off-by: Stefan Zimmermann <stzi@linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
10 years agoS390: ccw support for virsh attach-disk address parameter
Stefan Zimmermann [Wed, 4 Feb 2015 14:00:08 +0000 (15:00 +0100)]
S390: ccw support for virsh attach-disk address parameter

Adding ccw bus address support to the optional address parameter of virsh
attach-disk. The format used is ccw:cssid. ssid.devno, e.g.
ccw:0xfe.0x0.0x0201

Virtio-ccw devices must have their cssid set to 0xfe.

Signed-off-by: Stefan Zimmermann <stzi@linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
10 years agoconf: fix a minor typo
Erik Skultety [Fri, 6 Feb 2015 18:13:24 +0000 (19:13 +0100)]
conf: fix a minor typo

10 years agoClear dynamic seclabels on LXCProcessStart failure
Cédric Bosdonnat [Fri, 6 Feb 2015 13:13:43 +0000 (14:13 +0100)]
Clear dynamic seclabels on LXCProcessStart failure

commit a58e1cb4 didn't fix the bug if the security_default_confined is
not set to 1. We now clean up even if there is no seclabel defined or
the default one.

10 years agomaint: improve usage of autogen's --no-git
Stefan Zimmermann [Fri, 6 Feb 2015 16:19:03 +0000 (17:19 +0100)]
maint: improve usage of autogen's --no-git

If you build libvirt with the --no-git option, then gnulib requires
either $GNULIB_SRCDIR in the environment or --gnulib-srcdir on the
command line.  But we had not been supporting its use from the
command line.  This patch is a bit picky: --gnulib-srcdir must be
passed immediately after --no-git; but since we don't reorder
arguments, and since we already required --no-git to be first to
have any effect, it's not too horrible.  It also does the wrong
thing if you include spaces in your arguments, but developers
doing that deserve what they get, right?

Signed-off-by: Stefan Zimmermann <stzi@linux.vnet.ibm.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agonetwork: don't allow multiple portgroups with the same name in a network
Laine Stump [Thu, 5 Feb 2015 19:20:54 +0000 (14:20 -0500)]
network: don't allow multiple portgroups with the same name in a network

When defining and creating networks, we have been checking to make
sure there is only a single "default" portgroup, but haven't verified
that no two portgroups have the same name. We *do* check for multiple
definitions when updating the portgroups in an existing network
though.

This patch adds a check to networkValidate(), which is called when a
network is defined or created, to disallow duplicate names. It would
actually make sense to do this in the network XML parser (since it's
not really "something that might make sense but isn't supported by
this driver", but is instead "something that should never be
allowed"), but doing that carries the danger of causing errors when
rereading the config of existing networks when libvirtd is restarted
after an upgrade, and that would result in networks disappearing from
libvirt's list. (I'm thinking I should change the error to "XML_ERROR"
instead of "UNSUPPORTED", even though that's not the type of error
that networkValidate is intended for)

This resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1115858

10 years agoError out when custom tap device path makes no sense
Ján Tomko [Thu, 5 Feb 2015 12:40:11 +0000 (13:40 +0100)]
Error out when custom tap device path makes no sense

It is only usable for NETWORK and BRIDGE type interfaces.
Error out when trying to start a domain where the custom
tap device path is specified for interfaces of other types,
or when the daemon is not privileged.

Note that this cannot be checked at definition time, because
the comparison is against actual type.

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

10 years agoOnly parse custom vhost path for virtio interfaces
Ján Tomko [Thu, 5 Feb 2015 12:38:40 +0000 (13:38 +0100)]
Only parse custom vhost path for virtio interfaces

It is only supported for virtio adapters.
Silently drop it if it was specified for other models,
as is done for other virtio attributes.

Also mention this in the documentation.

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

10 years agoTrivially support DomainHasManagedSaveImage
Ján Tomko [Thu, 15 Jan 2015 14:02:44 +0000 (15:02 +0100)]
Trivially support DomainHasManagedSaveImage

Return 0 instead of ERR_NO_SUPPORT in each driver
where we don't support managed save or -1 if
the domain does not exist.

This avoids spamming daemon logs when 'virsh dominfo' is run.

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

10 years agoqemu: include libvirt & QEMU versions in QEMU log files
Daniel P. Berrange [Mon, 2 Feb 2015 10:28:30 +0000 (10:28 +0000)]
qemu: include libvirt & QEMU versions in QEMU log files

It is often helpful to know which version of libvirt and QEMU
was present when a guest was first launched. Ensure this info
is written into the QEMU log file for each guest.

10 years agolibxl: update dom->id in libxlDomainCreateWithFlags
Marek Marczykowski-Górecki [Thu, 5 Feb 2015 05:17:07 +0000 (06:17 +0100)]
libxl: update dom->id in libxlDomainCreateWithFlags

Otherwise domainCreateWithFlags via remote returns -1 as domid.

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
10 years agonodedev: check/add for scsi_host caps for NumOfCaps and ListCaps
John Ferlan [Wed, 4 Feb 2015 13:10:52 +0000 (08:10 -0500)]
nodedev: check/add for scsi_host caps for NumOfCaps and ListCaps

Commit id '652a2ec6' introduced two new node device capability flags
and the ability to use those flags as a way to search for a specific
subset of a 'scsi_host' device - namely a 'fc_host' and/or 'vports'.
The code modified the virNodeDeviceCapMatch whichs allows for searching
using the 'virsh nodedev-list [cap]' via virConnectListAllNodeDevices.

However, the original patches did not account for other searches for
the same capability key from virNodeDeviceNumOfCaps and virNodeDeviceListCaps
using nodeDeviceNumOfCaps and nodeDeviceListCaps. Since 'fc_host' and
'vports' are self defined bits of a 'scsi_host' device mere string
comparison against the basic/root type is not sufficient.

This patch adds the check for the 'fc_host' and 'vports' bits within
a 'scsi_host' device and allows the following python code to find the
capabilities for the device:

import libvirt
conn = libvirt.openReadOnly('qemu:///system')
devs = conn.listAllDevices()
for dev in devs:
    if 'fc_host' in dev.listCaps() or 'vports' in dev.listCaps():
        print dev.name(),dev.numOfCaps(),dev.listCaps()

10 years agonodedev: check/add for scsi_host caps for ListDevices
Shivaprasad G Bhat [Tue, 3 Feb 2015 11:55:16 +0000 (06:55 -0500)]
nodedev: check/add for scsi_host caps for ListDevices

Commit id '652a2ec6' introduced two new node device capability flags
and the ability to use those flags as a way to search for a specific
subset of a 'scsi_host' device - namely a 'fc_host' and/or 'vports'.
The code modified the virNodeDeviceCapMatch whichs allows for searching
using the 'virsh nodedev-list [cap]' via virConnectListAllNodeDevices.

However, the original patches did not account for other searches for
the same capability key from virNodeListDevices using virNodeDeviceHasCap.
Since 'fc_host' and 'vports' are self defined bits of a 'scsi_host'
device mere string comparison against the basic/root type is not
sufficient.

This patch adds the check for the 'fc_host' and 'vports' bits within
a 'scsi_host' device and allows the following python code to find the
capabilities for the device:

import libvirt
conn = libvirt.openReadOnly('qemu:///system')
fc = conn.listDevices('fc_host', 0)
print(fc)
fc = conn.listDevices('vports', 0)
print(fc)

Signed-off-by: Shivaprasad G Bhat <sbhat@linux.vnet.ibm.com>
10 years agoqemu: Properly report error on uuid mismatch in the migration cookie
Luyao Huang [Thu, 5 Feb 2015 03:42:26 +0000 (11:42 +0800)]
qemu: Properly report error on uuid mismatch in the migration cookie

Add the missing jump to the error label when the uuid in the
migration cookie XML does not match the uuid of the migrated
domain.

Signed-off-by: Luyao Huang <lhuang@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
10 years agolxc: fix double close handshakefds[1]
Luyao Huang [Wed, 4 Feb 2015 13:32:52 +0000 (21:32 +0800)]
lxc: fix double close handshakefds[1]

Signed-off-by: Luyao Huang <lhuang@redhat.com>
10 years agocpu: add Freescale ppc64 CPU models
Olivia Yin [Fri, 30 Jan 2015 06:50:03 +0000 (14:50 +0800)]
cpu: add Freescale ppc64 CPU models

With this patch, Freescale ppc64 CPU modesl could be recognized.

virsh # cpu-models ppc64
POWERPC_e6500
POWERPC_e5500
power8
power8e
power7+
power7
power6
POWER8_v1.0
POWER7+_v2.1
POWER7_v2.3
POWER7_v2.1
POWER7

virsh # capabilities
<capabilities>
  <host>
    <uuid>5a54efa6-20dc-4da7-b271-0b7fb7062cb8</uuid>
    <cpu>
      <arch>ppc64</arch>
      <model>POWERPC_e6500</model>
      <vendor>Freescale</vendor>

10 years agoutil: storage: Fix parsing of nbd:// URI without path
Peter Krempa [Tue, 3 Feb 2015 17:03:41 +0000 (18:03 +0100)]
util: storage: Fix parsing of nbd:// URI without path

If a storage file would be backed with a NBD device without path
(nbd://localhost) libvirt would crash when parsing the backing path for
the disk as the URI structure's path element is NULL in such case but
the NBD parser would access it shamelessly.

10 years agotests: virstoragetest: Switch backing chain test to use automatic numbering
Peter Krempa [Tue, 3 Feb 2015 16:54:04 +0000 (17:54 +0100)]
tests: virstoragetest: Switch backing chain test to use automatic numbering

I'm going to add a few test cases so it's the best time to convert the
test to automatic numbering.