]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
10 years agonetwork: save bridge name in ActualNetDef when actualType==network too
Laine Stump [Fri, 21 Nov 2014 17:20:37 +0000 (12:20 -0500)]
network: save bridge name in ActualNetDef when actualType==network too

When the actualType of a virDomainNetDef is "network", it means that
we are connecting to a libvirt-managed network (routed, natted, or
isolated) which does use a bridge device (created by libvirt). In the
past we have required drivers such as qemu to call the public API to
retrieve the bridge name in this case (even though it is available in
the NetDef's ActualNetDef if the actualType is "bridge" (i.e., an
externally-created bridge that isn't managed by libvirt). There is no
real reason for this difference, and as a matter of fact it
complicates things for qemu. Also, there is another bridge-related
attribute (macTableManager) that will need to be available in both
cases, so this makes things consistent.

In order to avoid problems when restarting libvirtd after an update
from an older version that *doesn't* store the network's bridgename in
the ActualNetDef, we also need to put it in place during
networkNotifyActualDevice() (this function is run for each interface
of each domain whenever libvirtd is restarted).

Along with making the bridge name available in the internal object, it
is also now reported in the <source> element of the <interface> state
XML (or the <actual> subelement in the internally-stored format).

The one oddity about this change is that usually there is a separate
union for every different "type" in a higher level object (e.g. in the
case of a virDomainNetDef there are separate "network" and "bridge"
members of the union that pivots on the type), but in this case
network and bridge types both have exactly the same attributes, so the
"bridge" member is used for both type==network and type==bridge.

10 years agoconf: new network bridge device attribute macTableManager
Laine Stump [Thu, 20 Nov 2014 17:40:33 +0000 (12:40 -0500)]
conf: new network bridge device attribute macTableManager

The macTableManager attribute of a network's bridge subelement tells
libvirt how the bridge's MAC address table (used to determine the
egress port for packets) is managed. In the default mode, "kernel",
management is left to the kernel, which usually determines entries in
part by turning on promiscuous mode on all ports of the bridge,
flooding packets to all ports when the correct destination is unknown,
and adding/removing entries to the fdb as it sees incoming traffic
from particular MAC addresses.  In "libvirt" mode, libvirt turns off
learning and flooding on all the bridge ports connected to guest
domain interfaces, and adds/removes entries according to the MAC
addresses in the domain interface configurations. A side effect of
turning off learning and unicast_flood on the ports of a bridge is
that (with Linux kernel 3.17 and newer), the kernel can automatically
turn off promiscuous mode on one or more of the bridge's ports
(usually only the one interface that is used to connect the bridge to
the physical network). The result is better performance (because
packets aren't being flooded to all ports, and can be dropped earlier
when they are of no interest) and slightly better security (a guest
can still send out packets with a spoofed source MAC address, but will
only receive traffic intended for the guest interface's configured MAC
address).

The attribute looks like this in the configuration:

  <network>
    <name>test</name>
    <bridge name='br0' macTableManager='libvirt'/>
    ...

This patch only adds the config knob, documentation, and test
cases. The functionality behind this knob is added in later patches.

10 years agoutil: functions to manage bridge fdb (forwarding database)
Laine Stump [Thu, 20 Nov 2014 16:55:50 +0000 (11:55 -0500)]
util: functions to manage bridge fdb (forwarding database)

These two functions use netlink RTM_NEWNEIGH and RTM_DELNEIGH messages
to add and delete entries from a bridge's fdb. The bridge itself is
not referenced in the arguments to the functions, only the name of the
device that is attached to the bridge (since a device can only be
attached to one bridge at a time, and must be attached for this
function to make sense, the kernel easily infers which bridge's fdb is
being modified by looking at the device name/index).

10 years agoutil: new functions for setting bridge and bridge port attributes
Laine Stump [Wed, 19 Nov 2014 18:28:57 +0000 (13:28 -0500)]
util: new functions for setting bridge and bridge port attributes

These functions all set/get items in the sysfs for a bridge device.

10 years agogetstats: add block.n.path stat
Eric Blake [Tue, 25 Nov 2014 00:12:30 +0000 (17:12 -0700)]
getstats: add block.n.path stat

I'm about to make block stats optionally more complex to cover
backing chains, where block.count will no longer equal the number
of <disks> for a domain.  For these reasons, it is nicer if the
statistics output includes the source path (for local files).
This patch doesn't add anything for network disks, although we
may decide to add that later.

With this patch, I now see the following for the same domain as
in the previous patch (one qcow2 file, and an empty cdrom drive):
$ virsh domstats --block foo
Domain: 'foo'
  block.count=2
  block.0.name=hda
  block.0.path=/var/lib/libvirt/images/foo.qcow2
  block.1.name=hdc

* src/libvirt-domain.c (virConnectGetAllDomainStats): Document
new field.
* tools/virsh.pod (domstats): Document new field.
* src/qemu/qemu_driver.c (qemuDomainGetStatsBlock): Return the new
stat for local files/block devices.
(QEMU_ADD_NAME_PARAM): Add parameter.
(qemuDomainGetStatsInterface): Update caller.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agogetstats: start giving offline block stats
Eric Blake [Tue, 25 Nov 2014 00:12:30 +0000 (17:12 -0700)]
getstats: start giving offline block stats

I noticed that for an offline domain, 'virsh domstats --block $dom'
was producing just the domain name, with no stats.  But the older
'virsh domblkinfo' works just fine on offline domains.  This patch
starts to get us closer, by at least reporting the disk names for
an offline domain.

With this patch, I now see the following for an offline domain
with one qcow2 disk and an empty cdrom drive:
$ virsh domstats --block foo
Domain: 'foo'
  block.count=2
  block.0.name=hda
  block.1.name=hdc

* src/qemu/qemu_driver.c (qemuDomainGetStatsBlock): Don't short-circuit
output of block name.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agogetstats: improve documentation
Eric Blake [Fri, 5 Dec 2014 04:39:55 +0000 (21:39 -0700)]
getstats: improve documentation

At least with 'virsh domstats --block' on an offline domain, we
currently output no stats even though we recognize the stat
category.  Although a later patch will improve this situation,
it is better to document that this is expected behavior.

Also, while the current implementation rejects filtering flags
for virDomainListGetStats, this limitation may be lifted in the
future and we do not enforce it at the API level.

* src/libvirt-domain.c (virConnectGetAllDomainStats): Document
that recognized stats might not be reported.
(virDomainListGetStats): Likewise, and tweak filtering documentation.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agogetstats: avoid memory leak on OOM
Eric Blake [Fri, 5 Dec 2014 23:06:52 +0000 (16:06 -0700)]
getstats: avoid memory leak on OOM

qemuDomainGetStatsBlock() could leak a stats hash table if it
encountered OOM while populating the virTypedParameters.
Oddly, the fix doesn't even touch qemuDomainGetStatsBlock :)

* src/qemu/qemu_driver.c (QEMU_ADD_COUNT_PARAM)
(QEMU_ADD_NAME_PARAM): Don't return early.
(qemuDomainGetStatsInterface): Adjust caller.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agodocs: Use gender-neutral pronoun in hacking.html.in
Christophe Fergeau [Mon, 8 Dec 2014 13:13:00 +0000 (14:13 +0100)]
docs: Use gender-neutral pronoun in hacking.html.in

Use 'they' instead of 'he'.

10 years agorpc: Report proper close reason
Martin Kletzander [Sun, 30 Nov 2014 19:09:08 +0000 (20:09 +0100)]
rpc: Report proper close reason

Whenever client socket was marked as closed for some reason, it could've
been changed when really closing the connection.  With this patch the
proper reason is kept since the first time it's marked as closed.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agovirsh: Don't reconnect after the command when disconnected
Martin Kletzander [Mon, 1 Dec 2014 10:46:14 +0000 (11:46 +0100)]
virsh: Don't reconnect after the command when disconnected

Each command that needs a connection causes a new connection to be
made.  Reconnecting after a command failed is pointless, mainly when
there is no other command to run.  Removeing three lines of code takes
care of that and keeps virsh working as it should.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agostorage: Fix printing/casting of uid_t/gid_t
Peter Krempa [Fri, 5 Dec 2014 08:51:23 +0000 (09:51 +0100)]
storage: Fix printing/casting of uid_t/gid_t

Other parts of libvirt use "%u" for formatting uid/gid and typecast to
unsigned int. Storage driver used the signed variant.

10 years agodocs: network: fix some trivial typos in docs/formatnetwork.html
Chen Fan [Fri, 5 Dec 2014 09:38:46 +0000 (17:38 +0800)]
docs: network: fix some trivial typos in docs/formatnetwork.html

this patch fix some weird typos:
   1. < hostdev>     => <hostdev>
   2. < type>        => <type>
   3. <virtualport > => <virtualport>
   4. redundant comma
   5. missing right-half bracket

Signed-off-by: Chen Fan <chen.fan.fnst@cn.fujitsu.com>
10 years agovirsh: Add adapter options for pool-{create|define}-as
John Ferlan [Thu, 4 Dec 2014 14:22:30 +0000 (09:22 -0500)]
virsh: Add adapter options for pool-{create|define}-as

Add the optional adapter options for pool create/define.  Results in
either:

<adapter type='scsi_host' name='scsi_host2'/>

or (on one line)

<adapter type='fc_host' parent='scsi_host5'
         wwnn='20000000c9831b4b' wwpn='10000000c9831b4b'/>

being generated.

10 years agovirsh: Add auth options for pool-{create|define}-as
John Ferlan [Wed, 3 Dec 2014 23:45:50 +0000 (18:45 -0500)]
virsh: Add auth options for pool-{create|define}-as

Add 3 new optional options for the pool-create-as and pool-define-as
command in order to define the 3 elements required in order to add
an auth element, such as:

<auth type='chap' username='myuser'>
  <secret usage='libvirtiscsi'/>
</auth>

10 years agovirsh.pod: Fix the pool-define-as and pool-create-as description
John Ferlan [Thu, 4 Dec 2014 00:46:54 +0000 (19:46 -0500)]
virsh.pod: Fix the pool-define-as and pool-create-as description

Properly format the options and provide meaningful descriptions for
the various options.

10 years agodocs: Fix a couple of typos on the storage pool html
John Ferlan [Thu, 4 Dec 2014 00:09:20 +0000 (19:09 -0500)]
docs: Fix a couple of typos on the storage pool html

Fix format of the secret XML in the example. The XML had an extraneous
"type='iscsi'" (which is used by the <disk> definitions)

The world wide node name had a typo in the acronym (wwwn).

10 years agoutil: check for an illegal character in a XML namespace prefix
Erik Skultety [Thu, 4 Dec 2014 13:37:09 +0000 (14:37 +0100)]
util: check for an illegal character in a XML namespace prefix

When user tries to insert element metadata providing a namespace
declaration as well, currently we insert the element without any validation
check for XML prefix (if provided). The next VM start would then
fail with parse error. This patch fixes this issue by adding a call to
xmlValidateNCName function to check for illegal characters in the
prefix.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1143921

10 years agoReport original error when QMP probing fails with new QEMU
Daniel P. Berrange [Thu, 4 Dec 2014 15:26:41 +0000 (15:26 +0000)]
Report original error when QMP probing fails with new QEMU

If probing capabilities via QMP fails, we now have a check
that prevents us falling back to -help parsing. Unfortunately
the error message

  "Failed to probe capabilities for /usr/bin/qemu-kvm:
   unsupported configuration: QEMU 2.1.2 is too new for help parsing"

is proving rather unhelpful to the user. We need to be telling
them why QMP failed (the root cause), rather than they can't
use -help (the side effect).

To do this we should capture stderr during QMP probing, and
if -help parsing then sees a new QEMU version, we know that
QMP should have worked, and so we can show the messages from
stderr. The message thus becomes

  "Failed to probe capabilities for /usr/bin/qemu-kvm:
   internal error: QEMU / QMP failed: Could not access
   KVM kernel module: No such file or directory
   failed to initialize KVM: No such file or directory"

10 years agoqemu: snapshot: Forbid internal snapshot with passthrough devices
Shanzhi Yu [Wed, 3 Dec 2014 11:12:35 +0000 (19:12 +0800)]
qemu: snapshot: Forbid internal snapshot with passthrough devices

When attempting to create internal system checkpoint with a passthrough
device qemu will report the following error:

error: operation failed: Error -22 while writing VM

This patch calls the function to check if migration is possible with
given VM and thus improves the error to:

error: Requested operation is not valid: domain has assigned non-USB host devices

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=874418#c19
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
10 years agostorage: backend: Log uid/gid when initializing storage file backend
Peter Krempa [Tue, 14 Oct 2014 13:55:09 +0000 (15:55 +0200)]
storage: backend: Log uid/gid when initializing storage file backend

To ease debugging permission problems add uid/gid values to the debug
message when initializing a storage file backend.

10 years agonetworkValidate: Disallow bandwidth in portgroups too
Michal Privoznik [Wed, 3 Dec 2014 17:15:40 +0000 (18:15 +0100)]
networkValidate: Disallow bandwidth in portgroups too

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

In one of the previous commits (eafb53fe) we disallowed
network-wide bandwidth to some network types. However, we
forgot about <portgroups/> which can have <bandwidth/> too.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agodocs: storage: fix rbd pool indentation
Cole Robinson [Thu, 4 Dec 2014 15:34:05 +0000 (10:34 -0500)]
docs: storage: fix rbd pool indentation

10 years agoqemu: process: Avoid uninitialized use two vars when reconnecting to vm
Peter Krempa [Thu, 4 Dec 2014 15:13:31 +0000 (16:13 +0100)]
qemu: process: Avoid uninitialized use two vars when reconnecting to vm

3ecebf07110ca8d3413072557f29137943e848e3 breaks the build as it adds a
way to jump to cleanup before the 'cfg' object is retrieved and 'priv'
is initialized.

10 years agoFix handling of whitespae in preprocessor macros for API generator
Daniel P. Berrange [Thu, 4 Dec 2014 12:06:32 +0000 (12:06 +0000)]
Fix handling of whitespae in preprocessor macros for API generator

The apibuild.py script did not handle whitespace in preprocessor
macros, so it failed to detect constants declared with '# define'
instead of '#define'. Since we now correctly indent our public
header files, we have silently lost all constants from
libvirt-api.xml. This also caused us to not detect formatting
errors in constant docs

10 years agoqemu: process: Refactor reconnecting to qemu processes
Peter Krempa [Wed, 3 Dec 2014 13:22:05 +0000 (14:22 +0100)]
qemu: process: Refactor reconnecting to qemu processes

Move entering the job into the thread to simplify the program flow. Also
as the code holds a separate reference to the domain object some
conditions can be simplified.

After this patch qemuDomainObjTransferJob is no longer needed so this
patch removes it.

10 years agodocs: Create html documentation even if XHTML1 DTD is not available to validate
Ian Campbell [Fri, 28 Nov 2014 14:36:18 +0000 (14:36 +0000)]
docs: Create html documentation even if XHTML1 DTD is not available to validate

On a Debian system lacking the w3c-dtd-xhtml package the build fails
with:

        $ make -C docs/ formatcaps.html
        make: Entering directory '/local/scratch/ianc/devel/libvirt.git/docs'
        Generating formatcaps.html.tmp
        I/O error : Attempt to load network entity http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd
        formatcaps.html.in:2: warning: failed to load external entity "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
        C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
                                                                                       ^
        I/O error : Attempt to load network entity http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd
        ../docs/sitemap.html.in:2: warning: failed to load external entity "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
        C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
                                                                                       ^
        missing XHTML1 DTD
        rm formatcaps.html.tmp
        make: Leaving directory '/local/scratch/ianc/devel/libvirt.git/docs'
        $ ls docs/formatcaps*
        docs/formatcaps.html.in

https://www.redhat.com/archives/libvir-list/2009-November/msg00413.html
suggests that the XHTML1 DTD should not be a hard requirement and the
docs should be generated but not validated if it is not available.

Therefore when the DTD is not available arrange for the .html.tmp file
to be propagated to the .html output.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Cc: Daniel Veillard <veillard@redhat.com>
10 years agotests: Fix misplaced parenthesis in qemumonitorjsontest
Martin Kletzander [Wed, 3 Dec 2014 13:42:27 +0000 (14:42 +0100)]
tests: Fix misplaced parenthesis in qemumonitorjsontest

When trying clang, it found out that we were comparing sizeof with 0
even though we wanted to check the return value of memcmp.  That showed
us that the test was wrong and it needs a fix as well.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agodrvbhyve: Automatically tear down guest domains on shutdown
Conrad Meyer [Fri, 14 Nov 2014 16:03:30 +0000 (11:03 -0500)]
drvbhyve: Automatically tear down guest domains on shutdown

Reboot requires more sophistication and is left as a future work item --
but at least part of the plumbing is in place.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoqemu: Fix virsh freeze when blockcopy storage file is removed
Erik Skultety [Wed, 3 Dec 2014 12:56:47 +0000 (13:56 +0100)]
qemu: Fix virsh freeze when blockcopy storage file is removed

If someone removes blockcopy storage file when still in mirroring phase
and then requesting blockjob abort using pivot, virsh cmd freezes. This
is not an issue with older qemu versions which did not support
asynchronous jobs (which we prefer by default).
As we have reached the mirroring phase successfully, polling monitor for
blockjob info always returns 1 and the loop never ends.
This fix introduces a check for qemuDomainBlockPivot return code, possibly
skipping the asynchronous waiting completely, if an error occurred and
asynchronous waiting was the preferred method.

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

10 years agodocs: More html/docs changes from libvirt.h.in split
John Ferlan [Wed, 3 Dec 2014 21:15:14 +0000 (16:15 -0500)]
docs: More html/docs changes from libvirt.h.in split

This changes the display from:

libvirt-storage: APIs for management of storages

to

libvirt-storage: APIs for management of storage pools and volumes

In making that change I expected my build tree html output to be
regenerated; however, it wasn't because the dependency for the separated
libvirt-storage.h wasn't there.  It was only present for libvirt.h.in

So I added each in the order displayed on the docs/html/index.html page

10 years agocpu: fix possible crash in getModels
Pavel Hrdina [Wed, 3 Dec 2014 17:50:16 +0000 (18:50 +0100)]
cpu: fix possible crash in getModels

Commit 86a15a25 introduced a new cpu driver API 'getModels'. Public API
allow you to pass NULL for models to get only number of existing models.
However the new code will crash with segfault so we have to count with
the possibility that the user wants only the number.

There is also difference in order of the models gathered by this new API
as the old approach was inserting the elements to the end of the array
so we should use 'VIR_APPEND_ELEMENT'.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
10 years agoqemu: driver: Reload snapshots and managedsaves prior to reconnecting
Peter Krempa [Wed, 3 Dec 2014 10:18:53 +0000 (11:18 +0100)]
qemu: driver: Reload snapshots and managedsaves prior to reconnecting

Reconnect to the VM is a possibly long-running job spawned in a separate
thread. We should reload the snapshot defs and managedsave state prior
to spawning the thread to avoid blocking of the daemon startup which
would serialize on the VM lock.

Also the reloading code would violate the domain job held while
reconnecting as the loader functions don't create jobs.

10 years agoleaseshelper: Fix incorrect alignment of a switch case
Peter Krempa [Wed, 3 Dec 2014 17:27:03 +0000 (18:27 +0100)]
leaseshelper: Fix incorrect alignment of a switch case

Introduced in ca6dbdd047d1ed691ccbae72556d85722a5f7a36

10 years agoleaseshelper: Skip entries missing expiry time on INIT action
Peter Krempa [Wed, 3 Dec 2014 17:24:38 +0000 (18:24 +0100)]
leaseshelper: Skip entries missing expiry time on INIT action

Coverity pointed out that in other places we always check the return
value from virJSONValueObjectGetNumberLong() but not in the new addition
in leaseshelper. To solve the issue and also be more robust in case
somebody would corrupt the file, skip outputting of the lease entry in
case the expiry time is missing.

10 years agostorage: fix crash caused by no check return before set close
Luyao Huang [Wed, 3 Dec 2014 15:01:32 +0000 (23:01 +0800)]
storage: fix crash caused by no check return before set close

https://bugzilla.redhat.com/show_bug.cgi?id=1087104#c5

When trying to use an invalid offset to virStorageVolUpload(), libvirt
fails in virFDStreamOpenFileInternal(), although it seems libvirt does
not check the return in storageVolUpload(), and calls
virFDStreamSetInternalCloseCb() right after.  But stream doesn't have a
privateData (is NULL) yet, and the daemon crashes then.

0  0x00007f09429a9c10 in pthread_mutex_lock () from /lib64/libpthread.so.0
1  0x00007f094514dbf5 in virMutexLock (m=<optimized out>) at util/virthread.c:88
2  0x00007f09451cb211 in virFDStreamSetInternalCloseCb at fdstream.c:795
3  0x00007f092ff2c9eb in storageVolUpload at storage/storage_driver.c:2098
4  0x00007f09451f46e0 in virStorageVolUpload at libvirt.c:14000
5  0x00007f0945c78fa1 in remoteDispatchStorageVolUpload at remote_dispatch.h:14339
6  remoteDispatchStorageVolUploadHelper at remote_dispatch.h:14309
7  0x00007f094524a192 in virNetServerProgramDispatchCall at rpc/virnetserverprogram.c:437

Signed-off-by: Luyao Huang <lhuang@redhat.com>
10 years agovirsh: vol-upload disallow negative offset
Shanzhi Yu [Wed, 3 Dec 2014 07:53:38 +0000 (15:53 +0800)]
virsh: vol-upload disallow negative offset

Commit 570d0f63 describes disabling negative offset usage for
vol-upload/download (e.g. cmdVolDownload and cmdVolUpload; however,
the change was only made to cmdVolDownload. There was no change to
cmdVolUpload.  This patch adds the same checks for vol-upload.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1087104
Signed-off-by: Shanzhi Yu <shyu@redhat.com>
10 years agonetwork: dnsmasq: Don't format lease file path
Peter Krempa [Thu, 20 Nov 2014 12:56:39 +0000 (13:56 +0100)]
network: dnsmasq: Don't format lease file path

Now that we don't use the leases file at all for leases just don't
format it into the config and use the leaseshelper to do all the
lifting.

10 years agoleaseshelper: Refactor control flow
Peter Krempa [Thu, 20 Nov 2014 13:49:31 +0000 (14:49 +0100)]
leaseshelper: Refactor control flow

Untangle a few conditions into a case statement and improve reporting of
invaid commands.

10 years agoleaseshelper: improvements to support all events
Nehal J Wani [Tue, 18 Nov 2014 17:16:25 +0000 (22:46 +0530)]
leaseshelper: improvements to support all events

This patch enables the helper program to detect event(s) triggered when
there is a change in lease length or expiry and client-id. This
transfers complete control of leases database to libvirt and obsoletes
use of the lease database file (<network-name>.leases). That file will
not be created, read, or written.  This is achieved by adding the option
--leasefile-ro to dnsmasq and passing a custom env var to leaseshelper,
which helps us map events related to leases with their corresponding
network bridges, no matter what the event be.

Also, this requires the addition of a new non-lease entry in our custom
lease database: "server-duid". It is required to identify a DHCPv6
server.

Now that dnsmasq doesn't maintain its own leases database, it relies on
our helper program to tell it about previous leases and server duid.
Thus, this patch makes our leases program honor an extra action: "init",
in which it sends the known info in a particular format to dnsmasq
by printing it to stdout.

The drawback of this change is that upgrade to this new approach does
not transfer the existing leases for the network if the leaseshelper
wasn't already used.

10 years agocpu-driver: Fix the cross driver function call
Daniel Hansel [Thu, 20 Nov 2014 10:08:21 +0000 (11:08 +0100)]
cpu-driver: Fix the cross driver function call

For Intel and PowerPC the implementation is calling a cpu driver
function across driver layers (i.e. from qemu driver directly to cpu
driver).
The correct behavior is to use libvirt API functionality to perform such
a inter-driver call.

This patch introduces a new cpu driver API function getModels() to
retrieve the cpu models. The currect implementation to process the
cpu_map XML content is transferred to the INTEL and PowerPC cpu driver
specific API functions.
Additionally processing the cpu_map XML file is not safe due to the fact
that the cpu map does not exist for all architectures. Therefore it is
better to encapsulate the processing in the architecture specific cpu
drivers.

Signed-off-by: Daniel Hansel <daniel.hansel@linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Reviewed-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
10 years agoqemu_migration: Precreate missing storage
Michal Privoznik [Tue, 25 Nov 2014 13:19:07 +0000 (14:19 +0100)]
qemu_migration: Precreate missing storage

Based on previous commit, we can now precreate missing volumes. While
digging out the functionality from storage driver would be nicer, if
you've seen the code it's nearly impossible. So I'm going from the
other end:

1) For given disk target, disk path is looked up.
2) For the disk path, storage pool is looked up, a volume XML is
constructed and then passed to virStorageVolCreateXML() which has all
the knowledge how to create raw images, (encrypted) qcow(2) images,
etc.

One of the advantages of this approach is, we don't have to care about
image conversion - qemu does that for us. So for instance, users can
transform qcow2 into raw on migration (if the correct XML is passed to
the migration API).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoqemu_migration: Send disk sizes to the other side
Michal Privoznik [Mon, 24 Nov 2014 14:55:36 +0000 (15:55 +0100)]
qemu_migration: Send disk sizes to the other side

Up 'til now, users need to precreate non-shared storage on migration
themselves. This is not very friendly requirement and we should do
something about it. In this patch, the migration cookie is extended,
so that <nbd/> section does not only contain NBD port, but info on
disks being migrated. This patch sends a list of pairs of:

    <disk target; disk size>

to the destination. The actual storage allocation is left for next
commit.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoqemuMonitorJSONBlockStatsUpdateCapacity: Don't skip disks
Michal Privoznik [Mon, 1 Dec 2014 14:31:51 +0000 (15:31 +0100)]
qemuMonitorJSONBlockStatsUpdateCapacity: Don't skip disks

The function queries the block devices visible to qemu
('query-block') and parses the qemu's output. The info is
returned in a hash table which is expected to be pre-filled by
qemuMonitorJSONGetAllBlockStatsInfo(). However, in the next patch
we are not going to call the latter function at all, so we should
make the former function add devices into the hash table if not
found there.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agostorage: Introduce storagePoolLookupByTargetPath
Michal Privoznik [Wed, 26 Nov 2014 16:13:00 +0000 (17:13 +0100)]
storage: Introduce storagePoolLookupByTargetPath

While this could be exposed as a public API, it's not done yet as
there's no demand for that yet. Anyway, this is just preparing
the environment for easier volume creation on the destination.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoReplace virDomainSnapshotFree with virObjectUnref
John Ferlan [Mon, 1 Dec 2014 12:30:16 +0000 (07:30 -0500)]
Replace virDomainSnapshotFree with virObjectUnref

Since virDomainSnapshotFree will call virObjectUnref anyway, let's just use
that directly so as to avoid the possibility that we inadvertently clear out
a pending error message when using the public API.

10 years agoReplace virInterfaceFree with virObjectUnref
John Ferlan [Sun, 30 Nov 2014 17:07:19 +0000 (12:07 -0500)]
Replace virInterfaceFree with virObjectUnref

Since virInterfaceFree will call virObjectUnref anyway, let's just use that
directly so as to avoid the possibility that we inadvertently clear out
a pending error message when using the public API.

10 years agoReplace virNWFilterFree with virObjectUnref
John Ferlan [Sun, 30 Nov 2014 17:03:00 +0000 (12:03 -0500)]
Replace virNWFilterFree with virObjectUnref

Since virNWFilterFree will call virObjectUnref anyway, let's just use that
directly so as to avoid the possibility that we inadvertently clear out
a pending error message when using the public API.

10 years agoReplace virSecretFree with virObjectUnref
John Ferlan [Sun, 30 Nov 2014 16:48:06 +0000 (11:48 -0500)]
Replace virSecretFree with virObjectUnref

Since virSecretFree will call virObjectUnref anyway, let's just use that
directly so as to avoid the possibility that we inadvertently clear out
a pending error message when using the public API.

10 years agoReplace virStreamFree with virObjectUnref
John Ferlan [Sun, 30 Nov 2014 15:19:38 +0000 (10:19 -0500)]
Replace virStreamFree with virObjectUnref

Since virStreamFree will call virObjectUnref anyway, let's just use that
directly so as to avoid the possibility that we inadvertently clear out
a pending error message when using the public API.

10 years agoReplace virStoragePoolFree with virObjectUnref
John Ferlan [Sun, 30 Nov 2014 14:35:12 +0000 (09:35 -0500)]
Replace virStoragePoolFree with virObjectUnref

Since virStoragePoolFree will call virObjectUnref anyway, let's just use that
directly so as to avoid the possibility that we inadvertently clear out
a pending error message when using the public API.

10 years agoReplace virStorageVolFree with virObjectUnref
John Ferlan [Sun, 30 Nov 2014 14:26:02 +0000 (09:26 -0500)]
Replace virStorageVolFree with virObjectUnref

Since virStorageVolFree will call virObjectUnref anyway, let's just use that
directly so as to avoid the possibility that we inadvertently clear out
a pending error message when using the public API.

10 years agoReplace virNodeDeviceFree with virObjectUnref
John Ferlan [Sat, 29 Nov 2014 12:03:35 +0000 (07:03 -0500)]
Replace virNodeDeviceFree with virObjectUnref

Since virNodeDeviceFree will call virObjectUnref anyway, let's just use that
directly so as to avoid the possibility that we inadvertently clear out
a pending error message when using the public API.

10 years agoReplace virNetworkFree with virObjectUnref
John Ferlan [Tue, 25 Nov 2014 12:42:58 +0000 (07:42 -0500)]
Replace virNetworkFree with virObjectUnref

Since virNetworkFree will call virObjectUnref anyway, let's just use that
directly so as to avoid the possibility that we inadvertently clear out
a pending error message when using the public API.

10 years agoReplace virDomainFree with virObjectUnref
John Ferlan [Sun, 30 Nov 2014 14:57:02 +0000 (09:57 -0500)]
Replace virDomainFree with virObjectUnref

Since virDomainFree will call virObjectUnref anyway, let's just use that
directly so as to avoid the possibility that we inadvertently clear out
a pending error message when using the public API.

10 years agorpc: Replace virXXXFree with virObjectUnref
John Ferlan [Sun, 30 Nov 2014 14:40:31 +0000 (09:40 -0500)]
rpc: Replace virXXXFree with virObjectUnref

Modify the various virXXXFree calls to only call virObjectUnref. Calling
the public API will reset the last error thus clearing out a pending error.

10 years agoparallels: fix compilation of parallels_storage.c
Dmitry Guryanov [Tue, 18 Nov 2014 13:02:04 +0000 (16:02 +0300)]
parallels: fix compilation of parallels_storage.c

virConnect.privateData is void *, so we can't access
fields of parallelsConn, pointer to which is stored in
virConnect.privateData. So replace all occurences of
conn->privateData->storageState with privconn->storageState.

Signed-off-by: Dmitry Guryanov <dguryanov@parallels.com>
10 years agoGenerate a MAC when loading a config instead of package update
Ján Tomko [Tue, 11 Nov 2014 08:16:09 +0000 (09:16 +0100)]
Generate a MAC when loading a config instead of package update

Partially reverts commit 5754dbd.

The code in the specfile adds a MAC address to every <bridge>,
even for <forward mode='bridge'> for which we don't support
changing MAC addresses.

Remove it completely. For new networks, we have been adding
MAC addresses on definition/creation since the commit mentioned above.
For existing networks (pre-0.9.0), the MAC is added by this commit.

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

10 years agoSilently ignore MAC in NetworkLoadConfig
Ján Tomko [Mon, 10 Nov 2014 16:40:07 +0000 (17:40 +0100)]
Silently ignore MAC in NetworkLoadConfig

Libvirt's RPMs have been adding it to networks which don't support it.

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

10 years agolibvirt.c: Move virDomainGetFSInfo to libvirt-domain.c
Michal Privoznik [Tue, 2 Dec 2014 08:29:21 +0000 (09:29 +0100)]
libvirt.c: Move virDomainGetFSInfo to libvirt-domain.c

Since our big split of libvirt.c there are only a few functions
living there. The majority was moved to corresponding subfile,
e.g. domain functions were moved to libvirt-domain.c. However,
the patches for virDomainGetFSInfo() and virDomainFSInfoFree()
introduction were posted prior the big split and merged after.
This resulted in two domain functions landing in wrong file.
Move them to the correct one.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agonwfilter: fix crash when adding non-existing nwfilter
Pavel Hrdina [Mon, 1 Dec 2014 16:23:00 +0000 (17:23 +0100)]
nwfilter: fix crash when adding non-existing nwfilter

Adding non-existing nwfilter to a network interface device without any
nwfilter specified will crash libvirt daemon with segfault. The reason is
that the nwfilter is not found an libvirt will try to restore old
nwfilter configuration but there is no nwfilter specified.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
10 years agoconf: fix a comment typo in virDomainVideoDefaultRAM
Wang Rui [Tue, 2 Dec 2014 03:55:09 +0000 (11:55 +0800)]
conf: fix a comment typo in virDomainVideoDefaultRAM

Signed-off-by: Wang Rui <moon.wangrui@huawei.com>
10 years agoconf: replace call to virNetworkFree() with virObjectUnref()
Laine Stump [Tue, 25 Nov 2014 09:17:51 +0000 (04:17 -0500)]
conf: replace call to virNetworkFree() with virObjectUnref()

The function virNetworkObjListExport() in network_conf.c had a call to
the public API virNetworkFree() which was causing a link error:

CCLD     libvirt_driver_vbox_network_impl.la
 ./.libs/libvirt_conf.a(libvirt_conf_la-network_conf.o): In function `virNetworkObjListExport':
/home/laine/devel/libvirt/src/conf/network_conf.c:4496: undefined reference to `virNetworkFree'

This would happen when I added

  #include "network_conf.h"

into domain_conf.h, then attempted to call a new function from that
file (and enum converter, similar to virNetworkForwardTypeToString())

In the end, virNetworkFree() ends up just calling virObjectUnref(obj)
anyway (after clearing all pending errors, which we probably *don't*
want to do in the cleanup of a utility function), so this is likely
more correct than the original code as well.

10 years agobuild, docs: Let make see the dependencies for html/*.html
Martin Kletzander [Tue, 2 Dec 2014 06:50:18 +0000 (07:50 +0100)]
build, docs: Let make see the dependencies for html/*.html

Make was not able to realize the dependencies for html/*.html files when
running 'make -j9 dist'.  All the files are generated together with
html/index.html, so simply separating them into another variable and
adding one block into the dependency chain solves the issue.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agodocs: Correct invalid hyperlinks
Martin Kletzander [Mon, 1 Dec 2014 13:36:13 +0000 (14:36 +0100)]
docs: Correct invalid hyperlinks

Since libvirt.h was split into multiple files and similarly
docs/libvirt-libvirt.html, docs/hvsupport.html have bad hyperlinks.  The
same happens for all the html.in files that used <code class='docref'>
tag, because page.xsl has no idea where to point the link that's found.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agoFix race condition in qemuGetProcessInfo
Eduardo Costa [Mon, 1 Dec 2014 20:24:20 +0000 (18:24 -0200)]
Fix race condition in qemuGetProcessInfo

There is a race condition between the fopen and fscanf calls
in qemuGetProcessInfo. If fopen succeeds, there is a small
possibility that the file no longer exists before reading from it.
Now, if either fopen or fscanf calls fail, the function will behave
just as only fopen had failed.

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

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agolibxl: Resolve Coverity CHECKED_RETURN
John Ferlan [Mon, 1 Dec 2014 16:10:18 +0000 (11:10 -0500)]
libxl: Resolve Coverity CHECKED_RETURN

Commit id 'cb88d433' refactored the calling sequence to use a thread;
however, in doing so "lost" the check for if virNetSocketAccept returns
failure.  Since other code makes that check, Coverity complains. Although
a false positive, adding back the failure check pacifies Coverity

10 years agodomain_conf: Resolve Coverity CHECKED_RETURN
John Ferlan [Wed, 29 Oct 2014 13:25:56 +0000 (09:25 -0400)]
domain_conf: Resolve Coverity CHECKED_RETURN

Commit id '0d36a5d05' modified the code slightly, but removed the
return value check thus causing Coverity to complain that this call
was the only one where the return value wasn't checked. Since nothing
was done previously if there was a failure, just use ignore_value here
to pacify Coverity

10 years agovirhook: Resolve Coverity NULL_RETURNS
John Ferlan [Tue, 30 Sep 2014 11:01:49 +0000 (07:01 -0400)]
virhook: Resolve Coverity NULL_RETURNS

Coverity complains that many other callers to return err from
virGetLastError() will check if err is not NULL before dereferencing
it.  Just do the same here for safety.

10 years agohotplug: Resolve Coverity FORWARD_NULL
John Ferlan [Tue, 30 Sep 2014 10:55:23 +0000 (06:55 -0400)]
hotplug: Resolve Coverity FORWARD_NULL

Coverity complained that because the cfg->macFilter call checked
net->ifname != NULL before calling ebtablesRemoveForwardAllowIn, then
the virNetDevOpenvswitchRemovePort call should have the same check.

However, if I move the ebtables call prior to the check for TYPE_DIRECT
(where there is a VIR_FREE(net->ifname)), then it seems Coverity is
happy.  Since firewall info is tacked on last during setup, removing
it in the opposite order of initialization seems to be natural anyway

10 years agostorage: Add mixed fc_host/scsi_host duplicate adapter source checks
John Ferlan [Fri, 14 Nov 2014 14:50:59 +0000 (09:50 -0500)]
storage: Add mixed fc_host/scsi_host duplicate adapter source checks

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

The virStoragePoolSourceFindDuplicate only checks the incoming definition
against the same type of pool as the def; however, for "scsi_host" and
"fc_host" adapter pools, it's possible that either some pool "scsi_host"
adapter definition is already using the scsi_hostN that the "fc_host"
adapter definition wants to use or some "fc_host" pool adapter definition
is using a vHBA scsi_hostN or parent scsi_hostN that an incoming "scsi_host"
definition is trying to use.

This patch adds the mismatched type checks and adds extraneous comments
to describe what each check is determining.

This patch also modifies the documentation to be describe what scsi_hostN
devices a "scsi_host" source adapter should use and which to avoid. It also
updates the parent definition to specifically call out that for mixed
environments it's better to define which parent to use so that the duplicate
pool checks can be done properly.

10 years agostorage: Move and rename getVhbaSCSIHostParent
John Ferlan [Mon, 17 Nov 2014 13:40:59 +0000 (08:40 -0500)]
storage: Move and rename getVhbaSCSIHostParent

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

Move the API from the backend to storage_conf and rename it to
virStoragePoolGetVhbaSCSIHostParent.  A future patch will need to
use this functionality from storage_conf

10 years agoconf: Don't redefine virDomainTPMDefPtr
Martin Kletzander [Mon, 1 Dec 2014 12:19:55 +0000 (13:19 +0100)]
conf: Don't redefine virDomainTPMDefPtr

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agoqemu: Make pid available for security managers in qemuProcessAttach
Luyao Huang [Mon, 1 Dec 2014 09:54:35 +0000 (17:54 +0800)]
qemu: Make pid available for security managers in qemuProcessAttach

There are some small issue in qemuProcessAttach:

1.Fix virSecurityManagerGetProcessLabel always get pid = 0,
move 'vm->pid = pid' before call virSecurityManagerGetProcessLabel.

2.Use virSecurityManagerGenLabel to get image label.

3.Fix always set selinux label for other security driver label.

Signed-off-by: Luyao Huang <lhuang@redhat.com>
10 years agoconf: Add device-related code for panic devices
Martin Kletzander [Sun, 30 Nov 2014 19:54:50 +0000 (20:54 +0100)]
conf: Add device-related code for panic devices

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agoconf: Add device-related code for TPM devices
Martin Kletzander [Sun, 30 Nov 2014 19:54:50 +0000 (20:54 +0100)]
conf: Add device-related code for TPM devices

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agoqemu: fix block{commit,copy} abort handling
Erik Skultety [Thu, 27 Nov 2014 12:29:42 +0000 (13:29 +0100)]
qemu: fix block{commit,copy} abort handling

When a block{commit,copy} job was aborted on a domain, block job handler
did not process it correctly, leaving a phantom job in the background.
Any further calls to any blockjob causes "block <jobtype> still active"
error. This patch fixes the blockjob handler so that it checks not only
for VIR_DOMAIN_BLOCK_JOB_FAILED status, but VIR_DOMAIN_BLOCK_JOB_CANCELED
status as well, followed by our existing cleanup routine.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
10 years agoqemu: set jobinfo type to FAILED if job is failed in qemuMigrationRun
Wang Rui [Mon, 1 Dec 2014 07:05:33 +0000 (15:05 +0800)]
qemu: set jobinfo type to FAILED if job is failed in qemuMigrationRun

If job is failed in qemuMigrationRun, we expect the jobinfo type as
FAILED. But jobinfo type won't be updated until entering
qemuMigrationWaitForCompletion. We should make it updated in all
conditions. Moreover, we can't use qemuMigrationUpdateJobStatus
here because job may fail in libvirt, so we can't query job status
from QEMU.

Signed-off-by: Wang Rui <moon.wangrui@huawei.com>
10 years agoqemu: set jobinfo type to CANCELLED if migration is cancelled in all conditions
Wang Rui [Mon, 1 Dec 2014 07:05:32 +0000 (15:05 +0800)]
qemu: set jobinfo type to CANCELLED if migration is cancelled in all conditions

The migration job status is traced in qemuMigrationUpdateJobStatus
which is called in qemuMigrationRun. But if migration is cancelled
before the trace such as in qemuMigrationDriveMirror, the jobinfo
type won't be updated to CANCELLED. After this patch, we can get
jobinfo type CANCELLED if migration is cancelled during drive
mirror.  Moreover, we can't use qemuMigrationUpdateJobStatus
because from qemu's point of view it's just the drive mirror being
cancelled and the migration hasn't even started yet.

Signed-off-by: Wang Rui <moon.wangrui@huawei.com>
10 years agodocs: Fix missing slashes in XML examples
Luyao Huang [Fri, 28 Nov 2014 06:44:24 +0000 (14:44 +0800)]
docs: Fix missing slashes in XML examples

When I pasted some XML from libvirt.org, I've found a small mistake.

Signed-off-by: Luyao Huang <lhuang@redhat.com>
10 years agoqemu: Don't track quiesced state of FSs
Michal Privoznik [Thu, 27 Nov 2014 10:43:56 +0000 (11:43 +0100)]
qemu: Don't track quiesced state of FSs

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

As of b6d4dad11b (1.2.5) we are trying to keep the status of FSFreeze
in the guest. Even though I've tried to fixed couple of corner cases
(6ea54769ba18), it occurred to me just recently, that the approach is
broken by design. Firstly, there are many other ways to talk to
qemu-ga (even through libvirt) that filesystems can be thawed (e.g.
qemu-agent-command) without libvirt noticing. Moreover, there are
plenty of ways to thaw filesystems without even qemu-ga noticing (yes,
qemu-ga keeps internal track of FSFreeze status). So, instead of
keeping the track ourselves, or asking qemu-ga for stale state, it's
the best to let qemu-ga deal with that (and possibly let guest kernel
propagate an error).

Moreover, there's one bug with the following approach, if fsfreeze
command failed, we've executed fsthaw subsequently. So issuing
domfsfreeze in virsh gave the following result:

virsh # domfsfreeze gentoo
Froze 1 filesystem(s)

virsh # domfsfreeze gentoo
error: Unable to freeze filesystems
error: internal error: unable to execute QEMU agent command 'guest-fsfreeze-freeze': The command guest-fsfreeze-freeze has been disabled for this instance

virsh # domfsfreeze gentoo
Froze 1 filesystem(s)

virsh # domfsfreeze gentoo
error: Unable to freeze filesystems
error: internal error: unable to execute QEMU agent command 'guest-fsfreeze-freeze': The command guest-fsfreeze-freeze has been disabled for this instance

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoFix usage of virReportSystemError
Jiri Denemark [Fri, 28 Nov 2014 08:37:42 +0000 (09:37 +0100)]
Fix usage of virReportSystemError

virReportSystemError is reserved for reporting system errors, calling it
with VIR_ERR_* error codes produces error messages that do not make any
sense, such as

    internal error: guest failed to start: Kernel doesn't support user
    namespace: Link has been severed

We should prohibit wrong usage with a syntax-check rule.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
10 years agodocs: fix simple typo in TPM paragraph
Martin Kletzander [Fri, 28 Nov 2014 08:37:09 +0000 (09:37 +0100)]
docs: fix simple typo in TPM paragraph

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agotests: fix documentation for mocking methods
Martin Kletzander [Wed, 26 Nov 2014 10:55:59 +0000 (11:55 +0100)]
tests: fix documentation for mocking methods

It looks like it was copy-pasted, so in case anyone wonders what some of
those methods do without looking at them, and for the sake of
completeness, fix them.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agoRevert "ip link needs 'name' in 3.16 to create the veth pair"
Martin Kletzander [Wed, 26 Nov 2014 08:25:43 +0000 (09:25 +0100)]
Revert "ip link needs 'name' in 3.16 to create the veth pair"

This reverts commit 433b427ff853ab72d32573d415e6ec569b77c7cb.

The patch was added in order to overcome a bug in iproute2 and since it
was properly identified as a bug, particularly in openSUSE 13.2, and it
is being worked on [1], the best solution for libvirt seems to be to
keep the old behaviour.

[1] https://bugzilla.novell.com/show_bug.cgi?id=907093

10 years agonetwork: Fix upgrade from libvirt older than 1.2.4
Jiri Denemark [Wed, 26 Nov 2014 15:24:27 +0000 (16:24 +0100)]
network: Fix upgrade from libvirt older than 1.2.4

Starting from libvirt-1.2.4, network state XML files moved to another
directory (see commit b9e95491) and libvirt automatically migrates the
network state files to a new location. However, the code used
dirent.d_type which is not supported by all filesystems. Thus, when
libvirt was upgraded on a host which used such filesystem, network state
XMLs were not properly moved and running networks disappeared from
libvirt.

This patch falls back to lstat() whenever dirent.d_type is DT_UNKNOWN to
fix this issue.

https://bugzilla.redhat.com/show_bug.cgi?id=1167145
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
10 years agoutil: Avoid calling closedir(NULL)
Jiri Denemark [Mon, 24 Nov 2014 16:37:13 +0000 (17:37 +0100)]
util: Avoid calling closedir(NULL)

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
10 years agovirsh: document block.n.allocation stat
Eric Blake [Mon, 24 Nov 2014 20:58:20 +0000 (13:58 -0700)]
virsh: document block.n.allocation stat

Commit 7557ddf added some additional block.* stats to
virDomainListGetStats, but failed to document them in 'man
virsh'.  Also, I noticed some inconsistent use of commas.

* tools/virsh.pod (domstats): Tweak commas, add missing stats.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agodbus: fix arrays of bools
Eric Blake [Sat, 22 Nov 2014 00:03:34 +0000 (17:03 -0700)]
dbus: fix arrays of bools

Commit 2aa167ca tried to fix the DBus interaction code to allow
callers to use native types instead of 4-byte bools.  But in
fixing the issue, I missed the case of an arrayref; Conrad Meyer
shows the following valid complaint issued by clang:

  CC       util/libvirt_util_la-virdbus.lo
util/virdbus.c:956:13: error: cast from 'bool *' to 'dbus_bool_t *' (aka 'unsigned int *') increases required alignment from 1 to 4 [-Werror,-Wcast-align]
            GET_NEXT_VAL(dbus_bool_t, bool_val, bool, "%d");
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
util/virdbus.c:858:17: note: expanded from macro 'GET_NEXT_VAL'
            x = (dbustype *)(*xptrptr + (*narrayptr - 1));              \
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1 error generated.

But fixing that points out that we have NEVER supported arrayrefs
of sub-int types (byte, i16, u16, and now bool).  Again, while raw
types promote, arrays do not; so the macros HAVE to deal with both
size possibilities rather than assuming that an arrayref uses the
same sizing as the promoted raw type.

Obviously, our testsuite wasn't covering as much as it should have.

* src/util/virdbus.c (GET_NEXT_VAL): Also fix array cases.
(SET_NEXT_VAL): Fix uses of sub-int arrays.
* tests/virdbustest.c (testMessageArray, testMessageArrayRef):
Test it.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agoqemu: add the missing jobinfo type in qemuDomainGetJobInfo
Wang Rui [Tue, 25 Nov 2014 11:51:45 +0000 (19:51 +0800)]
qemu: add the missing jobinfo type in qemuDomainGetJobInfo

Commit 6fcddfcd refactored job statistics but missed the jobinfo type updated
in qemuDomainGetJobInfo. After this patch, we can use virDomainGetJobInfo to
get jobinfo type again.

Signed-off-by: Wang Rui <moon.wangrui@huawei.com>
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
10 years agoResolve build breaker
John Ferlan [Tue, 25 Nov 2014 12:06:46 +0000 (07:06 -0500)]
Resolve build breaker

Commit 'c264eeaa' didn't do the prerequisite 'make syntax-check' before
pushing. There was a <tab> in the whitespace for the comment.  Replaced
with spaces and aligned.

pushed as build breaker since Jenkins complained loudly

10 years agolxc: don't unmount subtree if it contains the source of the mount
Cédric Bosdonnat [Mon, 24 Nov 2014 14:10:19 +0000 (15:10 +0100)]
lxc: don't unmount subtree if it contains the source of the mount

The typical case where we had a problem is with such a filesystem
definition as created by virt-sandbox-service:

    <filesystem type='bind' accessmode='passthrough'>
      <source dir='/var/lib/libvirt/filesystems/mysshd/var'/>
      <target dir='/var'/>
    </filesystem>

In this case, we don't want to unmount the /var subtree or we may
loose the access to the source folder.

10 years agolxc: be more patient while resolving symlinks
Cédric Bosdonnat [Fri, 21 Nov 2014 16:45:55 +0000 (17:45 +0100)]
lxc: be more patient while resolving symlinks

Resolving symlinks can fail before mounting any file system if one file
system depends on another being mounted. Symlinks are now resolved in
two passes:

  * Before any file system is mounted, but then we are more gentle if
    the source path can't be accessed
  * Right before mounting a file system, so that we are sure that we
    have the resolved path... but then if it can't be accessed we raise
    an error.

10 years agoip link needs 'name' in 3.16 to create the veth pair
Cédric Bosdonnat [Thu, 20 Nov 2014 14:26:35 +0000 (15:26 +0100)]
ip link needs 'name' in 3.16 to create the veth pair

Due to a change (or bug?) in ip link implementation, the command
    'ip link add vnet0...'
is forced into
    'ip link add name vnet0...'
The changed command also works on older versions of iproute2, just the
'name' parameter has been made mandatory.

10 years agovirt-aa-helper: /etc/libvirt-sandbox/services isn't restricted
Cédric Bosdonnat [Thu, 20 Nov 2014 10:32:38 +0000 (11:32 +0100)]
virt-aa-helper: /etc/libvirt-sandbox/services isn't restricted

To get virt-sandbox-service working with AppArmor, virt-aa-helper
needs not to choke on path in /etc/libvirt-sandbox/services.

10 years agovirt-aa-helper wasn't running virErrorInitialize
Cédric Bosdonnat [Thu, 20 Nov 2014 10:31:44 +0000 (11:31 +0100)]
virt-aa-helper wasn't running virErrorInitialize

This turns out to be working by magic but needs to be fixed.

10 years agoqemu-command: introduce new vgamem attribute for QXL video device
Pavel Hrdina [Thu, 20 Nov 2014 18:52:00 +0000 (19:52 +0100)]
qemu-command: introduce new vgamem attribute for QXL video device

Add attribute to set vgamem_mb parameter of QXL device for QEMU. This
value sets the size of VGA framebuffer for QXL device. Default value in
QEMU is 8MB so reuse it also in libvirt to not break things.

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

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
10 years agoqemu-command: use vram attribute for all video devices
Pavel Hrdina [Thu, 20 Nov 2014 18:51:12 +0000 (19:51 +0100)]
qemu-command: use vram attribute for all video devices

So far we didn't have any option to set video memory size for qemu video
devices. There was only the vram (ram for QXL) attribute but it was valid
only for the QXL video device.

To provide this feature to users QEMU has a dedicated device attribute
called 'vgamem_mb' to set the video memory size. We will use the 'vram'
attribute for setting video memory size for other QEMU video devices.

For the cirrus device we will ignore the vram value because it has
hardcoded video size in QEMU.

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

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
10 years agocaps: introduce new QEMU capability for vgamem_mb device property
Pavel Hrdina [Wed, 12 Nov 2014 12:58:33 +0000 (13:58 +0100)]
caps: introduce new QEMU capability for vgamem_mb device property

Allow setting vgamem size for video devices.

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

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
10 years agoQXL: fix setting ram and vram values for QEMU QXL device
Pavel Hrdina [Tue, 18 Nov 2014 16:21:48 +0000 (17:21 +0100)]
QXL: fix setting ram and vram values for QEMU QXL device

QEMU has two different type of QXL display device. The first "qxl-vga"
is for primary video device and second "qxl" is for secondary video
device.

There are also two different ways how to specify those devices on qemu
command line, the first one and obsolete is using "-vga" option and the
current new one is using "-device" option. The "-vga" could be used only
to setup primary video device, so the "-vga qxl" equal to
"-device qxl-vga". Unfortunately the "-vga qxl" doesn't support setting
additional parameters for the device and "-global" option must be used
for this purpose. It's mandatory to use "-global qxl-vga...." to set the
parameters of primary video device previously defined with "-vga qxl".

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

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>