提交 f8d49d5b 编写于 作者: J John Ferlan

qemu: Remove generation of drive alias from qcow passphrase backends

Rather than pass the disks[i]->info.alias to qemuMonitorSetDrivePassphrase
and then generate the "drive-%s" alias from that, let's use qemuAliasFromDisk
prior to the call to generate the drive alias and then pass that along
thus removing the need to generate the alias from the monitor code.
上级 675a7e4e
...@@ -3688,16 +3688,11 @@ int qemuMonitorJSONSetDrivePassphrase(qemuMonitorPtr mon, ...@@ -3688,16 +3688,11 @@ int qemuMonitorJSONSetDrivePassphrase(qemuMonitorPtr mon,
int ret = -1; int ret = -1;
virJSONValuePtr cmd; virJSONValuePtr cmd;
virJSONValuePtr reply = NULL; virJSONValuePtr reply = NULL;
char *drive;
if (virAsprintf(&drive, "%s%s", QEMU_DRIVE_HOST_PREFIX, alias) < 0)
return -1;
cmd = qemuMonitorJSONMakeCommand("block_passwd", cmd = qemuMonitorJSONMakeCommand("block_passwd",
"s:device", drive, "s:device", alias,
"s:password", passphrase, "s:password", passphrase,
NULL); NULL);
VIR_FREE(drive);
if (!cmd) if (!cmd)
return -1; return -1;
......
...@@ -2008,8 +2008,7 @@ int qemuMonitorTextSetDrivePassphrase(qemuMonitorPtr mon, ...@@ -2008,8 +2008,7 @@ int qemuMonitorTextSetDrivePassphrase(qemuMonitorPtr mon,
if (!safe_str) if (!safe_str)
return -1; return -1;
if (virAsprintf(&cmd, "block_passwd %s%s \"%s\"", if (virAsprintf(&cmd, "block_passwd %s \"%s\"", alias, safe_str) < 0)
QEMU_DRIVE_HOST_PREFIX, alias, safe_str) < 0)
goto cleanup; goto cleanup;
if (qemuMonitorHMPCommand(mon, cmd, &reply) < 0) if (qemuMonitorHMPCommand(mon, cmd, &reply) < 0)
......
...@@ -2476,7 +2476,7 @@ qemuProcessInitPasswords(virConnectPtr conn, ...@@ -2476,7 +2476,7 @@ qemuProcessInitPasswords(virConnectPtr conn,
goto cleanup; goto cleanup;
VIR_FREE(alias); VIR_FREE(alias);
if (VIR_STRDUP(alias, vm->def->disks[i]->info.alias) < 0) if (!(alias = qemuAliasFromDisk(vm->def->disks[i])))
goto cleanup; goto cleanup;
if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0) if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0)
goto cleanup; goto cleanup;
......
...@@ -1190,7 +1190,7 @@ GEN_TEST_FUNC(qemuMonitorJSONAddNetdev, "some_dummy_netdevstr") ...@@ -1190,7 +1190,7 @@ GEN_TEST_FUNC(qemuMonitorJSONAddNetdev, "some_dummy_netdevstr")
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, "vda", "secret_passhprase") 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)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册