Skip to contentSkip to conversation

Add ability to build without any targets enabled

PATCH In review Daniel P. Berrange 3 participants 3 messages Aug 31, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Add ability to build without any targets enabled

From: "Daniel P. Berrange" <[email protected]>

The qemu-img, qemu-nbd and qemu-io tools are quite useful in their own right. eg LXC can use qemu-img and qemu-nbd to support running of containers with qcow2 images. As such it is reasonable to allow building these tools, without enabling any QEMU targets. This change does two things:

- Allows passing an empty string to the --target-list arg to disable all targets
- Adds --enable-tools/--disable-tools args to enable/disable building of qemu-img, qemu-nbd and qemu-io independantly of whether any softmmu target is disabled. The builds default to enabled at all times.

With this you can do

  ./configure --target-list=

and get a build that only includes the basic tools

---
 configure | 38 ++++++++++++++++++++++++++------------
 1 file changed, 26 insertions(+), 12 deletions(-)
configure +26 -12
index d97fd81..bbde154 100755
@@ -128,6 +128,7 @@ libs_qga=""
 debug_info="yes"
 
 target_list=""
+without_targets=0
 
 # Default value for a variable defining feature "foo".
 #  * foo="no"  feature will only be used if --enable-foo arg is given
@@ -216,6 +217,7 @@ usb_redir=""
 opengl=""
 zlib="yes"
 guest_agent="yes"
+want_tools="yes"
 libiscsi=""
 coroutine=""
 seccomp=""
@@ -614,7 +616,12 @@ for opt do
   ;;
   --cpu=*)
   ;;
-  --target-list=*) target_list="$optarg"
+  --target-list=*)
+    if test -z "$optarg" ; then
+        without_targets=1
+    else
+        target_list="$optarg"
+    fi
   ;;
   --enable-trace-backend=*) trace_backend="$optarg"
   ;;
@@ -865,6 +872,10 @@ for opt do
   ;;
   --disable-guest-agent) guest_agent="no"
   ;;
+  --enable-tools) want_tools="yes"
+  ;;
+  --disable-tools) want_tools="no"
+  ;;
   --enable-seccomp) seccomp="yes"
   ;;
   --disable-seccomp) seccomp="no"
@@ -1315,14 +1326,13 @@ if ! "$python" -c 'import sys; sys.exit(sys.version_info < (2,4) or sys.version_
 fi
 
 if test -z "$target_list" ; then
-    target_list="$default_target_list"
+    if test $without_targets = 0 ; then
+        target_list="$default_target_list"
+    fi
 else
     target_list=`echo "$target_list" | sed -e 's/,/ /g'`
 fi
-if test -z "$target_list" ; then
-    echo "No targets enabled"
-    exit 1
-fi
+
 # see if system emulation was really requested
 case " $target_list " in
   *"-softmmu "*) softmmu=yes
@@ -3039,9 +3049,14 @@ fi
 qemu_confdir=$sysconfdir$confsuffix
 qemu_datadir=$datadir$confsuffix
 
-tools=
-if test "$softmmu" = yes ; then
+tools=""
+if test "$want_tools" = "yes" ; then
   tools="qemu-img\$(EXESUF) qemu-io\$(EXESUF) $tools"
+  if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" ] ; then
+    tools="qemu-nbd\$(EXESUF) $tools"
+  fi
+fi
+if test "$softmmu" = yes ; then
   if test "$virtfs" != no ; then
     if test "$cap" = yes && test "$linux" = yes && test "$attr" = yes ; then
       virtfs=yes
@@ -3055,14 +3070,13 @@ if test "$softmmu" = yes ; then
     fi
   fi
   if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" ] ; then
-      tools="qemu-nbd\$(EXESUF) $tools"
     if [ "$guest_agent" = "yes" ]; then
       tools="qemu-ga\$(EXESUF) $tools"
     fi
   fi
-fi
-if test "$smartcard_nss" = "yes" ; then
-  tools="vscclient\$(EXESUF) $tools"
+  if test "$smartcard_nss" = "yes" ; then
+    tools="vscclient\$(EXESUF) $tools"
+  fi
 fi
 
 # Mac OS X ships with a broken assembler
Signature · 1 line
1.7.11.2
#1 lore raw
Quoted 8 lines · Daniel P. Berrange

From: "Daniel P. Berrange" <[email protected]>

The qemu-img, qemu-nbd and qemu-io tools are quite useful in their own right. eg LXC can use qemu-img and qemu-nbd to support running of containers with qcow2 images. As such it is reasonable to allow building these tools, without enabling any QEMU targets. This change does two things:

Quoted 6 lines

- Allows passing an empty string to the --target-list arg to disable all targets
- Adds --enable-tools/--disable-tools args to enable/disable building of qemu-img, qemu-nbd and qemu-io independantly of whether any softmmu target is disabled. The builds default to enabled at all times.

Feels to me like these should be separate patches.

Quoted 33 lines

With this you can do

  ./configure --target-list=

and get a build that only includes the basic tools

---
 configure | 38 ++++++++++++++++++++++++++------------
 1 file changed, 26 insertions(+), 12 deletions(-)
configure +2 -0
index d97fd81..bbde154 100755
@@ -128,6 +128,7 @@ libs_qga=""
 debug_info="yes"
 
 target_list=""
+without_targets=0
 
 # Default value for a variable defining feature "foo".
 #  * foo="no"  feature will only be used if --enable-foo arg is given
@@ -216,6 +217,7 @@ usb_redir=""
 opengl=""
 zlib="yes"
 guest_agent="yes"
+want_tools="yes"
 libiscsi=""
 coroutine=""
 seccomp=""
@@ -614,7 +616,12 @@ for opt do
   ;;

configure for opt do · line 625

Quoted 10 lines
configure +6 -1
   --cpu=*)
   ;;
-  --target-list=*) target_list="$optarg"
+  --target-list=*)
+    if test -z "$optarg" ; then
+        without_targets=1
+    else
+        target_list="$optarg"
+    fi
   ;;

I think the code ends up a bit simpler if you start with target_list=DEFAULT
and use that as the indicator of 'use default list' rather than the empty string. However that does add the 'undocumented feature' that '--target-list=DEFAULT' becomes valid...

-- PMM

#2 lore raw

Am 31.08.2012 19:15, schrieb Peter Maydell:

Quoted 68 lines · Daniel P. Berrange
Quoted 8 lines

From: "Daniel P. Berrange"<[email protected]>

The qemu-img, qemu-nbd and qemu-io tools are quite useful in their own right. eg LXC can use qemu-img and qemu-nbd to support running of containers with qcow2 images. As such it is reasonable to allow building these tools, without enabling any QEMU targets. This change does two things:

Quoted 6 lines

- Allows passing an empty string to the --target-list arg to disable all targets
- Adds --enable-tools/--disable-tools args to enable/disable building of qemu-img, qemu-nbd and qemu-io independantly of whether any softmmu target is disabled. The builds default to enabled at all times.

Feels to me like these should be separate patches.

Quoted 33 lines

With this you can do

   ./configure --target-list=

and get a build that only includes the basic tools

---
  configure | 38 ++++++++++++++++++++++++++------------
  1 file changed, 26 insertions(+), 12 deletions(-)
configure +2 -0
index d97fd81..bbde154 100755
@@ -128,6 +128,7 @@ libs_qga=""
  debug_info="yes"
 
  target_list=""
+without_targets=0
 
  # Default value for a variable defining feature "foo".
  #  * foo="no"  feature will only be used if --enable-foo arg is given
@@ -216,6 +217,7 @@ usb_redir=""
  opengl=""
  zlib="yes"
  guest_agent="yes"
+want_tools="yes"
  libiscsi=""
  coroutine=""
  seccomp=""
@@ -614,7 +616,12 @@ for opt do
    ;;

configure for opt do · line 625

Quoted 10 lines
configure +6 -1
    --cpu=*)
    ;;
-  --target-list=*) target_list="$optarg"
+  --target-list=*)
+    if test -z "$optarg" ; then
+        without_targets=1
+    else
+        target_list="$optarg"
+    fi
    ;;

I think the code ends up a bit simpler if you start with target_list=DEFAULT
and use that as the indicator of 'use default list' rather than the empty string. However that does add the 'undocumented feature' that '--target-list=DEFAULT' becomes valid...

Quoted 1 line

-- PMM

An undefined target_list might be a better indicator and does not add undocumented features.

I appreciate the possibility of default builds without tools:
they save time when running 'git bisect' or in cross builds when the tools are not needed.

My private QEMU has this feature since several years, but uses an approach which differs from this patch: there are always Makefile targets 'doc' and 'tools'. By default, 'all' includes 'doc' and 'tools', but they can be disabled using configure options (--disable-docs, --disable-tools). Even when they are disabled, it is possible to run 'make doc' or 'make tools'.

Regards,

Stefan W.