backup: qemu: Add helper API for looking up node name

Qemu bitmap operations require knowing the node name associated with
the format layer (the qcow2 file); as upcoming patches will be
grabbing that information frequently, make a helper function to access
it.

Another potential benefit of this function is that we have a single
place where we could insert a QMP node-name scraping call if we don't
currently know the node name, when -blockdev is not supported;
however, the goal is that we hopefully don't ever have to do that
because we instead scrape node names only at the point where they
change.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
Eric Blake 2019-07-22 11:22:05 -05:00
parent 5f4e079650
commit e3a4b8f461
2 changed files with 18 additions and 0 deletions

View File

@ -10360,6 +10360,21 @@ qemuDomainDiskChangeSupported(virDomainDiskDefPtr disk,
return true;
}
/* Return the format node name for a given disk of an online guest */
const char *
qemuDomainDiskNodeFormatLookup(virDomainObjPtr vm,
const char *disk)
{
size_t i;
for (i = 0; i < vm->def->ndisks; i++) {
if (STREQ(vm->def->disks[i]->dst, disk))
return vm->def->disks[i]->src->nodeformat;
}
return NULL;
}
bool
qemuDomainDiskBlockJobIsActive(virDomainDiskDefPtr disk)
{

View File

@ -804,6 +804,9 @@ int qemuDomainDetermineDiskChain(virQEMUDriverPtr driver,
bool qemuDomainDiskChangeSupported(virDomainDiskDefPtr disk,
virDomainDiskDefPtr orig_disk);
const char *qemuDomainDiskNodeFormatLookup(virDomainObjPtr vm,
const char *disk);
int qemuDomainStorageFileInit(virQEMUDriverPtr driver,
virDomainObjPtr vm,
virStorageSourcePtr src,