Commit Graph

94 Commits

Author SHA1 Message Date
Andrea Bolognani
b8a625f384 hostdev: Mark PCI devices as inactive as they're detached
We want to eventually factor out the code dealing with device detaching
and reattaching, so that we can share it and make sure it's called eg.
when 'virsh nodedev-detach' is used.

For that to happen, it's important that the lists of active and inactive
PCI devices are updated every time a device changes its state.

Instead of passing NULL as the last argument of virPCIDeviceDetach() and
virPCIDeviceReattach(), pass the proper list so that it can be updated.
2015-12-21 11:21:00 +01:00
Andrea Bolognani
6d9cdd2a57 pci: Introduce virPCIStubDriver enumeration
This replaces the virPCIKnownStubs string array that was used
internally for stub driver validation.

Advantages:

  * possible values are well-defined
  * typos in driver names will be detected at compile time
  * avoids having several copies of the same string around
  * no error checking required when setting / getting value

The names used mirror those in the
virDomainHostdevSubsysPCIBackendType enumeration.
2015-12-21 11:17:22 +01:00
Andrea Bolognani
7743454165 pci: Use virPCIDeviceAddress in virPCIDevice
Instead of replicating the information (domain, bus, slot, function)
inside the virPCIDevice structure, use the already-existing
virPCIDeviceAddress structure.

For users of the module, this means that the object returned by
virPCIDeviceGetAddress() can no longer be NULL and must no longer
be freed by the caller.
2015-12-16 09:07:25 +01:00
Andrea Bolognani
2ab52f4af7 hostdev: Rename virHostdevUpdateDomainActiveDevices()
The new name, virHostdevUpdateActiveDomainDevices(), follows the
same naming conventions used by the rest of the module.

No functional changes.
2015-10-26 13:50:35 +01:00
Laine Stump
108d591b11 hostdev: skip ACS check when using VFIO for device assignment
The ACS checks are meaningless when using the more modern VFIO driver
for device assignment since VFIO has its own more complete and exact
checks, but I didn't realize that when I added support for VFIO. This
patch eliminates the ACS check when preparing PCI devices for
assignment if VFIO is being used.

This resolves:

  https://bugzilla.redhat.com/show_bug.cgi?id=1256486
2015-08-26 14:07:01 -04:00
Shivaprasad G Bhat
e3810db34f Allow vfio hotplug of a device to the domain which owns the iommu
The commit 7e72de4 didn't consider the hotplug scenarios. The patch addresses
the hotplug case whereby if atleast one of the pci function is owned by a
guest, the hotplug of other functions/devices in the same iommu group to the
same guest goes through successfully.

Signed-off-by: Shivaprasad G Bhat <sbhat@linux.vnet.ibm.com>
2015-08-06 17:55:03 +02:00
Eric Farman
22b8a61756 Convert SCSI logical unit from unsigned int to unsigned long long
The SCSI Architecture Model defines a logical unit address
as 64-bits in length, so change the field accordingly so
that the entire value could be stored.

Signed-off-by: Eric Farman <farman@linux.vnet.ibm.com>
2015-06-22 16:03:33 -04:00
Eric Farman
3b7983ad6d Print SCSI address attributes bus, target, unit as unsigned integer
The address elements are all unsigned integers, so we should
use the appropriate print directive when printing it.

Signed-off-by: Eric Farman <farman@linux.vnet.ibm.com>
2015-06-22 16:03:33 -04:00
John Ferlan
6f75779ece virhostdev: Fix comments for virHostdevReAttachPCIDevices
Pushed previous patch (commit id 'd45dadae6') too quickly...

The patch just updates the patch from Laine's suggestions.
2015-04-24 13:38:01 -04:00
Huanle Han
d45dadae6c hostdev: fix net config restore error
Fix for such a case:
1. Domain A and B xml contain the same SRIOV net hostdev(<interface
type='hostdev' /> with same pci address).
2. virsh start A (Successfully, and configure the SRIOV net with
custom mac)
3. virsh start B (Fail because of the hostdev used by domain A or other
reason.)
In step 3, 'virHostdevNetConfigRestore' is called for the hostdev
which is still used by domain A. It makes the mac/vlan of the SRIOV net
change.

Code Change in this fix:
1. As the pci used by other domain have been removed from
'pcidevs' in previous loop, we only restore the nic config for
the hostdev still in 'pcidevs'(used by this domain)
2. update the comments to make it more clear

Signed-off-by: Huanle Han <hanxueluo@gmail.com>
2015-04-24 12:28:59 -04:00
Huanle Han
7ec3f8051f hostdev: Create virHostdevIsPCINetDevice
Refactor some code to create a static function virHostdevIsPCINetDevice
which will detect whether the hostdev is a pci net device or not.

Signed-off-by: Huanle Han <hanxueluo@gmail.com>
2015-04-24 12:28:59 -04:00
Huanle Han
a959671da8 hostdev: fix loop index error when resetvfnetconfig
The variable 'last_processed_hostdev_vf' indicates index of the last
successfully configed vf. When resetvfnetconfig because of failure,
hostdevs[last_processed_hostdev_vf] should also be reset.

Signed-off-by: Huanle Han <hanxueluo@gmail.com>
2015-04-14 14:49:15 +02:00
Shivaprasad G Bhat
fb0ef7a60e hostdev: Report the domain name for used hostdevs during nodedev-detach
The nodedev-detach can report the name of the domain using the device
just the way nodedev-reattach does it.

Signed-off-by: Shivaprasad G Bhat <sbhat@linux.vnet.ibm.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2015-04-07 14:01:40 +02:00
Huanle Han
7adb4bfc80 hostdev: Fix index error in loop after remove an element
'virPCIDeviceList' is actually an array. Removing one element makes the
rest of the element move.

Use while loop, increase index only when not virPCIDeviceListDel(pcidevs, dev)

Signed-off-by: Huanle Han <hanxueluo@gmail.com>
2015-04-02 16:05:32 +02:00
Martin Kletzander
0e7457e501 Fix common misspellings
Wikipedia's list of common misspellings [1] has a machine-readable
version.  This patch fixes those misspellings mentioned in the list
which don't have multiple right variants (as e.g. "accension", which can
be both "accession" and "ascension"), such misspellings are left
untouched.  The list of changes was manually re-checked for false
positives.

[1] https://en.wikipedia.org/wiki/Wikipedia:Lists_of_common_misspellings/For_machines

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2015-03-23 09:01:30 +01:00
Shivaprasad G Bhat
7e72de49fe check IOMMU group devices usage when preparing device for vfio passthrough
The virsh start <domain> fails with qemu error when the hostdevices of the
same iommu group are used actively by other vms. It is not clear which
hostdev from the same iommu group is used by any of the running guests.
User has to go through every guest xml to figure out who is using the
hostdev of same iommu group.

Solution:
Iterate the iommu group of the hostdev and error our neatly in case a
device in the same iommu group is busy. Reattach code also does the same
kind of check, remove duplicate code as well.

Signed-off-by: Shivaprasad G Bhat <sbhat@linux.vnet.ibm.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-01-14 18:01:06 +01:00
John Ferlan
17bddc46f4 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.
2014-07-24 07:04:44 -04:00
John Ferlan
42957661dc 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
2014-07-24 06:39:28 -04:00
John Ferlan
5805621cd9 hostdev: Introduce virDomainHostdevSubsysSCSI
Create a separate typedef for the hostdev union data describing SCSI
Then adjust the code to use the new pointer
2014-07-24 06:39:27 -04:00
John Ferlan
1c8da0d44e hostdev: Introduce virDomainHostdevSubsysPCI
Create a separate typedef for the hostdev union data describing PCI.
Then adjust the code to use the new pointer
2014-07-24 06:39:27 -04:00
John Ferlan
7540d07f09 hostdev: Introduce virDomainHostdevSubsysUSB
Create a separate typedef for the hostdev union data describing USB.
Then adjust the code to use the new pointer
2014-07-24 06:39:27 -04:00
Daniel P. Berrange
3cfa19da22 Replace Pci with PCI throughout
Since it is an abbreviation, PCI should always be fully
capitalized or full lower case, never Pci.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2014-04-08 11:15:55 +01:00
Ján Tomko
63f22dc80f Create hostdevmgr in UserRuntimeDirectory for session libvirt
Without this, session libvirt won't start if it fails to create
the directory.
2014-03-28 10:07:52 +01:00
Ján Tomko
1fc4846b09 Remove double free in virHostdevManagerDispose
The object itself is freed by virObjectUnref.
2014-03-28 10:07:32 +01:00
Ján Tomko
bada4222e5 Indent top-level labels by one space in src/util/ 2014-03-25 14:58:40 +01:00
Daniel P. Berrange
2835c1e730 Add virLogSource variables to all source files
Any source file which calls the logging APIs now needs
to have a VIR_LOG_INIT("source.name") declaration at
the start of the file. This provides a static variable
of the virLogSource type.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2014-03-18 14:29:22 +00:00
Chunyan Liu
98c5c53d69 add hostdev pci backend type for xen
Add VIR_DOMAIN_HOSTDEV_PCI_BACKEND_XEN. For legacy xen, it will use "pciback" as
stub driver.
2014-03-12 17:03:23 +00:00
Chunyan Liu
7becc46225 Add parameter checks/annotations to hostdev APIs
Mark many parameters as NONNULL and check for empty list of
hostdevs.
2014-03-12 16:53:33 +00:00
Chunyan Liu
e991b09ddd add 3 wrapper functions for prepare/reattach/update domain hostdevs 2014-03-12 16:53:20 +00:00
Chunyan Liu
4dd9f103fa improve virHostdevUpdate* parameters to make it more widely used
Changes parameter from vm def to specific hostdevs info and name info, so that
it could be used more widely, e.g, could be used without full vm def info.
2014-03-12 16:41:32 +00:00
Daniel P. Berrange
a65e6d3626 Capitalize USB, PCI and SCSI in hostdev variables
Change any variable names with Usb, Pci or Scsi to use
USB, PCI and SCSI since they are abbreviations.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2014-03-12 16:38:18 +00:00
Daniel P. Berrange
e9a60dcc7c Remove redundant duplicated 'Hostdev' string method names
Some virHostdevXXXX methods included the string Hostdev again
as a suffix. Change the latter to Device instead.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2014-03-12 16:35:30 +00:00
Chunyan Liu
7be4bddea1 Capitalize USB, PCI and SCSI in hostdev methods
Change any method names with Usb, Pci or Scsi to use
USB, PCI and SCSI since they are abbreviations.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2014-03-12 16:20:01 +00:00
Daniel P. Berrange
b4bbaeef41 Fixed const-ness of parameters in netdev/hostdev code
Various methods in virnetdev.c and virhostdev.c were missing
const-ness for several char * parameters.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2014-03-12 16:03:06 +00:00
Chunyan Liu
1c6ee84c9d improve parameter name to let it more meaningful 2014-03-12 16:03:06 +00:00
Chunyan Liu
1fabf06ca5 move virHostdevNodeDevice* to virhostdev.c 2014-03-12 16:03:06 +00:00
Chunyan Liu
a4797138ad move virHostdevReAttachHostScsiDevices to virhostdev.c 2014-03-12 16:03:06 +00:00
Chunyan Liu
2d961cf3ba move virHostdevReAttachUsbHostdevs to virhostdev.c 2014-03-12 16:03:05 +00:00
Chunyan Liu
5035f75fed move virHostdevPrepareHostSCSIDevices to virhostdev.c 2014-03-12 16:03:05 +00:00
Chunyan Liu
1c310c609c move virHostdevPrepareHostUSBDevices to virhostdev.c 2014-03-12 16:03:05 +00:00
Chunyan Liu
00729f4559 move virHostdevUpdate* functions to virhostdev.c 2014-03-12 16:03:05 +00:00
Chunyan Liu
899b261127 move virHostdevPrepare(ReAttach)PCIDevices to virhostdev.c 2014-03-12 16:03:05 +00:00
Chunyan Liu
6b306d66fa virhostdev: use virObject to virHostdevManager to keep reference
Use virObject to virHostdevManager, so that each driver using virHostdevManager
can keep a reference to it, and through counting refs to make virHostdevManager
get freed.
2014-03-12 16:03:04 +00:00
Chunyan Liu
6b4c0a635e add virhostdev files to maintain global state of host devices
Signed-off-by: Chunyan Liu <cyliu@suse.com>
2014-03-04 12:28:45 +00:00