]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
10 years agovirNetworkObjIsDuplicate: s/@doms/@nets/
Michal Privoznik [Wed, 25 Feb 2015 14:10:53 +0000 (15:10 +0100)]
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>
10 years agonetworkGetNetworkAddress: Drop empty 'error' label
Michal Privoznik [Wed, 25 Feb 2015 16:51:37 +0000 (17:51 +0100)]
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>
10 years agotestNetworkUpdate: Unlock network at the end
Michal Privoznik [Wed, 25 Feb 2015 16:46:45 +0000 (17:46 +0100)]
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>
10 years agobridge_driver: Don't check network active unlocked
Michal Privoznik [Mon, 23 Feb 2015 18:00:57 +0000 (19:00 +0100)]
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>
10 years agonetworkLookupByUUID: Improve error message
Michal Privoznik [Mon, 23 Feb 2015 14:05:44 +0000 (15:05 +0100)]
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>
10 years agoqemuProcessReconnect: Fill in pid file path
Michal Privoznik [Tue, 3 Mar 2015 10:51:19 +0000 (11:51 +0100)]
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>
10 years agoqemu: check defaultMode for spice graphics independently
Pavel Hrdina [Fri, 27 Feb 2015 14:07:03 +0000 (15:07 +0100)]
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>
10 years agoqemu: remove duplicated code for allocating spice ports
Pavel Hrdina [Fri, 27 Feb 2015 13:28:53 +0000 (14:28 +0100)]
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>
10 years agotests : Add test for 'ppc64le' architecture.
Prerna Saxena [Thu, 26 Feb 2015 17:15:54 +0000 (22:45 +0530)]
tests : Add test for 'ppc64le' architecture.

Signed-off-by: Prerna Saxena <prerna@linux.vnet.ibm.com>
10 years agoRNG: Add 'ppc64le' arch and newer pseries-2.* machine types
Prerna Saxena [Thu, 26 Feb 2015 14:10:58 +0000 (08:10 -0600)]
RNG: Add 'ppc64le' arch and newer pseries-2.* machine types

Acked-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Prerna Saxena <prerna@linux.vnet.ibm.com>
10 years agoschema: Fix interface link state schema
Peter Krempa [Mon, 2 Mar 2015 16:21:23 +0000 (17:21 +0100)]
schema: Fix interface link state schema

In commit edd1295e1da6bfe8e4e257e5fbfad71ac0bf7c87 I've introduced an
XML element that allows to configure state of the network interface
link. Somehow the RNG schema hunk ended up in a weird place in the
network schema definition. Move it to the right place and add a test
case.

Note that the link state is set up via the monitor at VM startup so I
originally didn't think of adding a test case.

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

10 years agoconf: De-duplicate scheduling policy enums
Martin Kletzander [Mon, 2 Mar 2015 16:14:39 +0000 (17:14 +0100)]
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>
10 years agoqemu: Don't crash in qemuDomainOpenChannel()
Martin Kletzander [Mon, 2 Mar 2015 14:42:41 +0000 (15:42 +0100)]
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>
10 years agovirsh.pod: Update find-storage-pool-sources[-as] man page
John Ferlan [Wed, 25 Feb 2015 22:41:34 +0000 (17:41 -0500)]
virsh.pod: Update find-storage-pool-sources[-as] man page

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

Add to the man page a more complete description of what exactly the
command expects on input and will return on output based on what is
currently supported.

Perhaps missing findPoolSources implementations are backends for
sheepdog and rbd.  Also missing any backend is zfs.

10 years agoiscsi: Adjust error message for findStorageSources backend
John Ferlan [Wed, 25 Feb 2015 22:31:55 +0000 (17:31 -0500)]
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>

10 years agovirsh.pod: Add information regarding LXC for setmem, memtune, and dominfo
John Ferlan [Thu, 26 Feb 2015 23:31:06 +0000 (18:31 -0500)]
virsh.pod: Add information regarding LXC for setmem, memtune, and dominfo

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

Modify the virsh man page to more accurately describe which values are
set by the virsh setmem and displayed by the virsh memtune or dominfo
based on the setmem command results.

10 years agodisk: Provide a default storage source format type.
John Ferlan [Fri, 27 Feb 2015 00:39:36 +0000 (19:39 -0500)]
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.

10 years agodisk: Disallow duplicated target 'dev' values
John Ferlan [Thu, 26 Feb 2015 17:20:01 +0000 (12:20 -0500)]
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.

10 years agovirsh: Adjust domblklist to understand disk volume syntax
John Ferlan [Thu, 26 Feb 2015 16:22:17 +0000 (11:22 -0500)]
virsh: Adjust domblklist to understand disk volume syntax

A disk using a source pool is listed as having a source '-' in domblklist
because it doesn't check the right XML syntax to find the source.

Add a check for "./source/volume" which is where the "path" (of sorts)
to the volume name is described.

10 years agoconf: numa: Add helper to count total memory size configured in NUMA
Peter Krempa [Mon, 16 Feb 2015 19:15:04 +0000 (20:15 +0100)]
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.

10 years agoqemu: Forbid setting maximum memory size with the API with NUMA enabled
Peter Krempa [Tue, 17 Feb 2015 15:53:25 +0000 (16:53 +0100)]
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.

10 years agophyp: Fix error messages mentioning memory
Peter Krempa [Tue, 24 Feb 2015 17:08:51 +0000 (18:08 +0100)]
phyp: Fix error messages mentioning memory

The messages for currentMemory and memory were swapped.

10 years agodocs: add a note that attr 'managed' is only used by PCI devices
Erik Skultety [Fri, 27 Feb 2015 11:45:57 +0000 (12:45 +0100)]
docs: add a note that attr 'managed' is only used by PCI devices

Our documentation isn't 100% clear about hostdev 'managed' attribute usage,
because it only makes sense to use it with PCI devices, yet we format
this attribute to all hostdev devices. By adding a note into the docs,
we can possibly avoid confusion from customer's side and also avoid a solution
using ternary logic.

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

10 years agostorage: sheepdog: Avoid skipping variable initialization
Peter Krempa [Mon, 2 Mar 2015 09:09:49 +0000 (10:09 +0100)]
storage: sheepdog: Avoid skipping variable initialization

Commit 155ca616eb231181f6978efc9e3a1eb0eb60af8a added a error message
that skips initialization of the 'cmd' variable. Fortunately it was not
released.

10 years agoCheck if domain is running in qemuDomainAgentIsAvailable
Ján Tomko [Thu, 26 Feb 2015 13:00:47 +0000 (14:00 +0100)]
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

10 years agoPass virDomainObjPtr to qemuDomainAgentAvailable
Ján Tomko [Fri, 27 Feb 2015 13:06:47 +0000 (14:06 +0100)]
Pass virDomainObjPtr to qemuDomainAgentAvailable

Not just the DomainObj's private data.

10 years agoCheck for qemu guest agent availability after getting the job
Ján Tomko [Thu, 26 Feb 2015 12:47:58 +0000 (13:47 +0100)]
Check for qemu guest agent availability after getting the job

This way checks requiring the job can be done in qemuDomainAgentAvailable.

10 years agoAllow creating volumes with a backing store but no capacity
Ján Tomko [Tue, 17 Feb 2015 15:57:02 +0000 (16:57 +0100)]
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

10 years agoAllow omitting volume capacity when backing store is specified
Ján Tomko [Tue, 17 Feb 2015 15:55:59 +0000 (16:55 +0100)]
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.

10 years agoRevert "Restore skipping of setting capacity"
Ján Tomko [Thu, 19 Feb 2015 12:43:03 +0000 (13:43 +0100)]
Revert "Restore skipping of setting capacity"

This reverts commit f1856eb622fde2e6c3a6a932d1dded7f1691d205.

Now that we can update capacity from image metadata,
we don't need to skip the update.

10 years agoProbe for capacity in virStorageBackendUpdateVolTargetInfo
Ján Tomko [Thu, 19 Feb 2015 12:35:20 +0000 (13:35 +0100)]
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.

10 years agoAllow cloning volumes with no capacity specified
Ján Tomko [Tue, 17 Feb 2015 15:54:53 +0000 (16:54 +0100)]
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.

10 years agoAllow parsing volumes without specifying the capacity
Ján Tomko [Tue, 17 Feb 2015 15:47:04 +0000 (16:47 +0100)]
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.

10 years agoParse backingStore before capacity in volume XML
Ján Tomko [Tue, 10 Feb 2015 14:10:05 +0000 (15:10 +0100)]
Parse backingStore before capacity in volume XML

So we can allow omitting the capacity element if backing store is
present.

10 years agoAdd flags argument to virStorageVolDefParse*
Ján Tomko [Thu, 5 Feb 2015 15:20:17 +0000 (16:20 +0100)]
Add flags argument to virStorageVolDefParse*

Allow the callers to pass down libvirt-internal flags.

10 years agoAdd --migratable support to virsh cpu-baseline
Ján Tomko [Thu, 5 Feb 2015 14:30:50 +0000 (15:30 +0100)]
Add --migratable support to virsh cpu-baseline

Wire up VIR_CONNECT_BASELINE_CPU_MIGRATABLE to this
command line option.

10 years agoTrivially implement VIR_CONNECT_BASELINE_CPU_MIGRATABLE for non-x86 cpus
Ján Tomko [Thu, 5 Feb 2015 14:29:52 +0000 (15:29 +0100)]
Trivially implement VIR_CONNECT_BASELINE_CPU_MIGRATABLE for non-x86 cpus

Assume no features block migration.

10 years agoImplement VIR_CONNECT_BASELINE_CPU_MIGRATABLE in the x86 cpu driver
Ján Tomko [Thu, 5 Feb 2015 14:28:09 +0000 (15:28 +0100)]
Implement VIR_CONNECT_BASELINE_CPU_MIGRATABLE in the x86 cpu driver

Filter out non-migratable features if
VIR_CONNECT_BASELINE_CPU_MIGRATABLE was specified.

10 years agoAdd VIR_CONNECT_BASELINE_CPU_MIGRATABLE flag
Ján Tomko [Thu, 5 Feb 2015 14:26:03 +0000 (15:26 +0100)]
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

10 years agoUse virBufferTrim when generating boot options
Ján Tomko [Wed, 18 Feb 2015 16:30:52 +0000 (17:30 +0100)]
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.

10 years agoMake -boot arg generation more readable
Ján Tomko [Wed, 18 Feb 2015 16:25:10 +0000 (17:25 +0100)]
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.

10 years agoRemove code handling the QEMU_CAPS_DOMID capability
Ján Tomko [Wed, 18 Feb 2015 15:33:50 +0000 (16:33 +0100)]
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.

10 years agoRemove bootloader option from QEMU
Ján Tomko [Wed, 18 Feb 2015 15:08:40 +0000 (16:08 +0100)]
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

10 years agoPost-release version bump for new dev cycle
Ján Tomko [Mon, 2 Mar 2015 06:38:43 +0000 (07:38 +0100)]
Post-release version bump for new dev cycle

10 years agoRelease of libvirt-1.2.13
Daniel Veillard [Mon, 2 Mar 2015 03:40:05 +0000 (11:40 +0800)]
Release of libvirt-1.2.13

10 years agodocs: Add mist.io as libvirt-based application
Michal Privoznik [Fri, 27 Feb 2015 15:11:25 +0000 (16:11 +0100)]
docs: Add mist.io as libvirt-based application

As reported on the libvirt-users list [1], there's new web
application called mist.io which uses libvirt as one of its
backends. Lets add it into our list of libivrt based
applications.

1: https://www.redhat.com/archives/libvirt-users/2015-February/msg00096.html

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoReally fix XML formatting flags in SaveImageUpdateDef
Ján Tomko [Fri, 27 Feb 2015 10:55:40 +0000 (11:55 +0100)]
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

10 years agoIgnore listen attribute of <graphics> for type network listens
Ján Tomko [Thu, 26 Feb 2015 13:33:26 +0000 (14:33 +0100)]
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.

10 years agoutil: storage: Fix error type in virStorageSourceParseBackingURI
Peter Krempa [Thu, 26 Feb 2015 09:35:47 +0000 (10:35 +0100)]
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.

10 years agoutil: storagefile: Don't crash on gluster URIs without path
Peter Krempa [Thu, 26 Feb 2015 09:28:21 +0000 (10:28 +0100)]
util: storagefile: Don't crash on gluster URIs without path

Similar to commit fdb80ed4f6563928b9942a0d1450e0c725aa6c06 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

10 years agoconf: error out on missing dhcp host attributes
Ján Tomko [Thu, 26 Feb 2015 08:03:09 +0000 (09:03 +0100)]
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.

10 years agoconf: error out on invalid host id
Luyao Huang [Thu, 26 Feb 2015 06:14:20 +0000 (14:14 +0800)]
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>
10 years agoqemu: fix ifindex array reported to systemd
Laine Stump [Fri, 20 Feb 2015 19:52:37 +0000 (14:52 -0500)]
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().

10 years agoutil: check for null ifname inside virNetDevBandwidthSet()
Laine Stump [Tue, 24 Feb 2015 18:17:24 +0000 (13:17 -0500)]
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).

10 years agonetwork: only clear bandwidth if it has been set
Laine Stump [Tue, 24 Feb 2015 17:12:56 +0000 (12:12 -0500)]
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).

10 years agoschema: Allow interleaving the /domain/os/type element
Peter Krempa [Wed, 25 Feb 2015 10:19:15 +0000 (11:19 +0100)]
schema: Allow interleaving the /domain/os/type element

The element wasn't declared under the interleave thus it was required
always to be first. This made it inconvenient when pasting new stuff to
the XML manually in the "wrong" place.

10 years agoFix typos in messages
Yuri Chornoivan [Wed, 25 Feb 2015 13:12:33 +0000 (14:12 +0100)]
Fix typos in messages

Signed-off-by: Ján Tomko <jtomko@redhat.com>
10 years agoFix error messages in virStorageFileGetMetadataFromFD
Ján Tomko [Thu, 19 Feb 2015 12:32:41 +0000 (13:32 +0100)]
Fix error messages in virStorageFileGetMetadataFromFD

Do not use relPath, it has not been filled by virStorageFileMetadataNew.

10 years agoschema: Add virtio-mmio address type into RNG
Martin Kletzander [Wed, 25 Feb 2015 10:23:45 +0000 (11:23 +0100)]
schema: Add virtio-mmio address type into RNG

The "virtio-mmio" is perfectly valid address type which we parse and
format correctly, but it's missing in our RNG schemas, hence editing a
domain with device having such address fails the validation.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agoClarify behavior or virDomainDetachDevice
Ján Tomko [Fri, 20 Feb 2015 11:25:42 +0000 (12:25 +0100)]
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

10 years agoAssign default SCSI controller model before checking attribute validity
Ján Tomko [Wed, 18 Feb 2015 14:11:31 +0000 (15:11 +0100)]
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

10 years agovirsh: Add missing parenthesis into man page
Martin Kletzander [Wed, 25 Feb 2015 08:34:27 +0000 (09:34 +0100)]
virsh: Add missing parenthesis into man page

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agoqemu: Use correct flags for ABI stability check in SaveImageUpdateDef
Michal Privoznik [Thu, 19 Feb 2015 12:54:53 +0000 (13:54 +0100)]
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>
10 years agocpu: Format <cpu/> properly
Michal Privoznik [Wed, 18 Feb 2015 17:04:16 +0000 (18:04 +0100)]
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>
10 years agovirCPUDefFormatBufFull: Use our general error handling pattern
Michal Privoznik [Wed, 18 Feb 2015 17:06:44 +0000 (18:06 +0100)]
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>
10 years agoutil: Introduce virBufferAddBuffer
Michal Privoznik [Thu, 19 Feb 2015 09:56:58 +0000 (10:56 +0100)]
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>
10 years agoqemu: fix memory leak while starting a guest
Pavel Hrdina [Tue, 24 Feb 2015 13:31:37 +0000 (14:31 +0100)]
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>
10 years agonetwork_conf: Forbid commas in DNS TXT
Michal Privoznik [Mon, 23 Feb 2015 12:19:16 +0000 (13:19 +0100)]
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>
10 years agoRework s390 architecture checking
Stefan Zimmermann [Wed, 18 Feb 2015 15:44:19 +0000 (16:44 +0100)]
Rework s390 architecture checking

Making use of the ARCH_IS_S390 macro introduced with
e808357528d8be1ebc3970424b4a7b7c04eda2b6

Signed-off-by: Stefan Zimmermann <stzi@linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
10 years agoPrevent default creation of usb controller on s390 and s390x
Stefan Zimmermann [Wed, 18 Feb 2015 15:44:17 +0000 (16:44 +0100)]
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>
10 years agoman: moved virsh command cpu-models
Daniel Hansel [Wed, 18 Feb 2015 13:53:32 +0000 (14:53 +0100)]
man: moved virsh command cpu-models

The description of the virsh command 'cpu-models' was written in the
wrong context (i.e. beside the domain states).
This patch moves the command description just to the cpu related
commands like 'cpu-baseline' and 'cpu-compare'.

Signed-off-by: Daniel Hansel <daniel.hansel@linux.vnet.ibm.com>
10 years agopo: Add config file for zanata
Daniel P. Berrange [Mon, 23 Feb 2015 09:45:02 +0000 (09:45 +0000)]
po: Add config file for zanata

Add configuration file for use with https://fedora.zanata.org
translation system

10 years agolibvirt-guests: Allow time sync on guests resume
Michal Privoznik [Wed, 18 Feb 2015 10:59:22 +0000 (11:59 +0100)]
libvirt-guests: Allow time sync on guests resume

Well, imagine domains were running, and as the host went down, they
were managesaved. Later, after some time, the host went up again and
domains got restored. But without correct time. And depending on how
long was the host shut off, it may take some time for ntp to sync the
time too. But hey, wait a minute. We have an API just for that! So:

1) Introduce SYNC_TIME variable in libvirt-guests.sysconf to allow
users control over the new functionality
2) Call 'virsh domtime --sync $dom' in the libvirt-guests script.

Unfortunately, this is all-or-nothing approach (just like anything
else with the script). Domains are required to have configured and
running qemu-ga inside.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoqemu: Fix AAVMF/OVMF #define names
Cole Robinson [Wed, 18 Feb 2015 19:26:02 +0000 (14:26 -0500)]
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.

10 years agolibxl: support backend domain setting for disk and net devices
Marek Marczykowski [Fri, 20 Feb 2015 03:22:06 +0000 (04:22 +0100)]
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>
10 years agoconf: support backend domain name in disk and network devices
Marek Marczykowski [Fri, 20 Feb 2015 03:22:05 +0000 (04:22 +0100)]
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>
10 years agonetwork: allow <pf> together with <interface>/<address> in network status
Laine Stump [Sun, 15 Feb 2015 03:43:16 +0000 (22:43 -0500)]
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
34cc3b2f106e296df5e64309620c79d16fd76c85 (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.

10 years agoqemu: caps: Add capability bit for the "pc-dimm" device
Peter Krempa [Mon, 6 Oct 2014 12:16:47 +0000 (14:16 +0200)]
qemu: caps: Add capability bit for the "pc-dimm" device

The pc-dimm device represents a RAM memory module.

10 years agoconf: Hoist validation of memory size into the post parse callback
Peter Krempa [Tue, 10 Feb 2015 16:11:40 +0000 (17:11 +0100)]
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.

10 years agoconf: numa: Check ABI stability of NUMA configuration
Peter Krempa [Mon, 16 Feb 2015 19:34:37 +0000 (20:34 +0100)]
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.

10 years agoconf: ABI: Hugepage backing definition is not guest ABI
Peter Krempa [Wed, 11 Feb 2015 14:15:13 +0000 (15:15 +0100)]
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.

10 years agoconf: Move all NUMA configuration to virDomainNuma
Peter Krempa [Mon, 16 Feb 2015 16:28:48 +0000 (17:28 +0100)]
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.

10 years agoconf: numa: Add setter/getter for NUMA node memory size
Peter Krempa [Mon, 16 Feb 2015 18:14:23 +0000 (19:14 +0100)]
conf: numa: Add setter/getter for NUMA node memory size

Add the helpers and refactor places where the value is accessed without
them.

10 years agoconf: numa: Add accessor to NUMA node's memory access mode
Peter Krempa [Mon, 16 Feb 2015 17:51:36 +0000 (18:51 +0100)]
conf: numa: Add accessor to NUMA node's memory access mode

10 years agoconf: numa: Add accessor for the NUMA node cpu mask
Peter Krempa [Mon, 16 Feb 2015 17:38:43 +0000 (18:38 +0100)]
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.

10 years agoconf: numa: Add helper to get guest NUMA node count and refactor users
Peter Krempa [Mon, 16 Feb 2015 17:11:46 +0000 (18:11 +0100)]
conf: numa: Add helper to get guest NUMA node count and refactor users

Add an accessor so that a later refactor is simpler.

10 years agoqemu: command: Unify retrieval of NUMA cell count in qemuBuildNumaArgStr
Peter Krempa [Mon, 16 Feb 2015 16:55:50 +0000 (17:55 +0100)]
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.

10 years agoconf: numa: Don't pass double pointer to virDomainNumatuneParseXML
Peter Krempa [Mon, 16 Feb 2015 16:19:15 +0000 (17:19 +0100)]
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.

10 years agonuma: conf: Tweak parameters of virDomainNumatuneSet
Peter Krempa [Mon, 16 Feb 2015 16:05:46 +0000 (17:05 +0100)]
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".

10 years agoconf: numa: Always allocate the NUMA config
Peter Krempa [Mon, 16 Feb 2015 15:42:13 +0000 (16:42 +0100)]
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.

10 years agoconf: Allocate domain definition with the new helper
Peter Krempa [Mon, 16 Feb 2015 15:30:11 +0000 (16:30 +0100)]
conf: Allocate domain definition with the new helper

Use the virDomainDefNew() helper to allocate the definition instead of
doing it via VIR_ALLOC.

10 years agoconf: Separate helper for creating domain objects
Peter Krempa [Mon, 16 Feb 2015 14:58:13 +0000 (15:58 +0100)]
conf: Separate helper for creating domain objects

Move the existing virDomainDefNew to virDomainDefNewFull as it's setting
a few things in the conf and re-introduce virDomainDefNew as a function
without parameters for common use.

10 years agoconf: numa: Format <numatune> XML only if necessary
Peter Krempa [Mon, 16 Feb 2015 13:17:41 +0000 (14:17 +0100)]
conf: numa: Format <numatune> XML only if necessary

Do a content-aware check if formatting of the <numatune> element is
necessary. Later on the def->numa structure will be always present so we
cannot decide only on the basis whether it's allocated.

10 years agoconf: numa: Refactor logic in virDomainNumatuneParseXML
Peter Krempa [Thu, 12 Feb 2015 15:04:45 +0000 (16:04 +0100)]
conf: numa: Refactor logic in virDomainNumatuneParseXML

Shuffling around the logic will allow to simplify the code quite a bit.
As an additional bonus the change in the logic now reports an error if
automatic placement is selected and individual placement is configured.

10 years agoconf: numa: Reformat virDomainNumatuneParseXML
Peter Krempa [Thu, 12 Feb 2015 14:34:05 +0000 (15:34 +0100)]
conf: numa: Reformat virDomainNumatuneParseXML

Collapse few of the conditions so that the program flow is more clear.

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.