block: Fix libbz2 library dependency regresssion
v4 cover block: Fix libbz2 library dependency regresssion
v4: Remove unused variable in patch 1 and unwanted warning in patch 2. [Max]
v3: Fix typo in copyright header. [Max]
Fix pre-existing type casting. [Max]
v2: Rebase on top of Max's block-next tree, which has Colin's patches to
dynamically load block modules.
Two more tweaks to the module system is added.
v1 was submitted as a single patch:
https://lists.gnu.org/archive/html/qemu-devel/2016-08/msg00508.html
Fam Zheng (3):
scripts: Allow block module to not define BlockDriver
module: Don't load the same module if requested multiple times
dmg: Move libbz2 code to dmg-bz2.so
block/Makefile.objs | 3 +- block/dmg-bz2.c | 62 ++++++++++++++++++++++++++++++++++++ block/dmg.c | 69 ++++++++++------------------------------- block/dmg.h | 59 +++++++++++++++++++++++++++++++++++ scripts/modules/module_block.py | 7 ----- util/module.c | 18 +++++++++-- 6 files changed, 156 insertions(+), 62 deletions(-) create mode 100644 block/dmg-bz2.c create mode 100644 block/dmg.h
Signature · 1 line
2.7.4
PATCH v4 2/3 module: Don't load the same module if requested multiple times
Use a hash table to keep record of all loaded modules, and return early if the requested module is already loaded.
--- util/module.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-)
util/module.c +16 -2
@@ -163,14 +163,28 @@ void module_load_one(const char *prefix, const char *lib_name)char *fname =NULL ;char *exec_dir;char *dirs[3 ]; +char *module_name;int i =0 ;int ret; +static GHashTable *loaded_modules;if (!g_module_supported ()) {fprintf (stderr,"Module is not supported by system.\n" );return ; } +if (!loaded_modules) { + loaded_modules =g_hash_table_new (g_str_hash, g_str_equal); + } + + module_name =g_strdup_printf ("%s%s" , prefix, lib_name); + +if (g_hash_table_lookup (loaded_modules, module_name)) { +g_free (module_name); +return ; + } +g_hash_table_insert (loaded_modules, module_name, module_name); + exec_dir =qemu_get_exec_dir (); dirs[i++] =g_strdup_printf ("%s" ,CONFIG_QEMU_MODDIR ); dirs[i++] =g_strdup_printf ("%s/.." , exec_dir ? :"" );
@@ -180,8 +194,8 @@ void module_load_one(const char *prefix, const char *lib_name) exec_dir =NULL ;for (i =0 ; i <ARRAY_SIZE (dirs); i++) { - fname =g_strdup_printf ("%s/%s%s%s" , - dirs[i], prefix, lib_name,HOST_DSOSUF ); + fname =g_strdup_printf ("%s/%s%s" , + dirs[i], module_name,HOST_DSOSUF ); ret =module_load_file (fname);g_free (fname); fname =NULL ;
Signature · 1 line
2.7.4
PATCH v4 1/3 scripts: Allow block module to not define BlockDriver
In reply to Fam Zheng--- scripts/modules/module_block.py | 7 ------- 1 file changed, 7 deletions(-)
scripts/modules/module_block.py +0 -7
@@ -37,7 +37,6 @@ def add_module(fheader, library, format_name, protocol_name): def process_file(fheader, filename): # This parser assumes the coding style rules are being followed with open(filename, "r") as cfile: - found_something = False found_start = False library, _ = os.path.splitext(os.path.basename(filename)) for line in cfile:
@@ -51,16 +50,10 @@ def process_file(fheader, filename): add_module(fheader, library, format_name, protocol_name) found_start = False elif line.find("static BlockDriver") != -1: - found_something = True found_start = True format_name = "" protocol_name = "" - if not found_something: - print("No BlockDriver struct found in " + filename + ". \ - Is this really a module?", file=sys.stderr) - sys.exit(1) - def print_top(fheader): fheader.write('''/* AUTOMATICALLY GENERATED, DO NOT MODIFY */ /*
Signature · 1 line
2.7.4
PATCH v4 3/3 dmg: Move libbz2 code to dmg-bz2.so
In reply to Fam Zhengdmg.o was moved to block-obj-m in 5505e8b76 to become a separate module, so that its reference to libbz2, since 6b383c08c, doesn't add an extra library to the main executable.
Until recently, commit 06e60f70a (blockdev: Add dynamic module loading for block drivers) moved it back to block-obj-y to simplify the design of dynamic loading of block modules. But we don't want to lose the feature of less library dependency on the main executable.
The solution here is to move only the bz2 related code to a separate DSO file, and load it when dmg_open is called.
dmg_probe doesn't depend on bz2 support to work, and is the only code in this file which can run before dmg_open.
While we are at it, fix the unhelpful cast of last argument passed to dmg_uncompress_bz2.
--- block/Makefile.objs | 3 ++- block/dmg-bz2.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++ block/dmg.c | 69 +++++++++++++---------------------------------------- block/dmg.h | 59 +++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 140 insertions(+), 53 deletions(-) create mode 100644 block/dmg-bz2.c create mode 100644 block/dmg.h
block/Makefile.objs +2 -1
@@ -40,6 +40,7 @@ gluster.o-libs := $(GLUSTERFS_LIBS) ssh.o-cflags := $(LIBSSH2_CFLAGS) ssh.o-libs := $(LIBSSH2_LIBS) archipelago.o-libs := $(ARCHIPELAGO_LIBS) -dmg.o-libs := $(BZIP2_LIBS) +block-obj-$(if $(CONFIG_BZIP2),m,n) += dmg-bz2.o +dmg-bz2.o-libs := $(BZIP2_LIBS) qcow.o-libs := -lz linux-aio.o-libs := -laio
block/dmg-bz2.c new file +62 -0
62 lines not on this page · raw message
block/dmg.c +17 -52
115 lines not on this page · raw message
block/dmg.h new file +59 -0
59 lines not on this page · raw message
Signature · 1 line
2.7.4
Quoted 18 lines · Fam Zheng
v4: Remove unused variable in patch 1 and unwanted warning in patch 2. [Max]
v3: Fix typo in copyright header. [Max]
Fix pre-existing type casting. [Max]v2: Rebase on top of Max's block-next tree, which has Colin's patches to
dynamically load block modules.
Two more tweaks to the module system is added.v1 was submitted as a single patch:
https://lists.gnu.org/archive/html/qemu-devel/2016-08/msg00508.html
Fam Zheng (3):
scripts: Allow block module to not define BlockDriver
module: Don't load the same module if requested multiple times
dmg: Move libbz2 code to dmg-bz2.so
Quoted 13 lines
block/Makefile.objs | 3 +- block/dmg-bz2.c | 62 ++++++++++++++++++++++++++++++++++++ block/dmg.c | 69 ++++++++++------------------------------- block/dmg.h | 59 +++++++++++++++++++++++++++++++++++ scripts/modules/module_block.py | 7 ----- util/module.c | 18 +++++++++-- 6 files changed, 156 insertions(+), 62 deletions(-) create mode 100644 block/dmg-bz2.c create mode 100644 block/dmg.hSignature · 1 line
2.7.4
Quoted 18 lines · Fam Zheng
v4: Remove unused variable in patch 1 and unwanted warning in patch 2. [Max]
v3: Fix typo in copyright header. [Max]
Fix pre-existing type casting. [Max]v2: Rebase on top of Max's block-next tree, which has Colin's patches to
dynamically load block modules.
Two more tweaks to the module system is added.v1 was submitted as a single patch:
https://lists.gnu.org/archive/html/qemu-devel/2016-08/msg00508.html
Fam Zheng (3):
scripts: Allow block module to not define BlockDriver
module: Don't load the same module if requested multiple times
dmg: Move libbz2 code to dmg-bz2.so
Quoted 9 lines
block/Makefile.objs | 3 +- block/dmg-bz2.c | 62 ++++++++++++++++++++++++++++++++++++ block/dmg.c | 69 ++++++++++------------------------------- block/dmg.h | 59 +++++++++++++++++++++++++++++++++++ scripts/modules/module_block.py | 7 ----- util/module.c | 18 +++++++++-- 6 files changed, 156 insertions(+), 62 deletions(-) create mode 100644 block/dmg-bz2.c create mode 100644 block/dmg.h
Max was the last one to comment on this series. I'll wait for him to review this before applying it.
Quoted 29 lines · Stefan Hajnoczi
Quoted 18 lines · Fam Zheng
v4: Remove unused variable in patch 1 and unwanted warning in patch 2. [Max]
v3: Fix typo in copyright header. [Max]
Fix pre-existing type casting. [Max]v2: Rebase on top of Max's block-next tree, which has Colin's patches to
dynamically load block modules.
Two more tweaks to the module system is added.v1 was submitted as a single patch:
https://lists.gnu.org/archive/html/qemu-devel/2016-08/msg00508.html
Fam Zheng (3):
scripts: Allow block module to not define BlockDriver
module: Don't load the same module if requested multiple times
dmg: Move libbz2 code to dmg-bz2.soQuoted 9 lines
block/Makefile.objs | 3 +- block/dmg-bz2.c | 62 ++++++++++++++++++++++++++++++++++++ block/dmg.c | 69 ++++++++++------------------------------- block/dmg.h | 59 +++++++++++++++++++++++++++++++++++ scripts/modules/module_block.py | 7 ----- util/module.c | 18 +++++++++-- 6 files changed, 156 insertions(+), 62 deletions(-) create mode 100644 block/dmg-bz2.c create mode 100644 block/dmg.h
Quoted 2 lines
Max was the last one to comment on this series. I'll wait for him to review this before applying it.
Looks good to me, but I'm afraid this series might depend on my block-next (now block) branch which has not been merged to master yet, actually. So maybe I should apply it instead? ;-)
Max
Quoted 30 lines · Max Reitz
Quoted 29 lines · Stefan Hajnoczi
Quoted 27 lines · Fam Zheng
v4: Remove unused variable in patch 1 and unwanted warning in patch 2. [Max]
v3: Fix typo in copyright header. [Max]
Fix pre-existing type casting. [Max]v2: Rebase on top of Max's block-next tree, which has Colin's patches to
dynamically load block modules.
Two more tweaks to the module system is added.v1 was submitted as a single patch:
https://lists.gnu.org/archive/html/qemu-devel/2016-08/msg00508.html
Fam Zheng (3):
scripts: Allow block module to not define BlockDriver
module: Don't load the same module if requested multiple times
dmg: Move libbz2 code to dmg-bz2.soblock/Makefile.objs | 3 +- block/dmg-bz2.c | 62 ++++++++++++++++++++++++++++++++++++ block/dmg.c | 69 ++++++++++------------------------------- block/dmg.h | 59 +++++++++++++++++++++++++++++++++++ scripts/modules/module_block.py | 7 ----- util/module.c | 18 +++++++++-- 6 files changed, 156 insertions(+), 62 deletions(-) create mode 100644 block/dmg-bz2.c create mode 100644 block/dmg.h
Quoted 6 lines
Quoted 2 lines
Max was the last one to comment on this series. I'll wait for him to review this before applying it.
Looks good to me, but I'm afraid this series might depend on my block-next (now block) branch which has not been merged to master yet, actually. So maybe I should apply it instead? ;-)
Yes, please!
Fam
Quoted 30 lines · Max Reitz
Quoted 29 lines · Stefan Hajnoczi
Quoted 27 lines · Fam Zheng
v4: Remove unused variable in patch 1 and unwanted warning in patch 2. [Max]
v3: Fix typo in copyright header. [Max]
Fix pre-existing type casting. [Max]v2: Rebase on top of Max's block-next tree, which has Colin's patches to
dynamically load block modules.
Two more tweaks to the module system is added.v1 was submitted as a single patch:
https://lists.gnu.org/archive/html/qemu-devel/2016-08/msg00508.html
Fam Zheng (3):
scripts: Allow block module to not define BlockDriver
module: Don't load the same module if requested multiple times
dmg: Move libbz2 code to dmg-bz2.soblock/Makefile.objs | 3 +- block/dmg-bz2.c | 62 ++++++++++++++++++++++++++++++++++++ block/dmg.c | 69 ++++++++++------------------------------- block/dmg.h | 59 +++++++++++++++++++++++++++++++++++ scripts/modules/module_block.py | 7 ----- util/module.c | 18 +++++++++-- 6 files changed, 156 insertions(+), 62 deletions(-) create mode 100644 block/dmg-bz2.c create mode 100644 block/dmg.h
Quoted 6 lines
Quoted 2 lines
Max was the last one to comment on this series. I'll wait for him to review this before applying it.
Looks good to me, but I'm afraid this series might depend on my block-next (now block) branch which has not been merged to master yet, actually. So maybe I should apply it instead? ;-)
Yes, that's fine.
Stefan
Max Reitz
AppliedQuoted 18 lines · Fam Zheng
v4: Remove unused variable in patch 1 and unwanted warning in patch 2. [Max]
v3: Fix typo in copyright header. [Max]
Fix pre-existing type casting. [Max]v2: Rebase on top of Max's block-next tree, which has Colin's patches to
dynamically load block modules.
Two more tweaks to the module system is added.v1 was submitted as a single patch:
https://lists.gnu.org/archive/html/qemu-devel/2016-08/msg00508.html
Fam Zheng (3):
scripts: Allow block module to not define BlockDriver
module: Don't load the same module if requested multiple times
dmg: Move libbz2 code to dmg-bz2.so
Quoted 9 lines
block/Makefile.objs | 3 +- block/dmg-bz2.c | 62 ++++++++++++++++++++++++++++++++++++ block/dmg.c | 69 ++++++++++------------------------------- block/dmg.h | 59 +++++++++++++++++++++++++++++++++++ scripts/modules/module_block.py | 7 ----- util/module.c | 18 +++++++++-- 6 files changed, 156 insertions(+), 62 deletions(-) create mode 100644 block/dmg-bz2.c create mode 100644 block/dmg.h
Thanks, applied to my block branch:
https://github.com/XanClic/qemu/commits/block
Max