提交 40d8e2ba 编写于 作者: J John Ferlan

qemu: Introduce qemuDomainSecretPrepare and Destroy

Rather than needing to pass the conn parameter to various command
line building API's, add qemuDomainSecretPrepare just prior to the
qemuProcessLaunch which calls qemuBuilCommandLine. The function
must be called after qemuProcessPrepareHost since it's expected
to eventually need the domain masterKey generated during the prepare
host call. Additionally, future patches may require device aliases
(assigned during the prepare domain call) in order to associate
the secret objects.

The qemuDomainSecretDestroy is called after the qemuProcessLaunch
finishes in order to clear and free memory used by the secrets
that were recently prepared, so they are not kept around in memory
too long.

Placing the setup here is beneficial for future patches which will
need the domain masterKey in order to generate an encrypted secret
along with an initialization vector to be saved and passed (since
the masterKey shouldn't be passed around).

Finally, since the secret is not added during command line build,
the hotplug code will need to get the secret into the private disk data.
Signed-off-by: NJohn Ferlan <jferlan@redhat.com>
上级 48f56a9c
...@@ -832,7 +832,7 @@ qemuBuildNetworkDriveURI(virStorageSourcePtr src, ...@@ -832,7 +832,7 @@ qemuBuildNetworkDriveURI(virStorageSourcePtr src,
int int
qemuGetDriveSourceString(virStorageSourcePtr src, qemuGetDriveSourceString(virStorageSourcePtr src,
virConnectPtr conn, qemuDomainSecretInfoPtr secinfo,
char **source) char **source)
{ {
int actualType = virStorageSourceGetActualType(src); int actualType = virStorageSourceGetActualType(src);
...@@ -846,31 +846,6 @@ qemuGetDriveSourceString(virStorageSourcePtr src, ...@@ -846,31 +846,6 @@ qemuGetDriveSourceString(virStorageSourcePtr src,
if (virStorageSourceIsEmpty(src)) if (virStorageSourceIsEmpty(src))
return 1; return 1;
if (conn) {
if (actualType == VIR_STORAGE_TYPE_NETWORK &&
src->auth &&
(src->protocol == VIR_STORAGE_NET_PROTOCOL_ISCSI ||
src->protocol == VIR_STORAGE_NET_PROTOCOL_RBD)) {
bool encode = false;
int secretType = VIR_SECRET_USAGE_TYPE_ISCSI;
const char *protocol = virStorageNetProtocolTypeToString(src->protocol);
username = src->auth->username;
if (src->protocol == VIR_STORAGE_NET_PROTOCOL_RBD) {
/* qemu requires the secret to be encoded for RBD */
encode = true;
secretType = VIR_SECRET_USAGE_TYPE_CEPH;
}
if (!(secret = virSecretGetSecretString(conn,
protocol,
encode,
src->auth,
secretType)))
goto cleanup;
}
}
switch ((virStorageType) actualType) { switch ((virStorageType) actualType) {
case VIR_STORAGE_TYPE_BLOCK: case VIR_STORAGE_TYPE_BLOCK:
case VIR_STORAGE_TYPE_FILE: case VIR_STORAGE_TYPE_FILE:
...@@ -881,6 +856,11 @@ qemuGetDriveSourceString(virStorageSourcePtr src, ...@@ -881,6 +856,11 @@ qemuGetDriveSourceString(virStorageSourcePtr src,
break; break;
case VIR_STORAGE_TYPE_NETWORK: case VIR_STORAGE_TYPE_NETWORK:
if (secinfo) {
username = secinfo->s.plain.username;
secret = secinfo->s.plain.secret;
}
if (!(*source = qemuBuildNetworkDriveURI(src, username, secret))) if (!(*source = qemuBuildNetworkDriveURI(src, username, secret)))
goto cleanup; goto cleanup;
break; break;
...@@ -894,7 +874,6 @@ qemuGetDriveSourceString(virStorageSourcePtr src, ...@@ -894,7 +874,6 @@ qemuGetDriveSourceString(virStorageSourcePtr src,
ret = 0; ret = 0;
cleanup: cleanup:
VIR_FREE(secret);
return ret; return ret;
} }
...@@ -1033,8 +1012,7 @@ qemuCheckFips(void) ...@@ -1033,8 +1012,7 @@ qemuCheckFips(void)
char * char *
qemuBuildDriveStr(virConnectPtr conn, qemuBuildDriveStr(virDomainDiskDefPtr disk,
virDomainDiskDefPtr disk,
bool bootable, bool bootable,
virQEMUCapsPtr qemuCaps) virQEMUCapsPtr qemuCaps)
{ {
...@@ -1046,6 +1024,7 @@ qemuBuildDriveStr(virConnectPtr conn, ...@@ -1046,6 +1024,7 @@ qemuBuildDriveStr(virConnectPtr conn,
int busid = -1, unitid = -1; int busid = -1, unitid = -1;
char *source = NULL; char *source = NULL;
int actualType = virStorageSourceGetActualType(disk->src); int actualType = virStorageSourceGetActualType(disk->src);
qemuDomainDiskPrivatePtr diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
if (idx < 0) { if (idx < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
...@@ -1127,7 +1106,7 @@ qemuBuildDriveStr(virConnectPtr conn, ...@@ -1127,7 +1106,7 @@ qemuBuildDriveStr(virConnectPtr conn,
break; break;
} }
if (qemuGetDriveSourceString(disk->src, conn, &source) < 0) if (qemuGetDriveSourceString(disk->src, diskPriv->secinfo, &source) < 0)
goto error; goto error;
if (source && if (source &&
...@@ -1816,7 +1795,6 @@ qemuBuildDriveDevStr(const virDomainDef *def, ...@@ -1816,7 +1795,6 @@ qemuBuildDriveDevStr(const virDomainDef *def,
static int static int
qemuBuildDiskDriveCommandLine(virCommandPtr cmd, qemuBuildDiskDriveCommandLine(virCommandPtr cmd,
virConnectPtr conn,
const virDomainDef *def, const virDomainDef *def,
virQEMUCapsPtr qemuCaps, virQEMUCapsPtr qemuCaps,
bool emitBootindex) bool emitBootindex)
...@@ -1910,7 +1888,7 @@ qemuBuildDiskDriveCommandLine(virCommandPtr cmd, ...@@ -1910,7 +1888,7 @@ qemuBuildDiskDriveCommandLine(virCommandPtr cmd,
deviceFlagMasked = true; deviceFlagMasked = true;
} }
} }
optstr = qemuBuildDriveStr(conn, disk, optstr = qemuBuildDriveStr(disk,
emitBootindex ? false : !!bootindex, emitBootindex ? false : !!bootindex,
qemuCaps); qemuCaps);
if (deviceFlagMasked) if (deviceFlagMasked)
...@@ -9367,8 +9345,7 @@ qemuBuildCommandLine(virConnectPtr conn, ...@@ -9367,8 +9345,7 @@ qemuBuildCommandLine(virConnectPtr conn,
if (qemuBuildHubCommandLine(cmd, def, qemuCaps) < 0) if (qemuBuildHubCommandLine(cmd, def, qemuCaps) < 0)
goto error; goto error;
if (qemuBuildDiskDriveCommandLine(cmd, conn, def, qemuCaps, if (qemuBuildDiskDriveCommandLine(cmd, def, qemuCaps, emitBootindex) < 0)
emitBootindex) < 0)
goto error; goto error;
if (qemuBuildFSDevCommandLine(cmd, def, qemuCaps) < 0) if (qemuBuildFSDevCommandLine(cmd, def, qemuCaps) < 0)
......
...@@ -101,8 +101,7 @@ char *qemuDeviceDriveHostAlias(virDomainDiskDefPtr disk, ...@@ -101,8 +101,7 @@ char *qemuDeviceDriveHostAlias(virDomainDiskDefPtr disk,
virQEMUCapsPtr qemuCaps); virQEMUCapsPtr qemuCaps);
/* Both legacy & current support */ /* Both legacy & current support */
char *qemuBuildDriveStr(virConnectPtr conn, char *qemuBuildDriveStr(virDomainDiskDefPtr disk,
virDomainDiskDefPtr disk,
bool bootable, bool bootable,
virQEMUCapsPtr qemuCaps); virQEMUCapsPtr qemuCaps);
...@@ -179,7 +178,7 @@ char *qemuBuildRedirdevDevStr(const virDomainDef *def, ...@@ -179,7 +178,7 @@ char *qemuBuildRedirdevDevStr(const virDomainDef *def,
int qemuNetworkPrepareDevices(virDomainDefPtr def); int qemuNetworkPrepareDevices(virDomainDefPtr def);
int qemuGetDriveSourceString(virStorageSourcePtr src, int qemuGetDriveSourceString(virStorageSourcePtr src,
virConnectPtr conn, qemuDomainSecretInfoPtr secinfo,
char **source); char **source);
int qemuCheckDiskConfig(virDomainDiskDefPtr disk); int qemuCheckDiskConfig(virDomainDiskDefPtr disk);
......
...@@ -46,6 +46,7 @@ ...@@ -46,6 +46,7 @@
#include "viratomic.h" #include "viratomic.h"
#include "virprocess.h" #include "virprocess.h"
#include "virrandom.h" #include "virrandom.h"
#include "secret_util.h"
#include "base64.h" #include "base64.h"
#ifdef WITH_GNUTLS #ifdef WITH_GNUTLS
# include <gnutls/gnutls.h> # include <gnutls/gnutls.h>
...@@ -791,6 +792,146 @@ qemuDomainDiskPrivateDispose(void *obj) ...@@ -791,6 +792,146 @@ qemuDomainDiskPrivateDispose(void *obj)
} }
/* qemuDomainSecretPlainSetup:
* @conn: Pointer to connection
* @secinfo: Pointer to secret info
* @protocol: Protocol for secret
* @authdef: Pointer to auth data
*
* Taking a secinfo, fill in the plaintext information
*
* Returns 0 on success, -1 on failure with error message
*/
static int
qemuDomainSecretPlainSetup(virConnectPtr conn,
qemuDomainSecretInfoPtr secinfo,
virStorageNetProtocol protocol,
virStorageAuthDefPtr authdef)
{
bool encode = false;
int secretType = VIR_SECRET_USAGE_TYPE_ISCSI;
const char *protocolstr = virStorageNetProtocolTypeToString(protocol);
secinfo->type = VIR_DOMAIN_SECRET_INFO_PLAIN;
if (VIR_STRDUP(secinfo->s.plain.username, authdef->username) < 0)
return -1;
if (protocol == VIR_STORAGE_NET_PROTOCOL_RBD) {
/* qemu requires the secret to be encoded for RBD */
encode = true;
secretType = VIR_SECRET_USAGE_TYPE_CEPH;
}
if (!(secinfo->s.plain.secret =
virSecretGetSecretString(conn, protocolstr, encode,
authdef, secretType)))
return -1;
return 0;
}
/* qemuDomainSecretDiskDestroy:
* @disk: Pointer to a disk definition
*
* Clear and destroy memory associated with the secret
*/
void
qemuDomainSecretDiskDestroy(virDomainDiskDefPtr disk)
{
qemuDomainDiskPrivatePtr diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
if (!diskPriv->secinfo)
return;
qemuDomainSecretInfoFree(&diskPriv->secinfo);
}
/* qemuDomainSecretDiskPrepare:
* @conn: Pointer to connection
* @disk: Pointer to a disk definition
*
* For the right disk, generate the qemuDomainSecretInfo structure.
*
* Returns 0 on success, -1 on failure
*/
int
qemuDomainSecretDiskPrepare(virConnectPtr conn,
virDomainDiskDefPtr disk)
{
virStorageSourcePtr src = disk->src;
qemuDomainSecretInfoPtr secinfo = NULL;
if (conn && !virStorageSourceIsEmpty(src) &&
virStorageSourceGetActualType(src) == VIR_STORAGE_TYPE_NETWORK &&
src->auth &&
(src->protocol == VIR_STORAGE_NET_PROTOCOL_ISCSI ||
src->protocol == VIR_STORAGE_NET_PROTOCOL_RBD)) {
qemuDomainDiskPrivatePtr diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
if (VIR_ALLOC(secinfo) < 0)
return -1;
if (qemuDomainSecretPlainSetup(conn, secinfo, src->protocol,
src->auth) < 0)
goto error;
diskPriv->secinfo = secinfo;
}
return 0;
error:
qemuDomainSecretInfoFree(&secinfo);
return -1;
}
/* qemuDomainSecretDestroy:
* @vm: Domain object
*
* Once completed with the generation of the command line it is
* expect to remove the secrets
*/
void
qemuDomainSecretDestroy(virDomainObjPtr vm)
{
size_t i;
for (i = 0; i < vm->def->ndisks; i++)
qemuDomainSecretDiskDestroy(vm->def->disks[i]);
}
/* qemuDomainSecretPrepare:
* @conn: Pointer to connection
* @vm: Domain object
*
* For any objects that may require an auth/secret setup, create a
* qemuDomainSecretInfo and save it in the approriate place within
* the private structures. This will be used by command line build
* code in order to pass the secret along to qemu in order to provide
* the necessary authentication data.
*
* Returns 0 on success, -1 on failure with error message set
*/
int
qemuDomainSecretPrepare(virConnectPtr conn,
virDomainObjPtr vm)
{
size_t i;
for (i = 0; i < vm->def->ndisks; i++) {
if (qemuDomainSecretDiskPrepare(conn, vm->def->disks[i]) < 0)
return -1;
}
return 0;
}
/* This is the old way of setting up per-domain directories */ /* This is the old way of setting up per-domain directories */
static int static int
qemuDomainSetPrivatePathsOld(virQEMUDriverPtr driver, qemuDomainSetPrivatePathsOld(virQEMUDriverPtr driver,
...@@ -3799,8 +3940,7 @@ qemuDomainDiskChainElementPrepare(virQEMUDriverPtr driver, ...@@ -3799,8 +3940,7 @@ qemuDomainDiskChainElementPrepare(virQEMUDriverPtr driver,
bool bool
qemuDomainDiskSourceDiffers(virConnectPtr conn, qemuDomainDiskSourceDiffers(virDomainDiskDefPtr disk,
virDomainDiskDefPtr disk,
virDomainDiskDefPtr origDisk) virDomainDiskDefPtr origDisk)
{ {
char *diskSrc = NULL, *origDiskSrc = NULL; char *diskSrc = NULL, *origDiskSrc = NULL;
...@@ -3816,8 +3956,10 @@ qemuDomainDiskSourceDiffers(virConnectPtr conn, ...@@ -3816,8 +3956,10 @@ qemuDomainDiskSourceDiffers(virConnectPtr conn,
if (diskEmpty ^ origDiskEmpty) if (diskEmpty ^ origDiskEmpty)
return true; return true;
if (qemuGetDriveSourceString(disk->src, conn, &diskSrc) < 0 || /* This won't be a network storage, so no need to get the diskPriv
qemuGetDriveSourceString(origDisk->src, conn, &origDiskSrc) < 0) * in order to fetch the secret, thus NULL for param2 */
if (qemuGetDriveSourceString(disk->src, NULL, &diskSrc) < 0 ||
qemuGetDriveSourceString(origDisk->src, NULL, &origDiskSrc) < 0)
goto cleanup; goto cleanup;
/* So far in qemu disk sources are considered different /* So far in qemu disk sources are considered different
......
...@@ -497,8 +497,7 @@ int qemuDomainDetermineDiskChain(virQEMUDriverPtr driver, ...@@ -497,8 +497,7 @@ int qemuDomainDetermineDiskChain(virQEMUDriverPtr driver,
bool force_probe, bool force_probe,
bool report_broken); bool report_broken);
bool qemuDomainDiskSourceDiffers(virConnectPtr conn, bool qemuDomainDiskSourceDiffers(virDomainDiskDefPtr disk,
virDomainDiskDefPtr disk,
virDomainDiskDefPtr origDisk); virDomainDiskDefPtr origDisk);
bool qemuDomainDiskChangeSupported(virDomainDiskDefPtr disk, bool qemuDomainDiskChangeSupported(virDomainDiskDefPtr disk,
...@@ -616,4 +615,16 @@ int qemuDomainMasterKeyCreate(virQEMUDriverPtr driver, ...@@ -616,4 +615,16 @@ int qemuDomainMasterKeyCreate(virQEMUDriverPtr driver,
void qemuDomainMasterKeyRemove(qemuDomainObjPrivatePtr priv); void qemuDomainMasterKeyRemove(qemuDomainObjPrivatePtr priv);
void qemuDomainSecretDiskDestroy(virDomainDiskDefPtr disk)
ATTRIBUTE_NONNULL(1);
int qemuDomainSecretDiskPrepare(virConnectPtr conn, virDomainDiskDefPtr disk)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
void qemuDomainSecretDestroy(virDomainObjPtr vm)
ATTRIBUTE_NONNULL(1);
int qemuDomainSecretPrepare(virConnectPtr conn, virDomainObjPtr vm)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
#endif /* __QEMU_DOMAIN_H__ */ #endif /* __QEMU_DOMAIN_H__ */
...@@ -7712,14 +7712,16 @@ qemuDomainChangeDiskLive(virConnectPtr conn, ...@@ -7712,14 +7712,16 @@ qemuDomainChangeDiskLive(virConnectPtr conn,
orig_disk->startupPolicy = dev->data.disk->startupPolicy; orig_disk->startupPolicy = dev->data.disk->startupPolicy;
orig_disk->snapshot = dev->data.disk->snapshot; orig_disk->snapshot = dev->data.disk->snapshot;
if (qemuDomainDiskSourceDiffers(conn, disk, orig_disk)) { if (qemuDomainDiskSourceDiffers(disk, orig_disk)) {
/* Add the new disk src into shared disk hash table */ /* Add the new disk src into shared disk hash table */
if (qemuAddSharedDevice(driver, dev, vm->def->name) < 0) if (qemuAddSharedDevice(driver, dev, vm->def->name) < 0)
goto cleanup; goto cleanup;
if (qemuDomainChangeEjectableMedia(driver, conn, vm, if (qemuDomainChangeEjectableMedia(driver, vm, orig_disk,
orig_disk, dev->data.disk->src, force) < 0) { dev->data.disk->src,
ignore_value(qemuRemoveSharedDisk(driver, dev->data.disk, vm->def->name)); force) < 0) {
ignore_value(qemuRemoveSharedDisk(driver, dev->data.disk,
vm->def->name));
goto rollback; goto rollback;
} }
......
...@@ -148,7 +148,6 @@ qemuDomainPrepareDisk(virQEMUDriverPtr driver, ...@@ -148,7 +148,6 @@ qemuDomainPrepareDisk(virQEMUDriverPtr driver,
/** /**
* qemuDomainChangeEjectableMedia: * qemuDomainChangeEjectableMedia:
* @driver: qemu driver structure * @driver: qemu driver structure
* @conn: connection structure
* @vm: domain definition * @vm: domain definition
* @disk: disk definition to change the source of * @disk: disk definition to change the source of
* @newsrc: new disk source to change to * @newsrc: new disk source to change to
...@@ -163,7 +162,6 @@ qemuDomainPrepareDisk(virQEMUDriverPtr driver, ...@@ -163,7 +162,6 @@ qemuDomainPrepareDisk(virQEMUDriverPtr driver,
*/ */
int int
qemuDomainChangeEjectableMedia(virQEMUDriverPtr driver, qemuDomainChangeEjectableMedia(virQEMUDriverPtr driver,
virConnectPtr conn,
virDomainObjPtr vm, virDomainObjPtr vm,
virDomainDiskDefPtr disk, virDomainDiskDefPtr disk,
virStorageSourcePtr newsrc, virStorageSourcePtr newsrc,
...@@ -232,7 +230,9 @@ qemuDomainChangeEjectableMedia(virQEMUDriverPtr driver, ...@@ -232,7 +230,9 @@ qemuDomainChangeEjectableMedia(virQEMUDriverPtr driver,
} while (rc < 0); } while (rc < 0);
if (!virStorageSourceIsEmpty(newsrc)) { if (!virStorageSourceIsEmpty(newsrc)) {
if (qemuGetDriveSourceString(newsrc, conn, &sourcestr) < 0) qemuDomainDiskPrivatePtr diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
if (qemuGetDriveSourceString(newsrc, diskPriv->secinfo, &sourcestr) < 0)
goto error; goto error;
if (virStorageSourceGetActualType(newsrc) != VIR_STORAGE_TYPE_DIR) { if (virStorageSourceGetActualType(newsrc) != VIR_STORAGE_TYPE_DIR) {
...@@ -369,7 +369,10 @@ qemuDomainAttachVirtioDiskDevice(virConnectPtr conn, ...@@ -369,7 +369,10 @@ qemuDomainAttachVirtioDiskDevice(virConnectPtr conn,
if (qemuAssignDeviceDiskAlias(vm->def, disk, priv->qemuCaps) < 0) if (qemuAssignDeviceDiskAlias(vm->def, disk, priv->qemuCaps) < 0)
goto error; goto error;
if (!(drivestr = qemuBuildDriveStr(conn, disk, false, priv->qemuCaps))) if (qemuDomainSecretDiskPrepare(conn, disk) < 0)
goto error;
if (!(drivestr = qemuBuildDriveStr(disk, false, priv->qemuCaps)))
goto error; goto error;
if (!(drivealias = qemuDeviceDriveHostAlias(disk, priv->qemuCaps))) if (!(drivealias = qemuDeviceDriveHostAlias(disk, priv->qemuCaps)))
...@@ -411,6 +414,7 @@ qemuDomainAttachVirtioDiskDevice(virConnectPtr conn, ...@@ -411,6 +414,7 @@ qemuDomainAttachVirtioDiskDevice(virConnectPtr conn,
virDomainDiskInsertPreAlloced(vm->def, disk); virDomainDiskInsertPreAlloced(vm->def, disk);
cleanup: cleanup:
qemuDomainSecretDiskDestroy(disk);
VIR_FREE(devstr); VIR_FREE(devstr);
VIR_FREE(drivestr); VIR_FREE(drivestr);
VIR_FREE(drivealias); VIR_FREE(drivealias);
...@@ -574,10 +578,13 @@ qemuDomainAttachSCSIDisk(virConnectPtr conn, ...@@ -574,10 +578,13 @@ qemuDomainAttachSCSIDisk(virConnectPtr conn,
if (qemuAssignDeviceDiskAlias(vm->def, disk, priv->qemuCaps) < 0) if (qemuAssignDeviceDiskAlias(vm->def, disk, priv->qemuCaps) < 0)
goto error; goto error;
if (qemuDomainSecretDiskPrepare(conn, disk) < 0)
goto error;
if (!(devstr = qemuBuildDriveDevStr(vm->def, disk, 0, priv->qemuCaps))) if (!(devstr = qemuBuildDriveDevStr(vm->def, disk, 0, priv->qemuCaps)))
goto error; goto error;
if (!(drivestr = qemuBuildDriveStr(conn, disk, false, priv->qemuCaps))) if (!(drivestr = qemuBuildDriveStr(disk, false, priv->qemuCaps)))
goto error; goto error;
if (VIR_REALLOC_N(vm->def->disks, vm->def->ndisks+1) < 0) if (VIR_REALLOC_N(vm->def->disks, vm->def->ndisks+1) < 0)
...@@ -608,6 +615,7 @@ qemuDomainAttachSCSIDisk(virConnectPtr conn, ...@@ -608,6 +615,7 @@ qemuDomainAttachSCSIDisk(virConnectPtr conn,
virDomainDiskInsertPreAlloced(vm->def, disk); virDomainDiskInsertPreAlloced(vm->def, disk);
cleanup: cleanup:
qemuDomainSecretDiskDestroy(disk);
VIR_FREE(devstr); VIR_FREE(devstr);
VIR_FREE(drivestr); VIR_FREE(drivestr);
virObjectUnref(cfg); virObjectUnref(cfg);
...@@ -620,8 +628,7 @@ qemuDomainAttachSCSIDisk(virConnectPtr conn, ...@@ -620,8 +628,7 @@ qemuDomainAttachSCSIDisk(virConnectPtr conn,
static int static int
qemuDomainAttachUSBMassStorageDevice(virConnectPtr conn, qemuDomainAttachUSBMassStorageDevice(virQEMUDriverPtr driver,
virQEMUDriverPtr driver,
virDomainObjPtr vm, virDomainObjPtr vm,
virDomainDiskDefPtr disk) virDomainDiskDefPtr disk)
{ {
...@@ -644,7 +651,7 @@ qemuDomainAttachUSBMassStorageDevice(virConnectPtr conn, ...@@ -644,7 +651,7 @@ qemuDomainAttachUSBMassStorageDevice(virConnectPtr conn,
if (qemuAssignDeviceDiskAlias(vm->def, disk, priv->qemuCaps) < 0) if (qemuAssignDeviceDiskAlias(vm->def, disk, priv->qemuCaps) < 0)
goto error; goto error;
if (!(drivestr = qemuBuildDriveStr(conn, disk, false, priv->qemuCaps))) if (!(drivestr = qemuBuildDriveStr(disk, false, priv->qemuCaps)))
goto error; goto error;
if (!(devstr = qemuBuildDriveDevStr(vm->def, disk, 0, priv->qemuCaps))) if (!(devstr = qemuBuildDriveDevStr(vm->def, disk, 0, priv->qemuCaps)))
goto error; goto error;
...@@ -732,7 +739,7 @@ qemuDomainAttachDeviceDiskLive(virConnectPtr conn, ...@@ -732,7 +739,7 @@ qemuDomainAttachDeviceDiskLive(virConnectPtr conn,
goto cleanup; goto cleanup;
} }
if (qemuDomainChangeEjectableMedia(driver, conn, vm, orig_disk, if (qemuDomainChangeEjectableMedia(driver, vm, orig_disk,
disk->src, false) < 0) disk->src, false) < 0)
goto cleanup; goto cleanup;
...@@ -754,7 +761,7 @@ qemuDomainAttachDeviceDiskLive(virConnectPtr conn, ...@@ -754,7 +761,7 @@ qemuDomainAttachDeviceDiskLive(virConnectPtr conn,
_("disk device='lun' is not supported for usb bus")); _("disk device='lun' is not supported for usb bus"));
break; break;
} }
ret = qemuDomainAttachUSBMassStorageDevice(conn, driver, vm, disk); ret = qemuDomainAttachUSBMassStorageDevice(driver, vm, disk);
break; break;
case VIR_DOMAIN_DISK_BUS_VIRTIO: case VIR_DOMAIN_DISK_BUS_VIRTIO:
......
...@@ -29,7 +29,6 @@ ...@@ -29,7 +29,6 @@
# include "domain_conf.h" # include "domain_conf.h"
int qemuDomainChangeEjectableMedia(virQEMUDriverPtr driver, int qemuDomainChangeEjectableMedia(virQEMUDriverPtr driver,
virConnectPtr conn,
virDomainObjPtr vm, virDomainObjPtr vm,
virDomainDiskDefPtr disk, virDomainDiskDefPtr disk,
virStorageSourcePtr newsrc, virStorageSourcePtr newsrc,
......
...@@ -5665,6 +5665,9 @@ qemuProcessStart(virConnectPtr conn, ...@@ -5665,6 +5665,9 @@ qemuProcessStart(virConnectPtr conn,
if (qemuProcessPrepareHost(driver, vm, !!incoming) < 0) if (qemuProcessPrepareHost(driver, vm, !!incoming) < 0)
goto stop; goto stop;
if (qemuDomainSecretPrepare(conn, vm) < 0)
goto cleanup;
if ((rv = qemuProcessLaunch(conn, driver, vm, asyncJob, incoming, if ((rv = qemuProcessLaunch(conn, driver, vm, asyncJob, incoming,
snapshot, vmop, flags)) < 0) { snapshot, vmop, flags)) < 0) {
if (rv == -2) if (rv == -2)
...@@ -5673,6 +5676,8 @@ qemuProcessStart(virConnectPtr conn, ...@@ -5673,6 +5676,8 @@ qemuProcessStart(virConnectPtr conn,
} }
relabel = true; relabel = true;
qemuDomainSecretDestroy(vm);
if (incoming && if (incoming &&
incoming->deferredURI && incoming->deferredURI &&
qemuMigrationRunIncoming(driver, vm, incoming->deferredURI, asyncJob) < 0) qemuMigrationRunIncoming(driver, vm, incoming->deferredURI, asyncJob) < 0)
...@@ -5734,6 +5739,9 @@ qemuProcessCreatePretendCmd(virConnectPtr conn, ...@@ -5734,6 +5739,9 @@ qemuProcessCreatePretendCmd(virConnectPtr conn,
if (qemuProcessPrepareDomain(conn, driver, vm, flags) < 0) if (qemuProcessPrepareDomain(conn, driver, vm, flags) < 0)
goto cleanup; goto cleanup;
if (qemuDomainSecretPrepare(conn, vm) < 0)
goto cleanup;
VIR_DEBUG("Building emulator command line"); VIR_DEBUG("Building emulator command line");
cmd = qemuBuildCommandLine(conn, cmd = qemuBuildCommandLine(conn,
driver, driver,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册