2010-12-16 16:10:54 +00:00
|
|
|
/*
|
|
|
|
* qemu_hostdev.c: QEMU hostdev management
|
|
|
|
*
|
2013-03-18 19:56:12 +00:00
|
|
|
* Copyright (C) 2006-2007, 2009-2013 Red Hat, Inc.
|
2010-12-16 16:10:54 +00:00
|
|
|
* Copyright (C) 2006 Daniel P. Berrange
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2012-09-20 22:30:55 +00:00
|
|
|
* License along with this library. If not, see
|
2012-07-21 10:06:23 +00:00
|
|
|
* <http://www.gnu.org/licenses/>.
|
2010-12-16 16:10:54 +00:00
|
|
|
*
|
|
|
|
* Author: Daniel P. Berrange <berrange@redhat.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
2013-09-19 15:01:17 +00:00
|
|
|
#include <dirent.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
#include <errno.h>
|
|
|
|
|
2010-12-16 16:10:54 +00:00
|
|
|
#include "qemu_hostdev.h"
|
2012-12-12 17:59:27 +00:00
|
|
|
#include "virlog.h"
|
2012-12-13 18:21:53 +00:00
|
|
|
#include "virerror.h"
|
2012-12-12 18:06:53 +00:00
|
|
|
#include "viralloc.h"
|
2012-12-13 14:52:25 +00:00
|
|
|
#include "virpci.h"
|
2012-12-12 17:04:51 +00:00
|
|
|
#include "virusb.h"
|
2013-05-03 18:07:29 +00:00
|
|
|
#include "virscsi.h"
|
2012-03-06 01:12:44 +00:00
|
|
|
#include "virnetdev.h"
|
2013-09-19 15:01:17 +00:00
|
|
|
#include "virfile.h"
|
2014-03-05 09:58:54 +00:00
|
|
|
#include "virhostdev.h"
|
2010-12-16 16:10:54 +00:00
|
|
|
|
2012-07-18 15:22:03 +00:00
|
|
|
#define VIR_FROM_THIS VIR_FROM_QEMU
|
|
|
|
|
2014-03-06 04:32:42 +00:00
|
|
|
int
|
|
|
|
qemuUpdateActivePciHostdevs(virQEMUDriverPtr driver,
|
|
|
|
virDomainDefPtr def)
|
|
|
|
{
|
|
|
|
virHostdevManagerPtr mgr = driver->hostdevMgr;
|
|
|
|
|
|
|
|
if (!def->nhostdevs)
|
|
|
|
return 0;
|
|
|
|
|
2014-03-06 04:59:29 +00:00
|
|
|
return virHostdevUpdateActivePciHostdevs(mgr, QEMU_DRIVER_NAME, def);
|
2014-03-06 04:32:42 +00:00
|
|
|
}
|
|
|
|
|
2014-03-06 04:45:16 +00:00
|
|
|
int
|
|
|
|
qemuUpdateActiveUsbHostdevs(virQEMUDriverPtr driver,
|
|
|
|
virDomainDefPtr def)
|
|
|
|
{
|
|
|
|
virHostdevManagerPtr mgr = driver->hostdevMgr;
|
|
|
|
|
|
|
|
if (!def->nhostdevs)
|
|
|
|
return 0;
|
|
|
|
|
2014-03-06 04:59:29 +00:00
|
|
|
return virHostdevUpdateActiveUsbHostdevs(mgr, QEMU_DRIVER_NAME, def);
|
2014-03-06 04:45:16 +00:00
|
|
|
}
|
|
|
|
|
2014-03-06 04:47:50 +00:00
|
|
|
int
|
|
|
|
qemuUpdateActiveScsiHostdevs(virQEMUDriverPtr driver,
|
|
|
|
virDomainDefPtr def)
|
|
|
|
{
|
|
|
|
virHostdevManagerPtr mgr = driver->hostdevMgr;
|
|
|
|
|
|
|
|
if (!def->nhostdevs)
|
|
|
|
return 0;
|
|
|
|
|
2014-03-06 04:59:29 +00:00
|
|
|
return virHostdevUpdateActiveScsiHostdevs(mgr, QEMU_DRIVER_NAME, def);
|
2014-03-06 04:47:50 +00:00
|
|
|
}
|
|
|
|
|
2013-10-08 13:47:36 +00:00
|
|
|
|
qemu: default to vfio for nodedev-detach
This patch resolves:
https://bugzilla.redhat.com/show_bug.cgi?id=1035188
Commit f094aaac48a6 changed the PCI device assignment in qemu domains
to default to using VFIO rather than legacy KVM device assignment
(when VFIO is available). It didn't change which driver was used by
default for virNodeDeviceDetachFlags(), though, so that API (and the
virsh nodedev-detach command) was still binding to the pci-stub
driver, used by legacy KVM assignment, by default.
This patch publicizes (only within the qemu module, though, so no
additions to the symbol exports are needed) the functions that check
for presence of KVM and VFIO device assignment, then uses those
functions to decide what to do when no driver is specified for
virNodeDeviceDetachFlags(); if the vfio driver is loaded, the device
will be bound to vfio-pci, or if legacy KVM assignment is supported on
this system, the device will be bound to pci-stub; if neither method
is available, the detach will fail.
2013-11-29 11:19:26 +00:00
|
|
|
bool
|
2013-09-19 15:01:17 +00:00
|
|
|
qemuHostdevHostSupportsPassthroughVFIO(void)
|
|
|
|
{
|
|
|
|
DIR *iommuDir = NULL;
|
|
|
|
struct dirent *iommuGroup = NULL;
|
|
|
|
bool ret = false;
|
|
|
|
|
|
|
|
/* condition 1 - /sys/kernel/iommu_groups/ contains entries */
|
|
|
|
if (!(iommuDir = opendir("/sys/kernel/iommu_groups/")))
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
while ((iommuGroup = readdir(iommuDir))) {
|
|
|
|
/* skip ./ ../ */
|
|
|
|
if (STRPREFIX(iommuGroup->d_name, "."))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
/* assume we found a group */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!iommuGroup)
|
|
|
|
goto cleanup;
|
|
|
|
/* okay, iommu is on and recognizes groups */
|
|
|
|
|
|
|
|
/* condition 2 - /dev/vfio/vfio exists */
|
|
|
|
if (!virFileExists("/dev/vfio/vfio"))
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
ret = true;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
if (iommuDir)
|
|
|
|
closedir(iommuDir);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#if HAVE_LINUX_KVM_H
|
|
|
|
# include <linux/kvm.h>
|
qemu: default to vfio for nodedev-detach
This patch resolves:
https://bugzilla.redhat.com/show_bug.cgi?id=1035188
Commit f094aaac48a6 changed the PCI device assignment in qemu domains
to default to using VFIO rather than legacy KVM device assignment
(when VFIO is available). It didn't change which driver was used by
default for virNodeDeviceDetachFlags(), though, so that API (and the
virsh nodedev-detach command) was still binding to the pci-stub
driver, used by legacy KVM assignment, by default.
This patch publicizes (only within the qemu module, though, so no
additions to the symbol exports are needed) the functions that check
for presence of KVM and VFIO device assignment, then uses those
functions to decide what to do when no driver is specified for
virNodeDeviceDetachFlags(); if the vfio driver is loaded, the device
will be bound to vfio-pci, or if legacy KVM assignment is supported on
this system, the device will be bound to pci-stub; if neither method
is available, the detach will fail.
2013-11-29 11:19:26 +00:00
|
|
|
bool
|
2013-09-19 15:01:17 +00:00
|
|
|
qemuHostdevHostSupportsPassthroughLegacy(void)
|
|
|
|
{
|
|
|
|
int kvmfd = -1;
|
|
|
|
bool ret = false;
|
|
|
|
|
|
|
|
if ((kvmfd = open("/dev/kvm", O_RDONLY)) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
# ifdef KVM_CAP_IOMMU
|
|
|
|
if ((ioctl(kvmfd, KVM_CHECK_EXTENSION, KVM_CAP_IOMMU)) <= 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
ret = true;
|
|
|
|
# endif
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
VIR_FORCE_CLOSE(kvmfd);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
#else
|
qemu: default to vfio for nodedev-detach
This patch resolves:
https://bugzilla.redhat.com/show_bug.cgi?id=1035188
Commit f094aaac48a6 changed the PCI device assignment in qemu domains
to default to using VFIO rather than legacy KVM device assignment
(when VFIO is available). It didn't change which driver was used by
default for virNodeDeviceDetachFlags(), though, so that API (and the
virsh nodedev-detach command) was still binding to the pci-stub
driver, used by legacy KVM assignment, by default.
This patch publicizes (only within the qemu module, though, so no
additions to the symbol exports are needed) the functions that check
for presence of KVM and VFIO device assignment, then uses those
functions to decide what to do when no driver is specified for
virNodeDeviceDetachFlags(); if the vfio driver is loaded, the device
will be bound to vfio-pci, or if legacy KVM assignment is supported on
this system, the device will be bound to pci-stub; if neither method
is available, the detach will fail.
2013-11-29 11:19:26 +00:00
|
|
|
bool
|
2013-09-19 15:01:17 +00:00
|
|
|
qemuHostdevHostSupportsPassthroughLegacy(void)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
static bool
|
|
|
|
qemuPrepareHostdevPCICheckSupport(virDomainHostdevDefPtr *hostdevs,
|
2013-09-20 08:39:51 +00:00
|
|
|
size_t nhostdevs,
|
|
|
|
virQEMUCapsPtr qemuCaps)
|
2013-09-19 15:01:17 +00:00
|
|
|
{
|
|
|
|
bool supportsPassthroughKVM = qemuHostdevHostSupportsPassthroughLegacy();
|
|
|
|
bool supportsPassthroughVFIO = qemuHostdevHostSupportsPassthroughVFIO();
|
|
|
|
size_t i;
|
|
|
|
|
|
|
|
/* assign defaults for hostdev passthrough */
|
|
|
|
for (i = 0; i < nhostdevs; i++) {
|
|
|
|
virDomainHostdevDefPtr hostdev = hostdevs[i];
|
|
|
|
int *backend = &hostdev->source.subsys.u.pci.backend;
|
|
|
|
|
|
|
|
if (hostdev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS)
|
|
|
|
continue;
|
|
|
|
if (hostdev->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
switch ((virDomainHostdevSubsysPciBackendType) *backend) {
|
2013-09-20 08:39:51 +00:00
|
|
|
case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_DEFAULT:
|
|
|
|
if (supportsPassthroughVFIO &&
|
|
|
|
virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VFIO_PCI)) {
|
|
|
|
*backend = VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO;
|
|
|
|
} else if (supportsPassthroughKVM &&
|
|
|
|
(virQEMUCapsGet(qemuCaps, QEMU_CAPS_PCIDEVICE) ||
|
|
|
|
virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE))) {
|
|
|
|
*backend = VIR_DOMAIN_HOSTDEV_PCI_BACKEND_KVM;
|
|
|
|
} else {
|
|
|
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
|
|
|
_("host doesn't support passthrough of "
|
|
|
|
"host PCI devices"));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
2013-09-19 15:01:17 +00:00
|
|
|
case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO:
|
|
|
|
if (!supportsPassthroughVFIO) {
|
|
|
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
|
|
|
_("host doesn't support VFIO PCI passthrough"));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_KVM:
|
|
|
|
if (!supportsPassthroughKVM) {
|
|
|
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
|
|
|
_("host doesn't support legacy PCI passthrough"));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_TYPE_LAST:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-03-05 11:37:51 +00:00
|
|
|
int
|
|
|
|
qemuPrepareHostdevPCIDevices(virQEMUDriverPtr driver,
|
|
|
|
const char *name,
|
|
|
|
const unsigned char *uuid,
|
|
|
|
virDomainHostdevDefPtr *hostdevs,
|
|
|
|
int nhostdevs,
|
|
|
|
virQEMUCapsPtr qemuCaps,
|
|
|
|
unsigned int flags)
|
|
|
|
{
|
|
|
|
int ret = -1;
|
|
|
|
virHostdevManagerPtr hostdev_mgr = driver->hostdevMgr;
|
|
|
|
|
|
|
|
if (!qemuPrepareHostdevPCICheckSupport(hostdevs, nhostdevs, qemuCaps))
|
|
|
|
goto out;
|
|
|
|
|
2014-03-05 11:47:40 +00:00
|
|
|
ret = virHostdevPreparePCIDevices(hostdev_mgr, QEMU_DRIVER_NAME,
|
|
|
|
name, uuid, hostdevs,
|
2014-03-05 11:37:51 +00:00
|
|
|
nhostdevs, flags);
|
2014-03-05 09:58:54 +00:00
|
|
|
out:
|
2010-12-16 16:10:54 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2014-03-06 05:31:47 +00:00
|
|
|
int
|
|
|
|
qemuPrepareHostUSBDevices(virQEMUDriverPtr driver,
|
|
|
|
const char *name,
|
|
|
|
virDomainHostdevDefPtr *hostdevs,
|
|
|
|
int nhostdevs,
|
|
|
|
unsigned int flags)
|
|
|
|
{
|
|
|
|
virHostdevManagerPtr hostdev_mgr = driver->hostdevMgr;
|
|
|
|
|
2014-03-06 05:42:19 +00:00
|
|
|
return virHostdevPrepareUSBDevices(hostdev_mgr, QEMU_DRIVER_NAME, name,
|
2014-03-06 05:31:47 +00:00
|
|
|
hostdevs, nhostdevs, flags);
|
|
|
|
}
|
|
|
|
|
2014-03-06 06:05:22 +00:00
|
|
|
int
|
|
|
|
qemuPrepareHostdevSCSIDevices(virQEMUDriverPtr driver,
|
|
|
|
const char *name,
|
|
|
|
virDomainHostdevDefPtr *hostdevs,
|
|
|
|
int nhostdevs)
|
|
|
|
{
|
|
|
|
size_t i;
|
|
|
|
virHostdevManagerPtr hostdev_mgr = driver->hostdevMgr;
|
|
|
|
|
|
|
|
/* Loop 1: Add the shared scsi host device to shared device
|
|
|
|
* table.
|
|
|
|
*/
|
|
|
|
for (i = 0; i < nhostdevs; i++) {
|
|
|
|
virDomainDeviceDef dev;
|
|
|
|
|
|
|
|
dev.type = VIR_DOMAIN_DEVICE_HOSTDEV;
|
|
|
|
dev.data.hostdev = hostdevs[i];
|
|
|
|
|
|
|
|
if (qemuAddSharedDevice(driver, &dev, name) < 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (qemuSetUnprivSGIO(&dev) < 0)
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2014-03-06 06:12:52 +00:00
|
|
|
return virHostdevPrepareSCSIDevices(hostdev_mgr, QEMU_DRIVER_NAME,
|
|
|
|
name, hostdevs, nhostdevs);
|
2014-03-06 06:05:22 +00:00
|
|
|
}
|
|
|
|
|
2013-10-08 13:47:36 +00:00
|
|
|
|
|
|
|
int
|
|
|
|
qemuPrepareHostDevices(virQEMUDriverPtr driver,
|
|
|
|
virDomainDefPtr def,
|
2013-09-20 08:39:51 +00:00
|
|
|
virQEMUCapsPtr qemuCaps,
|
2014-03-05 10:56:26 +00:00
|
|
|
unsigned int flags)
|
2010-12-16 16:10:54 +00:00
|
|
|
{
|
|
|
|
if (!def->nhostdevs)
|
|
|
|
return 0;
|
|
|
|
|
2013-01-16 12:09:58 +00:00
|
|
|
if (qemuPrepareHostdevPCIDevices(driver, def->name, def->uuid,
|
2013-09-20 08:39:51 +00:00
|
|
|
def->hostdevs, def->nhostdevs,
|
2014-03-05 10:56:26 +00:00
|
|
|
qemuCaps, flags) < 0)
|
2010-12-16 16:10:54 +00:00
|
|
|
return -1;
|
|
|
|
|
2014-03-05 06:20:50 +00:00
|
|
|
if (qemuPrepareHostUSBDevices(driver, def->name,
|
2014-03-05 11:12:04 +00:00
|
|
|
def->hostdevs, def->nhostdevs, flags) < 0)
|
2010-12-16 16:10:54 +00:00
|
|
|
return -1;
|
|
|
|
|
2013-05-03 18:07:29 +00:00
|
|
|
if (qemuPrepareHostdevSCSIDevices(driver, def->name,
|
|
|
|
def->hostdevs, def->nhostdevs) < 0)
|
|
|
|
return -1;
|
|
|
|
|
2010-12-16 16:10:54 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-03-05 11:53:51 +00:00
|
|
|
void
|
|
|
|
qemuDomainReAttachHostdevDevices(virQEMUDriverPtr driver,
|
|
|
|
const char *name,
|
|
|
|
virDomainHostdevDefPtr *hostdevs,
|
|
|
|
int nhostdevs)
|
|
|
|
{
|
|
|
|
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
|
|
|
|
char *oldStateDir = cfg->stateDir;
|
|
|
|
virHostdevManagerPtr hostdev_mgr = driver->hostdevMgr;
|
|
|
|
|
2014-03-05 11:55:45 +00:00
|
|
|
virHostdevReAttachPCIDevices(hostdev_mgr, QEMU_DRIVER_NAME, name,
|
2014-03-05 11:53:51 +00:00
|
|
|
hostdevs, nhostdevs, oldStateDir);
|
|
|
|
|
2013-01-10 21:03:14 +00:00
|
|
|
virObjectUnref(cfg);
|
2010-12-16 16:10:54 +00:00
|
|
|
}
|
|
|
|
|
2014-03-06 06:28:07 +00:00
|
|
|
void
|
|
|
|
qemuDomainReAttachHostUsbDevices(virQEMUDriverPtr driver,
|
|
|
|
const char *name,
|
|
|
|
virDomainHostdevDefPtr *hostdevs,
|
|
|
|
int nhostdevs)
|
|
|
|
{
|
|
|
|
virHostdevManagerPtr hostdev_mgr = driver->hostdevMgr;
|
|
|
|
|
2014-03-06 06:33:29 +00:00
|
|
|
virHostdevReAttachUsbHostdevs(hostdev_mgr, QEMU_DRIVER_NAME,
|
|
|
|
name, hostdevs, nhostdevs);
|
2014-03-06 06:28:07 +00:00
|
|
|
}
|
|
|
|
|
2013-10-08 13:47:36 +00:00
|
|
|
|
2013-05-03 18:07:29 +00:00
|
|
|
void
|
|
|
|
qemuDomainReAttachHostScsiDevices(virQEMUDriverPtr driver,
|
|
|
|
const char *name,
|
|
|
|
virDomainHostdevDefPtr *hostdevs,
|
|
|
|
int nhostdevs)
|
|
|
|
{
|
Convert 'int i' to 'size_t i' in src/qemu files
Convert the type of loop iterators named 'i', 'j', k',
'ii', 'jj', 'kk', to be 'size_t' instead of 'int' or
'unsigned int', also santizing 'ii', 'jj', 'kk' to use
the normal 'i', 'j', 'k' naming
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-07-08 14:09:33 +00:00
|
|
|
size_t i;
|
2014-03-05 09:58:54 +00:00
|
|
|
virHostdevManagerPtr hostdev_mgr = driver->hostdevMgr;
|
2013-05-03 18:07:29 +00:00
|
|
|
|
2014-03-05 09:58:54 +00:00
|
|
|
virObjectLock(hostdev_mgr->activeScsiHostdevs);
|
2013-05-03 18:07:29 +00:00
|
|
|
for (i = 0; i < nhostdevs; i++) {
|
|
|
|
virDomainHostdevDefPtr hostdev = hostdevs[i];
|
2014-01-29 17:22:42 +00:00
|
|
|
virSCSIDevicePtr scsi;
|
|
|
|
virSCSIDevicePtr tmp;
|
2013-05-03 18:07:38 +00:00
|
|
|
virDomainDeviceDef dev;
|
|
|
|
|
|
|
|
dev.type = VIR_DOMAIN_DEVICE_HOSTDEV;
|
|
|
|
dev.data.hostdev = hostdev;
|
|
|
|
|
|
|
|
ignore_value(qemuRemoveSharedDevice(driver, &dev, name));
|
2013-05-03 18:07:29 +00:00
|
|
|
|
|
|
|
if (hostdev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS ||
|
|
|
|
hostdev->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI)
|
|
|
|
continue;
|
|
|
|
|
2014-01-30 07:05:59 +00:00
|
|
|
if (!(scsi = virSCSIDeviceNew(NULL,
|
|
|
|
hostdev->source.subsys.u.scsi.adapter,
|
2013-05-03 18:07:29 +00:00
|
|
|
hostdev->source.subsys.u.scsi.bus,
|
|
|
|
hostdev->source.subsys.u.scsi.target,
|
|
|
|
hostdev->source.subsys.u.scsi.unit,
|
2014-01-08 14:51:29 +00:00
|
|
|
hostdev->readonly,
|
|
|
|
hostdev->shareable))) {
|
2013-05-03 18:07:29 +00:00
|
|
|
VIR_WARN("Unable to reattach SCSI device %s:%d:%d:%d on domain %s",
|
|
|
|
hostdev->source.subsys.u.scsi.adapter,
|
|
|
|
hostdev->source.subsys.u.scsi.bus,
|
|
|
|
hostdev->source.subsys.u.scsi.target,
|
|
|
|
hostdev->source.subsys.u.scsi.unit,
|
|
|
|
name);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Only delete the devices which are marked as being used by @name,
|
|
|
|
* because qemuProcessStart could fail on the half way. */
|
|
|
|
|
2014-03-05 09:58:54 +00:00
|
|
|
if (!(tmp = virSCSIDeviceListFind(hostdev_mgr->activeScsiHostdevs, scsi))) {
|
2013-05-03 18:07:29 +00:00
|
|
|
VIR_WARN("Unable to find device %s:%d:%d:%d "
|
|
|
|
"in list of active SCSI devices",
|
|
|
|
hostdev->source.subsys.u.scsi.adapter,
|
|
|
|
hostdev->source.subsys.u.scsi.bus,
|
|
|
|
hostdev->source.subsys.u.scsi.target,
|
|
|
|
hostdev->source.subsys.u.scsi.unit);
|
2014-01-29 17:22:42 +00:00
|
|
|
virSCSIDeviceFree(scsi);
|
2013-05-03 18:07:29 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2014-01-29 17:22:42 +00:00
|
|
|
VIR_DEBUG("Removing %s:%d:%d:%d dom=%s from activeScsiHostdevs",
|
|
|
|
hostdev->source.subsys.u.scsi.adapter,
|
|
|
|
hostdev->source.subsys.u.scsi.bus,
|
|
|
|
hostdev->source.subsys.u.scsi.target,
|
|
|
|
hostdev->source.subsys.u.scsi.unit,
|
|
|
|
name);
|
2013-05-03 18:07:29 +00:00
|
|
|
|
2014-03-05 09:58:54 +00:00
|
|
|
virSCSIDeviceListDel(hostdev_mgr->activeScsiHostdevs, tmp, QEMU_DRIVER_NAME, name);
|
2014-01-29 17:22:42 +00:00
|
|
|
virSCSIDeviceFree(scsi);
|
2013-05-03 18:07:29 +00:00
|
|
|
}
|
2014-03-05 09:58:54 +00:00
|
|
|
virObjectUnlock(hostdev_mgr->activeScsiHostdevs);
|
2013-05-03 18:07:29 +00:00
|
|
|
}
|
|
|
|
|
2013-10-08 13:47:36 +00:00
|
|
|
void
|
|
|
|
qemuDomainReAttachHostDevices(virQEMUDriverPtr driver,
|
|
|
|
virDomainDefPtr def)
|
2010-12-16 16:10:54 +00:00
|
|
|
{
|
|
|
|
if (!def->nhostdevs)
|
|
|
|
return;
|
|
|
|
|
2012-03-06 01:12:44 +00:00
|
|
|
qemuDomainReAttachHostdevDevices(driver, def->name, def->hostdevs,
|
|
|
|
def->nhostdevs);
|
2012-03-26 14:40:01 +00:00
|
|
|
|
|
|
|
qemuDomainReAttachHostUsbDevices(driver, def->name, def->hostdevs,
|
|
|
|
def->nhostdevs);
|
2013-05-03 18:07:29 +00:00
|
|
|
|
|
|
|
qemuDomainReAttachHostScsiDevices(driver, def->name, def->hostdevs,
|
|
|
|
def->nhostdevs);
|
2010-12-16 16:10:54 +00:00
|
|
|
}
|