virhostdev.h 4.4 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 34 35 36 37 38 39
# include "domain_conf.h"

typedef enum {
    VIR_HOSTDEV_STRICT_ACS_CHECK     = (1 << 0), /* strict acs check */
    VIR_HOSTDEV_COLD_BOOT            = (1 << 1), /* cold boot */
} virHostdevFlag;

40 41 42 43 44 45 46 47 48 49 50 51 52

typedef struct _virHostdevManager virHostdevManager;
typedef virHostdevManager *virHostdevManagerPtr;
struct _virHostdevManager {
    char *stateDir;

    virPCIDeviceListPtr activePciHostdevs;
    virPCIDeviceListPtr inactivePciHostdevs;
    virUSBDeviceListPtr activeUsbHostdevs;
    virSCSIDeviceListPtr activeScsiHostdevs;
};

virHostdevManagerPtr virHostdevManagerGetDefault(void);
53 54 55 56 57 58
int
virHostdevPreparePCIDevices(virHostdevManagerPtr hostdev_mgr,
                            const char *drv_name,
                            const char *name,
                            const unsigned char *uuid,
                            virDomainHostdevDefPtr *hostdevs,
59 60 61 62 63 64 65
                            int nhostdevs,
                            unsigned int flags);
int
virHostdevPrepareUSBDevices(virHostdevManagerPtr hostdev_mgr,
                            const char *drv_name,
                            const char *name,
                            virDomainHostdevDefPtr *hostdevs,
66 67
                            int nhostdevs,
                            unsigned int flags);
68 69 70 71 72 73
int
virHostdevPrepareSCSIDevices(virHostdevManagerPtr hostdev_mgr,
                             const char *drv_name,
                             const char *name,
                             virDomainHostdevDefPtr *hostdevs,
                             int nhostdevs);
74 75 76 77 78 79 80
void
virHostdevReAttachPCIDevices(virHostdevManagerPtr hostdev_mgr,
                             const char *drv_name,
                             const char *name,
                             virDomainHostdevDefPtr *hostdevs,
                             int nhostdevs,
                             char *oldStateDir);
81 82 83 84 85 86
void
virHostdevReAttachUsbHostdevs(virHostdevManagerPtr hostdev_mgr,
                              const char *drv_name,
                              const char *name,
                              virDomainHostdevDefPtr *hostdevs,
                              int nhostdevs);
87 88 89 90 91 92
void
virHostdevReAttachScsiHostdevs(virHostdevManagerPtr hostdev_mgr,
                               const char *drv_name,
                               const char *name,
                               virDomainHostdevDefPtr *hostdevs,
                               int nhostdevs);
93 94 95 96 97 98 99 100 101 102 103 104
int
virHostdevUpdateActivePciHostdevs(virHostdevManagerPtr mgr,
                                  const char *drv_name,
                                  virDomainDefPtr def);
int
virHostdevUpdateActiveUsbHostdevs(virHostdevManagerPtr mgr,
                                  const char *drv_name,
                                  virDomainDefPtr def);
int
virHostdevUpdateActiveScsiHostdevs(virHostdevManagerPtr mgr,
                                   const char *drv_name,
                                   virDomainDefPtr def);
105

106 107 108 109 110 111 112 113
/* functions used by NodeDevDetach/Reattach/Reset */
int virHostdevPciNodeDeviceDetach(virHostdevManagerPtr mgr,
                                  virPCIDevicePtr pci);
int virHostdevPciNodeDeviceReAttach(virHostdevManagerPtr mgr,
                                    virPCIDevicePtr pci);
int virHostdevPciNodeDeviceReset(virHostdevManagerPtr mgr,
                                 virPCIDevicePtr pci);

114
#endif /* __VIR_HOSTDEV_H__ */