mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-22 11:22:23 +00:00
qemu: Add field to store QOM path of a disk in private data
When using -blockdev you need to use the qom path to refer to the disk fronends. Add means for storing the path and getting it after restart. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
4ceecd3a6f
commit
716c46178a
@ -1065,6 +1065,7 @@ qemuDomainDiskPrivateDispose(void *obj)
|
||||
|
||||
VIR_FREE(priv->blockJobError);
|
||||
virStorageSourceFree(priv->migrSource);
|
||||
VIR_FREE(priv->qomName);
|
||||
}
|
||||
|
||||
static virClassPtr qemuDomainStorageSourcePrivateClass;
|
||||
@ -2123,6 +2124,30 @@ qemuStorageSourcePrivateDataFormat(virStorageSourcePtr src,
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
qemuDomainDiskPrivateParse(xmlXPathContextPtr ctxt,
|
||||
virDomainDiskDefPtr disk)
|
||||
{
|
||||
qemuDomainDiskPrivatePtr priv = QEMU_DOMAIN_DISK_PRIVATE(disk);
|
||||
|
||||
priv->qomName = virXPathString("string(./qom/@name)", ctxt);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
qemuDomainDiskPrivateFormat(virDomainDiskDefPtr disk,
|
||||
virBufferPtr buf)
|
||||
{
|
||||
qemuDomainDiskPrivatePtr priv = QEMU_DOMAIN_DISK_PRIVATE(disk);
|
||||
|
||||
virBufferEscapeString(buf, "<qom name='%s'/>\n", priv->qomName);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
qemuDomainObjPrivateXMLFormatVcpus(virBufferPtr buf,
|
||||
virDomainDefPtr def)
|
||||
@ -2973,6 +2998,8 @@ virDomainXMLPrivateDataCallbacks virQEMUDriverPrivateDataCallbacks = {
|
||||
.alloc = qemuDomainObjPrivateAlloc,
|
||||
.free = qemuDomainObjPrivateFree,
|
||||
.diskNew = qemuDomainDiskPrivateNew,
|
||||
.diskParse = qemuDomainDiskPrivateParse,
|
||||
.diskFormat = qemuDomainDiskPrivateFormat,
|
||||
.vcpuNew = qemuDomainVcpuPrivateNew,
|
||||
.chrSourceNew = qemuDomainChrSourcePrivateNew,
|
||||
.vsockNew = qemuDomainVsockPrivateNew,
|
||||
|
@ -396,6 +396,8 @@ struct _qemuDomainDiskPrivate {
|
||||
/* information about the device */
|
||||
bool tray; /* device has tray */
|
||||
bool removable; /* device media can be removed/changed */
|
||||
|
||||
char *qomName; /* QOM path of the disk (also refers to the block backend) */
|
||||
};
|
||||
|
||||
# define QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(src) \
|
||||
|
@ -333,6 +333,9 @@
|
||||
<target dev='vdb' bus='virtio'/>
|
||||
<alias name='virtio-disk1'/>
|
||||
<address type='pci' domain='0x0000' bus='0x00' slot='0x0b' function='0x0'/>
|
||||
<privateData>
|
||||
<qom name='virtio-disk1/virtio-backend'/>
|
||||
</privateData>
|
||||
</disk>
|
||||
<disk type='file' device='cdrom'>
|
||||
<driver name='qemu' type='raw'/>
|
||||
|
Loading…
x
Reference in New Issue
Block a user