mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 08:13:54 -06:00
qapi: Convert block_passwd
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
This commit is contained in:
parent
4b37156c40
commit
a4dea8a9f4
7 changed files with 56 additions and 19 deletions
22
blockdev.c
22
blockdev.c
|
@ -15,6 +15,7 @@
|
|||
#include "qemu-config.h"
|
||||
#include "sysemu.h"
|
||||
#include "block_int.h"
|
||||
#include "qmp-commands.h"
|
||||
|
||||
static QTAILQ_HEAD(drivelist, DriveInfo) drives = QTAILQ_HEAD_INITIALIZER(drives);
|
||||
|
||||
|
@ -710,28 +711,25 @@ int do_eject(Monitor *mon, const QDict *qdict, QObject **ret_data)
|
|||
return eject_device(mon, bs, force);
|
||||
}
|
||||
|
||||
int do_block_set_passwd(Monitor *mon, const QDict *qdict,
|
||||
QObject **ret_data)
|
||||
void qmp_block_passwd(const char *device, const char *password, Error **errp)
|
||||
{
|
||||
BlockDriverState *bs;
|
||||
int err;
|
||||
|
||||
bs = bdrv_find(qdict_get_str(qdict, "device"));
|
||||
bs = bdrv_find(device);
|
||||
if (!bs) {
|
||||
qerror_report(QERR_DEVICE_NOT_FOUND, qdict_get_str(qdict, "device"));
|
||||
return -1;
|
||||
error_set(errp, QERR_DEVICE_NOT_FOUND, device);
|
||||
return;
|
||||
}
|
||||
|
||||
err = bdrv_set_key(bs, qdict_get_str(qdict, "password"));
|
||||
err = bdrv_set_key(bs, password);
|
||||
if (err == -EINVAL) {
|
||||
qerror_report(QERR_DEVICE_NOT_ENCRYPTED, bdrv_get_device_name(bs));
|
||||
return -1;
|
||||
error_set(errp, QERR_DEVICE_NOT_ENCRYPTED, bdrv_get_device_name(bs));
|
||||
return;
|
||||
} else if (err < 0) {
|
||||
qerror_report(QERR_INVALID_PASSWORD);
|
||||
return -1;
|
||||
error_set(errp, QERR_INVALID_PASSWORD);
|
||||
return;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int do_change_block(Monitor *mon, const char *device,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue