mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-05 12:35:20 +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;
|
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
|
int
|
||||||
virDomainDiskIndexByName(virDomainDefPtr def, const char *name,
|
virDomainDiskIndexByName(virDomainDefPtr def, const char *name,
|
||||||
bool allow_ambiguous)
|
bool allow_ambiguous)
|
||||||
@ -12388,6 +12399,15 @@ virDomainDiskPathByName(virDomainDefPtr def, const char *name)
|
|||||||
return idx < 0 ? NULL : virDomainDiskGetSource(def->disks[idx]);
|
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,
|
int virDomainDiskInsert(virDomainDefPtr def,
|
||||||
virDomainDiskDefPtr disk)
|
virDomainDiskDefPtr disk)
|
||||||
{
|
{
|
||||||
|
@ -2685,8 +2685,16 @@ int virDomainDiskIndexByAddress(virDomainDefPtr def,
|
|||||||
virDevicePCIAddressPtr pci_controller,
|
virDevicePCIAddressPtr pci_controller,
|
||||||
unsigned int bus, unsigned int target,
|
unsigned int bus, unsigned int target,
|
||||||
unsigned int unit);
|
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,
|
int virDomainDiskIndexByName(virDomainDefPtr def, const char *name,
|
||||||
bool allow_ambiguous);
|
bool allow_ambiguous);
|
||||||
|
virDomainDiskDefPtr virDomainDiskByName(virDomainDefPtr def,
|
||||||
|
const char *name,
|
||||||
|
bool allow_ambiguous);
|
||||||
const char *virDomainDiskPathByName(virDomainDefPtr, const char *name);
|
const char *virDomainDiskPathByName(virDomainDefPtr, const char *name);
|
||||||
int virDomainDiskInsert(virDomainDefPtr def,
|
int virDomainDiskInsert(virDomainDefPtr def,
|
||||||
virDomainDiskDefPtr disk)
|
virDomainDiskDefPtr disk)
|
||||||
|
@ -238,6 +238,8 @@ virDomainDeviceInfoCopy;
|
|||||||
virDomainDeviceInfoIterate;
|
virDomainDeviceInfoIterate;
|
||||||
virDomainDeviceTypeToString;
|
virDomainDeviceTypeToString;
|
||||||
virDomainDiskBusTypeToString;
|
virDomainDiskBusTypeToString;
|
||||||
|
virDomainDiskByAddress;
|
||||||
|
virDomainDiskByName;
|
||||||
virDomainDiskCacheTypeFromString;
|
virDomainDiskCacheTypeFromString;
|
||||||
virDomainDiskCacheTypeToString;
|
virDomainDiskCacheTypeToString;
|
||||||
virDomainDiskDefAssignAddress;
|
virDomainDiskDefAssignAddress;
|
||||||
|
Loading…
Reference in New Issue
Block a user