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