]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
7 years agoqemu: Tolerate storage source private data being NULL
Peter Krempa [Thu, 9 Nov 2017 11:51:25 +0000 (12:51 +0100)]
qemu: Tolerate storage source private data being NULL

In some cases it does not make sense to pursue that the private data
will be allocated (especially when we don't need to put anything in it).

Ensure that the code works without it.

This also fixes few crashes pointed out in
https://bugzilla.redhat.com/show_bug.cgi?id=1510323

7 years agoqemu: parse: Allocate disk definition with private data
Peter Krempa [Wed, 8 Nov 2017 19:44:35 +0000 (20:44 +0100)]
qemu: parse: Allocate disk definition with private data

Use virDomainDiskDefNew instead of VIR_ALLOC in
qemuParseCommandLineDisk.

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

7 years agoqemu: block: Don't leak server JSON object from protocol generators
Peter Krempa [Thu, 9 Nov 2017 09:29:53 +0000 (10:29 +0100)]
qemu: block: Don't leak server JSON object from protocol generators

If creation of the main JSON object containing the storage portion of a
virStorageSource would fail but we'd allocate the server structure we'd
leak it. Found by coverity.

7 years agoqemu: block: Break out early on invalid storage sources
Peter Krempa [Thu, 9 Nov 2017 09:13:26 +0000 (10:13 +0100)]
qemu: block: Break out early on invalid storage sources

Return NULL right away in qemuBlockStorageSourceGetBackendProps when an
invalid storage source is presented so that virJSONValueObjectAdd isn't
called with a NULL argument.

Found by coverity.

7 years agoconf: Properly parse <backingStore/>
Peter Krempa [Wed, 8 Nov 2017 14:42:51 +0000 (15:42 +0100)]
conf: Properly parse <backingStore/>

The terminator would not be parsed properly since the XPath selector was
looking for an populated element, and also the code did not bother
assigning the terminating virStorageSourcePtr to the backingStore
property of the parent.

Some tests would catch it if there wasn't bigger fallout from the change
to backing store termination in a693fdba0111. Fix them properly now.

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

7 years agoRevert "virNetDevSupportBandwidth: Enable QoS for vhostuser"
Michal Privoznik [Fri, 10 Nov 2017 15:16:52 +0000 (16:16 +0100)]
Revert "virNetDevSupportBandwidth: Enable QoS for vhostuser"

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

This reverts commit bc8a99ef06417a2303ccab455f9f045e2a617916.

The vhostuser is not a TAP. Therefore our QoS code is not able to
set any bandwidth. I don't really understand what I was thinking.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
7 years agolibxlxml2domconfigtest: add test for vNUMA config
Wim ten Have [Fri, 10 Nov 2017 20:03:16 +0000 (13:03 -0700)]
libxlxml2domconfigtest: add test for vNUMA config

Add tests to ensure the libxl_domain_config generator properly
handles vNUMA configuration.

Signed-off-by: Wim ten Have <wim.ten.have@oracle.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
7 years agoxlconfigtest: add tests for vNUMA configuration
Wim ten Have [Fri, 10 Nov 2017 19:12:34 +0000 (12:12 -0700)]
xlconfigtest: add tests for vNUMA configuration

Add tests for conversion of domXML vNUMA config to/from
xen-xl native vNUMA config.

Signed-off-by: Wim ten Have <wim.ten.have@oracle.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
7 years agolibxl: vnuma support
Wim ten Have [Thu, 2 Nov 2017 15:47:22 +0000 (16:47 +0100)]
libxl: vnuma support

This patch generates a NUMA distance-aware libxl description from the
information extracted from a NUMA distance-aware libvirt XML file.

By default, if no NUMA node distance information is supplied in the
libvirt XML file, this patch uses the distances 10 for local and 20
for remote nodes/sockets.

Signed-off-by: Wim ten Have <wim.ten.have@oracle.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
7 years agoxenconfig: add domxml conversions for xen-xl
Wim ten Have [Thu, 2 Nov 2017 15:47:21 +0000 (16:47 +0100)]
xenconfig: add domxml conversions for xen-xl

This patch converts NUMA configurations between the Xen libxl
configuration file format and libvirt's XML format.

XML HVM domain on a 4 node (2 cores/socket) configuration:

  <cpu>
    <numa>
      <cell id='0' cpus='0-1' memory='2097152' unit='KiB'>
        <distances>
          <sibling id='0' value='10'/>
          <sibling id='1' value='21'/>
          <sibling id='2' value='31'/>
          <sibling id='3' value='21'/>
        </distances>
      </cell>
      <cell id='1' cpus='2-3' memory='2097152' unit='KiB'>
        <distances>
          <sibling id='0' value='21'/>
          <sibling id='1' value='10'/>
          <sibling id='2' value='21'/>
          <sibling id='3' value='31'/>
        </distances>
      </cell>
      <cell id='2' cpus='3-4' memory='2097152' unit='KiB'>
        <distances>
          <sibling id='0' value='31'/>
          <sibling id='1' value='21'/>
          <sibling id='2' value='10'/>
          <sibling id='3' value='21'/>
        </distances>
      </cell>
      <cell id='3' cpus='5-6' memory='2097152' unit='KiB'>
        <distances>
          <sibling id='0' value='21'/>
          <sibling id='1' value='31'/>
          <sibling id='2' value='21'/>
          <sibling id='3' value='10'/>
        </distances>
      </cell>
    </numa>
  </cpu>

Xen xl.cfg domain configuration:

  vnuma = [["pnode=0","size=2048","vcpus=0-1","vdistances=10,21,31,21"],
           ["pnode=1","size=2048","vcpus=2-3","vdistances=21,10,21,31"],
           ["pnode=2","size=2048","vcpus=4-5","vdistances=31,21,10,21"],
           ["pnode=3","size=2048","vcpus=6-7","vdistances=21,31,21,10"]]

If there is no XML <distances> description amongst the <cell> data the
conversion schema from xml to native will generate 10 for local and 20
for all remote instances.

Signed-off-by: Wim ten Have <wim.ten.have@oracle.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
7 years agonuma: describe siblings distances within cells
Wim ten Have [Thu, 2 Nov 2017 15:47:20 +0000 (16:47 +0100)]
numa: describe siblings distances within cells

Add support for describing NUMA distances in a domain's <numa> <cell>
XML description.

Below is an example of a 4 node setup:

  <cpu>
    <numa>
      <cell id='0' cpus='0-3' memory='2097152' unit='KiB'>
        <distances>
          <sibling id='0' value='10'/>
          <sibling id='1' value='21'/>
          <sibling id='2' value='31'/>
          <sibling id='3' value='21'/>
        </distances>
      </cell>
      <cell id='1' cpus='4-7' memory='2097152' unit='KiB'>
        <distances>
          <sibling id='0' value='21'/>
          <sibling id='1' value='10'/>
          <sibling id='2' value='21'/>
          <sibling id='3' value='31'/>
        </distances>
      </cell>
      <cell id='2' cpus='8-11' memory='2097152' unit='KiB'>
        <distances>
          <sibling id='0' value='31'/>
          <sibling id='1' value='21'/>
          <sibling id='2' value='10'/>
          <sibling id='3' value='21'/>
        </distances>
      <cell id='3' cpus='12-15' memory='2097152' unit='KiB'>
        <distances>
          <sibling id='0' value='21'/>
          <sibling id='1' value='31'/>
          <sibling id='2' value='21'/>
          <sibling id='3' value='10'/>
        </distances>
      </cell>
    </numa>
  </cpu>

A <cell> defines a NUMA node. <distances> describes the NUMA distance
from the <cell> to the other NUMA nodes (the <sibling>s).  For example,
in above XML description, the distance between NUMA node0 <cell id='0'
...> and NUMA node2 <sibling id='2' ...> is 31.

Valid distance values are '10 <= value <= 255'.  A distance value of 10
represents the distance to the node itself.  A distance value of 20
represents the default value for remote nodes but other values are
possible depending on the physical topology of the system.

When distances are not fully described, any missing sibling distance
values will default to 10 for local nodes and 20 for remote nodes.

If distance is given for A -> B, then we default B -> A to the same
value instead of 20.

Signed-off-by: Wim ten Have <wim.ten.have@oracle.com>
Reviewed-by: Daniel P. Berrange <berrange@redhat.com>
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
7 years agoremote: Set *neventCallbacks to zero at DEREG_CB
xinhua.Cao [Sat, 11 Nov 2017 08:30:41 +0000 (16:30 +0800)]
remote: Set *neventCallbacks to zero at DEREG_CB

To avoid the chance that the loop is run twice, set the neventCallbacks
to zero after VIR_FREE(eventCallbacks) was called.

7 years agotests: fix TTY check in virTestUseTerminalColors()
Pino Toscano [Thu, 9 Nov 2017 12:31:03 +0000 (13:31 +0100)]
tests: fix TTY check in virTestUseTerminalColors()

Since colors would be used when writing to stdout, then check that
stdout is a TTY, instead of stdin.

This avoids the usage of terminal color codes when the output is
directed to file.

7 years agoqemuBuildDriveDevStr: Prefer default aliases for IDE bus
Michal Privoznik [Thu, 9 Nov 2017 12:34:43 +0000 (13:34 +0100)]
qemuBuildDriveDevStr: Prefer default aliases for IDE bus

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

When testing user aliases it was discovered that for 440fx
machine type which has default IDE bus builtin, domain cannot
start if IDE controller has the user provided alias. This is
because for 440fx we don't put the IDE controller onto the
command line (since it is builtin) and therefore any device that
is plugged onto the bus must use the default alias.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
7 years agonuma: avoid failure in nodememstats on non-NUMA systems
Viktor Mihajlovski [Fri, 22 Sep 2017 14:12:23 +0000 (16:12 +0200)]
numa: avoid failure in nodememstats on non-NUMA systems

libvirt reports a fake NUMA topology in virConnectGetCapabilities
even if built without numactl support. The fake NUMA topology consists
of a single cell representing the host's cpu and memory resources.
Currently this is the case for ARM and s390[x] RPM builds.

A client iterating over NUMA cells obtained via virConnectGetCapabilities
and invoking virNodeGetMemoryStats on them will see an internal failure
"NUMA isn't available on this host" from virNumaGetMaxNode. An example
for such a client is VDSM.

Since the intention seems to be that libvirt always reports at least
a single cell it is necessary to return "fake" node memory statistics
matching the previously reported fake cell in case NUMA isn't supported
on the system.

Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
7 years agonews: Update for vbox 5.2 support
Dawid Zamirski [Tue, 7 Nov 2017 22:44:31 +0000 (17:44 -0500)]
news: Update for vbox 5.2 support

7 years agovbox: Add support for 5.2.x
Dawid Zamirski [Tue, 7 Nov 2017 22:36:34 +0000 (17:36 -0500)]
vbox: Add support for 5.2.x

Simply add the 5.2 SDK header to the existing unified framework. No
other special handling is needed as there's no API break between
existing 5.1 and the just added 5.2.

7 years agovbox: Add vbox 5.2 CAPI header file.
Dawid Zamirski [Tue, 7 Nov 2017 22:22:08 +0000 (17:22 -0500)]
vbox: Add vbox 5.2 CAPI header file.

Extracted from 5.2 SDK and reindented with cppi

7 years agovirconf: properly set the end of content
Jim Fehlig [Tue, 7 Nov 2017 21:20:44 +0000 (14:20 -0700)]
virconf: properly set the end of content

There was a recent report of the xen-xl converter not handling
config files missing an ending newline

https://www.redhat.com/archives/libvir-list/2017-October/msg01353.html

Commit 3cc2a9e0 fixed a similar problem when parsing content of a
file but missed parsing in-memory content. But AFAICT, the better
fix is to properly set the end of the content when initializing the
virConfParserCtxt in virConfParse().

This commit reverts the part of 3cc2a9e0 that appends a newline to
files missing it, and fixes setting the end of content when
initializing virConfParserCtxt. A test is also added to check
parsing in-memory content missing an ending newline.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Daniel P. Berrange <berrange@redhat.com>
7 years agoconf: Fix type for @liveStatus in virDomainObjListLoadAllConfigs
Peter Krempa [Wed, 8 Nov 2017 14:17:33 +0000 (15:17 +0100)]
conf: Fix type for @liveStatus in virDomainObjListLoadAllConfigs

Use bool instead of an int.

7 years agoqemu-ns: Detect /dev/* mount point duplicates even better
Michal Privoznik [Wed, 8 Nov 2017 14:20:10 +0000 (15:20 +0100)]
qemu-ns: Detect /dev/* mount point duplicates even better

In 4f1570720218302 I've tried to make duplicates detection for
nested /dev mount better. However, I've missed the obvious case
when there are two same mount points. For instance if:

  # mount --bind /dev/blah /dev/blah
  # mount --bind /dev/blah /dev/blah

Yeah, very unlikely (in qemu driver world) but possible.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
7 years agoutil: storage: Fix parsing of IPv6 portal address for iSCSI
Peter Krempa [Tue, 7 Nov 2017 15:20:23 +0000 (16:20 +0100)]
util: storage: Fix parsing of IPv6 portal address for iSCSI

Split on the last colon and avoid parsing port if the split remainder
contains the closing square bracket, so that IPv6 addresses are
interpreted correctly.

7 years agotests: Add caps for QEMU 2.10.0 on ppc64
Andrea Bolognani [Fri, 3 Nov 2017 16:26:30 +0000 (17:26 +0100)]
tests: Add caps for QEMU 2.10.0 on ppc64

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agotests: Rename ppc64le caps to ppc64
Andrea Bolognani [Mon, 6 Nov 2017 11:40:24 +0000 (12:40 +0100)]
tests: Rename ppc64le caps to ppc64

The architecture itself is called ppc64, and it can run both in big
endian and little endian mode - the latter is known as ppc64le.

From the (virtual) hardware point of view, ppc64 is a more accurate
name so it should be used here.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agotests: Add caps for QEMU 2.10.0 on aarch64 (GICv3)
Andrea Bolognani [Mon, 6 Nov 2017 11:23:35 +0000 (12:23 +0100)]
tests: Add caps for QEMU 2.10.0 on aarch64 (GICv3)

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agotests: Add caps for QEMU 2.10.0 on aarch64 (GICv2)
Andrea Bolognani [Mon, 6 Nov 2017 11:23:22 +0000 (12:23 +0100)]
tests: Add caps for QEMU 2.10.0 on aarch64 (GICv2)

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agonews: Document predictable file names for memory-backend-file
Michal Privoznik [Tue, 24 Oct 2017 09:59:29 +0000 (11:59 +0200)]
news: Document predictable file names for memory-backend-file

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agoqemu: Use predictable file names for memory-backend-file
Michal Privoznik [Tue, 7 Nov 2017 14:20:12 +0000 (15:20 +0100)]
qemu: Use predictable file names for memory-backend-file

In some cases management application needs to allocate memory for
qemu upfront and then just let qemu use that. Since we don't want
to expose path for memory-backend-file anywhere in the domain
XML, we can generate predictable paths. In this case:

  $memoryBackingDir/libvirt/qemu/$shortName/$alias

where $shortName is result of virDomainDefGetShortName().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agoqemu: Destroy whole memory tree
Michal Privoznik [Tue, 7 Nov 2017 15:03:40 +0000 (16:03 +0100)]
qemu: Destroy whole memory tree

When removing path where huge pages are call virFileDeleteTree
instead of plain rmdir(). The reason is that in the near future
there's going to be more in the path than just files - some
subdirs. Therefore plain rmdir() is not going to be enough.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agoqemu: Rename qemuProcessBuildDestroyHugepagesPath
Michal Privoznik [Tue, 7 Nov 2017 14:19:43 +0000 (15:19 +0100)]
qemu: Rename qemuProcessBuildDestroyHugepagesPath

At the same time, move its internals into a separate function so
that they can be reused.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agoqemu: Set alias for memory cell in qemuBuildMemoryCellBackendStr
Michal Privoznik [Tue, 7 Nov 2017 14:12:33 +0000 (15:12 +0100)]
qemu: Set alias for memory cell in qemuBuildMemoryCellBackendStr

Very soon qemuBuildMemoryBackendStr() is going to use memory cell
aliases. Therefore set one. At the same time, move it a bit
further - if virAsprintf() fails, there's no point in setting
rest of the members.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agodocs: Document autoport behavior in the vbox driver
Dawid Zamirski [Tue, 7 Nov 2017 21:36:48 +0000 (16:36 -0500)]
docs: Document autoport behavior in the vbox driver

7 years agodocs: Update vbox driver documentation.
Dawid Zamirski [Tue, 7 Nov 2017 21:36:47 +0000 (16:36 -0500)]
docs: Update vbox driver documentation.

* libvirt no longer supports vbox <= 3.x
* update XML definition sample to show how to attach disks to VBOX's SAS
  controller and how to change IDE controller model.
* update XML to show how to create RDP display with autoport.

7 years agocputest: Add data for Intel(R) Core(TM) i7-7700 CPU
Jiri Denemark [Mon, 2 Oct 2017 13:51:21 +0000 (15:51 +0200)]
cputest: Add data for Intel(R) Core(TM) i7-7700 CPU

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agocputest: Add data for Intel(R) Xeon(R) CPU E5-2650 v4
Jiri Denemark [Thu, 2 Nov 2017 19:50:25 +0000 (20:50 +0100)]
cputest: Add data for Intel(R) Xeon(R) CPU E5-2650 v4

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agocputest: Do not drop v[0-9] from CPU names
Jiri Denemark [Thu, 2 Nov 2017 13:43:37 +0000 (14:43 +0100)]
cputest: Do not drop v[0-9] from CPU names

Version is a significant part of some Xeon CPUs.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agodocs: Update news.xml with vbox changes.
Dawid Zamirski [Tue, 7 Nov 2017 18:49:30 +0000 (13:49 -0500)]
docs: Update news.xml with vbox changes.

7 years agovbox: Add SAS controller support
Dawid Zamirski [Tue, 7 Nov 2017 18:49:29 +0000 (13:49 -0500)]
vbox: Add SAS controller support

In VirtualBox SAS and SCSI are separate controller types whereas libvirt
does not make such distinction. This patch adds support for attaching
the VBOX SAS controllers by mapping the 'lsisas1068' controller model in
libvirt XML to VBOX SAS controller type. If VBOX VM has disks attached
to both SCSI and SAS controller libvirt domain XML will have two
<controller type='scsci'> elements with index and model attributes set
accordingly. In this case, each respective <disk> element must have
<address> element specified to assign it to respective SCSI controller.

7 years agovbox: Generate disk address element in dumpxml
Dawid Zamirski [Tue, 7 Nov 2017 18:49:28 +0000 (13:49 -0500)]
vbox: Generate disk address element in dumpxml

This patch adds <address> element to each <disk> device since device
names alone won't adequately reflect the storage device layout in the
VM. With this patch, the ouput produced by dumpxml will faithfully
reproduce the storage layout of the VM if used with define.

7 years agovbox: Process empty removable disks in dumpxml
Dawid Zamirski [Tue, 7 Nov 2017 18:49:27 +0000 (13:49 -0500)]
vbox: Process empty removable disks in dumpxml

Previously any removable storage device without media attached was
omitted from domain XML dump. They're still (rightfully) omitted in
snapshot XML dump but need to be accounted properly to for the device
names to stay in 'sync' between domain and snapshot XML dumps.

7 years agovbox: Cleanup vboxDumpDisks implementation
Dawid Zamirski [Tue, 7 Nov 2017 18:49:26 +0000 (13:49 -0500)]
vbox: Cleanup vboxDumpDisks implementation

Primer the code for further changes:

* move variable declarations to the top of the function
* group together free/release statements
* error check and report VBOX API calls used

7 years agovbox: Correctly generate drive name in dumpxml
Dawid Zamirski [Tue, 7 Nov 2017 18:49:25 +0000 (13:49 -0500)]
vbox: Correctly generate drive name in dumpxml

If a VBOX VM has e.g. a SATA and SCSI disk attached, the XML generated
by dumpxml used to produce "sda" for both of those disks. This is an
invalid domain XML as libvirt does not allow duplicate device names. To
address this, keep the running total of disks that will use "sd" prefix
for device name and pass it to the vboxGenerateMediumName which no
longer tries to "compute" the value based only on current and max
port and slot values. After this the vboxGetMaxPortSlotValues is not
needed and was deleted.

7 years agovbox: Swap vboxSnapshotGetReadOnlyDisks arguments
Dawid Zamirski [Tue, 7 Nov 2017 18:49:24 +0000 (13:49 -0500)]
vbox: Swap vboxSnapshotGetReadOnlyDisks arguments

So that the function signature matches vboxSnapshotGetReadWriteDisks

7 years agovbox: Do not free disk definitions on cleanup
Dawid Zamirski [Tue, 7 Nov 2017 18:49:23 +0000 (13:49 -0500)]
vbox: Do not free disk definitions on cleanup

Both vboxSnapshotGetReadWriteDisks and vboxSnapshotGetReadWriteDisks do
not need to free the def->disks on cleanup because it's being done by
the caller via virDomainSnaphotDefFree

7 years agovbox: Cleanup/prepare snasphot dumpxml functions
Dawid Zamirski [Tue, 7 Nov 2017 18:49:22 +0000 (13:49 -0500)]
vbox: Cleanup/prepare snasphot dumpxml functions

This patch prepares the vboxSnapshotGetReadOnlyDisks and
vboxSnapshotGetReadWriteDisks functions for further changes so that
the code movement does not obstruct the gist of those future changes.
This is done primarily because we'll need to know the type of vbox
storage controller as early as possible and make decisions based on
that info.

7 years agovbox: Rename vboxDumpIDEHDDs to vboxDumpDisks
Dawid Zamirski [Tue, 7 Nov 2017 18:49:21 +0000 (13:49 -0500)]
vbox: Rename vboxDumpIDEHDDs to vboxDumpDisks

Because it deals with other disk types as well not just IDE. Also this
function now returns -1 on error

7 years agovbox: Add vboxDumpStorageControllers
Dawid Zamirski [Tue, 7 Nov 2017 18:49:20 +0000 (13:49 -0500)]
vbox: Add vboxDumpStorageControllers

7 years agovbox: Process <controller> element in domain XML
Dawid Zamirski [Tue, 7 Nov 2017 18:49:19 +0000 (13:49 -0500)]
vbox: Process <controller> element in domain XML

With this patch, the vbox driver will no longer attach all supported
storage controllers by default even if no disk devices are associated
with them. Instead, it will attach only those that are implicitly added
by virDomainDefAddImplicitController based on <disk> element or if
explicitly specified via the <controller> element.

7 years agovbox: Cleanup partially-defined VM on failure
Dawid Zamirski [Tue, 7 Nov 2017 18:49:18 +0000 (13:49 -0500)]
vbox: Cleanup partially-defined VM on failure

Since the VBOX API requires to register an initial VM before proceeding
to attach any remaining devices to it, any failure to attach such
devices should result in automatic cleanup of the initially registered
VM so that the state of VBOX registry remains clean without any leftover
"aborted" VMs in it. Failure to cleanup of such partial VMs results in a
warning log so that actual define error stays on the top of the error
stack.

7 years agostorage: Privatize virStoragePoolObj and virStorageVolDefList
John Ferlan [Wed, 26 Jul 2017 19:13:28 +0000 (15:13 -0400)]
storage: Privatize virStoragePoolObj and virStorageVolDefList

Move the structures into virstorageobj so that both are known
within virstorageobj.c.

7 years agostorage: Use virStoragePoolObjGetDef accessor for new driver events
John Ferlan [Fri, 6 Oct 2017 14:31:34 +0000 (10:31 -0400)]
storage: Use virStoragePoolObjGetDef accessor for new driver events

Missed from merge from commit id 'b0652192' into commit id 'bfcd8fc92'
were a couple of obj->def-> references.

7 years agostorage: Use virStoragePoolObjGetDef accessor for ZFS backend
John Ferlan [Wed, 26 Jul 2017 18:39:54 +0000 (14:39 -0400)]
storage: Use virStoragePoolObjGetDef accessor for ZFS backend

In preparation for privatizing the object, use the accessor.

7 years agostorage: Use virStoragePoolObjGetDef accessor for VSTORAGE backend
John Ferlan [Wed, 26 Jul 2017 18:36:46 +0000 (14:36 -0400)]
storage: Use virStoragePoolObjGetDef accessor for VSTORAGE backend

In preparation for privatizing the object, use the accessor.

7 years agostorage: Use virStoragePoolObjGetDef accessor for SCSI backend
John Ferlan [Wed, 26 Jul 2017 18:34:57 +0000 (14:34 -0400)]
storage: Use virStoragePoolObjGetDef accessor for SCSI backend

In preparation for privatizing the object, use the accessor.

7 years agostorage: Use virStoragePoolObjGetDef accessor for RBD backend
John Ferlan [Wed, 26 Jul 2017 18:32:09 +0000 (14:32 -0400)]
storage: Use virStoragePoolObjGetDef accessor for RBD backend

In preparation for privatizing the object, use the accessor.

7 years agostorage: Use virStoragePoolObjGetDef accessor for MPATH backend
John Ferlan [Wed, 26 Jul 2017 18:28:16 +0000 (14:28 -0400)]
storage: Use virStoragePoolObjGetDef accessor for MPATH backend

In preparation for privatizing the object, use the accessor.

7 years agostorage: Use virStoragePoolObjGetDef accessor for iSCSI backend
John Ferlan [Wed, 26 Jul 2017 18:26:27 +0000 (14:26 -0400)]
storage: Use virStoragePoolObjGetDef accessor for iSCSI backend

In preparation for privatizing the object, use the accessor.

7 years agoapparmor, virt-aa-helper: allow ipv6
Christian Ehrhardt [Fri, 3 Nov 2017 08:46:59 +0000 (09:46 +0100)]
apparmor, virt-aa-helper: allow ipv6

In case ipv6 is used the network inet6 permission is required for
virt-aa-helper.

Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
7 years agoapparmor: allow qemu to read max_segments
Christian Ehrhardt [Fri, 3 Nov 2017 08:46:58 +0000 (09:46 +0100)]
apparmor: allow qemu to read max_segments

Since qemu 2.9 via 9103f1ce "file-posix: Consider max_segments for
BlockLimits.max_transfer" this is a new access that is denied by the
qemu profile.

It is non fatal, but prevents the fix mentioned to actually work.
It should be safe to allow reading from that path.

Since qemu opens a symlink path we need to translate that for apparmor from
"/sys/dev/block/*/queue/max_segments" to
"/sys/devices/**/block/*/queue/max_segments"

Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
7 years agotests: Add testing of storage backend JSON props formatter
Peter Krempa [Fri, 3 Nov 2017 14:20:55 +0000 (15:20 +0100)]
tests: Add testing of storage backend JSON props formatter

Add a new test program called 'qemublocktest' to test the block layer
related stuff and test storage source to JSON generator by comparing it
to the JSON parser.

7 years agoqemu: block: Add node-names to JSON backing storage strings
Peter Krempa [Mon, 9 Oct 2017 06:55:15 +0000 (08:55 +0200)]
qemu: block: Add node-names to JSON backing storage strings

Format out the node-name if it was assigned for JSON-based storage
specification.

7 years agoqemu: block: Add JSON props generator for ssh storage backing
Peter Krempa [Mon, 23 Oct 2017 16:54:12 +0000 (18:54 +0200)]
qemu: block: Add JSON props generator for ssh storage backing

7 years agoqemu: block: Add JSON props generator for sheepdog storage backing
Peter Krempa [Mon, 23 Oct 2017 16:44:35 +0000 (18:44 +0200)]
qemu: block: Add JSON props generator for sheepdog storage backing

7 years agoqemu: block: Add JSON props generator for RBD storage backing
Peter Krempa [Mon, 23 Oct 2017 16:16:53 +0000 (18:16 +0200)]
qemu: block: Add JSON props generator for RBD storage backing

7 years agoqemu: block: Add JSON props generator for NBD storage backing
Peter Krempa [Thu, 13 Jul 2017 13:48:06 +0000 (15:48 +0200)]
qemu: block: Add JSON props generator for NBD storage backing

7 years agoqemu: block: Add JSON props generator for iSCSI protocol
John Ferlan [Thu, 19 Oct 2017 15:44:57 +0000 (17:44 +0200)]
qemu: block: Add JSON props generator for iSCSI protocol

7 years agoqemu: block: Add JSON props generator for 'curl' based storage backends
Peter Krempa [Thu, 13 Jul 2017 13:48:06 +0000 (15:48 +0200)]
qemu: block: Add JSON props generator for 'curl' based storage backends

QEMU uses curl for accessing files using http(s) and ftp(s). They share
common options so let's generate them in one helper.

7 years agostorage: Store RBD image name as pool and image name
Peter Krempa [Mon, 23 Oct 2017 14:23:45 +0000 (16:23 +0200)]
storage: Store RBD image name as pool and image name

Similarly to how we store gluster names, split the name into a pool and
image portions when paring the XML and store them separately.

7 years agostorage: Don't store leading '/' in image name when splitting out volume
Peter Krempa [Mon, 23 Oct 2017 14:39:49 +0000 (16:39 +0200)]
storage: Don't store leading '/' in image name when splitting out volume

Libvirt historically stores storage source path including the volume as
one string in the XML, but that is not really flexible enough when
dealing with the fields in the code. Previously we'd store the slash
separating the two as part of the image name. This was fine for gluster
but it's not necessary and does not scale well when converting other
protocols.

Don't store the slash as part of the path. The resulting change from
absolute to relative path within the gluster driver should be okay,
as the root directory is the default when accessing gluster.

7 years agoqemu: process: Split out useful parts from qemuBuildNetworkDriveURI
Peter Krempa [Thu, 13 Jul 2017 13:38:50 +0000 (15:38 +0200)]
qemu: process: Split out useful parts from qemuBuildNetworkDriveURI

Extract the part formatting the basic URI part so that it can be reused
to format JSON backing definitions. Parts specific to the command line
format will remain in qemuBuildNetworkDriveURI. The new function is
called qemuBlockStorageSourceGetURI.

7 years agoqemu: block: Use proper type for servers for VxHS disks
Peter Krempa [Mon, 23 Oct 2017 16:02:28 +0000 (18:02 +0200)]
qemu: block: Use proper type for servers for VxHS disks

Original implementation used 'SocketAddress' equivalent from qemu for
the disk server field, while qemu documentation specifies
'InetSocketAddress'. The backing store parser uses the correct parsing
function but the formatter used the incorrect one (and also with the
legacy mode enabled which was wrong).

7 years agoqemu: command: Move disk serial validation to qemuCheckDiskConfig
Peter Krempa [Wed, 1 Nov 2017 15:05:55 +0000 (16:05 +0100)]
qemu: command: Move disk serial validation to qemuCheckDiskConfig

7 years agoqemu: command: Move blkiotune checks to qemuCheckDiskConfig
Peter Krempa [Wed, 1 Nov 2017 10:47:19 +0000 (11:47 +0100)]
qemu: command: Move blkiotune checks to qemuCheckDiskConfig

7 years agoqemu: command: Refactor blkiotune checks to tolerate NULL qemuCaps
Peter Krempa [Wed, 1 Nov 2017 10:42:06 +0000 (11:42 +0100)]
qemu: command: Refactor blkiotune checks to tolerate NULL qemuCaps

To allow aggregating the checks, refactor the code to check capabilities
only if they were provided.

7 years agoqemu: command: Merge checks from qemuBuildDriveStrValidate to qemuCheckDiskConfig
Peter Krempa [Tue, 7 Nov 2017 13:32:02 +0000 (14:32 +0100)]
qemu: command: Merge checks from qemuBuildDriveStrValidate to qemuCheckDiskConfig

Stash all the disk definition and capability checks into one function.

7 years agoqemu: command: Refactor qemuBuildDriveStrValidate to make qemuCaps optional
Peter Krempa [Wed, 1 Nov 2017 10:17:20 +0000 (11:17 +0100)]
qemu: command: Refactor qemuBuildDriveStrValidate to make qemuCaps optional

To allow merging this with other disk type checks we need to check
qemuCaps only when available, since some of the checks are executed on
disk cold-plug and thus capabilities should not be checked.

Make the checks optional by making them conditional on qemuCaps not
being NULL.

7 years agoqemu: command: Directly report bus type in qemuBuildDriveStrValidate
Peter Krempa [Wed, 1 Nov 2017 10:02:41 +0000 (11:02 +0100)]
qemu: command: Directly report bus type in qemuBuildDriveStrValidate

All of the error message are already in a conditional block with known
bus type. Inline the bus type rather than formatting it from a separate
variable.

7 years agoqemu: command: Move disk index validation closer to usage
Peter Krempa [Wed, 1 Nov 2017 09:41:55 +0000 (10:41 +0100)]
qemu: command: Move disk index validation closer to usage

The disk index validation is used only in very specific cases and does
not need to be performed otherwise. Move it out of the global check into
the usage place.

7 years agoqemu: command: Remove dead code when formatting -drive
Peter Krempa [Wed, 1 Nov 2017 09:33:24 +0000 (10:33 +0100)]
qemu: command: Remove dead code when formatting -drive

busid and unitid are ever used only if the device is an SD card due to
the check in qemuDiskBusNeedsDeviceArg. Since the SD card does not have
an bus or unit number, most of the code and command line formatter can
be removed since it will never be used.

7 years agoutil: Fix condition check in virDiskNameToIndex
Peter Krempa [Wed, 1 Nov 2017 09:30:04 +0000 (10:30 +0100)]
util: Fix condition check in virDiskNameToIndex

Use the more common '< 0' rather than the non-zero check.

7 years agoqemu: Move memPath generation from memoryBackingDir to a separate function
Michal Privoznik [Mon, 23 Oct 2017 09:33:06 +0000 (11:33 +0200)]
qemu: Move memPath generation from memoryBackingDir to a separate function

In near future we will need more than just a plain VIR_STRDUP().
Better implement that in a separate function and in
qemuBuildMemoryBackendStr() which is complicated enough already.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agoconf: s/virDomainObjGetShortName/virDomainDefGetShortName/
Michal Privoznik [Mon, 23 Oct 2017 13:13:09 +0000 (15:13 +0200)]
conf: s/virDomainObjGetShortName/virDomainDefGetShortName/

This function works over domain definition and not domain object.
Its name is thus misleading.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agorpc,lockd: Add missing netserver refcount increment on reload
Nikolay Shirokovskiy [Tue, 24 Oct 2017 10:47:36 +0000 (13:47 +0300)]
rpc,lockd: Add missing netserver refcount increment on reload

After the virNetDaemonAddServerPostExec call in virtlogd we should have
netserver refcount set to 2. One goes to netdaemon servers hashtable
and one goes to virt{logd,lock} own reference to netserver. Let's add
the missing increment in virNetDaemonAddServerPostExec itself while
holding the daemon lock.

Since lockd defers management of the @srv object by the presence
in the hash table, virLockDaemonNewPostExecRestart must Unref the
alloc'd Ref on the @srv object done as part of virNetDaemonAddServerPostExec
and virNetServerNewPostExecRestart processing. The virNetDaemonGetServer
in lock_daemon main will also take a reference which is Unref'd during
main cleanup.

7 years agolockd: Need to Unref @srv when done with it.
John Ferlan [Sat, 28 Oct 2017 21:03:20 +0000 (17:03 -0400)]
lockd: Need to Unref @srv when done with it.

Commit id '252610f7d' used a hash table to store the @srv, but
didn't handle the virObjectUnref if virNetDaemonNew failed nor
did it use virObjectUnref once successfully placed into the table
which will now be managing it's lifetime (and would cause the
virObjectRef if successfully inserted into the table).

7 years agoconf: Don't inline virDomainNetTypeSharesHostView
Jiri Denemark [Thu, 2 Nov 2017 18:58:00 +0000 (19:58 +0100)]
conf: Don't inline virDomainNetTypeSharesHostView

When coverage build is enabled, gcc complains about it:

In file included from qemu/qemu_agent.h:29:0,
                 from qemu/qemu_driver.c:47:
qemu/qemu_driver.c: In function 'qemuDomainSetInterfaceParameters':
./conf/domain_conf.h:3397:1: error: inlining failed in call to
'virDomainNetTypeSharesHostView': call is unlikely and code size would
grow [-Werror=inline]
 virDomainNetTypeSharesHostView(const virDomainNetDef *net)
 ^

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
7 years agovirsh: Define multi line macros properly
Michal Privoznik [Tue, 31 Oct 2017 10:47:36 +0000 (11:47 +0100)]
virsh: Define multi line macros properly

In some cases there's dangling backward slash at the end of multi
line macros. While technically the code works, it will stop if
some empty lines are removed.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
7 years agodomain: Allow 'model' attribute for ide controller
Dawid Zamirski [Tue, 24 Oct 2017 19:35:32 +0000 (15:35 -0400)]
domain: Allow 'model' attribute for ide controller

The optional values are 'piix3', 'piix4' or 'ich6'. Those will be
needed to allow setting IDE controller model in VirtualBox driver.

7 years agovbox: Add more IStorageController API mappings
Dawid Zamirski [Tue, 24 Oct 2017 19:35:31 +0000 (15:35 -0400)]
vbox: Add more IStorageController API mappings

This patch exposes additional methods of the native VBOX API to the
libvirt 'unified' vbox API to deal with IStorageController. The exposed
methods are:

* IStorageController->GetStorageControllerType()
* IStorageController->SetStorageControllerType()
* IMachine->GetStorageControllers()

7 years agovbox: Support empty removable drives.
Dawid Zamirski [Tue, 24 Oct 2017 19:35:30 +0000 (15:35 -0400)]
vbox: Support empty removable drives.

Original code was checking for non empty disk source before proceeding
to actually attach disk device to VM. This prevented from creating
empty removable devices like DVD or floppy. Therefore, this patch
re-organizes the loop work-flow to allow such configurations as well as
makes the code follow better libvirt practices. Additionally, adjusted
debug logs to be more helpful - removed old ones and added new which
give more valuable info for troubleshooting.

7 years agovbox: Errors in vboxAttachDrives are now critical
Dawid Zamirski [Tue, 24 Oct 2017 19:35:29 +0000 (15:35 -0400)]
vbox: Errors in vboxAttachDrives are now critical

Previously, if one tried to define a VBOX VM and the API failed to
perform the requested actions for some reason, it would just log the
error and move on to process remaining disk definitions. This is not
desired as it could result in incorrectly defined VM without the caller
even knowing about it. So now all the code paths that call
virReportError are now treated as hard failures as they should have
been.

7 years agovbox: Remove unused mediumEmpty
Dawid Zamirski [Fri, 3 Nov 2017 11:49:32 +0000 (07:49 -0400)]
vbox: Remove unused mediumEmpty

Remove the setting since it's unused as of commit 34364df3 which should
have never copied it in from the old code which ended up getting removed
as part of commit c7c286c6.

7 years agovbox: Cleanup vboxAttachDrives implementation
Dawid Zamirski [Tue, 24 Oct 2017 19:35:28 +0000 (15:35 -0400)]
vbox: Cleanup vboxAttachDrives implementation

This commit primes vboxAttachDrives for further changes so when they
are made, the diff is less noisy:

* move variable declarations to the top of the function
* add disk variable to replace all the def->disks[i] instances
* add cleanup at the end of the loop body, so it's all in one place
  rather than scattered through the loop body. It's purposefully
  called 'cleanup' rather than 'skip' or 'continue' because future
  commit will treat errors as hard-failures.

7 years agovbox: vboxAttachDrives now relies on address info
Dawid Zamirski [Tue, 24 Oct 2017 19:35:27 +0000 (15:35 -0400)]
vbox: vboxAttachDrives now relies on address info

Previously, the driver was computing VBOX's devicePort/deviceSlot values
based on device name and max port/slot values. While this worked, it
completely ignored <address> values. Additionally, libvirt's built-in
virDomainDiskDefAssignAddress already does a good job  setting default
values on virDomainDeviceDriveAddress struct which we can use to set
devicePort and deviceSlot and accomplish the same result while allowing
the customizing those via XML. Also, this allows to remove some code
which will make further patches smaller.

7 years agovbox: Close media when undefining domains
Dawid Zamirski [Tue, 24 Oct 2017 19:35:25 +0000 (15:35 -0400)]
vbox: Close media when undefining domains

When registering a VM we call OpenMedium on each disk image which adds it
to vbox's global media registry. Therefore, we should make sure to call
Close when unregistering VM so we cleanup the media registry entries
after ourselves - this does not remove disk image files. This follows
the behaviour of the VBoxManage unregistervm command.

7 years agovbox: Update ATTRIBUTE_UNUSED usage
Dawid Zamirski [Tue, 24 Oct 2017 19:35:24 +0000 (15:35 -0400)]
vbox: Update ATTRIBUTE_UNUSED usage

Since the removal of VBOX <= 3x, the function arguments are actually
used so they should not be marked with ATTRIBUTE_UNUSED anymore.

7 years agocfg.mk: Prohibit backspace alignment attempts
Andrea Bolognani [Tue, 31 Oct 2017 13:12:52 +0000 (14:12 +0100)]
cfg.mk: Prohibit backspace alignment attempts

Now that our codebase is clean, we can add a syntax-check rule
to ensure it will remain so.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
7 years agoRemove backslash alignment attempts
Andrea Bolognani [Fri, 3 Nov 2017 12:09:47 +0000 (13:09 +0100)]
Remove backslash alignment attempts

Right-aligning backslashes when defining macros or using complex
commands in Makefiles looks cute, but as soon as any changes is
required to the code you end up with either distractingly broken
alignment or unnecessarily big diffs where most of the changes
are just pushing all backslashes a few characters to one side.

Generated using

  $ git grep -El '[[:blank:]][[:blank:]]\\$' | \
    grep -E '*\.([chx]|am|mk)$$' | \
    while read f; do \
      sed -Ei 's/[[:blank:]]*[[:blank:]]\\$/ \\/g' "$f"; \
    done

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
7 years agoqemu: domain: skip chain detection to end of backing chain
Peter Krempa [Fri, 29 Sep 2017 10:02:29 +0000 (12:02 +0200)]
qemu: domain: skip chain detection to end of backing chain

When a user provides the backing chain, we will not need to re-detect
all the backing stores again, but should move to the end of the user
specified chain. Additionally if a user provides a full terminated chain
we should not attempt any further detection.

7 years agoqemu: domain: Prepare TLS data for the whole backing chain
Peter Krempa [Fri, 20 Oct 2017 13:33:35 +0000 (15:33 +0200)]
qemu: domain: Prepare TLS data for the whole backing chain

Iterate through the backing chain when setting up TLS for disks.

7 years agoqemu: domain: Remove pointless alias check
Peter Krempa [Fri, 20 Oct 2017 13:12:49 +0000 (15:12 +0200)]
qemu: domain: Remove pointless alias check

When attaching the disks, aliases are always generated.