On 18.05.2015 14:43, Ján Tomko wrote:
Base-64 encode the password and pass it to the guest agent
via the 'guest-set-user-password' command.
https://bugzilla.redhat.com/show_bug.cgi?id=1174177
---
src/qemu/qemu_agent.c | 39 +++++++++++++++++++++++++++++++++++
src/qemu/qemu_agent.h | 4 ++++
src/qemu/qemu_driver.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 98 insertions(+)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 2668011..6c7bc86 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -20124,6 +20124,60 @@ qemuGetDHCPInterfaces(virDomainPtr dom,
goto cleanup;
}
+
+static int
+qemuDomainSetUserPassword(virDomainPtr dom,
+ const char *user,
+ const char *password,
+ unsigned int flags)
+{
+ virQEMUDriverPtr driver = dom->conn->privateData;
+ qemuDomainObjPrivatePtr priv;
+ virDomainObjPtr vm;
+ int ret = -1;
+ int rv;
+
I failed to see how @rv is different to @ret.
+ virCheckFlags(VIR_DOMAIN_PASSWORD_CRYPTED, -1);
+
+ if (!(vm = qemuDomObjFromDomain(dom)))
+ return ret;
+
+ if (virDomainSetUserPasswordEnsureACL(dom->conn, vm->def) < 0)
+ goto cleanup;
+
+ priv = vm->privateData;
+
+ if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0)
+ goto cleanup;
+
+ if (!virDomainObjIsActive(vm)) {
+ virReportError(VIR_ERR_OPERATION_INVALID,
+ "%s", _("domain is not running"));
+ goto endjob;
+ }
+
+ if (!qemuDomainAgentAvailable(vm, true))
+ goto endjob;
+
+ qemuDomainObjEnterAgent(vm);
+ rv = qemuAgentSetUserPassword(priv->agent, user, password,
+ flags & VIR_DOMAIN_PASSWORD_CRYPTED);
+ qemuDomainObjExitAgent(vm);
+
+ if (rv < 0)
+ goto endjob;
+
+ ret = 0;
+
+ endjob:
+ qemuDomainObjEndJob(driver, vm);
+
+ cleanup:
+ virDomainObjEndAPI(&vm);
+ return ret;
+}
+
+
ACK though.
Michal