提交 ab0e32fb 编写于 作者: J John Ferlan 提交者: Peter Krempa

qemu: Relocate qemuDomainSecretInfoPtr to qemuDomainStorageSourcePrivate

Since the secret information is really virStorageSource specific
piece of data, let's manage the privateData from there instead of
at the Disk level.
Signed-off-by: NJohn Ferlan <jferlan@redhat.com>
Signed-off-by: NPeter Krempa <pkrempa@redhat.com>
上级 3ff3eb70
...@@ -1362,7 +1362,8 @@ qemuBuildDriveSourceStr(virDomainDiskDefPtr disk, ...@@ -1362,7 +1362,8 @@ qemuBuildDriveSourceStr(virDomainDiskDefPtr disk,
{ {
int actualType = virStorageSourceGetActualType(disk->src); int actualType = virStorageSourceGetActualType(disk->src);
qemuDomainDiskPrivatePtr diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk); qemuDomainDiskPrivatePtr diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
qemuDomainSecretInfoPtr secinfo = diskPriv->secinfo; qemuDomainStorageSourcePrivatePtr srcpriv = QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(disk->src);
qemuDomainSecretInfoPtr secinfo = srcpriv->secinfo;
qemuDomainSecretInfoPtr encinfo = diskPriv->encinfo; qemuDomainSecretInfoPtr encinfo = diskPriv->encinfo;
virJSONValuePtr srcprops = NULL; virJSONValuePtr srcprops = NULL;
char *source = NULL; char *source = NULL;
...@@ -2239,7 +2240,8 @@ qemuBuildDiskDriveCommandLine(virCommandPtr cmd, ...@@ -2239,7 +2240,8 @@ qemuBuildDiskDriveCommandLine(virCommandPtr cmd,
bool driveBoot = false; bool driveBoot = false;
virDomainDiskDefPtr disk = def->disks[i]; virDomainDiskDefPtr disk = def->disks[i];
qemuDomainDiskPrivatePtr diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk); qemuDomainDiskPrivatePtr diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
qemuDomainSecretInfoPtr secinfo = diskPriv->secinfo; qemuDomainStorageSourcePrivatePtr srcPriv = QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(disk->src);
qemuDomainSecretInfoPtr secinfo = srcPriv->secinfo;
qemuDomainSecretInfoPtr encinfo = diskPriv->encinfo; qemuDomainSecretInfoPtr encinfo = diskPriv->encinfo;
if (disk->info.bootIndex) { if (disk->info.bootIndex) {
......
...@@ -927,7 +927,6 @@ qemuDomainDiskPrivateDispose(void *obj) ...@@ -927,7 +927,6 @@ qemuDomainDiskPrivateDispose(void *obj)
{ {
qemuDomainDiskPrivatePtr priv = obj; qemuDomainDiskPrivatePtr priv = obj;
qemuDomainSecretInfoFree(&priv->secinfo);
qemuDomainSecretInfoFree(&priv->encinfo); qemuDomainSecretInfoFree(&priv->encinfo);
} }
...@@ -1344,9 +1343,10 @@ void ...@@ -1344,9 +1343,10 @@ void
qemuDomainSecretDiskDestroy(virDomainDiskDefPtr disk) qemuDomainSecretDiskDestroy(virDomainDiskDefPtr disk)
{ {
qemuDomainDiskPrivatePtr diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk); qemuDomainDiskPrivatePtr diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
qemuDomainStorageSourcePrivatePtr srcPriv = QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(disk->src);
if (diskPriv && diskPriv->secinfo) if (srcPriv && srcPriv->secinfo)
qemuDomainSecretInfoFree(&diskPriv->secinfo); qemuDomainSecretInfoFree(&srcPriv->secinfo);
if (diskPriv && diskPriv->encinfo) if (diskPriv && diskPriv->encinfo)
qemuDomainSecretInfoFree(&diskPriv->encinfo); qemuDomainSecretInfoFree(&diskPriv->encinfo);
...@@ -1395,6 +1395,12 @@ qemuDomainSecretDiskPrepare(virConnectPtr conn, ...@@ -1395,6 +1395,12 @@ qemuDomainSecretDiskPrepare(virConnectPtr conn,
{ {
virStorageSourcePtr src = disk->src; virStorageSourcePtr src = disk->src;
qemuDomainDiskPrivatePtr diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk); qemuDomainDiskPrivatePtr diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
qemuDomainStorageSourcePrivatePtr srcPriv;
if (!(disk->src->privateData = qemuDomainStorageSourcePrivateNew()))
return -1;
srcPriv = QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(disk->src);
if (qemuDomainSecretDiskCapable(src)) { if (qemuDomainSecretDiskCapable(src)) {
virSecretUsageType usageType = VIR_SECRET_USAGE_TYPE_ISCSI; virSecretUsageType usageType = VIR_SECRET_USAGE_TYPE_ISCSI;
...@@ -1402,7 +1408,7 @@ qemuDomainSecretDiskPrepare(virConnectPtr conn, ...@@ -1402,7 +1408,7 @@ qemuDomainSecretDiskPrepare(virConnectPtr conn,
if (src->protocol == VIR_STORAGE_NET_PROTOCOL_RBD) if (src->protocol == VIR_STORAGE_NET_PROTOCOL_RBD)
usageType = VIR_SECRET_USAGE_TYPE_CEPH; usageType = VIR_SECRET_USAGE_TYPE_CEPH;
if (!(diskPriv->secinfo = if (!(srcPriv->secinfo =
qemuDomainSecretInfoNew(conn, priv, disk->info.alias, qemuDomainSecretInfoNew(conn, priv, disk->info.alias,
usageType, src->auth->username, usageType, src->auth->username,
&src->auth->seclookupdef, false))) &src->auth->seclookupdef, false)))
......
...@@ -349,10 +349,6 @@ struct _qemuDomainDiskPrivate { ...@@ -349,10 +349,6 @@ struct _qemuDomainDiskPrivate {
bool migrating; /* the disk is being migrated */ bool migrating; /* the disk is being migrated */
/* for storage devices using auth/secret
* NB: *not* to be written to qemu domain object XML */
qemuDomainSecretInfoPtr secinfo;
/* for storage devices using encryption/secret /* for storage devices using encryption/secret
* Can have both <auth> and <encryption> for some disks * Can have both <auth> and <encryption> for some disks
* NB:*not* to be written to qemu domain object XML */ * NB:*not* to be written to qemu domain object XML */
......
...@@ -258,6 +258,7 @@ qemuDomainChangeEjectableMedia(virQEMUDriverPtr driver, ...@@ -258,6 +258,7 @@ qemuDomainChangeEjectableMedia(virQEMUDriverPtr driver,
char *driveAlias = NULL; char *driveAlias = NULL;
qemuDomainObjPrivatePtr priv = vm->privateData; qemuDomainObjPrivatePtr priv = vm->privateData;
qemuDomainDiskPrivatePtr diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk); qemuDomainDiskPrivatePtr diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
qemuDomainStorageSourcePrivatePtr srcPriv = QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(disk->src);
const char *format = NULL; const char *format = NULL;
char *sourcestr = NULL; char *sourcestr = NULL;
...@@ -299,7 +300,7 @@ qemuDomainChangeEjectableMedia(virQEMUDriverPtr driver, ...@@ -299,7 +300,7 @@ qemuDomainChangeEjectableMedia(virQEMUDriverPtr driver,
} }
if (!virStorageSourceIsEmpty(newsrc)) { if (!virStorageSourceIsEmpty(newsrc)) {
if (qemuGetDriveSourceString(newsrc, diskPriv->secinfo, &sourcestr) < 0) if (qemuGetDriveSourceString(newsrc, srcPriv->secinfo, &sourcestr) < 0)
goto error; goto error;
if (virStorageSourceGetActualType(newsrc) != VIR_STORAGE_TYPE_DIR) { if (virStorageSourceGetActualType(newsrc) != VIR_STORAGE_TYPE_DIR) {
...@@ -370,6 +371,7 @@ qemuDomainAttachDiskGeneric(virConnectPtr conn, ...@@ -370,6 +371,7 @@ qemuDomainAttachDiskGeneric(virConnectPtr conn,
virJSONValuePtr secobjProps = NULL; virJSONValuePtr secobjProps = NULL;
virJSONValuePtr encobjProps = NULL; virJSONValuePtr encobjProps = NULL;
qemuDomainDiskPrivatePtr diskPriv; qemuDomainDiskPrivatePtr diskPriv;
qemuDomainStorageSourcePrivatePtr srcPriv;
qemuDomainSecretInfoPtr secinfo; qemuDomainSecretInfoPtr secinfo;
qemuDomainSecretInfoPtr encinfo; qemuDomainSecretInfoPtr encinfo;
...@@ -383,7 +385,8 @@ qemuDomainAttachDiskGeneric(virConnectPtr conn, ...@@ -383,7 +385,8 @@ qemuDomainAttachDiskGeneric(virConnectPtr conn,
goto error; goto error;
diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk); diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
secinfo = diskPriv->secinfo; srcPriv = QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(disk->src);
secinfo = srcPriv->secinfo;
if (secinfo && secinfo->type == VIR_DOMAIN_SECRET_INFO_TYPE_AES) { if (secinfo && secinfo->type == VIR_DOMAIN_SECRET_INFO_TYPE_AES) {
if (qemuBuildSecretInfoProps(secinfo, &secobjProps) < 0) if (qemuBuildSecretInfoProps(secinfo, &secobjProps) < 0)
goto error; goto error;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册