1 /* 2 * virnvme.h: helper APIs for managing NVMe devices 3 * 4 * This library is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU Lesser General Public 6 * License as published by the Free Software Foundation; either 7 * version 2.1 of the License, or (at your option) any later version. 8 * 9 * This library is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 * Lesser General Public License for more details. 13 * 14 * You should have received a copy of the GNU Lesser General Public 15 * License along with this library. If not, see 16 * <http://www.gnu.org/licenses/>. 17 */ 18 19 #pragma once 20 21 #include "virpci.h" 22 23 typedef struct _virNVMeDevice virNVMeDevice; 24 25 /* Note that this list is lockable, and in fact, it is caller's 26 * responsibility to acquire the lock and release it. The reason 27 * is that in a lot of cases the list must be locked between two 28 * API calls and therefore only caller knows when it is safe to 29 * finally release the lock. */ 30 typedef struct _virNVMeDeviceList virNVMeDeviceList; 31 32 G_DEFINE_AUTOPTR_CLEANUP_FUNC(virNVMeDeviceList, virObjectUnref); 33 34 virNVMeDevice * 35 virNVMeDeviceNew(const virPCIDeviceAddress *address, 36 unsigned long namespace, 37 bool managed); 38 39 void 40 virNVMeDeviceFree(virNVMeDevice *dev); 41 42 G_DEFINE_AUTOPTR_CLEANUP_FUNC(virNVMeDevice, virNVMeDeviceFree); 43 44 virNVMeDevice * 45 virNVMeDeviceCopy(const virNVMeDevice *dev); 46 47 const virPCIDeviceAddress * 48 virNVMeDeviceAddressGet(const virNVMeDevice *dev); 49 50 void 51 virNVMeDeviceUsedByClear(virNVMeDevice *dev); 52 53 void 54 virNVMeDeviceUsedByGet(const virNVMeDevice *dev, 55 const char **drv, 56 const char **dom); 57 58 void 59 virNVMeDeviceUsedBySet(virNVMeDevice *dev, 60 const char *drv, 61 const char *dom); 62 63 virNVMeDeviceList * 64 virNVMeDeviceListNew(void); 65 66 size_t 67 virNVMeDeviceListCount(const virNVMeDeviceList *list); 68 69 int 70 virNVMeDeviceListAdd(virNVMeDeviceList *list, 71 const virNVMeDevice *dev); 72 73 int 74 virNVMeDeviceListDel(virNVMeDeviceList *list, 75 const virNVMeDevice *dev); 76 77 virNVMeDevice * 78 virNVMeDeviceListGet(virNVMeDeviceList *list, 79 size_t i); 80 81 virNVMeDevice * 82 virNVMeDeviceListLookup(virNVMeDeviceList *list, 83 const virNVMeDevice *dev); 84 85 ssize_t 86 virNVMeDeviceListLookupIndex(virNVMeDeviceList *list, 87 const virNVMeDevice *dev); 88 89 virPCIDeviceList * 90 virNVMeDeviceListCreateDetachList(virNVMeDeviceList *activeList, 91 virNVMeDeviceList *toDetachList); 92 93 virPCIDeviceList * 94 virNVMeDeviceListCreateReAttachList(virNVMeDeviceList *activeList, 95 virNVMeDeviceList *toReAttachList); 96