When using -blockdev you need to use the qdev path to refer to the disk fronends. Add means for storing the path and getting it after restart. Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx> --- src/qemu/qemu_domain.c | 27 +++++++++++++++++++++++++++ src/qemu/qemu_domain.h | 2 ++ tests/qemustatusxml2xmldata/modern-in.xml | 3 +++ 3 files changed, 32 insertions(+) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 6103b86478..9c1a2c6053 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -1065,6 +1065,7 @@ qemuDomainDiskPrivateDispose(void *obj) VIR_FREE(priv->blockJobError); virStorageSourceFree(priv->migrSource); + VIR_FREE(priv->backendQomName); } 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->backendQomName = virXPathString("string(./qom/@backend)", ctxt); + + return 0; +} + + +static int +qemuDomainDiskPrivateFormat(virDomainDiskDefPtr disk, + virBufferPtr buf) +{ + qemuDomainDiskPrivatePtr priv = QEMU_DOMAIN_DISK_PRIVATE(disk); + + virBufferEscapeString(buf, "<qom backend='%s'/>\n", priv->backendQomName); + + 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, diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 5dcbdfbbe1..7d0b304727 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -396,6 +396,8 @@ struct _qemuDomainDiskPrivate { /* information about the device */ bool tray; /* device has tray */ bool removable; /* device media can be removed/changed */ + + char *backendQomName; /* QOM path to the eligible block backend */ }; # define QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(src) \ diff --git a/tests/qemustatusxml2xmldata/modern-in.xml b/tests/qemustatusxml2xmldata/modern-in.xml index 4fb5f326c2..21d4faca66 100644 --- a/tests/qemustatusxml2xmldata/modern-in.xml +++ b/tests/qemustatusxml2xmldata/modern-in.xml @@ -331,6 +331,9 @@ <target dev='vdb' bus='virtio'/> <alias name='virtio-disk1'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x0b' function='0x0'/> + <privateData> + <qom backend='virtio-disk1/virtio-backend'/> + </privateData> </disk> <disk type='file' device='cdrom'> <driver name='qemu' type='raw'/> -- 2.16.2 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list