|
|
404507 |
From aa56a230d346174047f4d21b127bdbea52a1ce3c Mon Sep 17 00:00:00 2001
|
|
|
404507 |
Message-Id: <aa56a230d346174047f4d21b127bdbea52a1ce3c@dist-git>
|
|
|
404507 |
From: Peter Krempa <pkrempa@redhat.com>
|
|
|
404507 |
Date: Mon, 13 Nov 2017 13:43:21 +0100
|
|
|
404507 |
Subject: [PATCH] qemu: Tolerate storage source private data being NULL
|
|
|
404507 |
|
|
|
404507 |
In some cases it does not make sense to pursue that the private data
|
|
|
404507 |
will be allocated (especially when we don't need to put anything in it).
|
|
|
404507 |
|
|
|
404507 |
Ensure that the code works without it.
|
|
|
404507 |
|
|
|
404507 |
This also fixes few crashes pointed out in
|
|
|
404507 |
https://bugzilla.redhat.com/show_bug.cgi?id=1510323
|
|
|
404507 |
|
|
|
404507 |
(cherry picked from commit 8056721cbb75a717604a1f7971440726d9d85045)
|
|
|
404507 |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
404507 |
---
|
|
|
404507 |
src/qemu/qemu_command.c | 18 ++++++++++++++----
|
|
|
404507 |
src/qemu/qemu_hotplug.c | 17 ++++++++++++-----
|
|
|
404507 |
2 files changed, 26 insertions(+), 9 deletions(-)
|
|
|
404507 |
|
|
|
404507 |
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
|
|
|
404507 |
index f8eb59884c..e60f93083f 100644
|
|
|
404507 |
--- a/src/qemu/qemu_command.c
|
|
|
404507 |
+++ b/src/qemu/qemu_command.c
|
|
|
404507 |
@@ -1362,12 +1362,17 @@ qemuBuildDriveSourceStr(virDomainDiskDefPtr disk,
|
|
|
404507 |
{
|
|
|
404507 |
int actualType = virStorageSourceGetActualType(disk->src);
|
|
|
404507 |
qemuDomainStorageSourcePrivatePtr srcpriv = QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(disk->src);
|
|
|
404507 |
- qemuDomainSecretInfoPtr secinfo = srcpriv->secinfo;
|
|
|
404507 |
- qemuDomainSecretInfoPtr encinfo = srcpriv->encinfo;
|
|
|
404507 |
+ qemuDomainSecretInfoPtr secinfo = NULL;
|
|
|
404507 |
+ qemuDomainSecretInfoPtr encinfo = NULL;
|
|
|
404507 |
virJSONValuePtr srcprops = NULL;
|
|
|
404507 |
char *source = NULL;
|
|
|
404507 |
int ret = -1;
|
|
|
404507 |
|
|
|
404507 |
+ if (srcpriv) {
|
|
|
404507 |
+ secinfo = srcpriv->secinfo;
|
|
|
404507 |
+ encinfo = srcpriv->encinfo;
|
|
|
404507 |
+ }
|
|
|
404507 |
+
|
|
|
404507 |
if (qemuDiskSourceNeedsProps(disk->src) &&
|
|
|
404507 |
!(srcprops = qemuDiskSourceGetProps(disk->src)))
|
|
|
404507 |
goto cleanup;
|
|
|
404507 |
@@ -2239,8 +2244,13 @@ qemuBuildDiskDriveCommandLine(virCommandPtr cmd,
|
|
|
404507 |
bool driveBoot = false;
|
|
|
404507 |
virDomainDiskDefPtr disk = def->disks[i];
|
|
|
404507 |
qemuDomainStorageSourcePrivatePtr srcPriv = QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(disk->src);
|
|
|
404507 |
- qemuDomainSecretInfoPtr secinfo = srcPriv->secinfo;
|
|
|
404507 |
- qemuDomainSecretInfoPtr encinfo = srcPriv->encinfo;
|
|
|
404507 |
+ qemuDomainSecretInfoPtr secinfo = NULL;
|
|
|
404507 |
+ qemuDomainSecretInfoPtr encinfo = NULL;
|
|
|
404507 |
+
|
|
|
404507 |
+ if (srcPriv) {
|
|
|
404507 |
+ secinfo = srcPriv->secinfo;
|
|
|
404507 |
+ encinfo = srcPriv->encinfo;
|
|
|
404507 |
+ }
|
|
|
404507 |
|
|
|
404507 |
if (disk->info.bootIndex) {
|
|
|
404507 |
bootindex = disk->info.bootIndex;
|
|
|
404507 |
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
|
|
|
404507 |
index 5701c033be..edf07d0b65 100644
|
|
|
404507 |
--- a/src/qemu/qemu_hotplug.c
|
|
|
404507 |
+++ b/src/qemu/qemu_hotplug.c
|
|
|
404507 |
@@ -259,6 +259,7 @@ qemuDomainChangeEjectableMedia(virQEMUDriverPtr driver,
|
|
|
404507 |
qemuDomainObjPrivatePtr priv = vm->privateData;
|
|
|
404507 |
qemuDomainDiskPrivatePtr diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
|
|
|
404507 |
qemuDomainStorageSourcePrivatePtr srcPriv = QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(disk->src);
|
|
|
404507 |
+ qemuDomainSecretInfoPtr secinfo = NULL;
|
|
|
404507 |
const char *format = NULL;
|
|
|
404507 |
char *sourcestr = NULL;
|
|
|
404507 |
|
|
|
404507 |
@@ -268,6 +269,9 @@ qemuDomainChangeEjectableMedia(virQEMUDriverPtr driver,
|
|
|
404507 |
goto cleanup;
|
|
|
404507 |
}
|
|
|
404507 |
|
|
|
404507 |
+ if (srcPriv)
|
|
|
404507 |
+ secinfo = srcPriv->secinfo;
|
|
|
404507 |
+
|
|
|
404507 |
if (disk->device != VIR_DOMAIN_DISK_DEVICE_FLOPPY &&
|
|
|
404507 |
disk->device != VIR_DOMAIN_DISK_DEVICE_CDROM) {
|
|
|
404507 |
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
404507 |
@@ -300,7 +304,7 @@ qemuDomainChangeEjectableMedia(virQEMUDriverPtr driver,
|
|
|
404507 |
}
|
|
|
404507 |
|
|
|
404507 |
if (!virStorageSourceIsEmpty(newsrc)) {
|
|
|
404507 |
- if (qemuGetDriveSourceString(newsrc, srcPriv->secinfo, &sourcestr) < 0)
|
|
|
404507 |
+ if (qemuGetDriveSourceString(newsrc, secinfo, &sourcestr) < 0)
|
|
|
404507 |
goto error;
|
|
|
404507 |
|
|
|
404507 |
if (virStorageSourceGetActualType(newsrc) != VIR_STORAGE_TYPE_DIR) {
|
|
|
404507 |
@@ -371,8 +375,8 @@ qemuDomainAttachDiskGeneric(virConnectPtr conn,
|
|
|
404507 |
virJSONValuePtr secobjProps = NULL;
|
|
|
404507 |
virJSONValuePtr encobjProps = NULL;
|
|
|
404507 |
qemuDomainStorageSourcePrivatePtr srcPriv;
|
|
|
404507 |
- qemuDomainSecretInfoPtr secinfo;
|
|
|
404507 |
- qemuDomainSecretInfoPtr encinfo;
|
|
|
404507 |
+ qemuDomainSecretInfoPtr secinfo = NULL;
|
|
|
404507 |
+ qemuDomainSecretInfoPtr encinfo = NULL;
|
|
|
404507 |
|
|
|
404507 |
if (qemuDomainPrepareDisk(driver, vm, disk, NULL, false) < 0)
|
|
|
404507 |
goto cleanup;
|
|
|
404507 |
@@ -384,13 +388,16 @@ qemuDomainAttachDiskGeneric(virConnectPtr conn,
|
|
|
404507 |
goto error;
|
|
|
404507 |
|
|
|
404507 |
srcPriv = QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(disk->src);
|
|
|
404507 |
- secinfo = srcPriv->secinfo;
|
|
|
404507 |
+ if (srcPriv) {
|
|
|
404507 |
+ secinfo = srcPriv->secinfo;
|
|
|
404507 |
+ encinfo = srcPriv->encinfo;
|
|
|
404507 |
+ }
|
|
|
404507 |
+
|
|
|
404507 |
if (secinfo && secinfo->type == VIR_DOMAIN_SECRET_INFO_TYPE_AES) {
|
|
|
404507 |
if (qemuBuildSecretInfoProps(secinfo, &secobjProps) < 0)
|
|
|
404507 |
goto error;
|
|
|
404507 |
}
|
|
|
404507 |
|
|
|
404507 |
- encinfo = srcPriv->encinfo;
|
|
|
404507 |
if (encinfo && qemuBuildSecretInfoProps(encinfo, &encobjProps) < 0)
|
|
|
404507 |
goto error;
|
|
|
404507 |
|
|
|
404507 |
--
|
|
|
404507 |
2.15.0
|
|
|
404507 |
|