]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
7 years agodocs: drop XHTML 1.0 validation of website
Daniel P. Berrange [Wed, 26 Jul 2017 16:13:40 +0000 (17:13 +0100)]
docs: drop XHTML 1.0 validation of website

The HTML pages are currently validated against an XHTML 1.0 DTD.
This makes it impossible to take advantage of features that are
introduced in HTML 5, because they'll fail validation.

There is intentionally no DTD defined for HTML 5, so there's no
alternative to XHTML 1.0 DTD that we could switch to. The only
options are to stick with XHTML 1.0 forever, or drop the DTD
validation, and we pick the latter.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
7 years agodocs: switch to using 'id' attribute instead of 'name' for links
Daniel P. Berrange [Wed, 26 Jul 2017 14:52:42 +0000 (15:52 +0100)]
docs: switch to using 'id' attribute instead of 'name' for links

The 'name' attribute on <a...> elements is deprecated in favour
of the 'id' attribute which is allowed on any element. HTML5
drops 'name' support entirely.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
7 years agoTurn virDomainDeviceInfoFormat into void
Ján Tomko [Wed, 28 Jun 2017 15:10:59 +0000 (17:10 +0200)]
Turn virDomainDeviceInfoFormat into void

The rombar attribute was already validated at the time of parsing
the XML.

7 years agoconf: check for buffer errors before virBufferUse
Ján Tomko [Tue, 27 Jun 2017 14:33:22 +0000 (16:33 +0200)]
conf: check for buffer errors before virBufferUse

After an OOM error, virBuffer* APIs set buf->use to zero.
Adding a buffer to the parent buffer only if use is non-zero
would quietly drop data on error.

Check the error beforehand to make sure buf->use is zero
because we have not attempted to add anything to it.

7 years agoUse a separate buffer for <hub> subelements
Ján Tomko [Tue, 27 Jun 2017 14:36:24 +0000 (16:36 +0200)]
Use a separate buffer for <hub> subelements

Switch virDomainHubDefFormat to use a separate buffer for subelements.

7 years agoUse a separate buffer for <watchdog> subelements
Ján Tomko [Tue, 27 Jun 2017 14:28:06 +0000 (16:28 +0200)]
Use a separate buffer for <watchdog> subelements

Convert virDomainWatchdogDefFormat to use a separate
buffer for subelements.

7 years agoUse a separate buffer for <sound> subelements
Ján Tomko [Tue, 27 Jun 2017 14:27:18 +0000 (16:27 +0200)]
Use a separate buffer for <sound> subelements

Convert virDomainSoundDefFormat to use a separate buffer
for subelements.

7 years agoUse a separate buffer for <smartcard> subelements
Ján Tomko [Tue, 27 Jun 2017 14:24:11 +0000 (16:24 +0200)]
Use a separate buffer for <smartcard> subelements

Convert virDomainSmartcardDefFormat to use a separate buffer
for possible subelements, to avoid the need for duplicated
formatting logic in virDomainDeviceInfoNeedsFormat.

7 years agovirDomainDeviceInfoFormat: delete outdated comments
Ján Tomko [Tue, 27 Jun 2017 12:14:32 +0000 (14:14 +0200)]
virDomainDeviceInfoFormat: delete outdated comments

This function has grown to format more than just the address.
Delete the comment completely to avoid failing to update it
in the future.

Also, the indentation is now handled by the virBuffer APIs,
so the comment about indentation no longer makes sense.

7 years agoRemove superfluous usage of virDomainDeviceInfoNeedsFormat
Ján Tomko [Tue, 27 Jun 2017 12:04:52 +0000 (14:04 +0200)]
Remove superfluous usage of virDomainDeviceInfoNeedsFormat

This function returns false if virDomainDeviceInfoFormat
would not format anything.

Using it as the sole condition to decide whether to call
virDomainDeviceInfoFormat or not is pointless, since
the conditions are repeated in virDomainDeviceInfoFormat.

7 years agovirCapabilitiesFormatCaches: free cpus_str right after use
Ján Tomko [Wed, 2 Aug 2017 13:38:40 +0000 (15:38 +0200)]
virCapabilitiesFormatCaches: free cpus_str right after use

This will simplify the cleanup when we start checking for
buffer errors.

7 years agoAdd support for virtio-net.tx_queue_size
Michal Privoznik [Wed, 12 Jul 2017 12:19:26 +0000 (14:19 +0200)]
Add support for virtio-net.tx_queue_size

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

Just like I've added support for setting rx_queue_size (in
c56cdf259 and friends), qemu just gained support for setting tx
ring size.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
7 years agodriver: conditionalize use of dlopen functions & use mingw-dlfcn
Daniel P. Berrange [Wed, 2 Aug 2017 10:21:12 +0000 (11:21 +0100)]
driver: conditionalize use of dlopen functions & use mingw-dlfcn

Not every platform is guaranteed to have dlopen/dlsym, so we should
conditionalize its use. Suprisingly it is actually present for Win32
via the mingw-dlfcn add on, but we should still conditionalize it.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
7 years agotools: rename 'socket' to 'sockpath'
Daniel P. Berrange [Wed, 2 Aug 2017 10:51:08 +0000 (11:51 +0100)]
tools: rename 'socket' to 'sockpath'

A variable named 'socket' clashes with the function of the same
name, causing build failures due to warnings on some platforms.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
7 years agovirnetworkobj: Make virNetworkObjFindBy{UUID,Name}Locked() static again
Michal Privoznik [Tue, 25 Jul 2017 15:04:11 +0000 (17:04 +0200)]
virnetworkobj: Make virNetworkObjFindBy{UUID,Name}Locked() static again

These functions were made exportable back in 3aa3e072 when I was
splitting network code into parsing and list management parts.
Since then the split is finished now and these two functions do
not need to be exported anymore.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
7 years agovirConnect: Update comment for @privateData
Michal Privoznik [Thu, 27 Jul 2017 06:43:40 +0000 (08:43 +0200)]
virConnect: Update comment for @privateData

This member allows us to store a pointer to some private data.
However, the comment says it's used in both domain driver and
network driver. Well, it is not. It's just one pointer and domain
driver uses it directly. Network driver has a global driver
variable. Update the comment to not confuse others.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
7 years agotools: virsh: Adding unix socket support to 'domdisplay' command.
Julio Faracco [Fri, 28 Jul 2017 21:49:35 +0000 (18:49 -0300)]
tools: virsh: Adding unix socket support to 'domdisplay' command.

This commit adds the unix socket URL support to 'domdisplay' command.
Before, even if an user was using unix socket to define a spice graphics,
the command 'domdisplay' showed that the settings were not supported. Now,
the command shows the proper URL: spice+unix://foo/bar.sock.

Settings:
<graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1'>
  <listen type='address' address='127.0.0.1'/>
</graphics>
<graphics type='spice'>
  <listen type='socket' socket='/tmp/spice.sock'/>
</graphics>

Before:
virsh # domdisplay --all Windows7
vnc://127.0.0.1:0

After:
virsh # domdisplay --all Windows7
vnc://127.0.0.1:0
spice+unix:///tmp/spice.sock

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

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
7 years agoUpdate news.xml after the post-release
Michal Privoznik [Mon, 31 Jul 2017 08:50:58 +0000 (10:50 +0200)]
Update news.xml after the post-release

In 19581afd778 the configure.ac was updated. However, the
news.xml was missing adjustment - creating the new section for
the release.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
7 years agoqemu: Split shmem preparation as it's supposed to be
Martin Kletzander [Fri, 21 Jul 2017 11:47:05 +0000 (13:47 +0200)]
qemu: Split shmem preparation as it's supposed to be

Since the introduction of shmem, there was a split of preparation code
from the formatting code from qemuBuildCommandLine() into
qemuProcessPrepareDomain().  Let's fix shmem in this regard, so that
we can slowly get to a cleaner codebase.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
7 years agoPost-release version bump to 3.7.0
Martin Kletzander [Wed, 2 Aug 2017 07:27:08 +0000 (09:27 +0200)]
Post-release version bump to 3.7.0

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
7 years agoRelease of libvirt-3.6.0
Daniel Veillard [Wed, 2 Aug 2017 02:00:22 +0000 (10:00 +0800)]
Release of libvirt-3.6.0

* docs/news.xml: updated for the release
* po/*.po*: regenerated

7 years agovirNetDaemonCallInhibit: Call virNetDaemonGotInhibitReply properly
Michal Privoznik [Tue, 1 Aug 2017 09:04:22 +0000 (11:04 +0200)]
virNetDaemonCallInhibit: Call virNetDaemonGotInhibitReply properly

So there are couple of issues here. Firstly, we never unref the
@pendingReply and thus it leaks.

==13279== 144 (72 direct, 72 indirect) bytes in 1 blocks are definitely lost in loss record 1,095 of 1,259
==13279==    at 0x4C2E080: calloc (vg_replace_malloc.c:711)
==13279==    by 0x781FA97: _dbus_pending_call_new_unlocked (in /usr/lib64/libdbus-1.so.3.14.11)
==13279==    by 0x7812A4C: dbus_connection_send_with_reply (in /usr/lib64/libdbus-1.so.3.14.11)
==13279==    by 0x56BEDF3: virNetDaemonCallInhibit (virnetdaemon.c:514)
==13279==    by 0x56BEF18: virNetDaemonAddShutdownInhibition (virnetdaemon.c:536)
==13279==    by 0x12473B: daemonInhibitCallback (libvirtd.c:742)
==13279==    by 0x1249BD: daemonRunStateInit (libvirtd.c:823)
==13279==    by 0x554FBCF: virThreadHelper (virthread.c:206)
==13279==    by 0x8F913D3: start_thread (in /lib64/libpthread-2.23.so)
==13279==    by 0x928DE3C: clone (in /lib64/libc-2.23.so)

Secondly, while we send the message, we are suspended ('cos we're
talking to a UNIX socket).  However, until we are resumed back
again the reply might have came therefore subsequent
dbus_pending_call_set_notify() has no effect and in fact the
virNetDaemonGotInhibitReply() callback is never called. Thirdly,
the dbus_connection_send_with_reply() has really stupid policy
for return values. To cite the man page:

  Returns
      FALSE if no memory, TRUE otherwise.

Yes, that's right. If anything goes wrong and it's not case of
OOM then TRUE is returned, i.e. you're trying to pass FDs and
it's not supported, or you're not connected, or anything else.
Therefore, checking for return value of
dbus_connection_send_with_reply() is not enoguh. We also have to
check if @pendingReply is not NULL before proceeding any further.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
7 years agovirCgroupValidateMachineGroup: Don't free @machinename
Michal Privoznik [Tue, 1 Aug 2017 07:08:31 +0000 (09:08 +0200)]
virCgroupValidateMachineGroup: Don't free @machinename

We are given a string in @machinename, we never allocate it, just
merely use it for reading. We should not free it otherwise it
leads to double free:

==32191== Thread 17:
==32191== Invalid free() / delete / delete[] / realloc()
==32191==    at 0x4C2D1A0: free (vg_replace_malloc.c:530)
==32191==    by 0x54BBB84: virFree (viralloc.c:582)
==32191==    by 0x2BC04499: qemuProcessStop (qemu_process.c:6313)
==32191==    by 0x2BC500FF: processMonitorEOFEvent (qemu_driver.c:4724)
==32191==    by 0x2BC502FC: qemuProcessEventHandler (qemu_driver.c:4769)
==32191==    by 0x5550640: virThreadPoolWorker (virthreadpool.c:167)
==32191==    by 0x554FBCF: virThreadHelper (virthread.c:206)
==32191==    by 0x8F913D3: start_thread (in /lib64/libpthread-2.23.so)
==32191==    by 0x928DE3C: clone (in /lib64/libc-2.23.so)
==32191==  Address 0x31893d70 is 0 bytes inside a block of size 1,100 free'd
==32191==    at 0x4C2D1A0: free (vg_replace_malloc.c:530)
==32191==    by 0x54BBB84: virFree (viralloc.c:582)
==32191==    by 0x54C1936: virCgroupValidateMachineGroup (vircgroup.c:343)
==32191==    by 0x54C4B29: virCgroupNewDetectMachine (vircgroup.c:1550)
==32191==    by 0x2BBDDA29: qemuConnectCgroup (qemu_cgroup.c:972)
==32191==    by 0x2BC05DA7: qemuProcessReconnect (qemu_process.c:6822)
==32191==    by 0x554FBCF: virThreadHelper (virthread.c:206)
==32191==    by 0x8F913D3: start_thread (in /lib64/libpthread-2.23.so)
==32191==    by 0x928DE3C: clone (in /lib64/libc-2.23.so)
==32191==  Block was alloc'd at
==32191==    at 0x4C2BE80: malloc (vg_replace_malloc.c:298)
==32191==    by 0x4C2E35F: realloc (vg_replace_malloc.c:785)
==32191==    by 0x54BB492: virReallocN (viralloc.c:245)
==32191==    by 0x54BEDF2: virBufferGrow (virbuffer.c:150)
==32191==    by 0x54BF3B9: virBufferVasprintf (virbuffer.c:408)
==32191==    by 0x54BF324: virBufferAsprintf (virbuffer.c:381)
==32191==    by 0x55BB271: virDomainGenerateMachineName (domain_conf.c:27078)
==32191==    by 0x2BBD5B8F: qemuDomainGetMachineName (qemu_domain.c:9595)
==32191==    by 0x2BBDD9B4: qemuConnectCgroup (qemu_cgroup.c:966)
==32191==    by 0x2BC05DA7: qemuProcessReconnect (qemu_process.c:6822)
==32191==    by 0x554FBCF: virThreadHelper (virthread.c:206)
==32191==    by 0x8F913D3: start_thread (in /lib64/libpthread-2.23.so)

Moreover, make the @machinename 'const char *' to mark it
explicitly that we are not changing the passed string.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
7 years agonews: Fix typo
Andrea Bolognani [Tue, 1 Aug 2017 06:29:19 +0000 (08:29 +0200)]
news: Fix typo

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
7 years agonews: Update for 3.6.0 release
Michal Privoznik [Fri, 28 Jul 2017 14:10:51 +0000 (16:10 +0200)]
news: Update for 3.6.0 release

I was volunteered to prepare the release notes.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
7 years agotests: qemumonitorjson: Old and empty test case for node name detection
Peter Krempa [Wed, 26 Jul 2017 09:06:51 +0000 (11:06 +0200)]
tests: qemumonitorjson: Old and empty test case for node name detection

Prior to qemu 2.5 the node names would not be generated, thus would be
missing from 'query-blockstats' and 'query-named-block-nodes'. Test that
the code correctly detects nothing.

Additionally make sure that a VM without disks does not cause problems.

The test case change is necessary as our test file checker does not play
well with empty files.

7 years agotests: utils: Allow NULL strings to be equal to empty file in virTestCompareToFile
Peter Krempa [Fri, 28 Jul 2017 10:37:48 +0000 (12:37 +0200)]
tests: utils: Allow NULL strings to be equal to empty file in virTestCompareToFile

Treat an NULL string equivalent to an empty string in
virTestCompareToFile so that callers don't need to add additional logic
in case when a test produces no output.

7 years agotests: Run virdrivermoduletest only when WITH_LIBVIRTD is defined
Peter Krempa [Fri, 28 Jul 2017 09:54:37 +0000 (11:54 +0200)]
tests: Run virdrivermoduletest only when WITH_LIBVIRTD is defined

The test makes sense only when building the daemon, thus run it only in
such case.

7 years agotests: Run virt-aa-helper-test only when the helper was compiled
Peter Krempa [Fri, 28 Jul 2017 09:49:38 +0000 (11:49 +0200)]
tests: Run virt-aa-helper-test only when the helper was compiled

'virt-aa-helper' is compiled when both WITH_LIBVIRTD and
WITH_SECDRIVER_APPARMOR are defined. The test was run only when
WITH_SECDRIVER_APPARMOR was defined thus causing a build failure when
building without the daemon.

7 years agodocs: Format comment timestamp in UTC
Martin Kletzander [Fri, 28 Jul 2017 08:45:26 +0000 (10:45 +0200)]
docs: Format comment timestamp in UTC

I just forgot '-u' in a54c9622860a.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
7 years agonodedev: Fix double unlock of the driver on udevEnumerateDevices failure
Erik Skultety [Wed, 26 Jul 2017 08:45:11 +0000 (10:45 +0200)]
nodedev: Fix double unlock of the driver on udevEnumerateDevices failure

Commit @4cb719b2dc moved the driver locks around since these have become
unnecessary at spots where the code handles now self-lockable object
list, but missed the possible double unlock if udevEnumerateDevices
fails, because at that point the driver lock had been already dropped.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
7 years agoRevert "build: distribute tests/virfilecachedata"
Pavel Hrdina [Thu, 27 Jul 2017 10:08:13 +0000 (12:08 +0200)]
Revert "build: distribute tests/virfilecachedata"

This reverts commit d3d422e00c995d50c4b78066367bfbc4f872f586.

Already fixed by commit 5a30b817ec93543c7a6cc93b5a6091a6666e377e.

7 years agobuild: distribute tests/virfilecachedata
Pavel Hrdina [Thu, 27 Jul 2017 09:55:40 +0000 (11:55 +0200)]
build: distribute tests/virfilecachedata

Missed by 478f0c5b8575.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
7 years agosecurity: apparmor: load the storage driver dynamically
Peter Krempa [Wed, 26 Jul 2017 19:57:23 +0000 (21:57 +0200)]
security: apparmor: load the storage driver dynamically

In commit 5e515b542d I've attempted to fix the inability to access
storage from the apparmor helper program by linking with the storage
driver. By linking with the .so the linker complains that it's not
portable. Fix this by loading the module dynamically as we are supposed
to do.

Reviewed-by: Daniel P. Berrange <berrange@redhat.com>
7 years agomake: Drop building without driver modules
Peter Krempa [Wed, 26 Jul 2017 19:31:47 +0000 (21:31 +0200)]
make: Drop building without driver modules

Driver modules proved to be reliable for a long time. Since support for
not building modules complicates the code and makefiles drop it.

Reviewed-by: Daniel P. Berrange <berrange@redhat.com>
7 years agotests: add virfilecachedata to EXTRA_DIST
Daniel P. Berrange [Thu, 27 Jul 2017 09:56:20 +0000 (10:56 +0100)]
tests: add virfilecachedata to EXTRA_DIST

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
7 years agotests: add test case for new syntax of VNC unix path with '='
Pavel Hrdina [Fri, 21 Jul 2017 17:55:35 +0000 (19:55 +0200)]
tests: add test case for new syntax of VNC unix path with '='

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
7 years agoqemu: properly handle '=' in the VNC socket path
Pavel Hrdina [Fri, 21 Jul 2017 17:54:33 +0000 (19:54 +0200)]
qemu: properly handle '=' in the VNC socket path

If a domain name contains a '=' and the unix socket path is
auto-generated or socket path provided by user contains '=' QEMU
is unable to properly parse the command line.  In order to make it
work we need to use the new command line syntax for VNC if it's
available, otherwise we can use the old syntax.

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

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
7 years agoqemu: capabilities: introduce QEMU_CAPS_VNC_MULTI_SERVERS
Pavel Hrdina [Fri, 21 Jul 2017 16:44:14 +0000 (18:44 +0200)]
qemu: capabilities: introduce QEMU_CAPS_VNC_MULTI_SERVERS

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
7 years agotests: qemumonitorjson: Test extraction of iSCSI device node names
Peter Krempa [Wed, 3 May 2017 06:45:00 +0000 (08:45 +0200)]
tests: qemumonitorjson: Test extraction of iSCSI device node names

Test storage was created on a rhel/centos 7 node using targetcli.

Reviewed-by: Eric Blake <eblake@redhat.com>
7 years agotests: qemumonitorjson: Test extraction of LUKS node names
Peter Krempa [Thu, 27 Jul 2017 08:26:41 +0000 (10:26 +0200)]
tests: qemumonitorjson: Test extraction of LUKS node names

Test file created by:

qemu-img create -f luks /var/lib/libvirt/images/luks 10M \
        -o key-secret=asdf --object secret,id=asdf,format=raw,data=asdf

Used in libvirt as:
 <disk type='file' device='disk'>
   <driver name='qemu' type='raw'/>
   <source file='/var/lib/libvirt/images/luks'/>
   <target dev='vda' bus='virtio'/>
   <encryption format='luks'>
     <secret type='passphrase' uuid='9b2c831a-fdb9-4c09-873c-1959580589e1'/>
   </encryption>
 </disk>

Reviewed-by: Eric Blake <eblake@redhat.com>
7 years agotests: qemumonitorjson: Add test case for node name detection with blockjob
Peter Krempa [Wed, 26 Jul 2017 09:06:51 +0000 (11:06 +0200)]
tests: qemumonitorjson: Add test case for node name detection with blockjob

qemu 2.9 returns an extra layer in the backing data if a block job is
active. Add a test case to see whether our code properly detects and
ignores such layer.

The test data was prepared by creating a backing chain of qcow2 images
(with qemu-img and with libvirt's snapshot feature).

One of the layers was then merged back by doing a block-commit:

virsh blockcommit VM hda --top /var/lib/libvirt/images/b

and then a block-copy job was started and kept in synchronized phase:

virsh blockcopy VM hda /tmp/tgt.img --transient job

Reviewed-by: Eric Blake <eblake@redhat.com>
7 years agotests: qemumonitorjson: Fix 'gluster' node name detection test case
Peter Krempa [Wed, 26 Jul 2017 08:30:18 +0000 (10:30 +0200)]
tests: qemumonitorjson: Fix 'gluster' node name detection test case

Add the blockstats data and fix the expected output.

Reviewed-by: Eric Blake <eblake@redhat.com>
7 years agotests: qemumonitorjson: Fix 'relative' node name detection test case
Peter Krempa [Wed, 26 Jul 2017 08:30:18 +0000 (10:30 +0200)]
tests: qemumonitorjson: Fix 'relative' node name detection test case

Add the blockstats data and fix the expected output.

Test data was created as:

qemu-img create -f qcow2 img0 10M
qemu-img create -f qcow2 -o "backing_fmt=qcow2,backing_file=img0" img1
qemu-img create -f qcow2 -o "backing_fmt=qcow2,backing_file=img1" img2
...

Reviewed-by: Eric Blake <eblake@redhat.com>
7 years agotests: qemumonitorjson: Add data and fix 'same-backing' node detection case
Peter Krempa [Wed, 26 Jul 2017 08:27:57 +0000 (10:27 +0200)]
tests: qemumonitorjson: Add data and fix 'same-backing' node detection case

With the new approach we are actually able to correctly detect node
names for the two instances of the same backing file.

Test images were created as:
qemu-img create -f qcow2 /var/lib/libvirt/images/base.qcow2 10M
qemu-img create -f qcow2 \
   -o "backing_fmt=qcow2,backing_file=/var/lib/libvirt/images/base.qcow2 \
   /var/lib/libvirt/images/a.qcow2
qemu-img create -f qcow2 \
   -o "backing_fmt=qcow2,backing_file=/var/lib/libvirt/images/base.qcow2 \
   /var/lib/libvirt/images/b.qcow2

and then used for two separate disks.

Reviewed-by: Eric Blake <eblake@redhat.com>
7 years agoqemu: block: store and test driver names for detected storage nodes
Peter Krempa [Tue, 25 Jul 2017 17:10:27 +0000 (19:10 +0200)]
qemu: block: store and test driver names for detected storage nodes

Store the 'drv' field both for the storage node and for the format node
and format them in the test case.

Reviewed-by: Eric Blake <eblake@redhat.com>
7 years agotests: qemumonitorjson: Simplify node name detection test
Peter Krempa [Wed, 26 Jul 2017 07:42:11 +0000 (09:42 +0200)]
tests: qemumonitorjson: Simplify node name detection test

We can now iterate the hash table and print all detected backing chains.
This simplifies calling of the test cases.

Reviewed-by: Eric Blake <eblake@redhat.com>
7 years agotests: Extract mock library for making hash table deterministic
Peter Krempa [Wed, 26 Jul 2017 08:02:21 +0000 (10:02 +0200)]
tests: Extract mock library for making hash table deterministic

virHashNew calls virRandomBits to initialize seed for the hashing
function. If a test uses iteration through the hash table to produce
results they may/will be non-deterministic. Extract the mock library
which was used for mac address mapping to be universal.

Reviewed-by: Eric Blake <eblake@redhat.com>
7 years agoqemu: block: Refactor node name detection code
Peter Krempa [Wed, 26 Jul 2017 07:36:21 +0000 (09:36 +0200)]
qemu: block: Refactor node name detection code

Remove the complex and unreliable code which inferred the node name
hierarchy only from data returned by 'query-named-block-nodes'. It turns
out that query-blockstats contain the full hierarchy of nodes as
perceived by qemu so the inference code is not necessary.

In query blockstats, the 'parent' object corresponds to the storage
behind a storage volume and 'backing' corresponds to the lower level of
backing chain. Since all have node names this data can be really easily
used to detect node names.

In addition to the code refactoring the one remaining test case needed
to be fixed along.

Reviewed-by: Eric Blake <eblake@redhat.com>
7 years agoutil: storagefile: rename 'nodebacking' to 'nodestorage' in virStorageSource
Peter Krempa [Tue, 25 Jul 2017 16:11:58 +0000 (18:11 +0200)]
util: storagefile: rename 'nodebacking' to 'nodestorage' in virStorageSource

Make it less confusing by naming the field which refers to the storage
object as 'nodestorage'.

Reviewed-by: Eric Blake <eblake@redhat.com>
7 years agoqemu: block: Rename qemuBlockFillNodeData and move it to the top
Peter Krempa [Tue, 25 Jul 2017 15:32:38 +0000 (17:32 +0200)]
qemu: block: Rename qemuBlockFillNodeData and move it to the top

The same operation will become useful in other places so rename the
function to be more generic and move it to the top so that it can be
reused earlier in the file.

Reviewed-by: Eric Blake <eblake@redhat.com>
7 years agotests: qemumontitorjson: temporarily disable node name detection tests
Peter Krempa [Wed, 26 Jul 2017 07:33:32 +0000 (09:33 +0200)]
tests: qemumontitorjson: temporarily disable node name detection tests

To simplify the refactoring patches disable the tests. This will allow
adding test data later.

Reviewed-by: Eric Blake <eblake@redhat.com>
7 years agotests: qemumonitorjson: simplify path handling in testBlockNodeNameDetect
Peter Krempa [Tue, 25 Jul 2017 13:49:00 +0000 (15:49 +0200)]
tests: qemumonitorjson: simplify path handling in testBlockNodeNameDetect

Extract the test prefix path into a variable and reuse
virTestLoadFileJSON to load the sample json files rather than doing it
manually.

Reviewed-by: Eric Blake <eblake@redhat.com>
7 years agotests: utils: Add virTestLoadFileJSON helper
Peter Krempa [Tue, 25 Jul 2017 16:40:50 +0000 (18:40 +0200)]
tests: utils: Add virTestLoadFileJSON helper

This new helper loads, parses and returns a JSON file from 'abs_srcdir'
By using variable arguments for the function, it's not necessary to
format the path separately in the test cases.

Reviewed-by: Eric Blake <eblake@redhat.com>
7 years agotests: qemuhelp: convert to virTestLoadFilePath
Peter Krempa [Tue, 25 Jul 2017 13:13:33 +0000 (15:13 +0200)]
tests: qemuhelp: convert to virTestLoadFilePath

As a sample usage of the new helper convert the calls in qemuhelptest to
the new helper.

Reviewed-by: Eric Blake <eblake@redhat.com>
7 years agotests: utils: Add virTestLoadFilePath helper
Peter Krempa [Tue, 25 Jul 2017 13:11:31 +0000 (15:11 +0200)]
tests: utils: Add virTestLoadFilePath helper

This new helper loads and returns a file from 'abs_srcdir'. By using
variable arguments for the function, it's not necessary to format the
path separately in the test cases.

Reviewed-by: Eric Blake <eblake@redhat.com>
7 years agoutil: buffer: Add virBufferStrcatVArgs
Peter Krempa [Mon, 24 Jul 2017 16:54:15 +0000 (18:54 +0200)]
util: buffer: Add virBufferStrcatVArgs

Split out the worker loop into a separate function and export it.

Reviewed-by: Eric Blake <eblake@redhat.com>
7 years agotests: utils: Don't calculate file size in virTestLoadFile
Peter Krempa [Tue, 25 Jul 2017 12:28:48 +0000 (14:28 +0200)]
tests: utils: Don't calculate file size in virTestLoadFile

The callers don't use it so don't waste a strlen(). Also fix the comment
for the function.

Reviewed-by: Eric Blake <eblake@redhat.com>
7 years agotests: qemumonitorjson: Drop redundant data from testBlockNodeNameDetectFormat
Peter Krempa [Wed, 26 Jul 2017 07:32:10 +0000 (09:32 +0200)]
tests: qemumonitorjson: Drop redundant data from testBlockNodeNameDetectFormat

The node name and backing file name can be inferred from the hierarchy.
This will also help when converting to detect node names using
query-blockstats data.

Reviewed-by: Eric Blake <eblake@redhat.com>
7 years agotests: qemumonitor: Prepare for more test data in testBlockNodeNameDetect
Peter Krempa [Wed, 26 Jul 2017 07:30:18 +0000 (09:30 +0200)]
tests: qemumonitor: Prepare for more test data in testBlockNodeNameDetect

Rename 'json' and related variables to 'nodeNameJson'. Also rename the
test files along. This is a preparation for modifying how we detect node
names which will also require data from 'query-blockstats'.

Reviewed-by: Eric Blake <eblake@redhat.com>
7 years agotests: qemumonitorjson: Consolidate basic node name detection test cases
Peter Krempa [Wed, 26 Jul 2017 07:26:56 +0000 (09:26 +0200)]
tests: qemumonitorjson: Consolidate basic node name detection test cases

Test cases named '1' and '2' differed only in the length of the backing
chain, so remove test case '2' and rename test '1' to 'basic'.

Reviewed-by: Eric Blake <eblake@redhat.com>
7 years agoqemu: monitor: Extract call of 'query-blockstats' and add new API for it
Peter Krempa [Mon, 24 Jul 2017 10:51:10 +0000 (12:51 +0200)]
qemu: monitor: Extract call of 'query-blockstats' and add new API for it

Allow getting the raw data from query-blockstats, so that we can use it
to detect the backing chain later on.

Reviewed-by: Eric Blake <eblake@redhat.com>
7 years agostorage: Disallow usage of the HBA for a fc_host backing
John Ferlan [Thu, 20 Jul 2017 18:52:15 +0000 (14:52 -0400)]
storage: Disallow usage of the HBA for a fc_host backing

Disallow providing the wwnn/wwpn of the HBA in the adapter XML:

  <adapter type='fc_host' [parent='scsi_hostN'] wwnn='HBA_wwnn'
    wwpn='HBA_wwpn'/>

This should be considered a configuration error since a vHBA
would not be created. In order to use the HBA as the backing the
following XML should be used:

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

So add a check prior to the checkParent call to validate that
the provided wwnn/wwpn resolves to a vHBA and not an HBA.

Signed-off-by: John Ferlan <jferlan@redhat.com>
7 years agoqemu_cgroup: Remove unnecessary virQEMUDriverPtr arguments
Martin Kletzander [Tue, 25 Jul 2017 15:49:43 +0000 (17:49 +0200)]
qemu_cgroup: Remove unnecessary virQEMUDriverPtr arguments

Since commit 2e6ecba1bcac, the pointer to the qemu driver is saved in
domain object's private data and hence does not have to be passed as
yet another parameter if domain object is already one of them.

This is a first (example) patch of this kind of clean up, others will
hopefully follow.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
7 years agodocs: Add build timestamps to generated html/php pages
Martin Kletzander [Wed, 26 Jul 2017 15:04:37 +0000 (17:04 +0200)]
docs: Add build timestamps to generated html/php pages

In order not to make the build even less reproducible, honour
SOURCE_DATE_EPOCH environment variable as specified:

  https://reproducible-builds.org/specs/source-date-epoch/

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
7 years agobuild: Distribute tests/{qemucpumock.c,testutilshostcpus.h}
Martin Kletzander [Wed, 26 Jul 2017 15:34:03 +0000 (17:34 +0200)]
build: Distribute tests/{qemucpumock.c,testutilshostcpus.h}

Missed by 13554a9e7f4e.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
7 years agotests: Prepare for stricter NIC model validation
Andrea Bolognani [Tue, 25 Jul 2017 14:46:14 +0000 (16:46 +0200)]
tests: Prepare for stricter NIC model validation

While using "definitely-not-virtio" as a model name is very
cute, it will also cause the relevant test to fail once we
introduce stricter validation.

Use "e1000", which is definitely not virtio but also a valid
model name, instead.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
7 years agodocs: Fix typo in memory backing section
Nitesh Konkar [Wed, 26 Jul 2017 09:54:25 +0000 (15:24 +0530)]
docs: Fix typo in memory backing section

Signed-off-by: Nitesh Konkar <nitkon12@linux.vnet.ibm.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
7 years agotest: Use consistent variable names for network test driver APIs
John Ferlan [Fri, 12 May 2017 11:57:12 +0000 (07:57 -0400)]
test: Use consistent variable names for network test driver APIs

A virNetworkObjPtr will be an 'obj'.

A virNetworkPtr will be a 'net'.

Signed-off-by: John Ferlan <jferlan@redhat.com>
7 years agoqemu: privatize _virQEMUCapsCachePriv struct
Pavel Hrdina [Wed, 19 Jul 2017 15:02:40 +0000 (17:02 +0200)]
qemu: privatize _virQEMUCapsCachePriv struct

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
7 years agoqemu: switch QEMU capabilities to use virFileCache
Pavel Hrdina [Wed, 19 Jul 2017 15:01:56 +0000 (17:01 +0200)]
qemu: switch QEMU capabilities to use virFileCache

The switch contains considerable amount of changes:

  virQEMUCapsRememberCached() is removed because this is now handled
  by virFileCacheSave().

  virQEMUCapsInitCached() is removed because this is now handled by
  virFileCacheLoad().

  virQEMUCapsNewForBinary() is split into two functions,
  virQEMUCapsNewData() which creates new data if there is nothing
  cached and virQEMUCapsLoadFile() which loads the cached data.
  This is now handled by virFileCacheNewData().

  virQEMUCapsCacheValidate() is removed because this is now handled by
  virFileCacheValidate().

  virQEMUCapsCacheFree() is removed because it's no longer required.

  Add virCapsPtr into virQEMUCapsCachePriv because for each call of
  virFileCacheLookup*() we need to use current virCapsPtr.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
7 years agoqemu: pass only host arch instead of the whole virCaps
Pavel Hrdina [Fri, 21 Jul 2017 13:09:54 +0000 (15:09 +0200)]
qemu: pass only host arch instead of the whole virCaps

This is a preparation for following patches where we switch to
virFileCache for QEMU capabilities cache

The host arch will always remain the same but virCaps may change.  Now
the host arch is stored while creating new qemu capabilities cache.
It removes the need to pass virCaps into virQEMUCapsCache*() functions.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
7 years agotests: rewrite host CPU mocking
Pavel Hrdina [Fri, 21 Jul 2017 12:24:51 +0000 (14:24 +0200)]
tests: rewrite host CPU mocking

Move all the host CPU data into a separate file and rewrite qemucpumock
to not use passed @caps.  This is preparation for following patch which
will replace virCaps argument with virArch.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
7 years agoqemu: introduce struct _virQEMUCapsCachePriv
Pavel Hrdina [Tue, 20 Jun 2017 14:17:23 +0000 (16:17 +0200)]
qemu: introduce struct _virQEMUCapsCachePriv

This will store private data that will be used by following patches
when switching to virFileCache.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
7 years agotests: add virfilecachetest
Pavel Hrdina [Wed, 12 Apr 2017 13:58:29 +0000 (15:58 +0200)]
tests: add virfilecachetest

Implements 3 test cases that covers how the cache is used.

We have to mock unlink() function because the caching code unlinks
files that are no longer valid and we don't want to do it in our tests.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
7 years agoutil: introduce virFileCache
Pavel Hrdina [Fri, 7 Apr 2017 15:34:53 +0000 (17:34 +0200)]
util: introduce virFileCache

The new virFileCache will nicely handle the caching logic for any data
that we would like to cache.  For each type of data we will just need
to implement few handlers that will take care of creating, validating,
loading and saving the cached data.

The cached data must be an instance of virObject.

Currently we cache QEMU capabilities which will start using
virFileCache.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
7 years agoqemu: we prefer C89 comment styles over C99
Pavel Hrdina [Tue, 25 Jul 2017 21:10:00 +0000 (23:10 +0200)]
qemu: we prefer C89 comment styles over C99

Introduced by commit 'a7bc2c8cfd6f'.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
7 years agoGenerate unique socket file
Scott Garfinkle [Tue, 25 Jul 2017 14:33:50 +0000 (09:33 -0500)]
Generate unique socket file

It's possible to have more than one unnamed virtio-serial unix channel.
We need to generate a unique name for each channel. Currently, we use
".../unknown.sock" for all of them. Better practice would be to specify
an explicit target path name; however, in the absence of that, we need
uniqueness in the names we generate internally.

Before the changes we'd get /var/lib/libvirt/qemu/channel/target/unknown.sock
for each instance of
    <channel type='unix'>
        <source mode='bind'/>
        <target type='virtio'/>
    </channel>

Now, we get vioser-00-00-01.sock, vioser-00-00-02.sock, etc.

Signed-off-by: Scott Garfinkle <seg@us.ibm.com>
7 years agoMove machineName generation from virsystemd into domain_conf
Martin Kletzander [Fri, 21 Jul 2017 13:51:03 +0000 (15:51 +0200)]
Move machineName generation from virsystemd into domain_conf

It is more related to a domain as we might use it even when there is
no systemd and it does not use any dbus/systemd functions.  In order
not to use code from conf/ in util/ pass machineName in cgroups code
as a parameter.  That also fixes a leak of machineName in the lxc
driver and cleans up and de-duplicates some code.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
7 years agolxc: Make lxcProcessStop callable even without PID being available
Martin Kletzander [Fri, 21 Jul 2017 13:56:46 +0000 (15:56 +0200)]
lxc: Make lxcProcessStop callable even without PID being available

This way the function can work as a central point of clean-up code and
we don't have to duplicate code.  And it works similarly to the qemu
driver.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
7 years agoqemu: Save qemu driver in qemuDomainObjPrivateData
Martin Kletzander [Fri, 21 Jul 2017 13:46:56 +0000 (15:46 +0200)]
qemu: Save qemu driver in qemuDomainObjPrivateData

This way we can finally make it static and not use any externs anywhere.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
7 years agoconf: Pass config.priv to xmlopt->privateData.alloc
Martin Kletzander [Fri, 21 Jul 2017 13:29:00 +0000 (15:29 +0200)]
conf: Pass config.priv to xmlopt->privateData.alloc

This will help us to get to some data more easily.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
7 years agosecret: Handle object list removal and deletion properly
John Ferlan [Thu, 1 Jun 2017 16:43:06 +0000 (12:43 -0400)]
secret: Handle object list removal and deletion properly

Rather than rely on virSecretObjEndAPI to make the final virObjectUnref
after the call to virSecretObjListRemove, be more explicit by calling
virObjectUnref and setting @obj to NULL for secretUndefine and in
the error path of secretDefineXML. Calling EndAPI will end up calling
Unlock on an already unlocked object which has indeteriminate results
(usually an ignored error).

The virSecretObjEndAPI will both Unref and Unlock the object; however,
the virSecretObjListRemove would have already Unlock'd the object so
calling Unlock again is incorrect. Once the virSecretObjListRemove
is called all that's left is to Unref our interest since that's the
corrollary to the virSecretObjListAdd which returned our ref interest
plus references for each hash table in which the object resides. In math
terms, after an Add there's 2 refs on the object (1 for the object and
1 for the list). After calling Remove there's just 1 ref on the object.
For the Add callers, calling EndAPI removes the ref for the object and
unlocks it, but since it's in a list the other 1 remains.

Signed-off-by: John Ferlan <jferlan@redhat.com>
7 years agosecret: Fix memory leak in virSecretLoad
John Ferlan [Tue, 25 Jul 2017 13:02:09 +0000 (09:02 -0400)]
secret: Fix memory leak in virSecretLoad

If the virSecretLoadValue fails, the code jumped to cleanup without
setting @ret = obj, thus calling virSecretObjListRemove which only
accounts for the object reference related to adding the object to
the list during virSecretObjListAdd, but does not account for the
reference to the object itself as the return of @ret would be NULL
so the caller wouldn't call virSecretObjEndAPI on the object recently
added thus reducing the refcnt to zero.

This patch will perform the ObjListRemove in the failure path of
virSecretLoadValue and Unref @obj in order to perform clean up
and return @obj as NULL. The @def will be freed as part of the
virObjectUnref.

7 years agosecret: Properly handle @def after virSecretObjAdd in driver
John Ferlan [Thu, 1 Jun 2017 12:17:52 +0000 (08:17 -0400)]
secret: Properly handle @def after virSecretObjAdd in driver

Since the virSecretObjListAdd technically consumes @def on success,
the secretDefineXML should set @def = NULL immediately and process
the remaining calls using a new @objDef variable. We can use use
VIR_STEAL_PTR since we know the Add function just stores @def in
obj->def.

Because we steal @def into @objDef, if we jump to restore_backup:
and @backup is set, then we need to ensure the @def would be
free'd properly, so we'll steal it back from @objDef. For the other
condition this fixes a double free of @def if the code had jumped to
@backup == NULL thus calling virSecretObjListRemove without setting
@def = NULL. In this case, the subsequent call to DefFree would
succeed and free @def; however, the call to EndAPI would also
call DefFree because the Unref done would be the last one for
the @obj meaning the obj->def would be used to call DefFree,
but it's already been free'd because @def wasn't managed right
within this error path.

Signed-off-by: John Ferlan <jferlan@redhat.com>
7 years agosecret: Remove need for local configFile and base64File in ObjectAdd
John Ferlan [Wed, 31 May 2017 19:11:28 +0000 (15:11 -0400)]
secret: Remove need for local configFile and base64File in ObjectAdd

Rather than assign to a local variable, let's just assign directly to the
object using the error path for cleanup.

Signed-off-by: John Ferlan <jferlan@redhat.com>
7 years agoRevert "virthread: Introduce virRWLockInitPreferWriter"
Michal Privoznik [Tue, 25 Jul 2017 08:31:54 +0000 (10:31 +0200)]
Revert "virthread: Introduce virRWLockInitPreferWriter"

This reverts commit 328bd24443d2a345a5832ee48ebba0208f8036ea.

As it turns out, this is not portable and very Linux & glibc
specific. Worse, this may lead to not starving writers on Linux
but everywhere else. Revert this and if the starvation occurs
resolve it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrange <berrange@redhat.com>
7 years agoconf: Rename virDomainControllerIsPCIHostBridge() to IsPSeriesPHB()
Andrea Bolognani [Mon, 24 Jul 2017 11:26:57 +0000 (13:26 +0200)]
conf: Rename virDomainControllerIsPCIHostBridge() to IsPSeriesPHB()

The original name didn't hint at the fact that PHBs are
a pSeries-specific concept.

Suggested-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
7 years agoconf: Fix backwards migration of pSeries guests
Andrea Bolognani [Wed, 19 Jul 2017 08:37:04 +0000 (10:37 +0200)]
conf: Fix backwards migration of pSeries guests

Recent commits made it so that pci-root controllers for
pSeries guests are automatically assigned the
spapr-pci-host-bridge model name; however, that prevents
guests to migrate to older versions of libvirt which don't
know about that model name at all, which at the moment is
all of them :)

To avoid the issue, just strip the model name from PHBs
when formatting the migratable XML; guests that use more
than one PHB are not going to be migratable anyway.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
7 years agostorage: Check if provided parent is vHBA capable
John Ferlan [Thu, 20 Jul 2017 15:14:46 +0000 (11:14 -0400)]
storage: Check if provided parent is vHBA capable

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

If the parent provided for the storage pool adapter is not vHBA
capable, then issue a configuration error even though the provided
wwnn/wwpn were found.

It is a configuration error to provide a mismatched parent to
the wwnn/wwpn. The @parent is optional and is used as a means to
perform duplicate pool source checks.

7 years agostorage: Remove @conn from virNodeDeviceCreateVport
John Ferlan [Tue, 18 Jul 2017 13:51:08 +0000 (09:51 -0400)]
storage: Remove @conn from virNodeDeviceCreateVport

It's no longer needed since the checkParent code moved back to
storage_backend_scsi.c

Signed-off-by: John Ferlan <jferlan@redhat.com>
7 years agostorage: Fix existing parent check for vHBA creation
John Ferlan [Tue, 18 Jul 2017 13:21:30 +0000 (09:21 -0400)]
storage: Fix existing parent check for vHBA creation

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

Commit id '106930aaa' altered the order of checking for an existing
vHBA (e.g something created via nodedev-create functionality outside
of the storage pool logic) which inadvertantly broke the code to
decide whether to alter/force the fchost->managed field to be 'yes'
because the storage pool will be managing the created vHBA in order
to ensure when the storage pool is destroyed that the vHBA is also
destroyed.

This patch moves the check (and checkParent helper) for an existing
vHBA back into the createVport in storage_backend_scsi. It also
adjusts the checkParent logic to more closely follow the intentions
prior to commit id '79ab0935'. The changes made by commit id '08c0ea16f'
are only necessary to run the virStoragePoolFCRefreshThread when
a vHBA was really created because there's a timing lag such that
the refreshPool call made after a startPool from storagePoolCreate*
wouldn't necessarily find LUNs, but the thread would. For an already
existing vHBA, using the thread is unnecessary since the vHBA already
exists and the lag to configure the LUNs wouldn't exist.

Signed-off-by: John Ferlan <jferlan@redhat.com>
7 years agonodedev: Remove driver locks around object list mgmt code
John Ferlan [Thu, 29 Jun 2017 20:51:54 +0000 (16:51 -0400)]
nodedev: Remove driver locks around object list mgmt code

Since virnodedeviceobj now has a self-lockable hash table, there's no
need to lock the table from the driver for processing. Thus remove the
locks from the driver for NodeDeviceObjList mgmt.

This includes the test driver as well.

7 years agonodedev: Convert virNodeDeviceObjListPtr to use hash tables
John Ferlan [Thu, 29 Jun 2017 19:50:06 +0000 (15:50 -0400)]
nodedev: Convert virNodeDeviceObjListPtr to use hash tables

Rather than use a forward linked list of elements, it'll be much more
efficient to use a hash table to reference the elements by unique name
and to perform hash searches.

This patch does all the heavy lifting of converting the list object to
use a self locking list that contains the hash table. Each of the FindBy
functions that do not involve finding the object by it's key (name) is
converted to use virHashSearch in order to find the specific object.
When searching for the key (name), it's possible to use virHashLookup.
For any of the list perusal functions that are required to evaluate
each object, the virHashForEach function is used.

7 years agonodedev: Remove @create from virNodeDeviceObjListGetParentHost
John Ferlan [Thu, 20 Jul 2017 13:17:22 +0000 (09:17 -0400)]
nodedev: Remove @create from virNodeDeviceObjListGetParentHost

The only callers to this function are from CreateXML paths now, so
let's just remove the unnecessary parameter.

7 years agonodedev: Alter node device deletion logic
John Ferlan [Thu, 20 Jul 2017 13:07:52 +0000 (09:07 -0400)]
nodedev: Alter node device deletion logic

Alter the node device deletion logic to make use of the parent field
from the obj->def rather than call virNodeDeviceObjListGetParentHost.
As it turns out the saved @def won't have parent_wwnn/wwpn or
parent_fabric_wwn, so the only logical path would be to call
virNodeDeviceObjListGetParentHostByParent which we can accomplish
directly via virNodeDeviceObjListFindByName.

7 years agovirdomainobjlist: Use virObjectRWLockable
Michal Privoznik [Wed, 19 Jul 2017 10:11:05 +0000 (12:11 +0200)]
virdomainobjlist: Use virObjectRWLockable

There is no reason why two threads trying to look up two domains
should mutually exclude each other. Utilize new
virObjectRWLockable that was just introduced.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
7 years agovirobject: Introduce virObjectRWLockable
Michal Privoznik [Wed, 19 Jul 2017 07:31:50 +0000 (09:31 +0200)]
virobject: Introduce virObjectRWLockable

Up until now we only had virObjectLockable which uses mutexes for
mutually excluding each other in critical section. Well, this is
not enough. Future work will require RW locks so we might as well
have virObjectRWLockable which is introduced here.

Moreover, polymorphism is introduced to our code for the first
time. Yay! More specifically, virObjectLock will grab a write
lock, virObjectLockRead will grab a read lock then (what a
surprise right?). This has great advantage that an object can be
made derived from virObjectRWLockable in a single line and still
continue functioning properly (mutexes can be viewed as grabbing
write locks only). Then just those critical sections that can
grab a read lock need fixing. Therefore the resulting change is
going to be way smaller.

In order to avoid writer starvation, the object initializes RW
lock that prefers writers.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
7 years agovirthread: Introduce virRWLockInitPreferWriter
Michal Privoznik [Wed, 19 Jul 2017 10:54:23 +0000 (12:54 +0200)]
virthread: Introduce virRWLockInitPreferWriter

We already have virRWLockInit. But this uses pthread defaults
which prefer reader to initialize the RW lock. This may lead to
writer starvation. Therefore we need to have the counterpart that
prefers writers. Now, according to the
pthread_rwlockattr_setkind_np() man page setting
PTHREAD_RWLOCK_PREFER_WRITER_NP attribute is no-op. Therefore we
need to use PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP
attribute. So much for good enum value names.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
7 years agotestutils: Remove unneeded variable
Martin Kletzander [Fri, 21 Jul 2017 06:11:56 +0000 (08:11 +0200)]
testutils: Remove unneeded variable

virDomainXMLOptionNew() gladly accepts NULL and it is used in some
drivers.  There is no need for additional variable with no members set

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>