Compare commits
110 Commits
master
...
stable-2.9
Author | SHA1 | Date |
---|---|---|
Michael Roth | 4cd42653f5 | |
Greg Kurz | c24c5910b7 | |
Richard Henderson | 2d1bbf51c2 | |
Anthony PERARD | 30b76b2439 | |
Stefano Stabellini | 2f64063f4e | |
Prasad J Pandit | 15d8f91446 | |
Gerd Hoffmann | f9c313f70f | |
Dr. David Alan Gilbert | 53206753ba | |
Michael Roth | 167e76494e | |
Farhan Ali | e22e199b2b | |
Alexander Graf | 5035184165 | |
Max Reitz | 20920f4db6 | |
Gerd Hoffmann | 4e6889b76b | |
Paolo Bonzini | 244a3ef947 | |
Paolo Bonzini | 578fb5003f | |
Paolo Bonzini | 50b9353315 | |
Paolo Bonzini | d016071ca5 | |
Paolo Bonzini | 20fd62d374 | |
Greg Kurz | 7442018a00 | |
Prasad J Pandit | 0f590e798f | |
Gerd Hoffmann | 3c69132635 | |
P J P | 40a7d47c5a | |
Thomas Huth | 9b9b4423d7 | |
Thomas Huth | 980e8260e6 | |
Eduardo Habkost | aab00230aa | |
Eduardo Otubo | cfc65be6fb | |
Thomas Huth | ac0038f182 | |
Samuel Thibault | 62708c7c12 | |
Marc-André Lureau | 746e1fd000 | |
Thomas Huth | e8679f5b45 | |
Philipp Kern | c152efc943 | |
Greg Kurz | 077a67e929 | |
Jeff Cody | f4f3529cfe | |
Aleksandr Bezzubikov | 5f7f7e4f05 | |
Laurent Vivier | de9b6728ff | |
Kevin Wolf | a0ddbcfb68 | |
Kevin Wolf | d445e0a022 | |
Alexander Graf | ad480ab20b | |
Gerd Hoffmann | f8d050a20a | |
Jason Wang | 9527514ceb | |
Greg Kurz | 2a7526b0ce | |
Kevin Wolf | 2e40aad231 | |
Jason Wang | 70da03f10c | |
Laurent Vivier | 19284a0141 | |
Alexander Graf | 0060a3e936 | |
Bruce Rogers | e0398ccdf4 | |
Max Reitz | 438cd1e6aa | |
Paolo Bonzini | 40ed5cdf72 | |
Max Reitz | 2182791734 | |
Max Reitz | 1828d47845 | |
Kevin Wolf | 1dd3ba38f6 | |
Eric Blake | ecc7a24c11 | |
Eric Blake | ec49c8ac57 | |
Kevin Wolf | f28b8906dd | |
Max Filippov | bace1f90f9 | |
Greg Kurz | 3b2f3a4691 | |
Laurent Vivier | 7f4c9f5f3b | |
Greg Kurz | 592ee4007e | |
Greg Kurz | 917a5b9f2f | |
Eduardo Habkost | 2401d8a490 | |
Michael Roth | 1775fe6148 | |
Michael Roth | b0a3eadd8c | |
Paolo Bonzini | 3b428e9512 | |
Ladi Prosek | 11bac2f941 | |
Kevin Wolf | 0ebbef1fa1 | |
Eric Blake | 64945cb5f3 | |
Eric Blake | 6a3f9c5c6e | |
Eric Blake | 3f3fe284ef | |
Eric Blake | 48f2dc0657 | |
Eric Blake | 3ae74003b5 | |
Eric Blake | 577cf9e6bb | |
Eric Blake | 138cf638ba | |
Eric Blake | a1a3d603c4 | |
Yunjian Wang | 0b185544c9 | |
Halil Pasic | f3676379cc | |
Sameeh Jubran | 4921c573c8 | |
Fam Zheng | 952cc38204 | |
Greg Kurz | c6b510d1e5 | |
Hervé Poussineau | 636eacb641 | |
Alberto Garcia | c60a8ed89b | |
Paolo Bonzini | c79bef68c4 | |
Paolo Bonzini | 4b519b9fd7 | |
Paolo Bonzini | f00c08cbac | |
Max Filippov | d81db0beca | |
Max Filippov | e442253479 | |
John Snow | af8ca55a6b | |
Max Reitz | 5797a36abd | |
Max Reitz | 73aa7ad7d2 | |
Anton Nefedov | d8cddcc2b9 | |
Stefan Hajnoczi | ce119247a1 | |
Zhiyong Yang | 0e727a207e | |
Fam Zheng | d2fcb92b18 | |
Eric Blake | e59084b5b2 | |
Eric Blake | 1eaf431077 | |
Eric Blake | 396474a18c | |
Eric Blake | 3f308bf3ac | |
Eric Blake | 21047240d0 | |
Greg Kurz | 785d9ab216 | |
Markus Armbruster | 45b3eac752 | |
Bruce Rogers | c64d184584 | |
Max Reitz | c1059a3a3c | |
Herongguang (Stephen) | 0b906e4d0a | |
Daniel P. Berrange | 181e005f14 | |
Max Reitz | b8420f7102 | |
Max Reitz | bd1039b463 | |
Max Reitz | bc70597a48 | |
Max Reitz | a1c850fd9d | |
Max Reitz | c37a62b751 | |
Eric Blake | 4aa16db9cf | |
Sameeh Jubran | 27dd31f164 |
|
@ -1395,6 +1395,7 @@ S: Supported
|
||||||
F: qobject/
|
F: qobject/
|
||||||
F: include/qapi/qmp/
|
F: include/qapi/qmp/
|
||||||
X: include/qapi/qmp/dispatch.h
|
X: include/qapi/qmp/dispatch.h
|
||||||
|
F: scripts/coccinelle/qobject.cocci
|
||||||
F: tests/check-qdict.c
|
F: tests/check-qdict.c
|
||||||
F: tests/check-qfloat.c
|
F: tests/check-qfloat.c
|
||||||
F: tests/check-qint.c
|
F: tests/check-qint.c
|
||||||
|
|
|
@ -2028,6 +2028,8 @@ void AUD_del_capture (CaptureVoiceOut *cap, void *cb_opaque)
|
||||||
sw = sw1;
|
sw = sw1;
|
||||||
}
|
}
|
||||||
QLIST_REMOVE (cap, entries);
|
QLIST_REMOVE (cap, entries);
|
||||||
|
g_free (cap->hw.mix_buf);
|
||||||
|
g_free (cap->buf);
|
||||||
g_free (cap);
|
g_free (cap);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
|
82
block.c
82
block.c
|
@ -937,16 +937,14 @@ static void update_flags_from_options(int *flags, QemuOpts *opts)
|
||||||
static void update_options_from_flags(QDict *options, int flags)
|
static void update_options_from_flags(QDict *options, int flags)
|
||||||
{
|
{
|
||||||
if (!qdict_haskey(options, BDRV_OPT_CACHE_DIRECT)) {
|
if (!qdict_haskey(options, BDRV_OPT_CACHE_DIRECT)) {
|
||||||
qdict_put(options, BDRV_OPT_CACHE_DIRECT,
|
qdict_put_bool(options, BDRV_OPT_CACHE_DIRECT, flags & BDRV_O_NOCACHE);
|
||||||
qbool_from_bool(flags & BDRV_O_NOCACHE));
|
|
||||||
}
|
}
|
||||||
if (!qdict_haskey(options, BDRV_OPT_CACHE_NO_FLUSH)) {
|
if (!qdict_haskey(options, BDRV_OPT_CACHE_NO_FLUSH)) {
|
||||||
qdict_put(options, BDRV_OPT_CACHE_NO_FLUSH,
|
qdict_put_bool(options, BDRV_OPT_CACHE_NO_FLUSH,
|
||||||
qbool_from_bool(flags & BDRV_O_NO_FLUSH));
|
flags & BDRV_O_NO_FLUSH);
|
||||||
}
|
}
|
||||||
if (!qdict_haskey(options, BDRV_OPT_READ_ONLY)) {
|
if (!qdict_haskey(options, BDRV_OPT_READ_ONLY)) {
|
||||||
qdict_put(options, BDRV_OPT_READ_ONLY,
|
qdict_put_bool(options, BDRV_OPT_READ_ONLY, !(flags & BDRV_O_RDWR));
|
||||||
qbool_from_bool(!(flags & BDRV_O_RDWR)));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1167,7 +1165,7 @@ static int bdrv_open_common(BlockDriverState *bs, BlockBackend *file,
|
||||||
filename = qdict_get_try_str(options, "filename");
|
filename = qdict_get_try_str(options, "filename");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (drv->bdrv_needs_filename && !filename) {
|
if (drv->bdrv_needs_filename && (!filename || !filename[0])) {
|
||||||
error_setg(errp, "The '%s' block driver requires a file name",
|
error_setg(errp, "The '%s' block driver requires a file name",
|
||||||
drv->format_name);
|
drv->format_name);
|
||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
|
@ -1362,7 +1360,7 @@ static int bdrv_fill_options(QDict **options, const char *filename,
|
||||||
/* Fetch the file name from the options QDict if necessary */
|
/* Fetch the file name from the options QDict if necessary */
|
||||||
if (protocol && filename) {
|
if (protocol && filename) {
|
||||||
if (!qdict_haskey(*options, "filename")) {
|
if (!qdict_haskey(*options, "filename")) {
|
||||||
qdict_put(*options, "filename", qstring_from_str(filename));
|
qdict_put_str(*options, "filename", filename);
|
||||||
parse_filename = true;
|
parse_filename = true;
|
||||||
} else {
|
} else {
|
||||||
error_setg(errp, "Can't specify 'file' and 'filename' options at "
|
error_setg(errp, "Can't specify 'file' and 'filename' options at "
|
||||||
|
@ -1383,7 +1381,7 @@ static int bdrv_fill_options(QDict **options, const char *filename,
|
||||||
}
|
}
|
||||||
|
|
||||||
drvname = drv->format_name;
|
drvname = drv->format_name;
|
||||||
qdict_put(*options, "driver", qstring_from_str(drvname));
|
qdict_put_str(*options, "driver", drvname);
|
||||||
} else {
|
} else {
|
||||||
error_setg(errp, "Must specify either driver or file");
|
error_setg(errp, "Must specify either driver or file");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
@ -2038,7 +2036,7 @@ int bdrv_open_backing_file(BlockDriverState *bs, QDict *parent_options,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bs->backing_format[0] != '\0' && !qdict_haskey(options, "driver")) {
|
if (bs->backing_format[0] != '\0' && !qdict_haskey(options, "driver")) {
|
||||||
qdict_put(options, "driver", qstring_from_str(bs->backing_format));
|
qdict_put_str(options, "driver", bs->backing_format);
|
||||||
}
|
}
|
||||||
|
|
||||||
backing_hd = bdrv_open_inherit(*backing_filename ? backing_filename : NULL,
|
backing_hd = bdrv_open_inherit(*backing_filename ? backing_filename : NULL,
|
||||||
|
@ -2193,12 +2191,9 @@ static BlockDriverState *bdrv_append_temp_snapshot(BlockDriverState *bs,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Prepare options QDict for the temporary file */
|
/* Prepare options QDict for the temporary file */
|
||||||
qdict_put(snapshot_options, "file.driver",
|
qdict_put_str(snapshot_options, "file.driver", "file");
|
||||||
qstring_from_str("file"));
|
qdict_put_str(snapshot_options, "file.filename", tmp_filename);
|
||||||
qdict_put(snapshot_options, "file.filename",
|
qdict_put_str(snapshot_options, "driver", "qcow2");
|
||||||
qstring_from_str(tmp_filename));
|
|
||||||
qdict_put(snapshot_options, "driver",
|
|
||||||
qstring_from_str("qcow2"));
|
|
||||||
|
|
||||||
bs_snapshot = bdrv_open(NULL, NULL, snapshot_options, flags, errp);
|
bs_snapshot = bdrv_open(NULL, NULL, snapshot_options, flags, errp);
|
||||||
snapshot_options = NULL;
|
snapshot_options = NULL;
|
||||||
|
@ -2373,8 +2368,7 @@ static BlockDriverState *bdrv_open_inherit(const char *filename,
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
qdict_put(options, "file",
|
qdict_put_str(options, "file", bdrv_get_node_name(file_bs));
|
||||||
qstring_from_str(bdrv_get_node_name(file_bs)));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2396,8 +2390,8 @@ static BlockDriverState *bdrv_open_inherit(const char *filename,
|
||||||
* sure to update both bs->options (which has the full effective
|
* sure to update both bs->options (which has the full effective
|
||||||
* options for bs) and options (which has file.* already removed).
|
* options for bs) and options (which has file.* already removed).
|
||||||
*/
|
*/
|
||||||
qdict_put(bs->options, "driver", qstring_from_str(drv->format_name));
|
qdict_put_str(bs->options, "driver", drv->format_name);
|
||||||
qdict_put(options, "driver", qstring_from_str(drv->format_name));
|
qdict_put_str(options, "driver", drv->format_name);
|
||||||
} else if (!drv) {
|
} else if (!drv) {
|
||||||
error_setg(errp, "Must specify either driver or file");
|
error_setg(errp, "Must specify either driver or file");
|
||||||
goto fail;
|
goto fail;
|
||||||
|
@ -2772,12 +2766,12 @@ int bdrv_reopen_prepare(BDRVReopenState *reopen_state, BlockReopenQueue *queue,
|
||||||
* that they are checked at the end of this function. */
|
* that they are checked at the end of this function. */
|
||||||
value = qemu_opt_get(opts, "node-name");
|
value = qemu_opt_get(opts, "node-name");
|
||||||
if (value) {
|
if (value) {
|
||||||
qdict_put(reopen_state->options, "node-name", qstring_from_str(value));
|
qdict_put_str(reopen_state->options, "node-name", value);
|
||||||
}
|
}
|
||||||
|
|
||||||
value = qemu_opt_get(opts, "driver");
|
value = qemu_opt_get(opts, "driver");
|
||||||
if (value) {
|
if (value) {
|
||||||
qdict_put(reopen_state->options, "driver", qstring_from_str(value));
|
qdict_put_str(reopen_state->options, "driver", value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* if we are to stay read-only, do not allow permission change
|
/* if we are to stay read-only, do not allow permission change
|
||||||
|
@ -3268,7 +3262,7 @@ exit:
|
||||||
/**
|
/**
|
||||||
* Truncate file to 'offset' bytes (needed only for file protocols)
|
* Truncate file to 'offset' bytes (needed only for file protocols)
|
||||||
*/
|
*/
|
||||||
int bdrv_truncate(BdrvChild *child, int64_t offset)
|
int bdrv_truncate(BdrvChild *child, int64_t offset, Error **errp)
|
||||||
{
|
{
|
||||||
BlockDriverState *bs = child->bs;
|
BlockDriverState *bs = child->bs;
|
||||||
BlockDriver *drv = bs->drv;
|
BlockDriver *drv = bs->drv;
|
||||||
|
@ -3280,12 +3274,18 @@ int bdrv_truncate(BdrvChild *child, int64_t offset)
|
||||||
* cannot assert this permission in that case. */
|
* cannot assert this permission in that case. */
|
||||||
// assert(child->perm & BLK_PERM_RESIZE);
|
// assert(child->perm & BLK_PERM_RESIZE);
|
||||||
|
|
||||||
if (!drv)
|
if (!drv) {
|
||||||
|
error_setg(errp, "No medium inserted");
|
||||||
return -ENOMEDIUM;
|
return -ENOMEDIUM;
|
||||||
if (!drv->bdrv_truncate)
|
}
|
||||||
|
if (!drv->bdrv_truncate) {
|
||||||
|
error_setg(errp, "Image format driver does not support resize");
|
||||||
return -ENOTSUP;
|
return -ENOTSUP;
|
||||||
if (bs->read_only)
|
}
|
||||||
|
if (bs->read_only) {
|
||||||
|
error_setg(errp, "Image is read-only");
|
||||||
return -EACCES;
|
return -EACCES;
|
||||||
|
}
|
||||||
|
|
||||||
ret = drv->bdrv_truncate(bs, offset);
|
ret = drv->bdrv_truncate(bs, offset);
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
|
@ -3293,6 +3293,8 @@ int bdrv_truncate(BdrvChild *child, int64_t offset)
|
||||||
bdrv_dirty_bitmap_truncate(bs);
|
bdrv_dirty_bitmap_truncate(bs);
|
||||||
bdrv_parent_cb_resize(bs);
|
bdrv_parent_cb_resize(bs);
|
||||||
++bs->write_gen;
|
++bs->write_gen;
|
||||||
|
} else {
|
||||||
|
error_setg_errno(errp, -ret, "Failed to resize image");
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -3861,19 +3863,6 @@ BlockDriverState *bdrv_find_backing_image(BlockDriverState *bs,
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
int bdrv_get_backing_file_depth(BlockDriverState *bs)
|
|
||||||
{
|
|
||||||
if (!bs->drv) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!bs->backing) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1 + bdrv_get_backing_file_depth(bs->backing->bs);
|
|
||||||
}
|
|
||||||
|
|
||||||
void bdrv_init(void)
|
void bdrv_init(void)
|
||||||
{
|
{
|
||||||
module_call_init(MODULE_INIT_BLOCK);
|
module_call_init(MODULE_INIT_BLOCK);
|
||||||
|
@ -4268,8 +4257,7 @@ void bdrv_img_create(const char *filename, const char *fmt,
|
||||||
|
|
||||||
if (backing_fmt) {
|
if (backing_fmt) {
|
||||||
backing_options = qdict_new();
|
backing_options = qdict_new();
|
||||||
qdict_put(backing_options, "driver",
|
qdict_put_str(backing_options, "driver", backing_fmt);
|
||||||
qstring_from_str(backing_fmt));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bs = bdrv_open(full_backing, NULL, backing_options, back_flags,
|
bs = bdrv_open(full_backing, NULL, backing_options, back_flags,
|
||||||
|
@ -4674,11 +4662,9 @@ void bdrv_refresh_filename(BlockDriverState *bs)
|
||||||
* contain a representation of the filename, therefore the following
|
* contain a representation of the filename, therefore the following
|
||||||
* suffices without querying the (exact_)filename of this BDS. */
|
* suffices without querying the (exact_)filename of this BDS. */
|
||||||
if (bs->file->bs->full_open_options) {
|
if (bs->file->bs->full_open_options) {
|
||||||
qdict_put_obj(opts, "driver",
|
qdict_put_str(opts, "driver", drv->format_name);
|
||||||
QOBJECT(qstring_from_str(drv->format_name)));
|
|
||||||
QINCREF(bs->file->bs->full_open_options);
|
QINCREF(bs->file->bs->full_open_options);
|
||||||
qdict_put_obj(opts, "file",
|
qdict_put(opts, "file", bs->file->bs->full_open_options);
|
||||||
QOBJECT(bs->file->bs->full_open_options));
|
|
||||||
|
|
||||||
bs->full_open_options = opts;
|
bs->full_open_options = opts;
|
||||||
} else {
|
} else {
|
||||||
|
@ -4694,8 +4680,7 @@ void bdrv_refresh_filename(BlockDriverState *bs)
|
||||||
|
|
||||||
opts = qdict_new();
|
opts = qdict_new();
|
||||||
append_open_options(opts, bs);
|
append_open_options(opts, bs);
|
||||||
qdict_put_obj(opts, "driver",
|
qdict_put_str(opts, "driver", drv->format_name);
|
||||||
QOBJECT(qstring_from_str(drv->format_name)));
|
|
||||||
|
|
||||||
if (bs->exact_filename[0]) {
|
if (bs->exact_filename[0]) {
|
||||||
/* This may not work for all block protocol drivers (some may
|
/* This may not work for all block protocol drivers (some may
|
||||||
|
@ -4705,8 +4690,7 @@ void bdrv_refresh_filename(BlockDriverState *bs)
|
||||||
* needs some special format of the options QDict, it needs to
|
* needs some special format of the options QDict, it needs to
|
||||||
* implement the driver-specific bdrv_refresh_filename() function.
|
* implement the driver-specific bdrv_refresh_filename() function.
|
||||||
*/
|
*/
|
||||||
qdict_put_obj(opts, "filename",
|
qdict_put_str(opts, "filename", bs->exact_filename);
|
||||||
QOBJECT(qstring_from_str(bs->exact_filename)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bs->full_open_options = opts;
|
bs->full_open_options = opts;
|
||||||
|
|
290
block/blkdebug.c
290
block/blkdebug.c
|
@ -1,6 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* Block protocol for I/O error injection
|
* Block protocol for I/O error injection
|
||||||
*
|
*
|
||||||
|
* Copyright (C) 2016-2017 Red Hat, Inc.
|
||||||
* Copyright (c) 2010 Kevin Wolf <kwolf@redhat.com>
|
* Copyright (c) 2010 Kevin Wolf <kwolf@redhat.com>
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
@ -37,7 +38,12 @@
|
||||||
typedef struct BDRVBlkdebugState {
|
typedef struct BDRVBlkdebugState {
|
||||||
int state;
|
int state;
|
||||||
int new_state;
|
int new_state;
|
||||||
int align;
|
uint64_t align;
|
||||||
|
uint64_t max_transfer;
|
||||||
|
uint64_t opt_write_zero;
|
||||||
|
uint64_t max_write_zero;
|
||||||
|
uint64_t opt_discard;
|
||||||
|
uint64_t max_discard;
|
||||||
|
|
||||||
/* For blkdebug_refresh_filename() */
|
/* For blkdebug_refresh_filename() */
|
||||||
char *config_file;
|
char *config_file;
|
||||||
|
@ -301,7 +307,7 @@ static void blkdebug_parse_filename(const char *filename, QDict *options,
|
||||||
if (!strstart(filename, "blkdebug:", &filename)) {
|
if (!strstart(filename, "blkdebug:", &filename)) {
|
||||||
/* There was no prefix; therefore, all options have to be already
|
/* There was no prefix; therefore, all options have to be already
|
||||||
present in the QDict (except for the filename) */
|
present in the QDict (except for the filename) */
|
||||||
qdict_put(options, "x-image", qstring_from_str(filename));
|
qdict_put_str(options, "x-image", filename);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -320,7 +326,7 @@ static void blkdebug_parse_filename(const char *filename, QDict *options,
|
||||||
|
|
||||||
/* TODO Allow multi-level nesting and set file.filename here */
|
/* TODO Allow multi-level nesting and set file.filename here */
|
||||||
filename = c + 1;
|
filename = c + 1;
|
||||||
qdict_put(options, "x-image", qstring_from_str(filename));
|
qdict_put_str(options, "x-image", filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
static QemuOptsList runtime_opts = {
|
static QemuOptsList runtime_opts = {
|
||||||
|
@ -342,6 +348,31 @@ static QemuOptsList runtime_opts = {
|
||||||
.type = QEMU_OPT_SIZE,
|
.type = QEMU_OPT_SIZE,
|
||||||
.help = "Required alignment in bytes",
|
.help = "Required alignment in bytes",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
.name = "max-transfer",
|
||||||
|
.type = QEMU_OPT_SIZE,
|
||||||
|
.help = "Maximum transfer size in bytes",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.name = "opt-write-zero",
|
||||||
|
.type = QEMU_OPT_SIZE,
|
||||||
|
.help = "Optimum write zero alignment in bytes",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.name = "max-write-zero",
|
||||||
|
.type = QEMU_OPT_SIZE,
|
||||||
|
.help = "Maximum write zero size in bytes",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.name = "opt-discard",
|
||||||
|
.type = QEMU_OPT_SIZE,
|
||||||
|
.help = "Optimum discard alignment in bytes",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.name = "max-discard",
|
||||||
|
.type = QEMU_OPT_SIZE,
|
||||||
|
.help = "Maximum discard size in bytes",
|
||||||
|
},
|
||||||
{ /* end of list */ }
|
{ /* end of list */ }
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -352,8 +383,8 @@ static int blkdebug_open(BlockDriverState *bs, QDict *options, int flags,
|
||||||
BDRVBlkdebugState *s = bs->opaque;
|
BDRVBlkdebugState *s = bs->opaque;
|
||||||
QemuOpts *opts;
|
QemuOpts *opts;
|
||||||
Error *local_err = NULL;
|
Error *local_err = NULL;
|
||||||
uint64_t align;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
uint64_t align;
|
||||||
|
|
||||||
opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort);
|
opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort);
|
||||||
qemu_opts_absorb_qdict(opts, options, &local_err);
|
qemu_opts_absorb_qdict(opts, options, &local_err);
|
||||||
|
@ -382,21 +413,69 @@ static int blkdebug_open(BlockDriverState *bs, QDict *options, int flags,
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set request alignment */
|
bs->supported_write_flags = BDRV_REQ_FUA &
|
||||||
align = qemu_opt_get_size(opts, "align", 0);
|
bs->file->bs->supported_write_flags;
|
||||||
if (align < INT_MAX && is_power_of_2(align)) {
|
bs->supported_zero_flags = (BDRV_REQ_FUA | BDRV_REQ_MAY_UNMAP) &
|
||||||
s->align = align;
|
bs->file->bs->supported_zero_flags;
|
||||||
} else if (align) {
|
ret = -EINVAL;
|
||||||
error_setg(errp, "Invalid alignment");
|
|
||||||
ret = -EINVAL;
|
/* Set alignment overrides */
|
||||||
goto fail_unref;
|
s->align = qemu_opt_get_size(opts, "align", 0);
|
||||||
|
if (s->align && (s->align >= INT_MAX || !is_power_of_2(s->align))) {
|
||||||
|
error_setg(errp, "Cannot meet constraints with align %" PRIu64,
|
||||||
|
s->align);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
align = MAX(s->align, bs->file->bs->bl.request_alignment);
|
||||||
|
|
||||||
|
s->max_transfer = qemu_opt_get_size(opts, "max-transfer", 0);
|
||||||
|
if (s->max_transfer &&
|
||||||
|
(s->max_transfer >= INT_MAX ||
|
||||||
|
!QEMU_IS_ALIGNED(s->max_transfer, align))) {
|
||||||
|
error_setg(errp, "Cannot meet constraints with max-transfer %" PRIu64,
|
||||||
|
s->max_transfer);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
s->opt_write_zero = qemu_opt_get_size(opts, "opt-write-zero", 0);
|
||||||
|
if (s->opt_write_zero &&
|
||||||
|
(s->opt_write_zero >= INT_MAX ||
|
||||||
|
!QEMU_IS_ALIGNED(s->opt_write_zero, align))) {
|
||||||
|
error_setg(errp, "Cannot meet constraints with opt-write-zero %" PRIu64,
|
||||||
|
s->opt_write_zero);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
s->max_write_zero = qemu_opt_get_size(opts, "max-write-zero", 0);
|
||||||
|
if (s->max_write_zero &&
|
||||||
|
(s->max_write_zero >= INT_MAX ||
|
||||||
|
!QEMU_IS_ALIGNED(s->max_write_zero,
|
||||||
|
MAX(s->opt_write_zero, align)))) {
|
||||||
|
error_setg(errp, "Cannot meet constraints with max-write-zero %" PRIu64,
|
||||||
|
s->max_write_zero);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
s->opt_discard = qemu_opt_get_size(opts, "opt-discard", 0);
|
||||||
|
if (s->opt_discard &&
|
||||||
|
(s->opt_discard >= INT_MAX ||
|
||||||
|
!QEMU_IS_ALIGNED(s->opt_discard, align))) {
|
||||||
|
error_setg(errp, "Cannot meet constraints with opt-discard %" PRIu64,
|
||||||
|
s->opt_discard);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
s->max_discard = qemu_opt_get_size(opts, "max-discard", 0);
|
||||||
|
if (s->max_discard &&
|
||||||
|
(s->max_discard >= INT_MAX ||
|
||||||
|
!QEMU_IS_ALIGNED(s->max_discard,
|
||||||
|
MAX(s->opt_discard, align)))) {
|
||||||
|
error_setg(errp, "Cannot meet constraints with max-discard %" PRIu64,
|
||||||
|
s->max_discard);
|
||||||
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
goto out;
|
|
||||||
|
|
||||||
fail_unref:
|
|
||||||
bdrv_unref_child(bs, bs->file);
|
|
||||||
out:
|
out:
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
g_free(s->config_file);
|
g_free(s->config_file);
|
||||||
|
@ -405,11 +484,30 @@ out:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int inject_error(BlockDriverState *bs, BlkdebugRule *rule)
|
static int rule_check(BlockDriverState *bs, uint64_t offset, uint64_t bytes)
|
||||||
{
|
{
|
||||||
BDRVBlkdebugState *s = bs->opaque;
|
BDRVBlkdebugState *s = bs->opaque;
|
||||||
int error = rule->options.inject.error;
|
BlkdebugRule *rule = NULL;
|
||||||
bool immediately = rule->options.inject.immediately;
|
int error;
|
||||||
|
bool immediately;
|
||||||
|
|
||||||
|
QSIMPLEQ_FOREACH(rule, &s->active_rules, active_next) {
|
||||||
|
uint64_t inject_offset = rule->options.inject.offset;
|
||||||
|
|
||||||
|
if (inject_offset == -1 ||
|
||||||
|
(bytes && inject_offset >= offset &&
|
||||||
|
inject_offset < offset + bytes))
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!rule || !rule->options.inject.error) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
immediately = rule->options.inject.immediately;
|
||||||
|
error = rule->options.inject.error;
|
||||||
|
|
||||||
if (rule->options.inject.once) {
|
if (rule->options.inject.once) {
|
||||||
QSIMPLEQ_REMOVE(&s->active_rules, rule, BlkdebugRule, active_next);
|
QSIMPLEQ_REMOVE(&s->active_rules, rule, BlkdebugRule, active_next);
|
||||||
|
@ -428,21 +526,18 @@ static int coroutine_fn
|
||||||
blkdebug_co_preadv(BlockDriverState *bs, uint64_t offset, uint64_t bytes,
|
blkdebug_co_preadv(BlockDriverState *bs, uint64_t offset, uint64_t bytes,
|
||||||
QEMUIOVector *qiov, int flags)
|
QEMUIOVector *qiov, int flags)
|
||||||
{
|
{
|
||||||
BDRVBlkdebugState *s = bs->opaque;
|
int err;
|
||||||
BlkdebugRule *rule = NULL;
|
|
||||||
|
|
||||||
QSIMPLEQ_FOREACH(rule, &s->active_rules, active_next) {
|
/* Sanity check block layer guarantees */
|
||||||
uint64_t inject_offset = rule->options.inject.offset;
|
assert(QEMU_IS_ALIGNED(offset, bs->bl.request_alignment));
|
||||||
|
assert(QEMU_IS_ALIGNED(bytes, bs->bl.request_alignment));
|
||||||
if (inject_offset == -1 ||
|
if (bs->bl.max_transfer) {
|
||||||
(inject_offset >= offset && inject_offset < offset + bytes))
|
assert(bytes <= bs->bl.max_transfer);
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rule && rule->options.inject.error) {
|
err = rule_check(bs, offset, bytes);
|
||||||
return inject_error(bs, rule);
|
if (err) {
|
||||||
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
return bdrv_co_preadv(bs->file, offset, bytes, qiov, flags);
|
return bdrv_co_preadv(bs->file, offset, bytes, qiov, flags);
|
||||||
|
@ -452,21 +547,18 @@ static int coroutine_fn
|
||||||
blkdebug_co_pwritev(BlockDriverState *bs, uint64_t offset, uint64_t bytes,
|
blkdebug_co_pwritev(BlockDriverState *bs, uint64_t offset, uint64_t bytes,
|
||||||
QEMUIOVector *qiov, int flags)
|
QEMUIOVector *qiov, int flags)
|
||||||
{
|
{
|
||||||
BDRVBlkdebugState *s = bs->opaque;
|
int err;
|
||||||
BlkdebugRule *rule = NULL;
|
|
||||||
|
|
||||||
QSIMPLEQ_FOREACH(rule, &s->active_rules, active_next) {
|
/* Sanity check block layer guarantees */
|
||||||
uint64_t inject_offset = rule->options.inject.offset;
|
assert(QEMU_IS_ALIGNED(offset, bs->bl.request_alignment));
|
||||||
|
assert(QEMU_IS_ALIGNED(bytes, bs->bl.request_alignment));
|
||||||
if (inject_offset == -1 ||
|
if (bs->bl.max_transfer) {
|
||||||
(inject_offset >= offset && inject_offset < offset + bytes))
|
assert(bytes <= bs->bl.max_transfer);
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rule && rule->options.inject.error) {
|
err = rule_check(bs, offset, bytes);
|
||||||
return inject_error(bs, rule);
|
if (err) {
|
||||||
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
return bdrv_co_pwritev(bs->file, offset, bytes, qiov, flags);
|
return bdrv_co_pwritev(bs->file, offset, bytes, qiov, flags);
|
||||||
|
@ -474,22 +566,81 @@ blkdebug_co_pwritev(BlockDriverState *bs, uint64_t offset, uint64_t bytes,
|
||||||
|
|
||||||
static int blkdebug_co_flush(BlockDriverState *bs)
|
static int blkdebug_co_flush(BlockDriverState *bs)
|
||||||
{
|
{
|
||||||
BDRVBlkdebugState *s = bs->opaque;
|
int err = rule_check(bs, 0, 0);
|
||||||
BlkdebugRule *rule = NULL;
|
|
||||||
|
|
||||||
QSIMPLEQ_FOREACH(rule, &s->active_rules, active_next) {
|
if (err) {
|
||||||
if (rule->options.inject.offset == -1) {
|
return err;
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (rule && rule->options.inject.error) {
|
|
||||||
return inject_error(bs, rule);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return bdrv_co_flush(bs->file->bs);
|
return bdrv_co_flush(bs->file->bs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int coroutine_fn blkdebug_co_pwrite_zeroes(BlockDriverState *bs,
|
||||||
|
int64_t offset, int count,
|
||||||
|
BdrvRequestFlags flags)
|
||||||
|
{
|
||||||
|
uint32_t align = MAX(bs->bl.request_alignment,
|
||||||
|
bs->bl.pwrite_zeroes_alignment);
|
||||||
|
int err;
|
||||||
|
|
||||||
|
/* Only pass through requests that are larger than requested
|
||||||
|
* preferred alignment (so that we test the fallback to writes on
|
||||||
|
* unaligned portions), and check that the block layer never hands
|
||||||
|
* us anything unaligned that crosses an alignment boundary. */
|
||||||
|
if (count < align) {
|
||||||
|
assert(QEMU_IS_ALIGNED(offset, align) ||
|
||||||
|
QEMU_IS_ALIGNED(offset + count, align) ||
|
||||||
|
DIV_ROUND_UP(offset, align) ==
|
||||||
|
DIV_ROUND_UP(offset + count, align));
|
||||||
|
return -ENOTSUP;
|
||||||
|
}
|
||||||
|
assert(QEMU_IS_ALIGNED(offset, align));
|
||||||
|
assert(QEMU_IS_ALIGNED(count, align));
|
||||||
|
if (bs->bl.max_pwrite_zeroes) {
|
||||||
|
assert(count <= bs->bl.max_pwrite_zeroes);
|
||||||
|
}
|
||||||
|
|
||||||
|
err = rule_check(bs, offset, count);
|
||||||
|
if (err) {
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
return bdrv_co_pwrite_zeroes(bs->file, offset, count, flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int coroutine_fn blkdebug_co_pdiscard(BlockDriverState *bs,
|
||||||
|
int64_t offset, int count)
|
||||||
|
{
|
||||||
|
uint32_t align = bs->bl.pdiscard_alignment;
|
||||||
|
int err;
|
||||||
|
|
||||||
|
/* Only pass through requests that are larger than requested
|
||||||
|
* minimum alignment, and ensure that unaligned requests do not
|
||||||
|
* cross optimum discard boundaries. */
|
||||||
|
if (count < bs->bl.request_alignment) {
|
||||||
|
assert(QEMU_IS_ALIGNED(offset, align) ||
|
||||||
|
QEMU_IS_ALIGNED(offset + count, align) ||
|
||||||
|
DIV_ROUND_UP(offset, align) ==
|
||||||
|
DIV_ROUND_UP(offset + count, align));
|
||||||
|
return -ENOTSUP;
|
||||||
|
}
|
||||||
|
assert(QEMU_IS_ALIGNED(offset, bs->bl.request_alignment));
|
||||||
|
assert(QEMU_IS_ALIGNED(count, bs->bl.request_alignment));
|
||||||
|
if (align && count >= align) {
|
||||||
|
assert(QEMU_IS_ALIGNED(offset, align));
|
||||||
|
assert(QEMU_IS_ALIGNED(count, align));
|
||||||
|
}
|
||||||
|
if (bs->bl.max_pdiscard) {
|
||||||
|
assert(count <= bs->bl.max_pdiscard);
|
||||||
|
}
|
||||||
|
|
||||||
|
err = rule_check(bs, offset, count);
|
||||||
|
if (err) {
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
return bdrv_co_pdiscard(bs->file->bs, offset, count);
|
||||||
|
}
|
||||||
|
|
||||||
static void blkdebug_close(BlockDriverState *bs)
|
static void blkdebug_close(BlockDriverState *bs)
|
||||||
{
|
{
|
||||||
|
@ -663,7 +814,7 @@ static int64_t blkdebug_getlength(BlockDriverState *bs)
|
||||||
|
|
||||||
static int blkdebug_truncate(BlockDriverState *bs, int64_t offset)
|
static int blkdebug_truncate(BlockDriverState *bs, int64_t offset)
|
||||||
{
|
{
|
||||||
return bdrv_truncate(bs->file, offset);
|
return bdrv_truncate(bs->file, offset, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void blkdebug_refresh_filename(BlockDriverState *bs, QDict *options)
|
static void blkdebug_refresh_filename(BlockDriverState *bs, QDict *options)
|
||||||
|
@ -689,16 +840,20 @@ static void blkdebug_refresh_filename(BlockDriverState *bs, QDict *options)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!force_json && bs->file->bs->exact_filename[0]) {
|
if (!force_json && bs->file->bs->exact_filename[0]) {
|
||||||
snprintf(bs->exact_filename, sizeof(bs->exact_filename),
|
int ret = snprintf(bs->exact_filename, sizeof(bs->exact_filename),
|
||||||
"blkdebug:%s:%s", s->config_file ?: "",
|
"blkdebug:%s:%s", s->config_file ?: "",
|
||||||
bs->file->bs->exact_filename);
|
bs->file->bs->exact_filename);
|
||||||
|
if (ret >= sizeof(bs->exact_filename)) {
|
||||||
|
/* An overflow makes the filename unusable, so do not report any */
|
||||||
|
bs->exact_filename[0] = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
opts = qdict_new();
|
opts = qdict_new();
|
||||||
qdict_put_obj(opts, "driver", QOBJECT(qstring_from_str("blkdebug")));
|
qdict_put_str(opts, "driver", "blkdebug");
|
||||||
|
|
||||||
QINCREF(bs->file->bs->full_open_options);
|
QINCREF(bs->file->bs->full_open_options);
|
||||||
qdict_put_obj(opts, "image", QOBJECT(bs->file->bs->full_open_options));
|
qdict_put(opts, "image", bs->file->bs->full_open_options);
|
||||||
|
|
||||||
for (e = qdict_first(options); e; e = qdict_next(options, e)) {
|
for (e = qdict_first(options); e; e = qdict_next(options, e)) {
|
||||||
if (strcmp(qdict_entry_key(e), "x-image")) {
|
if (strcmp(qdict_entry_key(e), "x-image")) {
|
||||||
|
@ -717,6 +872,21 @@ static void blkdebug_refresh_limits(BlockDriverState *bs, Error **errp)
|
||||||
if (s->align) {
|
if (s->align) {
|
||||||
bs->bl.request_alignment = s->align;
|
bs->bl.request_alignment = s->align;
|
||||||
}
|
}
|
||||||
|
if (s->max_transfer) {
|
||||||
|
bs->bl.max_transfer = s->max_transfer;
|
||||||
|
}
|
||||||
|
if (s->opt_write_zero) {
|
||||||
|
bs->bl.pwrite_zeroes_alignment = s->opt_write_zero;
|
||||||
|
}
|
||||||
|
if (s->max_write_zero) {
|
||||||
|
bs->bl.max_pwrite_zeroes = s->max_write_zero;
|
||||||
|
}
|
||||||
|
if (s->opt_discard) {
|
||||||
|
bs->bl.pdiscard_alignment = s->opt_discard;
|
||||||
|
}
|
||||||
|
if (s->max_discard) {
|
||||||
|
bs->bl.max_pdiscard = s->max_discard;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int blkdebug_reopen_prepare(BDRVReopenState *reopen_state,
|
static int blkdebug_reopen_prepare(BDRVReopenState *reopen_state,
|
||||||
|
@ -744,6 +914,8 @@ static BlockDriver bdrv_blkdebug = {
|
||||||
.bdrv_co_preadv = blkdebug_co_preadv,
|
.bdrv_co_preadv = blkdebug_co_preadv,
|
||||||
.bdrv_co_pwritev = blkdebug_co_pwritev,
|
.bdrv_co_pwritev = blkdebug_co_pwritev,
|
||||||
.bdrv_co_flush_to_disk = blkdebug_co_flush,
|
.bdrv_co_flush_to_disk = blkdebug_co_flush,
|
||||||
|
.bdrv_co_pwrite_zeroes = blkdebug_co_pwrite_zeroes,
|
||||||
|
.bdrv_co_pdiscard = blkdebug_co_pdiscard,
|
||||||
|
|
||||||
.bdrv_debug_event = blkdebug_debug_event,
|
.bdrv_debug_event = blkdebug_debug_event,
|
||||||
.bdrv_debug_breakpoint = blkdebug_debug_breakpoint,
|
.bdrv_debug_breakpoint = blkdebug_debug_breakpoint,
|
||||||
|
|
|
@ -37,9 +37,6 @@ static int blkreplay_open(BlockDriverState *bs, QDict *options, int flags,
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
fail:
|
fail:
|
||||||
if (ret < 0) {
|
|
||||||
bdrv_unref_child(bs, bs->file);
|
|
||||||
}
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -67,7 +67,7 @@ static void blkverify_parse_filename(const char *filename, QDict *options,
|
||||||
if (!strstart(filename, "blkverify:", &filename)) {
|
if (!strstart(filename, "blkverify:", &filename)) {
|
||||||
/* There was no prefix; therefore, all options have to be already
|
/* There was no prefix; therefore, all options have to be already
|
||||||
present in the QDict (except for the filename) */
|
present in the QDict (except for the filename) */
|
||||||
qdict_put(options, "x-image", qstring_from_str(filename));
|
qdict_put_str(options, "x-image", filename);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ static void blkverify_parse_filename(const char *filename, QDict *options,
|
||||||
|
|
||||||
/* TODO Allow multi-level nesting and set file.filename here */
|
/* TODO Allow multi-level nesting and set file.filename here */
|
||||||
filename = c + 1;
|
filename = c + 1;
|
||||||
qdict_put(options, "x-image", qstring_from_str(filename));
|
qdict_put_str(options, "x-image", filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
static QemuOptsList runtime_opts = {
|
static QemuOptsList runtime_opts = {
|
||||||
|
@ -142,9 +142,6 @@ static int blkverify_open(BlockDriverState *bs, QDict *options, int flags,
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
fail:
|
fail:
|
||||||
if (ret < 0) {
|
|
||||||
bdrv_unref_child(bs, bs->file);
|
|
||||||
}
|
|
||||||
qemu_opts_del(opts);
|
qemu_opts_del(opts);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -291,13 +288,12 @@ static void blkverify_refresh_filename(BlockDriverState *bs, QDict *options)
|
||||||
&& s->test_file->bs->full_open_options)
|
&& s->test_file->bs->full_open_options)
|
||||||
{
|
{
|
||||||
QDict *opts = qdict_new();
|
QDict *opts = qdict_new();
|
||||||
qdict_put_obj(opts, "driver", QOBJECT(qstring_from_str("blkverify")));
|
qdict_put_str(opts, "driver", "blkverify");
|
||||||
|
|
||||||
QINCREF(bs->file->bs->full_open_options);
|
QINCREF(bs->file->bs->full_open_options);
|
||||||
qdict_put_obj(opts, "raw", QOBJECT(bs->file->bs->full_open_options));
|
qdict_put(opts, "raw", bs->file->bs->full_open_options);
|
||||||
QINCREF(s->test_file->bs->full_open_options);
|
QINCREF(s->test_file->bs->full_open_options);
|
||||||
qdict_put_obj(opts, "test",
|
qdict_put(opts, "test", s->test_file->bs->full_open_options);
|
||||||
QOBJECT(s->test_file->bs->full_open_options));
|
|
||||||
|
|
||||||
bs->full_open_options = opts;
|
bs->full_open_options = opts;
|
||||||
}
|
}
|
||||||
|
@ -305,10 +301,14 @@ static void blkverify_refresh_filename(BlockDriverState *bs, QDict *options)
|
||||||
if (bs->file->bs->exact_filename[0]
|
if (bs->file->bs->exact_filename[0]
|
||||||
&& s->test_file->bs->exact_filename[0])
|
&& s->test_file->bs->exact_filename[0])
|
||||||
{
|
{
|
||||||
snprintf(bs->exact_filename, sizeof(bs->exact_filename),
|
int ret = snprintf(bs->exact_filename, sizeof(bs->exact_filename),
|
||||||
"blkverify:%s:%s",
|
"blkverify:%s:%s",
|
||||||
bs->file->bs->exact_filename,
|
bs->file->bs->exact_filename,
|
||||||
s->test_file->bs->exact_filename);
|
s->test_file->bs->exact_filename);
|
||||||
|
if (ret >= sizeof(bs->exact_filename)) {
|
||||||
|
/* An overflow makes the filename unusable, so do not report any */
|
||||||
|
bs->exact_filename[0] = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1746,13 +1746,14 @@ int blk_pwrite_compressed(BlockBackend *blk, int64_t offset, const void *buf,
|
||||||
BDRV_REQ_WRITE_COMPRESSED);
|
BDRV_REQ_WRITE_COMPRESSED);
|
||||||
}
|
}
|
||||||
|
|
||||||
int blk_truncate(BlockBackend *blk, int64_t offset)
|
int blk_truncate(BlockBackend *blk, int64_t offset, Error **errp)
|
||||||
{
|
{
|
||||||
if (!blk_is_available(blk)) {
|
if (!blk_is_available(blk)) {
|
||||||
|
error_setg(errp, "No medium inserted");
|
||||||
return -ENOMEDIUM;
|
return -ENOMEDIUM;
|
||||||
}
|
}
|
||||||
|
|
||||||
return bdrv_truncate(blk->root, offset);
|
return bdrv_truncate(blk->root, offset, errp);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void blk_pdiscard_entry(void *opaque)
|
static void blk_pdiscard_entry(void *opaque)
|
||||||
|
|
|
@ -89,6 +89,12 @@ static void commit_complete(BlockJob *job, void *opaque)
|
||||||
int ret = data->ret;
|
int ret = data->ret;
|
||||||
bool remove_commit_top_bs = false;
|
bool remove_commit_top_bs = false;
|
||||||
|
|
||||||
|
/* Make sure overlay_bs and top stay around until bdrv_set_backing_hd() */
|
||||||
|
bdrv_ref(top);
|
||||||
|
if (overlay_bs) {
|
||||||
|
bdrv_ref(overlay_bs);
|
||||||
|
}
|
||||||
|
|
||||||
/* Remove base node parent that still uses BLK_PERM_WRITE/RESIZE before
|
/* Remove base node parent that still uses BLK_PERM_WRITE/RESIZE before
|
||||||
* the normal backing chain can be restored. */
|
* the normal backing chain can be restored. */
|
||||||
blk_unref(s->base);
|
blk_unref(s->base);
|
||||||
|
@ -115,6 +121,13 @@ static void commit_complete(BlockJob *job, void *opaque)
|
||||||
}
|
}
|
||||||
g_free(s->backing_file_str);
|
g_free(s->backing_file_str);
|
||||||
blk_unref(s->top);
|
blk_unref(s->top);
|
||||||
|
|
||||||
|
/* If there is more than one reference to the job (e.g. if called from
|
||||||
|
* block_job_finish_sync()), block_job_completed() won't free it and
|
||||||
|
* therefore the blockers on the intermediate nodes remain. This would
|
||||||
|
* cause bdrv_set_backing_hd() to fail. */
|
||||||
|
block_job_remove_all_bdrv(job);
|
||||||
|
|
||||||
block_job_completed(&s->common, ret);
|
block_job_completed(&s->common, ret);
|
||||||
g_free(data);
|
g_free(data);
|
||||||
|
|
||||||
|
@ -124,6 +137,9 @@ static void commit_complete(BlockJob *job, void *opaque)
|
||||||
if (remove_commit_top_bs) {
|
if (remove_commit_top_bs) {
|
||||||
bdrv_set_backing_hd(overlay_bs, top, &error_abort);
|
bdrv_set_backing_hd(overlay_bs, top, &error_abort);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bdrv_unref(overlay_bs);
|
||||||
|
bdrv_unref(top);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void coroutine_fn commit_run(void *opaque)
|
static void coroutine_fn commit_run(void *opaque)
|
||||||
|
@ -151,7 +167,7 @@ static void coroutine_fn commit_run(void *opaque)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (base_len < s->common.len) {
|
if (base_len < s->common.len) {
|
||||||
ret = blk_truncate(s->base, s->common.len);
|
ret = blk_truncate(s->base, s->common.len, NULL);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
@ -335,6 +351,9 @@ void commit_start(const char *job_id, BlockDriverState *bs,
|
||||||
if (commit_top_bs == NULL) {
|
if (commit_top_bs == NULL) {
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
if (!filter_node_name) {
|
||||||
|
commit_top_bs->implicit = true;
|
||||||
|
}
|
||||||
commit_top_bs->total_sectors = top->total_sectors;
|
commit_top_bs->total_sectors = top->total_sectors;
|
||||||
bdrv_set_aio_context(commit_top_bs, bdrv_get_aio_context(top));
|
bdrv_set_aio_context(commit_top_bs, bdrv_get_aio_context(top));
|
||||||
|
|
||||||
|
@ -511,8 +530,9 @@ int bdrv_commit(BlockDriverState *bs)
|
||||||
* grow the backing file image if possible. If not possible,
|
* grow the backing file image if possible. If not possible,
|
||||||
* we must return an error */
|
* we must return an error */
|
||||||
if (length > backing_length) {
|
if (length > backing_length) {
|
||||||
ret = blk_truncate(backing, length);
|
ret = blk_truncate(backing, length, &local_err);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
|
error_report_err(local_err);
|
||||||
goto ro_cleanup;
|
goto ro_cleanup;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -389,7 +389,7 @@ static int block_crypto_truncate(BlockDriverState *bs, int64_t offset)
|
||||||
|
|
||||||
offset += payload_offset;
|
offset += payload_offset;
|
||||||
|
|
||||||
return bdrv_truncate(bs->file, offset);
|
return bdrv_truncate(bs->file, offset, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void block_crypto_close(BlockDriverState *bs)
|
static void block_crypto_close(BlockDriverState *bs)
|
||||||
|
|
33
block/curl.c
33
block/curl.c
|
@ -147,6 +147,7 @@ static void curl_multi_do(void *arg);
|
||||||
static void curl_multi_read(void *arg);
|
static void curl_multi_read(void *arg);
|
||||||
|
|
||||||
#ifdef NEED_CURL_TIMER_CALLBACK
|
#ifdef NEED_CURL_TIMER_CALLBACK
|
||||||
|
/* Called from curl_multi_do_locked, with s->mutex held. */
|
||||||
static int curl_timer_cb(CURLM *multi, long timeout_ms, void *opaque)
|
static int curl_timer_cb(CURLM *multi, long timeout_ms, void *opaque)
|
||||||
{
|
{
|
||||||
BDRVCURLState *s = opaque;
|
BDRVCURLState *s = opaque;
|
||||||
|
@ -163,6 +164,7 @@ static int curl_timer_cb(CURLM *multi, long timeout_ms, void *opaque)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Called from curl_multi_do_locked, with s->mutex held. */
|
||||||
static int curl_sock_cb(CURL *curl, curl_socket_t fd, int action,
|
static int curl_sock_cb(CURL *curl, curl_socket_t fd, int action,
|
||||||
void *userp, void *sp)
|
void *userp, void *sp)
|
||||||
{
|
{
|
||||||
|
@ -212,6 +214,7 @@ static int curl_sock_cb(CURL *curl, curl_socket_t fd, int action,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Called from curl_multi_do_locked, with s->mutex held. */
|
||||||
static size_t curl_header_cb(void *ptr, size_t size, size_t nmemb, void *opaque)
|
static size_t curl_header_cb(void *ptr, size_t size, size_t nmemb, void *opaque)
|
||||||
{
|
{
|
||||||
BDRVCURLState *s = opaque;
|
BDRVCURLState *s = opaque;
|
||||||
|
@ -226,6 +229,7 @@ static size_t curl_header_cb(void *ptr, size_t size, size_t nmemb, void *opaque)
|
||||||
return realsize;
|
return realsize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Called from curl_multi_do_locked, with s->mutex held. */
|
||||||
static size_t curl_read_cb(void *ptr, size_t size, size_t nmemb, void *opaque)
|
static size_t curl_read_cb(void *ptr, size_t size, size_t nmemb, void *opaque)
|
||||||
{
|
{
|
||||||
CURLState *s = ((CURLState*)opaque);
|
CURLState *s = ((CURLState*)opaque);
|
||||||
|
@ -264,7 +268,9 @@ static size_t curl_read_cb(void *ptr, size_t size, size_t nmemb, void *opaque)
|
||||||
request_length - offset);
|
request_length - offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
qemu_mutex_unlock(&s->s->mutex);
|
||||||
acb->common.cb(acb->common.opaque, 0);
|
acb->common.cb(acb->common.opaque, 0);
|
||||||
|
qemu_mutex_lock(&s->s->mutex);
|
||||||
qemu_aio_unref(acb);
|
qemu_aio_unref(acb);
|
||||||
s->acb[i] = NULL;
|
s->acb[i] = NULL;
|
||||||
}
|
}
|
||||||
|
@ -275,6 +281,7 @@ read_end:
|
||||||
return size * nmemb;
|
return size * nmemb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Called with s->mutex held. */
|
||||||
static int curl_find_buf(BDRVCURLState *s, size_t start, size_t len,
|
static int curl_find_buf(BDRVCURLState *s, size_t start, size_t len,
|
||||||
CURLAIOCB *acb)
|
CURLAIOCB *acb)
|
||||||
{
|
{
|
||||||
|
@ -305,8 +312,6 @@ static int curl_find_buf(BDRVCURLState *s, size_t start, size_t len,
|
||||||
if (clamped_len < len) {
|
if (clamped_len < len) {
|
||||||
qemu_iovec_memset(acb->qiov, clamped_len, 0, len - clamped_len);
|
qemu_iovec_memset(acb->qiov, clamped_len, 0, len - clamped_len);
|
||||||
}
|
}
|
||||||
acb->common.cb(acb->common.opaque, 0);
|
|
||||||
|
|
||||||
return FIND_RET_OK;
|
return FIND_RET_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -449,6 +454,7 @@ static void curl_multi_timeout_do(void *arg)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Called with s->mutex held. */
|
||||||
static CURLState *curl_init_state(BlockDriverState *bs, BDRVCURLState *s)
|
static CURLState *curl_init_state(BlockDriverState *bs, BDRVCURLState *s)
|
||||||
{
|
{
|
||||||
CURLState *state = NULL;
|
CURLState *state = NULL;
|
||||||
|
@ -467,7 +473,9 @@ static CURLState *curl_init_state(BlockDriverState *bs, BDRVCURLState *s)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!state) {
|
if (!state) {
|
||||||
|
qemu_mutex_unlock(&s->mutex);
|
||||||
aio_poll(bdrv_get_aio_context(bs), true);
|
aio_poll(bdrv_get_aio_context(bs), true);
|
||||||
|
qemu_mutex_lock(&s->mutex);
|
||||||
}
|
}
|
||||||
} while(!state);
|
} while(!state);
|
||||||
|
|
||||||
|
@ -530,8 +538,14 @@ static CURLState *curl_init_state(BlockDriverState *bs, BDRVCURLState *s)
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Called with s->mutex held. */
|
||||||
static void curl_clean_state(CURLState *s)
|
static void curl_clean_state(CURLState *s)
|
||||||
{
|
{
|
||||||
|
int j;
|
||||||
|
for (j = 0; j < CURL_NUM_ACB; j++) {
|
||||||
|
assert(!s->acb[j]);
|
||||||
|
}
|
||||||
|
|
||||||
if (s->s->multi)
|
if (s->s->multi)
|
||||||
curl_multi_remove_handle(s->s->multi, s->curl);
|
curl_multi_remove_handle(s->s->multi, s->curl);
|
||||||
|
|
||||||
|
@ -548,7 +562,7 @@ static void curl_clean_state(CURLState *s)
|
||||||
static void curl_parse_filename(const char *filename, QDict *options,
|
static void curl_parse_filename(const char *filename, QDict *options,
|
||||||
Error **errp)
|
Error **errp)
|
||||||
{
|
{
|
||||||
qdict_put(options, CURL_BLOCK_OPT_URL, qstring_from_str(filename));
|
qdict_put_str(options, CURL_BLOCK_OPT_URL, filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void curl_detach_aio_context(BlockDriverState *bs)
|
static void curl_detach_aio_context(BlockDriverState *bs)
|
||||||
|
@ -556,6 +570,7 @@ static void curl_detach_aio_context(BlockDriverState *bs)
|
||||||
BDRVCURLState *s = bs->opaque;
|
BDRVCURLState *s = bs->opaque;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
qemu_mutex_lock(&s->mutex);
|
||||||
for (i = 0; i < CURL_NUM_STATES; i++) {
|
for (i = 0; i < CURL_NUM_STATES; i++) {
|
||||||
if (s->states[i].in_use) {
|
if (s->states[i].in_use) {
|
||||||
curl_clean_state(&s->states[i]);
|
curl_clean_state(&s->states[i]);
|
||||||
|
@ -571,6 +586,7 @@ static void curl_detach_aio_context(BlockDriverState *bs)
|
||||||
curl_multi_cleanup(s->multi);
|
curl_multi_cleanup(s->multi);
|
||||||
s->multi = NULL;
|
s->multi = NULL;
|
||||||
}
|
}
|
||||||
|
qemu_mutex_unlock(&s->mutex);
|
||||||
|
|
||||||
timer_del(&s->timer);
|
timer_del(&s->timer);
|
||||||
}
|
}
|
||||||
|
@ -668,6 +684,7 @@ static int curl_open(BlockDriverState *bs, QDict *options, int flags,
|
||||||
return -EROFS;
|
return -EROFS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
qemu_mutex_init(&s->mutex);
|
||||||
opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort);
|
opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort);
|
||||||
qemu_opts_absorb_qdict(opts, options, &local_err);
|
qemu_opts_absorb_qdict(opts, options, &local_err);
|
||||||
if (local_err) {
|
if (local_err) {
|
||||||
|
@ -738,7 +755,9 @@ static int curl_open(BlockDriverState *bs, QDict *options, int flags,
|
||||||
DPRINTF("CURL: Opening %s\n", file);
|
DPRINTF("CURL: Opening %s\n", file);
|
||||||
s->aio_context = bdrv_get_aio_context(bs);
|
s->aio_context = bdrv_get_aio_context(bs);
|
||||||
s->url = g_strdup(file);
|
s->url = g_strdup(file);
|
||||||
|
qemu_mutex_lock(&s->mutex);
|
||||||
state = curl_init_state(bs, s);
|
state = curl_init_state(bs, s);
|
||||||
|
qemu_mutex_unlock(&s->mutex);
|
||||||
if (!state)
|
if (!state)
|
||||||
goto out_noclean;
|
goto out_noclean;
|
||||||
|
|
||||||
|
@ -782,11 +801,12 @@ static int curl_open(BlockDriverState *bs, QDict *options, int flags,
|
||||||
}
|
}
|
||||||
DPRINTF("CURL: Size = %zd\n", s->len);
|
DPRINTF("CURL: Size = %zd\n", s->len);
|
||||||
|
|
||||||
|
qemu_mutex_lock(&s->mutex);
|
||||||
curl_clean_state(state);
|
curl_clean_state(state);
|
||||||
|
qemu_mutex_unlock(&s->mutex);
|
||||||
curl_easy_cleanup(state->curl);
|
curl_easy_cleanup(state->curl);
|
||||||
state->curl = NULL;
|
state->curl = NULL;
|
||||||
|
|
||||||
qemu_mutex_init(&s->mutex);
|
|
||||||
curl_attach_aio_context(bs, bdrv_get_aio_context(bs));
|
curl_attach_aio_context(bs, bdrv_get_aio_context(bs));
|
||||||
|
|
||||||
qemu_opts_del(opts);
|
qemu_opts_del(opts);
|
||||||
|
@ -797,6 +817,7 @@ out:
|
||||||
curl_easy_cleanup(state->curl);
|
curl_easy_cleanup(state->curl);
|
||||||
state->curl = NULL;
|
state->curl = NULL;
|
||||||
out_noclean:
|
out_noclean:
|
||||||
|
qemu_mutex_destroy(&s->mutex);
|
||||||
g_free(s->cookie);
|
g_free(s->cookie);
|
||||||
g_free(s->url);
|
g_free(s->url);
|
||||||
qemu_opts_del(opts);
|
qemu_opts_del(opts);
|
||||||
|
@ -827,8 +848,8 @@ static void curl_readv_bh_cb(void *p)
|
||||||
// we can just call the callback and be done.
|
// we can just call the callback and be done.
|
||||||
switch (curl_find_buf(s, start, acb->nb_sectors * BDRV_SECTOR_SIZE, acb)) {
|
switch (curl_find_buf(s, start, acb->nb_sectors * BDRV_SECTOR_SIZE, acb)) {
|
||||||
case FIND_RET_OK:
|
case FIND_RET_OK:
|
||||||
qemu_aio_unref(acb);
|
ret = 0;
|
||||||
// fall through
|
goto out;
|
||||||
case FIND_RET_WAIT:
|
case FIND_RET_WAIT:
|
||||||
goto out;
|
goto out;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -345,7 +345,7 @@ BlockDirtyInfoList *bdrv_query_dirty_bitmaps(BlockDriverState *bs)
|
||||||
QLIST_FOREACH(bm, &bs->dirty_bitmaps, list) {
|
QLIST_FOREACH(bm, &bs->dirty_bitmaps, list) {
|
||||||
BlockDirtyInfo *info = g_new0(BlockDirtyInfo, 1);
|
BlockDirtyInfo *info = g_new0(BlockDirtyInfo, 1);
|
||||||
BlockDirtyInfoList *entry = g_new0(BlockDirtyInfoList, 1);
|
BlockDirtyInfoList *entry = g_new0(BlockDirtyInfoList, 1);
|
||||||
info->count = bdrv_get_dirty_count(bm);
|
info->count = bdrv_get_dirty_count(bm) << BDRV_SECTOR_BITS;
|
||||||
info->granularity = bdrv_dirty_bitmap_granularity(bm);
|
info->granularity = bdrv_dirty_bitmap_granularity(bm);
|
||||||
info->has_name = !!bm->name;
|
info->has_name = !!bm->name;
|
||||||
info->name = g_strdup(bm->name);
|
info->name = g_strdup(bm->name);
|
||||||
|
|
|
@ -377,7 +377,7 @@ static void raw_parse_filename(const char *filename, QDict *options,
|
||||||
* function call can be ignored. */
|
* function call can be ignored. */
|
||||||
strstart(filename, "file:", &filename);
|
strstart(filename, "file:", &filename);
|
||||||
|
|
||||||
qdict_put_obj(options, "filename", QOBJECT(qstring_from_str(filename)));
|
qdict_put_str(options, "filename", filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
static QemuOptsList raw_runtime_opts = {
|
static QemuOptsList raw_runtime_opts = {
|
||||||
|
@ -2150,7 +2150,7 @@ static void hdev_parse_filename(const char *filename, QDict *options,
|
||||||
/* The prefix is optional, just as for "file". */
|
/* The prefix is optional, just as for "file". */
|
||||||
strstart(filename, "host_device:", &filename);
|
strstart(filename, "host_device:", &filename);
|
||||||
|
|
||||||
qdict_put_obj(options, "filename", QOBJECT(qstring_from_str(filename)));
|
qdict_put_str(options, "filename", filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool hdev_is_sg(BlockDriverState *bs)
|
static bool hdev_is_sg(BlockDriverState *bs)
|
||||||
|
@ -2239,7 +2239,7 @@ static int hdev_open(BlockDriverState *bs, QDict *options, int flags,
|
||||||
goto hdev_open_Mac_error;
|
goto hdev_open_Mac_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
qdict_put(options, "filename", qstring_from_str(bsd_path));
|
qdict_put_str(options, "filename", bsd_path);
|
||||||
|
|
||||||
hdev_open_Mac_error:
|
hdev_open_Mac_error:
|
||||||
g_free(mediaType);
|
g_free(mediaType);
|
||||||
|
@ -2449,7 +2449,7 @@ static void cdrom_parse_filename(const char *filename, QDict *options,
|
||||||
/* The prefix is optional, just as for "file". */
|
/* The prefix is optional, just as for "file". */
|
||||||
strstart(filename, "host_cdrom:", &filename);
|
strstart(filename, "host_cdrom:", &filename);
|
||||||
|
|
||||||
qdict_put_obj(options, "filename", QOBJECT(qstring_from_str(filename)));
|
qdict_put_str(options, "filename", filename);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -282,7 +282,7 @@ static void raw_parse_filename(const char *filename, QDict *options,
|
||||||
* function call can be ignored. */
|
* function call can be ignored. */
|
||||||
strstart(filename, "file:", &filename);
|
strstart(filename, "file:", &filename);
|
||||||
|
|
||||||
qdict_put_obj(options, "filename", QOBJECT(qstring_from_str(filename)));
|
qdict_put_str(options, "filename", filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
static QemuOptsList raw_runtime_opts = {
|
static QemuOptsList raw_runtime_opts = {
|
||||||
|
@ -669,7 +669,7 @@ static void hdev_parse_filename(const char *filename, QDict *options,
|
||||||
/* The prefix is optional, just as for "file". */
|
/* The prefix is optional, just as for "file". */
|
||||||
strstart(filename, "host_device:", &filename);
|
strstart(filename, "host_device:", &filename);
|
||||||
|
|
||||||
qdict_put_obj(options, "filename", QOBJECT(qstring_from_str(filename)));
|
qdict_put_str(options, "filename", filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int hdev_open(BlockDriverState *bs, QDict *options, int flags,
|
static int hdev_open(BlockDriverState *bs, QDict *options, int flags,
|
||||||
|
|
|
@ -1757,6 +1757,7 @@ static int64_t coroutine_fn bdrv_co_get_block_status(BlockDriverState *bs,
|
||||||
int64_t n;
|
int64_t n;
|
||||||
int64_t ret, ret2;
|
int64_t ret, ret2;
|
||||||
|
|
||||||
|
*file = NULL;
|
||||||
total_sectors = bdrv_nb_sectors(bs);
|
total_sectors = bdrv_nb_sectors(bs);
|
||||||
if (total_sectors < 0) {
|
if (total_sectors < 0) {
|
||||||
return total_sectors;
|
return total_sectors;
|
||||||
|
@ -1777,11 +1778,11 @@ static int64_t coroutine_fn bdrv_co_get_block_status(BlockDriverState *bs,
|
||||||
ret = BDRV_BLOCK_DATA | BDRV_BLOCK_ALLOCATED;
|
ret = BDRV_BLOCK_DATA | BDRV_BLOCK_ALLOCATED;
|
||||||
if (bs->drv->protocol_name) {
|
if (bs->drv->protocol_name) {
|
||||||
ret |= BDRV_BLOCK_OFFSET_VALID | (sector_num * BDRV_SECTOR_SIZE);
|
ret |= BDRV_BLOCK_OFFSET_VALID | (sector_num * BDRV_SECTOR_SIZE);
|
||||||
|
*file = bs;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
*file = NULL;
|
|
||||||
bdrv_inc_in_flight(bs);
|
bdrv_inc_in_flight(bs);
|
||||||
ret = bs->drv->bdrv_co_get_block_status(bs, sector_num, nb_sectors, pnum,
|
ret = bs->drv->bdrv_co_get_block_status(bs, sector_num, nb_sectors, pnum,
|
||||||
file);
|
file);
|
||||||
|
@ -1791,9 +1792,9 @@ static int64_t coroutine_fn bdrv_co_get_block_status(BlockDriverState *bs,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ret & BDRV_BLOCK_RAW) {
|
if (ret & BDRV_BLOCK_RAW) {
|
||||||
assert(ret & BDRV_BLOCK_OFFSET_VALID);
|
assert(ret & BDRV_BLOCK_OFFSET_VALID && *file);
|
||||||
ret = bdrv_get_block_status(*file, ret >> BDRV_SECTOR_BITS,
|
ret = bdrv_co_get_block_status(*file, ret >> BDRV_SECTOR_BITS,
|
||||||
*pnum, pnum, file);
|
*pnum, pnum, file);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -514,7 +514,12 @@ static void mirror_exit(BlockJob *job, void *opaque)
|
||||||
|
|
||||||
/* Remove target parent that still uses BLK_PERM_WRITE/RESIZE before
|
/* Remove target parent that still uses BLK_PERM_WRITE/RESIZE before
|
||||||
* inserting target_bs at s->to_replace, where we might not be able to get
|
* inserting target_bs at s->to_replace, where we might not be able to get
|
||||||
* these permissions. */
|
* these permissions.
|
||||||
|
*
|
||||||
|
* Note that blk_unref() alone doesn't necessarily drop permissions because
|
||||||
|
* we might be running nested inside mirror_drain(), which takes an extra
|
||||||
|
* reference, so use an explicit blk_set_perm() first. */
|
||||||
|
blk_set_perm(s->target, 0, BLK_PERM_ALL, &error_abort);
|
||||||
blk_unref(s->target);
|
blk_unref(s->target);
|
||||||
s->target = NULL;
|
s->target = NULL;
|
||||||
|
|
||||||
|
@ -724,7 +729,7 @@ static void coroutine_fn mirror_run(void *opaque)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s->bdev_length > base_length) {
|
if (s->bdev_length > base_length) {
|
||||||
ret = blk_truncate(s->target, s->bdev_length);
|
ret = blk_truncate(s->target, s->bdev_length, NULL);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
goto immediate_exit;
|
goto immediate_exit;
|
||||||
}
|
}
|
||||||
|
@ -1147,6 +1152,9 @@ static void mirror_start_job(const char *job_id, BlockDriverState *bs,
|
||||||
if (mirror_top_bs == NULL) {
|
if (mirror_top_bs == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (!filter_node_name) {
|
||||||
|
mirror_top_bs->implicit = true;
|
||||||
|
}
|
||||||
mirror_top_bs->total_sectors = bs->total_sectors;
|
mirror_top_bs->total_sectors = bs->total_sectors;
|
||||||
bdrv_set_aio_context(mirror_top_bs, bdrv_get_aio_context(bs));
|
bdrv_set_aio_context(mirror_top_bs, bdrv_get_aio_context(bs));
|
||||||
|
|
||||||
|
|
|
@ -352,14 +352,14 @@ int nbd_client_co_pdiscard(BlockDriverState *bs, int64_t offset, int count)
|
||||||
void nbd_client_detach_aio_context(BlockDriverState *bs)
|
void nbd_client_detach_aio_context(BlockDriverState *bs)
|
||||||
{
|
{
|
||||||
NBDClientSession *client = nbd_get_client_session(bs);
|
NBDClientSession *client = nbd_get_client_session(bs);
|
||||||
qio_channel_detach_aio_context(QIO_CHANNEL(client->sioc));
|
qio_channel_detach_aio_context(QIO_CHANNEL(client->ioc));
|
||||||
}
|
}
|
||||||
|
|
||||||
void nbd_client_attach_aio_context(BlockDriverState *bs,
|
void nbd_client_attach_aio_context(BlockDriverState *bs,
|
||||||
AioContext *new_context)
|
AioContext *new_context)
|
||||||
{
|
{
|
||||||
NBDClientSession *client = nbd_get_client_session(bs);
|
NBDClientSession *client = nbd_get_client_session(bs);
|
||||||
qio_channel_attach_aio_context(QIO_CHANNEL(client->sioc), new_context);
|
qio_channel_attach_aio_context(QIO_CHANNEL(client->ioc), new_context);
|
||||||
aio_co_schedule(new_context, client->read_reply_co);
|
aio_co_schedule(new_context, client->read_reply_co);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
47
block/nbd.c
47
block/nbd.c
|
@ -65,11 +65,11 @@ static int nbd_parse_uri(const char *filename, QDict *options)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* transport */
|
/* transport */
|
||||||
if (!strcmp(uri->scheme, "nbd")) {
|
if (!g_strcmp0(uri->scheme, "nbd")) {
|
||||||
is_unix = false;
|
is_unix = false;
|
||||||
} else if (!strcmp(uri->scheme, "nbd+tcp")) {
|
} else if (!g_strcmp0(uri->scheme, "nbd+tcp")) {
|
||||||
is_unix = false;
|
is_unix = false;
|
||||||
} else if (!strcmp(uri->scheme, "nbd+unix")) {
|
} else if (!g_strcmp0(uri->scheme, "nbd+unix")) {
|
||||||
is_unix = true;
|
is_unix = true;
|
||||||
} else {
|
} else {
|
||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
|
@ -79,7 +79,7 @@ static int nbd_parse_uri(const char *filename, QDict *options)
|
||||||
p = uri->path ? uri->path : "/";
|
p = uri->path ? uri->path : "/";
|
||||||
p += strspn(p, "/");
|
p += strspn(p, "/");
|
||||||
if (p[0]) {
|
if (p[0]) {
|
||||||
qdict_put(options, "export", qstring_from_str(p));
|
qdict_put_str(options, "export", p);
|
||||||
}
|
}
|
||||||
|
|
||||||
qp = query_params_parse(uri->query);
|
qp = query_params_parse(uri->query);
|
||||||
|
@ -94,9 +94,8 @@ static int nbd_parse_uri(const char *filename, QDict *options)
|
||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
qdict_put(options, "server.type", qstring_from_str("unix"));
|
qdict_put_str(options, "server.type", "unix");
|
||||||
qdict_put(options, "server.path",
|
qdict_put_str(options, "server.path", qp->p[0].value);
|
||||||
qstring_from_str(qp->p[0].value));
|
|
||||||
} else {
|
} else {
|
||||||
QString *host;
|
QString *host;
|
||||||
char *port_str;
|
char *port_str;
|
||||||
|
@ -115,11 +114,11 @@ static int nbd_parse_uri(const char *filename, QDict *options)
|
||||||
host = qstring_from_str(uri->server);
|
host = qstring_from_str(uri->server);
|
||||||
}
|
}
|
||||||
|
|
||||||
qdict_put(options, "server.type", qstring_from_str("inet"));
|
qdict_put_str(options, "server.type", "inet");
|
||||||
qdict_put(options, "server.host", host);
|
qdict_put(options, "server.host", host);
|
||||||
|
|
||||||
port_str = g_strdup_printf("%d", uri->port ?: NBD_DEFAULT_PORT);
|
port_str = g_strdup_printf("%d", uri->port ?: NBD_DEFAULT_PORT);
|
||||||
qdict_put(options, "server.port", qstring_from_str(port_str));
|
qdict_put_str(options, "server.port", port_str);
|
||||||
g_free(port_str);
|
g_free(port_str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -181,7 +180,7 @@ static void nbd_parse_filename(const char *filename, QDict *options,
|
||||||
export_name[0] = 0; /* truncate 'file' */
|
export_name[0] = 0; /* truncate 'file' */
|
||||||
export_name += strlen(EN_OPTSTR);
|
export_name += strlen(EN_OPTSTR);
|
||||||
|
|
||||||
qdict_put(options, "export", qstring_from_str(export_name));
|
qdict_put_str(options, "export", export_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* extract the host_spec - fail if it's not nbd:... */
|
/* extract the host_spec - fail if it's not nbd:... */
|
||||||
|
@ -196,8 +195,8 @@ static void nbd_parse_filename(const char *filename, QDict *options,
|
||||||
|
|
||||||
/* are we a UNIX or TCP socket? */
|
/* are we a UNIX or TCP socket? */
|
||||||
if (strstart(host_spec, "unix:", &unixpath)) {
|
if (strstart(host_spec, "unix:", &unixpath)) {
|
||||||
qdict_put(options, "server.type", qstring_from_str("unix"));
|
qdict_put_str(options, "server.type", "unix");
|
||||||
qdict_put(options, "server.path", qstring_from_str(unixpath));
|
qdict_put_str(options, "server.path", unixpath);
|
||||||
} else {
|
} else {
|
||||||
InetSocketAddress *addr = NULL;
|
InetSocketAddress *addr = NULL;
|
||||||
|
|
||||||
|
@ -206,9 +205,9 @@ static void nbd_parse_filename(const char *filename, QDict *options,
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
qdict_put(options, "server.type", qstring_from_str("inet"));
|
qdict_put_str(options, "server.type", "inet");
|
||||||
qdict_put(options, "server.host", qstring_from_str(addr->host));
|
qdict_put_str(options, "server.host", addr->host);
|
||||||
qdict_put(options, "server.port", qstring_from_str(addr->port));
|
qdict_put_str(options, "server.port", addr->port);
|
||||||
qapi_free_InetSocketAddress(addr);
|
qapi_free_InetSocketAddress(addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -247,13 +246,13 @@ static bool nbd_process_legacy_socket_options(QDict *output_options,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
qdict_put(output_options, "server.type", qstring_from_str("unix"));
|
qdict_put_str(output_options, "server.type", "unix");
|
||||||
qdict_put(output_options, "server.path", qstring_from_str(path));
|
qdict_put_str(output_options, "server.path", path);
|
||||||
} else if (host) {
|
} else if (host) {
|
||||||
qdict_put(output_options, "server.type", qstring_from_str("inet"));
|
qdict_put_str(output_options, "server.type", "inet");
|
||||||
qdict_put(output_options, "server.host", qstring_from_str(host));
|
qdict_put_str(output_options, "server.host", host);
|
||||||
qdict_put(output_options, "server.port",
|
qdict_put_str(output_options, "server.port",
|
||||||
qstring_from_str(port ?: stringify(NBD_DEFAULT_PORT)));
|
port ?: stringify(NBD_DEFAULT_PORT));
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -528,7 +527,7 @@ static void nbd_refresh_filename(BlockDriverState *bs, QDict *options)
|
||||||
path = s->saddr->u.q_unix.path;
|
path = s->saddr->u.q_unix.path;
|
||||||
} /* else can't represent as pseudo-filename */
|
} /* else can't represent as pseudo-filename */
|
||||||
|
|
||||||
qdict_put(opts, "driver", qstring_from_str("nbd"));
|
qdict_put_str(opts, "driver", "nbd");
|
||||||
|
|
||||||
if (path && s->export) {
|
if (path && s->export) {
|
||||||
snprintf(bs->exact_filename, sizeof(bs->exact_filename),
|
snprintf(bs->exact_filename, sizeof(bs->exact_filename),
|
||||||
|
@ -551,10 +550,10 @@ static void nbd_refresh_filename(BlockDriverState *bs, QDict *options)
|
||||||
qdict_put_obj(opts, "server", saddr_qdict);
|
qdict_put_obj(opts, "server", saddr_qdict);
|
||||||
|
|
||||||
if (s->export) {
|
if (s->export) {
|
||||||
qdict_put(opts, "export", qstring_from_str(s->export));
|
qdict_put_str(opts, "export", s->export);
|
||||||
}
|
}
|
||||||
if (s->tlscredsid) {
|
if (s->tlscredsid) {
|
||||||
qdict_put(opts, "tls-creds", qstring_from_str(s->tlscredsid));
|
qdict_put_str(opts, "tls-creds", s->tlscredsid);
|
||||||
}
|
}
|
||||||
|
|
||||||
qdict_flatten(opts);
|
qdict_flatten(opts);
|
||||||
|
|
56
block/nfs.c
56
block/nfs.c
|
@ -83,7 +83,7 @@ static int nfs_parse_uri(const char *filename, QDict *options, Error **errp)
|
||||||
error_setg(errp, "Invalid URI specified");
|
error_setg(errp, "Invalid URI specified");
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
if (strcmp(uri->scheme, "nfs") != 0) {
|
if (g_strcmp0(uri->scheme, "nfs") != 0) {
|
||||||
error_setg(errp, "URI scheme must be 'nfs'");
|
error_setg(errp, "URI scheme must be 'nfs'");
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
@ -104,9 +104,9 @@ static int nfs_parse_uri(const char *filename, QDict *options, Error **errp)
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
qdict_put(options, "server.host", qstring_from_str(uri->server));
|
qdict_put_str(options, "server.host", uri->server);
|
||||||
qdict_put(options, "server.type", qstring_from_str("inet"));
|
qdict_put_str(options, "server.type", "inet");
|
||||||
qdict_put(options, "path", qstring_from_str(uri->path));
|
qdict_put_str(options, "path", uri->path);
|
||||||
|
|
||||||
for (i = 0; i < qp->n; i++) {
|
for (i = 0; i < qp->n; i++) {
|
||||||
unsigned long long val;
|
unsigned long long val;
|
||||||
|
@ -121,23 +121,17 @@ static int nfs_parse_uri(const char *filename, QDict *options, Error **errp)
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
if (!strcmp(qp->p[i].name, "uid")) {
|
if (!strcmp(qp->p[i].name, "uid")) {
|
||||||
qdict_put(options, "user",
|
qdict_put_str(options, "user", qp->p[i].value);
|
||||||
qstring_from_str(qp->p[i].value));
|
|
||||||
} else if (!strcmp(qp->p[i].name, "gid")) {
|
} else if (!strcmp(qp->p[i].name, "gid")) {
|
||||||
qdict_put(options, "group",
|
qdict_put_str(options, "group", qp->p[i].value);
|
||||||
qstring_from_str(qp->p[i].value));
|
|
||||||
} else if (!strcmp(qp->p[i].name, "tcp-syncnt")) {
|
} else if (!strcmp(qp->p[i].name, "tcp-syncnt")) {
|
||||||
qdict_put(options, "tcp-syn-count",
|
qdict_put_str(options, "tcp-syn-count", qp->p[i].value);
|
||||||
qstring_from_str(qp->p[i].value));
|
|
||||||
} else if (!strcmp(qp->p[i].name, "readahead")) {
|
} else if (!strcmp(qp->p[i].name, "readahead")) {
|
||||||
qdict_put(options, "readahead-size",
|
qdict_put_str(options, "readahead-size", qp->p[i].value);
|
||||||
qstring_from_str(qp->p[i].value));
|
|
||||||
} else if (!strcmp(qp->p[i].name, "pagecache")) {
|
} else if (!strcmp(qp->p[i].name, "pagecache")) {
|
||||||
qdict_put(options, "page-cache-size",
|
qdict_put_str(options, "page-cache-size", qp->p[i].value);
|
||||||
qstring_from_str(qp->p[i].value));
|
|
||||||
} else if (!strcmp(qp->p[i].name, "debug")) {
|
} else if (!strcmp(qp->p[i].name, "debug")) {
|
||||||
qdict_put(options, "debug",
|
qdict_put_str(options, "debug", qp->p[i].value);
|
||||||
qstring_from_str(qp->p[i].value));
|
|
||||||
} else {
|
} else {
|
||||||
error_setg(errp, "Unknown NFS parameter name: %s",
|
error_setg(errp, "Unknown NFS parameter name: %s",
|
||||||
qp->p[i].name);
|
qp->p[i].name);
|
||||||
|
@ -440,19 +434,23 @@ static void nfs_client_close(NFSClient *client)
|
||||||
if (client->context) {
|
if (client->context) {
|
||||||
if (client->fh) {
|
if (client->fh) {
|
||||||
nfs_close(client->context, client->fh);
|
nfs_close(client->context, client->fh);
|
||||||
|
client->fh = NULL;
|
||||||
}
|
}
|
||||||
aio_set_fd_handler(client->aio_context, nfs_get_fd(client->context),
|
aio_set_fd_handler(client->aio_context, nfs_get_fd(client->context),
|
||||||
false, NULL, NULL, NULL, NULL);
|
false, NULL, NULL, NULL, NULL);
|
||||||
nfs_destroy_context(client->context);
|
nfs_destroy_context(client->context);
|
||||||
|
client->context = NULL;
|
||||||
}
|
}
|
||||||
memset(client, 0, sizeof(NFSClient));
|
g_free(client->path);
|
||||||
|
qemu_mutex_destroy(&client->mutex);
|
||||||
|
qapi_free_NFSServer(client->server);
|
||||||
|
client->server = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void nfs_file_close(BlockDriverState *bs)
|
static void nfs_file_close(BlockDriverState *bs)
|
||||||
{
|
{
|
||||||
NFSClient *client = bs->opaque;
|
NFSClient *client = bs->opaque;
|
||||||
nfs_client_close(client);
|
nfs_client_close(client);
|
||||||
qemu_mutex_destroy(&client->mutex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static NFSServer *nfs_config(QDict *options, Error **errp)
|
static NFSServer *nfs_config(QDict *options, Error **errp)
|
||||||
|
@ -505,6 +503,7 @@ static int64_t nfs_client_open(NFSClient *client, QDict *options,
|
||||||
struct stat st;
|
struct stat st;
|
||||||
char *file = NULL, *strp = NULL;
|
char *file = NULL, *strp = NULL;
|
||||||
|
|
||||||
|
qemu_mutex_init(&client->mutex);
|
||||||
opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort);
|
opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort);
|
||||||
qemu_opts_absorb_qdict(opts, options, &local_err);
|
qemu_opts_absorb_qdict(opts, options, &local_err);
|
||||||
if (local_err) {
|
if (local_err) {
|
||||||
|
@ -667,7 +666,7 @@ static int nfs_file_open(BlockDriverState *bs, QDict *options, int flags,
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
qemu_mutex_init(&client->mutex);
|
|
||||||
bs->total_sectors = ret;
|
bs->total_sectors = ret;
|
||||||
ret = 0;
|
ret = 0;
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -811,7 +810,7 @@ static void nfs_refresh_filename(BlockDriverState *bs, QDict *options)
|
||||||
QObject *server_qdict;
|
QObject *server_qdict;
|
||||||
Visitor *ov;
|
Visitor *ov;
|
||||||
|
|
||||||
qdict_put(opts, "driver", qstring_from_str("nfs"));
|
qdict_put_str(opts, "driver", "nfs");
|
||||||
|
|
||||||
if (client->uid && !client->gid) {
|
if (client->uid && !client->gid) {
|
||||||
snprintf(bs->exact_filename, sizeof(bs->exact_filename),
|
snprintf(bs->exact_filename, sizeof(bs->exact_filename),
|
||||||
|
@ -834,28 +833,25 @@ static void nfs_refresh_filename(BlockDriverState *bs, QDict *options)
|
||||||
visit_type_NFSServer(ov, NULL, &client->server, &error_abort);
|
visit_type_NFSServer(ov, NULL, &client->server, &error_abort);
|
||||||
visit_complete(ov, &server_qdict);
|
visit_complete(ov, &server_qdict);
|
||||||
qdict_put_obj(opts, "server", server_qdict);
|
qdict_put_obj(opts, "server", server_qdict);
|
||||||
qdict_put(opts, "path", qstring_from_str(client->path));
|
qdict_put_str(opts, "path", client->path);
|
||||||
|
|
||||||
if (client->uid) {
|
if (client->uid) {
|
||||||
qdict_put(opts, "user", qint_from_int(client->uid));
|
qdict_put_int(opts, "user", client->uid);
|
||||||
}
|
}
|
||||||
if (client->gid) {
|
if (client->gid) {
|
||||||
qdict_put(opts, "group", qint_from_int(client->gid));
|
qdict_put_int(opts, "group", client->gid);
|
||||||
}
|
}
|
||||||
if (client->tcp_syncnt) {
|
if (client->tcp_syncnt) {
|
||||||
qdict_put(opts, "tcp-syn-cnt",
|
qdict_put_int(opts, "tcp-syn-cnt", client->tcp_syncnt);
|
||||||
qint_from_int(client->tcp_syncnt));
|
|
||||||
}
|
}
|
||||||
if (client->readahead) {
|
if (client->readahead) {
|
||||||
qdict_put(opts, "readahead-size",
|
qdict_put_int(opts, "readahead-size", client->readahead);
|
||||||
qint_from_int(client->readahead));
|
|
||||||
}
|
}
|
||||||
if (client->pagecache) {
|
if (client->pagecache) {
|
||||||
qdict_put(opts, "page-cache-size",
|
qdict_put_int(opts, "page-cache-size", client->pagecache);
|
||||||
qint_from_int(client->pagecache));
|
|
||||||
}
|
}
|
||||||
if (client->debug) {
|
if (client->debug) {
|
||||||
qdict_put(opts, "debug", qint_from_int(client->debug));
|
qdict_put_int(opts, "debug", client->debug);
|
||||||
}
|
}
|
||||||
|
|
||||||
visit_free(ov);
|
visit_free(ov);
|
||||||
|
|
|
@ -232,7 +232,7 @@ static void null_refresh_filename(BlockDriverState *bs, QDict *opts)
|
||||||
bs->drv->format_name);
|
bs->drv->format_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
qdict_put(opts, "driver", qstring_from_str(bs->drv->format_name));
|
qdict_put_str(opts, "driver", bs->drv->format_name);
|
||||||
bs->full_open_options = opts;
|
bs->full_open_options = opts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -223,7 +223,8 @@ static int64_t allocate_clusters(BlockDriverState *bs, int64_t sector_num,
|
||||||
space << BDRV_SECTOR_BITS, 0);
|
space << BDRV_SECTOR_BITS, 0);
|
||||||
} else {
|
} else {
|
||||||
ret = bdrv_truncate(bs->file,
|
ret = bdrv_truncate(bs->file,
|
||||||
(s->data_end + space) << BDRV_SECTOR_BITS);
|
(s->data_end + space) << BDRV_SECTOR_BITS,
|
||||||
|
NULL);
|
||||||
}
|
}
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -456,8 +457,10 @@ static int parallels_check(BlockDriverState *bs, BdrvCheckResult *res,
|
||||||
size - res->image_end_offset);
|
size - res->image_end_offset);
|
||||||
res->leaks += count;
|
res->leaks += count;
|
||||||
if (fix & BDRV_FIX_LEAKS) {
|
if (fix & BDRV_FIX_LEAKS) {
|
||||||
ret = bdrv_truncate(bs->file, res->image_end_offset);
|
Error *local_err = NULL;
|
||||||
|
ret = bdrv_truncate(bs->file, res->image_end_offset, &local_err);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
|
error_report_err(local_err);
|
||||||
res->check_errors++;
|
res->check_errors++;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -504,7 +507,7 @@ static int parallels_create(const char *filename, QemuOpts *opts, Error **errp)
|
||||||
|
|
||||||
blk_set_allow_write_beyond_eof(file, true);
|
blk_set_allow_write_beyond_eof(file, true);
|
||||||
|
|
||||||
ret = blk_truncate(file, 0);
|
ret = blk_truncate(file, 0, errp);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
@ -696,7 +699,7 @@ static int parallels_open(BlockDriverState *bs, QDict *options, int flags,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(flags & BDRV_O_RESIZE) || !bdrv_has_zero_init(bs->file->bs) ||
|
if (!(flags & BDRV_O_RESIZE) || !bdrv_has_zero_init(bs->file->bs) ||
|
||||||
bdrv_truncate(bs->file, bdrv_getlength(bs->file->bs)) != 0) {
|
bdrv_truncate(bs->file, bdrv_getlength(bs->file->bs), NULL) != 0) {
|
||||||
s->prealloc_mode = PRL_PREALLOC_MODE_FALLOCATE;
|
s->prealloc_mode = PRL_PREALLOC_MODE_FALLOCATE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -739,7 +742,7 @@ static void parallels_close(BlockDriverState *bs)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bs->open_flags & BDRV_O_RDWR) {
|
if (bs->open_flags & BDRV_O_RDWR) {
|
||||||
bdrv_truncate(bs->file, s->data_end << BDRV_SECTOR_BITS);
|
bdrv_truncate(bs->file, s->data_end << BDRV_SECTOR_BITS, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_free(s->bat_dirty_bmap);
|
g_free(s->bat_dirty_bmap);
|
||||||
|
|
34
block/qapi.c
34
block/qapi.c
|
@ -64,7 +64,6 @@ BlockDeviceInfo *bdrv_block_device_info(BlockBackend *blk,
|
||||||
info->backing_file = g_strdup(bs->backing_file);
|
info->backing_file = g_strdup(bs->backing_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
info->backing_file_depth = bdrv_get_backing_file_depth(bs);
|
|
||||||
info->detect_zeroes = bs->detect_zeroes;
|
info->detect_zeroes = bs->detect_zeroes;
|
||||||
|
|
||||||
if (blk && blk_get_public(blk)->throttle_state) {
|
if (blk && blk_get_public(blk)->throttle_state) {
|
||||||
|
@ -125,6 +124,7 @@ BlockDeviceInfo *bdrv_block_device_info(BlockBackend *blk,
|
||||||
|
|
||||||
bs0 = bs;
|
bs0 = bs;
|
||||||
p_image_info = &info->image;
|
p_image_info = &info->image;
|
||||||
|
info->backing_file_depth = 0;
|
||||||
while (1) {
|
while (1) {
|
||||||
Error *local_err = NULL;
|
Error *local_err = NULL;
|
||||||
bdrv_query_image_info(bs0, p_image_info, &local_err);
|
bdrv_query_image_info(bs0, p_image_info, &local_err);
|
||||||
|
@ -133,13 +133,21 @@ BlockDeviceInfo *bdrv_block_device_info(BlockBackend *blk,
|
||||||
qapi_free_BlockDeviceInfo(info);
|
qapi_free_BlockDeviceInfo(info);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bs0->drv && bs0->backing) {
|
if (bs0->drv && bs0->backing) {
|
||||||
|
info->backing_file_depth++;
|
||||||
bs0 = bs0->backing->bs;
|
bs0 = bs0->backing->bs;
|
||||||
(*p_image_info)->has_backing_image = true;
|
(*p_image_info)->has_backing_image = true;
|
||||||
p_image_info = &((*p_image_info)->backing_image);
|
p_image_info = &((*p_image_info)->backing_image);
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Skip automatically inserted nodes that the user isn't aware of for
|
||||||
|
* query-block (blk != NULL), but not for query-named-block-nodes */
|
||||||
|
while (blk && bs0 && bs0->drv && bs0->implicit) {
|
||||||
|
bs0 = backing_bs(bs0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return info;
|
return info;
|
||||||
|
@ -322,6 +330,12 @@ static void bdrv_query_info(BlockBackend *blk, BlockInfo **p_info,
|
||||||
{
|
{
|
||||||
BlockInfo *info = g_malloc0(sizeof(*info));
|
BlockInfo *info = g_malloc0(sizeof(*info));
|
||||||
BlockDriverState *bs = blk_bs(blk);
|
BlockDriverState *bs = blk_bs(blk);
|
||||||
|
|
||||||
|
/* Skip automatically inserted nodes that the user isn't aware of */
|
||||||
|
while (bs && bs->drv && bs->implicit) {
|
||||||
|
bs = backing_bs(bs);
|
||||||
|
}
|
||||||
|
|
||||||
info->device = g_strdup(blk_name(blk));
|
info->device = g_strdup(blk_name(blk));
|
||||||
info->type = g_strdup("unknown");
|
info->type = g_strdup("unknown");
|
||||||
info->locked = blk_dev_is_medium_locked(blk);
|
info->locked = blk_dev_is_medium_locked(blk);
|
||||||
|
@ -424,8 +438,8 @@ static void bdrv_query_blk_stats(BlockDeviceStats *ds, BlockBackend *blk)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static BlockStats *bdrv_query_bds_stats(const BlockDriverState *bs,
|
static BlockStats *bdrv_query_bds_stats(BlockDriverState *bs,
|
||||||
bool query_backing)
|
bool blk_level)
|
||||||
{
|
{
|
||||||
BlockStats *s = NULL;
|
BlockStats *s = NULL;
|
||||||
|
|
||||||
|
@ -436,6 +450,14 @@ static BlockStats *bdrv_query_bds_stats(const BlockDriverState *bs,
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Skip automatically inserted nodes that the user isn't aware of in
|
||||||
|
* a BlockBackend-level command. Stay at the exact node for a node-level
|
||||||
|
* command. */
|
||||||
|
while (blk_level && bs->drv && bs->implicit) {
|
||||||
|
bs = backing_bs(bs);
|
||||||
|
assert(bs);
|
||||||
|
}
|
||||||
|
|
||||||
if (bdrv_get_node_name(bs)[0]) {
|
if (bdrv_get_node_name(bs)[0]) {
|
||||||
s->has_node_name = true;
|
s->has_node_name = true;
|
||||||
s->node_name = g_strdup(bdrv_get_node_name(bs));
|
s->node_name = g_strdup(bdrv_get_node_name(bs));
|
||||||
|
@ -445,12 +467,12 @@ static BlockStats *bdrv_query_bds_stats(const BlockDriverState *bs,
|
||||||
|
|
||||||
if (bs->file) {
|
if (bs->file) {
|
||||||
s->has_parent = true;
|
s->has_parent = true;
|
||||||
s->parent = bdrv_query_bds_stats(bs->file->bs, query_backing);
|
s->parent = bdrv_query_bds_stats(bs->file->bs, blk_level);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (query_backing && bs->backing) {
|
if (blk_level && bs->backing) {
|
||||||
s->has_backing = true;
|
s->has_backing = true;
|
||||||
s->backing = bdrv_query_bds_stats(bs->backing->bs, query_backing);
|
s->backing = bdrv_query_bds_stats(bs->backing->bs, blk_level);
|
||||||
}
|
}
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
|
|
|
@ -473,7 +473,7 @@ static uint64_t get_cluster_offset(BlockDriverState *bs,
|
||||||
/* round to cluster size */
|
/* round to cluster size */
|
||||||
cluster_offset = (cluster_offset + s->cluster_size - 1) &
|
cluster_offset = (cluster_offset + s->cluster_size - 1) &
|
||||||
~(s->cluster_size - 1);
|
~(s->cluster_size - 1);
|
||||||
bdrv_truncate(bs->file, cluster_offset + s->cluster_size);
|
bdrv_truncate(bs->file, cluster_offset + s->cluster_size, NULL);
|
||||||
/* if encrypted, we must initialize the cluster
|
/* if encrypted, we must initialize the cluster
|
||||||
content which won't be written */
|
content which won't be written */
|
||||||
if (bs->encrypted &&
|
if (bs->encrypted &&
|
||||||
|
@ -833,7 +833,7 @@ static int qcow_create(const char *filename, QemuOpts *opts, Error **errp)
|
||||||
|
|
||||||
blk_set_allow_write_beyond_eof(qcow_blk, true);
|
blk_set_allow_write_beyond_eof(qcow_blk, true);
|
||||||
|
|
||||||
ret = blk_truncate(qcow_blk, 0);
|
ret = blk_truncate(qcow_blk, 0, errp);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
@ -916,7 +916,7 @@ static int qcow_make_empty(BlockDriverState *bs)
|
||||||
if (bdrv_pwrite_sync(bs->file, s->l1_table_offset, s->l1_table,
|
if (bdrv_pwrite_sync(bs->file, s->l1_table_offset, s->l1_table,
|
||||||
l1_length) < 0)
|
l1_length) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
ret = bdrv_truncate(bs->file, s->l1_table_offset + l1_length);
|
ret = bdrv_truncate(bs->file, s->l1_table_offset + l1_length, NULL);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
|
|
@ -1728,14 +1728,17 @@ static int check_refblocks(BlockDriverState *bs, BdrvCheckResult *res,
|
||||||
|
|
||||||
if (fix & BDRV_FIX_ERRORS) {
|
if (fix & BDRV_FIX_ERRORS) {
|
||||||
int64_t new_nb_clusters;
|
int64_t new_nb_clusters;
|
||||||
|
Error *local_err = NULL;
|
||||||
|
|
||||||
if (offset > INT64_MAX - s->cluster_size) {
|
if (offset > INT64_MAX - s->cluster_size) {
|
||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
goto resize_fail;
|
goto resize_fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = bdrv_truncate(bs->file, offset + s->cluster_size);
|
ret = bdrv_truncate(bs->file, offset + s->cluster_size,
|
||||||
|
&local_err);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
|
error_report_err(local_err);
|
||||||
goto resize_fail;
|
goto resize_fail;
|
||||||
}
|
}
|
||||||
size = bdrv_getlength(bs->file->bs);
|
size = bdrv_getlength(bs->file->bs);
|
||||||
|
|
|
@ -2265,7 +2265,7 @@ static int qcow2_create2(const char *filename, int64_t total_size,
|
||||||
* table)
|
* table)
|
||||||
*/
|
*/
|
||||||
options = qdict_new();
|
options = qdict_new();
|
||||||
qdict_put(options, "driver", qstring_from_str("qcow2"));
|
qdict_put_str(options, "driver", "qcow2");
|
||||||
blk = blk_new_open(filename, NULL, options,
|
blk = blk_new_open(filename, NULL, options,
|
||||||
BDRV_O_RDWR | BDRV_O_RESIZE | BDRV_O_NO_FLUSH,
|
BDRV_O_RDWR | BDRV_O_RESIZE | BDRV_O_NO_FLUSH,
|
||||||
&local_err);
|
&local_err);
|
||||||
|
@ -2294,9 +2294,9 @@ static int qcow2_create2(const char *filename, int64_t total_size,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Okay, now that we have a valid image, let's give it the right size */
|
/* Okay, now that we have a valid image, let's give it the right size */
|
||||||
ret = blk_truncate(blk, total_size);
|
ret = blk_truncate(blk, total_size, errp);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
error_setg_errno(errp, -ret, "Could not resize image");
|
error_prepend(errp, "Could not resize image: ");
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2327,7 +2327,7 @@ static int qcow2_create2(const char *filename, int64_t total_size,
|
||||||
|
|
||||||
/* Reopen the image without BDRV_O_NO_FLUSH to flush it before returning */
|
/* Reopen the image without BDRV_O_NO_FLUSH to flush it before returning */
|
||||||
options = qdict_new();
|
options = qdict_new();
|
||||||
qdict_put(options, "driver", qstring_from_str("qcow2"));
|
qdict_put_str(options, "driver", "qcow2");
|
||||||
blk = blk_new_open(filename, NULL, options,
|
blk = blk_new_open(filename, NULL, options,
|
||||||
BDRV_O_RDWR | BDRV_O_NO_BACKING, &local_err);
|
BDRV_O_RDWR | BDRV_O_NO_BACKING, &local_err);
|
||||||
if (blk == NULL) {
|
if (blk == NULL) {
|
||||||
|
@ -2584,7 +2584,7 @@ qcow2_co_pwritev_compressed(BlockDriverState *bs, uint64_t offset,
|
||||||
/* align end of file to a sector boundary to ease reading with
|
/* align end of file to a sector boundary to ease reading with
|
||||||
sector based I/Os */
|
sector based I/Os */
|
||||||
cluster_offset = bdrv_getlength(bs->file->bs);
|
cluster_offset = bdrv_getlength(bs->file->bs);
|
||||||
return bdrv_truncate(bs->file, cluster_offset);
|
return bdrv_truncate(bs->file, cluster_offset, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
buf = qemu_blockalign(bs, s->cluster_size);
|
buf = qemu_blockalign(bs, s->cluster_size);
|
||||||
|
@ -2674,6 +2674,7 @@ fail:
|
||||||
static int make_completely_empty(BlockDriverState *bs)
|
static int make_completely_empty(BlockDriverState *bs)
|
||||||
{
|
{
|
||||||
BDRVQcow2State *s = bs->opaque;
|
BDRVQcow2State *s = bs->opaque;
|
||||||
|
Error *local_err = NULL;
|
||||||
int ret, l1_clusters;
|
int ret, l1_clusters;
|
||||||
int64_t offset;
|
int64_t offset;
|
||||||
uint64_t *new_reftable = NULL;
|
uint64_t *new_reftable = NULL;
|
||||||
|
@ -2798,8 +2799,10 @@ static int make_completely_empty(BlockDriverState *bs)
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = bdrv_truncate(bs->file, (3 + l1_clusters) * s->cluster_size);
|
ret = bdrv_truncate(bs->file, (3 + l1_clusters) * s->cluster_size,
|
||||||
|
&local_err);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
|
error_report_err(local_err);
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3273,9 +3276,10 @@ static int qcow2_amend_options(BlockDriverState *bs, QemuOpts *opts,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = blk_truncate(blk, new_size);
|
ret = blk_truncate(blk, new_size, &local_err);
|
||||||
blk_unref(blk);
|
blk_unref(blk);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
|
error_report_err(local_err);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -635,7 +635,7 @@ static int qed_create(const char *filename, uint32_t cluster_size,
|
||||||
blk_set_allow_write_beyond_eof(blk, true);
|
blk_set_allow_write_beyond_eof(blk, true);
|
||||||
|
|
||||||
/* File must start empty and grow, check truncate is supported */
|
/* File must start empty and grow, check truncate is supported */
|
||||||
ret = blk_truncate(blk, 0);
|
ret = blk_truncate(blk, 0, errp);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1096,19 +1096,15 @@ static void quorum_refresh_filename(BlockDriverState *bs, QDict *options)
|
||||||
children = qlist_new();
|
children = qlist_new();
|
||||||
for (i = 0; i < s->num_children; i++) {
|
for (i = 0; i < s->num_children; i++) {
|
||||||
QINCREF(s->children[i]->bs->full_open_options);
|
QINCREF(s->children[i]->bs->full_open_options);
|
||||||
qlist_append_obj(children,
|
qlist_append(children, s->children[i]->bs->full_open_options);
|
||||||
QOBJECT(s->children[i]->bs->full_open_options));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
opts = qdict_new();
|
opts = qdict_new();
|
||||||
qdict_put_obj(opts, "driver", QOBJECT(qstring_from_str("quorum")));
|
qdict_put_str(opts, "driver", "quorum");
|
||||||
qdict_put_obj(opts, QUORUM_OPT_VOTE_THRESHOLD,
|
qdict_put_int(opts, QUORUM_OPT_VOTE_THRESHOLD, s->threshold);
|
||||||
QOBJECT(qint_from_int(s->threshold)));
|
qdict_put_bool(opts, QUORUM_OPT_BLKVERIFY, s->is_blkverify);
|
||||||
qdict_put_obj(opts, QUORUM_OPT_BLKVERIFY,
|
qdict_put_bool(opts, QUORUM_OPT_REWRITE, s->rewrite_corrupted);
|
||||||
QOBJECT(qbool_from_bool(s->is_blkverify)));
|
qdict_put(opts, "children", children);
|
||||||
qdict_put_obj(opts, QUORUM_OPT_REWRITE,
|
|
||||||
QOBJECT(qbool_from_bool(s->rewrite_corrupted)));
|
|
||||||
qdict_put_obj(opts, "children", QOBJECT(children));
|
|
||||||
|
|
||||||
bs->full_open_options = opts;
|
bs->full_open_options = opts;
|
||||||
}
|
}
|
||||||
|
|
|
@ -341,7 +341,7 @@ static int raw_truncate(BlockDriverState *bs, int64_t offset)
|
||||||
|
|
||||||
s->size = offset;
|
s->size = offset;
|
||||||
offset += s->offset;
|
offset += s->offset;
|
||||||
return bdrv_truncate(bs->file, offset);
|
return bdrv_truncate(bs->file, offset, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int raw_media_changed(BlockDriverState *bs)
|
static int raw_media_changed(BlockDriverState *bs)
|
||||||
|
|
16
block/rbd.c
16
block/rbd.c
|
@ -154,20 +154,20 @@ static void qemu_rbd_parse_filename(const char *filename, QDict *options,
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
qemu_rbd_unescape(found_str);
|
qemu_rbd_unescape(found_str);
|
||||||
qdict_put(options, "pool", qstring_from_str(found_str));
|
qdict_put_str(options, "pool", found_str);
|
||||||
|
|
||||||
if (strchr(p, '@')) {
|
if (strchr(p, '@')) {
|
||||||
found_str = qemu_rbd_next_tok(p, '@', &p);
|
found_str = qemu_rbd_next_tok(p, '@', &p);
|
||||||
qemu_rbd_unescape(found_str);
|
qemu_rbd_unescape(found_str);
|
||||||
qdict_put(options, "image", qstring_from_str(found_str));
|
qdict_put_str(options, "image", found_str);
|
||||||
|
|
||||||
found_str = qemu_rbd_next_tok(p, ':', &p);
|
found_str = qemu_rbd_next_tok(p, ':', &p);
|
||||||
qemu_rbd_unescape(found_str);
|
qemu_rbd_unescape(found_str);
|
||||||
qdict_put(options, "snapshot", qstring_from_str(found_str));
|
qdict_put_str(options, "snapshot", found_str);
|
||||||
} else {
|
} else {
|
||||||
found_str = qemu_rbd_next_tok(p, ':', &p);
|
found_str = qemu_rbd_next_tok(p, ':', &p);
|
||||||
qemu_rbd_unescape(found_str);
|
qemu_rbd_unescape(found_str);
|
||||||
qdict_put(options, "image", qstring_from_str(found_str));
|
qdict_put_str(options, "image", found_str);
|
||||||
}
|
}
|
||||||
if (!p) {
|
if (!p) {
|
||||||
goto done;
|
goto done;
|
||||||
|
@ -189,9 +189,9 @@ static void qemu_rbd_parse_filename(const char *filename, QDict *options,
|
||||||
qemu_rbd_unescape(value);
|
qemu_rbd_unescape(value);
|
||||||
|
|
||||||
if (!strcmp(name, "conf")) {
|
if (!strcmp(name, "conf")) {
|
||||||
qdict_put(options, "conf", qstring_from_str(value));
|
qdict_put_str(options, "conf", value);
|
||||||
} else if (!strcmp(name, "id")) {
|
} else if (!strcmp(name, "id")) {
|
||||||
qdict_put(options, "user" , qstring_from_str(value));
|
qdict_put_str(options, "user", value);
|
||||||
} else {
|
} else {
|
||||||
/*
|
/*
|
||||||
* We pass these internally to qemu_rbd_set_keypairs(), so
|
* We pass these internally to qemu_rbd_set_keypairs(), so
|
||||||
|
@ -204,8 +204,8 @@ static void qemu_rbd_parse_filename(const char *filename, QDict *options,
|
||||||
if (!keypairs) {
|
if (!keypairs) {
|
||||||
keypairs = qlist_new();
|
keypairs = qlist_new();
|
||||||
}
|
}
|
||||||
qlist_append(keypairs, qstring_from_str(name));
|
qlist_append_str(keypairs, name);
|
||||||
qlist_append(keypairs, qstring_from_str(value));
|
qlist_append_str(keypairs, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1052,11 +1052,11 @@ static void sd_parse_uri(SheepdogConfig *cfg, const char *filename,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* transport */
|
/* transport */
|
||||||
if (!strcmp(uri->scheme, "sheepdog")) {
|
if (!g_strcmp0(uri->scheme, "sheepdog")) {
|
||||||
is_unix = false;
|
is_unix = false;
|
||||||
} else if (!strcmp(uri->scheme, "sheepdog+tcp")) {
|
} else if (!g_strcmp0(uri->scheme, "sheepdog+tcp")) {
|
||||||
is_unix = false;
|
is_unix = false;
|
||||||
} else if (!strcmp(uri->scheme, "sheepdog+unix")) {
|
} else if (!g_strcmp0(uri->scheme, "sheepdog+unix")) {
|
||||||
is_unix = true;
|
is_unix = true;
|
||||||
} else {
|
} else {
|
||||||
error_setg(&err, "URI scheme must be 'sheepdog', 'sheepdog+tcp',"
|
error_setg(&err, "URI scheme must be 'sheepdog', 'sheepdog+tcp',"
|
||||||
|
|
|
@ -200,7 +200,7 @@ int bdrv_snapshot_goto(BlockDriverState *bs,
|
||||||
|
|
||||||
qdict_extract_subqdict(options, &file_options, "file.");
|
qdict_extract_subqdict(options, &file_options, "file.");
|
||||||
QDECREF(file_options);
|
QDECREF(file_options);
|
||||||
qdict_put(options, "file", qstring_from_str(bdrv_get_node_name(file)));
|
qdict_put_str(options, "file", bdrv_get_node_name(file));
|
||||||
|
|
||||||
drv->bdrv_close(bs);
|
drv->bdrv_close(bs);
|
||||||
bdrv_unref_child(bs, bs->file);
|
bdrv_unref_child(bs, bs->file);
|
||||||
|
|
18
block/ssh.c
18
block/ssh.c
|
@ -205,7 +205,7 @@ static int parse_uri(const char *filename, QDict *options, Error **errp)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(uri->scheme, "ssh") != 0) {
|
if (g_strcmp0(uri->scheme, "ssh") != 0) {
|
||||||
error_setg(errp, "URI scheme must be 'ssh'");
|
error_setg(errp, "URI scheme must be 'ssh'");
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
@ -227,24 +227,23 @@ static int parse_uri(const char *filename, QDict *options, Error **errp)
|
||||||
}
|
}
|
||||||
|
|
||||||
if(uri->user && strcmp(uri->user, "") != 0) {
|
if(uri->user && strcmp(uri->user, "") != 0) {
|
||||||
qdict_put(options, "user", qstring_from_str(uri->user));
|
qdict_put_str(options, "user", uri->user);
|
||||||
}
|
}
|
||||||
|
|
||||||
qdict_put(options, "server.host", qstring_from_str(uri->server));
|
qdict_put_str(options, "server.host", uri->server);
|
||||||
|
|
||||||
port_str = g_strdup_printf("%d", uri->port ?: 22);
|
port_str = g_strdup_printf("%d", uri->port ?: 22);
|
||||||
qdict_put(options, "server.port", qstring_from_str(port_str));
|
qdict_put_str(options, "server.port", port_str);
|
||||||
g_free(port_str);
|
g_free(port_str);
|
||||||
|
|
||||||
qdict_put(options, "path", qstring_from_str(uri->path));
|
qdict_put_str(options, "path", uri->path);
|
||||||
|
|
||||||
/* Pick out any query parameters that we understand, and ignore
|
/* Pick out any query parameters that we understand, and ignore
|
||||||
* the rest.
|
* the rest.
|
||||||
*/
|
*/
|
||||||
for (i = 0; i < qp->n; ++i) {
|
for (i = 0; i < qp->n; ++i) {
|
||||||
if (strcmp(qp->p[i].name, "host_key_check") == 0) {
|
if (strcmp(qp->p[i].name, "host_key_check") == 0) {
|
||||||
qdict_put(options, "host_key_check",
|
qdict_put_str(options, "host_key_check", qp->p[i].value);
|
||||||
qstring_from_str(qp->p[i].value));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -574,9 +573,8 @@ static bool ssh_process_legacy_socket_options(QDict *output_opts,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (host) {
|
if (host) {
|
||||||
qdict_put(output_opts, "server.host", qstring_from_str(host));
|
qdict_put_str(output_opts, "server.host", host);
|
||||||
qdict_put(output_opts, "server.port",
|
qdict_put_str(output_opts, "server.port", port ?: stringify(22));
|
||||||
qstring_from_str(port ?: stringify(22)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -280,6 +280,6 @@ void stream_start(const char *job_id, BlockDriverState *bs,
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
if (orig_bs_flags != bdrv_get_flags(bs)) {
|
if (orig_bs_flags != bdrv_get_flags(bs)) {
|
||||||
bdrv_reopen(bs, s->bs_flags, NULL);
|
bdrv_reopen(bs, orig_bs_flags, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -832,9 +832,9 @@ static int vdi_create(const char *filename, QemuOpts *opts, Error **errp)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (image_type == VDI_TYPE_STATIC) {
|
if (image_type == VDI_TYPE_STATIC) {
|
||||||
ret = blk_truncate(blk, offset + blocks * block_size);
|
ret = blk_truncate(blk, offset + blocks * block_size, errp);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
error_setg(errp, "Failed to statically allocate %s", filename);
|
error_prepend(errp, "Failed to statically allocate %s", filename);
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -548,7 +548,7 @@ static int vhdx_log_flush(BlockDriverState *bs, BDRVVHDXState *s,
|
||||||
if (new_file_size % (1024*1024)) {
|
if (new_file_size % (1024*1024)) {
|
||||||
/* round up to nearest 1MB boundary */
|
/* round up to nearest 1MB boundary */
|
||||||
new_file_size = ((new_file_size >> 20) + 1) << 20;
|
new_file_size = ((new_file_size >> 20) + 1) << 20;
|
||||||
bdrv_truncate(bs->file, new_file_size);
|
bdrv_truncate(bs->file, new_file_size, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
qemu_vfree(desc_entries);
|
qemu_vfree(desc_entries);
|
||||||
|
|
29
block/vhdx.c
29
block/vhdx.c
|
@ -1171,7 +1171,7 @@ static int vhdx_allocate_block(BlockDriverState *bs, BDRVVHDXState *s,
|
||||||
/* per the spec, the address for a block is in units of 1MB */
|
/* per the spec, the address for a block is in units of 1MB */
|
||||||
*new_offset = ROUND_UP(*new_offset, 1024 * 1024);
|
*new_offset = ROUND_UP(*new_offset, 1024 * 1024);
|
||||||
|
|
||||||
return bdrv_truncate(bs->file, *new_offset + s->block_size);
|
return bdrv_truncate(bs->file, *new_offset + s->block_size, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1586,7 +1586,7 @@ exit:
|
||||||
static int vhdx_create_bat(BlockBackend *blk, BDRVVHDXState *s,
|
static int vhdx_create_bat(BlockBackend *blk, BDRVVHDXState *s,
|
||||||
uint64_t image_size, VHDXImageType type,
|
uint64_t image_size, VHDXImageType type,
|
||||||
bool use_zero_blocks, uint64_t file_offset,
|
bool use_zero_blocks, uint64_t file_offset,
|
||||||
uint32_t length)
|
uint32_t length, Error **errp)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
uint64_t data_file_offset;
|
uint64_t data_file_offset;
|
||||||
|
@ -1607,16 +1607,21 @@ static int vhdx_create_bat(BlockBackend *blk, BDRVVHDXState *s,
|
||||||
if (type == VHDX_TYPE_DYNAMIC) {
|
if (type == VHDX_TYPE_DYNAMIC) {
|
||||||
/* All zeroes, so we can just extend the file - the end of the BAT
|
/* All zeroes, so we can just extend the file - the end of the BAT
|
||||||
* is the furthest thing we have written yet */
|
* is the furthest thing we have written yet */
|
||||||
ret = blk_truncate(blk, data_file_offset);
|
ret = blk_truncate(blk, data_file_offset, errp);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
|
error_setg_errno(errp, -ret,
|
||||||
|
"Failed to resize the underlying file");
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
} else if (type == VHDX_TYPE_FIXED) {
|
} else if (type == VHDX_TYPE_FIXED) {
|
||||||
ret = blk_truncate(blk, data_file_offset + image_size);
|
ret = blk_truncate(blk, data_file_offset + image_size, errp);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
|
error_setg_errno(errp, -ret,
|
||||||
|
"Failed to resize the underlying file");
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
error_setg(errp, "Unsupported image type");
|
||||||
ret = -ENOTSUP;
|
ret = -ENOTSUP;
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
@ -1627,6 +1632,7 @@ static int vhdx_create_bat(BlockBackend *blk, BDRVVHDXState *s,
|
||||||
/* for a fixed file, the default BAT entry is not zero */
|
/* for a fixed file, the default BAT entry is not zero */
|
||||||
s->bat = g_try_malloc0(length);
|
s->bat = g_try_malloc0(length);
|
||||||
if (length && s->bat == NULL) {
|
if (length && s->bat == NULL) {
|
||||||
|
error_setg(errp, "Failed to allocate memory for the BAT");
|
||||||
ret = -ENOMEM;
|
ret = -ENOMEM;
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
@ -1646,6 +1652,7 @@ static int vhdx_create_bat(BlockBackend *blk, BDRVVHDXState *s,
|
||||||
}
|
}
|
||||||
ret = blk_pwrite(blk, file_offset, s->bat, length, 0);
|
ret = blk_pwrite(blk, file_offset, s->bat, length, 0);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
|
error_setg_errno(errp, -ret, "Failed to write the BAT");
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1671,7 +1678,8 @@ static int vhdx_create_new_region_table(BlockBackend *blk,
|
||||||
uint32_t log_size,
|
uint32_t log_size,
|
||||||
bool use_zero_blocks,
|
bool use_zero_blocks,
|
||||||
VHDXImageType type,
|
VHDXImageType type,
|
||||||
uint64_t *metadata_offset)
|
uint64_t *metadata_offset,
|
||||||
|
Error **errp)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
uint32_t offset = 0;
|
uint32_t offset = 0;
|
||||||
|
@ -1740,7 +1748,7 @@ static int vhdx_create_new_region_table(BlockBackend *blk,
|
||||||
/* The region table gives us the data we need to create the BAT,
|
/* The region table gives us the data we need to create the BAT,
|
||||||
* so do that now */
|
* so do that now */
|
||||||
ret = vhdx_create_bat(blk, s, image_size, type, use_zero_blocks,
|
ret = vhdx_create_bat(blk, s, image_size, type, use_zero_blocks,
|
||||||
bat_file_offset, bat_length);
|
bat_file_offset, bat_length, errp);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
@ -1749,12 +1757,14 @@ static int vhdx_create_new_region_table(BlockBackend *blk,
|
||||||
ret = blk_pwrite(blk, VHDX_REGION_TABLE_OFFSET, buffer,
|
ret = blk_pwrite(blk, VHDX_REGION_TABLE_OFFSET, buffer,
|
||||||
VHDX_HEADER_BLOCK_SIZE, 0);
|
VHDX_HEADER_BLOCK_SIZE, 0);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
|
error_setg_errno(errp, -ret, "Failed to write first region table");
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = blk_pwrite(blk, VHDX_REGION_TABLE2_OFFSET, buffer,
|
ret = blk_pwrite(blk, VHDX_REGION_TABLE2_OFFSET, buffer,
|
||||||
VHDX_HEADER_BLOCK_SIZE, 0);
|
VHDX_HEADER_BLOCK_SIZE, 0);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
|
error_setg_errno(errp, -ret, "Failed to write second region table");
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1825,6 +1835,7 @@ static int vhdx_create(const char *filename, QemuOpts *opts, Error **errp)
|
||||||
ret = -ENOTSUP;
|
ret = -ENOTSUP;
|
||||||
goto exit;
|
goto exit;
|
||||||
} else {
|
} else {
|
||||||
|
error_setg(errp, "Invalid subformat '%s'", type);
|
||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
@ -1879,12 +1890,14 @@ static int vhdx_create(const char *filename, QemuOpts *opts, Error **errp)
|
||||||
ret = blk_pwrite(blk, VHDX_FILE_ID_OFFSET, &signature, sizeof(signature),
|
ret = blk_pwrite(blk, VHDX_FILE_ID_OFFSET, &signature, sizeof(signature),
|
||||||
0);
|
0);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
|
error_setg_errno(errp, -ret, "Failed to write file signature");
|
||||||
goto delete_and_exit;
|
goto delete_and_exit;
|
||||||
}
|
}
|
||||||
if (creator) {
|
if (creator) {
|
||||||
ret = blk_pwrite(blk, VHDX_FILE_ID_OFFSET + sizeof(signature),
|
ret = blk_pwrite(blk, VHDX_FILE_ID_OFFSET + sizeof(signature),
|
||||||
creator, creator_items * sizeof(gunichar2), 0);
|
creator, creator_items * sizeof(gunichar2), 0);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
|
error_setg_errno(errp, -ret, "Failed to write creator field");
|
||||||
goto delete_and_exit;
|
goto delete_and_exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1893,13 +1906,14 @@ static int vhdx_create(const char *filename, QemuOpts *opts, Error **errp)
|
||||||
/* Creates (B),(C) */
|
/* Creates (B),(C) */
|
||||||
ret = vhdx_create_new_headers(blk, image_size, log_size);
|
ret = vhdx_create_new_headers(blk, image_size, log_size);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
|
error_setg_errno(errp, -ret, "Failed to write image headers");
|
||||||
goto delete_and_exit;
|
goto delete_and_exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Creates (D),(E),(G) explicitly. (F) created as by-product */
|
/* Creates (D),(E),(G) explicitly. (F) created as by-product */
|
||||||
ret = vhdx_create_new_region_table(blk, image_size, block_size, 512,
|
ret = vhdx_create_new_region_table(blk, image_size, block_size, 512,
|
||||||
log_size, use_zero_blocks, image_type,
|
log_size, use_zero_blocks, image_type,
|
||||||
&metadata_offset);
|
&metadata_offset, errp);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
goto delete_and_exit;
|
goto delete_and_exit;
|
||||||
}
|
}
|
||||||
|
@ -1908,6 +1922,7 @@ static int vhdx_create(const char *filename, QemuOpts *opts, Error **errp)
|
||||||
ret = vhdx_create_new_metadata(blk, image_size, block_size, 512,
|
ret = vhdx_create_new_metadata(blk, image_size, block_size, 512,
|
||||||
metadata_offset, image_type);
|
metadata_offset, image_type);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
|
error_setg_errno(errp, -ret, "Failed to initialize metadata");
|
||||||
goto delete_and_exit;
|
goto delete_and_exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
13
block/vmdk.c
13
block/vmdk.c
|
@ -1714,10 +1714,7 @@ static int vmdk_create_extent(const char *filename, int64_t filesize,
|
||||||
blk_set_allow_write_beyond_eof(blk, true);
|
blk_set_allow_write_beyond_eof(blk, true);
|
||||||
|
|
||||||
if (flat) {
|
if (flat) {
|
||||||
ret = blk_truncate(blk, filesize);
|
ret = blk_truncate(blk, filesize, errp);
|
||||||
if (ret < 0) {
|
|
||||||
error_setg_errno(errp, -ret, "Could not truncate file");
|
|
||||||
}
|
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
magic = cpu_to_be32(VMDK4_MAGIC);
|
magic = cpu_to_be32(VMDK4_MAGIC);
|
||||||
|
@ -1780,9 +1777,8 @@ static int vmdk_create_extent(const char *filename, int64_t filesize,
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = blk_truncate(blk, le64_to_cpu(header.grain_offset) << 9);
|
ret = blk_truncate(blk, le64_to_cpu(header.grain_offset) << 9, errp);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
error_setg_errno(errp, -ret, "Could not truncate file");
|
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2090,10 +2086,7 @@ static int vmdk_create(const char *filename, QemuOpts *opts, Error **errp)
|
||||||
/* bdrv_pwrite write padding zeros to align to sector, we don't need that
|
/* bdrv_pwrite write padding zeros to align to sector, we don't need that
|
||||||
* for description file */
|
* for description file */
|
||||||
if (desc_offset == 0) {
|
if (desc_offset == 0) {
|
||||||
ret = blk_truncate(new_blk, desc_len);
|
ret = blk_truncate(new_blk, desc_len, errp);
|
||||||
if (ret < 0) {
|
|
||||||
error_setg_errno(errp, -ret, "Could not truncate file");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
exit:
|
exit:
|
||||||
if (new_blk) {
|
if (new_blk) {
|
||||||
|
|
13
block/vpc.c
13
block/vpc.c
|
@ -851,20 +851,21 @@ static int create_dynamic_disk(BlockBackend *blk, uint8_t *buf,
|
||||||
}
|
}
|
||||||
|
|
||||||
static int create_fixed_disk(BlockBackend *blk, uint8_t *buf,
|
static int create_fixed_disk(BlockBackend *blk, uint8_t *buf,
|
||||||
int64_t total_size)
|
int64_t total_size, Error **errp)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
/* Add footer to total size */
|
/* Add footer to total size */
|
||||||
total_size += HEADER_SIZE;
|
total_size += HEADER_SIZE;
|
||||||
|
|
||||||
ret = blk_truncate(blk, total_size);
|
ret = blk_truncate(blk, total_size, errp);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = blk_pwrite(blk, total_size - HEADER_SIZE, buf, HEADER_SIZE, 0);
|
ret = blk_pwrite(blk, total_size - HEADER_SIZE, buf, HEADER_SIZE, 0);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
|
error_setg_errno(errp, -ret, "Unable to write VHD header");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -996,11 +997,11 @@ static int vpc_create(const char *filename, QemuOpts *opts, Error **errp)
|
||||||
|
|
||||||
if (disk_type == VHD_DYNAMIC) {
|
if (disk_type == VHD_DYNAMIC) {
|
||||||
ret = create_dynamic_disk(blk, buf, total_sectors);
|
ret = create_dynamic_disk(blk, buf, total_sectors);
|
||||||
|
if (ret < 0) {
|
||||||
|
error_setg(errp, "Unable to create or write VHD header");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
ret = create_fixed_disk(blk, buf, total_size);
|
ret = create_fixed_disk(blk, buf, total_size, errp);
|
||||||
}
|
|
||||||
if (ret < 0) {
|
|
||||||
error_setg(errp, "Unable to create or write VHD header");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
out:
|
out:
|
||||||
|
|
|
@ -1057,10 +1057,10 @@ static void vvfat_parse_filename(const char *filename, QDict *options,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Fill in the options QDict */
|
/* Fill in the options QDict */
|
||||||
qdict_put(options, "dir", qstring_from_str(filename));
|
qdict_put_str(options, "dir", filename);
|
||||||
qdict_put(options, "fat-type", qint_from_int(fat_type));
|
qdict_put_int(options, "fat-type", fat_type);
|
||||||
qdict_put(options, "floppy", qbool_from_bool(floppy));
|
qdict_put_bool(options, "floppy", floppy);
|
||||||
qdict_put(options, "rw", qbool_from_bool(rw));
|
qdict_put_bool(options, "rw", rw);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int vvfat_open(BlockDriverState *bs, QDict *options, int flags,
|
static int vvfat_open(BlockDriverState *bs, QDict *options, int flags,
|
||||||
|
@ -2958,8 +2958,7 @@ vvfat_co_pwritev(BlockDriverState *bs, uint64_t offset, uint64_t bytes,
|
||||||
static int64_t coroutine_fn vvfat_co_get_block_status(BlockDriverState *bs,
|
static int64_t coroutine_fn vvfat_co_get_block_status(BlockDriverState *bs,
|
||||||
int64_t sector_num, int nb_sectors, int *n, BlockDriverState **file)
|
int64_t sector_num, int nb_sectors, int *n, BlockDriverState **file)
|
||||||
{
|
{
|
||||||
BDRVVVFATState* s = bs->opaque;
|
*n = bs->total_sectors - sector_num;
|
||||||
*n = s->sector_count - sector_num;
|
|
||||||
if (*n > nb_sectors) {
|
if (*n > nb_sectors) {
|
||||||
*n = nb_sectors;
|
*n = nb_sectors;
|
||||||
} else if (*n < 0) {
|
} else if (*n < 0) {
|
||||||
|
@ -3040,7 +3039,7 @@ static int enable_write_target(BlockDriverState *bs, Error **errp)
|
||||||
}
|
}
|
||||||
|
|
||||||
options = qdict_new();
|
options = qdict_new();
|
||||||
qdict_put(options, "write-target.driver", qstring_from_str("qcow"));
|
qdict_put_str(options, "write-target.driver", "qcow");
|
||||||
s->qcow = bdrv_open_child(s->qcow_filename, options, "write-target", bs,
|
s->qcow = bdrv_open_child(s->qcow_filename, options, "write-target", bs,
|
||||||
&child_vvfat_qcow, false, errp);
|
&child_vvfat_qcow, false, errp);
|
||||||
QDECREF(options);
|
QDECREF(options);
|
||||||
|
|
|
@ -27,6 +27,10 @@ typedef struct NBDServerData {
|
||||||
|
|
||||||
static NBDServerData *nbd_server;
|
static NBDServerData *nbd_server;
|
||||||
|
|
||||||
|
static void nbd_blockdev_client_closed(NBDClient *client, bool ignored)
|
||||||
|
{
|
||||||
|
nbd_client_put(client);
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean nbd_accept(QIOChannel *ioc, GIOCondition condition,
|
static gboolean nbd_accept(QIOChannel *ioc, GIOCondition condition,
|
||||||
gpointer opaque)
|
gpointer opaque)
|
||||||
|
@ -46,7 +50,7 @@ static gboolean nbd_accept(QIOChannel *ioc, GIOCondition condition,
|
||||||
qio_channel_set_name(QIO_CHANNEL(cioc), "nbd-server");
|
qio_channel_set_name(QIO_CHANNEL(cioc), "nbd-server");
|
||||||
nbd_client_new(NULL, cioc,
|
nbd_client_new(NULL, cioc,
|
||||||
nbd_server->tlscreds, NULL,
|
nbd_server->tlscreds, NULL,
|
||||||
nbd_client_put);
|
nbd_blockdev_client_closed);
|
||||||
object_unref(OBJECT(cioc));
|
object_unref(OBJECT(cioc));
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
71
blockdev.c
71
blockdev.c
|
@ -527,7 +527,7 @@ static BlockBackend *blockdev_init(const char *file, QDict *bs_opts,
|
||||||
error_setg(errp, "Cannot specify both 'driver' and 'format'");
|
error_setg(errp, "Cannot specify both 'driver' and 'format'");
|
||||||
goto early_err;
|
goto early_err;
|
||||||
}
|
}
|
||||||
qdict_put(bs_opts, "driver", qstring_from_str(buf));
|
qdict_put_str(bs_opts, "driver", buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
on_write_error = BLOCKDEV_ON_ERROR_ENOSPC;
|
on_write_error = BLOCKDEV_ON_ERROR_ENOSPC;
|
||||||
|
@ -903,10 +903,8 @@ DriveInfo *drive_new(QemuOpts *all_opts, BlockInterfaceType block_default_type)
|
||||||
copy_on_read = false;
|
copy_on_read = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
qdict_put(bs_opts, BDRV_OPT_READ_ONLY,
|
qdict_put_str(bs_opts, BDRV_OPT_READ_ONLY, read_only ? "on" : "off");
|
||||||
qstring_from_str(read_only ? "on" : "off"));
|
qdict_put_str(bs_opts, "copy-on-read", copy_on_read ? "on" : "off");
|
||||||
qdict_put(bs_opts, "copy-on-read",
|
|
||||||
qstring_from_str(copy_on_read ? "on" :"off"));
|
|
||||||
|
|
||||||
/* Controller type */
|
/* Controller type */
|
||||||
value = qemu_opt_get(legacy_opts, "if");
|
value = qemu_opt_get(legacy_opts, "if");
|
||||||
|
@ -1030,7 +1028,7 @@ DriveInfo *drive_new(QemuOpts *all_opts, BlockInterfaceType block_default_type)
|
||||||
new_id = g_strdup_printf("%s%s%i", if_name[type],
|
new_id = g_strdup_printf("%s%s%i", if_name[type],
|
||||||
mediastr, unit_id);
|
mediastr, unit_id);
|
||||||
}
|
}
|
||||||
qdict_put(bs_opts, "id", qstring_from_str(new_id));
|
qdict_put_str(bs_opts, "id", new_id);
|
||||||
g_free(new_id);
|
g_free(new_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1067,7 +1065,7 @@ DriveInfo *drive_new(QemuOpts *all_opts, BlockInterfaceType block_default_type)
|
||||||
error_report("werror is not supported by this bus type");
|
error_report("werror is not supported by this bus type");
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
qdict_put(bs_opts, "werror", qstring_from_str(werror));
|
qdict_put_str(bs_opts, "werror", werror);
|
||||||
}
|
}
|
||||||
|
|
||||||
rerror = qemu_opt_get(legacy_opts, "rerror");
|
rerror = qemu_opt_get(legacy_opts, "rerror");
|
||||||
|
@ -1077,7 +1075,7 @@ DriveInfo *drive_new(QemuOpts *all_opts, BlockInterfaceType block_default_type)
|
||||||
error_report("rerror is not supported by this bus type");
|
error_report("rerror is not supported by this bus type");
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
qdict_put(bs_opts, "rerror", qstring_from_str(rerror));
|
qdict_put_str(bs_opts, "rerror", rerror);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Actual block device init: Functionality shared with blockdev-add */
|
/* Actual block device init: Functionality shared with blockdev-add */
|
||||||
|
@ -1737,10 +1735,9 @@ static void external_snapshot_prepare(BlkActionState *common,
|
||||||
|
|
||||||
options = qdict_new();
|
options = qdict_new();
|
||||||
if (s->has_snapshot_node_name) {
|
if (s->has_snapshot_node_name) {
|
||||||
qdict_put(options, "node-name",
|
qdict_put_str(options, "node-name", snapshot_node_name);
|
||||||
qstring_from_str(snapshot_node_name));
|
|
||||||
}
|
}
|
||||||
qdict_put(options, "driver", qstring_from_str(format));
|
qdict_put_str(options, "driver", format);
|
||||||
|
|
||||||
flags |= BDRV_O_NO_BACKING;
|
flags |= BDRV_O_NO_BACKING;
|
||||||
}
|
}
|
||||||
|
@ -2579,11 +2576,10 @@ void qmp_blockdev_change_medium(bool has_device, const char *device,
|
||||||
|
|
||||||
options = qdict_new();
|
options = qdict_new();
|
||||||
detect_zeroes = blk_get_detect_zeroes_from_root_state(blk);
|
detect_zeroes = blk_get_detect_zeroes_from_root_state(blk);
|
||||||
qdict_put(options, "detect-zeroes",
|
qdict_put_str(options, "detect-zeroes", detect_zeroes ? "on" : "off");
|
||||||
qstring_from_str(detect_zeroes ? "on" : "off"));
|
|
||||||
|
|
||||||
if (has_format) {
|
if (has_format) {
|
||||||
qdict_put(options, "driver", qstring_from_str(format));
|
qdict_put_str(options, "driver", format);
|
||||||
}
|
}
|
||||||
|
|
||||||
medium_bs = bdrv_open(filename, NULL, options, bdrv_flags, errp);
|
medium_bs = bdrv_open(filename, NULL, options, bdrv_flags, errp);
|
||||||
|
@ -2927,29 +2923,9 @@ void qmp_block_resize(bool has_device, const char *device,
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* complete all in-flight operations before resizing the device */
|
bdrv_drained_begin(bs);
|
||||||
bdrv_drain_all();
|
ret = blk_truncate(blk, size, errp);
|
||||||
|
bdrv_drained_end(bs);
|
||||||
ret = blk_truncate(blk, size);
|
|
||||||
switch (ret) {
|
|
||||||
case 0:
|
|
||||||
break;
|
|
||||||
case -ENOMEDIUM:
|
|
||||||
error_setg(errp, QERR_DEVICE_HAS_NO_MEDIUM, device);
|
|
||||||
break;
|
|
||||||
case -ENOTSUP:
|
|
||||||
error_setg(errp, QERR_UNSUPPORTED);
|
|
||||||
break;
|
|
||||||
case -EACCES:
|
|
||||||
error_setg(errp, "Device '%s' is read only", device);
|
|
||||||
break;
|
|
||||||
case -EBUSY:
|
|
||||||
error_setg(errp, QERR_DEVICE_IN_USE, device);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
error_setg_errno(errp, -ret, "Could not resize");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
out:
|
out:
|
||||||
blk_unref(blk);
|
blk_unref(blk);
|
||||||
|
@ -3174,6 +3150,7 @@ static BlockJob *do_drive_backup(DriveBackup *backup, BlockJobTxn *txn,
|
||||||
Error *local_err = NULL;
|
Error *local_err = NULL;
|
||||||
int flags;
|
int flags;
|
||||||
int64_t size;
|
int64_t size;
|
||||||
|
bool set_backing_hd = false;
|
||||||
|
|
||||||
if (!backup->has_speed) {
|
if (!backup->has_speed) {
|
||||||
backup->speed = 0;
|
backup->speed = 0;
|
||||||
|
@ -3224,6 +3201,8 @@ static BlockJob *do_drive_backup(DriveBackup *backup, BlockJobTxn *txn,
|
||||||
}
|
}
|
||||||
if (backup->sync == MIRROR_SYNC_MODE_NONE) {
|
if (backup->sync == MIRROR_SYNC_MODE_NONE) {
|
||||||
source = bs;
|
source = bs;
|
||||||
|
flags |= BDRV_O_NO_BACKING;
|
||||||
|
set_backing_hd = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
size = bdrv_getlength(bs);
|
size = bdrv_getlength(bs);
|
||||||
|
@ -3250,8 +3229,10 @@ static BlockJob *do_drive_backup(DriveBackup *backup, BlockJobTxn *txn,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (backup->format) {
|
if (backup->format) {
|
||||||
options = qdict_new();
|
if (!options) {
|
||||||
qdict_put(options, "driver", qstring_from_str(backup->format));
|
options = qdict_new();
|
||||||
|
}
|
||||||
|
qdict_put_str(options, "driver", backup->format);
|
||||||
}
|
}
|
||||||
|
|
||||||
target_bs = bdrv_open(backup->target, NULL, options, flags, errp);
|
target_bs = bdrv_open(backup->target, NULL, options, flags, errp);
|
||||||
|
@ -3261,6 +3242,14 @@ static BlockJob *do_drive_backup(DriveBackup *backup, BlockJobTxn *txn,
|
||||||
|
|
||||||
bdrv_set_aio_context(target_bs, aio_context);
|
bdrv_set_aio_context(target_bs, aio_context);
|
||||||
|
|
||||||
|
if (set_backing_hd) {
|
||||||
|
bdrv_set_backing_hd(target_bs, source, &local_err);
|
||||||
|
if (local_err) {
|
||||||
|
bdrv_unref(target_bs);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (backup->has_bitmap) {
|
if (backup->has_bitmap) {
|
||||||
bmap = bdrv_find_dirty_bitmap(bs, backup->bitmap);
|
bmap = bdrv_find_dirty_bitmap(bs, backup->bitmap);
|
||||||
if (!bmap) {
|
if (!bmap) {
|
||||||
|
@ -3555,10 +3544,10 @@ void qmp_drive_mirror(DriveMirror *arg, Error **errp)
|
||||||
|
|
||||||
options = qdict_new();
|
options = qdict_new();
|
||||||
if (arg->has_node_name) {
|
if (arg->has_node_name) {
|
||||||
qdict_put(options, "node-name", qstring_from_str(arg->node_name));
|
qdict_put_str(options, "node-name", arg->node_name);
|
||||||
}
|
}
|
||||||
if (format) {
|
if (format) {
|
||||||
qdict_put(options, "driver", qstring_from_str(format));
|
qdict_put_str(options, "driver", format);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Mirroring takes care of copy-on-write using the source's backing
|
/* Mirroring takes care of copy-on-write using the source's backing
|
||||||
|
|
16
exec.c
16
exec.c
|
@ -2010,10 +2010,10 @@ void *qemu_map_ram_ptr(RAMBlock *ram_block, ram_addr_t addr)
|
||||||
* In that case just map until the end of the page.
|
* In that case just map until the end of the page.
|
||||||
*/
|
*/
|
||||||
if (block->offset == 0) {
|
if (block->offset == 0) {
|
||||||
return xen_map_cache(addr, 0, 0);
|
return xen_map_cache(addr, 0, 0, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
block->host = xen_map_cache(block->offset, block->max_length, 1);
|
block->host = xen_map_cache(block->offset, block->max_length, 1, false);
|
||||||
}
|
}
|
||||||
return ramblock_ptr(block, addr);
|
return ramblock_ptr(block, addr);
|
||||||
}
|
}
|
||||||
|
@ -2024,7 +2024,7 @@ void *qemu_map_ram_ptr(RAMBlock *ram_block, ram_addr_t addr)
|
||||||
* Called within RCU critical section.
|
* Called within RCU critical section.
|
||||||
*/
|
*/
|
||||||
static void *qemu_ram_ptr_length(RAMBlock *ram_block, ram_addr_t addr,
|
static void *qemu_ram_ptr_length(RAMBlock *ram_block, ram_addr_t addr,
|
||||||
hwaddr *size)
|
hwaddr *size, bool lock)
|
||||||
{
|
{
|
||||||
RAMBlock *block = ram_block;
|
RAMBlock *block = ram_block;
|
||||||
if (*size == 0) {
|
if (*size == 0) {
|
||||||
|
@ -2043,10 +2043,10 @@ static void *qemu_ram_ptr_length(RAMBlock *ram_block, ram_addr_t addr,
|
||||||
* In that case just map the requested area.
|
* In that case just map the requested area.
|
||||||
*/
|
*/
|
||||||
if (block->offset == 0) {
|
if (block->offset == 0) {
|
||||||
return xen_map_cache(addr, *size, 1);
|
return xen_map_cache(addr, *size, lock, lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
block->host = xen_map_cache(block->offset, block->max_length, 1);
|
block->host = xen_map_cache(block->offset, block->max_length, 1, lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ramblock_ptr(block, addr);
|
return ramblock_ptr(block, addr);
|
||||||
|
@ -2765,7 +2765,7 @@ static MemTxResult address_space_write_continue(AddressSpace *as, hwaddr addr,
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* RAM case */
|
/* RAM case */
|
||||||
ptr = qemu_map_ram_ptr(mr->ram_block, addr1);
|
ptr = qemu_ram_ptr_length(mr->ram_block, addr1, &l, false);
|
||||||
memcpy(ptr, buf, l);
|
memcpy(ptr, buf, l);
|
||||||
invalidate_and_set_dirty(mr, addr1, l);
|
invalidate_and_set_dirty(mr, addr1, l);
|
||||||
}
|
}
|
||||||
|
@ -2856,7 +2856,7 @@ MemTxResult address_space_read_continue(AddressSpace *as, hwaddr addr,
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* RAM case */
|
/* RAM case */
|
||||||
ptr = qemu_map_ram_ptr(mr->ram_block, addr1);
|
ptr = qemu_ram_ptr_length(mr->ram_block, addr1, &l, false);
|
||||||
memcpy(buf, ptr, l);
|
memcpy(buf, ptr, l);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3167,7 +3167,7 @@ void *address_space_map(AddressSpace *as,
|
||||||
|
|
||||||
memory_region_ref(mr);
|
memory_region_ref(mr);
|
||||||
*plen = address_space_extend_translation(as, addr, len, mr, xlat, l, is_write);
|
*plen = address_space_extend_translation(as, addr, len, mr, xlat, l, is_write);
|
||||||
ptr = qemu_ram_ptr_length(mr->ram_block, xlat, plen);
|
ptr = qemu_ram_ptr_length(mr->ram_block, xlat, plen, true);
|
||||||
rcu_read_unlock();
|
rcu_read_unlock();
|
||||||
|
|
||||||
return ptr;
|
return ptr;
|
||||||
|
|
|
@ -278,17 +278,27 @@ update_map_file:
|
||||||
|
|
||||||
static int fchmodat_nofollow(int dirfd, const char *name, mode_t mode)
|
static int fchmodat_nofollow(int dirfd, const char *name, mode_t mode)
|
||||||
{
|
{
|
||||||
|
struct stat stbuf;
|
||||||
int fd, ret;
|
int fd, ret;
|
||||||
|
|
||||||
/* FIXME: this should be handled with fchmodat(AT_SYMLINK_NOFOLLOW).
|
/* FIXME: this should be handled with fchmodat(AT_SYMLINK_NOFOLLOW).
|
||||||
* Unfortunately, the linux kernel doesn't implement it yet. As an
|
* Unfortunately, the linux kernel doesn't implement it yet.
|
||||||
* alternative, let's open the file and use fchmod() instead. This
|
|
||||||
* may fail depending on the permissions of the file, but it is the
|
|
||||||
* best we can do to avoid TOCTTOU. We first try to open read-only
|
|
||||||
* in case name points to a directory. If that fails, we try write-only
|
|
||||||
* in case name doesn't point to a directory.
|
|
||||||
*/
|
*/
|
||||||
fd = openat_file(dirfd, name, O_RDONLY, 0);
|
|
||||||
|
/* First, we clear non-racing symlinks out of the way. */
|
||||||
|
if (fstatat(dirfd, name, &stbuf, AT_SYMLINK_NOFOLLOW)) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (S_ISLNK(stbuf.st_mode)) {
|
||||||
|
errno = ELOOP;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Access modes are ignored when O_PATH is supported. We try O_RDONLY and
|
||||||
|
* O_WRONLY for old-systems that don't support O_PATH.
|
||||||
|
*/
|
||||||
|
fd = openat_file(dirfd, name, O_RDONLY | O_PATH_9P_UTIL, 0);
|
||||||
|
#if O_PATH_9P_UTIL == 0
|
||||||
if (fd == -1) {
|
if (fd == -1) {
|
||||||
/* In case the file is writable-only and isn't a directory. */
|
/* In case the file is writable-only and isn't a directory. */
|
||||||
if (errno == EACCES) {
|
if (errno == EACCES) {
|
||||||
|
@ -302,6 +312,24 @@ static int fchmodat_nofollow(int dirfd, const char *name, mode_t mode)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
ret = fchmod(fd, mode);
|
ret = fchmod(fd, mode);
|
||||||
|
#else
|
||||||
|
if (fd == -1) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Now we handle racing symlinks. */
|
||||||
|
ret = fstat(fd, &stbuf);
|
||||||
|
if (!ret) {
|
||||||
|
if (S_ISLNK(stbuf.st_mode)) {
|
||||||
|
errno = ELOOP;
|
||||||
|
ret = -1;
|
||||||
|
} else {
|
||||||
|
char *proc_path = g_strdup_printf("/proc/self/fd/%d", fd);
|
||||||
|
ret = chmod(proc_path, mode);
|
||||||
|
g_free(proc_path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
close_preserve_errno(fd);
|
close_preserve_errno(fd);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -452,6 +480,11 @@ static off_t local_telldir(FsContext *ctx, V9fsFidOpenState *fs)
|
||||||
return telldir(fs->dir.stream);
|
return telldir(fs->dir.stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool local_is_mapped_file_metadata(FsContext *fs_ctx, const char *name)
|
||||||
|
{
|
||||||
|
return !strcmp(name, VIRTFS_META_DIR);
|
||||||
|
}
|
||||||
|
|
||||||
static struct dirent *local_readdir(FsContext *ctx, V9fsFidOpenState *fs)
|
static struct dirent *local_readdir(FsContext *ctx, V9fsFidOpenState *fs)
|
||||||
{
|
{
|
||||||
struct dirent *entry;
|
struct dirent *entry;
|
||||||
|
@ -465,8 +498,8 @@ again:
|
||||||
if (ctx->export_flags & V9FS_SM_MAPPED) {
|
if (ctx->export_flags & V9FS_SM_MAPPED) {
|
||||||
entry->d_type = DT_UNKNOWN;
|
entry->d_type = DT_UNKNOWN;
|
||||||
} else if (ctx->export_flags & V9FS_SM_MAPPED_FILE) {
|
} else if (ctx->export_flags & V9FS_SM_MAPPED_FILE) {
|
||||||
if (!strcmp(entry->d_name, VIRTFS_META_DIR)) {
|
if (local_is_mapped_file_metadata(ctx, entry->d_name)) {
|
||||||
/* skp the meta data directory */
|
/* skip the meta data directory */
|
||||||
goto again;
|
goto again;
|
||||||
}
|
}
|
||||||
entry->d_type = DT_UNKNOWN;
|
entry->d_type = DT_UNKNOWN;
|
||||||
|
@ -559,6 +592,12 @@ static int local_mknod(FsContext *fs_ctx, V9fsPath *dir_path,
|
||||||
int err = -1;
|
int err = -1;
|
||||||
int dirfd;
|
int dirfd;
|
||||||
|
|
||||||
|
if (fs_ctx->export_flags & V9FS_SM_MAPPED_FILE &&
|
||||||
|
local_is_mapped_file_metadata(fs_ctx, name)) {
|
||||||
|
errno = EINVAL;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
dirfd = local_opendir_nofollow(fs_ctx, dir_path->data);
|
dirfd = local_opendir_nofollow(fs_ctx, dir_path->data);
|
||||||
if (dirfd == -1) {
|
if (dirfd == -1) {
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -605,6 +644,12 @@ static int local_mkdir(FsContext *fs_ctx, V9fsPath *dir_path,
|
||||||
int err = -1;
|
int err = -1;
|
||||||
int dirfd;
|
int dirfd;
|
||||||
|
|
||||||
|
if (fs_ctx->export_flags & V9FS_SM_MAPPED_FILE &&
|
||||||
|
local_is_mapped_file_metadata(fs_ctx, name)) {
|
||||||
|
errno = EINVAL;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
dirfd = local_opendir_nofollow(fs_ctx, dir_path->data);
|
dirfd = local_opendir_nofollow(fs_ctx, dir_path->data);
|
||||||
if (dirfd == -1) {
|
if (dirfd == -1) {
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -694,6 +739,12 @@ static int local_open2(FsContext *fs_ctx, V9fsPath *dir_path, const char *name,
|
||||||
int err = -1;
|
int err = -1;
|
||||||
int dirfd;
|
int dirfd;
|
||||||
|
|
||||||
|
if (fs_ctx->export_flags & V9FS_SM_MAPPED_FILE &&
|
||||||
|
local_is_mapped_file_metadata(fs_ctx, name)) {
|
||||||
|
errno = EINVAL;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Mark all the open to not follow symlinks
|
* Mark all the open to not follow symlinks
|
||||||
*/
|
*/
|
||||||
|
@ -752,6 +803,12 @@ static int local_symlink(FsContext *fs_ctx, const char *oldpath,
|
||||||
int err = -1;
|
int err = -1;
|
||||||
int dirfd;
|
int dirfd;
|
||||||
|
|
||||||
|
if (fs_ctx->export_flags & V9FS_SM_MAPPED_FILE &&
|
||||||
|
local_is_mapped_file_metadata(fs_ctx, name)) {
|
||||||
|
errno = EINVAL;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
dirfd = local_opendir_nofollow(fs_ctx, dir_path->data);
|
dirfd = local_opendir_nofollow(fs_ctx, dir_path->data);
|
||||||
if (dirfd == -1) {
|
if (dirfd == -1) {
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -826,6 +883,12 @@ static int local_link(FsContext *ctx, V9fsPath *oldpath,
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
int odirfd, ndirfd;
|
int odirfd, ndirfd;
|
||||||
|
|
||||||
|
if (ctx->export_flags & V9FS_SM_MAPPED_FILE &&
|
||||||
|
local_is_mapped_file_metadata(ctx, name)) {
|
||||||
|
errno = EINVAL;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
odirfd = local_opendir_nofollow(ctx, odirpath);
|
odirfd = local_opendir_nofollow(ctx, odirpath);
|
||||||
if (odirfd == -1) {
|
if (odirfd == -1) {
|
||||||
goto out;
|
goto out;
|
||||||
|
@ -957,6 +1020,14 @@ static int local_unlinkat_common(FsContext *ctx, int dirfd, const char *name,
|
||||||
if (ctx->export_flags & V9FS_SM_MAPPED_FILE) {
|
if (ctx->export_flags & V9FS_SM_MAPPED_FILE) {
|
||||||
int map_dirfd;
|
int map_dirfd;
|
||||||
|
|
||||||
|
/* We need to remove the metadata as well:
|
||||||
|
* - the metadata directory if we're removing a directory
|
||||||
|
* - the metadata file in the parent's metadata directory
|
||||||
|
*
|
||||||
|
* If any of these are missing (ie, ENOENT) then we're probably
|
||||||
|
* trying to remove something that wasn't created in mapped-file
|
||||||
|
* mode. We just ignore the error.
|
||||||
|
*/
|
||||||
if (flags == AT_REMOVEDIR) {
|
if (flags == AT_REMOVEDIR) {
|
||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
|
@ -964,32 +1035,20 @@ static int local_unlinkat_common(FsContext *ctx, int dirfd, const char *name,
|
||||||
if (fd == -1) {
|
if (fd == -1) {
|
||||||
goto err_out;
|
goto err_out;
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
* If directory remove .virtfs_metadata contained in the
|
|
||||||
* directory
|
|
||||||
*/
|
|
||||||
ret = unlinkat(fd, VIRTFS_META_DIR, AT_REMOVEDIR);
|
ret = unlinkat(fd, VIRTFS_META_DIR, AT_REMOVEDIR);
|
||||||
close_preserve_errno(fd);
|
close_preserve_errno(fd);
|
||||||
if (ret < 0 && errno != ENOENT) {
|
if (ret < 0 && errno != ENOENT) {
|
||||||
/*
|
|
||||||
* We didn't had the .virtfs_metadata file. May be file created
|
|
||||||
* in non-mapped mode ?. Ignore ENOENT.
|
|
||||||
*/
|
|
||||||
goto err_out;
|
goto err_out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
* Now remove the name from parent directory
|
|
||||||
* .virtfs_metadata directory.
|
|
||||||
*/
|
|
||||||
map_dirfd = openat_dir(dirfd, VIRTFS_META_DIR);
|
map_dirfd = openat_dir(dirfd, VIRTFS_META_DIR);
|
||||||
ret = unlinkat(map_dirfd, name, 0);
|
if (map_dirfd != -1) {
|
||||||
close_preserve_errno(map_dirfd);
|
ret = unlinkat(map_dirfd, name, 0);
|
||||||
if (ret < 0 && errno != ENOENT) {
|
close_preserve_errno(map_dirfd);
|
||||||
/*
|
if (ret < 0 && errno != ENOENT) {
|
||||||
* We didn't had the .virtfs_metadata file. May be file created
|
goto err_out;
|
||||||
* in non-mapped mode ?. Ignore ENOENT.
|
}
|
||||||
*/
|
} else if (errno != ENOENT) {
|
||||||
goto err_out;
|
goto err_out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1013,7 +1072,7 @@ static int local_remove(FsContext *ctx, const char *path)
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fstatat(dirfd, path, &stbuf, AT_SYMLINK_NOFOLLOW) < 0) {
|
if (fstatat(dirfd, name, &stbuf, AT_SYMLINK_NOFOLLOW) < 0) {
|
||||||
goto err_out;
|
goto err_out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1096,6 +1155,12 @@ static int local_lremovexattr(FsContext *ctx, V9fsPath *fs_path,
|
||||||
static int local_name_to_path(FsContext *ctx, V9fsPath *dir_path,
|
static int local_name_to_path(FsContext *ctx, V9fsPath *dir_path,
|
||||||
const char *name, V9fsPath *target)
|
const char *name, V9fsPath *target)
|
||||||
{
|
{
|
||||||
|
if (ctx->export_flags & V9FS_SM_MAPPED_FILE &&
|
||||||
|
local_is_mapped_file_metadata(ctx, name)) {
|
||||||
|
errno = EINVAL;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
if (dir_path) {
|
if (dir_path) {
|
||||||
v9fs_path_sprintf(target, "%s/%s", dir_path->data, name);
|
v9fs_path_sprintf(target, "%s/%s", dir_path->data, name);
|
||||||
} else if (strcmp(name, "/")) {
|
} else if (strcmp(name, "/")) {
|
||||||
|
@ -1116,6 +1181,13 @@ static int local_renameat(FsContext *ctx, V9fsPath *olddir,
|
||||||
int ret;
|
int ret;
|
||||||
int odirfd, ndirfd;
|
int odirfd, ndirfd;
|
||||||
|
|
||||||
|
if (ctx->export_flags & V9FS_SM_MAPPED_FILE &&
|
||||||
|
(local_is_mapped_file_metadata(ctx, old_name) ||
|
||||||
|
local_is_mapped_file_metadata(ctx, new_name))) {
|
||||||
|
errno = EINVAL;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
odirfd = local_opendir_nofollow(ctx, olddir->data);
|
odirfd = local_opendir_nofollow(ctx, olddir->data);
|
||||||
if (odirfd == -1) {
|
if (odirfd == -1) {
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -1206,6 +1278,12 @@ static int local_unlinkat(FsContext *ctx, V9fsPath *dir,
|
||||||
int ret;
|
int ret;
|
||||||
int dirfd;
|
int dirfd;
|
||||||
|
|
||||||
|
if (ctx->export_flags & V9FS_SM_MAPPED_FILE &&
|
||||||
|
local_is_mapped_file_metadata(ctx, name)) {
|
||||||
|
errno = EINVAL;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
dirfd = local_opendir_nofollow(ctx, dir->data);
|
dirfd = local_opendir_nofollow(ctx, dir->data);
|
||||||
if (dirfd == -1) {
|
if (dirfd == -1) {
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -13,6 +13,12 @@
|
||||||
#ifndef QEMU_9P_UTIL_H
|
#ifndef QEMU_9P_UTIL_H
|
||||||
#define QEMU_9P_UTIL_H
|
#define QEMU_9P_UTIL_H
|
||||||
|
|
||||||
|
#ifdef O_PATH
|
||||||
|
#define O_PATH_9P_UTIL O_PATH
|
||||||
|
#else
|
||||||
|
#define O_PATH_9P_UTIL 0
|
||||||
|
#endif
|
||||||
|
|
||||||
static inline void close_preserve_errno(int fd)
|
static inline void close_preserve_errno(int fd)
|
||||||
{
|
{
|
||||||
int serrno = errno;
|
int serrno = errno;
|
||||||
|
@ -22,13 +28,8 @@ static inline void close_preserve_errno(int fd)
|
||||||
|
|
||||||
static inline int openat_dir(int dirfd, const char *name)
|
static inline int openat_dir(int dirfd, const char *name)
|
||||||
{
|
{
|
||||||
#ifdef O_PATH
|
|
||||||
#define OPENAT_DIR_O_PATH O_PATH
|
|
||||||
#else
|
|
||||||
#define OPENAT_DIR_O_PATH 0
|
|
||||||
#endif
|
|
||||||
return openat(dirfd, name,
|
return openat(dirfd, name,
|
||||||
O_DIRECTORY | O_RDONLY | O_NOFOLLOW | OPENAT_DIR_O_PATH);
|
O_DIRECTORY | O_RDONLY | O_NOFOLLOW | O_PATH_9P_UTIL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int openat_file(int dirfd, const char *name, int flags,
|
static inline int openat_file(int dirfd, const char *name, int flags,
|
||||||
|
@ -43,9 +44,14 @@ static inline int openat_file(int dirfd, const char *name, int flags,
|
||||||
}
|
}
|
||||||
|
|
||||||
serrno = errno;
|
serrno = errno;
|
||||||
/* O_NONBLOCK was only needed to open the file. Let's drop it. */
|
/* O_NONBLOCK was only needed to open the file. Let's drop it. We don't
|
||||||
ret = fcntl(fd, F_SETFL, flags);
|
* do that with O_PATH since fcntl(F_SETFL) isn't supported, and openat()
|
||||||
assert(!ret);
|
* ignored it anyway.
|
||||||
|
*/
|
||||||
|
if (!(flags & O_PATH_9P_UTIL)) {
|
||||||
|
ret = fcntl(fd, F_SETFL, flags);
|
||||||
|
assert(!ret);
|
||||||
|
}
|
||||||
errno = serrno;
|
errno = serrno;
|
||||||
return fd;
|
return fd;
|
||||||
}
|
}
|
||||||
|
|
|
@ -385,7 +385,10 @@ static void piix4_device_plug_cb(HotplugHandler *hotplug_dev,
|
||||||
dev, errp);
|
dev, errp);
|
||||||
}
|
}
|
||||||
} else if (object_dynamic_cast(OBJECT(dev), TYPE_PCI_DEVICE)) {
|
} else if (object_dynamic_cast(OBJECT(dev), TYPE_PCI_DEVICE)) {
|
||||||
acpi_pcihp_device_plug_cb(hotplug_dev, &s->acpi_pci_hotplug, dev, errp);
|
if (!xen_enabled()) {
|
||||||
|
acpi_pcihp_device_plug_cb(hotplug_dev, &s->acpi_pci_hotplug, dev,
|
||||||
|
errp);
|
||||||
|
}
|
||||||
} else if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) {
|
} else if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) {
|
||||||
if (s->cpu_hotplug_legacy) {
|
if (s->cpu_hotplug_legacy) {
|
||||||
legacy_acpi_cpu_plug_cb(hotplug_dev, &s->gpe_cpu, dev, errp);
|
legacy_acpi_cpu_plug_cb(hotplug_dev, &s->gpe_cpu, dev, errp);
|
||||||
|
@ -408,8 +411,10 @@ static void piix4_device_unplug_request_cb(HotplugHandler *hotplug_dev,
|
||||||
acpi_memory_unplug_request_cb(hotplug_dev, &s->acpi_memory_hotplug,
|
acpi_memory_unplug_request_cb(hotplug_dev, &s->acpi_memory_hotplug,
|
||||||
dev, errp);
|
dev, errp);
|
||||||
} else if (object_dynamic_cast(OBJECT(dev), TYPE_PCI_DEVICE)) {
|
} else if (object_dynamic_cast(OBJECT(dev), TYPE_PCI_DEVICE)) {
|
||||||
acpi_pcihp_device_unplug_cb(hotplug_dev, &s->acpi_pci_hotplug, dev,
|
if (!xen_enabled()) {
|
||||||
errp);
|
acpi_pcihp_device_unplug_cb(hotplug_dev, &s->acpi_pci_hotplug, dev,
|
||||||
|
errp);
|
||||||
|
}
|
||||||
} else if (object_dynamic_cast(OBJECT(dev), TYPE_CPU) &&
|
} else if (object_dynamic_cast(OBJECT(dev), TYPE_CPU) &&
|
||||||
!s->cpu_hotplug_legacy) {
|
!s->cpu_hotplug_legacy) {
|
||||||
acpi_cpu_unplug_request_cb(hotplug_dev, &s->cpuhp_state, dev, errp);
|
acpi_cpu_unplug_request_cb(hotplug_dev, &s->cpuhp_state, dev, errp);
|
||||||
|
@ -700,7 +705,7 @@ static void piix4_pm_class_init(ObjectClass *klass, void *data)
|
||||||
* Reason: part of PIIX4 southbridge, needs to be wired up,
|
* Reason: part of PIIX4 southbridge, needs to be wired up,
|
||||||
* e.g. by mips_malta_init()
|
* e.g. by mips_malta_init()
|
||||||
*/
|
*/
|
||||||
dc->cannot_instantiate_with_device_add_yet = true;
|
dc->user_creatable = false;
|
||||||
dc->hotpluggable = false;
|
dc->hotpluggable = false;
|
||||||
hc->plug = piix4_device_plug_cb;
|
hc->plug = piix4_device_plug_cb;
|
||||||
hc->unplug_request = piix4_device_unplug_request_cb;
|
hc->unplug_request = piix4_device_unplug_request_cb;
|
||||||
|
|
|
@ -1076,7 +1076,7 @@ static void sl_nand_class_init(ObjectClass *klass, void *data)
|
||||||
dc->vmsd = &vmstate_sl_nand_info;
|
dc->vmsd = &vmstate_sl_nand_info;
|
||||||
dc->props = sl_nand_properties;
|
dc->props = sl_nand_properties;
|
||||||
/* Reason: init() method uses drive_get() */
|
/* Reason: init() method uses drive_get() */
|
||||||
dc->cannot_instantiate_with_device_add_yet = true;
|
dc->user_creatable = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const TypeInfo sl_nand_info = {
|
static const TypeInfo sl_nand_info = {
|
||||||
|
|
|
@ -292,7 +292,7 @@ static void mv88w8618_audio_class_init(ObjectClass *klass, void *data)
|
||||||
dc->vmsd = &mv88w8618_audio_vmsd;
|
dc->vmsd = &mv88w8618_audio_vmsd;
|
||||||
dc->props = mv88w8618_audio_properties;
|
dc->props = mv88w8618_audio_properties;
|
||||||
/* Reason: pointer property "wm8750" */
|
/* Reason: pointer property "wm8750" */
|
||||||
dc->cannot_instantiate_with_device_add_yet = true;
|
dc->user_creatable = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const TypeInfo mv88w8618_audio_info = {
|
static const TypeInfo mv88w8618_audio_info = {
|
||||||
|
|
|
@ -223,7 +223,7 @@ static void pcspk_class_initfn(ObjectClass *klass, void *data)
|
||||||
dc->vmsd = &vmstate_spk;
|
dc->vmsd = &vmstate_spk;
|
||||||
dc->props = pcspk_properties;
|
dc->props = pcspk_properties;
|
||||||
/* Reason: realize sets global pcspk_state */
|
/* Reason: realize sets global pcspk_state */
|
||||||
dc->cannot_instantiate_with_device_add_yet = true;
|
dc->user_creatable = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const TypeInfo pcspk_info = {
|
static const TypeInfo pcspk_info = {
|
||||||
|
|
|
@ -1082,7 +1082,7 @@ static int blk_connect(struct XenDevice *xendev)
|
||||||
|
|
||||||
if (strcmp(blkdev->fileproto, "<unset>")) {
|
if (strcmp(blkdev->fileproto, "<unset>")) {
|
||||||
options = qdict_new();
|
options = qdict_new();
|
||||||
qdict_put(options, "driver", qstring_from_str(blkdev->fileproto));
|
qdict_put_str(options, "driver", blkdev->fileproto);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* setup via xenbus -> create new block driver instance */
|
/* setup via xenbus -> create new block driver instance */
|
||||||
|
|
|
@ -1121,6 +1121,9 @@ static void virtio_serial_device_unrealize(DeviceState *dev, Error **errp)
|
||||||
timer_free(vser->post_load->timer);
|
timer_free(vser->post_load->timer);
|
||||||
g_free(vser->post_load);
|
g_free(vser->post_load);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
qbus_set_hotplug_handler(BUS(&vser->bus), NULL, errp);
|
||||||
|
|
||||||
virtio_cleanup(vdev);
|
virtio_cleanup(vdev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -91,7 +91,7 @@ static void or_irq_class_init(ObjectClass *klass, void *data)
|
||||||
dc->vmsd = &vmstate_or_irq;
|
dc->vmsd = &vmstate_or_irq;
|
||||||
|
|
||||||
/* Reason: Needs to be wired up to work, e.g. see stm32f205_soc.c */
|
/* Reason: Needs to be wired up to work, e.g. see stm32f205_soc.c */
|
||||||
dc->cannot_instantiate_with_device_add_yet = true;
|
dc->user_creatable = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const TypeInfo or_irq_type_info = {
|
static const TypeInfo or_irq_type_info = {
|
||||||
|
|
|
@ -1159,6 +1159,7 @@ static void device_class_init(ObjectClass *class, void *data)
|
||||||
* should override it in their class_init()
|
* should override it in their class_init()
|
||||||
*/
|
*/
|
||||||
dc->hotpluggable = true;
|
dc->hotpluggable = true;
|
||||||
|
dc->user_creatable = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void device_reset(DeviceState *dev)
|
void device_reset(DeviceState *dev)
|
||||||
|
|
|
@ -288,7 +288,7 @@ static void register_class_init(ObjectClass *oc, void *data)
|
||||||
DeviceClass *dc = DEVICE_CLASS(oc);
|
DeviceClass *dc = DEVICE_CLASS(oc);
|
||||||
|
|
||||||
/* Reason: needs to be wired up to work */
|
/* Reason: needs to be wired up to work */
|
||||||
dc->cannot_instantiate_with_device_add_yet = true;
|
dc->user_creatable = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const TypeInfo register_info = {
|
static const TypeInfo register_info = {
|
||||||
|
|
|
@ -33,6 +33,11 @@ static void core_prop_set_core_id(Object *obj, Visitor *v, const char *name,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (value < 0) {
|
||||||
|
error_setg(errp, "Invalid core id %"PRId64, value);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
core->core_id = value;
|
core->core_id = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -601,7 +601,7 @@ static void i8257_class_init(ObjectClass *klass, void *data)
|
||||||
idc->schedule = i8257_dma_schedule;
|
idc->schedule = i8257_dma_schedule;
|
||||||
idc->register_channel = i8257_dma_register_channel;
|
idc->register_channel = i8257_dma_register_channel;
|
||||||
/* Reason: needs to be wired up by isa_bus_dma() to work */
|
/* Reason: needs to be wired up by isa_bus_dma() to work */
|
||||||
dc->cannot_instantiate_with_device_add_yet = true;
|
dc->user_creatable = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const TypeInfo i8257_info = {
|
static const TypeInfo i8257_info = {
|
||||||
|
|
|
@ -305,7 +305,7 @@ static void sparc32_dma_class_init(ObjectClass *klass, void *data)
|
||||||
dc->vmsd = &vmstate_dma;
|
dc->vmsd = &vmstate_dma;
|
||||||
dc->props = sparc32_dma_properties;
|
dc->props = sparc32_dma_properties;
|
||||||
/* Reason: pointer property "iommu_opaque" */
|
/* Reason: pointer property "iommu_opaque" */
|
||||||
dc->cannot_instantiate_with_device_add_yet = true;
|
dc->user_creatable = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const TypeInfo sparc32_dma_info = {
|
static const TypeInfo sparc32_dma_info = {
|
||||||
|
|
|
@ -773,7 +773,7 @@ static void omap_gpio_class_init(ObjectClass *klass, void *data)
|
||||||
dc->reset = omap_gpif_reset;
|
dc->reset = omap_gpif_reset;
|
||||||
dc->props = omap_gpio_properties;
|
dc->props = omap_gpio_properties;
|
||||||
/* Reason: pointer property "clk" */
|
/* Reason: pointer property "clk" */
|
||||||
dc->cannot_instantiate_with_device_add_yet = true;
|
dc->user_creatable = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const TypeInfo omap_gpio_info = {
|
static const TypeInfo omap_gpio_info = {
|
||||||
|
@ -804,7 +804,7 @@ static void omap2_gpio_class_init(ObjectClass *klass, void *data)
|
||||||
dc->reset = omap2_gpif_reset;
|
dc->reset = omap2_gpif_reset;
|
||||||
dc->props = omap2_gpio_properties;
|
dc->props = omap2_gpio_properties;
|
||||||
/* Reason: pointer properties "iclk", "fclk0", ..., "fclk5" */
|
/* Reason: pointer properties "iclk", "fclk0", ..., "fclk5" */
|
||||||
dc->cannot_instantiate_with_device_add_yet = true;
|
dc->user_creatable = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const TypeInfo omap2_gpio_info = {
|
static const TypeInfo omap2_gpio_info = {
|
||||||
|
|
|
@ -491,7 +491,7 @@ static void omap_i2c_class_init(ObjectClass *klass, void *data)
|
||||||
dc->props = omap_i2c_properties;
|
dc->props = omap_i2c_properties;
|
||||||
dc->reset = omap_i2c_reset;
|
dc->reset = omap_i2c_reset;
|
||||||
/* Reason: pointer properties "iclk", "fclk" */
|
/* Reason: pointer properties "iclk", "fclk" */
|
||||||
dc->cannot_instantiate_with_device_add_yet = true;
|
dc->user_creatable = false;
|
||||||
dc->realize = omap_i2c_realize;
|
dc->realize = omap_i2c_realize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -123,7 +123,7 @@ static void smbus_eeprom_class_initfn(ObjectClass *klass, void *data)
|
||||||
sc->read_data = eeprom_read_data;
|
sc->read_data = eeprom_read_data;
|
||||||
dc->props = smbus_eeprom_properties;
|
dc->props = smbus_eeprom_properties;
|
||||||
/* Reason: pointer property "data" */
|
/* Reason: pointer property "data" */
|
||||||
dc->cannot_instantiate_with_device_add_yet = true;
|
dc->user_creatable = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const TypeInfo smbus_eeprom_info = {
|
static const TypeInfo smbus_eeprom_info = {
|
||||||
|
|
|
@ -103,7 +103,7 @@ static void ich9_smb_class_init(ObjectClass *klass, void *data)
|
||||||
* Reason: part of ICH9 southbridge, needs to be wired up by
|
* Reason: part of ICH9 southbridge, needs to be wired up by
|
||||||
* pc_q35_init()
|
* pc_q35_init()
|
||||||
*/
|
*/
|
||||||
dc->cannot_instantiate_with_device_add_yet = true;
|
dc->user_creatable = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
I2CBus *ich9_smb_init(PCIBus *bus, int devfn, uint32_t smb_io_base)
|
I2CBus *ich9_smb_init(PCIBus *bus, int devfn, uint32_t smb_io_base)
|
||||||
|
|
|
@ -1818,9 +1818,9 @@ static Aml *build_q35_osc_method(void)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Always allow native PME, AER (no dependencies)
|
* Always allow native PME, AER (no dependencies)
|
||||||
* Never allow SHPC (no SHPC controller in this system)
|
* Allow SHPC (PCI bridges can have SHPC controller)
|
||||||
*/
|
*/
|
||||||
aml_append(if_ctx, aml_and(a_ctrl, aml_int(0x1D), a_ctrl));
|
aml_append(if_ctx, aml_and(a_ctrl, aml_int(0x1F), a_ctrl));
|
||||||
|
|
||||||
if_ctx2 = aml_if(aml_lnot(aml_equal(aml_arg(1), aml_int(1))));
|
if_ctx2 = aml_if(aml_lnot(aml_equal(aml_arg(1), aml_int(1))));
|
||||||
/* Unknown revision */
|
/* Unknown revision */
|
||||||
|
|
|
@ -597,7 +597,7 @@ static void port92_class_initfn(ObjectClass *klass, void *data)
|
||||||
* wiring: its A20 output line needs to be wired up by
|
* wiring: its A20 output line needs to be wired up by
|
||||||
* port92_init().
|
* port92_init().
|
||||||
*/
|
*/
|
||||||
dc->cannot_instantiate_with_device_add_yet = true;
|
dc->user_creatable = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const TypeInfo port92_info = {
|
static const TypeInfo port92_info = {
|
||||||
|
|
|
@ -483,6 +483,7 @@ void hid_reset(HIDState *hs)
|
||||||
memset(hs->kbd.keycodes, 0, sizeof(hs->kbd.keycodes));
|
memset(hs->kbd.keycodes, 0, sizeof(hs->kbd.keycodes));
|
||||||
memset(hs->kbd.key, 0, sizeof(hs->kbd.key));
|
memset(hs->kbd.key, 0, sizeof(hs->kbd.key));
|
||||||
hs->kbd.keys = 0;
|
hs->kbd.keys = 0;
|
||||||
|
hs->kbd.modifiers = 0;
|
||||||
break;
|
break;
|
||||||
case HID_MOUSE:
|
case HID_MOUSE:
|
||||||
case HID_TABLET:
|
case HID_TABLET:
|
||||||
|
|
|
@ -286,7 +286,7 @@ static void vmmouse_class_initfn(ObjectClass *klass, void *data)
|
||||||
dc->vmsd = &vmstate_vmmouse;
|
dc->vmsd = &vmstate_vmmouse;
|
||||||
dc->props = vmmouse_properties;
|
dc->props = vmmouse_properties;
|
||||||
/* Reason: pointer property "ps2_mouse" */
|
/* Reason: pointer property "ps2_mouse" */
|
||||||
dc->cannot_instantiate_with_device_add_yet = true;
|
dc->user_creatable = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const TypeInfo vmmouse_info = {
|
static const TypeInfo vmmouse_info = {
|
||||||
|
|
|
@ -501,7 +501,7 @@ static void apic_common_class_init(ObjectClass *klass, void *data)
|
||||||
* Reason: APIC and CPU need to be wired up by
|
* Reason: APIC and CPU need to be wired up by
|
||||||
* x86_cpu_apic_create()
|
* x86_cpu_apic_create()
|
||||||
*/
|
*/
|
||||||
dc->cannot_instantiate_with_device_add_yet = true;
|
dc->user_creatable = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const TypeInfo apic_common_type = {
|
static const TypeInfo apic_common_type = {
|
||||||
|
|
|
@ -173,7 +173,7 @@ static void etraxfs_pic_class_init(ObjectClass *klass, void *data)
|
||||||
dc->props = etraxfs_pic_properties;
|
dc->props = etraxfs_pic_properties;
|
||||||
/*
|
/*
|
||||||
* Note: pointer property "interrupt_vector" may remain null, thus
|
* Note: pointer property "interrupt_vector" may remain null, thus
|
||||||
* no need for dc->cannot_instantiate_with_device_add_yet = true;
|
* no need for dc->user_creatable = false;
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -360,7 +360,7 @@ static void grlib_irqmp_class_init(ObjectClass *klass, void *data)
|
||||||
dc->reset = grlib_irqmp_reset;
|
dc->reset = grlib_irqmp_reset;
|
||||||
dc->props = grlib_irqmp_properties;
|
dc->props = grlib_irqmp_properties;
|
||||||
/* Reason: pointer properties "set_pil_in", "set_pil_in_opaque" */
|
/* Reason: pointer properties "set_pil_in", "set_pil_in_opaque" */
|
||||||
dc->cannot_instantiate_with_device_add_yet = true;
|
dc->user_creatable = false;
|
||||||
dc->realize = grlib_irqmp_realize;
|
dc->realize = grlib_irqmp_realize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -144,7 +144,7 @@ static void pic_common_class_init(ObjectClass *klass, void *data)
|
||||||
* wiring of the slave to the master is hard-coded in device model
|
* wiring of the slave to the master is hard-coded in device model
|
||||||
* code.
|
* code.
|
||||||
*/
|
*/
|
||||||
dc->cannot_instantiate_with_device_add_yet = true;
|
dc->user_creatable = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const TypeInfo pic_common_type = {
|
static const TypeInfo pic_common_type = {
|
||||||
|
|
|
@ -80,7 +80,7 @@ static void altera_iic_class_init(ObjectClass *klass, void *data)
|
||||||
DeviceClass *dc = DEVICE_CLASS(klass);
|
DeviceClass *dc = DEVICE_CLASS(klass);
|
||||||
|
|
||||||
/* Reason: needs to be wired up, e.g. by nios2_10m50_ghrd_init() */
|
/* Reason: needs to be wired up, e.g. by nios2_10m50_ghrd_init() */
|
||||||
dc->cannot_instantiate_with_device_add_yet = true;
|
dc->user_creatable = false;
|
||||||
dc->realize = altera_iic_realize;
|
dc->realize = altera_iic_realize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -401,7 +401,7 @@ static void omap_intc_class_init(ObjectClass *klass, void *data)
|
||||||
dc->reset = omap_inth_reset;
|
dc->reset = omap_inth_reset;
|
||||||
dc->props = omap_intc_properties;
|
dc->props = omap_intc_properties;
|
||||||
/* Reason: pointer property "clk" */
|
/* Reason: pointer property "clk" */
|
||||||
dc->cannot_instantiate_with_device_add_yet = true;
|
dc->user_creatable = false;
|
||||||
dc->realize = omap_intc_realize;
|
dc->realize = omap_intc_realize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -656,7 +656,7 @@ static void omap2_intc_class_init(ObjectClass *klass, void *data)
|
||||||
dc->reset = omap_inth_reset;
|
dc->reset = omap_inth_reset;
|
||||||
dc->props = omap2_intc_properties;
|
dc->props = omap2_intc_properties;
|
||||||
/* Reason: pointer property "iclk", "fclk" */
|
/* Reason: pointer property "iclk", "fclk" */
|
||||||
dc->cannot_instantiate_with_device_add_yet = true;
|
dc->user_creatable = false;
|
||||||
dc->realize = omap2_intc_realize;
|
dc->realize = omap2_intc_realize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -805,7 +805,7 @@ static void ich9_lpc_class_init(ObjectClass *klass, void *data)
|
||||||
* Reason: part of ICH9 southbridge, needs to be wired up by
|
* Reason: part of ICH9 southbridge, needs to be wired up by
|
||||||
* pc_q35_init()
|
* pc_q35_init()
|
||||||
*/
|
*/
|
||||||
dc->cannot_instantiate_with_device_add_yet = true;
|
dc->user_creatable = false;
|
||||||
hc->plug = ich9_pm_device_plug_cb;
|
hc->plug = ich9_pm_device_plug_cb;
|
||||||
hc->unplug_request = ich9_pm_device_unplug_request_cb;
|
hc->unplug_request = ich9_pm_device_unplug_request_cb;
|
||||||
hc->unplug = ich9_pm_device_unplug_cb;
|
hc->unplug = ich9_pm_device_unplug_cb;
|
||||||
|
|
|
@ -123,7 +123,7 @@ static void piix4_class_init(ObjectClass *klass, void *data)
|
||||||
* Reason: part of PIIX4 southbridge, needs to be wired up,
|
* Reason: part of PIIX4 southbridge, needs to be wired up,
|
||||||
* e.g. by mips_malta_init()
|
* e.g. by mips_malta_init()
|
||||||
*/
|
*/
|
||||||
dc->cannot_instantiate_with_device_add_yet = true;
|
dc->user_creatable = false;
|
||||||
dc->hotpluggable = false;
|
dc->hotpluggable = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -494,7 +494,7 @@ static void via_class_init(ObjectClass *klass, void *data)
|
||||||
* Reason: part of VIA VT82C686 southbridge, needs to be wired up,
|
* Reason: part of VIA VT82C686 southbridge, needs to be wired up,
|
||||||
* e.g. by mips_fulong2e_init()
|
* e.g. by mips_fulong2e_init()
|
||||||
*/
|
*/
|
||||||
dc->cannot_instantiate_with_device_add_yet = true;
|
dc->user_creatable = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const TypeInfo via_info = {
|
static const TypeInfo via_info = {
|
||||||
|
|
|
@ -1224,7 +1224,7 @@ static void gt64120_pci_class_init(ObjectClass *klass, void *data)
|
||||||
* PCI-facing part of the host bridge, not usable without the
|
* PCI-facing part of the host bridge, not usable without the
|
||||||
* host-facing part, which can't be device_add'ed, yet.
|
* host-facing part, which can't be device_add'ed, yet.
|
||||||
*/
|
*/
|
||||||
dc->cannot_instantiate_with_device_add_yet = true;
|
dc->user_creatable = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const TypeInfo gt64120_pci_info = {
|
static const TypeInfo gt64120_pci_info = {
|
||||||
|
|
|
@ -163,7 +163,7 @@ static void vmport_class_initfn(ObjectClass *klass, void *data)
|
||||||
|
|
||||||
dc->realize = vmport_realizefn;
|
dc->realize = vmport_realizefn;
|
||||||
/* Reason: realize sets global port_state */
|
/* Reason: realize sets global port_state */
|
||||||
dc->cannot_instantiate_with_device_add_yet = true;
|
dc->user_creatable = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const TypeInfo vmport_info = {
|
static const TypeInfo vmport_info = {
|
||||||
|
|
|
@ -934,7 +934,7 @@ static void dp8393x_class_init(ObjectClass *klass, void *data)
|
||||||
dc->vmsd = &vmstate_dp8393x;
|
dc->vmsd = &vmstate_dp8393x;
|
||||||
dc->props = dp8393x_properties;
|
dc->props = dp8393x_properties;
|
||||||
/* Reason: dma_mr property can't be set */
|
/* Reason: dma_mr property can't be set */
|
||||||
dc->cannot_instantiate_with_device_add_yet = true;
|
dc->user_creatable = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const TypeInfo dp8393x_info = {
|
static const TypeInfo dp8393x_info = {
|
||||||
|
|
|
@ -2454,14 +2454,20 @@ e1000e_set_ics(E1000ECore *core, int index, uint32_t val)
|
||||||
static void
|
static void
|
||||||
e1000e_set_icr(E1000ECore *core, int index, uint32_t val)
|
e1000e_set_icr(E1000ECore *core, int index, uint32_t val)
|
||||||
{
|
{
|
||||||
|
uint32_t icr = 0;
|
||||||
if ((core->mac[ICR] & E1000_ICR_ASSERTED) &&
|
if ((core->mac[ICR] & E1000_ICR_ASSERTED) &&
|
||||||
(core->mac[CTRL_EXT] & E1000_CTRL_EXT_IAME)) {
|
(core->mac[CTRL_EXT] & E1000_CTRL_EXT_IAME)) {
|
||||||
trace_e1000e_irq_icr_process_iame();
|
trace_e1000e_irq_icr_process_iame();
|
||||||
e1000e_clear_ims_bits(core, core->mac[IAM]);
|
e1000e_clear_ims_bits(core, core->mac[IAM]);
|
||||||
}
|
}
|
||||||
|
|
||||||
trace_e1000e_irq_icr_write(val, core->mac[ICR], core->mac[ICR] & ~val);
|
icr = core->mac[ICR] & ~val;
|
||||||
core->mac[ICR] &= ~val;
|
/* Windows driver expects that the "receive overrun" bit and other
|
||||||
|
* ones to be cleared when the "Other" bit (#24) is cleared.
|
||||||
|
*/
|
||||||
|
icr = (val & E1000_ICR_OTHER) ? (icr & ~E1000_ICR_OTHER_CAUSES) : icr;
|
||||||
|
trace_e1000e_irq_icr_write(val, core->mac[ICR], icr);
|
||||||
|
core->mac[ICR] = icr;
|
||||||
e1000e_update_interrupt_state(core);
|
e1000e_update_interrupt_state(core);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -630,7 +630,7 @@ static void etraxfs_eth_class_init(ObjectClass *klass, void *data)
|
||||||
k->init = fs_eth_init;
|
k->init = fs_eth_init;
|
||||||
dc->props = etraxfs_eth_properties;
|
dc->props = etraxfs_eth_properties;
|
||||||
/* Reason: pointer properties "dma_out", "dma_in" */
|
/* Reason: pointer properties "dma_out", "dma_in" */
|
||||||
dc->cannot_instantiate_with_device_add_yet = true;
|
dc->user_creatable = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const TypeInfo etraxfs_eth_info = {
|
static const TypeInfo etraxfs_eth_info = {
|
||||||
|
|
|
@ -165,7 +165,7 @@ static void lance_class_init(ObjectClass *klass, void *data)
|
||||||
dc->vmsd = &vmstate_lance;
|
dc->vmsd = &vmstate_lance;
|
||||||
dc->props = lance_properties;
|
dc->props = lance_properties;
|
||||||
/* Reason: pointer property "dma" */
|
/* Reason: pointer property "dma" */
|
||||||
dc->cannot_instantiate_with_device_add_yet = true;
|
dc->user_creatable = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const TypeInfo lance_info = {
|
static const TypeInfo lance_info = {
|
||||||
|
|
|
@ -723,6 +723,8 @@ static int virtio_net_handle_offloads(VirtIONet *n, uint8_t cmd,
|
||||||
if (cmd == VIRTIO_NET_CTRL_GUEST_OFFLOADS_SET) {
|
if (cmd == VIRTIO_NET_CTRL_GUEST_OFFLOADS_SET) {
|
||||||
uint64_t supported_offloads;
|
uint64_t supported_offloads;
|
||||||
|
|
||||||
|
offloads = virtio_ldq_p(vdev, &offloads);
|
||||||
|
|
||||||
if (!n->has_vnet_hdr) {
|
if (!n->has_vnet_hdr) {
|
||||||
return VIRTIO_NET_ERR;
|
return VIRTIO_NET_ERR;
|
||||||
}
|
}
|
||||||
|
@ -1522,9 +1524,12 @@ static void virtio_net_del_queue(VirtIONet *n, int index)
|
||||||
if (q->tx_timer) {
|
if (q->tx_timer) {
|
||||||
timer_del(q->tx_timer);
|
timer_del(q->tx_timer);
|
||||||
timer_free(q->tx_timer);
|
timer_free(q->tx_timer);
|
||||||
|
q->tx_timer = NULL;
|
||||||
} else {
|
} else {
|
||||||
qemu_bh_delete(q->tx_bh);
|
qemu_bh_delete(q->tx_bh);
|
||||||
|
q->tx_bh = NULL;
|
||||||
}
|
}
|
||||||
|
q->tx_waiting = 0;
|
||||||
virtio_del_queue(vdev, index * 2 + 1);
|
virtio_del_queue(vdev, index * 2 + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -128,7 +128,7 @@ static void dec_21154_pci_host_class_init(ObjectClass *klass, void *data)
|
||||||
* PCI-facing part of the host bridge, not usable without the
|
* PCI-facing part of the host bridge, not usable without the
|
||||||
* host-facing part, which can't be device_add'ed, yet.
|
* host-facing part, which can't be device_add'ed, yet.
|
||||||
*/
|
*/
|
||||||
dc->cannot_instantiate_with_device_add_yet = true;
|
dc->user_creatable = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const TypeInfo dec_21154_pci_host_info = {
|
static const TypeInfo dec_21154_pci_host_info = {
|
||||||
|
|
|
@ -150,7 +150,7 @@ static void pxb_host_class_init(ObjectClass *class, void *data)
|
||||||
|
|
||||||
dc->fw_name = "pci";
|
dc->fw_name = "pci";
|
||||||
/* Reason: Internal part of the pxb/pxb-pcie device, not usable by itself */
|
/* Reason: Internal part of the pxb/pxb-pcie device, not usable by itself */
|
||||||
dc->cannot_instantiate_with_device_add_yet = true;
|
dc->user_creatable = false;
|
||||||
sbc->explicit_ofw_unit_address = pxb_host_ofw_unit_address;
|
sbc->explicit_ofw_unit_address = pxb_host_ofw_unit_address;
|
||||||
hc->root_bus_path = pxb_host_root_bus_path;
|
hc->root_bus_path = pxb_host_root_bus_path;
|
||||||
}
|
}
|
||||||
|
|
|
@ -810,7 +810,7 @@ static void pbm_pci_host_class_init(ObjectClass *klass, void *data)
|
||||||
* PCI-facing part of the host bridge, not usable without the
|
* PCI-facing part of the host bridge, not usable without the
|
||||||
* host-facing part, which can't be device_add'ed, yet.
|
* host-facing part, which can't be device_add'ed, yet.
|
||||||
*/
|
*/
|
||||||
dc->cannot_instantiate_with_device_add_yet = true;
|
dc->user_creatable = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const TypeInfo pbm_pci_host_info = {
|
static const TypeInfo pbm_pci_host_info = {
|
||||||
|
|
|
@ -825,7 +825,7 @@ static void bonito_class_init(ObjectClass *klass, void *data)
|
||||||
* PCI-facing part of the host bridge, not usable without the
|
* PCI-facing part of the host bridge, not usable without the
|
||||||
* host-facing part, which can't be device_add'ed, yet.
|
* host-facing part, which can't be device_add'ed, yet.
|
||||||
*/
|
*/
|
||||||
dc->cannot_instantiate_with_device_add_yet = true;
|
dc->user_creatable = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const TypeInfo bonito_info = {
|
static const TypeInfo bonito_info = {
|
||||||
|
|
|
@ -136,7 +136,7 @@ static void gpex_root_class_init(ObjectClass *klass, void *data)
|
||||||
* PCI-facing part of the host bridge, not usable without the
|
* PCI-facing part of the host bridge, not usable without the
|
||||||
* host-facing part, which can't be device_add'ed, yet.
|
* host-facing part, which can't be device_add'ed, yet.
|
||||||
*/
|
*/
|
||||||
dc->cannot_instantiate_with_device_add_yet = true;
|
dc->user_creatable = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const TypeInfo gpex_root_info = {
|
static const TypeInfo gpex_root_info = {
|
||||||
|
|
|
@ -134,7 +134,7 @@ static void grackle_pci_class_init(ObjectClass *klass, void *data)
|
||||||
* PCI-facing part of the host bridge, not usable without the
|
* PCI-facing part of the host bridge, not usable without the
|
||||||
* host-facing part, which can't be device_add'ed, yet.
|
* host-facing part, which can't be device_add'ed, yet.
|
||||||
*/
|
*/
|
||||||
dc->cannot_instantiate_with_device_add_yet = true;
|
dc->user_creatable = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const TypeInfo grackle_pci_info = {
|
static const TypeInfo grackle_pci_info = {
|
||||||
|
|
|
@ -691,7 +691,7 @@ static void pci_piix3_class_init(ObjectClass *klass, void *data)
|
||||||
* Reason: part of PIIX3 southbridge, needs to be wired up by
|
* Reason: part of PIIX3 southbridge, needs to be wired up by
|
||||||
* pc_piix.c's pc_init1()
|
* pc_piix.c's pc_init1()
|
||||||
*/
|
*/
|
||||||
dc->cannot_instantiate_with_device_add_yet = true;
|
dc->user_creatable = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const TypeInfo piix3_pci_type_info = {
|
static const TypeInfo piix3_pci_type_info = {
|
||||||
|
@ -745,7 +745,7 @@ static void i440fx_class_init(ObjectClass *klass, void *data)
|
||||||
* PCI-facing part of the host bridge, not usable without the
|
* PCI-facing part of the host bridge, not usable without the
|
||||||
* host-facing part, which can't be device_add'ed, yet.
|
* host-facing part, which can't be device_add'ed, yet.
|
||||||
*/
|
*/
|
||||||
dc->cannot_instantiate_with_device_add_yet = true;
|
dc->user_creatable = false;
|
||||||
dc->hotpluggable = false;
|
dc->hotpluggable = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -874,7 +874,7 @@ static void i440fx_pcihost_class_init(ObjectClass *klass, void *data)
|
||||||
dc->fw_name = "pci";
|
dc->fw_name = "pci";
|
||||||
dc->props = i440fx_props;
|
dc->props = i440fx_props;
|
||||||
/* Reason: needs to be wired up by pc_init1 */
|
/* Reason: needs to be wired up by pc_init1 */
|
||||||
dc->cannot_instantiate_with_device_add_yet = true;
|
dc->user_creatable = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const TypeInfo i440fx_pcihost_info = {
|
static const TypeInfo i440fx_pcihost_info = {
|
||||||
|
|
|
@ -508,7 +508,7 @@ static void e500_host_bridge_class_init(ObjectClass *klass, void *data)
|
||||||
* PCI-facing part of the host bridge, not usable without the
|
* PCI-facing part of the host bridge, not usable without the
|
||||||
* host-facing part, which can't be device_add'ed, yet.
|
* host-facing part, which can't be device_add'ed, yet.
|
||||||
*/
|
*/
|
||||||
dc->cannot_instantiate_with_device_add_yet = true;
|
dc->user_creatable = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const TypeInfo e500_host_bridge_info = {
|
static const TypeInfo e500_host_bridge_info = {
|
||||||
|
|
|
@ -364,7 +364,7 @@ static void raven_class_init(ObjectClass *klass, void *data)
|
||||||
* Reason: PCI-facing part of the host bridge, not usable without
|
* Reason: PCI-facing part of the host bridge, not usable without
|
||||||
* the host-facing part, which can't be device_add'ed, yet.
|
* the host-facing part, which can't be device_add'ed, yet.
|
||||||
*/
|
*/
|
||||||
dc->cannot_instantiate_with_device_add_yet = true;
|
dc->user_creatable = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const TypeInfo raven_info = {
|
static const TypeInfo raven_info = {
|
||||||
|
|
|
@ -156,7 +156,7 @@ static void q35_host_class_init(ObjectClass *klass, void *data)
|
||||||
dc->realize = q35_host_realize;
|
dc->realize = q35_host_realize;
|
||||||
dc->props = mch_props;
|
dc->props = mch_props;
|
||||||
/* Reason: needs to be wired up by pc_q35_init */
|
/* Reason: needs to be wired up by pc_q35_init */
|
||||||
dc->cannot_instantiate_with_device_add_yet = true;
|
dc->user_creatable = false;
|
||||||
set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
|
set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
|
||||||
dc->fw_name = "pci";
|
dc->fw_name = "pci";
|
||||||
}
|
}
|
||||||
|
@ -549,7 +549,7 @@ static void mch_class_init(ObjectClass *klass, void *data)
|
||||||
* PCI-facing part of the host bridge, not usable without the
|
* PCI-facing part of the host bridge, not usable without the
|
||||||
* host-facing part, which can't be device_add'ed, yet.
|
* host-facing part, which can't be device_add'ed, yet.
|
||||||
*/
|
*/
|
||||||
dc->cannot_instantiate_with_device_add_yet = true;
|
dc->user_creatable = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const TypeInfo mch_info = {
|
static const TypeInfo mch_info = {
|
||||||
|
|
|
@ -366,7 +366,7 @@ static void unin_main_pci_host_class_init(ObjectClass *klass, void *data)
|
||||||
* PCI-facing part of the host bridge, not usable without the
|
* PCI-facing part of the host bridge, not usable without the
|
||||||
* host-facing part, which can't be device_add'ed, yet.
|
* host-facing part, which can't be device_add'ed, yet.
|
||||||
*/
|
*/
|
||||||
dc->cannot_instantiate_with_device_add_yet = true;
|
dc->user_creatable = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const TypeInfo unin_main_pci_host_info = {
|
static const TypeInfo unin_main_pci_host_info = {
|
||||||
|
@ -390,7 +390,7 @@ static void u3_agp_pci_host_class_init(ObjectClass *klass, void *data)
|
||||||
* PCI-facing part of the host bridge, not usable without the
|
* PCI-facing part of the host bridge, not usable without the
|
||||||
* host-facing part, which can't be device_add'ed, yet.
|
* host-facing part, which can't be device_add'ed, yet.
|
||||||
*/
|
*/
|
||||||
dc->cannot_instantiate_with_device_add_yet = true;
|
dc->user_creatable = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const TypeInfo u3_agp_pci_host_info = {
|
static const TypeInfo u3_agp_pci_host_info = {
|
||||||
|
@ -414,7 +414,7 @@ static void unin_agp_pci_host_class_init(ObjectClass *klass, void *data)
|
||||||
* PCI-facing part of the host bridge, not usable without the
|
* PCI-facing part of the host bridge, not usable without the
|
||||||
* host-facing part, which can't be device_add'ed, yet.
|
* host-facing part, which can't be device_add'ed, yet.
|
||||||
*/
|
*/
|
||||||
dc->cannot_instantiate_with_device_add_yet = true;
|
dc->user_creatable = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const TypeInfo unin_agp_pci_host_info = {
|
static const TypeInfo unin_agp_pci_host_info = {
|
||||||
|
@ -438,7 +438,7 @@ static void unin_internal_pci_host_class_init(ObjectClass *klass, void *data)
|
||||||
* PCI-facing part of the host bridge, not usable without the
|
* PCI-facing part of the host bridge, not usable without the
|
||||||
* host-facing part, which can't be device_add'ed, yet.
|
* host-facing part, which can't be device_add'ed, yet.
|
||||||
*/
|
*/
|
||||||
dc->cannot_instantiate_with_device_add_yet = true;
|
dc->user_creatable = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const TypeInfo unin_internal_pci_host_info = {
|
static const TypeInfo unin_internal_pci_host_info = {
|
||||||
|
|
|
@ -479,7 +479,7 @@ static void versatile_pci_host_class_init(ObjectClass *klass, void *data)
|
||||||
* PCI-facing part of the host bridge, not usable without the
|
* PCI-facing part of the host bridge, not usable without the
|
||||||
* host-facing part, which can't be device_add'ed, yet.
|
* host-facing part, which can't be device_add'ed, yet.
|
||||||
*/
|
*/
|
||||||
dc->cannot_instantiate_with_device_add_yet = true;
|
dc->user_creatable = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const TypeInfo versatile_pci_host_info = {
|
static const TypeInfo versatile_pci_host_info = {
|
||||||
|
|
|
@ -309,7 +309,7 @@ static void xilinx_pcie_root_class_init(ObjectClass *klass, void *data)
|
||||||
* PCI-facing part of the host bridge, not usable without the
|
* PCI-facing part of the host bridge, not usable without the
|
||||||
* host-facing part, which can't be device_add'ed, yet.
|
* host-facing part, which can't be device_add'ed, yet.
|
||||||
*/
|
*/
|
||||||
dc->cannot_instantiate_with_device_add_yet = true;
|
dc->user_creatable = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const TypeInfo xilinx_pcie_root_info = {
|
static const TypeInfo xilinx_pcie_root_info = {
|
||||||
|
|
|
@ -1083,6 +1083,7 @@ static void pci_qdev_unrealize(DeviceState *dev, Error **errp)
|
||||||
pc->exit(pci_dev);
|
pc->exit(pci_dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pci_device_deassert_intx(pci_dev);
|
||||||
do_pci_unregister_device(pci_dev);
|
do_pci_unregister_device(pci_dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -351,7 +351,7 @@ static void ppc4xx_host_bridge_class_init(ObjectClass *klass, void *data)
|
||||||
* PCI-facing part of the host bridge, not usable without the
|
* PCI-facing part of the host bridge, not usable without the
|
||||||
* host-facing part, which can't be device_add'ed, yet.
|
* host-facing part, which can't be device_add'ed, yet.
|
||||||
*/
|
*/
|
||||||
dc->cannot_instantiate_with_device_add_yet = true;
|
dc->user_creatable = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const TypeInfo ppc4xx_host_bridge_info = {
|
static const TypeInfo ppc4xx_host_bridge_info = {
|
||||||
|
|
|
@ -2508,20 +2508,6 @@ static void spapr_memory_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
|
||||||
uint64_t align = memory_region_get_alignment(mr);
|
uint64_t align = memory_region_get_alignment(mr);
|
||||||
uint64_t size = memory_region_size(mr);
|
uint64_t size = memory_region_size(mr);
|
||||||
uint64_t addr;
|
uint64_t addr;
|
||||||
char *mem_dev;
|
|
||||||
|
|
||||||
if (size % SPAPR_MEMORY_BLOCK_SIZE) {
|
|
||||||
error_setg(&local_err, "Hotplugged memory size must be a multiple of "
|
|
||||||
"%lld MB", SPAPR_MEMORY_BLOCK_SIZE/M_BYTE);
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
mem_dev = object_property_get_str(OBJECT(dimm), PC_DIMM_MEMDEV_PROP, NULL);
|
|
||||||
if (mem_dev && !kvmppc_is_mem_backend_page_size_ok(mem_dev)) {
|
|
||||||
error_setg(&local_err, "Memory backend has bad page size. "
|
|
||||||
"Use 'memory-backend-file' with correct mem-path.");
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
pc_dimm_memory_plug(dev, &ms->hotplug_memory, mr, align, &local_err);
|
pc_dimm_memory_plug(dev, &ms->hotplug_memory, mr, align, &local_err);
|
||||||
if (local_err) {
|
if (local_err) {
|
||||||
|
@ -2542,6 +2528,32 @@ out:
|
||||||
error_propagate(errp, local_err);
|
error_propagate(errp, local_err);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void spapr_memory_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
|
||||||
|
Error **errp)
|
||||||
|
{
|
||||||
|
PCDIMMDevice *dimm = PC_DIMM(dev);
|
||||||
|
PCDIMMDeviceClass *ddc = PC_DIMM_GET_CLASS(dimm);
|
||||||
|
MemoryRegion *mr = ddc->get_memory_region(dimm);
|
||||||
|
uint64_t size = memory_region_size(mr);
|
||||||
|
char *mem_dev;
|
||||||
|
|
||||||
|
if (size % SPAPR_MEMORY_BLOCK_SIZE) {
|
||||||
|
error_setg(errp, "Hotplugged memory size must be a multiple of "
|
||||||
|
"%lld MB", SPAPR_MEMORY_BLOCK_SIZE / M_BYTE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
mem_dev = object_property_get_str(OBJECT(dimm), PC_DIMM_MEMDEV_PROP, NULL);
|
||||||
|
if (mem_dev && !kvmppc_is_mem_backend_page_size_ok(mem_dev)) {
|
||||||
|
error_setg(errp, "Memory backend has bad page size. "
|
||||||
|
"Use 'memory-backend-file' with correct mem-path.");
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
out:
|
||||||
|
g_free(mem_dev);
|
||||||
|
}
|
||||||
|
|
||||||
typedef struct sPAPRDIMMState {
|
typedef struct sPAPRDIMMState {
|
||||||
uint32_t nr_lmbs;
|
uint32_t nr_lmbs;
|
||||||
} sPAPRDIMMState;
|
} sPAPRDIMMState;
|
||||||
|
@ -2793,7 +2805,7 @@ static void spapr_core_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
|
||||||
if (cc->nr_threads != smp_threads) {
|
if (cc->nr_threads != smp_threads) {
|
||||||
error_setg(errp, "invalid nr-threads %d, must be %d",
|
error_setg(errp, "invalid nr-threads %d, must be %d",
|
||||||
cc->nr_threads, smp_threads);
|
cc->nr_threads, smp_threads);
|
||||||
return;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
core_slot = spapr_find_cpu_slot(MACHINE(hotplug_dev), cc->core_id, &index);
|
core_slot = spapr_find_cpu_slot(MACHINE(hotplug_dev), cc->core_id, &index);
|
||||||
|
@ -2912,7 +2924,9 @@ static void spapr_machine_device_unplug_request(HotplugHandler *hotplug_dev,
|
||||||
static void spapr_machine_device_pre_plug(HotplugHandler *hotplug_dev,
|
static void spapr_machine_device_pre_plug(HotplugHandler *hotplug_dev,
|
||||||
DeviceState *dev, Error **errp)
|
DeviceState *dev, Error **errp)
|
||||||
{
|
{
|
||||||
if (object_dynamic_cast(OBJECT(dev), TYPE_SPAPR_CPU_CORE)) {
|
if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) {
|
||||||
|
spapr_memory_pre_plug(hotplug_dev, dev, errp);
|
||||||
|
} else if (object_dynamic_cast(OBJECT(dev), TYPE_SPAPR_CPU_CORE)) {
|
||||||
spapr_core_pre_plug(hotplug_dev, dev, errp);
|
spapr_core_pre_plug(hotplug_dev, dev, errp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -675,7 +675,7 @@ static void spapr_dr_connector_class_init(ObjectClass *k, void *data)
|
||||||
/*
|
/*
|
||||||
* Reason: it crashes FIXME find and document the real reason
|
* Reason: it crashes FIXME find and document the real reason
|
||||||
*/
|
*/
|
||||||
dk->cannot_instantiate_with_device_add_yet = true;
|
dk->user_creatable = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const TypeInfo spapr_dr_connector_info = {
|
static const TypeInfo spapr_dr_connector_info = {
|
||||||
|
|
|
@ -618,6 +618,8 @@ static void spapr_tce_table_class_init(ObjectClass *klass, void *data)
|
||||||
dc->init = spapr_tce_table_realize;
|
dc->init = spapr_tce_table_realize;
|
||||||
dc->reset = spapr_tce_reset;
|
dc->reset = spapr_tce_reset;
|
||||||
dc->unrealize = spapr_tce_table_unrealize;
|
dc->unrealize = spapr_tce_table_unrealize;
|
||||||
|
/* Reason: This is just an internal device for handling the hypercalls */
|
||||||
|
dc->user_creatable = false;
|
||||||
|
|
||||||
QLIST_INIT(&spapr_tce_tables);
|
QLIST_INIT(&spapr_tce_tables);
|
||||||
|
|
||||||
|
|
|
@ -1893,20 +1893,6 @@ static void spapr_pci_pre_save(void *opaque)
|
||||||
gpointer key, value;
|
gpointer key, value;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
g_free(sphb->msi_devs);
|
|
||||||
sphb->msi_devs = NULL;
|
|
||||||
sphb->msi_devs_num = g_hash_table_size(sphb->msi);
|
|
||||||
if (!sphb->msi_devs_num) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
sphb->msi_devs = g_malloc(sphb->msi_devs_num * sizeof(spapr_pci_msi_mig));
|
|
||||||
|
|
||||||
g_hash_table_iter_init(&iter, sphb->msi);
|
|
||||||
for (i = 0; g_hash_table_iter_next(&iter, &key, &value); ++i) {
|
|
||||||
sphb->msi_devs[i].key = *(uint32_t *) key;
|
|
||||||
sphb->msi_devs[i].value = *(spapr_pci_msi *) value;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sphb->pre_2_8_migration) {
|
if (sphb->pre_2_8_migration) {
|
||||||
sphb->mig_liobn = sphb->dma_liobn[0];
|
sphb->mig_liobn = sphb->dma_liobn[0];
|
||||||
sphb->mig_mem_win_addr = sphb->mem_win_addr;
|
sphb->mig_mem_win_addr = sphb->mem_win_addr;
|
||||||
|
@ -1920,6 +1906,20 @@ static void spapr_pci_pre_save(void *opaque)
|
||||||
sphb->mig_mem_win_size += sphb->mem64_win_size;
|
sphb->mig_mem_win_size += sphb->mem64_win_size;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_free(sphb->msi_devs);
|
||||||
|
sphb->msi_devs = NULL;
|
||||||
|
sphb->msi_devs_num = g_hash_table_size(sphb->msi);
|
||||||
|
if (!sphb->msi_devs_num) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
sphb->msi_devs = g_malloc(sphb->msi_devs_num * sizeof(spapr_pci_msi_mig));
|
||||||
|
|
||||||
|
g_hash_table_iter_init(&iter, sphb->msi);
|
||||||
|
for (i = 0; g_hash_table_iter_next(&iter, &key, &value); ++i) {
|
||||||
|
sphb->msi_devs[i].key = *(uint32_t *) key;
|
||||||
|
sphb->msi_devs[i].value = *(spapr_pci_msi *) value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int spapr_pci_post_load(void *opaque, int version_id)
|
static int spapr_pci_post_load(void *opaque, int version_id)
|
||||||
|
|
|
@ -191,6 +191,8 @@ static void spapr_rtc_class_init(ObjectClass *oc, void *data)
|
||||||
|
|
||||||
dc->realize = spapr_rtc_realize;
|
dc->realize = spapr_rtc_realize;
|
||||||
dc->vmsd = &vmstate_spapr_rtc;
|
dc->vmsd = &vmstate_spapr_rtc;
|
||||||
|
/* Reason: This is an internal device only for handling the hypercalls */
|
||||||
|
dc->user_creatable = false;
|
||||||
|
|
||||||
spapr_rtas_register(RTAS_GET_TIME_OF_DAY, "get-time-of-day",
|
spapr_rtas_register(RTAS_GET_TIME_OF_DAY, "get-time-of-day",
|
||||||
rtas_get_time_of_day);
|
rtas_get_time_of_day);
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue