mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-03 19:45:21 +00:00
Add wrappers for virDomainDiskIndexBy*
Sometimes the only thing we need is the pointer to virDomainDiskDef and having to call virDomainDiskIndexBy* APIs, storing the disk index, and looking it up in the disks array is ugly. After this patch, we can just call virDomainDiskBy* and get the pointer in one step. Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
This commit is contained in:
parent
fb0b9a2cc5
commit
865109b353
@ -12349,6 +12349,17 @@ virDomainDiskIndexByAddress(virDomainDefPtr def,
|
||||
return -1;
|
||||
}
|
||||
|
||||
virDomainDiskDefPtr
|
||||
virDomainDiskByAddress(virDomainDefPtr def,
|
||||
virDevicePCIAddressPtr pci_address,
|
||||
unsigned int bus,
|
||||
unsigned int target,
|
||||
unsigned int unit)
|
||||
{
|
||||
int idx = virDomainDiskIndexByAddress(def, pci_address, bus, target, unit);
|
||||
return idx < 0 ? NULL : def->disks[idx];
|
||||
}
|
||||
|
||||
int
|
||||
virDomainDiskIndexByName(virDomainDefPtr def, const char *name,
|
||||
bool allow_ambiguous)
|
||||
@ -12388,6 +12399,15 @@ virDomainDiskPathByName(virDomainDefPtr def, const char *name)
|
||||
return idx < 0 ? NULL : virDomainDiskGetSource(def->disks[idx]);
|
||||
}
|
||||
|
||||
virDomainDiskDefPtr
|
||||
virDomainDiskByName(virDomainDefPtr def,
|
||||
const char *name,
|
||||
bool allow_ambiguous)
|
||||
{
|
||||
int idx = virDomainDiskIndexByName(def, name, allow_ambiguous);
|
||||
return idx < 0 ? NULL : def->disks[idx];
|
||||
}
|
||||
|
||||
int virDomainDiskInsert(virDomainDefPtr def,
|
||||
virDomainDiskDefPtr disk)
|
||||
{
|
||||
|
@ -2685,8 +2685,16 @@ int virDomainDiskIndexByAddress(virDomainDefPtr def,
|
||||
virDevicePCIAddressPtr pci_controller,
|
||||
unsigned int bus, unsigned int target,
|
||||
unsigned int unit);
|
||||
virDomainDiskDefPtr virDomainDiskByAddress(virDomainDefPtr def,
|
||||
virDevicePCIAddressPtr pci_controller,
|
||||
unsigned int bus,
|
||||
unsigned int target,
|
||||
unsigned int unit);
|
||||
int virDomainDiskIndexByName(virDomainDefPtr def, const char *name,
|
||||
bool allow_ambiguous);
|
||||
virDomainDiskDefPtr virDomainDiskByName(virDomainDefPtr def,
|
||||
const char *name,
|
||||
bool allow_ambiguous);
|
||||
const char *virDomainDiskPathByName(virDomainDefPtr, const char *name);
|
||||
int virDomainDiskInsert(virDomainDefPtr def,
|
||||
virDomainDiskDefPtr disk)
|
||||
|
@ -238,6 +238,8 @@ virDomainDeviceInfoCopy;
|
||||
virDomainDeviceInfoIterate;
|
||||
virDomainDeviceTypeToString;
|
||||
virDomainDiskBusTypeToString;
|
||||
virDomainDiskByAddress;
|
||||
virDomainDiskByName;
|
||||
virDomainDiskCacheTypeFromString;
|
||||
virDomainDiskCacheTypeToString;
|
||||
virDomainDiskDefAssignAddress;
|
||||
|
Loading…
Reference in New Issue
Block a user