Skip to contentSkip to conversation

NBD isn't used by qemu-img, so don't link qemu-img against NBD objects

PATCH In review [email protected] 6 participants 20 messages Nov 19, 2010 – Dec 10, 2010 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 NBD isn't used by qemu-img, so don't link qemu-img against NBD objects

From: Jes Sorensen <[email protected]>

---
 Makefile      |    2 +-
 Makefile.objs |   12 ++++++++++--
 2 files changed, 11 insertions(+), 3 deletions(-)
Makefile +1 -1
index 747e47c..a503c1c 100644
@@ -154,7 +154,7 @@ qemu-img.o qemu-tool.o qemu-nbd.o qemu-io.o: $(GENERATED_HEADERS)
 
 qemu-img$(EXESUF): qemu-img.o qemu-tool.o qemu-error.o $(oslib-obj-y) $(trace-obj-y) $(block-obj-y) $(qobject-obj-y) $(version-obj-y) qemu-timer-common.o
 
-qemu-nbd$(EXESUF): qemu-nbd.o qemu-tool.o qemu-error.o $(oslib-obj-y) $(trace-obj-y) $(block-obj-y) $(qobject-obj-y) $(version-obj-y) qemu-timer-common.o
+qemu-nbd$(EXESUF): qemu-nbd.o qemu-tool.o qemu-error.o $(oslib-obj-y) $(trace-obj-y) $(block-obj-y) $(nbd-obj-y) $(qobject-obj-y) $(version-obj-y) qemu-timer-common.o
 
 qemu-io$(EXESUF): qemu-io.o cmd.o qemu-tool.o qemu-error.o $(oslib-obj-y) $(trace-obj-y) $(block-obj-y) $(qobject-obj-y) $(version-obj-y) qemu-timer-common.o
 
Makefile.objs +10 -2
index 23b17ce..5120e88 100644
@@ -14,13 +14,13 @@ oslib-obj-$(CONFIG_POSIX) += oslib-posix.o
 # block-obj-y is code used by both qemu system emulation and qemu-img
 
 block-obj-y = cutils.o cache-utils.o qemu-malloc.o qemu-option.o module.o
-block-obj-y += nbd.o block.o aio.o aes.o qemu-config.o
+block-obj-y += block.o aio.o aes.o qemu-config.o
 block-obj-$(CONFIG_POSIX) += posix-aio-compat.o
 block-obj-$(CONFIG_LINUX_AIO) += linux-aio.o
 
 block-nested-y += raw.o 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 blkdebug.o sheepdog.o blkverify.o
+block-nested-y += parallels.o blkdebug.o sheepdog.o blkverify.o
 block-nested-$(CONFIG_WIN32) += raw-win32.o
 block-nested-$(CONFIG_POSIX) += raw-posix.o
 block-nested-$(CONFIG_CURL) += curl.o
@@ -45,6 +45,13 @@ net-obj-y += $(addprefix net/, $(net-nested-y))
 fsdev-nested-$(CONFIG_VIRTFS) = qemu-fsdev.o
 fsdev-obj-$(CONFIG_VIRTFS) += $(addprefix fsdev/, $(fsdev-nested-y))
 
+#######################################################################
+# nbd-obj-y is code used by both qemu and qemu-nbd
+
+nbd-obj-y = nbd.o
+nbd-nested-y = nbd.o
+nbd-obj-y +=  $(addprefix block/, $(nbd-nested-y))
+
 ######################################################################
 # libqemu_common.a: Target independent part of system emulation. The
 # long term path is to suppress *all* target specific code in case of
@@ -53,6 +60,7 @@ fsdev-obj-$(CONFIG_VIRTFS) += $(addprefix fsdev/, $(fsdev-nested-y))
 
 common-obj-y = $(block-obj-y) blockdev.o
 common-obj-y += $(net-obj-y)
+common-obj-y += $(nbd-obj-y)
 common-obj-y += $(qobject-obj-y)
 common-obj-$(CONFIG_LINUX) += $(fsdev-obj-$(CONFIG_LINUX))
 common-obj-y += readline.o console.o cursor.o async.o qemu-error.o
Signature · 1 line
1.7.3.2
Tested-by on v1 1/1
#1 lore raw

Am 19.11.2010 um 17:30 schrieb [email protected]:

Quoted 7 lines

From: Jes Sorensen <[email protected]>

---
Makefile | 2 +-
Makefile.objs | 12 ++++++++++--

2 files changed, 11 insertions(+), 3 deletions(-)

Looks good to me and a clean build works okay.

Any plans for a way to disable NBD build completely? There are warnings about use of daemon() on Mac OS X and possibly Solaris, and there's little point in building qemu-nbd if one does not use it.

Andreas

#2 lore raw
Quoted 3 lines · Andreas Färber

Any plans for a way to disable NBD build completely? There are warnings about use of daemon() on Mac OS X and possibly Solaris, and there's little point in building qemu-nbd if one does not use it.

daemon() could be replaced by sharing os_daemonize().

What is the warning message that you get?

Stefan

#3 lore raw

Am 20.11.2010 um 18:39 schrieb Stefan Hajnoczi:

Quoted 9 lines

On Sat, Nov 20, 2010 at 5:22 PM, Andreas Färber <[email protected]

Quoted 4 lines

wrote:
Any plans for a way to disable NBD build completely? There are warnings about use of daemon() on Mac OS X and possibly Solaris, and there's little point in building qemu-nbd if one does not use it.

daemon() could be replaced by sharing os_daemonize().

What is the warning message that you get?

CC qemu-nbd.o
/Users/andreas/QEMU/qemu/qemu-nbd.c: In function ‘main’:
/Users/andreas/QEMU/qemu/qemu-nbd.c:364: warning: ‘daemon’ is deprecated (declared at /usr/include/stdlib.h:283)

http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man3/daemon.3.html

Andreas

#4 lore raw
Quoted 12 lines · Andreas Färber

Am 20.11.2010 um 18:39 schrieb Stefan Hajnoczi:

Quoted 10 lines
Quoted 5 lines · Andreas Färber

Any plans for a way to disable NBD build completely? There are warnings about use of daemon() on Mac OS X and possibly Solaris, and there's little
point in building qemu-nbd if one does not use it.

daemon() could be replaced by sharing os_daemonize().

Quoted 8 lines
Quoted 1 line

What is the warning message that you get?

 CC    qemu-nbd.o
/Users/andreas/QEMU/qemu/qemu-nbd.c: In function ‘main’:
/Users/andreas/QEMU/qemu/qemu-nbd.c:364: warning: ‘daemon’ is deprecated (declared at /usr/include/stdlib.h:283)

http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man3/daemon.3.html

Deprecated in favor of using launchd.

Removing qemu-nbd from the build because there is warning isn't a good strategy. You may not use qemu-io either but it is always built. That's important because otherwise it could bitrot, no one would notice, and one day qemu-tools wouldn't work on Mac OSX at all anymore. Instead we should fix the code that causes a warning.

Is it cheating much to daemonize manually in qemu-nbd? ;)

Stefan

#5 lore raw
Quoted 5 lines · Stefan Hajnoczi
Quoted 1 line · Andreas Färber

http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man3/daemon.3.html

Deprecated in favor of using launchd.

Quoted 7 lines

Removing qemu-nbd from the build because there is warning isn't a good strategy. You may not use qemu-io either but it is always built. That's important because otherwise it could bitrot, no one would notice, and one day qemu-tools wouldn't work on Mac OSX at all anymore. Instead we should fix the code that causes a warning.

Is it cheating much to daemonize manually in qemu-nbd? ;)

Maybe it would be feasible to write an os_daemonize() implementation based on launchd() on OSX?

#6 lore raw
In reply to Andreas Färber
Quoted 10 lines · Andreas Färber

Am 19.11.2010 um 17:30 schrieb [email protected]:

Quoted 7 lines

From: Jes Sorensen <[email protected]>

---
Makefile | 2 +-
Makefile.objs | 12 ++++++++++--

2 files changed, 11 insertions(+), 3 deletions(-)
Quoted 7 lines

Looks good to me and a clean build works okay.

Any plans for a way to disable NBD build completely? There are warnings about use of daemon() on Mac OS X and possibly Solaris, and there's little point in building qemu-nbd if one does not use it.

I think it would be worth adding as an option, however letting it default to 'on' to make sure it gets at least build tested unless a user explicitly disables it.

Cheers,
Jes

#7 lore raw
In reply to [email protected]

Am 19.11.2010 17:30, schrieb [email protected]:

Quoted 3 lines

From: Jes Sorensen <[email protected]>

You're compiling the nbd block driver out here. This is certainly not what you were attempting. (However, it's the only way to make it work, because otherwise qemu-img will need the top-level nbd.o)

qemu-img -help before this change shows:

Supported formats: raw cow qcow vdi vmdk cloop dmg bochs vpc vvfat qcow2 parallels nbd blkdebug sheepdog blkverify host_cdrom host_floppy host_device file tftp ftps ftp https http

Afterwards:

Supported formats: raw cow qcow vdi vmdk cloop dmg bochs vpc vvfat qcow2 parallels blkdebug sheepdog blkverify host_cdrom host_floppy host_device file tftp ftps ftp https http

Kevin

Quoted 60 lines
---
 Makefile      |    2 +-
 Makefile.objs |   12 ++++++++++--
 2 files changed, 11 insertions(+), 3 deletions(-)
Makefile +1 -1
index 747e47c..a503c1c 100644
@@ -154,7 +154,7 @@ qemu-img.o qemu-tool.o qemu-nbd.o qemu-io.o: $(GENERATED_HEADERS)
 
 qemu-img$(EXESUF): qemu-img.o qemu-tool.o qemu-error.o $(oslib-obj-y) $(trace-obj-y) $(block-obj-y) $(qobject-obj-y) $(version-obj-y) qemu-timer-common.o
 
-qemu-nbd$(EXESUF): qemu-nbd.o qemu-tool.o qemu-error.o $(oslib-obj-y) $(trace-obj-y) $(block-obj-y) $(qobject-obj-y) $(version-obj-y) qemu-timer-common.o
+qemu-nbd$(EXESUF): qemu-nbd.o qemu-tool.o qemu-error.o $(oslib-obj-y) $(trace-obj-y) $(block-obj-y) $(nbd-obj-y) $(qobject-obj-y) $(version-obj-y) qemu-timer-common.o
 
 qemu-io$(EXESUF): qemu-io.o cmd.o qemu-tool.o qemu-error.o $(oslib-obj-y) $(trace-obj-y) $(block-obj-y) $(qobject-obj-y) $(version-obj-y) qemu-timer-common.o
 
Makefile.objs +10 -2
index 23b17ce..5120e88 100644
@@ -14,13 +14,13 @@ oslib-obj-$(CONFIG_POSIX) += oslib-posix.o
 # block-obj-y is code used by both qemu system emulation and qemu-img
 
 block-obj-y = cutils.o cache-utils.o qemu-malloc.o qemu-option.o module.o
-block-obj-y += nbd.o block.o aio.o aes.o qemu-config.o
+block-obj-y += block.o aio.o aes.o qemu-config.o
 block-obj-$(CONFIG_POSIX) += posix-aio-compat.o
 block-obj-$(CONFIG_LINUX_AIO) += linux-aio.o
 
 block-nested-y += raw.o 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 blkdebug.o sheepdog.o blkverify.o
+block-nested-y += parallels.o blkdebug.o sheepdog.o blkverify.o
 block-nested-$(CONFIG_WIN32) += raw-win32.o
 block-nested-$(CONFIG_POSIX) += raw-posix.o
 block-nested-$(CONFIG_CURL) += curl.o
@@ -45,6 +45,13 @@ net-obj-y += $(addprefix net/, $(net-nested-y))
 fsdev-nested-$(CONFIG_VIRTFS) = qemu-fsdev.o
 fsdev-obj-$(CONFIG_VIRTFS) += $(addprefix fsdev/, $(fsdev-nested-y))
 
+#######################################################################
+# nbd-obj-y is code used by both qemu and qemu-nbd
+
+nbd-obj-y = nbd.o
+nbd-nested-y = nbd.o
+nbd-obj-y +=  $(addprefix block/, $(nbd-nested-y))
+
 ######################################################################
 # libqemu_common.a: Target independent part of system emulation. The
 # long term path is to suppress *all* target specific code in case of
@@ -53,6 +60,7 @@ fsdev-obj-$(CONFIG_VIRTFS) += $(addprefix fsdev/, $(fsdev-nested-y))
 
 common-obj-y = $(block-obj-y) blockdev.o
 common-obj-y += $(net-obj-y)
+common-obj-y += $(nbd-obj-y)
 common-obj-y += $(qobject-obj-y)
 common-obj-$(CONFIG_LINUX) += $(fsdev-obj-$(CONFIG_LINUX))
 common-obj-y += readline.o console.o cursor.o async.o qemu-error.o
#8 lore raw
Quoted 15 lines · Kevin Wolf

Am 19.11.2010 17:30, schrieb [email protected]:

Quoted 3 lines

From: Jes Sorensen <[email protected]>

You're compiling the nbd block driver out here. This is certainly not what you were attempting. (However, it's the only way to make it work, because otherwise qemu-img will need the top-level nbd.o)

qemu-img -help before this change shows:

Supported formats: raw cow qcow vdi vmdk cloop dmg bochs vpc vvfat qcow2 parallels nbd blkdebug sheepdog blkverify host_cdrom host_floppy host_device file tftp ftps ftp https http

Quoted 5 lines

Afterwards:

Supported formats: raw cow qcow vdi vmdk cloop dmg bochs vpc vvfat qcow2 parallels blkdebug sheepdog blkverify host_cdrom host_floppy host_device file tftp ftps ftp https http

I am aware of that, but what on earth is qemu-img doing with NBD in the first place? Doesn't make much sense to me.

Cheers,
Jes

#9 lore raw

Am 22.11.2010 15:08, schrieb Jes Sorensen:

Quoted 16 lines · Kevin Wolf
Quoted 15 lines

Am 19.11.2010 17:30, schrieb [email protected]:

Quoted 3 lines

From: Jes Sorensen <[email protected]>

You're compiling the nbd block driver out here. This is certainly not what you were attempting. (However, it's the only way to make it work, because otherwise qemu-img will need the top-level nbd.o)

qemu-img -help before this change shows:

Supported formats: raw cow qcow vdi vmdk cloop dmg bochs vpc vvfat qcow2 parallels nbd blkdebug sheepdog blkverify host_cdrom host_floppy host_device file tftp ftps ftp https http

Quoted 8 lines
Quoted 5 lines

Afterwards:

Supported formats: raw cow qcow vdi vmdk cloop dmg bochs vpc vvfat qcow2 parallels blkdebug sheepdog blkverify host_cdrom host_floppy host_device file tftp ftps ftp https http

I am aware of that, but what on earth is qemu-img doing with NBD in the first place? Doesn't make much sense to me.

The same as it's doing with file, host_device or http: Accessing images. Start an NBD server (e.g. with qemu-nbd) and try something like qemu -hda nbd:localhost. This is how you use the nbd block driver.

Kevin

#10 lore raw
Quoted 7 lines · Kevin Wolf

Am 22.11.2010 15:08, schrieb Jes Sorensen:

Quoted 2 lines

I am aware of that, but what on earth is qemu-img doing with NBD in the first place? Doesn't make much sense to me.

The same as it's doing with file, host_device or http: Accessing images. Start an NBD server (e.g. with qemu-nbd) and try something like qemu -hda nbd:localhost. This is how you use the nbd block driver.

Well ok, seems a really backwards way to try and shoot yourself in the foot, but ok, maybe I should redo the patch to simply allow compiling NBD out instead.

Cheers,
Jes

#11 lore raw

Am 22.11.2010 15:27, schrieb Jes Sorensen:

Quoted 5 lines · Kevin Wolf
Quoted 4 lines

Am 22.11.2010 15:08, schrieb Jes Sorensen:

Quoted 2 lines

I am aware of that, but what on earth is qemu-img doing with NBD in the first place? Doesn't make much sense to me.

Quoted 7 lines
Quoted 3 lines

The same as it's doing with file, host_device or http: Accessing images. Start an NBD server (e.g. with qemu-nbd) and try something like qemu -hda nbd:localhost. This is how you use the nbd block driver.

Well ok, seems a really backwards way to try and shoot yourself in the foot, but ok, maybe I should redo the patch to simply allow compiling NBD out instead.

You're free to dislike NBD as much as you want. Just compiling it out unconditionally and calling it a cleanup is a bit too much. ;-)

A configure option for disabling NBD sounds reasonable, though I'm not sure what you're trying to achieve with it. It doesn't have any external dependencies that you could avoid this way, does it?

Kevin

#12 lore raw
Quoted 6 lines · Kevin Wolf

Am 22.11.2010 15:27, schrieb Jes Sorensen:

Quoted 4 lines · Kevin Wolf

Well ok, seems a really backwards way to try and shoot yourself in the foot, but ok, maybe I should redo the patch to simply allow compiling NBD out instead.

Quoted 6 lines

You're free to dislike NBD as much as you want. Just compiling it out unconditionally and calling it a cleanup is a bit too much. ;-)

A configure option for disabling NBD sounds reasonable, though I'm not sure what you're trying to achieve with it. It doesn't have any external dependencies that you could avoid this way, does it?

Well it would allow us to not build qemu-nbd and reduce the size of qemu, those are wins, albeit not that big.

Cheers,
Jes

#13 lore raw
In reply to Kevin Wolf
Quoted 7 lines · Kevin Wolf

You're free to dislike NBD as much as you want. Just compiling it out unconditionally and calling it a cleanup is a bit too much. ;-)

A configure option for disabling NBD sounds reasonable, though I'm not sure what you're trying to achieve with it. It doesn't have any external dependencies that you could avoid this way, does it?

Using block format whitelisting should be enough to disable nbd. I don't see a need for an explicit --disable-nbd option.

Regards,

Anthony Liguori

Quoted 3 lines

Kevin

#14 lore raw
Quoted 11 lines · Anthony Liguori
Quoted 7 lines · Kevin Wolf

You're free to dislike NBD as much as you want. Just compiling it out unconditionally and calling it a cleanup is a bit too much. ;-)

A configure option for disabling NBD sounds reasonable, though I'm not sure what you're trying to achieve with it. It doesn't have any external dependencies that you could avoid this way, does it?

Using block format whitelisting should be enough to disable nbd. I don't see a need for an explicit --disable-nbd option.

Right, the right solution is probably to create a block driver list argument for configure, similar to what we have for the sound drivers.

Ignore my patch.

Cheers,
Jes

#15 lore raw
Quoted 12 lines · Jes Sorensen
Quoted 10 lines · Anthony Liguori
Quoted 8 lines · Kevin Wolf

You're free to dislike NBD as much as you want. Just compiling it out unconditionally and calling it a cleanup is a bit too much. ;-)

A configure option for disabling NBD sounds reasonable, though I'm not sure what you're trying to achieve with it. It doesn't have any external dependencies that you could avoid this way, does it?

Quoted 6 lines
Quoted 3 lines

Using block format whitelisting should be enough to disable nbd. I don't see a need for an explicit --disable-nbd option.

Right, the right solution is probably to create a block driver list argument for configure, similar to what we have for the sound drivers.

--block-drv-whitelist=

Regards,

Anthony Liguori

Quoted 5 lines

Ignore my patch.

Cheers,
Jes

#16 lore raw
Quoted 10 lines · Anthony Liguori
Quoted 7 lines · Jes Sorensen
Quoted 3 lines · Anthony Liguori

Using block format whitelisting should be enough to disable nbd. I don't see a need for an explicit --disable-nbd option.

Right, the right solution is probably to create a block driver list argument for configure, similar to what we have for the sound drivers.

--block-drv-whitelist=

Any idea what the difference is between 'whitelist' and 'list' in this context?

Jes

#17 lore raw
Quoted 10 lines · Jes Sorensen
Quoted 8 lines · Anthony Liguori
Quoted 6 lines · Jes Sorensen
Quoted 4 lines · Anthony Liguori

Using block format whitelisting should be enough to disable nbd. I don't see a need for an explicit --disable-nbd option.

Quoted 9 lines
Quoted 6 lines
Quoted 4 lines

Right, the right solution is probably to create a block driver list argument for configure, similar to what we have for the sound drivers.

--block-drv-whitelist=

Any idea what the difference is between 'whitelist' and 'list' in this context?

Everything is built, but only the formats that are in the whitelist are usable.

Regards,

Anthony Liguori

Quoted 2 lines

Jes

#18 lore raw
Quoted 6 lines · Anthony Liguori
Quoted 5 lines · Jes Sorensen
Quoted 4 lines · Anthony Liguori
Quoted 3 lines · Jes Sorensen

Right, the right solution is probably to create a block driver list argument for configure, similar to what we have for the sound drivers.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

--block-drv-whitelist=

Any idea what the difference is between 'whitelist' and 'list' in this context?

Everything is built, but only the formats that are in the whitelist are usable.

Kinda defeats the purpose IMHO. It would be useful to be able to strip out the formats one doesn't want to get a slimmed down binary.

Cheers,
Jes

#19 lore raw
Quoted 9 lines · Jes Sorensen
Quoted 8 lines · Anthony Liguori
Quoted 7 lines · Jes Sorensen
Quoted 6 lines · Anthony Liguori
Quoted 3 lines · Jes Sorensen

Right, the right solution is probably to create a block driver list argument for configure, similar to what we have for the sound drivers.

--block-drv-whitelist=

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

Any idea what the difference is between 'whitelist' and 'list' in this context?

Everything is built, but only the formats that are in the whitelist are usable.

Kinda defeats the purpose IMHO. It would be useful to be able to strip out the formats one doesn't want to get a slimmed down binary.

There are two different purposes here:

1. You want to remove support for a format from QEMU and all the tools. That's what you have in mind, I think.

2. You want to distinguish between "good for production" and "not so good for production" formats. That's what the whitelist is for. Formats need to be whitelisted to be usable with QEMU proper. Tools normally ignore the whitelist. Lets you attempt offline format conversion for non-whitelisted formats, which is useful.

Both are legitimate, in my opinion.