]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
10 years agosnapshot: conf: Enforce absolute paths on disk and memory images
Peter Krempa [Wed, 6 Aug 2014 13:17:00 +0000 (15:17 +0200)]
snapshot: conf: Enforce absolute paths on disk and memory images

RNG schema as well as the qemu driver requires absolute paths for memory
and disk snapshot image files but the XML parser was not enforcing it.
Add checks to avoid problems in qemu where the configuration it creates
is invalid.

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

10 years agoqemu: Make virFileFindHugeTLBFS fault tolerant
Michal Privoznik [Wed, 6 Aug 2014 08:37:48 +0000 (10:37 +0200)]
qemu: Make virFileFindHugeTLBFS fault tolerant

Since commit be0782e1 we are parsing /proc/meminfo to find out the
default huge page size. However, if the host we are running at does
not support any huge pages (e.g. CONFIG_HUGETLB_PAGE is turned off),
we will not successfully parse the meminfo file and hence the whole
qemu driver init process fails. Moreover, the default huge page size
is needed if and only if there's at least one hugetlbfs mount point.
So the fix consists of moving the virFileGetDefaultHugepageSize
function call after the first hugetlbfs mount point is found.

With this fix, we fail to start with one or more hugetlbfs mounts and
malformed meminfo file, but that's expected (how can one mount
hugetlbfs without kernel supporting huge pages?). Workaround in that
case is to umount all the hugetlbfs mounts.

Reported-by: Jim Fehlig <jfehlig@suse.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoNode Devices: Fix nodedev-list for fc_host & vports.
Prerna Saxena [Wed, 6 Aug 2014 10:20:11 +0000 (15:50 +0530)]
Node Devices: Fix nodedev-list for fc_host & vports.

In a system with Fiber Channel Host Adapters, a query to list all Fibre Channel
HBAs OR Vports currently returns empty list:
  $ virsh nodedev-list --cap fc_host

  $

Libvirt correctly discovers properties for all HBAs. However, the reporting
fails because of incorrect flag comparison while filtering these types.

This is fixed by removing references to 'VIR_CONNECT_LIST_NODE_DEVICES_CAP_*'
for comparison and replacing those with 'VIR_NODE_DEV_CAP_*'

Introduced by original commit id '652a2ec6'

Signed-off-by: Prerna Saxena <prerna@linux.vnet.ibm.com>
10 years agoqemu: reword caps-related error
Martin Kletzander [Tue, 5 Aug 2014 09:02:34 +0000 (11:02 +0200)]
qemu: reword caps-related error

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agoblockjob: correctly report active commit for job info
Eric Blake [Tue, 5 Aug 2014 14:49:32 +0000 (08:49 -0600)]
blockjob: correctly report active commit for job info

Commit 232a31b munged job info to report 'active commit' instead of
'commit' when generating events, but forgot to also munge the polling
variant of the command.

* src/qemu/qemu_driver.c (qemuDomainBlockJobImpl): Adjust type as
needed.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agoFix vlanid attribute name in nwfilter docs
Jianwei Hu [Tue, 5 Aug 2014 05:25:16 +0000 (13:25 +0800)]
Fix vlanid attribute name in nwfilter docs

'vlanid' is the attribute name in our XML,
'vlan-id' is the ebtables attribute:

[root@localhost ~]# virsh nwfilter-dumpxml myself
<filter name='myself' chain='root'>
  <uuid>7192ef51-cd50-4f14-ad7b-fa5c69ea19e3</uuid>
  <rule action='accept' direction='in' priority='500'>
    <vlan dstmacaddr='00:11:22:33:44:55' vlanid='44'/>
  </rule>
</filter>

[root@localhost ~]# ebtables -t nat -L
Bridge table: nat

...
-p 802_1Q -d 0:11:22:33:44:55 --vlan-id 44 -j ACCEPT

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

Signed-off-by: Ján Tomko <jtomko@redhat.com>
10 years agoDon't overwrite errors from virNetDevBandwidthSet
Ján Tomko [Mon, 28 Jul 2014 12:46:46 +0000 (14:46 +0200)]
Don't overwrite errors from virNetDevBandwidthSet

Otherwise this beautiful error would be overwritten when
the function is called with a really high rate number:

2014-07-28 12:51:47.920+0000: 2304: error : virCommandWait:2399 :
internal error: Child process (/sbin/tc class add dev vnet0 parent 1:
classid 1:1 htb rate 4294968kbps) unexpected exit status 1: Illegal "rate"
Usage: ... qdisc add ... htb [default N] [r2q N]
 default  minor id of class to which unclassified packets are sent {0}
 r2q      DRR quantums are computed as rate in Bps/r2q {10}
 debug    string of 16 numbers each 0-3 {0}

... class add ... htb rate R1 [burst B1] [mpu B] [overhead O]
                      [prio P] [slot S] [pslot PS]
                      [ceil R2] [cburst B2] [mtu MTU] [quantum Q]
 rate     rate allocated to this class (class can still borrow)
 burst    max bytes burst which can be accumulated during idle period {computed}
 mpu      minimum packet size used in rate computations
 overhead per-packet size overhead used in rate computations
 linklay  adapting to a linklayer e.g. atm
 ceil     definite upper class rate (no borrows) {rate}
 cburst   burst but for ceil {computed}
 mtu      max packet size we create rate map for {1600}
 prio     priority of leaf; lowe

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

10 years agovirsh: check if domiftune parameters fit into UINT
Ján Tomko [Thu, 26 Jun 2014 08:06:57 +0000 (10:06 +0200)]
virsh: check if domiftune parameters fit into UINT

We parse the bandwidth rates as unsinged long long,
then try to fit them in VIR_TYPED_PARAM_UINT.

Report an error if they exceed UINT_MAX instead of
quietly using wrong values.

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

10 years agostorage: Refresh storage pool after upload
John Ferlan [Mon, 28 Jul 2014 12:39:09 +0000 (08:39 -0400)]
storage: Refresh storage pool after upload

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

Upon successful upload of a volume, the target volume and storage pool
were not updated to reflect any changes as a result of the upload. Make
use of the existing stream close callback mechanism to force a backend
pool refresh to occur in a separate thread once the stream closes. The
separate thread should avoid potential deadlocks if the refresh needed
to wait on some event from the event loop which is used to perform
the stream callback.

10 years agoPost-release version bump for new dev cycle
Eric Blake [Wed, 2 Jul 2014 06:16:13 +0000 (08:16 +0200)]
Post-release version bump for new dev cycle

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agodomtop: Remove unused variable
Michal Privoznik [Mon, 4 Aug 2014 12:40:52 +0000 (14:40 +0200)]
domtop: Remove unused variable

The variable 'k' in the print_cpu_usage function is not used anywhere
and can fire a warning on some compilers.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agodomtop: Turn parse_argv into void
Michal Privoznik [Mon, 4 Aug 2014 12:37:14 +0000 (14:37 +0200)]
domtop: Turn parse_argv into void

Currently, the function follows the usual pattern used in our code:

  int ret = -1;
  ...
  ret = 0;
 cleanup:
  return ret;

However, the function always call exit() on error, so the cleanup
label is never jumped onto. Therefore, it doesn't make any sense to
have the parse_argv function return an integer value, if it
effectively can return only value of zero.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoqemu: fix comment in qemu.conf
Martin Kletzander [Thu, 31 Jul 2014 17:28:09 +0000 (19:28 +0200)]
qemu: fix comment in qemu.conf

There are multiple mount points after commit 725a211f, but one comment
wasn't changed to use plurals.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agoRelease of libvirt-1.2.7
Daniel Veillard [Sun, 3 Aug 2014 12:55:15 +0000 (08:55 -0400)]
Release of libvirt-1.2.7

* docs/news.html.in libvirt.spec.in: update for the release
* po/*.po*: update localizations and regenerate

10 years agobuild: fix build on cygwin
Eric Blake [Sun, 3 Aug 2014 02:47:36 +0000 (20:47 -0600)]
build: fix build on cygwin

Cygwin has getifaddrs(), but not AF_LINK, leading to:

util/virstats.c: In function 'virNetInterfaceStats':
util/virstats.c:138:41: error: 'AF_LINK' undeclared (first use in this function)
         if (ifa->ifa_addr->sa_family != AF_LINK)
...

* src/util/virstats.c (virNetInterfaceStats): Only use getifaddrs
if AF_LINK is present.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agonetwork: always set disable_ipv6, even when it should be 0
Laine Stump [Fri, 1 Aug 2014 21:51:37 +0000 (17:51 -0400)]
network: always set disable_ipv6, even when it should be 0

libvirt previously only touched an interface's disable_ipv6 setting in
sysfs if it needed to be set to 1, assuming that 0 is the
default. Apparently that isn't always the case though (kernel 3.15.7-1
in Arch Linux reportedly defaults a new interface's disable_ipv6
setting to 1) so this patch explicitly sets it to 0 or 1 as
appropriate.

10 years agoFix a crash when cloning a volume with no backing store
Ján Tomko [Fri, 1 Aug 2014 13:24:20 +0000 (15:24 +0200)]
Fix a crash when cloning a volume with no backing store

Introduced by commit 15213d1, not yet released.

10 years agodocs: bhyve: document recent changes
Roman Bogorodskiy [Thu, 24 Jul 2014 15:52:11 +0000 (19:52 +0400)]
docs: bhyve: document recent changes

 - mention that one disk and one network limitation
   is no longer current for 1.2.6 and newer
 - add 'cdrom' device to the sample domain XML

10 years agoblockcommit: turn on active commit
Eric Blake [Wed, 18 Jun 2014 23:16:27 +0000 (17:16 -0600)]
blockcommit: turn on active commit

With this in place, I can (finally!) now do:

virsh blockcommit $dom vda --shallow --verbose --pivot

and watch qemu shorten the backing chain by one, followed by
libvirt automatically updating the dumpxml output, effectively
undoing the work of virsh snapshot-commit --no-metadata --disk-only.
Commit is SOOOO much faster than blockpull, when I'm still fairly
close in time to when the temporary qcow2 wrapper file was created
via a snapshot operation!

* src/qemu/qemu_driver.c (qemuDomainBlockCommit): Implement live
commit.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agoblockcommit: track job type in xml
Eric Blake [Tue, 29 Jul 2014 03:46:44 +0000 (21:46 -0600)]
blockcommit: track job type in xml

A future patch is going to wire up qemu active block commit jobs;
but as they have similar events and are canceled/pivoted in the
same way as block copy jobs, it is easiest to track all bookkeeping
for the commit job by reusing the <mirror> element.  This patch
adds domain XML to track which job was responsible for creating a
mirroring situation, and adds a job='copy' attribute to all
existing uses of <mirror>.  Along the way, it also massages the
qemu monitor backend to read the new field in order to generate
the correct type of libvirt job (even though it requires a
future patch to actually cause a qemu event that can be reported
as an active commit).  It also prepares to update persistent XML
to match changes made to live XML when a copy completes.

* docs/schemas/domaincommon.rng: Enhance schema.
* docs/formatdomain.html.in: Document it.
* src/conf/domain_conf.h (_virDomainDiskDef): Add a field.
* src/conf/domain_conf.c (virDomainBlockJobType): String conversion.
(virDomainDiskDefParseXML): Parse job type.
(virDomainDiskDefFormat): Output job type.
* src/qemu/qemu_process.c (qemuProcessHandleBlockJob): Distinguish
active from regular commit.
* src/qemu/qemu_driver.c (qemuDomainBlockCopy): Set job type.
(qemuDomainBlockPivot, qemuDomainBlockJobImpl): Clean up job type
on completion.
* tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-mirror-old.xml:
Update tests.
* tests/qemuxml2argvdata/qemuxml2argv-disk-mirror.xml: Likewise.
* tests/qemuxml2argvdata/qemuxml2argv-disk-active-commit.xml: New
file.
* tests/qemuxml2xmltest.c (mymain): Drive new test.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agoDomain config: write <features/> if some capabilities are set.
Cédric Bosdonnat [Wed, 30 Jul 2014 09:20:59 +0000 (11:20 +0200)]
Domain config: write <features/> if some capabilities are set.

If all features are set to default (including the capabilities policy),
but some capabilities are toggled, we need to output the <features>
element when formatting the config.

10 years agodocs: fix an incorrect example for memoryBacking
Chen Hanxiao [Wed, 30 Jul 2014 03:03:15 +0000 (11:03 +0800)]
docs: fix an incorrect example for memoryBacking

commit 136ad49740f017aabcac48d02d2df6ab7b0195e9
forgot to add an end-tags for hugepages.

Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
10 years agoblockjob: properly track blockcopy xml changes on disk
Eric Blake [Tue, 29 Jul 2014 20:42:45 +0000 (14:42 -0600)]
blockjob: properly track blockcopy xml changes on disk

We were not directly saving the domain XML to file after starting
or finishing a blockcopy.  Without the startup write, a libvirtd
restart in the middle of a copy job would forget that the job was
underway.  Then at pivot, we were indirectly writing new XML in
reaction to events that occur as we stop and restart the guest CPUs.
But there was a race: since pivot is an async action, it is possible
that libvirtd is restarted before the pivot completes, so if XML
changes during the event, that change was not written.  The original
blockcopy code cleared out the <mirror> element prior to restarting
the CPUs, but this is also a race, observed if a user does an async
pivot and a dumpxml before the event occurs.  Furthermore, this race
will interfere with active commit in a future patch, because that
code will rely on the <mirror> element at the time of the qemu event
to determine whether to inform the user of a normal commit or an
active commit.

Fix things by saving state any time we modify live XML, while
delaying XML disk modifications until after the event completes.  We
still need a to teach libvirtd restarts to examine all existing
<mirror> elements to see if the job completed in the meantime (that
is, if libvirtd misses the event, the updated state still needs to be
updated in live XML), but that will be a later patch, in part because
we also need to to start taking advantage of newer qemu's ability to
keep the job around after completion rather than the current usage
where the job disappears both on error and on success.

* src/qemu/qemu_driver.c (qemuDomainBlockCopy): Track XML change
on disk.
(qemuDomainBlockJobImpl, qemuDomainBlockPivot): Move job-end XML
rewrites...
* src/qemu/qemu_process.c (qemuProcessHandleBlockJob): ...here.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agoblockcopy: add more XML for state tracking
Eric Blake [Mon, 28 Jul 2014 22:25:28 +0000 (16:25 -0600)]
blockcopy: add more XML for state tracking

Doing a blockcopy operation across a libvirtd restart is not very
robust at the moment.  In particular, we are clearing the <mirror>
element prior to telling qemu to finish the job.  Also, thanks to the
ability to request async completion, the user can easily regain
control prior to qemu actually finishing the effort, and they should
be able to poll the domain XML to see if the job is still going.

A future patch will fix things to actually wait until qemu is done
before modifying the XML to reflect the job completion.  But since
qemu issues identical BLOCK_JOB_COMPLETE events regardless of whether
the job was cancelled (kept the original disk) or completed (pivoted
to the new disk), we have to track which of the two operations were
used to end the job.  Furthermore, we'd like to avoid attempts to
end a job where we are already waiting on an earlier request to qemu
to end the job.  Likewise, if we miss the qemu event (perhaps because
it arrived during a libvirtd restart), we still need enough state
recorded to be able to determine how to modify the domain XML once
we reconnect to qemu and manually learn whether the job still exists.

Although this patch doesn't actually fix the problem, it is a
preliminary step that makes it possible to track whether a job
has already begun steps towards completion.

* src/conf/domain_conf.h (virDomainDiskMirrorState): New enum.
(_virDomainDiskDef): Convert bool mirroring to new enum.
* src/conf/domain_conf.c (virDomainDiskDefParseXML)
(virDomainDiskDefFormat): Handle new values.
* src/qemu/qemu_process.c (qemuProcessHandleBlockJob): Adjust
client.
* src/qemu/qemu_driver.c (qemuDomainBlockPivot)
(qemuDomainBlockJobImpl): Likewise.
* docs/schemas/domaincommon.rng (diskMirror): Expose new values.
* docs/formatdomain.html.in (elementsDisks): Document it.
* tests/qemuxml2argvdata/qemuxml2argv-disk-mirror.xml: Test it.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agoqemu: error out if PCI passthrough type is not supported
Hu Tao [Mon, 28 Jul 2014 08:45:23 +0000 (16:45 +0800)]
qemu: error out if PCI passthrough type is not supported

If PCI passthrough type is not supported, we should error out rather than
continue building the command line.

When starting a domain, the type has been already checked by
qemuPrepareHostdevPCICheckSupport() before building qemu command line,
so the problem doesn't emerge.

But when coverting a domain xml without specifying passthrough type explictly
to qemu arg, we will get a malformed command line.

the xml:

    <hostdev mode='subsystem' type='pci' managed='yes'>
      <source>
        <address domain='0x0001' bus='0x03' slot='0x00' function='0x0'/>
      </source>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
    </hostdev>

the converted command line:

  -device ,host=0001:03:00.0,id=hostdev0,bus=pci.0,addr=0x5

After this patch, virsh gives an error message:

  virsh domxml-to-native qemu-argv /tmp/tmp.xml
  error: internal error: invalid PCI passthrough type 'default'

Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
10 years agoqemu: Implement ./hugepages/page/[@size, @unit, @nodeset]
Michal Privoznik [Wed, 23 Jul 2014 15:37:21 +0000 (17:37 +0200)]
qemu: Implement ./hugepages/page/[@size, @unit, @nodeset]

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agodomain: Introduce ./hugepages/page/[@size, @unit, @nodeset]
Michal Privoznik [Wed, 23 Jul 2014 15:37:20 +0000 (17:37 +0200)]
domain: Introduce ./hugepages/page/[@size, @unit, @nodeset]

  <memoryBacking>
    <hugepages>
      <page size="1" unit="G" nodeset="0-3,5"/>
      <page size="2" unit="M" nodeset="4"/>
    </hugepages>
  </memoryBacking>

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agovirbitmap: Introduce virBitmapOverlaps
Michal Privoznik [Wed, 23 Jul 2014 15:37:19 +0000 (17:37 +0200)]
virbitmap: Introduce virBitmapOverlaps

This internal API just checks if two bitmaps intersect or not.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoqemu: Utilize virFileFindHugeTLBFS
Michal Privoznik [Wed, 23 Jul 2014 15:37:18 +0000 (17:37 +0200)]
qemu: Utilize virFileFindHugeTLBFS

Use better detection of hugetlbfs mount points. Yes, there can be
multiple mount points each serving different huge page size.

Since we already have ability to override the mount point in the
qemu.conf file, this crazy backward compatibility code is brought in.
Now we allow multiple mount points, so the "hugetlbfs_mount" option
must take an list of strings (mount points). But previously, it was
just a string, so we must accept both types now.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoIntroduce virFileFindHugeTLBFS
Michal Privoznik [Wed, 23 Jul 2014 15:37:17 +0000 (17:37 +0200)]
Introduce virFileFindHugeTLBFS

This should iterate over mount tab and search for hugetlbfs among with
looking for the default value of huge pages.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agostorage: create: Create files with correct mode
Peter Krempa [Mon, 28 Jul 2014 14:09:39 +0000 (16:09 +0200)]
storage: create: Create files with correct mode

Use correct mode when pre-creating files (for snapshots). The refactor
changing to storage driver usage caused a regression as some systems
created the file with 000 permissions forbidding qemu to write the file.

Pass mode to the creating functions to avoid the problem.

Regression since 185e07a5f82bc0692324f3ee13b4816d71b653c1.

10 years agoschema: bhyve and nmdm updates
Roman Bogorodskiy [Fri, 25 Jul 2014 16:43:49 +0000 (20:43 +0400)]
schema: bhyve and nmdm updates

* docs/schemas/domaincommon.rng: Add bhyve domain type, nmdm
  serial type and master and slave optional attributes for
  serial that are used by nmdm
* tests/domainschematest: Add bhyvexml2argvdata directory
  to validate bhyve XMLs

10 years agonodedev: fix a uninitialized variable build failure
Chen Hanxiao [Tue, 29 Jul 2014 02:05:08 +0000 (10:05 +0800)]
nodedev: fix a uninitialized variable build failure

Fix a -Werror=maybe-uninitialized warning

Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agonodedev: fix pci express memory leak
Eric Blake [Wed, 23 Jul 2014 04:38:30 +0000 (22:38 -0600)]
nodedev: fix pci express memory leak

Leak introduced in commit 16ebf10f (v1.2.6), detected by valgrind:

==9816== 216 (96 direct, 120 indirect) bytes in 6 blocks are definitely lost in loss record 665 of 821
==9816==    at 0x4A081D4: calloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==9816==    by 0x50836FB: virAlloc (viralloc.c:144)
==9816==    by 0x1DBDBE27: udevProcessPCI (node_device_udev.c:546)
==9816==    by 0x1DBDD79D: udevGetDeviceDetails (node_device_udev.c:1293)

* src/util/virpci.h (virPCIEDeviceInfoFree): New prototype.
* src/util/virpci.c (virPCIEDeviceInfoFree): New function.
* src/conf/node_device_conf.c (virNodeDevCapsDefFree): Clear
pci_express under pci case.
(virNodeDevCapPCIDevParseXML): Avoid leak.
* src/node_device/node_device_udev.c (udevProcessPCI): Likewise.
* src/libvirt_private.syms (virpci.h): Export it.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agonodedev: move pci express types to virpci.h
Eric Blake [Thu, 24 Jul 2014 01:52:22 +0000 (19:52 -0600)]
nodedev: move pci express types to virpci.h

Finding virPCIE* code is more intuitive if located in virpci.h
instead of node_device_conf.h.

* src/conf/node_device_conf.h (virPCIELinkSpeed, virPCIELink)
(virPCIEDeviceInfo): Move...
* src/util/virpci.h: ...here.
* src/conf/node_device_conf.c (virPCIELinkSpeed): Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agonodedev: let compiler help us on switches
Eric Blake [Thu, 24 Jul 2014 02:20:22 +0000 (20:20 -0600)]
nodedev: let compiler help us on switches

The compiler can alert us to places where we need to expand switch
statements because we add a new enum value, but only if we don't
have a default case.

* src/conf/node_device_conf.c (virNodeDeviceDefFormat)
(virNodeDevCapsDefParseXML, virNodeDevCapsDefFree): Drop default
case.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agoqemu: sound: Fix uninitialized model string
Peter Krempa [Mon, 28 Jul 2014 09:38:35 +0000 (11:38 +0200)]
qemu: sound: Fix uninitialized model string

Commit e5f36698e3efc3d258b2996c7423c47e05ec52b2 introduces a
false-positive build failure in the sound card model handling switch.
Initialize the model to NULL although the value should never be used.

10 years agoqemu: sound: Handle all possible sound cards in switch statement
Peter Krempa [Fri, 25 Jul 2014 08:24:40 +0000 (10:24 +0200)]
qemu: sound: Handle all possible sound cards in switch statement

Use correct type in the switch and handle all sound card models in it so
that the compiler tracks additions.

10 years agoconf: RNG: Always fill in default random source path for default backend
Peter Krempa [Fri, 25 Jul 2014 08:00:49 +0000 (10:00 +0200)]
conf: RNG: Always fill in default random source path for default backend

Libvirt documents that the default entropy source for the 'random'
backend of a RNG device is /dev/random. Instead of storing and
propagating NULL across our code and checking it in multiple places fill
the default in the post parse callback and use that in the other places.

10 years agospec: arm and aarch64 have kvm support with F20+
Cole Robinson [Fri, 18 Jul 2014 17:16:35 +0000 (13:16 -0400)]
spec: arm and aarch64 have kvm support with F20+

10 years agospec: Use power64 macro
Cole Robinson [Fri, 18 Jul 2014 17:15:45 +0000 (13:15 -0400)]
spec: Use power64 macro

Covers the whole ppc64 family. Example bug for binutils:

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

10 years agoqemu: Fix starting of VMs with empty CDROM drives
Peter Krempa [Fri, 25 Jul 2014 11:15:47 +0000 (13:15 +0200)]
qemu: Fix starting of VMs with empty CDROM drives

Since 24e5cafba6dbc2722e05f92dc0ae31b0f938f9f0 (thankfully unreleased)
when a VM with an empty disk drive would be started the code would call
stat() on NULL path as a check was missing from the callback rendering
machines unstartable.

Report success when the path is empty (denoting an empty drive).

10 years agolibvirt-guests: fix some typos in a comment
Martin Kletzander [Fri, 25 Jul 2014 09:46:10 +0000 (11:46 +0200)]
libvirt-guests: fix some typos in a comment

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agoutil: virTimeFieldsThenRaw never returns negative
James [Fri, 25 Jul 2014 08:13:57 +0000 (16:13 +0800)]
util: virTimeFieldsThenRaw never returns negative

virTimeFieldsThenRaw will never return negative result, so I clean up
the related meaningless judgements to make it better.

Signed-off-by: James <james.wangyufei@huawei.com>
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agolibvirt: Fix 'quest' typo in comment
Li Yang [Fri, 25 Jul 2014 07:53:45 +0000 (03:53 -0400)]
libvirt: Fix 'quest' typo in comment

Signed-off-by: Li Yang <liyang.fnst@cn.fujitsu.com>
10 years agotest: qemu: Add tests for multiple virtio-rng devices
Peter Krempa [Thu, 24 Jul 2014 13:15:20 +0000 (15:15 +0200)]
test: qemu: Add tests for multiple virtio-rng devices

10 years agovirtio-rng: allow multiple RNG devices
Peter Krempa [Mon, 25 Feb 2013 22:31:11 +0000 (23:31 +0100)]
virtio-rng: allow multiple RNG devices

qemu supports adding multiple RNG devices. This patch allows libvirt to
support this.

10 years agoqemu: cgroup: Don't use NULL path on default backed RNGs
Peter Krempa [Thu, 24 Jul 2014 13:47:39 +0000 (15:47 +0200)]
qemu: cgroup: Don't use NULL path on default backed RNGs

The "random" backend for virtio-rng can be started with no path
specified which equals to /dev/random. The cgroup code didn't consider
this and called few of the functions with NULL resulting into:

 $ virsh start rng-vm
 error: Failed to start domain rng-vm
 error: Path '(null)' is not accessible: Bad address

Problem introduced by commit c6320d34637a9883e31c4081d418fc33a4277cf2

10 years agoqemuConnectGetDomainCapabilities: Report error on unknown arch
Michal Privoznik [Thu, 24 Jul 2014 14:40:01 +0000 (16:40 +0200)]
qemuConnectGetDomainCapabilities: Report error on unknown arch

If user hasn't provided any @emulatorbin, the qemuCaps are
searched by @arch provided (which in fact can be guessed from the
host). However, there's no guarantee that the qemu binary for
@arch will exist.  Therefore qemu capabilities may be nonexistent
too. If that's the case, we should throw an error message prior
jumping onto 'cleanup' label as the helper lookup function
remains silent on no search result.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoremove range checking for blkiotune weight
Martin Kletzander [Thu, 24 Jul 2014 11:43:47 +0000 (13:43 +0200)]
remove range checking for blkiotune weight

This was changed before:

https://www.redhat.com/archives/libvir-list/2013-October/msg00525.html

but not everywhere in the code.

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agobhyve: cdrom support
Roman Bogorodskiy [Sat, 19 Jul 2014 15:15:26 +0000 (19:15 +0400)]
bhyve: cdrom support

Add support for CDROM devices for bhyve driver using
bhyve(8)'s 'ahci-cd' device type.

As bhyve currently does not support media insertion at runtime,
disallow to start a domain with an empty source path for cdrom
devices.

10 years agovirsh: add option for selecting domdisplay type
Martin Kletzander [Thu, 24 Jul 2014 12:23:12 +0000 (14:23 +0200)]
virsh: add option for selecting domdisplay type

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agovirsh: add error message when no graphical display is found
Martin Kletzander [Thu, 24 Jul 2014 12:18:23 +0000 (14:18 +0200)]
virsh: add error message when no graphical display is found

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agohostdev: Introduce virDomainHostdevSubsysSCSIiSCSI
John Ferlan [Wed, 9 Jul 2014 13:31:38 +0000 (09:31 -0400)]
hostdev: Introduce virDomainHostdevSubsysSCSIiSCSI

Create the structures and API's to hold and manage the iSCSI host device.
This extends the 'scsi_host' definitions added in commit id '5c811dce'.
A future patch will add the XML parsing, but that code requires some
infrastructure to be in place first in order to handle the differences
between a 'scsi_host' and an 'iSCSI host' device.

10 years agoAdd virConnectPtr for qemuBuildSCSIHostdevDrvStr
John Ferlan [Thu, 10 Jul 2014 15:16:15 +0000 (11:16 -0400)]
Add virConnectPtr for qemuBuildSCSIHostdevDrvStr

Add a conn for future patches to be able to grab the secret when
authenticating an iSCSI host device

10 years agohostdev: Introduce virDomainHostdevSubsysSCSIHost
John Ferlan [Fri, 20 Jun 2014 15:35:46 +0000 (11:35 -0400)]
hostdev: Introduce virDomainHostdevSubsysSCSIHost

Split virDomainHostdevSubsysSCSI further. In preparation for having
either SCSI or iSCSI data, create a union in virDomainHostdevSubsysSCSI
to contain just a virDomainHostdevSubsysSCSIHost to describe the
'scsi_host' host device

10 years agohostdev: Introduce virDomainHostdevSubsysSCSI
John Ferlan [Thu, 3 Jul 2014 21:01:10 +0000 (17:01 -0400)]
hostdev: Introduce virDomainHostdevSubsysSCSI

Create a separate typedef for the hostdev union data describing SCSI
Then adjust the code to use the new pointer

10 years agohostdev: Introduce virDomainHostdevSubsysPCI
John Ferlan [Thu, 3 Jul 2014 20:31:39 +0000 (16:31 -0400)]
hostdev: Introduce virDomainHostdevSubsysPCI

Create a separate typedef for the hostdev union data describing PCI.
Then adjust the code to use the new pointer

10 years agohostdev: Introduce virDomainHostdevSubsysUSB
John Ferlan [Thu, 3 Jul 2014 19:43:05 +0000 (15:43 -0400)]
hostdev: Introduce virDomainHostdevSubsysUSB

Create a separate typedef for the hostdev union data describing USB.
Then adjust the code to use the new pointer

10 years agoqemu: snapshot: Use storage driver to pre-create snapshot file
Peter Krempa [Mon, 30 Jun 2014 14:46:00 +0000 (16:46 +0200)]
qemu: snapshot: Use storage driver to pre-create snapshot file

Move the last operation done on local files to the storage driver API.

10 years agostorage: Implement virStorageFileCreate for local and gluster files
Peter Krempa [Mon, 30 Jun 2014 13:05:07 +0000 (15:05 +0200)]
storage: Implement virStorageFileCreate for local and gluster files

Add backends for this frontend function so that we can use it in the
snapshot creation code.

10 years agoqemu: Implement DAC driver chown callback to co-operate with storage drv
Peter Krempa [Thu, 10 Jul 2014 13:46:01 +0000 (15:46 +0200)]
qemu: Implement DAC driver chown callback to co-operate with storage drv

Use the storage driver to chown remote images.

10 years agosecurity: DAC: Plumb usage of chown callback
Peter Krempa [Thu, 10 Jul 2014 14:05:07 +0000 (16:05 +0200)]
security: DAC: Plumb usage of chown callback

Use the callback to set disk and storage image labels by modifying the
existing functions and adding wrappers to avoid refactoring a lot of the
code.

10 years agosecurity: DAC: Introduce callback to perform image chown
Peter Krempa [Thu, 10 Jul 2014 12:17:24 +0000 (14:17 +0200)]
security: DAC: Introduce callback to perform image chown

To integrate the security driver with the storage driver we need to
pass a callback for a function that will chown storage volumes.

Introduce and document the callback prototype.

10 years agosecurity: DAC: Remove superfluous link resolution
Peter Krempa [Thu, 10 Jul 2014 13:20:24 +0000 (15:20 +0200)]
security: DAC: Remove superfluous link resolution

When restoring security labels in the dac driver the code would resolve
the file path and use the resolved one to be chown-ed. The setting code
doesn't do that. Remove the unnecessary code.

10 years agostorage: Add witness for checking storage volume use in security driver
Peter Krempa [Wed, 9 Jul 2014 14:52:06 +0000 (16:52 +0200)]
storage: Add witness for checking storage volume use in security driver

With my intended use of storage driver assist to chown files on remote
storage we will need a witness that will tell us whether the given
storage volume supports operations needed by the storage driver.

10 years agostorage: Implement storage driver helper to chown disk images
Peter Krempa [Wed, 9 Jul 2014 14:42:10 +0000 (16:42 +0200)]
storage: Implement storage driver helper to chown disk images

Gluster storage works on a similar principle to NFS where it takes the
uid and gid of the actual process and uses it to access the storage
volume on the remote server. This introduces a need to chown storage
files on gluster via native API.

10 years agoqemuConnectGetDomainCapabilities: Use wiser defaults
Michal Privoznik [Thu, 17 Jul 2014 09:06:09 +0000 (11:06 +0200)]
qemuConnectGetDomainCapabilities: Use wiser defaults

Up to now, users have to pass two arguments at least: domain virt type
('qemu' vs 'kvm') and one of emulatorbin or architecture. This is not
much user friendly. Nowadays users mostly use KVM and share the host
architecture with the guest. So now, the API (and subsequently virsh
command) can be called with all NULLs  (without any arguments).

Before this patch:
 # virsh domcapabilities
 error: failed to get emulator capabilities
 error: virttype_str in qemuConnectGetDomainCapabilities must not be NULL

 # virsh domcapabilities kvm
 error: failed to get emulator capabilities
 error: invalid argument: at least one of emulatorbin or architecture fields must be present

After:

 # virsh domcapabilities
 <domainCapabilities>
   <path>/usr/bin/qemu-system-x86_64</path>
   <domain>kvm</domain>
   <machine>pc-i440fx-2.1</machine>
   <arch>x86_64</arch>
   <vcpu max='255'/>
 </domainCapabilities>

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agonumatune: finish the split from domain_conf and remove all dependencies
Martin Kletzander [Mon, 21 Jul 2014 09:32:33 +0000 (11:32 +0200)]
numatune: finish the split from domain_conf and remove all dependencies

This patch adds back the virDomainDef typedef into domain_conf and
makes all the numatune_conf functions independent of any virDomainDef
definitions.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agoleaseshelper: avoid mem leak after storing lease entries
Nehal J Wani [Wed, 23 Jul 2014 22:05:13 +0000 (03:35 +0530)]
leaseshelper: avoid mem leak after storing lease entries

Contents of existing lease file were being stored in a variable
which was never freed.

10 years agomaint: simplify some syntax check exemptions
Eric Blake [Fri, 18 Jul 2014 21:22:08 +0000 (15:22 -0600)]
maint: simplify some syntax check exemptions

Commit 5028160 accidentally weakened the strtol prohibitions to
skip ALL files under src/util instead of the former situation of
just protecting util/virsexpr.c; even though NONE of the files
in that directory need any protection.

Shorten some long lines while at it.

* cfg.mk (exclude_file_name_regexp--sc_prohibit_strtol): No need
to exclude all of util.
(exclude_file_name_regexp--sc_prohibit_sprintf): Reduce long line.
(exclude_file_name_regexp--sc_prohibit_raw_allocation): Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agoconf: avoid memory leaks while parsing seclabel
Eric Blake [Wed, 23 Jul 2014 04:02:56 +0000 (22:02 -0600)]
conf: avoid memory leaks while parsing seclabel

Our seclabel parsing was repeatedly assigning malloc'd data into a
temporary variable, without first freeing the previous use.  Among
other leaks flagged by valgrind:

==9312== 8 bytes in 1 blocks are definitely lost in loss record 88 of 821
==9312==    at 0x4A0645D: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==9312==    by 0x8C40369: strdup (strdup.c:42)
==9312==    by 0x50EA799: virStrdup (virstring.c:676)
==9312==    by 0x50FAEB9: virXPathString (virxml.c:90)
==9312==    by 0x50FAF1E: virXPathStringLimit (virxml.c:112)
==9312==    by 0x510F516: virSecurityLabelDefParseXML (domain_conf.c:4571)
==9312==    by 0x510FB20: virSecurityLabelDefsParseXML (domain_conf.c:4720)

While it was multiple problems, it looks like commit da78351 (thankfully
unreleased) was to blame for all of them.

* src/conf/domain_conf.c (virSecurityLabelDefParseXML): Plug leaks
detected by valgrind.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agonwfilter: plug memory leak with firewall
Eric Blake [Wed, 23 Jul 2014 04:18:07 +0000 (22:18 -0600)]
nwfilter: plug memory leak with firewall

Introduced in commit 70571ccc (v1.2.4). Caught by valgrind:

==9816== 170 (32 direct, 138 indirect) bytes in 1 blocks are definitely lost in loss record 646 of 821
==9816==    at 0x4A081D4: calloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==9816==    by 0x50836FB: virAlloc (viralloc.c:144)
==9816==    by 0x50AEC2B: virFirewallNew (virfirewall.c:204)
==9816==    by 0x1E2308ED: ebiptablesDriverProbeStateMatch (nwfilter_ebiptables_driver.c:3715)
==9816==    by 0x1E2309AD: ebiptablesDriverInit (nwfilter_ebiptables_driver.c:3742)

* src/nwfilter/nwfilter_ebiptables_driver.c
(ebiptablesDriverProbeStateMatch): Properly clean up.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agometadata: track title edits across libvirtd restart
Eric Blake [Tue, 22 Jul 2014 15:41:05 +0000 (09:41 -0600)]
metadata: track title edits across libvirtd restart

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

Although the edits were changing in-memory XML, it was not flushed
to disk; so unless some other action changes XML, a libvirtd restart
would lose the changed information.

* src/conf/domain_conf.c (virDomainObjSetMetadata): Add parameter,
to save live status across restarts.
(virDomainSaveXML): Allow for test driver.
* src/conf/domain_conf.h (virDomainObjSetMetadata): Adjust
signature.
* src/bhyve/bhyve_driver.c (bhyveDomainSetMetadata): Adjust caller.
* src/lxc/lxc_driver.c (lxcDomainSetMetadata): Likewise.
* src/qemu/qemu_driver.c (qemuDomainSetMetadata): Likewise.
* src/test/test_driver.c (testDomainSetMetadata): Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agodocs: Point to list of valid pool target volume formats
John Ferlan [Wed, 23 Jul 2014 12:36:50 +0000 (08:36 -0400)]
docs: Point to list of valid pool target volume formats

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

Rather than point off to some nefarious "pool-specific docs" page when
describing the "format" field for the target pool provide a link to the
storage driver page which describes the various valid formats for each
pool type.  Also make it a bit more clear that if a valid format isn't
specified, then the type field is ignored.

10 years agospec: Enable sanlock on qemu_kvm_arches for RHEL
Jiri Denemark [Wed, 23 Jul 2014 07:04:22 +0000 (09:04 +0200)]
spec: Enable sanlock on qemu_kvm_arches for RHEL

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
10 years agoAdded myself in AUTHORS.in
Cédric Bosdonnat [Wed, 23 Jul 2014 14:23:46 +0000 (16:23 +0200)]
Added myself in AUTHORS.in

10 years agoDocumented VIR_DOMAIN_FEATURE_CAPABILITIES use of virDomainCapabilitesPolicy
Cédric Bosdonnat [Wed, 23 Jul 2014 14:21:59 +0000 (16:21 +0200)]
Documented VIR_DOMAIN_FEATURE_CAPABILITIES use of virDomainCapabilitesPolicy

10 years agoIntroduce virTristateSwitch enum
Ján Tomko [Fri, 27 Jun 2014 15:18:53 +0000 (17:18 +0200)]
Introduce virTristateSwitch enum

For the values "default", "on", "off"

Replaces
virDeviceAddressPCIMulti
virDomainFeatureState
virDomainIoEventFd
virDomainVirtioEventIdx
virDomainDiskCopyOnRead
virDomainMemDump
virDomainPCIRombarMode
virDomainGraphicsSpicePlaybackCompression

10 years agoIntroduce virTristateBool enum type
Ján Tomko [Fri, 27 Jun 2014 15:16:54 +0000 (17:16 +0200)]
Introduce virTristateBool enum type

Replace all three-state (default/yes/no) enums with it:
virDomainBIOSUseserial
virDomainBootMenu
virDomainPMState
virDomainGraphicsSpiceClipboardCopypaste
virDomainGraphicsSpiceAgentFileTransfer
virNetworkDNSForwardPlainNames

10 years agoFix build after 47e5b5ae3262f140955abd57bbb13337c65a3497
Peter Krempa [Wed, 23 Jul 2014 08:19:20 +0000 (10:19 +0200)]
Fix build after 47e5b5ae3262f140955abd57bbb13337c65a3497

The patch described above introduced two problems caught by the compiler
and thus breaking the build.

One of the problems was comparison of unsigned with < 0 and the second
one jumped a variable init.

10 years agoLXC: show used memory as 0 when domain is not active
Chen Hanxiao [Thu, 17 Jul 2014 09:28:29 +0000 (17:28 +0800)]
LXC: show used memory as 0 when domain is not active

Before:
virsh # dominfo chx3
State:          shut off
Max memory:     92160 KiB
Used memory:    92160 KiB

After:
virsh # dominfo container1
State:          shut off
Max memory:     92160 KiB
Used memory:    0 KiB

Similar to qemu cases.

Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
10 years agolxc domain from xml: convert lxc.cap.drop
Cédric Bosdonnat [Fri, 18 Jul 2014 08:02:30 +0000 (10:02 +0200)]
lxc domain from xml: convert lxc.cap.drop

10 years agolxc: allow to keep or drop capabilities
Cédric Bosdonnat [Fri, 18 Jul 2014 08:02:29 +0000 (10:02 +0200)]
lxc: allow to keep or drop capabilities

Added <capabilities> in the <features> section of LXC domains
configuration. This section can contain elements named after the
capabilities like:

  <mknod state="on"/>, keep CAP_MKNOD capability
  <sys_chroot state="off"/> drop CAP_SYS_CHROOT capability

Users can restrict or give more capabilities than the default using
this mechanism.

10 years agoLXC: create a bind mount for sysfs when enable userns but disable netns
Chen Hanxiao [Mon, 14 Jul 2014 10:01:51 +0000 (18:01 +0800)]
LXC: create a bind mount for sysfs when enable userns but disable netns

kernel commit 7dc5dbc879bd0779924b5132a48b731a0bc04a1e
forbid us doing a fresh mount for sysfs
when enable userns but disable netns.
This patch will create a bind mount in this senario.

Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
10 years agotests: Remove stale scsihostdata dir
Michal Privoznik [Tue, 22 Jul 2014 09:06:21 +0000 (11:06 +0200)]
tests: Remove stale scsihostdata dir

In the fbd91d49 commit, new scsihostdata dir is added to EXTRA_DIST in
the tests/Makefile.am. However, the directory itself is not created
anywhere, nor in the commit.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoqemu: snapshot: Forbid taking/reverting snapshots in PMSUSPENDED state
Peter Krempa [Mon, 21 Jul 2014 13:48:35 +0000 (15:48 +0200)]
qemu: snapshot: Forbid taking/reverting snapshots in PMSUSPENDED state

Qemu doesn't currently support them and behaves strangely. Just forbid
them.

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

10 years agoqemu: snapshot: Forbid taking snapshot in invalid state
Peter Krempa [Mon, 21 Jul 2014 13:20:43 +0000 (15:20 +0200)]
qemu: snapshot: Forbid taking snapshot in invalid state

Similarly to 49a3a649a85f9d3d478be355aa8694bce889586a forbid creating
snapshots in domain states impossible to reach in qemu.

10 years agodomtop: Fix build on mingw
Michal Privoznik [Mon, 21 Jul 2014 15:26:57 +0000 (17:26 +0200)]
domtop: Fix build on mingw

Firstly, there's no sigaction() nor struct sigaction on mingw. We have
to use the one implemented by gnulib (and hence link with gnulib).
Then, for some reason one header file from windows defines ERROR
symbol. Yes it does. Sigh.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agobuild: fix build without numactl
Eric Blake [Mon, 21 Jul 2014 17:24:21 +0000 (11:24 -0600)]
build: fix build without numactl

Under ./configure --without-numactl but with numactl-devel installed,
the build fails with:

../../src/util/virnuma.c: In function 'virNumaNodeIsAvailable':
../../src/util/virnuma.c:407:5: error: implicit declaration of function 'numa_bitmask_isbitset' [-Werror=implicit-function-declaration]
     return numa_bitmask_isbitset(numa_nodes_ptr, node);
     ^

and other failures, all because the configure results for particular
functions were used without regard to whether libnuma was even being
linked in.

* src/util/virnuma.c (virNumaGetPages): Fix message typo.
(virNumaNodeIsAvailable): Correct build when not using numactl.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agostorage: logical: drop useless if
Roman Bogorodskiy [Mon, 21 Jul 2014 17:08:58 +0000 (21:08 +0400)]
storage: logical: drop useless if

virStorageBackendLogicalCreateVol contains a piece like:

    if (vol->target.path != NULL) {
        /* A target path passed to CreateVol has no meaning */
        VIR_FREE(vol->target.path);
    }

The 'if' is useless here, but 'syntax-check' doesn't catch that
because of the comment, so drop the 'if'.

10 years agoFix build on non-Linux platforms
Roman Bogorodskiy [Mon, 21 Jul 2014 17:26:00 +0000 (21:26 +0400)]
Fix build on non-Linux platforms

Commit ef48a1b introduced virFindSCSIHostByPCI for Linux and
a stub for other platforms that returns -1 while the function
should return 'char *', so use 'return NULL' instead.

Commit fbd91d4 introduced virReadSCSIUniqueId with the third
argument 'int *result', however the stub for non-Linux patform
uses 'unsigned int *result', so change it to 'int *result'.

Pushed under the build breaker rule.

10 years agogetAdapterName: Lookup stable scsi_host
John Ferlan [Mon, 9 Jun 2014 16:19:16 +0000 (12:19 -0400)]
getAdapterName: Lookup stable scsi_host

If a parentaddr was provided in the XML, have getAdapterName lookup
the stable address.  This allows virStorageBackendSCSICheckPool() and
virStorageBackendSCSIRefreshPool() to automagically find the scsi_host
by its PCI address and unique_id

10 years agoscsi_host: Introduce virFindSCSIHostByPCI
John Ferlan [Tue, 10 Jun 2014 11:47:12 +0000 (07:47 -0400)]
scsi_host: Introduce virFindSCSIHostByPCI

Introduce a new function to parse the provided scsi_host parent address
and unique_id value in order to find the /sys/class/scsi_host directory
which will allow a stable SCSI host address

Add a test to scsihosttest to lookup the host# name by using the PCI address
and unique_id value

10 years agoAdd unique_id to nodedev output
John Ferlan [Thu, 5 Jun 2014 17:17:05 +0000 (13:17 -0400)]
Add unique_id to nodedev output

Add an optional unique_id parameter to nodedev.  Allows for easier lookup
and display of the unique_id value in order to document for use with
scsi_host code.

10 years agovirutil: Introduce virReadSCSIUniqueId
John Ferlan [Tue, 10 Jun 2014 15:09:20 +0000 (11:09 -0400)]
virutil: Introduce virReadSCSIUniqueId

Introduce a new function to read the current scsi_host entry and return
the value found in the 'unique_id' file.

Add a 'scsihosttest' test (similar to the fchosttest, but incorporating some
of the concepts of the mocked pci test library) in order to read the
unique_id file like would be found in the /sys/class/scsi_host tree.

10 years agoscsi_backend: Use existing LINUX_SYSFS_SCSI_HOST_PREFIX definition
John Ferlan [Mon, 9 Jun 2014 16:41:04 +0000 (12:41 -0400)]
scsi_backend: Use existing LINUX_SYSFS_SCSI_HOST_PREFIX definition

Rather than supplying the path again in the formatting of the sysfs
scsi_host directory.

10 years agostorage: Introduce parentaddr into virStoragePoolSourceAdapter
Osier Yang [Tue, 4 Mar 2014 03:15:13 +0000 (22:15 -0500)]
storage: Introduce parentaddr into virStoragePoolSourceAdapter

Between reboots and kernel reloads, the SCSI host number used for SCSI
storage pools may change requiring modification to the storage pool XML
in order to use a specific SCSI host adapter.

This patch introduces the "parentaddr" element and "unique_id" attribute
for the SCSI host adapter in order to uniquely identify the adapter
between reboots and kernel reloads. For now the goal is to only parse
and format the XML. Both will be required to be provided in order to
uniquely identify the desired SCSI host.

The new XML is expected to be as follows:

  <adapter type='scsi_host'>
    <parentaddr unique_id='3'>
      <address domain='0x0000' bus='0x00' slot='0x1f' func='0x2'/>
    </parentaddr>
  </adapter>

where "parentaddr" is the parent device of the SCSI host using the PCI
address on which the device resides and the value from the unique_id file
for the device. Both the PCI address and unique_id values will be used
to traverse the /sys/class/scsi_host/ directories looking at each link
to match the PCI address reformatted to the directory link format where
"domain:bus:slot:function" is found.  Then for each matching directory
the unique_id file for the scsi_host will be used to match the unique_id
value in the xml.

For a PCI address listed above, this will be formatted to "0000:00:1f.2"
and the links in /sys/class/scsi_host will be used to find the host#
to be used for the 'scsi_host' device. Each entry is a link to the
/sys/bus/pci/devices directories, e.g.:

%  ls -al /sys/class/scsi_host/host2
lrwxrwxrwx. 1 root root 0 Jun  1 00:22 /sys/class/scsi_host/host2 -> ../../devices/pci0000:00/0000:00:1f.2/ata3/host2/scsi_host/host2

% cat /sys/class/scsi_host/host2/unique_id
3

The "parentaddr" and "name" attributes are mutually exclusive to identify
the SCSI host number. Use of the "parentaddr" element will be the preferred
mechanism.

This patch only supports to parse and format the XMLs. Later patches will
add code to find out the scsi host number.

10 years agovirStoragePoolSourceAdapter: Refine the SCSI_HOST adapter name
Osier Yang [Mon, 3 Mar 2014 20:04:17 +0000 (15:04 -0500)]
virStoragePoolSourceAdapter: Refine the SCSI_HOST adapter name

Preparation for future patches by creating a scsi_host union. For now,
just the 'name' will be present.

10 years agogetAdapterName: check for SCSI_HOST
John Ferlan [Mon, 3 Mar 2014 19:57:50 +0000 (14:57 -0500)]
getAdapterName: check for SCSI_HOST

Rather than assume that NOT FC_HOST is SCSI_HOST, let's call them out
specifically. Makes it easier to find SCSI_HOST code/structs and ensures
something isn't missed in the future