build-sys: Fix iscsi module loading failure
Subsystems (2)
cover build-sys: Fix iscsi module loading failure
The iscsi driver doesn't work if built with --enable-modules:
$ ~/build/last/qemu-img Failed to open module: /home/fam/build/master/block-iscsi.so: undefined symbol: qmp_query_uuid qemu-img: Not enough arguments Try 'qemu-img --help' for more information
This fixes it by completely linking libqemuutil.a (now qemuutil.o) rather than on demand.
A few stub functions are added into libqemustub to make linker happy.
Lastly, iqn generation code is moved from iscsi.c to util, so that qmp_query_uuid or its stub is not missed.
Fam
Fam Zheng (6):
build-sys: Move fifio8 to hw/
stubs: Add iohandler.c
stubs: Add openpty.c
stubs: Add timer.c
build-sys: Change libqemuutil.a to qemuutil.o and link whole object
iscsi: Move iqn generation code to util
Makefile | 17 ++++--- Makefile.objs | 2 +- Makefile.target | 2 +- block/iscsi.c | 15 +----- hw/Makefile.objs | 1 + hw/fifo8.c | 125 ++++++++++++++++++++++++++++++++++++++++++++++++++ include/qemu-common.h | 3 ++ stubs/Makefile.objs | 3 ++ stubs/iohandler.c | 20 ++++++++ stubs/openpty.c | 21 +++++++++ stubs/timer.c | 44 ++++++++++++++++++ tests/Makefile | 60 ++++++++++++------------ util/Makefile.objs | 2 +- util/fifo8.c | 125 -------------------------------------------------- util/iqn.c | 38 +++++++++++++++ 15 files changed, 299 insertions(+), 179 deletions(-) create mode 100644 hw/fifo8.c create mode 100644 stubs/iohandler.c create mode 100644 stubs/openpty.c create mode 100644 stubs/timer.c delete mode 100644 util/fifo8.c create mode 100644 util/iqn.c
Signature · 1 line
2.0.3
PATCH 1/6 build-sys: Move fifio8 to hw/
Since it has a dependency on vmstate and is only used by device emulation, moving out from util will make the archive more independent.
--- hw/Makefile.objs | 1 + hw/fifo8.c | 125 +++++++++++++++++++++++++++++++++++++++++++++++++++++ util/Makefile.objs | 1 - util/fifo8.c | 125 ----------------------------------------------------- 4 files changed, 126 insertions(+), 126 deletions(-) create mode 100644 hw/fifo8.c delete mode 100644 util/fifo8.c
hw/Makefile.objs +1 -0
@@ -33,3 +33,4 @@ devices-dirs-$(CONFIG_MEM_HOTPLUG) += mem/ devices-dirs-y += core/ common-obj-y += $(devices-dirs-y) obj-y += $(devices-dirs-y) +obj-y += fifo8.o
hw/fifo8.c new file +125 -0
125 lines not on this page · raw message
util/Makefile.objs +0 -1
@@ -3,7 +3,6 @@ util-obj-$(CONFIG_WIN32) += oslib-win32.o qemu-thread-win32.o event_notifier-win util-obj-$(CONFIG_POSIX) += oslib-posix.o qemu-thread-posix.o event_notifier-posix.o qemu-openpty.o util-obj-y += envlist.o path.o host-utils.o module.o util-obj-y += bitmap.o bitops.o hbitmap.o -util-obj-y += fifo8.o util-obj-y += acl.o util-obj-y += error.o qemu-error.o util-obj-$(CONFIG_POSIX) += compatfd.o
util/fifo8.c deleted +0 -125
125 lines not on this page · raw message
Signature · 1 line
2.0.3
Re: [Qemu-devel] [PATCH 1/6] build-sys: Move fifio8 to hw/
Typo in the subject, and please set up git to do rename detection correctly. I still could review the patch by checking the hashes in the "index" lines, so:
Il 20/08/2014 12:01, Fam Zheng ha scritto:
Quoted 297 lines
Since it has a dependency on vmstate and is only used by device emulation, moving out from util will make the archive more independent.
Signed-off-by Fam Zheng <[email protected]>--- hw/Makefile.objs | 1 + hw/fifo8.c | 125 +++++++++++++++++++++++++++++++++++++++++++++++++++++ util/Makefile.objs | 1 - util/fifo8.c | 125 ----------------------------------------------------- 4 files changed, 126 insertions(+), 126 deletions(-) create mode 100644 hw/fifo8.c delete mode 100644 util/fifo8.chw/Makefile.objs +1
-0@@ -33,3 +33,4 @@ devices-dirs-$(CONFIG_MEM_HOTPLUG) += mem/ devices-dirs-y += core/ common-obj-y += $(devices-dirs-y) obj-y += $(devices-dirs-y) +obj-y += fifo8.ohw/fifo8.c new file +125
-0@@ -0,0 +1,125 @@ +/* +* Generic FIFO component, implemented as a circular buffer. +* +* Copyright (c) 2012 Peter A. G. Crosthwaite +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version +* 2 of the License, or (at your option) any later version. +* +* You should have received a copy of the GNU General Public License along +* with this program; if not, see <http://www.gnu.org/licenses/>. +*/ + +#include "qemu-common.h" +#include "qemu/fifo8.h" + +void fifo8_create (Fifo8 *fifo,uint32_t capacity) +{ + fifo->data =g_new (uint8_t, capacity); + fifo->capacity = capacity; + fifo->head =0 ; + fifo->num =0 ; +} + +void fifo8_destroy (Fifo8 *fifo) +{ +g_free (fifo->data); +} + +void fifo8_push (Fifo8 *fifo,uint8_t data) +{ +if (fifo->num == fifo->capacity) { +abort (); + } + fifo->data[(fifo->head + fifo->num) % fifo->capacity] = data; + fifo->num++; +} + +void fifo8_push_all (Fifo8 *fifo,const uint8_t *data,uint32_t num) +{ +uint32_t start, avail; + +if (fifo->num + num > fifo->capacity) { +abort (); + } + + start = (fifo->head + fifo->num) % fifo->capacity; + +if (start + num <= fifo->capacity) { +memcpy (&fifo->data[start], data, num); + }else { + avail = fifo->capacity - start; +memcpy (&fifo->data[start], data, avail); +memcpy (&fifo->data[0 ], &data[avail], num - avail); + } + + fifo->num += num; +} + +uint8_t fifo8_pop (Fifo8 *fifo) +{ +uint8_t ret; + +if (fifo->num ==0 ) { +abort (); + } + ret = fifo->data[fifo->head++]; + fifo->head %= fifo->capacity; + fifo->num--; +return ret; +} + +const uint8_t *fifo8_pop_buf (Fifo8 *fifo,uint32_t max,uint32_t *num) +{ +uint8_t *ret; + +if (max ==0 || max > fifo->num) { +abort (); + } + *num =MIN (fifo->capacity - fifo->head, max); + ret = &fifo->data[fifo->head]; + fifo->head += *num; + fifo->head %= fifo->capacity; + fifo->num -= *num; +return ret; +} + +void fifo8_reset (Fifo8 *fifo) +{ + fifo->num =0 ; + fifo->head =0 ; +} + +bool fifo8_is_empty (Fifo8 *fifo) +{ +return (fifo->num ==0 ); +} + +bool fifo8_is_full (Fifo8 *fifo) +{ +return (fifo->num == fifo->capacity); +} + +uint32_t fifo8_num_free (Fifo8 *fifo) +{ +return fifo->capacity - fifo->num; +} + +uint32_t fifo8_num_used (Fifo8 *fifo) +{ +return fifo->num; +} + +const VMStateDescription vmstate_fifo8 = { + .name ="Fifo8" , + .version_id =1 , + .minimum_version_id =1 , + .fields = (VMStateField []) { +VMSTATE_VBUFFER_UINT32 (data, Fifo8,1 ,NULL ,0 , capacity), +VMSTATE_UINT32 (head, Fifo8), +VMSTATE_UINT32 (num, Fifo8), +VMSTATE_END_OF_LIST () + } +};util/Makefile.objs +0
-1@@ -3,7 +3,6 @@ util-obj-$(CONFIG_WIN32) += oslib-win32.o qemu-thread-win32.o event_notifier-win util-obj-$(CONFIG_POSIX) += oslib-posix.o qemu-thread-posix.o event_notifier-posix.o qemu-openpty.o util-obj-y += envlist.o path.o host-utils.o module.o util-obj-y += bitmap.o bitops.o hbitmap.o -util-obj-y += fifo8.o util-obj-y += acl.o util-obj-y += error.o qemu-error.o util-obj-$(CONFIG_POSIX) += compatfd.outil/fifo8.c deleted +0
-125@@ -1,125 +0,0 @@ -/* -* Generic FIFO component, implemented as a circular buffer. -* -* Copyright (c) 2012 Peter A. G. Crosthwaite -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License -* as published by the Free Software Foundation; either version -* 2 of the License, or (at your option) any later version. -* -* You should have received a copy of the GNU General Public License along -* with this program; if not, see <http://www.gnu.org/licenses/>. -*/ - -#include "qemu-common.h" -#include "qemu/fifo8.h" - -void fifo8_create (Fifo8 *fifo,uint32_t capacity) -{ - fifo->data =g_new (uint8_t, capacity); - fifo->capacity = capacity; - fifo->head =0 ; - fifo->num =0 ; -} - -void fifo8_destroy (Fifo8 *fifo) -{ -g_free (fifo->data); -} - -void fifo8_push (Fifo8 *fifo,uint8_t data) -{ -if (fifo->num == fifo->capacity) { -abort (); - } - fifo->data[(fifo->head + fifo->num) % fifo->capacity] = data; - fifo->num++; -} - -void fifo8_push_all (Fifo8 *fifo,const uint8_t *data,uint32_t num) -{ -uint32_t start, avail; - -if (fifo->num + num > fifo->capacity) { -abort (); - } - - start = (fifo->head + fifo->num) % fifo->capacity; - -if (start + num <= fifo->capacity) { -memcpy (&fifo->data[start], data, num); - }else { - avail = fifo->capacity - start; -memcpy (&fifo->data[start], data, avail); -memcpy (&fifo->data[0 ], &data[avail], num - avail); - } - - fifo->num += num; -} - -uint8_t fifo8_pop (Fifo8 *fifo) -{ -uint8_t ret; - -if (fifo->num ==0 ) { -abort (); - } - ret = fifo->data[fifo->head++]; - fifo->head %= fifo->capacity; - fifo->num--; -return ret; -} - -const uint8_t *fifo8_pop_buf (Fifo8 *fifo,uint32_t max,uint32_t *num) -{ -uint8_t *ret; - -if (max ==0 || max > fifo->num) { -abort (); - } - *num =MIN (fifo->capacity - fifo->head, max); - ret = &fifo->data[fifo->head]; - fifo->head += *num; - fifo->head %= fifo->capacity; - fifo->num -= *num; -return ret; -} - -void fifo8_reset (Fifo8 *fifo) -{ - fifo->num =0 ; - fifo->head =0 ; -} - -bool fifo8_is_empty (Fifo8 *fifo) -{ -return (fifo->num ==0 ); -} - -bool fifo8_is_full (Fifo8 *fifo) -{ -return (fifo->num == fifo->capacity); -} - -uint32_t fifo8_num_free (Fifo8 *fifo) -{ -return fifo->capacity - fifo->num; -} - -uint32_t fifo8_num_used (Fifo8 *fifo) -{ -return fifo->num; -} - -const VMStateDescription vmstate_fifo8 = { - .name ="Fifo8" , - .version_id =1 , - .minimum_version_id =1 , - .fields = (VMStateField []) { -VMSTATE_VBUFFER_UINT32 (data, Fifo8,1 ,NULL ,0 , capacity), -VMSTATE_UINT32 (head, Fifo8), -VMSTATE_UINT32 (num, Fifo8), -VMSTATE_END_OF_LIST () - } -};
Re: [Qemu-devel] [PATCH 1/6] build-sys: Move fifio8 to hw/
In reply to Fam ZhengQuoted 7 lines · Fam Zheng
Since it has a dependency on vmstate and is only used by device emulation, moving out from util will make the archive more independent.
Signed-off-by Fam Zheng <[email protected]>--- hw/Makefile.objs | 1 + hw/fifo8.c | 125 +++++++++++++++++++++++++++++++++++++++++++++++++++++
Can we get it into a hw subdirectory? Either core or misc come to mind.
Regards,
Peter
Re: [Qemu-devel] [PATCH 1/6] build-sys: Move fifio8 to hw/
Quoted 10 lines · Peter Crosthwaite
Quoted 7 lines · Fam Zheng
Since it has a dependency on vmstate and is only used by device emulation, moving out from util will make the archive more independent.
Signed-off-by Fam Zheng <[email protected]>--- hw/Makefile.objs | 1 + hw/fifo8.c | 125 +++++++++++++++++++++++++++++++++++++++++++++++++++++Can we get it into a hw subdirectory? Either core or misc come to mind.
OK. I'll move it to misc. Thanks.
Fam
PATCH 2/6 stubs: Add iohandler.c
In reply to Fam ZhengAdd stub function "qemu_set_fd_handler" which is used by util/event_notifier-posix.c.
--- stubs/Makefile.objs | 1 + stubs/iohandler.c | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 stubs/iohandler.c
stubs/Makefile.objs +1 -0
@@ -40,3 +40,4 @@ stub-obj-$(CONFIG_WIN32) += fd-register.o stub-obj-y += cpus.o stub-obj-y += kvm.o stub-obj-y += qmp_pc_dimm_device_list.o +stub-obj-y += iohandler.o
stubs/iohandler.c new file +20 -0
@@ -0,0 +1,20 @@ +/* +* iohandler stub functions +* +* Copyright Red Hat, Inc., 2014 +* +* Author: Fam Zheng <[email protected]> +* +* This work is licensed under the terms of the GNU GPL, version 2 or +* later. See the COPYING file in the top-level directory. +*/ + +#include "qemu/main-loop.h" + +int qemu_set_fd_handler (int fd, +IOHandler *fd_read, +IOHandler *fd_write, +void *opaque) +{ +abort (); +}
Signature · 1 line
2.0.3
Re: [Qemu-devel] [PATCH 2/6] stubs: Add iohandler.c
Il 20/08/2014 12:01, Fam Zheng ha scritto:
Quoted 36 lines
Add stub function "
qemu_set_fd_handler" which is used byutil/event_notifier-posix.c.Signed-off-by Fam Zheng <[email protected]>--- stubs/Makefile.objs | 1 + stubs/iohandler.c | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 stubs/iohandler.cstubs/Makefile.objs +1
-0@@ -40,3 +40,4 @@ stub-obj-$(CONFIG_WIN32) += fd-register.o stub-obj-y += cpus.o stub-obj-y += kvm.o stub-obj-y += qmp_pc_dimm_device_list.o +stub-obj-y += iohandler.ostubs/iohandler.c new file +10
-0@@ -0,0 +1,20 @@ +/* +* iohandler stub functions +* +* Copyright Red Hat, Inc., 2014 +* +* Author: Fam Zheng <[email protected]> +* +* This work is licensed under the terms of the GNU GPL, version 2 or +* later. See the COPYING file in the top-level directory. +*/
stubs/iohandler.c line 20
Quoted 10 lines
stubs/iohandler.c new file +10
-0+ +#include "qemu/main-loop.h" + +int qemu_set_fd_handler (int fd, +IOHandler *fd_read, +IOHandler *fd_write, +void *opaque) +{ +abort (); +}
Please merge with stubs/set-fd-handler.c.
Paolo
PATCH 3/6 stubs: Add openpty.c
In reply to Fam ZhengAdd function "openpty" which is used by util/qemu-openpty.c.
--- stubs/Makefile.objs | 1 + stubs/openpty.c | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 stubs/openpty.c
stubs/Makefile.objs +1 -0
@@ -41,3 +41,4 @@ stub-obj-y += cpus.o stub-obj-y += kvm.o stub-obj-y += qmp_pc_dimm_device_list.o stub-obj-y += iohandler.o +stub-obj-y += openpty.o
stubs/openpty.c new file +21 -0
@@ -0,0 +1,21 @@ +/* +* openpty stub +* +* Copyright Red Hat, Inc., 2014 +* +* Author: Fam Zheng <[email protected]> +* +* This work is licensed under the terms of the GNU GPL, version 2 or +* later. See the COPYING file in the top-level directory. +*/ + +#include <stdlib.h> +#include <pty.h> + +int openpty (int *amaster,int *aslave,char *name, +const struct termios *termp, +const struct winsize *winp) +{ +abort (); +} +
Signature · 1 line
2.0.3
Re: [Qemu-devel] [PATCH 3/6] stubs: Add openpty.c
Il 20/08/2014 12:01, Fam Zheng ha scritto:
Quoted 36 lines
Add function "openpty" which is used by
util/qemu-openpty.c.Signed-off-by Fam Zheng <[email protected]>--- stubs/Makefile.objs | 1 + stubs/openpty.c | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 stubs/openpty.cstubs/Makefile.objs +1
-0@@ -41,3 +41,4 @@ stub-obj-y += cpus.o stub-obj-y += kvm.o stub-obj-y += qmp_pc_dimm_device_list.o stub-obj-y += iohandler.o +stub-obj-y += openpty.ostubs/openpty.c new file +11
-0@@ -0,0 +1,21 @@ +/* +* openpty stub +* +* Copyright Red Hat, Inc., 2014 +* +* Author: Fam Zheng <[email protected]> +* +* This work is licensed under the terms of the GNU GPL, version 2 or +* later. See the COPYING file in the top-level directory. +*/ +
stubs/openpty.c line 21
Quoted 10 lines
stubs/openpty.c new file +10
-0+#include <stdlib.h> +#include <pty.h> + +int openpty (int *amaster,int *aslave,char *name, +const struct termios *termp, +const struct winsize *winp) +{ +abort (); +} +
Please move -lutil from libs_softmmu to LIBS instead.
Paolo
PATCH 4/6 stubs: Add timer.c
In reply to Fam ZhengAdd timer functions that are used in util/throttle.c.
--- stubs/Makefile.objs | 1 + stubs/timer.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 stubs/timer.c
stubs/Makefile.objs +1 -0
@@ -42,3 +42,4 @@ stub-obj-y += kvm.o stub-obj-y += qmp_pc_dimm_device_list.o stub-obj-y += iohandler.o stub-obj-y += openpty.o +stub-obj-y += timer.o
stubs/timer.c new file +44 -0
44 lines not on this page · raw message
Signature · 1 line
2.0.3
Re: [Qemu-devel] [PATCH 4/6] stubs: Add timer.c
Il 20/08/2014 12:01, Fam Zheng ha scritto:
Quoted 59 lines
Add timer functions that are used in
util/throttle.c.Signed-off-by Fam Zheng <[email protected]>--- stubs/Makefile.objs | 1 + stubs/timer.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 stubs/timer.cstubs/Makefile.objs +1
-0@@ -42,3 +42,4 @@ stub-obj-y += kvm.o stub-obj-y += qmp_pc_dimm_device_list.o stub-obj-y += iohandler.o stub-obj-y += openpty.o +stub-obj-y += timer.ostubs/timer.c new file +34
-0@@ -0,0 +1,44 @@ +/* +* timer stub functions +* +* Copyright Red Hat, Inc., 2014 +* +* Author: Fam Zheng <[email protected]> +* +* This work is licensed under the terms of the GNU GPL, version 2 or +* later. See the COPYING file in the top-level directory. +*/ + +#include "qemu/timer.h" + +void timer_del (QEMUTimer *ts) +{ +abort (); +} + +void timer_init (QEMUTimer *ts, +QEMUTimerList *timer_list,int scale, +QEMUTimerCB *cb,void *opaque) +{ +abort (); +} + +void timer_free (QEMUTimer *ts) +{ +abort (); +} + +int64_t qemu_clock_get_ns (QEMUClockType type) +{ +abort (); +}
stubs/timer.c line 44
Quoted 10 lines
stubs/timer.c new file +10
-0+ +void timer_mod (QEMUTimer *ts,int64_t expire_time) +{ +abort (); +} + +bool timer_pending (QEMUTimer *ts) +{ +abort (); +}
Who uses these? The tests?
Perhaps util/throttle.c can be moved to the root and added to block-obj-y.
Paolo
PATCH 5/6 build-sys: Change libqemuutil.a to qemuutil.o and link whole object
In reply to Fam ZhengWhen an executable is being generated, unused functions from libqemuutil.a are not linked. This is the linker's convention on archives (libqemuutil.a).
Now that we have dynamically loaded modules, which may reference function from libqemuutil.a but not linked in the executable, because the executable itself didn't reference this symbol. That is a problem for module build.
We can't link both executable and the dynamic shared object to libqemuutil.a, because of the risk of inconsistent views of program
variables: DSO module sees a copy of some data because it is linked against libqemuutil.a, whereas the executable sees another copy. In other words, they each maintains a copy but with a same name. In this case, it can be very tricky to notice such a duplication, and make a bug hard to reason. So it's good to avoid it from the beginning.
This patch solves the above issue by fully linking. Specifically, it fixes block-iscsi.mo: in block/iscsi.c, util/bitmap.c functions are used, but qemu-img doesn't link it.
The solution is to link everything in libqemuutil.a. We do this by changing it to qemuutil.o, which includes all the util objects. This is easier and also expected to be more portable than "--whole-archive".
Because qemuutil.o is now fully linked and hence make executables references more symbols than before, some test executables now need libqemustub.a, so add them as necessary too.
--- Makefile | 17 +++++++++------- Makefile.objs | 2 +- Makefile.target | 2 +- tests/Makefile | 60 ++++++++++++++++++++++++++++----------------------------- 4 files changed, 42 insertions(+), 39 deletions(-)
Makefile +10 -7
@@ -187,7 +187,7 @@ subdir-dtc:dtc/libfdt dtc/tests dtc/%: mkdir -p $@ -$(SUBDIR_RULES): libqemuutil.a libqemustub.a $(common-obj-y) +$(SUBDIR_RULES): qemuutil.o libqemustub.a $(common-obj-y) ROMSUBDIR_RULES=$(patsubst %,romsubdir-%, $(ROMS)) romsubdir-%:
@@ -208,7 +208,10 @@ Makefile: $(version-obj-y) $(version-lobj-y) # Build libraries libqemustub.a: $(stub-obj-y) -libqemuutil.a: $(util-obj-y) + +qemuutil.o: CC_REL_FLAGS := -Wl,-r +qemuutil.o: $(util-obj-y) + $(call quiet-command,$(CC) -nostdlib $(CC_REL_FLAGS) -o $@ $^," LD -r $(TARGET_DIR)$@") block-modules = $(foreach o,$(block-obj-m),"$(basename $(subst /,-,$o))",) NULL util/module.o-cflags = -D'CONFIG_BLOCK_MODULES=$(block-modules)'
@@ -217,13 +220,13 @@ util/module.o-cflags = -D'CONFIG_BLOCK_MODULES=$(block-modules)' qemu-img.o: qemu-img-cmds.h -qemu-img$(EXESUF): qemu-img.o $(block-obj-y) libqemuutil.a libqemustub.a -qemu-nbd$(EXESUF): qemu-nbd.o $(block-obj-y) libqemuutil.a libqemustub.a -qemu-io$(EXESUF): qemu-io.o $(block-obj-y) libqemuutil.a libqemustub.a +qemu-img$(EXESUF): qemu-img.o $(block-obj-y) qemuutil.o libqemustub.a +qemu-nbd$(EXESUF): qemu-nbd.o $(block-obj-y) qemuutil.o libqemustub.a +qemu-io$(EXESUF): qemu-io.o $(block-obj-y) qemuutil.o libqemustub.a qemu-bridge-helper$(EXESUF): qemu-bridge-helper.o -fsdev/virtfs-proxy-helper$(EXESUF): fsdev/virtfs-proxy-helper.o fsdev/virtio-9p-marshal.o libqemuutil.a libqemustub.a +fsdev/virtfs-proxy-helper$(EXESUF): fsdev/virtfs-proxy-helper.o fsdev/virtio-9p-marshal.o qemuutil.o libqemustub.a fsdev/virtfs-proxy-helper$(EXESUF): LIBS += -lcap qemu-img-cmds.h: $(SRC_PATH)/qemu-img-cmds.hx
@@ -280,7 +283,7 @@ $(qapi-modules) $(SRC_PATH)/scripts/qapi-commands.py $(qapi-py) QGALIB_GEN=$(addprefix qga/qapi-generated/, qga-qapi-types.h qga-qapi-visit.h qga-qmp-commands.h) $(qga-obj-y) qemu-ga.o: $(QGALIB_GEN) -qemu-ga$(EXESUF): $(qga-obj-y) libqemuutil.a libqemustub.a +qemu-ga$(EXESUF): $(qga-obj-y) qemuutil.o libqemustub.a $(call LINK, $^) clean:
Makefile.objs +1 -1
@@ -109,6 +109,6 @@ target-obj-y += trace/ # guest agent # FIXME: a few definitions from qapi-types.o/qapi-visit.o are needed -# by libqemuutil.a. These should be moved to a separate .json schema. +# by qemuutil.o. These should be moved to a separate .json schema. qga-obj-y = qga/ qga-vss-dll-obj-y = qga/
Makefile.target +1 -1
@@ -176,7 +176,7 @@ all-obj-y += $(target-obj-y) all-obj-$(CONFIG_SOFTMMU) += $(block-obj-y) # build either PROG or PROGW -$(QEMU_PROG_BUILD): $(all-obj-y) ../libqemuutil.a ../libqemustub.a +$(QEMU_PROG_BUILD): $(all-obj-y) ../qemuutil.o ../libqemustub.a $(call LINK,$^) gdbstub-xml.c: $(TARGET_XML_FILES) $(SRC_PATH)/scripts/feature_to_c.sh
tests/Makefile +30 -30
94 lines not on this page · raw message
Signature · 1 line
2.0.3
Re: [Qemu-devel] [PATCH 5/6] build-sys: Change libqemuutil.a to qemuutil.o and link whole object
Il 20/08/2014 12:01, Fam Zheng ha scritto:
Makefile Makefile: $(version-obj-y) $(version-lobj-y) · line 212
Quoted 2 lines
Makefile +2
-0+ +qemuutil.o: CC_REL_FLAGS := -Wl,-r
Why the target-specific rule?
Makefile Makefile: $(version-obj-y) $(version-lobj-y) · line 214
Quoted 3 lines
Makefile +2
-0+qemuutil.o: $(util-obj-y) + $(call quiet-command,$(CC) -nostdlib $(CC_REL_FLAGS) -o $@ $^," LD -r $(TARGET_DIR)$@")
I think either you have
LD_REL := $(CC) -nostdlib -Wl,-r
(as opposed to "LD_REL := $(LD) -r" for example) or you do not need to put -Wl,-r in a separate variable.
Paolo
Re: [Qemu-devel] [PATCH 5/6] build-sys: Change libqemuutil.a to qemuutil.o and link whole object
Quoted 13 lines · Paolo Bonzini
Il 20/08/2014 12:01, Fam Zheng ha scritto:
Makefile Makefile: $(version-obj-y) $(version-lobj-y) · line 212
Quoted 2 lines
Makefile +2
-0+ +qemuutil.o: CC_REL_FLAGS := -Wl,-rWhy the target-specific rule?
Makefile Makefile: $(version-obj-y) $(version-lobj-y) · line 214
Quoted 3 lines
Makefile +2
-0+qemuutil.o: $(util-obj-y) + $(call quiet-command,$(CC) -nostdlib $(CC_REL_FLAGS) -o $@ $^," LD -r $(TARGET_DIR)$@")I think either you have
Quoted 4 lines
LD_REL:= $(CC) -nostdlib -Wl,-r(as opposed to "
LD_REL:= $(LD) -r" for example) or you do not need to put -Wl,-r in a separate variable.
Because comma doesn't work in Makefile macro invocation, we need to wrap the flag in a variable. (Is there a way to escape it?) Your LD_REL looks cleaner though.
Fam
Re: [Qemu-devel] [PATCH 5/6] build-sys: Change libqemuutil.a to qemuutil.o and link whole object
Il 21/08/2014 05:02, Fam Zheng ha scritto:
Quoted 14 lines · Paolo Bonzini
Quoted 13 lines
Il 20/08/2014 12:01, Fam Zheng ha scritto:
Makefile Makefile: $(version-obj-y) $(version-lobj-y) · line 212
Quoted 2 lines
Makefile +2
-0+ +qemuutil.o: CC_REL_FLAGS := -Wl,-rWhy the target-specific rule?
Makefile Makefile: $(version-obj-y) $(version-lobj-y) · line 214
Quoted 3 lines
Makefile +2
-0+qemuutil.o: $(util-obj-y) + $(call quiet-command,$(CC) -nostdlib $(CC_REL_FLAGS) -o $@ $^," LD -r $(TARGET_DIR)$@")I think either you have
Quoted 7 lines
Quoted 4 lines
LD_REL:= $(CC) -nostdlib -Wl,-r(as opposed to "
LD_REL:= $(LD) -r" for example) or you do not need to put -Wl,-r in a separate variable.Because comma doesn't work in
Makefilemacro invocation, we need to wrap the flag in a variable. (Is there a way to escape it?)
Well, there's
comma=,
and $(comma). Or
Wl=-Wl,
of course. But neither is particularly nice.
Quoted 1 line
Your
LD_RELlooks cleaner though.
Okay, let's go with it then.
Paolo
PATCH 6/6 iscsi: Move iqn generation code to util
In reply to Fam ZhengFunction qmp_query_uuid, even with a version in libqemustub.a, is not present in qemu-img, unless we move it to something that is linked with block-obj-y. Since it's a helper function, move it to util makes sense.
--- block/iscsi.c | 15 +-------------- include/qemu-common.h | 3 +++ util/Makefile.objs | 1 + util/iqn.c | 38 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 43 insertions(+), 14 deletions(-) create mode 100644 util/iqn.c
block/iscsi.c +1 -14
@@ -37,8 +37,6 @@#include "trace.h" #include "block/scsi.h" #include "qemu/iov.h" -#include "sysemu/sysemu.h" -#include "qmp-commands.h" #include <iscsi/iscsi.h> #include <iscsi/scsi-lowlevel.h>
@@ -1034,8 +1032,6 @@ static char *parse_initiator_name(const char *target)QemuOptsList *list;QemuOpts *opts;const char *name; -char *iscsi_name; -UuidInfo *uuid_info; list =qemu_find_opts ("iscsi" );if (list) {
@@ -1051,16 +1047,7 @@ static char *parse_initiator_name(const char *target) } } - uuid_info =qmp_query_uuid (NULL ); -if (strcmp (uuid_info->UUID,UUID_NONE ) ==0 ) { - name =qemu_get_vm_name (); - }else { - name = uuid_info->UUID; - } - iscsi_name =g_strdup_printf ("iqn.2008-11.org.linux-kvm%s%s" , - name ?":" :"" , name ? name :"" ); -qapi_free_UuidInfo (uuid_info); -return iscsi_name; +return iqn_generate ("iqn.2008-11.org.linux-kvm" ); }static void iscsi_nop_timed_event (void *opaque)
include/qemu-common.h +3 -0
@@ -420,6 +420,9 @@ int uleb128_decode_small(const uint8_t *in, uint32_t *n);/* unicode.c */ int mod_utf8_codepoint (const char *s,size_t n,char **end); +/* iqn.c */ +char *iqn_generate (const char *prefix); +/* * Hexdump a buffer to a file. An optional string prefix is added to every line */
util/Makefile.objs +1 -0
@@ -14,3 +14,4 @@ util-obj-y += throttle.o util-obj-y += getauxval.o util-obj-y += readline.o util-obj-y += rfifolock.o +util-obj-y += iqn.o
util/iqn.c new file +38 -0
@@ -0,0 +1,38 @@ +/* +* iqn generat function +* +* Copyright Red Hat, Inc., 2014 +* +* Author: Paolo Bonzini <[email protected]> +* Fam Zheng <[email protected]> +* +* This work is licensed under the terms of the GNU GPL, version 2 or +* later. See the COPYING file in the top-level directory. +*/ + +#include <glib.h> +#include "qemu/error-report.h" +#include "qemu-common.h" +#include "sysemu/sysemu.h" +#include "qmp-commands.h" + +char *iqn_generate (const char *prefix) +{ +const char *name; +char *iqn; +UuidInfo *uuid_info; + + uuid_info =qmp_query_uuid (NULL ); +if (strcmp (uuid_info->UUID,UUID_NONE ) ==0 ) { + name =qemu_get_vm_name (); + }else { + name = uuid_info->UUID; + } + iqn =g_strdup_printf ("%s%s%s" , + prefix, + name ?":" :"" , + name ? :"" ); +qapi_free_UuidInfo (uuid_info); + +return iqn; +}
Signature · 1 line
2.0.3
Re: [Qemu-devel] [PATCH 6/6] iscsi: Move iqn generation code to util
Il 20/08/2014 12:01, Fam Zheng ha scritto:
Quoted 82 lines
Function
qmp_query_uuid, even with a version in libqemustub.a, is not present in qemu-img, unless we move it to something that is linked with block-obj-y. Since it's a helper function, move it to util makes sense.Signed-off-by Fam Zheng <[email protected]>--- block/iscsi.c | 15 +-------------- include/qemu-common.h | 3 +++ util/Makefile.objs | 1 + util/iqn.c | 38 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 43 insertions(+), 14 deletions(-) create mode 100644 util/iqn.cblock/iscsi.c +1
-14@@ -37,8 +37,6 @@#include "trace.h" #include "block/scsi.h" #include "qemu/iov.h" -#include "sysemu/sysemu.h" -#include "qmp-commands.h" #include <iscsi/iscsi.h> #include <iscsi/scsi-lowlevel.h> @@ -1034,8 +1032,6 @@ static char *parse_initiator_name(const char *target)QemuOptsList *list;QemuOpts *opts;const char *name; -char *iscsi_name; -UuidInfo *uuid_info; list =qemu_find_opts ("iscsi" );if (list) {@@ -1051,16 +1047,7 @@ static char *parse_initiator_name(const char *target) } } - uuid_info =qmp_query_uuid (NULL ); -if (strcmp (uuid_info->UUID,UUID_NONE ) ==0 ) { - name =qemu_get_vm_name (); - }else { - name = uuid_info->UUID; - } - iscsi_name =g_strdup_printf ("iqn.2008-11.org.linux-kvm%s%s" , - name ?":" :"" , name ? name :"" ); -qapi_free_UuidInfo (uuid_info); -return iscsi_name; +return iqn_generate ("iqn.2008-11.org.linux-kvm" ); }static void iscsi_nop_timed_event (void *opaque)include/qemu-common.h +3
-0@@ -420,6 +420,9 @@ int uleb128_decode_small(const uint8_t *in, uint32_t *n);/* unicode.c */ int mod_utf8_codepoint (const char *s,size_t n,char **end); +/* iqn.c */ +char *iqn_generate (const char *prefix); +/* * Hexdump a buffer to a file. An optional string prefix is added to every line */ util/Makefile.objs +1
-0@@ -14,3 +14,4 @@ util-obj-y += throttle.o util-obj-y += getauxval.o util-obj-y += readline.o util-obj-y += rfifolock.o +util-obj-y += iqn.outil/iqn.c new file +0
-0
util/iqn.c line 6
Quoted 6 lines
util/iqn.c new file +6
-0@@ -0,0 +1,38 @@ +/* +* iqn generat function +* +* Copyright Red Hat, Inc., 2014 +* +* Author: Paolo Bonzini <[email protected]>
Why me? :)
Quoted 23 lines
util/iqn.c new file +22
-0+* Fam Zheng <[email protected]> +* +* This work is licensed under the terms of the GNU GPL, version 2 or +* later. See the COPYING file in the top-level directory. +*/ + +#include <glib.h> +#include "qemu/error-report.h" +#include "qemu-common.h" +#include "sysemu/sysemu.h" +#include "qmp-commands.h" + +char *iqn_generate (const char *prefix) +{ +const char *name; +char *iqn; +UuidInfo *uuid_info; + + uuid_info =qmp_query_uuid (NULL ); +if (strcmp (uuid_info->UUID,UUID_NONE ) ==0 ) { + name =qemu_get_vm_name (); + }else {
util/iqn.c line 38
Quoted 10 lines
util/iqn.c new file +10
-0+ name = uuid_info->UUID; + } + iqn =g_strdup_printf ("%s%s%s" , + prefix, + name ?":" :"" , + name ? :"" ); +qapi_free_UuidInfo (uuid_info); + +return iqn; +}
Ouch, this is ugly... I cannot think of any other way to do it, but perhaps Benoit's QMP-in-tools series could help here?
In any case, if we need it I think there's no need to keep the argument to iqn_generate.
Paolo
Re: [Qemu-devel] [PATCH 6/6] iscsi: Move iqn generation code to util
Quoted 15 lines · Paolo Bonzini
Il 20/08/2014 12:01, Fam Zheng ha scritto:
util/iqn.c line 6
Quoted 12 lines
util/iqn.c new file +6
-0@@ -0,0 +1,38 @@ +/* +* iqn generat function +* +* Copyright Red Hat, Inc., 2014 +* +* Author: Paolo Bonzini <[email protected]> Why me? :)
For the copied uuid part :)
Quoted 29 lines
Quoted 29 lines
util/iqn.c new file +28
-0+* Fam Zheng <[email protected]> +* +* This work is licensed under the terms of the GNU GPL, version 2 or +* later. See the COPYING file in the top-level directory. +*/ + +#include <glib.h> +#include "qemu/error-report.h" +#include "qemu-common.h" +#include "sysemu/sysemu.h" +#include "qmp-commands.h" + +char *iqn_generate (const char *prefix) +{ +const char *name; +char *iqn; +UuidInfo *uuid_info; + + uuid_info =qmp_query_uuid (NULL ); +if (strcmp (uuid_info->UUID,UUID_NONE ) ==0 ) { + name =qemu_get_vm_name (); + }else { + name = uuid_info->UUID; + } + iqn =g_strdup_printf ("%s%s%s" , + prefix, + name ?":" :"" , + name ? :"" );
Quoted 8 lines
util/iqn.c line 38
Quoted 5 lines
util/iqn.c new file +4
-0+qapi_free_UuidInfo (uuid_info); + +return iqn; +}Ouch, this is ugly... I cannot think of any other way to do it, but perhaps Benoit's QMP-in-tools series could help here?
I'll have a look to see if it helps.
Quoted 3 lines
In any case, if we need it I think there's no need to keep the argument to
iqn_generate.
Fam
Re: [Qemu-devel] [PATCH 6/6] iscsi: Move iqn generation code to util
In reply to Paolo BonziniQuoted 3 lines · Paolo Bonzini
In any case, if we need it I think there's no need to keep the argument to
iqn_generate.
How about multiple initiators? Should they use the same iqn?
Fam
Re: [Qemu-devel] [PATCH 6/6] iscsi: Move iqn generation code to util
Il 21/08/2014 05:54, Fam Zheng ha scritto:
Quoted 3 lines
Quoted 2 lines
Quoted 2 lines
In any case, if we need it I think there's no need to keep the argument to
iqn_generate.How about multiple initiators? Should they use the same iqn?
block/iscsi.c uses -iscsi for the options so that you don't have to place them in cleartext in the command line (instead you can use a -readconfig file and delete them). user and password can be included in the URL as well, though, and we could add an initiator-name option to the iscsi driver to be used with qemu-img/qemu-io.
The default would remain to always use the same iqn.
Paolo
Re: [Qemu-devel] [PATCH 6/6] iscsi: Move iqn generation code to util
Quoted 5 lines · Paolo Bonzini
Il 21/08/2014 05:54, Fam Zheng ha scritto:
Quoted 3 lines
Quoted 2 lines
Quoted 2 lines
In any case, if we need it I think there's no need to keep the argument to
iqn_generate.How about multiple initiators? Should they use the same iqn?
Quoted 8 lines
block/iscsi.cuses -iscsi for the options so that you don't have to place them in cleartext in the command line (instead you can use a -readconfig file and delete them). user and password can be included in the URL as well, though, and we could add an initiator-name option to the iscsi driver to be used with qemu-img/qemu-io.The default would remain to always use the same iqn.
Makes sense to me. Thanks,
Fam