qemu: Fix the command line generation for rbd auth using aes secrets
Closes: #827164
Guido Günther
7 years ago
0 | From: John Ferlan <jferlan@redhat.com> | |
1 | Date: Tue, 16 Aug 2016 16:50:15 -0400 | |
2 | Subject: qemu: Fix the command line generation for rbd auth using aes secrets | |
3 | ||
4 | https://bugzilla.redhat.com/show_bug.cgi?id=1182074 | |
5 | ||
6 | Since libvirt still uses a legacy qemu arg format to add a disk, the | |
7 | manner in which the 'password-secret' argument is passed to qemu needs | |
8 | to change to prepend a 'file.' If in the future, usage of the more | |
9 | modern disk format, then the prepended 'file.' can be removed. | |
10 | ||
11 | Fix based on Jim Fehlig <jfehlig@suse.com> posting and subsequent | |
12 | upstream list followups, see: | |
13 | ||
14 | http://www.redhat.com/archives/libvir-list/2016-August/msg00777.html | |
15 | ||
16 | for details. Introduced by commit id 'a1344f70'. | |
17 | ||
18 | Closes: #827164 | |
19 | --- | |
20 | src/qemu/qemu_command.c | 7 ++++++- | |
21 | .../qemuxml2argv-disk-drive-network-rbd-auth-AES.args | 2 +- | |
22 | 2 files changed, 7 insertions(+), 2 deletions(-) | |
23 | ||
24 | diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c | |
25 | index 5325f48..2b619a5 100644 | |
26 | --- a/src/qemu/qemu_command.c | |
27 | +++ b/src/qemu/qemu_command.c | |
28 | @@ -1296,7 +1296,12 @@ qemuBuildDriveSourceStr(virDomainDiskDefPtr disk, | |
29 | virBufferAddLit(buf, ","); | |
30 | ||
31 | if (secinfo && secinfo->type == VIR_DOMAIN_SECRET_INFO_TYPE_AES) { | |
32 | - virBufferAsprintf(buf, "password-secret=%s,", | |
33 | + /* NB: If libvirt starts using the more modern option based | |
34 | + * syntax to build the command line (e.g., "-drive driver=rbd, | |
35 | + * filename=%s,...") instead of the legacy model (e.g."-drive | |
36 | + * file=%s,..."), then the "file." prefix can be removed | |
37 | + */ | |
38 | + virBufferAsprintf(buf, "file.password-secret=%s,", | |
39 | secinfo->s.aes.alias); | |
40 | } | |
41 | ||
42 | diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-rbd-auth-AES.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-rbd-auth-AES.args | |
43 | index 5034bb7..07d01b6 100644 | |
44 | --- a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-rbd-auth-AES.args | |
45 | +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-rbd-auth-AES.args | |
46 | @@ -26,7 +26,7 @@ data=9eao5F8qtkGt+seB1HYivWIxbtwUu6MQtg1zpj/oDtUsPr1q8wBYM91uEHCn6j/1,\ | |
47 | keyid=masterKey0,iv=AAECAwQFBgcICQoLDA0ODw==,format=base64 \ | |
48 | -drive 'file=rbd:pool/image:id=myname:auth_supported=cephx\;none:\ | |
49 | mon_host=mon1.example.org\:6321\;mon2.example.org\:6322\;mon3.example.org\:\ | |
50 | -6322,password-secret=virtio-disk0-secret0,format=raw,if=none,\ | |
51 | +6322,file.password-secret=virtio-disk0-secret0,format=raw,if=none,\ | |
52 | id=drive-virtio-disk0' \ | |
53 | -device virtio-blk-pci,bus=pci.0,addr=0x3,drive=drive-virtio-disk0,\ | |
54 | id=virtio-disk0 |