[PATCHv3 2a/9] qemu: Remove generation of drive alias from qcow passphrase backends

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.

Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx>
---

 Mainly so it's more apparent/transparent what I was planning to do.
 If you'd rather see the whole series again - that's not a problem...

 src/qemu/qemu_monitor_json.c | 7 +------
 src/qemu/qemu_monitor_text.c | 3 +--
 src/qemu/qemu_process.c      | 2 +-
 tests/qemumonitorjsontest.c  | 2 +-
 4 files changed, 4 insertions(+), 10 deletions(-)

diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 93233ea..2995264 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -3688,16 +3688,11 @@ int qemuMonitorJSONSetDrivePassphrase(qemuMonitorPtr mon,
     int ret = -1;
     virJSONValuePtr cmd;
     virJSONValuePtr reply = NULL;
-    char *drive;
-
-    if (virAsprintf(&drive, "%s%s", QEMU_DRIVE_HOST_PREFIX, alias) < 0)
-        return -1;
 
     cmd = qemuMonitorJSONMakeCommand("block_passwd",
-                                     "s:device", drive,
+                                     "s:device", alias,
                                      "s:password", passphrase,
                                      NULL);
-    VIR_FREE(drive);
     if (!cmd)
         return -1;
 
diff --git a/src/qemu/qemu_monitor_text.c b/src/qemu/qemu_monitor_text.c
index 6c458e2..cf2979d 100644
--- a/src/qemu/qemu_monitor_text.c
+++ b/src/qemu/qemu_monitor_text.c
@@ -2008,8 +2008,7 @@ int qemuMonitorTextSetDrivePassphrase(qemuMonitorPtr mon,
     if (!safe_str)
         return -1;
 
-    if (virAsprintf(&cmd, "block_passwd %s%s \"%s\"",
-                    QEMU_DRIVE_HOST_PREFIX, alias, safe_str) < 0)
+    if (virAsprintf(&cmd, "block_passwd %s \"%s\"", alias, safe_str) < 0)
         goto cleanup;
 
     if (qemuMonitorHMPCommand(mon, cmd, &reply) < 0)
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 8e1b896..bcc5d92 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -2476,7 +2476,7 @@ qemuProcessInitPasswords(virConnectPtr conn,
             goto cleanup;
 
         VIR_FREE(alias);
-        if (VIR_STRDUP(alias, vm->def->disks[i]->info.alias) < 0)
+        if (!(alias = qemuAliasFromDisk(vm->def->disks[i])))
             goto cleanup;
         if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0)
             goto cleanup;
diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c
index f698c14..e8946c2 100644
--- a/tests/qemumonitorjsontest.c
+++ b/tests/qemumonitorjsontest.c
@@ -1190,7 +1190,7 @@ GEN_TEST_FUNC(qemuMonitorJSONAddNetdev, "some_dummy_netdevstr")
 GEN_TEST_FUNC(qemuMonitorJSONRemoveNetdev, "net0")
 GEN_TEST_FUNC(qemuMonitorJSONDelDevice, "ide0")
 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,
               VIR_DOMAIN_BLOCK_REBASE_SHALLOW | VIR_DOMAIN_BLOCK_REBASE_REUSE_EXT)
 GEN_TEST_FUNC(qemuMonitorJSONBlockCommit, "vdb", "/foo/bar1", "/foo/bar2", NULL, 1024)
-- 
2.7.4

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]