[libvirt] [PATCH] qemu: domain: Properly lookup top of chain in qemuDomainGetStorageSourceByDevstr

Peter Krempa posted 1 patch 7 years ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/20ee78bf9bafe542097fe0e144921d001a6799a7.1490799453.git.pkrempa@redhat.com
src/qemu/qemu_domain.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
[libvirt] [PATCH] qemu: domain: Properly lookup top of chain in qemuDomainGetStorageSourceByDevstr
Posted by Peter Krempa 7 years ago
When idx is 0 virStorageFileChainLookup returns the base (bottom) of the
backing chain rather than the top. This is expected by the callers of
qemuDomainGetStorageSourceByDevstr.

Add a special case for idx == 0
---
With this you are not able to specify the top image of a disk when using
virDomainSetBlockThreshold in qemu.

 src/qemu/qemu_domain.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 458bb5f9a..589eb1889 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -8605,7 +8605,10 @@ qemuDomainGetStorageSourceByDevstr(const char *devstr,
         goto cleanup;
     }

-    src = virStorageFileChainLookup(disk->src, NULL, NULL, idx, NULL);
+    if (idx == 0)
+        src = disk->src;
+    else
+        src = virStorageFileChainLookup(disk->src, NULL, NULL, idx, NULL);

  cleanup:
     VIR_FREE(target);
-- 
2.12.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] qemu: domain: Properly lookup top of chain in qemuDomainGetStorageSourceByDevstr
Posted by Eric Blake 7 years ago
On 03/29/2017 09:58 AM, Peter Krempa wrote:
> When idx is 0 virStorageFileChainLookup returns the base (bottom) of the
> backing chain rather than the top. This is expected by the callers of
> qemuDomainGetStorageSourceByDevstr.
> 
> Add a special case for idx == 0
> ---
> With this you are not able to specify the top image of a disk when using
> virDomainSetBlockThreshold in qemu.
> 
>  src/qemu/qemu_domain.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)

ACK

> 
> diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
> index 458bb5f9a..589eb1889 100644
> --- a/src/qemu/qemu_domain.c
> +++ b/src/qemu/qemu_domain.c
> @@ -8605,7 +8605,10 @@ qemuDomainGetStorageSourceByDevstr(const char *devstr,
>          goto cleanup;
>      }
> 
> -    src = virStorageFileChainLookup(disk->src, NULL, NULL, idx, NULL);
> +    if (idx == 0)
> +        src = disk->src;
> +    else
> +        src = virStorageFileChainLookup(disk->src, NULL, NULL, idx, NULL);
> 
>   cleanup:
>      VIR_FREE(target);
> 

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] qemu: domain: Properly lookup top of chain in qemuDomainGetStorageSourceByDevstr
Posted by Peter Krempa 7 years ago
On Wed, Mar 29, 2017 at 10:01:14 -0500, Eric Blake wrote:
> On 03/29/2017 09:58 AM, Peter Krempa wrote:
> > When idx is 0 virStorageFileChainLookup returns the base (bottom) of the
> > backing chain rather than the top. This is expected by the callers of
> > qemuDomainGetStorageSourceByDevstr.
> > 
> > Add a special case for idx == 0
> > ---
> > With this you are not able to specify the top image of a disk when using
> > virDomainSetBlockThreshold in qemu.
> > 
> >  src/qemu/qemu_domain.c | 5 ++++-
> >  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> ACK

Pushed; thanks for the quick review!

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