提交 cad14a52 编写于 作者: L Laine Stump

xen: implement virNodeDeviceDetachFlags backend

This was the only hypervisor driver other than qemu that implemented
virNodeDeviceDettach. It doesn't currently support multiple pci device
assignment driver backends, but it is simple to plug in this new API,
which will make it easier for Xen people to fill it in later when they
decide to support VFIO (or whatever other) device assignment. Also it
means that management applications will have the same API available to
them for both hypervisors on any given version of libvirt.

The only acceptable value for driverName in this case is NULL, since
there is no alternate, and I'm not willing to pick a name for the
default driver used by Xen.
上级 eaff1611
/*
* xen_driver.c: Unified Xen driver.
*
* Copyright (C) 2007-2012 Red Hat, Inc.
* Copyright (C) 2007-2013 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -2133,12 +2133,16 @@ out:
}
static int
xenUnifiedNodeDeviceDettach(virNodeDevicePtr dev)
xenUnifiedNodeDeviceDetachFlags(virNodeDevicePtr dev,
const char *driverName,
unsigned int flags)
{
virPCIDevicePtr pci;
unsigned domain, bus, slot, function;
int ret = -1;
virCheckFlags(0, -1);
if (xenUnifiedNodeDeviceGetPciInfo(dev, &domain, &bus, &slot, &function) < 0)
return -1;
......@@ -2146,7 +2150,15 @@ xenUnifiedNodeDeviceDettach(virNodeDevicePtr dev)
if (!pci)
return -1;
if (virPCIDeviceDetach(pci, NULL, NULL, "pciback") < 0)
if (!driverName) {
virPCIDeviceSetStubDriver(pci, "pciback");
} else {
virReportError(VIR_ERR_INVALID_ARG,
_("unknown driver name '%s'"), driverName);
goto out;
}
if (virPCIDeviceDetach(pci, NULL, NULL, NULL) < 0)
goto out;
ret = 0;
......@@ -2155,6 +2167,12 @@ out:
return ret;
}
static int
xenUnifiedNodeDeviceDettach(virNodeDevicePtr dev)
{
return xenUnifiedNodeDeviceDetachFlags(dev, NULL, 0);
}
static int
xenUnifiedNodeDeviceAssignedDomainId(virNodeDevicePtr dev)
{
......@@ -2405,6 +2423,7 @@ static virDriver xenUnifiedDriver = {
.connectDomainEventRegister = xenUnifiedConnectDomainEventRegister, /* 0.5.0 */
.connectDomainEventDeregister = xenUnifiedConnectDomainEventDeregister, /* 0.5.0 */
.nodeDeviceDettach = xenUnifiedNodeDeviceDettach, /* 0.6.1 */
.nodeDeviceDetachFlags = xenUnifiedNodeDeviceDetachFlags, /* 1.0.5 */
.nodeDeviceReAttach = xenUnifiedNodeDeviceReAttach, /* 0.6.1 */
.nodeDeviceReset = xenUnifiedNodeDeviceReset, /* 0.6.1 */
.connectIsEncrypted = xenUnifiedConnectIsEncrypted, /* 0.7.3 */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册