|
|
03cc27 |
From 7fd73c056fa74ab32f5976ccbd2ce516f504088a Mon Sep 17 00:00:00 2001
|
|
|
03cc27 |
Message-Id: <7fd73c056fa74ab32f5976ccbd2ce516f504088a@dist-git>
|
|
|
0d6001 |
From: Pino Toscano <ptoscano@redhat.com>
|
|
|
0d6001 |
Date: Mon, 23 Mar 2020 08:49:58 +0100
|
|
|
0d6001 |
Subject: [PATCH] vmx: make 'fileName' optional for CD-ROMs
|
|
|
0d6001 |
MIME-Version: 1.0
|
|
|
0d6001 |
Content-Type: text/plain; charset=UTF-8
|
|
|
0d6001 |
Content-Transfer-Encoding: 8bit
|
|
|
0d6001 |
|
|
|
0d6001 |
It seems like CD-ROMs may have no 'fileName' property specified in case
|
|
|
0d6001 |
there is nothing configured as attachment for the drive. Hence, make
|
|
|
0d6001 |
sure that virVMXParseDisk() do not consider it mandatory anymore,
|
|
|
0d6001 |
considering it an empty block cdrom device. Sadly virVMXParseDisk() is
|
|
|
0d6001 |
used also to parse disk and floppies, so make sure that a NULL fileName
|
|
|
0d6001 |
is handled in cdrom- and floppy-related paths.
|
|
|
0d6001 |
|
|
|
0d6001 |
https://bugzilla.redhat.com/show_bug.cgi?id=1808610
|
|
|
0d6001 |
|
|
|
0d6001 |
Signed-off-by: Pino Toscano <ptoscano@redhat.com>
|
|
|
0d6001 |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
0d6001 |
Tested-by: Richard W.M. Jones <rjones@redhat.com>
|
|
|
0d6001 |
(cherry picked from commit c5ee737bc5c0fc61451e45ff41526270bdf0113c)
|
|
|
0d6001 |
|
|
|
0d6001 |
https://bugzilla.redhat.com/show_bug.cgi?id=1815269
|
|
|
0d6001 |
https://bugzilla.redhat.com/show_bug.cgi?id=1816035
|
|
|
0d6001 |
https://bugzilla.redhat.com/show_bug.cgi?id=1816034
|
|
|
0d6001 |
|
|
|
0d6001 |
Signed-off-by: Pino Toscano <ptoscano@redhat.com>
|
|
|
0d6001 |
Message-Id: <20200323074958.377314-3-ptoscano@redhat.com>
|
|
|
03cc27 |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
0d6001 |
---
|
|
|
0d6001 |
src/vmx/vmx.c | 25 ++++++++++---------
|
|
|
0d6001 |
.../vmx2xmldata/vmx2xml-cdrom-ide-empty-2.vmx | 4 +++
|
|
|
0d6001 |
.../vmx2xmldata/vmx2xml-cdrom-ide-empty-2.xml | 23 +++++++++++++++++
|
|
|
0d6001 |
tests/vmx2xmltest.c | 1 +
|
|
|
0d6001 |
4 files changed, 41 insertions(+), 12 deletions(-)
|
|
|
0d6001 |
create mode 100644 tests/vmx2xmldata/vmx2xml-cdrom-ide-empty-2.vmx
|
|
|
0d6001 |
create mode 100644 tests/vmx2xmldata/vmx2xml-cdrom-ide-empty-2.xml
|
|
|
0d6001 |
|
|
|
0d6001 |
diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c
|
|
|
0d6001 |
index 89409870ff..14e5133ef7 100644
|
|
|
0d6001 |
--- a/src/vmx/vmx.c
|
|
|
0d6001 |
+++ b/src/vmx/vmx.c
|
|
|
0d6001 |
@@ -2204,7 +2204,7 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virConfPtr con
|
|
|
0d6001 |
goto cleanup;
|
|
|
0d6001 |
|
|
|
0d6001 |
/* vmx:fileName -> def:src, def:type */
|
|
|
0d6001 |
- if (virVMXGetConfigString(conf, fileName_name, &fileName, false) < 0)
|
|
|
0d6001 |
+ if (virVMXGetConfigString(conf, fileName_name, &fileName, true) < 0)
|
|
|
0d6001 |
goto cleanup;
|
|
|
0d6001 |
|
|
|
0d6001 |
/* vmx:writeThrough -> def:cachemode */
|
|
|
0d6001 |
@@ -2215,7 +2215,8 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virConfPtr con
|
|
|
0d6001 |
|
|
|
0d6001 |
/* Setup virDomainDiskDef */
|
|
|
0d6001 |
if (device == VIR_DOMAIN_DISK_DEVICE_DISK) {
|
|
|
0d6001 |
- if (virFileHasSuffix(fileName, ".iso") ||
|
|
|
0d6001 |
+ if (fileName == NULL ||
|
|
|
0d6001 |
+ virFileHasSuffix(fileName, ".iso") ||
|
|
|
0d6001 |
STREQ(fileName, "emptyBackingString") ||
|
|
|
0d6001 |
(deviceType &&
|
|
|
0d6001 |
(STRCASEEQ(deviceType, "atapi-cdrom") ||
|
|
|
0d6001 |
@@ -2274,7 +2275,7 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virConfPtr con
|
|
|
0d6001 |
goto cleanup;
|
|
|
0d6001 |
}
|
|
|
0d6001 |
} else if (device == VIR_DOMAIN_DISK_DEVICE_CDROM) {
|
|
|
0d6001 |
- if (virFileHasSuffix(fileName, ".vmdk")) {
|
|
|
0d6001 |
+ if (fileName && virFileHasSuffix(fileName, ".vmdk")) {
|
|
|
0d6001 |
/*
|
|
|
0d6001 |
* This function was called in order to parse a CDROM device, but
|
|
|
0d6001 |
* .vmdk files are for harddisk devices only. Just ignore it,
|
|
|
0d6001 |
@@ -2282,7 +2283,7 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virConfPtr con
|
|
|
0d6001 |
* handle it.
|
|
|
0d6001 |
*/
|
|
|
0d6001 |
goto ignore;
|
|
|
0d6001 |
- } else if (virFileHasSuffix(fileName, ".iso")) {
|
|
|
0d6001 |
+ } else if (fileName && virFileHasSuffix(fileName, ".iso")) {
|
|
|
0d6001 |
char *tmp;
|
|
|
0d6001 |
|
|
|
0d6001 |
if (deviceType && STRCASENEQ(deviceType, "cdrom-image")) {
|
|
|
0d6001 |
@@ -2303,7 +2304,7 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virConfPtr con
|
|
|
0d6001 |
} else if (deviceType && STRCASEEQ(deviceType, "atapi-cdrom")) {
|
|
|
0d6001 |
virDomainDiskSetType(*def, VIR_STORAGE_TYPE_BLOCK);
|
|
|
0d6001 |
|
|
|
0d6001 |
- if (STRCASEEQ(fileName, "auto detect")) {
|
|
|
0d6001 |
+ if (fileName && STRCASEEQ(fileName, "auto detect")) {
|
|
|
0d6001 |
ignore_value(virDomainDiskSetSource(*def, NULL));
|
|
|
0d6001 |
(*def)->startupPolicy = VIR_DOMAIN_STARTUP_POLICY_OPTIONAL;
|
|
|
0d6001 |
} else if (virDomainDiskSetSource(*def, fileName) < 0) {
|
|
|
0d6001 |
@@ -2314,7 +2315,7 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virConfPtr con
|
|
|
0d6001 |
(*def)->device = VIR_DOMAIN_DISK_DEVICE_LUN;
|
|
|
0d6001 |
virDomainDiskSetType(*def, VIR_STORAGE_TYPE_BLOCK);
|
|
|
0d6001 |
|
|
|
0d6001 |
- if (STRCASEEQ(fileName, "auto detect")) {
|
|
|
0d6001 |
+ if (fileName && STRCASEEQ(fileName, "auto detect")) {
|
|
|
0d6001 |
ignore_value(virDomainDiskSetSource(*def, NULL));
|
|
|
0d6001 |
(*def)->startupPolicy = VIR_DOMAIN_STARTUP_POLICY_OPTIONAL;
|
|
|
0d6001 |
} else if (virDomainDiskSetSource(*def, fileName) < 0) {
|
|
|
0d6001 |
@@ -2322,7 +2323,7 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virConfPtr con
|
|
|
0d6001 |
}
|
|
|
0d6001 |
} else if (busType == VIR_DOMAIN_DISK_BUS_SCSI &&
|
|
|
0d6001 |
deviceType && STRCASEEQ(deviceType, "scsi-passthru")) {
|
|
|
0d6001 |
- if (STRPREFIX(fileName, "/vmfs/devices/cdrom/")) {
|
|
|
0d6001 |
+ if (fileName && STRPREFIX(fileName, "/vmfs/devices/cdrom/")) {
|
|
|
0d6001 |
/* SCSI-passthru CD-ROMs actually are device='lun' */
|
|
|
0d6001 |
(*def)->device = VIR_DOMAIN_DISK_DEVICE_LUN;
|
|
|
0d6001 |
virDomainDiskSetType(*def, VIR_STORAGE_TYPE_BLOCK);
|
|
|
0d6001 |
@@ -2338,7 +2339,7 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virConfPtr con
|
|
|
0d6001 |
*/
|
|
|
0d6001 |
goto ignore;
|
|
|
0d6001 |
}
|
|
|
0d6001 |
- } else if (STREQ(fileName, "emptyBackingString")) {
|
|
|
0d6001 |
+ } else if (fileName && STREQ(fileName, "emptyBackingString")) {
|
|
|
0d6001 |
if (deviceType && STRCASENEQ(deviceType, "cdrom-image")) {
|
|
|
0d6001 |
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
0d6001 |
_("Expecting VMX entry '%s' to be 'cdrom-image' "
|
|
|
0d6001 |
@@ -2352,7 +2353,7 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virConfPtr con
|
|
|
0d6001 |
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
0d6001 |
_("Invalid or not yet handled value '%s' "
|
|
|
0d6001 |
"for VMX entry '%s' for device type '%s'"),
|
|
|
0d6001 |
- fileName, fileName_name,
|
|
|
0d6001 |
+ NULLSTR(fileName), fileName_name,
|
|
|
0d6001 |
deviceType ? deviceType : "unknown");
|
|
|
0d6001 |
goto cleanup;
|
|
|
0d6001 |
}
|
|
|
0d6001 |
@@ -2362,10 +2363,10 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virConfPtr con
|
|
|
0d6001 |
if (virDomainDiskSetSource(*def, fileName) < 0)
|
|
|
0d6001 |
goto cleanup;
|
|
|
0d6001 |
} else if (fileType != NULL && STRCASEEQ(fileType, "file")) {
|
|
|
0d6001 |
- char *tmp;
|
|
|
0d6001 |
+ char *tmp = NULL;
|
|
|
0d6001 |
|
|
|
0d6001 |
virDomainDiskSetType(*def, VIR_STORAGE_TYPE_FILE);
|
|
|
0d6001 |
- if (!(tmp = ctx->parseFileName(fileName, ctx->opaque)))
|
|
|
0d6001 |
+ if (fileName && !(tmp = ctx->parseFileName(fileName, ctx->opaque)))
|
|
|
0d6001 |
goto cleanup;
|
|
|
0d6001 |
if (virDomainDiskSetSource(*def, tmp) < 0) {
|
|
|
0d6001 |
VIR_FREE(tmp);
|
|
|
0d6001 |
@@ -2376,7 +2377,7 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virConfPtr con
|
|
|
0d6001 |
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
0d6001 |
_("Invalid or not yet handled value '%s' "
|
|
|
0d6001 |
"for VMX entry '%s' for device type '%s'"),
|
|
|
0d6001 |
- fileName, fileName_name,
|
|
|
0d6001 |
+ NULLSTR(fileName), fileName_name,
|
|
|
0d6001 |
deviceType ? deviceType : "unknown");
|
|
|
0d6001 |
goto cleanup;
|
|
|
0d6001 |
}
|
|
|
0d6001 |
diff --git a/tests/vmx2xmldata/vmx2xml-cdrom-ide-empty-2.vmx b/tests/vmx2xmldata/vmx2xml-cdrom-ide-empty-2.vmx
|
|
|
0d6001 |
new file mode 100644
|
|
|
0d6001 |
index 0000000000..36286cb20f
|
|
|
0d6001 |
--- /dev/null
|
|
|
0d6001 |
+++ b/tests/vmx2xmldata/vmx2xml-cdrom-ide-empty-2.vmx
|
|
|
0d6001 |
@@ -0,0 +1,4 @@
|
|
|
0d6001 |
+config.version = "8"
|
|
|
0d6001 |
+virtualHW.version = "4"
|
|
|
0d6001 |
+ide0:0.present = "true"
|
|
|
0d6001 |
+ide0:0.deviceType = "atapi-cdrom"
|
|
|
0d6001 |
diff --git a/tests/vmx2xmldata/vmx2xml-cdrom-ide-empty-2.xml b/tests/vmx2xmldata/vmx2xml-cdrom-ide-empty-2.xml
|
|
|
0d6001 |
new file mode 100644
|
|
|
0d6001 |
index 0000000000..af4a5ff9f6
|
|
|
0d6001 |
--- /dev/null
|
|
|
0d6001 |
+++ b/tests/vmx2xmldata/vmx2xml-cdrom-ide-empty-2.xml
|
|
|
0d6001 |
@@ -0,0 +1,23 @@
|
|
|
0d6001 |
+<domain type='vmware'>
|
|
|
0d6001 |
+ <uuid>00000000-0000-0000-0000-000000000000</uuid>
|
|
|
0d6001 |
+ <memory unit='KiB'>32768</memory>
|
|
|
0d6001 |
+ <currentMemory unit='KiB'>32768</currentMemory>
|
|
|
0d6001 |
+ <vcpu placement='static'>1</vcpu>
|
|
|
0d6001 |
+ <os>
|
|
|
0d6001 |
+ <type arch='i686'>hvm</type>
|
|
|
0d6001 |
+ </os>
|
|
|
0d6001 |
+ <clock offset='utc'/>
|
|
|
0d6001 |
+ <on_poweroff>destroy</on_poweroff>
|
|
|
0d6001 |
+ <on_reboot>restart</on_reboot>
|
|
|
0d6001 |
+ <on_crash>destroy</on_crash>
|
|
|
0d6001 |
+ <devices>
|
|
|
0d6001 |
+ <disk type='block' device='cdrom'>
|
|
|
0d6001 |
+ <target dev='hda' bus='ide'/>
|
|
|
0d6001 |
+ <address type='drive' controller='0' bus='0' target='0' unit='0'/>
|
|
|
0d6001 |
+ </disk>
|
|
|
0d6001 |
+ <controller type='ide' index='0'/>
|
|
|
0d6001 |
+ <video>
|
|
|
0d6001 |
+ <model type='vmvga' vram='4096' primary='yes'/>
|
|
|
0d6001 |
+ </video>
|
|
|
0d6001 |
+ </devices>
|
|
|
0d6001 |
+</domain>
|
|
|
0d6001 |
diff --git a/tests/vmx2xmltest.c b/tests/vmx2xmltest.c
|
|
|
0d6001 |
index 7289dc91e3..143ff4c937 100644
|
|
|
0d6001 |
--- a/tests/vmx2xmltest.c
|
|
|
0d6001 |
+++ b/tests/vmx2xmltest.c
|
|
|
0d6001 |
@@ -227,6 +227,7 @@ mymain(void)
|
|
|
0d6001 |
DO_TEST("cdrom-scsi-passthru", "cdrom-scsi-passthru");
|
|
|
0d6001 |
DO_TEST("cdrom-ide-file", "cdrom-ide-file");
|
|
|
0d6001 |
DO_TEST("cdrom-ide-empty", "cdrom-ide-empty");
|
|
|
0d6001 |
+ DO_TEST("cdrom-ide-empty-2", "cdrom-ide-empty-2");
|
|
|
0d6001 |
DO_TEST("cdrom-ide-device", "cdrom-ide-device");
|
|
|
0d6001 |
DO_TEST("cdrom-ide-raw-device", "cdrom-ide-raw-device");
|
|
|
0d6001 |
DO_TEST("cdrom-ide-raw-auto-detect", "cdrom-ide-raw-auto-detect");
|
|
|
0d6001 |
--
|
|
|
03cc27 |
2.26.0
|
|
|
0d6001 |
|