mirror of https://gitee.com/openkylin/qemu.git
-----BEGIN PGP SIGNATURE-----
iQIcBAABAgAGBQJbqbC9AAoJEL2+eyfA3jBXO9MQALB0smt3obst2SvGHYdKHDf/ 08Tmg2hg/1jhbCwKuVAQ2lZuSRKt8STCSXk/q14WBZH4VrXBVfwoVLMgiF7xet0r H5tmxrAQLIlTzDEPOkpJStq6xzThT+TXUqLhm3lSoalMNPkvB3frLb7LRii4n3Hd omyU0DWclksb8enbhEA7u3GSIbJJLdDs5/GvODsJi8A4Bdgmaw4xcf3YPmRPIYHR 6TX8nCQZC+Be8wkWJJ/MCADoPnwHh8id1a6yGZ5IqKFvxyo4CHE2SvvXlSP89ssR 7+EElpHSbJwyOI17BYZVdIORIfJbLFd5aJxjssvBp1Hv4DGowjCle5FqiJju3Ynd rIoRnCoXTZbJ9KlZ9iDNXh1nCgX6dzQRTkS4zp+Ey0Uw3OwYmt2W+iPKi/B2RfKs vH35AOJ/dbacHAGwSZgKxyK1I6whBuwGZ8bNI8SAiDTGaKyneQVIo41Xk78lxSt5 KFt4pplXSrAirtS62HWTGxrU3BKSoNYf3wLi0lnA5DrvgHVt2GfLfTbL4wxXXwDo BkdZneNmPhg0PBMc8YdqjlUZ74jgd/9KygqVCDO/ALa1+0PpvE/4oHNrWHCX9Nh2 fhE1f9DsJqe4bXxTisjcT8vsWvPT0Zv2piF5QGMu/P8EHHuetKSZ9sqPPK8M2eVR Q+cB7B942EE3CcIaZI/S =KbMO -----END PGP SIGNATURE----- Merge remote-tracking branch 'remotes/cody/tags/block-pull-request' into staging # gpg: Signature made Tue 25 Sep 2018 04:51:25 BST # gpg: using RSA key BDBE7B27C0DE3057 # gpg: Good signature from "Jeffrey Cody <jcody@redhat.com>" # gpg: aka "Jeffrey Cody <jeff@codyprime.org>" # gpg: aka "Jeffrey Cody <codyprime@gmail.com>" # Primary key fingerprint: 9957 4B4D 3474 90E7 9D98 D624 BDBE 7B27 C0DE 3057 * remotes/cody/tags/block-pull-request: curl: Make sslverify=off disable host as well as peer verification. block/rbd: add deprecation documentation for filename keyvalue pairs block/rbd: add iotest for rbd legacy keyvalue filename parsing block/rbd: Attempt to parse legacy filenames block/rbd: pull out qemu_rbd_convert_options Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
commit
32556acb5a
|
@ -483,6 +483,8 @@ static int curl_init_state(BDRVCURLState *s, CURLState *state)
|
||||||
curl_easy_setopt(state->curl, CURLOPT_URL, s->url);
|
curl_easy_setopt(state->curl, CURLOPT_URL, s->url);
|
||||||
curl_easy_setopt(state->curl, CURLOPT_SSL_VERIFYPEER,
|
curl_easy_setopt(state->curl, CURLOPT_SSL_VERIFYPEER,
|
||||||
(long) s->sslverify);
|
(long) s->sslverify);
|
||||||
|
curl_easy_setopt(state->curl, CURLOPT_SSL_VERIFYHOST,
|
||||||
|
s->sslverify ? 2L : 0L);
|
||||||
if (s->cookie) {
|
if (s->cookie) {
|
||||||
curl_easy_setopt(state->curl, CURLOPT_COOKIE, s->cookie);
|
curl_easy_setopt(state->curl, CURLOPT_COOKIE, s->cookie);
|
||||||
}
|
}
|
||||||
|
|
90
block/rbd.c
90
block/rbd.c
|
@ -655,12 +655,61 @@ failed_opts:
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int qemu_rbd_convert_options(QDict *options, BlockdevOptionsRbd **opts,
|
||||||
|
Error **errp)
|
||||||
|
{
|
||||||
|
Visitor *v;
|
||||||
|
Error *local_err = NULL;
|
||||||
|
|
||||||
|
/* Convert the remaining options into a QAPI object */
|
||||||
|
v = qobject_input_visitor_new_flat_confused(options, errp);
|
||||||
|
if (!v) {
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
visit_type_BlockdevOptionsRbd(v, NULL, opts, &local_err);
|
||||||
|
visit_free(v);
|
||||||
|
|
||||||
|
if (local_err) {
|
||||||
|
error_propagate(errp, local_err);
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int qemu_rbd_attempt_legacy_options(QDict *options,
|
||||||
|
BlockdevOptionsRbd **opts,
|
||||||
|
char **keypairs)
|
||||||
|
{
|
||||||
|
char *filename;
|
||||||
|
int r;
|
||||||
|
|
||||||
|
filename = g_strdup(qdict_get_try_str(options, "filename"));
|
||||||
|
if (!filename) {
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
qdict_del(options, "filename");
|
||||||
|
|
||||||
|
qemu_rbd_parse_filename(filename, options, NULL);
|
||||||
|
|
||||||
|
/* keypairs freed by caller */
|
||||||
|
*keypairs = g_strdup(qdict_get_try_str(options, "=keyvalue-pairs"));
|
||||||
|
if (*keypairs) {
|
||||||
|
qdict_del(options, "=keyvalue-pairs");
|
||||||
|
}
|
||||||
|
|
||||||
|
r = qemu_rbd_convert_options(options, opts, NULL);
|
||||||
|
|
||||||
|
g_free(filename);
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags,
|
static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags,
|
||||||
Error **errp)
|
Error **errp)
|
||||||
{
|
{
|
||||||
BDRVRBDState *s = bs->opaque;
|
BDRVRBDState *s = bs->opaque;
|
||||||
BlockdevOptionsRbd *opts = NULL;
|
BlockdevOptionsRbd *opts = NULL;
|
||||||
Visitor *v;
|
|
||||||
const QDictEntry *e;
|
const QDictEntry *e;
|
||||||
Error *local_err = NULL;
|
Error *local_err = NULL;
|
||||||
char *keypairs, *secretid;
|
char *keypairs, *secretid;
|
||||||
|
@ -676,20 +725,33 @@ static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags,
|
||||||
qdict_del(options, "password-secret");
|
qdict_del(options, "password-secret");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Convert the remaining options into a QAPI object */
|
r = qemu_rbd_convert_options(options, &opts, &local_err);
|
||||||
v = qobject_input_visitor_new_flat_confused(options, errp);
|
|
||||||
if (!v) {
|
|
||||||
r = -EINVAL;
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
visit_type_BlockdevOptionsRbd(v, NULL, &opts, &local_err);
|
|
||||||
visit_free(v);
|
|
||||||
|
|
||||||
if (local_err) {
|
if (local_err) {
|
||||||
error_propagate(errp, local_err);
|
/* If keypairs are present, that means some options are present in
|
||||||
r = -EINVAL;
|
* the modern option format. Don't attempt to parse legacy option
|
||||||
goto out;
|
* formats, as we won't support mixed usage. */
|
||||||
|
if (keypairs) {
|
||||||
|
error_propagate(errp, local_err);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If the initial attempt to convert and process the options failed,
|
||||||
|
* we may be attempting to open an image file that has the rbd options
|
||||||
|
* specified in the older format consisting of all key/value pairs
|
||||||
|
* encoded in the filename. Go ahead and attempt to parse the
|
||||||
|
* filename, and see if we can pull out the required options. */
|
||||||
|
r = qemu_rbd_attempt_legacy_options(options, &opts, &keypairs);
|
||||||
|
if (r < 0) {
|
||||||
|
/* Propagate the original error, not the legacy parsing fallback
|
||||||
|
* error, as the latter was just a best-effort attempt. */
|
||||||
|
error_propagate(errp, local_err);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
/* Take care whenever deciding to actually deprecate; once this ability
|
||||||
|
* is removed, we will not be able to open any images with legacy-styled
|
||||||
|
* backing image strings. */
|
||||||
|
error_report("RBD options encoded in the filename as keyvalue pairs "
|
||||||
|
"is deprecated");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Remove the processed options from the QDict (the visitor processes
|
/* Remove the processed options from the QDict (the visitor processes
|
||||||
|
|
|
@ -128,6 +128,21 @@ used instead.
|
||||||
In order to prevent QEMU from automatically opening an image's backing
|
In order to prevent QEMU from automatically opening an image's backing
|
||||||
chain, use ``"backing": null'' instead.
|
chain, use ``"backing": null'' instead.
|
||||||
|
|
||||||
|
@subsubsection rbd keyvalue pair encoded filenames: "" (since 3.1.0)
|
||||||
|
|
||||||
|
Options for ``rbd'' should be specified according to its runtime options,
|
||||||
|
like other block drivers. Legacy parsing of keyvalue pair encoded
|
||||||
|
filenames is useful to open images with the old format for backing files;
|
||||||
|
These image files should be updated to use the current format.
|
||||||
|
|
||||||
|
Example of legacy encoding:
|
||||||
|
|
||||||
|
@code{json:@{"file.driver":"rbd", "file.filename":"rbd:rbd/name"@}}
|
||||||
|
|
||||||
|
The above, converted to the current supported format:
|
||||||
|
|
||||||
|
@code{json:@{"file.driver":"rbd", "file.pool":"rbd", "file.image":"name"@}}
|
||||||
|
|
||||||
@subsection vio-spapr-device device options
|
@subsection vio-spapr-device device options
|
||||||
|
|
||||||
@subsubsection "irq": "" (since 3.0.0)
|
@subsubsection "irq": "" (since 3.0.0)
|
||||||
|
|
|
@ -0,0 +1,62 @@
|
||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# Test legacy and modern option parsing for rbd/ceph. This will not
|
||||||
|
# actually connect to a ceph server, but rather looks for the appropriate
|
||||||
|
# error message that indicates we parsed the options correctly.
|
||||||
|
#
|
||||||
|
# Copyright (C) 2018 Red Hat, Inc.
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation; either version 2 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
|
||||||
|
# creator
|
||||||
|
owner=jcody@redhat.com
|
||||||
|
|
||||||
|
seq=`basename $0`
|
||||||
|
echo "QA output created by $seq"
|
||||||
|
|
||||||
|
here=`pwd`
|
||||||
|
status=1 # failure is the default!
|
||||||
|
|
||||||
|
_cleanup()
|
||||||
|
{
|
||||||
|
rm "${BOGUS_CONF}"
|
||||||
|
}
|
||||||
|
trap "_cleanup; exit \$status" 0 1 2 3 15
|
||||||
|
|
||||||
|
# get standard environment, filters and checks
|
||||||
|
. ./common.rc
|
||||||
|
. ./common.filter
|
||||||
|
|
||||||
|
_supported_fmt generic
|
||||||
|
_supported_proto rbd
|
||||||
|
_supported_os Linux
|
||||||
|
|
||||||
|
BOGUS_CONF=${TEST_DIR}/ceph-$$.conf
|
||||||
|
touch "${BOGUS_CONF}"
|
||||||
|
|
||||||
|
_filter_conf()
|
||||||
|
{
|
||||||
|
sed -e "s#$BOGUS_CONF#BOGUS_CONF#g"
|
||||||
|
}
|
||||||
|
|
||||||
|
# We expect this to fail, with no monitor ip provided and a null conf file. Just want it
|
||||||
|
# to fail in the right way.
|
||||||
|
$QEMU_IMG info "json:{'file.driver':'rbd','file.filename':'rbd:rbd/bogus:conf=${BOGUS_CONF}'}" 2>&1 | _filter_conf
|
||||||
|
$QEMU_IMG info "json:{'file.driver':'rbd','file.pool':'rbd','file.image':'bogus','file.conf':'${BOGUS_CONF}'}" 2>&1 | _filter_conf
|
||||||
|
|
||||||
|
# success, all done
|
||||||
|
echo "*** done"
|
||||||
|
rm -f $seq.full
|
||||||
|
status=0
|
|
@ -0,0 +1,9 @@
|
||||||
|
QA output created by 231
|
||||||
|
qemu-img: RBD options encoded in the filename as keyvalue pairs is deprecated. Future versions may cease to parse these options in the future.
|
||||||
|
unable to get monitor info from DNS SRV with service name: ceph-mon
|
||||||
|
no monitors specified to connect to.
|
||||||
|
qemu-img: Could not open 'json:{'file.driver':'rbd','file.filename':'rbd:rbd/bogus:conf=BOGUS_CONF'}': error connecting: No such file or directory
|
||||||
|
unable to get monitor info from DNS SRV with service name: ceph-mon
|
||||||
|
no monitors specified to connect to.
|
||||||
|
qemu-img: Could not open 'json:{'file.driver':'rbd','file.pool':'rbd','file.image':'bogus','file.conf':'BOGUS_CONF'}': error connecting: No such file or directory
|
||||||
|
*** done
|
|
@ -226,3 +226,4 @@
|
||||||
226 auto quick
|
226 auto quick
|
||||||
227 auto quick
|
227 auto quick
|
||||||
229 auto quick
|
229 auto quick
|
||||||
|
231 auto quick
|
||||||
|
|
Loading…
Reference in New Issue