crypto: move common bits for all emulators to libqemuutil
Subsystems (2)
PATCH 1/1 crypto: move common bits for all emulators to libqemuutil
qcrypto_random_*, AES and qcrypto_init do not need to be linked as a whole and are the only parts that are used by user-mode emulation. Place them in libqemuutil, so that whatever needs them will pick them up automatically.
---
MAINTAINERS | 3 +++
Makefile | 4 +---
Makefile.objs | 1 -
Makefile.target | 2 --
crypto/Makefile.objs | 7 -------
util/Makefile.objs | 5 +++++
{crypto => util}/aes.c | 0
crypto/init.c => util/crypto-init.c | 0
{crypto => util}/random-gcrypt.c | 0
{crypto => util}/random-gnutls.c | 0
{crypto => util}/random-platform.c | 0
11 files changed, 9 insertions(+), 13 deletions(-)
rename {crypto => util}/aes.c (100%)
rename crypto/init.c => util/crypto-init.c (100%)
rename {crypto => util}/random-gcrypt.c (100%)
rename {crypto => util}/random-gnutls.c (100%)
rename {crypto => util}/random-platform.c (100%)MAINTAINERS +3 -0
@@ -2141,6 +2141,9 @@ F: tests/test-crypto-* F: tests/benchmark-crypto-* F: tests/crypto-tls-* F: tests/pkix_asn1_tab.c +F: util/aes.c +F: util/crypto-init.c +F: util/random-*.c F: qemu.sasl Coroutines
Makefile +1 -3
@@ -425,7 +425,6 @@ dummy := $(call unnest-vars,, \ block-obj-y \ block-obj-m \ crypto-obj-y \ - crypto-user-obj-y \ qom-obj-y \ io-obj-y \ common-obj-y \
@@ -498,8 +497,7 @@ subdir-capstone: .git-submodule-status subdir-slirp: .git-submodule-status $(call quiet-command,$(MAKE) -C $(SRC_PATH)/slirp BUILD_DIR="$(BUILD_DIR)/slirp" CC="$(CC)" AR="$(AR)" LD="$(LD)" RANLIB="$(RANLIB)" CFLAGS="$(QEMU_CFLAGS) $(CFLAGS)" LDFLAGS="$(LDFLAGS)") -$(SUBDIR_RULES): libqemuutil.a $(common-obj-y) \ - $(qom-obj-y) $(crypto-user-obj-$(CONFIG_USER_ONLY)) +$(SUBDIR_RULES): libqemuutil.a $(common-obj-y) $(qom-obj-y) ROMSUBDIR_RULES=$(patsubst %,romsubdir-%, $(ROMS)) # Only keep -O and -g cflags
Makefile.objs +0 -1
@@ -25,7 +25,6 @@ block-obj-m = block/ # crypto-obj-y is code used by both qemu system emulation and qemu-img crypto-obj-y = crypto/ -crypto-user-obj-y = crypto/ ####################################################################### # qom-obj-y is code used by both qemu system emulation and qemu-img
Makefile.target +0 -2
@@ -181,7 +181,6 @@ dummy := $(call unnest-vars,.., \ block-obj-m \ chardev-obj-y \ crypto-obj-y \ - crypto-user-obj-y \ qom-obj-y \ io-obj-y \ common-obj-y \
@@ -190,7 +189,6 @@ all-obj-y += $(common-obj-y) all-obj-y += $(qom-obj-y) all-obj-$(CONFIG_SOFTMMU) += $(authz-obj-y) all-obj-$(CONFIG_SOFTMMU) += $(block-obj-y) $(chardev-obj-y) -all-obj-$(CONFIG_USER_ONLY) += $(crypto-user-obj-y) all-obj-$(CONFIG_SOFTMMU) += $(crypto-obj-y) all-obj-$(CONFIG_SOFTMMU) += $(io-obj-y)
crypto/Makefile.objs +0 -7
@@ -19,10 +19,6 @@ crypto-obj-y += tlscredspsk.o crypto-obj-y += tlscredsx509.o crypto-obj-y += tlssession.o crypto-obj-y += secret.o -crypto-rng-obj-$(CONFIG_GCRYPT) += random-gcrypt.o -crypto-rng-obj-$(if $(CONFIG_GCRYPT),n,$(CONFIG_GNUTLS)) += random-gnutls.o -crypto-rng-obj-$(if $(CONFIG_GCRYPT),n,$(if $(CONFIG_GNUTLS),n,y)) += random-platform.o -crypto-obj-y += $(crypto-rng-obj-y) crypto-obj-y += pbkdf.o crypto-obj-$(CONFIG_NETTLE) += pbkdf-nettle.o crypto-obj-$(if $(CONFIG_NETTLE),n,$(CONFIG_GCRYPT)) += pbkdf-gcrypt.o
@@ -36,7 +32,4 @@ crypto-obj-y += block.o crypto-obj-y += block-qcow.o crypto-obj-y += block-luks.o -# Let the userspace emulators avoid linking stuff they won't use. -crypto-user-obj-y = aes.o $(crypto-rng-obj-y) init.o - stub-obj-y += pbkdf-stub.o
util/Makefile.objs +5 -0
@@ -57,3 +57,8 @@ util-obj-$(CONFIG_POSIX) += drm.o util-obj-y += guest-random.o stub-obj-y += filemonitor-stub.o + +util-obj-$(CONFIG_GCRYPT) += random-gcrypt.o +util-obj-$(if $(CONFIG_GCRYPT),n,$(CONFIG_GNUTLS)) += random-gnutls.o +util-obj-$(if $(CONFIG_GCRYPT),n,$(if $(CONFIG_GNUTLS),n,y)) += random-platform.o +util-obj-y += aes.o crypto-init.o
util/aes.c renamed from crypto/aes.c +0 -0
util/crypto-init.c renamed from crypto/init.c +0 -0
util/random-gcrypt.c renamed from crypto/random-gcrypt.c +0 -0
util/random-gnutls.c renamed from crypto/random-gnutls.c +0 -0
util/random-platform.c renamed from crypto/random-platform.c +0 -0
Signature · 1 line
1.8.3.1
Quoted 5 lines · Paolo Bonzini
qcrypto_random_*, AES and
qcrypto_initdo not need to be linked as a whole and are the only parts that are used by user-mode emulation. Place them in libqemuutil, so that whatever needs them will pick them up automatically.Signed-off-by Paolo Bonzini <[email protected]>
Quoted 12 lines
---
MAINTAINERS | 3 +++
Makefile | 4 +---
Makefile.objs | 1 -
Makefile.target | 2 --
crypto/Makefile.objs | 7 -------
util/Makefile.objs | 5 +++++
{crypto => util}/aes.c | 0
crypto/init.c => util/crypto-init.c | 0
{crypto => util}/random-gcrypt.c | 0
{crypto => util}/random-gnutls.c | 0
{crypto => util}/random-platform.c | 0Ewww, definitely do not want to see these files moved as it spreads the crypto related code over multiple locations again, which is exactly what I spent time fixing when introducing the crypto/ directory.
Placing them to libqemuutil.a shouldn't mean we need to move the code too.
Regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Quoted 19 lines · Daniel P. Berrangé
Quoted 5 lines · Paolo Bonzini
qcrypto_random_*, AES and
qcrypto_initdo not need to be linked as a whole and are the only parts that are used by user-mode emulation. Place them in libqemuutil, so that whatever needs them will pick them up automatically.Signed-off-by Paolo Bonzini <[email protected]>Quoted 12 lines
--- MAINTAINERS | 3 +++ Makefile | 4 +--- Makefile.objs | 1 - Makefile.target | 2 -- crypto/Makefile.objs | 7 ------- util/Makefile.objs | 5 +++++ {crypto => util}/aes.c | 0 crypto/init.c => util/crypto-init.c | 0 {crypto => util}/random-gcrypt.c | 0 {crypto => util}/random-gnutls.c | 0 {crypto => util}/random-platform.c | 0
Quoted 5 lines
Ewww, definitely do not want to see these files moved as it spreads the crypto related code over multiple locations again, which is exactly what I spent time fixing when introducing the
crypto/directory.Placing them to libqemuutil.a shouldn't mean we need to move the code too.
Fair enough, will do in v2.
Paolo
Quoted 20 lines · Paolo Bonzini
Quoted 19 lines · Daniel P. Berrangé
Quoted 17 lines · Paolo Bonzini
qcrypto_random_*, AES and
qcrypto_initdo not need to be linked as a whole and are the only parts that are used by user-mode emulation. Place them in libqemuutil, so that whatever needs them will pick them up automatically.Signed-off-by Paolo Bonzini <[email protected]>--- MAINTAINERS | 3 +++ Makefile | 4 +--- Makefile.objs | 1 - Makefile.target | 2 -- crypto/Makefile.objs | 7 ------- util/Makefile.objs | 5 +++++ {crypto => util}/aes.c | 0 crypto/init.c => util/crypto-init.c | 0 {crypto => util}/random-gcrypt.c | 0 {crypto => util}/random-gnutls.c | 0 {crypto => util}/random-platform.c | 0
Quoted 7 lines
Quoted 5 lines
Ewww, definitely do not want to see these files moved as it spreads the crypto related code over multiple locations again, which is exactly what I spent time fixing when introducing the
crypto/directory.Placing them to libqemuutil.a shouldn't mean we need to move the code too.
Fair enough, will do in v2.
I would love to be able to have a libqemucrypto.a library for everything in crypto/ really, but the way we do QOM registration via library constructors breaks this. The ld linker isn't clever enough to see the .o is used via a constructor so unhelpfully throws away all the .o files containing QOM objects :-(
Regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|