From 0d60011f70d74cbdcf24485c8ec4b62653051638 Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: May 12 2020 12:35:42 +0000 Subject: import libvirt-4.5.0-33.el7_8.1 --- diff --git a/SOURCES/libvirt-vmx-make-fileName-optional-for-CD-ROMs.patch b/SOURCES/libvirt-vmx-make-fileName-optional-for-CD-ROMs.patch new file mode 100644 index 0000000..8ba56a5 --- /dev/null +++ b/SOURCES/libvirt-vmx-make-fileName-optional-for-CD-ROMs.patch @@ -0,0 +1,200 @@ +From 4dc1cae9cd7838a2d9dabac09d96955d95445449 Mon Sep 17 00:00:00 2001 +Message-Id: <4dc1cae9cd7838a2d9dabac09d96955d95445449@dist-git> +From: Pino Toscano +Date: Mon, 23 Mar 2020 08:49:58 +0100 +Subject: [PATCH] vmx: make 'fileName' optional for CD-ROMs +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +It seems like CD-ROMs may have no 'fileName' property specified in case +there is nothing configured as attachment for the drive. Hence, make +sure that virVMXParseDisk() do not consider it mandatory anymore, +considering it an empty block cdrom device. Sadly virVMXParseDisk() is +used also to parse disk and floppies, so make sure that a NULL fileName +is handled in cdrom- and floppy-related paths. + +https://bugzilla.redhat.com/show_bug.cgi?id=1808610 + +Signed-off-by: Pino Toscano +Reviewed-by: Ján Tomko +Tested-by: Richard W.M. Jones +(cherry picked from commit c5ee737bc5c0fc61451e45ff41526270bdf0113c) + +https://bugzilla.redhat.com/show_bug.cgi?id=1815269 +https://bugzilla.redhat.com/show_bug.cgi?id=1816035 +https://bugzilla.redhat.com/show_bug.cgi?id=1816034 + +Signed-off-by: Pino Toscano +Message-Id: <20200323074958.377314-3-ptoscano@redhat.com> +--- + src/vmx/vmx.c | 25 ++++++++++--------- + .../vmx2xmldata/vmx2xml-cdrom-ide-empty-2.vmx | 4 +++ + .../vmx2xmldata/vmx2xml-cdrom-ide-empty-2.xml | 23 +++++++++++++++++ + tests/vmx2xmltest.c | 1 + + 4 files changed, 41 insertions(+), 12 deletions(-) + create mode 100644 tests/vmx2xmldata/vmx2xml-cdrom-ide-empty-2.vmx + create mode 100644 tests/vmx2xmldata/vmx2xml-cdrom-ide-empty-2.xml + +diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c +index 89409870ff..14e5133ef7 100644 +--- a/src/vmx/vmx.c ++++ b/src/vmx/vmx.c +@@ -2204,7 +2204,7 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virConfPtr con + goto cleanup; + + /* vmx:fileName -> def:src, def:type */ +- if (virVMXGetConfigString(conf, fileName_name, &fileName, false) < 0) ++ if (virVMXGetConfigString(conf, fileName_name, &fileName, true) < 0) + goto cleanup; + + /* vmx:writeThrough -> def:cachemode */ +@@ -2215,7 +2215,8 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virConfPtr con + + /* Setup virDomainDiskDef */ + if (device == VIR_DOMAIN_DISK_DEVICE_DISK) { +- if (virFileHasSuffix(fileName, ".iso") || ++ if (fileName == NULL || ++ virFileHasSuffix(fileName, ".iso") || + STREQ(fileName, "emptyBackingString") || + (deviceType && + (STRCASEEQ(deviceType, "atapi-cdrom") || +@@ -2274,7 +2275,7 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virConfPtr con + goto cleanup; + } + } else if (device == VIR_DOMAIN_DISK_DEVICE_CDROM) { +- if (virFileHasSuffix(fileName, ".vmdk")) { ++ if (fileName && virFileHasSuffix(fileName, ".vmdk")) { + /* + * This function was called in order to parse a CDROM device, but + * .vmdk files are for harddisk devices only. Just ignore it, +@@ -2282,7 +2283,7 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virConfPtr con + * handle it. + */ + goto ignore; +- } else if (virFileHasSuffix(fileName, ".iso")) { ++ } else if (fileName && virFileHasSuffix(fileName, ".iso")) { + char *tmp; + + if (deviceType && STRCASENEQ(deviceType, "cdrom-image")) { +@@ -2303,7 +2304,7 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virConfPtr con + } else if (deviceType && STRCASEEQ(deviceType, "atapi-cdrom")) { + virDomainDiskSetType(*def, VIR_STORAGE_TYPE_BLOCK); + +- if (STRCASEEQ(fileName, "auto detect")) { ++ if (fileName && STRCASEEQ(fileName, "auto detect")) { + ignore_value(virDomainDiskSetSource(*def, NULL)); + (*def)->startupPolicy = VIR_DOMAIN_STARTUP_POLICY_OPTIONAL; + } else if (virDomainDiskSetSource(*def, fileName) < 0) { +@@ -2314,7 +2315,7 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virConfPtr con + (*def)->device = VIR_DOMAIN_DISK_DEVICE_LUN; + virDomainDiskSetType(*def, VIR_STORAGE_TYPE_BLOCK); + +- if (STRCASEEQ(fileName, "auto detect")) { ++ if (fileName && STRCASEEQ(fileName, "auto detect")) { + ignore_value(virDomainDiskSetSource(*def, NULL)); + (*def)->startupPolicy = VIR_DOMAIN_STARTUP_POLICY_OPTIONAL; + } else if (virDomainDiskSetSource(*def, fileName) < 0) { +@@ -2322,7 +2323,7 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virConfPtr con + } + } else if (busType == VIR_DOMAIN_DISK_BUS_SCSI && + deviceType && STRCASEEQ(deviceType, "scsi-passthru")) { +- if (STRPREFIX(fileName, "/vmfs/devices/cdrom/")) { ++ if (fileName && STRPREFIX(fileName, "/vmfs/devices/cdrom/")) { + /* SCSI-passthru CD-ROMs actually are device='lun' */ + (*def)->device = VIR_DOMAIN_DISK_DEVICE_LUN; + virDomainDiskSetType(*def, VIR_STORAGE_TYPE_BLOCK); +@@ -2338,7 +2339,7 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virConfPtr con + */ + goto ignore; + } +- } else if (STREQ(fileName, "emptyBackingString")) { ++ } else if (fileName && STREQ(fileName, "emptyBackingString")) { + if (deviceType && STRCASENEQ(deviceType, "cdrom-image")) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Expecting VMX entry '%s' to be 'cdrom-image' " +@@ -2352,7 +2353,7 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virConfPtr con + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Invalid or not yet handled value '%s' " + "for VMX entry '%s' for device type '%s'"), +- fileName, fileName_name, ++ NULLSTR(fileName), fileName_name, + deviceType ? deviceType : "unknown"); + goto cleanup; + } +@@ -2362,10 +2363,10 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virConfPtr con + if (virDomainDiskSetSource(*def, fileName) < 0) + goto cleanup; + } else if (fileType != NULL && STRCASEEQ(fileType, "file")) { +- char *tmp; ++ char *tmp = NULL; + + virDomainDiskSetType(*def, VIR_STORAGE_TYPE_FILE); +- if (!(tmp = ctx->parseFileName(fileName, ctx->opaque))) ++ if (fileName && !(tmp = ctx->parseFileName(fileName, ctx->opaque))) + goto cleanup; + if (virDomainDiskSetSource(*def, tmp) < 0) { + VIR_FREE(tmp); +@@ -2376,7 +2377,7 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virConfPtr con + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Invalid or not yet handled value '%s' " + "for VMX entry '%s' for device type '%s'"), +- fileName, fileName_name, ++ NULLSTR(fileName), fileName_name, + deviceType ? deviceType : "unknown"); + goto cleanup; + } +diff --git a/tests/vmx2xmldata/vmx2xml-cdrom-ide-empty-2.vmx b/tests/vmx2xmldata/vmx2xml-cdrom-ide-empty-2.vmx +new file mode 100644 +index 0000000000..36286cb20f +--- /dev/null ++++ b/tests/vmx2xmldata/vmx2xml-cdrom-ide-empty-2.vmx +@@ -0,0 +1,4 @@ ++config.version = "8" ++virtualHW.version = "4" ++ide0:0.present = "true" ++ide0:0.deviceType = "atapi-cdrom" +diff --git a/tests/vmx2xmldata/vmx2xml-cdrom-ide-empty-2.xml b/tests/vmx2xmldata/vmx2xml-cdrom-ide-empty-2.xml +new file mode 100644 +index 0000000000..af4a5ff9f6 +--- /dev/null ++++ b/tests/vmx2xmldata/vmx2xml-cdrom-ide-empty-2.xml +@@ -0,0 +1,23 @@ ++ ++ 00000000-0000-0000-0000-000000000000 ++ 32768 ++ 32768 ++ 1 ++ ++ hvm ++ ++ ++ destroy ++ restart ++ destroy ++ ++ ++ ++
++ ++ ++ ++ ++ +diff --git a/tests/vmx2xmltest.c b/tests/vmx2xmltest.c +index 7289dc91e3..143ff4c937 100644 +--- a/tests/vmx2xmltest.c ++++ b/tests/vmx2xmltest.c +@@ -227,6 +227,7 @@ mymain(void) + DO_TEST("cdrom-scsi-passthru", "cdrom-scsi-passthru"); + DO_TEST("cdrom-ide-file", "cdrom-ide-file"); + DO_TEST("cdrom-ide-empty", "cdrom-ide-empty"); ++ DO_TEST("cdrom-ide-empty-2", "cdrom-ide-empty-2"); + DO_TEST("cdrom-ide-device", "cdrom-ide-device"); + DO_TEST("cdrom-ide-raw-device", "cdrom-ide-raw-device"); + DO_TEST("cdrom-ide-raw-auto-detect", "cdrom-ide-raw-auto-detect"); +-- +2.25.2 + diff --git a/SOURCES/libvirt-vmx-shortcut-earlier-few-ignore-cases-in-virVMXParseDisk.patch b/SOURCES/libvirt-vmx-shortcut-earlier-few-ignore-cases-in-virVMXParseDisk.patch new file mode 100644 index 0000000..7ac8a59 --- /dev/null +++ b/SOURCES/libvirt-vmx-shortcut-earlier-few-ignore-cases-in-virVMXParseDisk.patch @@ -0,0 +1,112 @@ +From 9258231d7ff91fab9af219a38fbf36f95d48aeb5 Mon Sep 17 00:00:00 2001 +Message-Id: <9258231d7ff91fab9af219a38fbf36f95d48aeb5@dist-git> +From: Pino Toscano +Date: Mon, 23 Mar 2020 08:49:57 +0100 +Subject: [PATCH] vmx: shortcut earlier few 'ignore' cases in virVMXParseDisk() +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Move earlier the checks for skipping a hard disk when parsing a CD-DROM, +and for skipping a CD-ROM when parsing a hard disk. This should have no +behaviour changes, and avoids to add repeated checks in following +commits. + +Signed-off-by: Pino Toscano +Reviewed-by: Ján Tomko +Tested-by: Richard W.M. Jones +(cherry picked from commit 9a469c0d358bf3fd4b4e55b20360620d6fda44b5) + +https://bugzilla.redhat.com/show_bug.cgi?id=1815269 +https://bugzilla.redhat.com/show_bug.cgi?id=1816035 +https://bugzilla.redhat.com/show_bug.cgi?id=1816034 + +Signed-off-by: Pino Toscano +Message-Id: <20200323074958.377314-2-ptoscano@redhat.com> +--- + src/vmx/vmx.c | 48 ++++++++++++++++++++++++------------------------ + 1 file changed, 24 insertions(+), 24 deletions(-) + +diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c +index 937bf0c96b..89409870ff 100644 +--- a/src/vmx/vmx.c ++++ b/src/vmx/vmx.c +@@ -2215,7 +2215,21 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virConfPtr con + + /* Setup virDomainDiskDef */ + if (device == VIR_DOMAIN_DISK_DEVICE_DISK) { +- if (virFileHasSuffix(fileName, ".vmdk")) { ++ if (virFileHasSuffix(fileName, ".iso") || ++ STREQ(fileName, "emptyBackingString") || ++ (deviceType && ++ (STRCASEEQ(deviceType, "atapi-cdrom") || ++ STRCASEEQ(deviceType, "cdrom-raw") || ++ (STRCASEEQ(deviceType, "scsi-passthru") && ++ STRPREFIX(fileName, "/vmfs/devices/cdrom/"))))) { ++ /* ++ * This function was called in order to parse a harddisk device, ++ * but .iso files, 'atapi-cdrom', 'cdrom-raw', and 'scsi-passthru' ++ * CDROM devices are for CDROM devices only. Just ignore it, another ++ * call to this function to parse a CDROM device may handle it. ++ */ ++ goto ignore; ++ } else if (virFileHasSuffix(fileName, ".vmdk")) { + char *tmp; + + if (deviceType != NULL) { +@@ -2251,20 +2265,6 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virConfPtr con + if (mode) + (*def)->transient = STRCASEEQ(mode, + "independent-nonpersistent"); +- } else if (virFileHasSuffix(fileName, ".iso") || +- STREQ(fileName, "emptyBackingString") || +- (deviceType && +- (STRCASEEQ(deviceType, "atapi-cdrom") || +- STRCASEEQ(deviceType, "cdrom-raw") || +- (STRCASEEQ(deviceType, "scsi-passthru") && +- STRPREFIX(fileName, "/vmfs/devices/cdrom/"))))) { +- /* +- * This function was called in order to parse a harddisk device, +- * but .iso files, 'atapi-cdrom', 'cdrom-raw', and 'scsi-passthru' +- * CDROM devices are for CDROM devices only. Just ignore it, another +- * call to this function to parse a CDROM device may handle it. +- */ +- goto ignore; + } else { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Invalid or not yet handled value '%s' " +@@ -2274,7 +2274,15 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virConfPtr con + goto cleanup; + } + } else if (device == VIR_DOMAIN_DISK_DEVICE_CDROM) { +- if (virFileHasSuffix(fileName, ".iso")) { ++ if (virFileHasSuffix(fileName, ".vmdk")) { ++ /* ++ * This function was called in order to parse a CDROM device, but ++ * .vmdk files are for harddisk devices only. Just ignore it, ++ * another call to this function to parse a harddisk device may ++ * handle it. ++ */ ++ goto ignore; ++ } else if (virFileHasSuffix(fileName, ".iso")) { + char *tmp; + + if (deviceType && STRCASENEQ(deviceType, "cdrom-image")) { +@@ -2292,14 +2300,6 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virConfPtr con + goto cleanup; + } + VIR_FREE(tmp); +- } else if (virFileHasSuffix(fileName, ".vmdk")) { +- /* +- * This function was called in order to parse a CDROM device, but +- * .vmdk files are for harddisk devices only. Just ignore it, +- * another call to this function to parse a harddisk device may +- * handle it. +- */ +- goto ignore; + } else if (deviceType && STRCASEEQ(deviceType, "atapi-cdrom")) { + virDomainDiskSetType(*def, VIR_STORAGE_TYPE_BLOCK); + +-- +2.25.2 + diff --git a/SPECS/libvirt.spec b/SPECS/libvirt.spec index d68df15..91e38c4 100644 --- a/SPECS/libvirt.spec +++ b/SPECS/libvirt.spec @@ -253,7 +253,7 @@ Summary: Library providing a simple virtualization API Name: libvirt Version: 4.5.0 -Release: 33%{?dist}%{?extra_release} +Release: 33%{?dist}.1%{?extra_release} License: LGPLv2+ URL: https://libvirt.org/ @@ -630,6 +630,8 @@ Patch364: libvirt-process-wait-longer-5-30s-on-hard-shutdown.patch Patch365: libvirt-qemu-Don-t-emit-SUSPENDED_POSTCOPY-event-on-destination.patch Patch366: libvirt-node_device_conf-Don-t-leak-physical_function-in-virNodeDeviceGetPCISRIOVCaps.patch Patch367: libvirt-RHEL-qemuCheckUnprivSGIO-use-sysfs_path-to-get-unpriv_sgio.patch +Patch368: libvirt-vmx-shortcut-earlier-few-ignore-cases-in-virVMXParseDisk.patch +Patch369: libvirt-vmx-make-fileName-optional-for-CD-ROMs.patch Requires: libvirt-daemon = %{version}-%{release} Requires: libvirt-daemon-config-network = %{version}-%{release} @@ -2532,6 +2534,10 @@ exit 0 %changelog +* Mon Mar 23 2020 Jiri Denemark - 4.5.0-33.el7_8.1 +- vmx: shortcut earlier few 'ignore' cases in virVMXParseDisk() (rhbz#1816035) +- vmx: make 'fileName' optional for CD-ROMs (rhbz#1816035) + * Fri Feb 14 2020 Jiri Denemark - 4.5.0-33 - RHEL: qemuCheckUnprivSGIO: use @sysfs_path to get unpriv_sgio (rhbz#1801139)