[libvirt] [PATCH] qemu: alias: Generate 'qomName' of disk with useraliases

Peter Krempa posted 1 patch 4 years, 7 months ago
Test syntax-check passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/e8f1df2d308a62d568b1aab24f0dc7c992958c68.1565968694.git.pkrempa@redhat.com
src/qemu/qemu_alias.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
[libvirt] [PATCH] qemu: alias: Generate 'qomName' of disk with useraliases
Posted by Peter Krempa 4 years, 7 months ago
Commit fb64e176f4f forgot to delete the check that short-circuits the
disk alias creation if the alias is already present. The side efect
of this is that the creation qomName which is necessary to be able to
refer to disk frontends when -blockdev is used was skipped when user
aliases are used.

Fix it by deleting the check. Also prevent any potential memory leaks
from calling this function repeatedly by creating the qomName only when
it's not present.

https://bugzilla.redhat.com/show_bug.cgi?id=1741838

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
---
 src/qemu/qemu_alias.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/src/qemu/qemu_alias.c b/src/qemu/qemu_alias.c
index 585cc972ba..216a18d0d9 100644
--- a/src/qemu/qemu_alias.c
+++ b/src/qemu/qemu_alias.c
@@ -182,9 +182,6 @@ qemuAssignDeviceDiskAlias(virDomainDefPtr def,
     const char *prefix = virDomainDiskBusTypeToString(disk->bus);
     int controllerModel = -1;

-    if (disk->info.alias)
-        return 0;
-
     if (!disk->info.alias) {
         if (disk->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE) {
             if (disk->bus == VIR_DOMAIN_DISK_BUS_SCSI) {
@@ -220,7 +217,8 @@ qemuAssignDeviceDiskAlias(virDomainDefPtr def,
      * on the alias in qemu. While certain disk types use just the alias, some
      * need the full path into /machine/peripheral as a historical artifact.
      */
-    if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_BLOCKDEV)) {
+    if (!diskPriv->qomName &&
+        virQEMUCapsGet(qemuCaps, QEMU_CAPS_BLOCKDEV)) {
         switch ((virDomainDiskBus) disk->bus) {
         case VIR_DOMAIN_DISK_BUS_FDC:
         case VIR_DOMAIN_DISK_BUS_IDE:
-- 
2.21.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] qemu: alias: Generate 'qomName' of disk with useraliases
Posted by Ján Tomko 4 years, 7 months ago
On Fri, Aug 16, 2019 at 05:18:14PM +0200, Peter Krempa wrote:
>Commit fb64e176f4f forgot to delete the check that short-circuits the
>disk alias creation if the alias is already present. The side efect

effect

>of this is that the creation qomName which is necessary to be able to
>refer to disk frontends when -blockdev is used was skipped when user
>aliases are used.
>
>Fix it by deleting the check. Also prevent any potential memory leaks
>from calling this function repeatedly by creating the qomName only when
>it's not present.
>
>https://bugzilla.redhat.com/show_bug.cgi?id=1741838
>
>Signed-off-by: Peter Krempa <pkrempa@redhat.com>
>---
> src/qemu/qemu_alias.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>

Reviewed-by: Ján Tomko <jtomko@redhat.com>

Jano
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list