]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: Remove generation of drive alias from qcow passphrase backends
authorJohn Ferlan <jferlan@redhat.com>
Mon, 1 Aug 2016 12:11:44 +0000 (08:11 -0400)
committerJohn Ferlan <jferlan@redhat.com>
Tue, 2 Aug 2016 14:11:11 +0000 (10:11 -0400)
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.

src/qemu/qemu_monitor_json.c
src/qemu/qemu_monitor_text.c
src/qemu/qemu_process.c
tests/qemumonitorjsontest.c

index 37bab949a19bca97e2f36624795b6a68bcfe9e28..a415e593e4265c20c32d8ad5dc2767503cf037df 100644 (file)
@@ -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;
 
index 9295219b3ff7d87bb856787c88acfe4742ae2064..00310d94a1351ac1cf9a4dec1695a3226287baa6 100644 (file)
@@ -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)
index 3f4d79f9e7fc2819a49a3aa4fc230c633a36594a..b87e305049f4a5bf5e187873557d13139982cf6d 100644 (file)
@@ -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;
index f698c144a6623a5a5d176f1270fe5b7281b09df6..e8946c263168423672a8369078d04dab0535919e 100644 (file)
@@ -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)