Convert block infrastructure to use new module init functionality
A message that is not in the archive (sent off-list or not yet received): [email protected]
[sent to wrong list]
Anfang der weitergeleiteten E-Mail:
Quoted 22 lines
Von: Andreas Färber <[email protected]>
Datum: 30. Mai 2009 18:05:18 MESZ
An: Anthony Liguori <[email protected]>
Kopie: [email protected], Ben Taylor <[email protected]>
Betreff: Re: [Qemu-commits] [COMMIT 5efa9d5] Convert block infrastructure to use new module init functionalityHello Anthony,
Am 14.05.2009 um 23:16 schrieb Anthony Liguori:
Quoted 3 lines
From: Anthony Liguori <[email protected]>
Signed-off-by Anthony Liguori <[email protected]>This commit
5efa9d5a8b18841c9c62208a494d7f519238979aappears to have broken the plain old -hda option (for both raw and qcow2 images) on OpenSolaris.Starting with this commit, qemu-system-sparc segfaults immediately; you later fixed it in
c833ab7351f2ebac46740380a81e34482e208dcc(Fix segv when passing an unknown protocol) to no longer segfault, now printing "qemu: could not read disk image /path/to/image".Any ideas?
Andreas
Quoted 7 lines
Quoted 7 lines
Starting with this commit, qemu-system-sparc segfaults immediately; you later fixed it in
c833ab7351f2ebac46740380a81e34482e208dcc(Fix segv when passing an unknown protocol) to no longer segfault, now printing "qemu: could not read disk image /path/to/image".
I would assume -z,allextract isn't doing what we would like it to do on OpenSolaris. A pointer to an OpenSolaris ld man page would be a good start to help me track this down.
Regards,
Anthony Liguori
Quoted 7 lines
Quoted 4 lines
Any ideas?
Andreas
Quoted 10 lines · Anthony Liguori
Quoted 5 lines
Quoted 5 lines
Starting with this commit, qemu-system-sparc segfaults immediately; you later fixed it in
c833ab7351f2ebac46740380a81e34482e208dcc(Fix segv when passing an unknown protocol) to no longer segfault, now printing "qemu: could not read disk image /path/to/image".I would assume -z,allextract isn't doing what we would like it to do on OpenSolaris. A pointer to an OpenSolaris ld man page would be a good start to help me track this down.
I suggest dropping the linker hacks and including all the objects explicitly.
Signature · 1 line
error compiling committee.c: too many arguments to function
Am 31.05.2009 um 12:15 schrieb Anthony Liguori:
Quoted 8 lines
Quoted 5 lines
Quoted 5 lines
Starting with this commit, qemu-system-sparc segfaults immediately; you later fixed it in
c833ab7351f2ebac46740380a81e34482e208dcc(Fix segv when passing an unknown protocol) to no longer segfault, now printing "qemu: could not read disk image /path/to/image".I would assume -z,allextract isn't doing what we would like it to do on OpenSolaris.
It's actually using -Wl,--whole-archive (GNU ld version 2.15 on OpenSolaris 2009.06 snv_111b).
qemu-img correctly lists all the formats, which I thought was a test case for the linker option.
Andreas
Am 31.05.2009 um 15:29 schrieb Andreas Färber:
Quoted 9 lines
Am 31.05.2009 um 12:15 schrieb Anthony Liguori:
Quoted 6 lines
Quoted 5 lines
Quoted 5 lines
Starting with this commit, qemu-system-sparc segfaults immediately; you later fixed it in
c833ab7351f2ebac46740380a81e34482e208dcc(Fix segv when passing an unknown protocol) to no longer segfault, now printing "qemu: could not read disk image /path/to/image".
Quoted 4 lines
Quoted 2 lines
I would assume -z,allextract isn't doing what we would like it to do on OpenSolaris.
It's actually using -Wl,--whole-archive (GNU ld version 2.15 on OpenSolaris 2009.06
snv_111b).
Sorry, your assumption was actually right.
The above version string is from ld (/usr/gnu/bin/ld), but gcc is configured to use /usr/ccs/bin/ld instead, the usual suspect. Sun documents it to support both --whole-archive and -z allextract, which explains the detection and use of --Wl,--whole-archive.
Reordering the checks, so that -Wl,-z,allextract is preferred, does not help.
Quoted 1 line
qemu-imgcorrectly lists all the formats, which I thought was a test case for the linker option.
qemu -drive format=? appears to better mirror the actual block format support.
Trying to use ld directly for the LINK rule didn't work due to architectural mismatches - it kept the output format as i386 despite any -A or -b elf64-x86-64 flags I set (-m64 didn't seem to be valid).
If I manually link ../block/raw-posix.o into i386-softmmu's $(QEMU_PROG), then instead of the original error message I get "qemu: hardware error: Unknown device 'smbus-eeprom'" followed by a segfault. I assume this is due to libqemuhw64.a. With upstream qemu, the Supported formats list is empty, with ../block/raw-posix.o linked in, it reads "host_device raw".
So it seems linking object files works while linking static libraries does not.
Architecturally the problem appears to be that the set of objects to link is determined in Makefile and Makefile.hw but is unknown to Makefile.target, where the problematic linking happens.
As a workaround, I've written the respective set of $(OBJS) to a file when linking and appending them to the LINK command. Except for two warnings (../aio.h and ../cache-utils.o linked twice) this works fine and makes BeOS boot up again.
Most likely someone will have a more efficient idea how to get the list of objects to Makefile.target and how to make the list unique to avoid warnings.
Andreas
Makefile +2 -0
@@ -229,6 +229,8 @@ curses.o: curses.c keymaps.h curses_keys.h bt-host.o: CFLAGS += $(CONFIG_BLUEZ_CFLAGS) libqemu_common.a: $(OBJS) + rm libqemu_common.mak + for o in $(OBJS); do echo ../$$o >> libqemu_common.mak; done
#######################################################################
# USER_OBJS is code used by qemu userspace emulation
Makefile.hw +2 -0
@@ -33,6 +33,8 @@ all: $(HWLIB) @true $(HWLIB): $(OBJS) + -rm -f $(HWLIB).list + for o in $(OBJS); do echo ../libhw64/$$o >> $(HWLIB).list; done clean: rm -f *.o *.d *.a *~
Makefile.target +0 -0
@@ -735,9 +735,9 @@ vl.o: qemu-options.h monitor.o: qemu-monitor.h $(QEMU_PROG): LIBS += $(SDL_LIBS) $(COCOA_LIBS) $(CURSES_LIBS) $
(BRLAPI_LIBS) $(VDE_LIBS) $(CURL_LIBS) -$(QEMU_PROG): ARLIBS=../libqemu_common.a libqemu.a $(HWLIB) +$(QEMU_PROG): ARLIBS=libqemu.a
$(QEMU_PROG): $(OBJS) ../libqemu_common.a libqemu.a $(HWLIB)
- $(call LINK,$(OBJS))
+ $(call LINK,$(OBJS) cat ../libqemu_common.mak cat $(HWLIB).list)
endif # !CONFIG_USER_ONLY
Makefile +2 -0
@@ -229,6 +229,8 @@ curses.o: curses.c keymaps.h curses_keys.h bt-host.o: CFLAGS += $(CONFIG_BLUEZ_CFLAGS) libqemu_common.a: $(OBJS) + rm libqemu_common.mak + for o in $(OBJS); do echo ../$$o >> libqemu_common.mak; done ####################################################################### # USER_OBJS is code used by qemu userspace emulation
Makefile.hw +2 -0
@@ -33,6 +33,8 @@ all: $(HWLIB) @true $(HWLIB): $(OBJS) + -rm -f $(HWLIB).list + for o in $(OBJS); do echo ../libhw64/$$o >> $(HWLIB).list; done clean: rm -f *.o *.d *.a *~
Makefile.target +2 -2
@@ -735,9 +735,9 @@ vl.o: qemu-options.h monitor.o: qemu-monitor.h $(QEMU_PROG): LIBS += $(SDL_LIBS) $(COCOA_LIBS) $(CURSES_LIBS) $(BRLAPI_LIBS) $(VDE_LIBS) $(CURL_LIBS) -$(QEMU_PROG): ARLIBS=../libqemu_common.a libqemu.a $(HWLIB) +$(QEMU_PROG): ARLIBS=libqemu.a $(QEMU_PROG): $(OBJS) ../libqemu_common.a libqemu.a $(HWLIB) - $(call LINK,$(OBJS)) + $(call LINK,$(OBJS) `cat ../libqemu_common.mak` `cat $(HWLIB).list`) endif # !CONFIG_USER_ONLY
RFC 1/1 Avoiding --whole-archive (was: [COMMIT 5efa9d5] Convert block infrastructure to use new module init functionality)
Am 13.06.2009 um 22:40 schrieb Andreas Färber:
Quoted 11 lines
Am 31.05.2009 um 15:29 schrieb Andreas Färber:
Quoted 9 lines
Am 31.05.2009 um 12:15 schrieb Anthony Liguori:
Quoted 7 lines
Quoted 4 lines
Quoted 4 lines
Starting with this commit, qemu-system-sparc segfaults immediately; you later fixed it in
c833ab7351f2ebac46740380a81e34482e208dcc(Fix segv when passing an unknown protocol) to no longer segfault, now printing "qemu: could not read disk image /path/to/image".I would assume -z,allextract isn't doing what we would like it to do on OpenSolaris.
[...]
Quoted 1 line
your assumption was actually right.
[...]
Quoted 4 lines
it seems linking object files works while linking static libraries does not.
Architecturally the problem appears to be that the set of objects to link is determined in
Makefileand Makefile.hw but is unknown to Makefile.target, where the problematic linking happens.
As a workaround, I've written the respective set of $(OBJS) to a file when linking and appending them to the LINK command. Except for two warnings (../aio.hand../cache-utils.olinked twice) this works fine and makes BeOS boot up again.
I came up with another workaround myself, that is using Makefile pseudotargets plus some Makefile magic to fetch the contents of $(OBJS) from Makefile.target. I then misuse the $(sort ) function to eliminate duplicates and thus linker warnings.
Linux/sparc and BeOS/i386 still boot okay despite the reordering.
Comments? Better ideas?
Andreas
Makefile +3 -0
@@ -230,6 +230,9 @@ bt-host.o: CFLAGS += $(CONFIG_BLUEZ_CFLAGS) libqemu_common.a: $(OBJS) +libqemu_common.a-OBJS: + @for o in $(OBJS); do echo ../$$o; done +
#######################################################################
# USER_OBJS is code used by qemu userspace emulation USER_OBJS=cutils.o cache-utils.o
Makefile.hw +3 -0
@@ -34,6 +34,9 @@ all: $(HWLIB) $(HWLIB): $(OBJS) +$(HWLIB)-OBJS: + @for o in $(OBJS); do echo ../$(notdir $(abspath .))/$$o; done + clean: rm -f *.o *.d *.a *~
Makefile.target +0 -0
@@ -735,9 +735,9 @@ vl.o: qemu-options.h monitor.o: qemu-monitor.h $(QEMU_PROG): LIBS += $(SDL_LIBS) $(COCOA_LIBS) $(CURSES_LIBS) $
(BRLAPI_LIBS) $(VDE_LIBS) $(CURL_LIBS) -$(QEMU_PROG): ARLIBS=../libqemu_common.a libqemu.a $(HWLIB) +$(QEMU_PROG): ARLIBS=libqemu.a
$(QEMU_PROG): $(OBJS) ../libqemu_common.a libqemu.a $(HWLIB)
- $(call LINK,$(OBJS))
+ $(call LINK,$(sort $(OBJS) $(shell $(MAKE) -C .. --no-print-directory libqemu_common.a-OBJS) $(shell $(MAKE) -C $(dir $(HWLIB)) --no-print-directory $(notdir $(HWLIB))-OBJS)))
endif # !CONFIG_USER_ONLY
Makefile +3 -0
@@ -230,6 +230,9 @@ bt-host.o: CFLAGS += $(CONFIG_BLUEZ_CFLAGS) libqemu_common.a: $(OBJS) +libqemu_common.a-OBJS: + @for o in $(OBJS); do echo ../$$o; done + ####################################################################### # USER_OBJS is code used by qemu userspace emulation USER_OBJS=cutils.o cache-utils.o
Makefile.hw +3 -0
@@ -34,6 +34,9 @@ all: $(HWLIB) $(HWLIB): $(OBJS) +$(HWLIB)-OBJS: + @for o in $(OBJS); do echo ../$(notdir $(abspath .))/$$o; done + clean: rm -f *.o *.d *.a *~
Makefile.target +2 -2
@@ -735,9 +735,9 @@ vl.o: qemu-options.h monitor.o: qemu-monitor.h $(QEMU_PROG): LIBS += $(SDL_LIBS) $(COCOA_LIBS) $(CURSES_LIBS) $(BRLAPI_LIBS) $(VDE_LIBS) $(CURL_LIBS) -$(QEMU_PROG): ARLIBS=../libqemu_common.a libqemu.a $(HWLIB) +$(QEMU_PROG): ARLIBS=libqemu.a $(QEMU_PROG): $(OBJS) ../libqemu_common.a libqemu.a $(HWLIB) - $(call LINK,$(OBJS)) + $(call LINK,$(sort $(OBJS) $(shell $(MAKE) -C .. --no-print-directory libqemu_common.a-OBJS) $(shell $(MAKE) -C $(dir $(HWLIB)) --no-print-directory $(notdir $(HWLIB))-OBJS))) endif # !CONFIG_USER_ONLY
Re: [Qemu-devel] [RFC] Avoiding --whole-archive
Quoted 10 lines · Andreas Färber
Quoted 4 lines
it seems linking object files works while linking static libraries does not.
Architecturally the problem appears to be that the set of objects to link is determined in
Makefileand Makefile.hw but is unknown to Makefile.target, where the problematic linking happens.
As a workaround, I've written the respective set of $(OBJS) to a file when linking and appending them to the LINK command. Except for two warnings (../aio.hand../cache-utils.olinked twice) this works fine and makes BeOS boot up again.I came up with another workaround myself, that is using
Makefilepseudotargets plus someMakefilemagic to fetch the contents of $(OBJS) from Makefile.target. I then misuse the $(sort ) function to eliminate duplicates and thus linker warnings.Linux/sparc and BeOS/i386 still boot okay despite the reordering.
Comments?
Way too clever, IMO. The danger here is that people will fear to edit the makefiles after this.
Quoted 2 lines
Better ideas?
Maybe a little bit better:
Makefile bt-host.o: CFLAGS += $(CONFIG_BLUEZ_CFLAGS) · line 235
Quoted 4 lines
Makefile +3
-0+libqemu_common.a-OBJS: + @for o in $(OBJS); do echo ../$$o; done +
libqemu_common.objlist: $(OBJS)
echo $(sort $(foreach obj, $^, $(shell readlink -f $(obj)))) > $@
Quoted 11 lines
$(QEMU_PROG): LIBS += $(SDL_LIBS) $(COCOA_LIBS) $(CURSES_LIBS)
$(BRLAPI_LIBS) $(VDE_LIBS) $(CURL_LIBS) -$(QEMU_PROG): ARLIBS=../libqemu_common.a libqemu.a $(HWLIB) +$(QEMU_PROG): ARLIBS=libqemu.a
$(QEMU_PROG): $(OBJS) ../libqemu_common.a libqemu.a $(HWLIB)(quoted diff) +1
-2- $(call LINK,$(OBJS)) + $(call LINK,$(sort $(OBJS) $(shell $(MAKE) -C .. --no-print-directory libqemu_common.a-OBJS) $(shell $(MAKE) -C $(dir$(HWLIB)) --no-print-directory $(notdir $(HWLIB))-OBJS)))
Here, depend on libqemu_common.objlist, and link it by including its contents in the link command line.
Oh, we could even make .objlist a linker script, except that's probably platform specific.
The real fix is building everything from a single makefile.
Signature · 1 line
error compiling committee.c: too many arguments to function
Re: [Qemu-devel] [RFC] Avoiding --whole-archive
In reply to Andreas FärberHello,
Am 14.06.2009 um 00:15 schrieb Andreas Färber:
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Am 31.05.2009 um 12:15 schrieb Anthony Liguori:
Quoted 7 lines
Quoted 4 lines
Quoted 4 lines
Starting with this commit, qemu-system-sparc segfaults immediately; you later fixed it in
c833ab7351f2ebac46740380a81e34482e208dcc(Fix segv when passing an unknown protocol) to no longer segfault, now printing "qemu: could not read disk image /path/to/image".I would assume -z,allextract isn't doing what we would like it to do on OpenSolaris.
This problem is still around after Juan's Makefile reorganizations.
Before, I had provided two alternative patches:
* The first version wrote the list of libqemu_common.a's and $(HWLIB)'s object files into a text file from Makefile[.hw] that was later read in Makefile.target.
* The second version was using dedicated Makefile[.hw] targets for printing the object files to stdout for use by Makefile.target, avoiding the need to write an intermediate file.
Avi had preferred a variation of the first version for reduced complexity.
Other ideas that crossed my mind were:
* using GNU ld directly instead of gcc for linking (broken by -Wl and some other LDFLAGS)
* extracting the .a archive to a temporary directory from the target Makefile and obtaining the names by ls *.o (similar to libtool)
Please decide what a patch should do to be accepted and to finally fix this issue.
Thanks,
Andreas
Re: [Qemu-devel] [RFC] Avoiding --whole-archive
Am 29.11.2009 um 15:17 schrieb Andreas Färber:
Quoted 18 lines
Am 14.06.2009 um 00:15 schrieb Andreas Färber:
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Am 31.05.2009 um 12:15 schrieb Anthony Liguori:
Quoted 7 lines
Quoted 4 lines
Quoted 4 lines
Starting with this commit, qemu-system-sparc segfaults immediately; you later fixed it in
c833ab7351f2ebac46740380a81e34482e208dcc(Fix segv when passing an unknown protocol) to no longer segfault, now printing "qemu: could not read disk image /path/to/image".I would assume -z,allextract isn't doing what we would like it to do on OpenSolaris.
This problem is still around after Juan's
Makefilereorganizations.Before, I had provided two alternative patches:
* The first version wrote the list of libqemu_common.a's and $(HWLIB)'s object files into a text file from Makefile[.hw] that was later read in Makefile.target.
Quoted 7 lines
* The second version was using dedicated Makefile[.hw] targets for printing the object files to stdout for use by Makefile.target, avoiding the need to write an intermediate file.
Avi had preferred a variation of the first version for reduced complexity.
Other ideas that crossed my mind were:
* using GNU ld directly instead of gcc for linking (broken by -Wl and some other LDFLAGS)
* extracting the .a archive to a temporary directory from the targetMakefileand obtaining the names byls *.o(similar to libtool)
The attached patches showcase the latter. $(ARLIBS) are extracted to .tmpobjs/<libname>/ and their *.o objects are linked individually. Filtering to *.o was necessary because on OSX archives contain non-.o files that otherwise break compilation. The extraction showed that libqemu_common.a contains two nbd.o files, one from ./nbd.c and one from ./block/nbd.c. The second patch thus renames block/nbd.o to distinguish the two and to avoid linker errors. A more permanent solution would be to rename the nbd.c file. With those two patches once again QEMU works on both OpenSolaris and Mac OS X, for in-tree and out-of-tree builds.
Andreas
rules.mak +1 -1
@@ -23,7 +23,7 @@ QEMU_CFLAGS += -MMD -MP -MT $@ $(call quiet-command,$(CC) $(QEMU_CFLAGS) $(CFLAGS) -c -o $@ $<," OBJC $(TARGET_DIR)$@") #LINK = $(call quiet-command,$(CC) $(QEMU_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ $(1) $(ARLIBS_BEGIN) $(ARLIBS) $(ARLIBS_END) $(LIBS)," LINK $(TARGET_DIR)$@") -LINK = $(call quiet-command,{ rm -rf .tmpobjs;mkdir .tmpobjs$(foreach arlib,$(ARLIBS),;(mkdir .tmpobjs/$(notdir $(arlib));cd .tmpobjs/$(notdir $(arlib)) && ar x ../../$(arlib)));$(CC) $(QEMU_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ $(1) $(foreach arlib,$(ARLIBS),$(foreach obj,$(shell $(AR) t $(arlib)),.tmpobjs/$(notdir $(arlib))/$(obj))) $(LIBS);}," LINK $(TARGET_DIR)$@") +LINK = $(call quiet-command,{ rm -rf .tmpobjs;mkdir .tmpobjs$(foreach arlib,$(ARLIBS),;(mkdir .tmpobjs/$(notdir $(arlib));cd .tmpobjs/$(notdir $(arlib)) && ar x ../../$(arlib)));$(CC) $(QEMU_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ $(1) $(foreach arlib,$(ARLIBS),$(foreach obj,$(filter %.o,$(shell $(AR) t $(arlib))),.tmpobjs/$(notdir $(arlib))/$(obj))) $(LIBS);}," LINK $(TARGET_DIR)$@") %$(EXESUF): %.o $(call LINK,$^)
Makefile +4 -1
@@ -91,11 +91,14 @@ block-obj-$(CONFIG_LINUX_AIO) += linux-aio.o block-nested-y += cow.o qcow.o vdi.o vmdk.o cloop.o dmg.o bochs.o vpc.o vvfat.o block-nested-y += qcow2.o qcow2-refcount.o qcow2-cluster.o qcow2-snapshot.o -block-nested-y += parallels.o nbd.o +block-nested-y += parallels.o nbd--.o block-nested-$(CONFIG_WIN32) += raw-win32.o block-nested-$(CONFIG_POSIX) += raw-posix.o block-nested-$(CONFIG_CURL) += curl.o +block/nbd--.o: block/nbd.c $(GENERATED_HEADERS) + $(call quiet-command,$(CC) $(QEMU_CFLAGS) $(CFLAGS) -c -o $@ $<," CC $(TARGET_DIR)$@") + block-obj-y += $(addprefix block/, $(block-nested-y)) net-obj-y = net.o
Re: [Qemu-devel] [RFC] Avoiding --whole-archive
In reply to Andreas FärberQuoted 5 lines · Andreas Färber
This problem is still around after Juan's
Makefilereorganizations.Before, I had provided two alternative patches:
Quoted 8 lines
* The first version wrote the list of libqemu_common.a's and $(HWLIB)'s object files into a text file from Makefile[.hw] that was later read in Makefile.target.
* The second version was using dedicated Makefile[.hw] targets for printing the object files to stdout for use by Makefile.target, avoiding the need to write an intermediate file.
Avi had preferred a variation of the first version for reduced complexity.
Other ideas that crossed my mind were:
* using GNU ld directly instead of gcc for linking (broken by -Wl and some other LDFLAGS)
Using ld directly may break link-time optimization when that arrives.
Signature · 1 line
Do not meddle in the internals of kernels, for they are subtle and quick to panic.