|
|
7a3408 |
From cc4d319a6eb8213079f32119714b7f686e4bf7ba Mon Sep 17 00:00:00 2001
|
|
|
7a3408 |
Message-Id: <cc4d319a6eb8213079f32119714b7f686e4bf7ba@dist-git>
|
|
|
7a3408 |
From: Matthias Bolte <matthias.bolte@googlemail.com>
|
|
|
7a3408 |
Date: Tue, 8 Sep 2015 09:52:58 +0200
|
|
|
7a3408 |
Subject: [PATCH] vmx: The virVMXParseDisk deviceType can be NULL, add some
|
|
|
7a3408 |
missing checks
|
|
|
7a3408 |
|
|
|
7a3408 |
https://bugzilla.redhat.com/show_bug.cgi?id=1172544
|
|
|
7a3408 |
|
|
|
7a3408 |
(cherry picked from commit 7c959e0dc036c0e9d4429ec5528c693b5e5e9929)
|
|
|
7a3408 |
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
|
|
|
7a3408 |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
7a3408 |
---
|
|
|
7a3408 |
src/vmx/vmx.c | 21 ++++++++++-----------
|
|
|
7a3408 |
1 file changed, 10 insertions(+), 11 deletions(-)
|
|
|
7a3408 |
|
|
|
7a3408 |
diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c
|
|
|
7a3408 |
index 3b23c0d..799668c 100644
|
|
|
7a3408 |
--- a/src/vmx/vmx.c
|
|
|
7a3408 |
+++ b/src/vmx/vmx.c
|
|
|
7a3408 |
@@ -2176,8 +2176,9 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virConfPtr con
|
|
|
7a3408 |
(*def)->transient = STRCASEEQ(mode,
|
|
|
7a3408 |
"independent-nonpersistent");
|
|
|
7a3408 |
} else if (virFileHasSuffix(fileName, ".iso") ||
|
|
|
7a3408 |
- STRCASEEQ(deviceType, "atapi-cdrom") ||
|
|
|
7a3408 |
- STRCASEEQ(deviceType, "cdrom-raw")) {
|
|
|
7a3408 |
+ (deviceType &&
|
|
|
7a3408 |
+ (STRCASEEQ(deviceType, "atapi-cdrom") ||
|
|
|
7a3408 |
+ STRCASEEQ(deviceType, "cdrom-raw")))) {
|
|
|
7a3408 |
/*
|
|
|
7a3408 |
* This function was called in order to parse a harddisk device,
|
|
|
7a3408 |
* but .iso files, 'atapi-cdrom', and 'cdrom-raw' devices are for
|
|
|
7a3408 |
@@ -2197,13 +2198,11 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virConfPtr con
|
|
|
7a3408 |
if (virFileHasSuffix(fileName, ".iso")) {
|
|
|
7a3408 |
char *tmp;
|
|
|
7a3408 |
|
|
|
7a3408 |
- if (deviceType != NULL) {
|
|
|
7a3408 |
- if (STRCASENEQ(deviceType, "cdrom-image")) {
|
|
|
7a3408 |
- virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
7a3408 |
- _("Expecting VMX entry '%s' to be 'cdrom-image' "
|
|
|
7a3408 |
- "but found '%s'"), deviceType_name, deviceType);
|
|
|
7a3408 |
- goto cleanup;
|
|
|
7a3408 |
- }
|
|
|
7a3408 |
+ if (deviceType && STRCASENEQ(deviceType, "cdrom-image")) {
|
|
|
7a3408 |
+ virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
7a3408 |
+ _("Expecting VMX entry '%s' to be 'cdrom-image' "
|
|
|
7a3408 |
+ "but found '%s'"), deviceType_name, deviceType);
|
|
|
7a3408 |
+ goto cleanup;
|
|
|
7a3408 |
}
|
|
|
7a3408 |
|
|
|
7a3408 |
virDomainDiskSetType(*def, VIR_STORAGE_TYPE_FILE);
|
|
|
7a3408 |
@@ -2222,7 +2221,7 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virConfPtr con
|
|
|
7a3408 |
* handle it.
|
|
|
7a3408 |
*/
|
|
|
7a3408 |
goto ignore;
|
|
|
7a3408 |
- } else if (STRCASEEQ(deviceType, "atapi-cdrom")) {
|
|
|
7a3408 |
+ } else if (deviceType && STRCASEEQ(deviceType, "atapi-cdrom")) {
|
|
|
7a3408 |
virDomainDiskSetType(*def, VIR_STORAGE_TYPE_BLOCK);
|
|
|
7a3408 |
|
|
|
7a3408 |
if (STRCASEEQ(fileName, "auto detect")) {
|
|
|
7a3408 |
@@ -2231,7 +2230,7 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virConfPtr con
|
|
|
7a3408 |
} else if (virDomainDiskSetSource(*def, fileName) < 0) {
|
|
|
7a3408 |
goto cleanup;
|
|
|
7a3408 |
}
|
|
|
7a3408 |
- } else if (STRCASEEQ(deviceType, "cdrom-raw")) {
|
|
|
7a3408 |
+ } else if (deviceType && STRCASEEQ(deviceType, "cdrom-raw")) {
|
|
|
7a3408 |
/* Raw access CD-ROMs actually are device='lun' */
|
|
|
7a3408 |
(*def)->device = VIR_DOMAIN_DISK_DEVICE_LUN;
|
|
|
7a3408 |
virDomainDiskSetType(*def, VIR_STORAGE_TYPE_BLOCK);
|
|
|
7a3408 |
--
|
|
|
7a3408 |
2.5.2
|
|
|
7a3408 |
|