virhostdev.h 7.8 KB
Newer Older
1 2
/* virhostdev.h: hostdev management
 *
3 4
 * Copyright (C) 2006-2007, 2009-2013 Red Hat, Inc.
 * Copyright (C) 2006 Daniel P. Berrange
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
 * Copyright (C) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany.
 *
 * 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/>.
 *
21
 * Author: Daniel P. Berrange <berrange@redhat.com>
22 23 24 25 26 27 28 29 30 31 32
 * Author: Chunyan Liu <cyliu@suse.com>
 */

#ifndef __VIR_HOSTDEV_H__
# define __VIR_HOSTDEV_H__

# include "internal.h"

# include "virpci.h"
# include "virusb.h"
# include "virscsi.h"
33
# include "virscsivhost.h"
34
# include "conf/domain_conf.h"
35 36 37 38

typedef enum {
    VIR_HOSTDEV_STRICT_ACS_CHECK     = (1 << 0), /* strict acs check */
    VIR_HOSTDEV_COLD_BOOT            = (1 << 1), /* cold boot */
39 40 41 42

    VIR_HOSTDEV_SP_PCI               = (1 << 8), /* support pci passthrough */
    VIR_HOSTDEV_SP_USB               = (1 << 9), /* support usb passthrough */
    VIR_HOSTDEV_SP_SCSI              = (1 << 10), /* support scsi passthrough */
43 44
} virHostdevFlag;

45 46 47 48

typedef struct _virHostdevManager virHostdevManager;
typedef virHostdevManager *virHostdevManagerPtr;
struct _virHostdevManager {
49 50
    virObject parent;

51 52
    char *stateDir;

53 54 55 56
    virPCIDeviceListPtr activePCIHostdevs;
    virPCIDeviceListPtr inactivePCIHostdevs;
    virUSBDeviceListPtr activeUSBHostdevs;
    virSCSIDeviceListPtr activeSCSIHostdevs;
57
    virSCSIVHostDeviceListPtr activeSCSIVHostHostdevs;
58 59 60
};

virHostdevManagerPtr virHostdevManagerGetDefault(void);
61 62 63
int
virHostdevPreparePCIDevices(virHostdevManagerPtr hostdev_mgr,
                            const char *drv_name,
64
                            const char *dom_name,
65 66
                            const unsigned char *uuid,
                            virDomainHostdevDefPtr *hostdevs,
67
                            int nhostdevs,
68 69 70
                            unsigned int flags)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3)
    ATTRIBUTE_NONNULL(4);
71 72 73 74 75 76

int
virHostdevFindUSBDevice(virDomainHostdevDefPtr hostdev,
                        bool mandatory,
                        virUSBDevicePtr *usb)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(3);
77 78 79
int
virHostdevPrepareUSBDevices(virHostdevManagerPtr hostdev_mgr,
                            const char *drv_name,
80
                            const char *dom_name,
81
                            virDomainHostdevDefPtr *hostdevs,
82
                            int nhostdevs,
83 84
                            unsigned int flags)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
85 86 87
int
virHostdevPrepareSCSIDevices(virHostdevManagerPtr hostdev_mgr,
                             const char *drv_name,
88
                             const char *dom_name,
89
                             virDomainHostdevDefPtr *hostdevs,
90 91
                             int nhostdevs)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
92 93 94 95 96 97 98
int
virHostdevPrepareSCSIVHostDevices(virHostdevManagerPtr hostdev_mgr,
                                  const char *drv_name,
                                  const char *dom_name,
                                  virDomainHostdevDefPtr *hostdevs,
                                  int nhostdevs)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
99 100 101
void
virHostdevReAttachPCIDevices(virHostdevManagerPtr hostdev_mgr,
                             const char *drv_name,
102
                             const char *dom_name,
103 104
                             virDomainHostdevDefPtr *hostdevs,
                             int nhostdevs,
105 106
                             const char *oldStateDir)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
107
void
108
virHostdevReAttachUSBDevices(virHostdevManagerPtr hostdev_mgr,
109
                              const char *drv_name,
110
                              const char *dom_name,
111
                              virDomainHostdevDefPtr *hostdevs,
112 113
                              int nhostdevs)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
114
void
115 116 117 118
virHostdevReAttachSCSIDevices(virHostdevManagerPtr hostdev_mgr,
                              const char *drv_name,
                              const char *dom_name,
                              virDomainHostdevDefPtr *hostdevs,
119 120
                              int nhostdevs)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
121 122 123 124 125 126 127
void
virHostdevReAttachSCSIVHostDevices(virHostdevManagerPtr hostdev_mgr,
                                   const char *drv_name,
                                   const char *dom_name,
                                   virDomainHostdevDefPtr *hostdevs,
                                   int nhostdevs)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
128
int
129
virHostdevUpdateActivePCIDevices(virHostdevManagerPtr mgr,
130 131
                                 virDomainHostdevDefPtr *hostdevs,
                                 int nhostdevs,
132
                                 const char *drv_name,
133 134
                                 const char *dom_name)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(4) ATTRIBUTE_NONNULL(5);
135
int
136
virHostdevUpdateActiveUSBDevices(virHostdevManagerPtr mgr,
137 138
                                 virDomainHostdevDefPtr *hostdevs,
                                 int nhostdevs,
139
                                 const char *drv_name,
140 141
                                 const char *dom_name)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(4) ATTRIBUTE_NONNULL(5);
142 143
int
virHostdevUpdateActiveSCSIDevices(virHostdevManagerPtr mgr,
144 145
                                  virDomainHostdevDefPtr *hostdevs,
                                  int nhostdevs,
146
                                  const char *drv_name,
147 148
                                  const char *dom_name)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(4) ATTRIBUTE_NONNULL(5);
149
int
150
virHostdevUpdateActiveDomainDevices(virHostdevManagerPtr mgr,
151 152
                                    const char *driver,
                                    virDomainDefPtr def,
153 154
                                    unsigned int flags)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
155 156 157 158
int
virHostdevPrepareDomainDevices(virHostdevManagerPtr mgr,
                               const char *driver,
                               virDomainDefPtr def,
159 160
                               unsigned int flags)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
161 162 163 164 165
void
virHostdevReAttachDomainDevices(virHostdevManagerPtr mgr,
                                const char *driver,
                                virDomainDefPtr def,
                                unsigned int flags,
166
                                const char *oldStateDir)
167
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
168 169 170
bool
virHostdevIsSCSIDevice(virDomainHostdevDefPtr hostdev)
    ATTRIBUTE_NONNULL(1);
171

172
/* functions used by NodeDevDetach/Reattach/Reset */
173
int virHostdevPCINodeDeviceDetach(virHostdevManagerPtr mgr,
174 175
                                  virPCIDevicePtr pci)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
176
int virHostdevPCINodeDeviceReAttach(virHostdevManagerPtr mgr,
177 178
                                    virPCIDevicePtr pci)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
179
int virHostdevPCINodeDeviceReset(virHostdevManagerPtr mgr,
180 181
                                 virPCIDevicePtr pci)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
182

183
#endif /* __VIR_HOSTDEV_H__ */