7a3408
From af566a030c4a70ed037eda075a4c09f14732482b Mon Sep 17 00:00:00 2001
7a3408
Message-Id: <af566a030c4a70ed037eda075a4c09f14732482b@dist-git>
7a3408
From: Cole Robinson <crobinso@redhat.com>
7a3408
Date: Wed, 12 Aug 2015 10:47:16 +0200
7a3408
Subject: [PATCH] domain: Fix crash if trying to live update disk <serial>
7a3408
7a3408
https://bugzilla.redhat.com/show_bug.cgi?id=1007228
7a3408
7a3408
If you pass <disk><serial> XML to UpdateDevice, and the original device
7a3408
didn't have a <serial> block, libvirtd crashes trying to read the original
7a3408
NULL serial string.
7a3408
7a3408
Use _NULLABLE string comparisons to avoid the crash. A couple other
7a3408
properties needed the change too.
7a3408
7a3408
(cherry picked from commit c7790408d7e16b1ad00a690433d9310f104994f7)
7a3408
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
7a3408
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
7a3408
---
7a3408
 src/conf/domain_conf.c | 8 ++++----
7a3408
 1 file changed, 4 insertions(+), 4 deletions(-)
7a3408
7a3408
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
7a3408
index aa1b860..8784367 100644
7a3408
--- a/src/conf/domain_conf.c
7a3408
+++ b/src/conf/domain_conf.c
7a3408
@@ -5783,28 +5783,28 @@ virDomainDiskDiffersSourceOnly(virDomainDiskDefPtr disk,
7a3408
 
7a3408
     CHECK_EQ(transient, "transient", true);
7a3408
 
7a3408
-    if (disk->serial && STRNEQ(disk->serial, orig_disk->serial)) {
7a3408
+    if (disk->serial && STRNEQ_NULLABLE(disk->serial, orig_disk->serial)) {
7a3408
         virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
7a3408
                        _("cannot modify field '%s' of the disk"),
7a3408
                        "serial");
7a3408
         return false;
7a3408
     }
7a3408
 
7a3408
-    if (disk->wwn && STRNEQ(disk->wwn, orig_disk->wwn)) {
7a3408
+    if (disk->wwn && STRNEQ_NULLABLE(disk->wwn, orig_disk->wwn)) {
7a3408
         virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
7a3408
                        _("cannot modify field '%s' of the disk"),
7a3408
                        "wwn");
7a3408
         return false;
7a3408
     }
7a3408
 
7a3408
-    if (disk->vendor && STRNEQ(disk->vendor, orig_disk->vendor)) {
7a3408
+    if (disk->vendor && STRNEQ_NULLABLE(disk->vendor, orig_disk->vendor)) {
7a3408
         virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
7a3408
                        _("cannot modify field '%s' of the disk"),
7a3408
                        "vendor");
7a3408
         return false;
7a3408
     }
7a3408
 
7a3408
-    if (disk->product && STRNEQ(disk->product, orig_disk->product)) {
7a3408
+    if (disk->product && STRNEQ_NULLABLE(disk->product, orig_disk->product)) {
7a3408
         virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
7a3408
                        _("cannot modify field '%s' of the disk"),
7a3408
                        "product");
7a3408
-- 
7a3408
2.5.0
7a3408