[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] [PATCH] qemu: Avoid crash in qemuDiskGetActualType

On 22/01/14 18:18, Peter Krempa wrote:
Libvirtd would crash if a domain contained an empty cdrom drive of
type='volume' as the disk def->srcpool member would be dereferenced. Fix
it by checking if the source pool is present before dereferencing it.

Also alter tests to catch this issue in the future.

Reported by: Kevin Shanahan
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1056328
  src/qemu/qemu_conf.c                                      | 2 +-
  tests/qemuxml2argvdata/qemuxml2argv-disk-source-pool.args | 2 ++
  tests/qemuxml2argvdata/qemuxml2argv-disk-source-pool.xml  | 6 ++++++
  3 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 4378791..ac53f6d 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -1302,7 +1302,7 @@ cleanup:
  qemuDiskGetActualType(virDomainDiskDefPtr def)
-    if (def->type == VIR_DOMAIN_DISK_TYPE_VOLUME)
+    if (def->type == VIR_DOMAIN_DISK_TYPE_VOLUME && def->srcpool)
          return def->srcpool->actualtype;

Returning the type as "volume" should be fine, since there is no
"case" statement for "volume" type when building the drive's
command line, and the "source" is empty anyway.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]