mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-22 04:25:18 +00:00
qemu: Remove code for setting up disk passphrases
Now that the old qcow2 encryption is removed we can safely delete all this code since it's not needed any more. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
c4eedd7930
commit
776d9bc3e8
@ -3118,19 +3118,6 @@ qemuMonitorAddDrive(qemuMonitorPtr mon,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
|
||||||
qemuMonitorSetDrivePassphrase(qemuMonitorPtr mon,
|
|
||||||
const char *alias,
|
|
||||||
const char *passphrase)
|
|
||||||
{
|
|
||||||
VIR_DEBUG("alias=%s passphrase=%p(value hidden)", alias, passphrase);
|
|
||||||
|
|
||||||
QEMU_CHECK_MONITOR(mon);
|
|
||||||
|
|
||||||
return qemuMonitorJSONSetDrivePassphrase(mon, alias, passphrase);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
qemuMonitorCreateSnapshot(qemuMonitorPtr mon, const char *name)
|
qemuMonitorCreateSnapshot(qemuMonitorPtr mon, const char *name)
|
||||||
{
|
{
|
||||||
|
@ -819,10 +819,6 @@ int qemuMonitorAddDrive(qemuMonitorPtr mon,
|
|||||||
int qemuMonitorDriveDel(qemuMonitorPtr mon,
|
int qemuMonitorDriveDel(qemuMonitorPtr mon,
|
||||||
const char *drivestr);
|
const char *drivestr);
|
||||||
|
|
||||||
int qemuMonitorSetDrivePassphrase(qemuMonitorPtr mon,
|
|
||||||
const char *alias,
|
|
||||||
const char *passphrase);
|
|
||||||
|
|
||||||
int qemuMonitorCreateSnapshot(qemuMonitorPtr mon, const char *name);
|
int qemuMonitorCreateSnapshot(qemuMonitorPtr mon, const char *name);
|
||||||
int qemuMonitorLoadSnapshot(qemuMonitorPtr mon, const char *name);
|
int qemuMonitorLoadSnapshot(qemuMonitorPtr mon, const char *name);
|
||||||
int qemuMonitorDeleteSnapshot(qemuMonitorPtr mon, const char *name);
|
int qemuMonitorDeleteSnapshot(qemuMonitorPtr mon, const char *name);
|
||||||
|
@ -4055,34 +4055,6 @@ int qemuMonitorJSONDelObject(qemuMonitorPtr mon,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int qemuMonitorJSONSetDrivePassphrase(qemuMonitorPtr mon,
|
|
||||||
const char *alias,
|
|
||||||
const char *passphrase)
|
|
||||||
{
|
|
||||||
int ret = -1;
|
|
||||||
virJSONValuePtr cmd;
|
|
||||||
virJSONValuePtr reply = NULL;
|
|
||||||
|
|
||||||
cmd = qemuMonitorJSONMakeCommand("block_passwd",
|
|
||||||
"s:device", alias,
|
|
||||||
"s:password", passphrase,
|
|
||||||
NULL);
|
|
||||||
if (!cmd)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
if (qemuMonitorJSONCheckError(cmd, reply) < 0)
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
ret = 0;
|
|
||||||
cleanup:
|
|
||||||
virJSONValueFree(cmd);
|
|
||||||
virJSONValueFree(reply);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
qemuMonitorJSONDiskSnapshot(qemuMonitorPtr mon, virJSONValuePtr actions,
|
qemuMonitorJSONDiskSnapshot(qemuMonitorPtr mon, virJSONValuePtr actions,
|
||||||
const char *device, const char *file,
|
const char *device, const char *file,
|
||||||
|
@ -235,10 +235,6 @@ int qemuMonitorJSONAddObject(qemuMonitorPtr mon,
|
|||||||
int qemuMonitorJSONDelObject(qemuMonitorPtr mon,
|
int qemuMonitorJSONDelObject(qemuMonitorPtr mon,
|
||||||
const char *objalias);
|
const char *objalias);
|
||||||
|
|
||||||
int qemuMonitorJSONSetDrivePassphrase(qemuMonitorPtr mon,
|
|
||||||
const char *alias,
|
|
||||||
const char *passphrase);
|
|
||||||
|
|
||||||
int qemuMonitorJSONDiskSnapshot(qemuMonitorPtr mon,
|
int qemuMonitorJSONDiskSnapshot(qemuMonitorPtr mon,
|
||||||
virJSONValuePtr actions,
|
virJSONValuePtr actions,
|
||||||
const char *device,
|
const char *device,
|
||||||
|
@ -371,74 +371,6 @@ qemuProcessFindDomainDiskByAlias(virDomainObjPtr vm,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
|
||||||
qemuProcessGetVolumeQcowPassphrase(virDomainDiskDefPtr disk,
|
|
||||||
char **secretRet,
|
|
||||||
size_t *secretLen)
|
|
||||||
{
|
|
||||||
virConnectPtr conn = NULL;
|
|
||||||
char *passphrase;
|
|
||||||
unsigned char *data;
|
|
||||||
size_t size;
|
|
||||||
int ret = -1;
|
|
||||||
virStorageEncryptionPtr enc;
|
|
||||||
|
|
||||||
if (!disk->src->encryption) {
|
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
||||||
_("disk %s does not have any encryption information"),
|
|
||||||
disk->src->path);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
enc = disk->src->encryption;
|
|
||||||
|
|
||||||
if (!(conn = virGetConnectSecret()))
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
if (enc->format != VIR_STORAGE_ENCRYPTION_FORMAT_QCOW ||
|
|
||||||
enc->nsecrets != 1 ||
|
|
||||||
enc->secrets[0]->type !=
|
|
||||||
VIR_STORAGE_ENCRYPTION_SECRET_TYPE_PASSPHRASE) {
|
|
||||||
virReportError(VIR_ERR_XML_ERROR,
|
|
||||||
_("invalid <encryption> for volume %s"),
|
|
||||||
virDomainDiskGetSource(disk));
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (virSecretGetSecretString(conn, &enc->secrets[0]->seclookupdef,
|
|
||||||
VIR_SECRET_USAGE_TYPE_VOLUME,
|
|
||||||
&data, &size) < 0)
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
if (memchr(data, '\0', size) != NULL) {
|
|
||||||
memset(data, 0, size);
|
|
||||||
VIR_FREE(data);
|
|
||||||
virReportError(VIR_ERR_XML_ERROR,
|
|
||||||
_("format='qcow' passphrase for %s must not contain a "
|
|
||||||
"'\\0'"), virDomainDiskGetSource(disk));
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (VIR_ALLOC_N(passphrase, size + 1) < 0) {
|
|
||||||
memset(data, 0, size);
|
|
||||||
VIR_FREE(data);
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
memcpy(passphrase, data, size);
|
|
||||||
passphrase[size] = '\0';
|
|
||||||
|
|
||||||
memset(data, 0, size);
|
|
||||||
VIR_FREE(data);
|
|
||||||
|
|
||||||
*secretRet = passphrase;
|
|
||||||
*secretLen = size;
|
|
||||||
|
|
||||||
ret = 0;
|
|
||||||
|
|
||||||
cleanup:
|
|
||||||
virObjectUnref(conn);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
qemuProcessHandleReset(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
|
qemuProcessHandleReset(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
|
||||||
virDomainObjPtr vm,
|
virDomainObjPtr vm,
|
||||||
@ -2729,11 +2661,8 @@ qemuProcessInitPasswords(virQEMUDriverPtr driver,
|
|||||||
int asyncJob)
|
int asyncJob)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
qemuDomainObjPrivatePtr priv = vm->privateData;
|
|
||||||
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
|
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
|
||||||
size_t i;
|
size_t i;
|
||||||
char *alias = NULL;
|
|
||||||
char *secret = NULL;
|
|
||||||
|
|
||||||
for (i = 0; i < vm->def->ngraphics; ++i) {
|
for (i = 0; i < vm->def->ngraphics; ++i) {
|
||||||
virDomainGraphicsDefPtr graphics = vm->def->graphics[i];
|
virDomainGraphicsDefPtr graphics = vm->def->graphics[i];
|
||||||
@ -2755,39 +2684,7 @@ qemuProcessInitPasswords(virQEMUDriverPtr driver,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < vm->def->ndisks; i++) {
|
|
||||||
size_t secretLen;
|
|
||||||
|
|
||||||
if (!vm->def->disks[i]->src->encryption ||
|
|
||||||
!virDomainDiskGetSource(vm->def->disks[i]))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (vm->def->disks[i]->src->encryption->format !=
|
|
||||||
VIR_STORAGE_ENCRYPTION_FORMAT_DEFAULT &&
|
|
||||||
vm->def->disks[i]->src->encryption->format !=
|
|
||||||
VIR_STORAGE_ENCRYPTION_FORMAT_QCOW)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
VIR_FREE(secret);
|
|
||||||
if (qemuProcessGetVolumeQcowPassphrase(vm->def->disks[i],
|
|
||||||
&secret, &secretLen) < 0)
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
VIR_FREE(alias);
|
|
||||||
if (!(alias = qemuAliasFromDisk(vm->def->disks[i])))
|
|
||||||
goto cleanup;
|
|
||||||
if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0)
|
|
||||||
goto cleanup;
|
|
||||||
ret = qemuMonitorSetDrivePassphrase(priv->mon, alias, secret);
|
|
||||||
if (qemuDomainObjExitMonitor(driver, vm) < 0)
|
|
||||||
ret = -1;
|
|
||||||
if (ret < 0)
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
VIR_FREE(alias);
|
|
||||||
VIR_FREE(secret);
|
|
||||||
virObjectUnref(cfg);
|
virObjectUnref(cfg);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -1343,7 +1343,6 @@ GEN_TEST_FUNC(qemuMonitorJSONAddNetdev, "id=net0,type=test")
|
|||||||
GEN_TEST_FUNC(qemuMonitorJSONRemoveNetdev, "net0")
|
GEN_TEST_FUNC(qemuMonitorJSONRemoveNetdev, "net0")
|
||||||
GEN_TEST_FUNC(qemuMonitorJSONDelDevice, "ide0")
|
GEN_TEST_FUNC(qemuMonitorJSONDelDevice, "ide0")
|
||||||
GEN_TEST_FUNC(qemuMonitorJSONAddDevice, "some_dummy_devicestr")
|
GEN_TEST_FUNC(qemuMonitorJSONAddDevice, "some_dummy_devicestr")
|
||||||
GEN_TEST_FUNC(qemuMonitorJSONSetDrivePassphrase, "drive-vda", "secret_passhprase")
|
|
||||||
GEN_TEST_FUNC(qemuMonitorJSONDriveMirror, "vdb", "/foo/bar", NULL, 1024, 0, 0,
|
GEN_TEST_FUNC(qemuMonitorJSONDriveMirror, "vdb", "/foo/bar", NULL, 1024, 0, 0,
|
||||||
VIR_DOMAIN_BLOCK_REBASE_SHALLOW | VIR_DOMAIN_BLOCK_REBASE_REUSE_EXT)
|
VIR_DOMAIN_BLOCK_REBASE_SHALLOW | VIR_DOMAIN_BLOCK_REBASE_REUSE_EXT)
|
||||||
GEN_TEST_FUNC(qemuMonitorJSONBlockCommit, "vdb", "/foo/bar1", "/foo/bar2", NULL, 1024)
|
GEN_TEST_FUNC(qemuMonitorJSONBlockCommit, "vdb", "/foo/bar1", "/foo/bar2", NULL, 1024)
|
||||||
@ -2967,7 +2966,6 @@ mymain(void)
|
|||||||
DO_TEST_GEN(qemuMonitorJSONRemoveNetdev);
|
DO_TEST_GEN(qemuMonitorJSONRemoveNetdev);
|
||||||
DO_TEST_GEN(qemuMonitorJSONDelDevice);
|
DO_TEST_GEN(qemuMonitorJSONDelDevice);
|
||||||
DO_TEST_GEN(qemuMonitorJSONAddDevice);
|
DO_TEST_GEN(qemuMonitorJSONAddDevice);
|
||||||
DO_TEST_GEN(qemuMonitorJSONSetDrivePassphrase);
|
|
||||||
DO_TEST_GEN(qemuMonitorJSONDriveMirror);
|
DO_TEST_GEN(qemuMonitorJSONDriveMirror);
|
||||||
DO_TEST_GEN(qemuMonitorJSONBlockCommit);
|
DO_TEST_GEN(qemuMonitorJSONBlockCommit);
|
||||||
DO_TEST_GEN(qemuMonitorJSONDrivePivot);
|
DO_TEST_GEN(qemuMonitorJSONDrivePivot);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user