提交 716c4617 编写于 作者: P Peter Krempa

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: NPeter Krempa <pkrempa@redhat.com>
Reviewed-by: NJán Tomko <jtomko@redhat.com>
上级 4ceecd3a
......@@ -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'/>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册