diff options
| author | Markus Armbruster <armbru@redhat.com> | 2014-09-30 13:59:30 +0200 |
|---|---|---|
| committer | Stefan Hajnoczi <stefanha@redhat.com> | 2014-10-03 10:30:33 +0100 |
| commit | f5bebbbb28dc7a149a891f0f1e112fb50bb72664 (patch) | |
| tree | 8bf30a59e4ce61326a92cefc7d03036104bdb170 /block.c | |
| parent | d93162e13c1f4a5b2a4de6b1997f32e3fca19e67 (diff) | |
| download | focaccia-qemu-f5bebbbb28dc7a149a891f0f1e112fb50bb72664.tar.gz focaccia-qemu-f5bebbbb28dc7a149a891f0f1e112fb50bb72664.zip | |
util: Emancipate id_wellformed() from QemuOpts
IDs have long spread beyond QemuOpts: not everything with an ID necessarily goes through QemuOpts. Commit 9aebf3b is about such a case: block layer names are meant to be well-formed IDs, but some of them don't go through QemuOpts, and thus weren't checked. The commit fixed that the straightforward way: rename the internal QemuOpts helper id_wellformed() to qemu_opts_id_wellformed() and give it external linkage. Instead of using it directly in block.c, the commit adds wrapper bdrv_is_valid_name(), probably to hide the connection to QemuOpts. Go one logical step further: emancipate IDs from QemuOpts. Rename the function back to id_wellformed(), and put it in another file. While there, clean up its value to bool. Peel off the bdrv_is_valid_name() wrapper. [Replaced stray return 0 with return false to match bool returns used elsewhere in id_wellformed(). --Stefan] Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'block.c')
| -rw-r--r-- | block.c | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/block.c b/block.c index c5a251c57e..d3aebeb050 100644 --- a/block.c +++ b/block.c @@ -335,18 +335,13 @@ void bdrv_register(BlockDriver *bdrv) QLIST_INSERT_HEAD(&bdrv_drivers, bdrv, list); } -static bool bdrv_is_valid_name(const char *name) -{ - return qemu_opts_id_wellformed(name); -} - /* create a new block device (by default it is empty) */ BlockDriverState *bdrv_new(const char *device_name, Error **errp) { BlockDriverState *bs; int i; - if (*device_name && !bdrv_is_valid_name(device_name)) { + if (*device_name && !id_wellformed(device_name)) { error_setg(errp, "Invalid device name"); return NULL; } @@ -874,7 +869,7 @@ static void bdrv_assign_node_name(BlockDriverState *bs, } /* Check for empty string or invalid characters */ - if (!bdrv_is_valid_name(node_name)) { + if (!id_wellformed(node_name)) { error_setg(errp, "Invalid node name"); return; } |