mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-22 04:25:18 +00:00
qemu: domain: Add helper to generate indexed backing store names
The code is currently simple, but if we later add node names, it will be necessary to generate the names based on the node name. Add a helper so that there's a central point to fix once we add self-generated node names.
This commit is contained in:
parent
1a5e2a8098
commit
4e1618ce72
@ -8558,3 +8558,25 @@ qemuDomainDiskLookupByNodename(virDomainDefPtr def,
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* qemuDomainDiskBackingStoreGetName:
|
||||
*
|
||||
* Creates a name using the indexed syntax (vda[1])for the given backing store
|
||||
* entry for a disk.
|
||||
*/
|
||||
char *
|
||||
qemuDomainDiskBackingStoreGetName(virDomainDiskDefPtr disk,
|
||||
virStorageSourcePtr src ATTRIBUTE_UNUSED,
|
||||
unsigned int idx)
|
||||
{
|
||||
char *ret = NULL;
|
||||
|
||||
if (idx)
|
||||
ignore_value(virAsprintf(&ret, "%s[%d]", disk->dst, idx));
|
||||
else
|
||||
ignore_value(VIR_STRDUP(ret, disk->dst));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -883,4 +883,8 @@ virDomainDiskDefPtr qemuDomainDiskLookupByNodename(virDomainDefPtr def,
|
||||
virStorageSourcePtr *src,
|
||||
unsigned int *idx);
|
||||
|
||||
char *qemuDomainDiskBackingStoreGetName(virDomainDiskDefPtr disk,
|
||||
virStorageSourcePtr src,
|
||||
unsigned int idx);
|
||||
|
||||
#endif /* __QEMU_DOMAIN_H__ */
|
||||
|
Loading…
x
Reference in New Issue
Block a user