Revision fd04a2ae
b/block.c | ||
---|---|---|
1134 | 1134 |
if (!bs->encrypted) |
1135 | 1135 |
return 0; |
1136 | 1136 |
} |
1137 |
if (!bs->encrypted || !bs->drv || !bs->drv->bdrv_set_key) |
|
1138 |
return -1; |
|
1137 |
if (!bs->encrypted) { |
|
1138 |
return -EINVAL; |
|
1139 |
} else if (!bs->drv || !bs->drv->bdrv_set_key) { |
|
1140 |
return -ENOMEDIUM; |
|
1141 |
} |
|
1139 | 1142 |
ret = bs->drv->bdrv_set_key(bs, key); |
1140 | 1143 |
if (ret < 0) { |
1141 | 1144 |
bs->valid_key = 0; |
b/monitor.c | ||
---|---|---|
1057 | 1057 |
QObject **ret_data) |
1058 | 1058 |
{ |
1059 | 1059 |
BlockDriverState *bs; |
1060 |
int err; |
|
1060 | 1061 |
|
1061 | 1062 |
bs = bdrv_find(qdict_get_str(qdict, "device")); |
1062 | 1063 |
if (!bs) { |
... | ... | |
1064 | 1065 |
return -1; |
1065 | 1066 |
} |
1066 | 1067 |
|
1067 |
if (bdrv_set_key(bs, qdict_get_str(qdict, "password")) < 0) { |
|
1068 |
err = bdrv_set_key(bs, qdict_get_str(qdict, "password")); |
|
1069 |
if (err == -EINVAL) { |
|
1070 |
qerror_report(QERR_DEVICE_NOT_ENCRYPTED, bdrv_get_device_name(bs)); |
|
1071 |
return -1; |
|
1072 |
} else if (err < 0) { |
|
1068 | 1073 |
qerror_report(QERR_INVALID_PASSWORD); |
1069 | 1074 |
return -1; |
1070 | 1075 |
} |
Also available in: Unified diff