[libvirt] [PATCH] qemu: Don't update physical storage size of empty drives

Peter Krempa posted 1 patch 7 years, 1 month ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/3ab614d50d28b13abb71c8bb910c8a845f410cd8.1487841725.git.pkrempa@redhat.com
src/qemu/qemu_driver.c | 3 +++
1 file changed, 3 insertions(+)
[libvirt] [PATCH] qemu: Don't update physical storage size of empty drives
Posted by Peter Krempa 7 years, 1 month ago
Previously the code called virStorageSourceUpdateBlockPhysicalSize which
did not do anything on empty drives since it worked only on block
devices. After the refactor in c5f6151390 it's called for all devices
and thus attempts to deref the NULL path of empty drives.

Add a check that skips the update of the physical size if the storage
source is empty.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1420718
---
 src/qemu/qemu_driver.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 6e1e3d408..77d81755a 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -11336,6 +11336,9 @@ qemuDomainStorageUpdatePhysical(virQEMUDriverPtr driver,
     int fd = -1;
     struct stat sb;

+    if (virStorageSourceIsEmpty(src))
+        return 0;
+
     if (qemuDomainStorageOpenStat(driver, cfg, vm, src, &fd, &sb) < 0)
         return -1;

-- 
2.11.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] qemu: Don't update physical storage size of empty drives
Posted by Jiri Denemark 7 years, 1 month ago
On Thu, Feb 23, 2017 at 10:22:05 +0100, Peter Krempa wrote:
> Previously the code called virStorageSourceUpdateBlockPhysicalSize which
> did not do anything on empty drives since it worked only on block
> devices. After the refactor in c5f6151390 it's called for all devices
> and thus attempts to deref the NULL path of empty drives.
> 
> Add a check that skips the update of the physical size if the storage
> source is empty.
> 
> Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1420718
> ---
>  src/qemu/qemu_driver.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
> index 6e1e3d408..77d81755a 100644
> --- a/src/qemu/qemu_driver.c
> +++ b/src/qemu/qemu_driver.c
> @@ -11336,6 +11336,9 @@ qemuDomainStorageUpdatePhysical(virQEMUDriverPtr driver,
>      int fd = -1;
>      struct stat sb;
> 
> +    if (virStorageSourceIsEmpty(src))
> +        return 0;
> +
>      if (qemuDomainStorageOpenStat(driver, cfg, vm, src, &fd, &sb) < 0)
>          return -1;
> 

ACK

Jirka

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