1 /*
2  * virscsivhost.h: helper APIs for managing host scsi_host devices
3  *
4  * Copyright (C) 2016 IBM Corporation
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library.  If not, see
18  * <http://www.gnu.org/licenses/>.
19  */
20 
21 #pragma once
22 
23 #include "internal.h"
24 #include "virobject.h"
25 
26 typedef struct _virSCSIVHostDevice virSCSIVHostDevice;
27 typedef struct _virSCSIVHostDeviceList virSCSIVHostDeviceList;
28 
29 G_DEFINE_AUTOPTR_CLEANUP_FUNC(virSCSIVHostDeviceList, virObjectUnref);
30 
31 
32 typedef int (*virSCSIVHostDeviceFileActor)(virSCSIVHostDevice *dev,
33                                            const char *name, void *opaque);
34 
35 int virSCSIVHostDeviceFileIterate(virSCSIVHostDevice *dev,
36                                   virSCSIVHostDeviceFileActor actor,
37                                   void *opaque);
38 const char *virSCSIVHostDeviceGetName(virSCSIVHostDevice *dev);
39 const char *virSCSIVHostDeviceGetPath(virSCSIVHostDevice *dev);
40 virSCSIVHostDevice *virSCSIVHostDeviceListGet(virSCSIVHostDeviceList *list,
41                                                 int idx);
42 size_t virSCSIVHostDeviceListCount(virSCSIVHostDeviceList *list);
43 virSCSIVHostDevice *virSCSIVHostDeviceListSteal(virSCSIVHostDeviceList *list,
44                                                   virSCSIVHostDevice *dev);
45 virSCSIVHostDevice *virSCSIVHostDeviceListFind(virSCSIVHostDeviceList *list,
46                                                  virSCSIVHostDevice *dev);
47 int  virSCSIVHostDeviceListAdd(virSCSIVHostDeviceList *list,
48                                virSCSIVHostDevice *dev);
49 void virSCSIVHostDeviceListDel(virSCSIVHostDeviceList *list,
50                                virSCSIVHostDevice *dev);
51 virSCSIVHostDeviceList *virSCSIVHostDeviceListNew(void);
52 virSCSIVHostDevice *virSCSIVHostDeviceNew(const char *name);
53 int virSCSIVHostDeviceSetUsedBy(virSCSIVHostDevice *dev,
54                                 const char *drvname,
55                                 const char *domname);
56 void virSCSIVHostDeviceGetUsedBy(virSCSIVHostDevice *dev,
57                                  const char **drv_name,
58                                  const char **dom_name);
59 void virSCSIVHostDeviceFree(virSCSIVHostDevice *dev);
60 int virSCSIVHostOpenVhostSCSI(int *vhostfd) G_GNUC_NO_INLINE;
61 
62 G_DEFINE_AUTOPTR_CLEANUP_FUNC(virSCSIVHostDevice, virSCSIVHostDeviceFree);
63