提交 c453f2d0 编写于 作者: R Roman Bogorodskiy

qemu: extract PCI handling structs

Introduce new files (domain_addr.[ch]) to provide
an API for domain device handling that could be
shared across the drivers.

A list of data types were extracted and moved there:

 qemuDomainPCIAddressBus -> virDomainPCIAddressBus
 qemuDomainPCIAddressBusPtr -> virDomainPCIAddressBusPtr
 _qemuDomainPCIAddressSet -> virDomainPCIAddressSet
 qemuDomainPCIAddressSetPtr -> virDomainPCIAddressSetPtr
 qemuDomainPCIConnectFlags -> virDomainPCIConnectFlags

Also, move the related definitions and macros.
上级 5884adc2
...@@ -247,6 +247,7 @@ NETDEV_CONF_SOURCES = \ ...@@ -247,6 +247,7 @@ NETDEV_CONF_SOURCES = \
# Domain driver generic impl APIs # Domain driver generic impl APIs
DOMAIN_CONF_SOURCES = \ DOMAIN_CONF_SOURCES = \
conf/capabilities.c conf/capabilities.h \ conf/capabilities.c conf/capabilities.h \
conf/domain_addr.h \
conf/domain_conf.c conf/domain_conf.h \ conf/domain_conf.c conf/domain_conf.h \
conf/domain_audit.c conf/domain_audit.h \ conf/domain_audit.c conf/domain_audit.h \
conf/domain_nwfilter.c conf/domain_nwfilter.h \ conf/domain_nwfilter.c conf/domain_nwfilter.h \
......
/*
* domain_addr.h: helper APIs for managing domain device addresses
*
* Copyright (C) 2006-2014 Red Hat, Inc.
* 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
* License along with this library. If not, see
* <http://www.gnu.org/licenses/>.
*
* Author: Daniel P. Berrange <berrange@redhat.com>
*/
#ifndef __DOMAIN_ADDR_H__
# define __DOMAIN_ADDR_H__
# include "domain_conf.h"
# define VIR_PCI_ADDRESS_SLOT_LAST 31
# define VIR_PCI_ADDRESS_FUNCTION_LAST 7
typedef enum {
VIR_PCI_CONNECT_HOTPLUGGABLE = 1 << 0,
/* This bus supports hot-plug */
VIR_PCI_CONNECT_SINGLESLOT = 1 << 1,
/* This "bus" has only a single downstream slot/port */
VIR_PCI_CONNECT_TYPE_PCI = 1 << 2,
/* PCI devices can connect to this bus */
VIR_PCI_CONNECT_TYPE_PCIE = 1 << 3,
/* PCI Express devices can connect to this bus */
VIR_PCI_CONNECT_TYPE_EITHER_IF_CONFIG = 1 << 4,
/* PCI *and* PCIe devices allowed, if the address
* was specified in the config by the user
*/
} virDomainPCIConnectFlags;
typedef struct {
virDomainControllerModelPCI model;
/* flags an min/max can be computed from model, but
* having them ready makes life easier.
*/
virDomainPCIConnectFlags flags;
size_t minSlot, maxSlot; /* usually 0,0 or 1,31 */
/* Each bit in a slot represents one function on that slot. If the
* bit is set, that function is in use by a device.
*/
uint8_t slots[VIR_PCI_ADDRESS_SLOT_LAST + 1];
} virDomainPCIAddressBus;
typedef virDomainPCIAddressBus *virDomainPCIAddressBusPtr;
struct _virDomainPCIAddressSet {
virDomainPCIAddressBus *buses;
size_t nbuses;
virDevicePCIAddress lastaddr;
virDomainPCIConnectFlags lastFlags;
bool dryRun; /* on a dry run, new buses are auto-added
and addresses aren't saved in device infos */
};
typedef struct _virDomainPCIAddressSet virDomainPCIAddressSet;
typedef virDomainPCIAddressSet *virDomainPCIAddressSetPtr;
/* a combination of all bit that describe the type of connections
* allowed, e.g. PCI, PCIe, switch
*/
# define VIR_PCI_CONNECT_TYPES_MASK \
(VIR_PCI_CONNECT_TYPE_PCI | VIR_PCI_CONNECT_TYPE_PCIE)
#endif /* __DOMAIN_ADDR_H__ */
此差异已折叠。
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#ifndef __QEMU_COMMAND_H__ #ifndef __QEMU_COMMAND_H__
# define __QEMU_COMMAND_H__ # define __QEMU_COMMAND_H__
# include "domain_addr.h"
# include "domain_conf.h" # include "domain_conf.h"
# include "vircommand.h" # include "vircommand.h"
# include "capabilities.h" # include "capabilities.h"
...@@ -234,55 +235,33 @@ void qemuDomainReleaseDeviceAddress(virDomainObjPtr vm, ...@@ -234,55 +235,33 @@ void qemuDomainReleaseDeviceAddress(virDomainObjPtr vm,
virDomainDeviceInfoPtr info, virDomainDeviceInfoPtr info,
const char *devstr); const char *devstr);
typedef enum {
QEMU_PCI_CONNECT_HOTPLUGGABLE = 1 << 0,
/* This bus supports hot-plug */
QEMU_PCI_CONNECT_SINGLESLOT = 1 << 1,
/* This "bus" has only a single downstream slot/port */
QEMU_PCI_CONNECT_TYPE_PCI = 1 << 2,
/* PCI devices can connect to this bus */
QEMU_PCI_CONNECT_TYPE_PCIE = 1 << 3,
/* PCI Express devices can connect to this bus */
QEMU_PCI_CONNECT_TYPE_EITHER_IF_CONFIG = 1 << 4,
/* PCI *and* PCIe devices allowed, if the address
* was specified in the config by the user
*/
} qemuDomainPCIConnectFlags;
/* a combination of all bit that describe the type of connections
* allowed, e.g. PCI, PCIe, switch
*/
# define QEMU_PCI_CONNECT_TYPES_MASK \
(QEMU_PCI_CONNECT_TYPE_PCI | QEMU_PCI_CONNECT_TYPE_PCIE)
int qemuDomainAssignPCIAddresses(virDomainDefPtr def, int qemuDomainAssignPCIAddresses(virDomainDefPtr def,
virQEMUCapsPtr qemuCaps, virQEMUCapsPtr qemuCaps,
virDomainObjPtr obj); virDomainObjPtr obj);
qemuDomainPCIAddressSetPtr qemuDomainPCIAddressSetCreate(virDomainDefPtr def, virDomainPCIAddressSetPtr qemuDomainPCIAddressSetCreate(virDomainDefPtr def,
unsigned int nbuses, unsigned int nbuses,
bool dryRun); bool dryRun);
int qemuDomainPCIAddressReserveSlot(qemuDomainPCIAddressSetPtr addrs, int qemuDomainPCIAddressReserveSlot(virDomainPCIAddressSetPtr addrs,
virDevicePCIAddressPtr addr, virDevicePCIAddressPtr addr,
qemuDomainPCIConnectFlags flags); virDomainPCIConnectFlags flags);
int qemuDomainPCIAddressReserveAddr(qemuDomainPCIAddressSetPtr addrs, int qemuDomainPCIAddressReserveAddr(virDomainPCIAddressSetPtr addrs,
virDevicePCIAddressPtr addr, virDevicePCIAddressPtr addr,
qemuDomainPCIConnectFlags flags, virDomainPCIConnectFlags flags,
bool reserveEntireSlot, bool reserveEntireSlot,
bool fromConfig); bool fromConfig);
int qemuDomainPCIAddressReserveNextSlot(qemuDomainPCIAddressSetPtr addrs, int qemuDomainPCIAddressReserveNextSlot(virDomainPCIAddressSetPtr addrs,
virDomainDeviceInfoPtr dev, virDomainDeviceInfoPtr dev,
qemuDomainPCIConnectFlags flags); virDomainPCIConnectFlags flags);
int qemuDomainPCIAddressEnsureAddr(qemuDomainPCIAddressSetPtr addrs, int qemuDomainPCIAddressEnsureAddr(virDomainPCIAddressSetPtr addrs,
virDomainDeviceInfoPtr dev); virDomainDeviceInfoPtr dev);
int qemuDomainPCIAddressReleaseAddr(qemuDomainPCIAddressSetPtr addrs, int qemuDomainPCIAddressReleaseAddr(virDomainPCIAddressSetPtr addrs,
virDevicePCIAddressPtr addr); virDevicePCIAddressPtr addr);
void qemuDomainPCIAddressSetFree(qemuDomainPCIAddressSetPtr addrs); void qemuDomainPCIAddressSetFree(virDomainPCIAddressSetPtr addrs);
int qemuAssignDevicePCISlots(virDomainDefPtr def, int qemuAssignDevicePCISlots(virDomainDefPtr def,
virQEMUCapsPtr qemuCaps, virQEMUCapsPtr qemuCaps,
qemuDomainPCIAddressSetPtr addrs); virDomainPCIAddressSetPtr addrs);
int qemuDomainCCWAddressAssign(virDomainDeviceInfoPtr dev, qemuDomainCCWAddressSetPtr addrs, int qemuDomainCCWAddressAssign(virDomainDeviceInfoPtr dev, qemuDomainCCWAddressSetPtr addrs,
bool autoassign); bool autoassign);
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
# include "virthread.h" # include "virthread.h"
# include "vircgroup.h" # include "vircgroup.h"
# include "domain_addr.h"
# include "domain_conf.h" # include "domain_conf.h"
# include "snapshot_conf.h" # include "snapshot_conf.h"
# include "qemu_monitor.h" # include "qemu_monitor.h"
...@@ -116,9 +117,6 @@ struct qemuDomainJobObj { ...@@ -116,9 +117,6 @@ struct qemuDomainJobObj {
bool asyncAbort; /* abort of async job requested */ bool asyncAbort; /* abort of async job requested */
}; };
typedef struct _qemuDomainPCIAddressSet qemuDomainPCIAddressSet;
typedef qemuDomainPCIAddressSet *qemuDomainPCIAddressSetPtr;
typedef void (*qemuDomainCleanupCallback)(virQEMUDriverPtr driver, typedef void (*qemuDomainCleanupCallback)(virQEMUDriverPtr driver,
virDomainObjPtr vm); virDomainObjPtr vm);
typedef struct _qemuDomainCCWAddressSet qemuDomainCCWAddressSet; typedef struct _qemuDomainCCWAddressSet qemuDomainCCWAddressSet;
...@@ -146,7 +144,7 @@ struct _qemuDomainObjPrivate { ...@@ -146,7 +144,7 @@ struct _qemuDomainObjPrivate {
int nvcpupids; int nvcpupids;
int *vcpupids; int *vcpupids;
qemuDomainPCIAddressSetPtr pciaddrs; virDomainPCIAddressSetPtr pciaddrs;
qemuDomainCCWAddressSetPtr ccwaddrs; qemuDomainCCWAddressSetPtr ccwaddrs;
int persistentAddrs; int persistentAddrs;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册