diff mbox

[1/3] Support --sysconfdir in configure to specify path to configuration files (v3)

Message ID 1264342938-7363-2-git-send-email-aliguori@us.ibm.com
State New
Headers show

Commit Message

Anthony Liguori Jan. 24, 2010, 2:22 p.m. UTC
The default value is ${prefix}/etc/qemu.  --sysconfdir can be used to override
the default to an absolute path.  The expectation is that when installed to
/usr, --sysconfdir=/etc/qemu will be used.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
---
v2 -> v3
 - default sysconfdir to ${prefix}/etc on unix, ${prefix} on win32
 - set confdir to ${sysconfdir}/qemu on unix, ${sysconfdir} on win32
v1 -> v2
 - rename to sysconf
---
 configure |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)

Comments

Paolo Bonzini Jan. 24, 2010, 2:45 p.m. UTC | #1
On 01/24/2010 03:22 PM, Anthony Liguori wrote:
> The default value is ${prefix}/etc/qemu.  --sysconfdir can be used to override
> the default to an absolute path.  The expectation is that when installed to
> /usr, --sysconfdir=/etc/qemu will be used.
>
> Signed-off-by: Anthony Liguori<aliguori@us.ibm.com>
> ---
> v2 ->  v3
>   - default sysconfdir to ${prefix}/etc on unix, ${prefix} on win32
>   - set confdir to ${sysconfdir}/qemu on unix, ${sysconfdir} on win32

I'm not sure about the choice for Windows.  Do we want possibly a dozen 
of .conf files all in the same directory as the binaries, or maybe it's 
better to set sysconfdir = ${prefix}/conf, confdir=${sysconfdir} on Windows?

> +if test "$mingw32" = "yes" ; then
> +  echo "CONFIG_QEMU_CONFDIR=\"$sysconfdir\"" >> $config_host_mak
> +else
> +  echo "CONFIG_QEMU_CONFDIR=\"${sysconfdir}/qemu\"" >> $config_host_mak
> +fi

Also, here you can use $confsuffix as used a bit above to avoid 
introducing an if here.

Anyway, this can be discussed/cleaned up later, this patch gets my ack.

Paolo
Anthony Liguori Jan. 24, 2010, 3:23 p.m. UTC | #2
On 01/24/2010 08:45 AM, Paolo Bonzini wrote:
> On 01/24/2010 03:22 PM, Anthony Liguori wrote:
>> The default value is ${prefix}/etc/qemu.  --sysconfdir can be used to 
>> override
>> the default to an absolute path.  The expectation is that when 
>> installed to
>> /usr, --sysconfdir=/etc/qemu will be used.
>>
>> Signed-off-by: Anthony Liguori<aliguori@us.ibm.com>
>> ---
>> v2 ->  v3
>>   - default sysconfdir to ${prefix}/etc on unix, ${prefix} on win32
>>   - set confdir to ${sysconfdir}/qemu on unix, ${sysconfdir} on win32
>
> I'm not sure about the choice for Windows.  Do we want possibly a 
> dozen of .conf files all in the same directory as the binaries, or 
> maybe it's better to set sysconfdir = ${prefix}/conf, 
> confdir=${sysconfdir} on Windows?

I honestly don't know.  What's the normal thing to do with Windows?

>
>> +if test "$mingw32" = "yes" ; then
>> +  echo "CONFIG_QEMU_CONFDIR=\"$sysconfdir\"" >> $config_host_mak
>> +else
>> +  echo "CONFIG_QEMU_CONFDIR=\"${sysconfdir}/qemu\"" >> $config_host_mak
>> +fi
>
> Also, here you can use $confsuffix as used a bit above to avoid 
> introducing an if here.
>
> Anyway, this can be discussed/cleaned up later, this patch gets my ack.

Regards,

Anthony Liguori

> Paolo
>
>
>
Avi Kivity Jan. 25, 2010, 2:43 p.m. UTC | #3
On 01/24/2010 05:23 PM, Anthony Liguori wrote:
> On 01/24/2010 08:45 AM, Paolo Bonzini wrote:
>> On 01/24/2010 03:22 PM, Anthony Liguori wrote:
>>> The default value is ${prefix}/etc/qemu.  --sysconfdir can be used 
>>> to override
>>> the default to an absolute path.  The expectation is that when 
>>> installed to
>>> /usr, --sysconfdir=/etc/qemu will be used.
>>>
>>> Signed-off-by: Anthony Liguori<aliguori@us.ibm.com>
>>> ---
>>> v2 ->  v3
>>>   - default sysconfdir to ${prefix}/etc on unix, ${prefix} on win32
>>>   - set confdir to ${sysconfdir}/qemu on unix, ${sysconfdir} on win32
>>
>> I'm not sure about the choice for Windows.  Do we want possibly a 
>> dozen of .conf files all in the same directory as the binaries, or 
>> maybe it's better to set sysconfdir = ${prefix}/conf, 
>> confdir=${sysconfdir} on Windows?
>
> I honestly don't know.  What's the normal thing to do with Windows?

The registry, I think.
Paolo Bonzini Jan. 25, 2010, 9:05 p.m. UTC | #4
>>> I'm not sure about the choice for Windows. Do we want possibly a
>>> dozen of .conf files all in the same directory as the binaries, or
>>> maybe it's better to set sysconfdir = ${prefix}/conf,
>>> confdir=${sysconfdir} on Windows?
>>
>> I honestly don't know. What's the normal thing to do with Windows?
>
> The registry, I think.

The registry would be used indeed to get the path or to override 
defaults.  However, what would be the default value (written in the 
registry by the installer, or used by the program if the registry value 
is absent)?

Paolo
Anthony Liguori Jan. 25, 2010, 9:14 p.m. UTC | #5
On 01/25/2010 03:05 PM, Paolo Bonzini wrote:
>
>>>> I'm not sure about the choice for Windows. Do we want possibly a
>>>> dozen of .conf files all in the same directory as the binaries, or
>>>> maybe it's better to set sysconfdir = ${prefix}/conf,
>>>> confdir=${sysconfdir} on Windows?
>>>
>>> I honestly don't know. What's the normal thing to do with Windows?
>>
>> The registry, I think.
>
> The registry would be used indeed to get the path or to override 
> defaults.  However, what would be the default value (written in the 
> registry by the installer, or used by the program if the registry 
> value is absent)?

ini-style configs are not at all uncommon on Windows.  I also don't 
think it's that uncommon to store executables and config files 
side-by-side in a Program Files directory.

Regards,

Anthony Liguori

> Paolo
Paolo Bonzini Jan. 25, 2010, 9:19 p.m. UTC | #6
On 01/25/2010 10:14 PM, Anthony Liguori wrote:
> On 01/25/2010 03:05 PM, Paolo Bonzini wrote:
>>
>>>>> I'm not sure about the choice for Windows. Do we want
>>>>> possibly a dozen of .conf files all in the same directory as
>>>>> the binaries, or maybe it's better to set sysconfdir =
>>>>> ${prefix}/conf, confdir=${sysconfdir} on Windows?
>>>>
>>>> I honestly don't know. What's the normal thing to do with
>>>> Windows?
>>>
>>> The registry, I think.
>>
>> The registry would be used indeed to get the path or to override
>> defaults. However, what would be the default value (written in the
>> registry by the installer, or used by the program if the registry
>> value is absent)?
>
> ini-style configs are not at all uncommon on Windows. I also don't
> think it's that uncommon to store executables and config files
> side-by-side in a Program Files directory.

Indeed, that's what I'm saying.  The registry may hold a path to the
ini files, but you would still have to think of a sane default.  You
chose the binaries' directory, fine, that's not a huge deal---someone
who cares about Windows can step up and say what they think.

Paolo
Avi Kivity Jan. 26, 2010, 8:56 a.m. UTC | #7
On 01/25/2010 11:05 PM, Paolo Bonzini wrote:
>
>>>> I'm not sure about the choice for Windows. Do we want possibly a
>>>> dozen of .conf files all in the same directory as the binaries, or
>>>> maybe it's better to set sysconfdir = ${prefix}/conf,
>>>> confdir=${sysconfdir} on Windows?
>>>
>>> I honestly don't know. What's the normal thing to do with Windows?
>>
>> The registry, I think.
>
> The registry would be used indeed to get the path or to override 
> defaults.  However, what would be the default value (written in the 
> registry by the installer, or used by the program if the registry 
> value is absent)?

You could use the registry to hold the defaults, not a path to the defaults.
diff mbox

Patch

diff --git a/configure b/configure
index 5631bbb..379b536 100755
--- a/configure
+++ b/configure
@@ -32,6 +32,7 @@  cpu=""
 prefix=""
 interp_prefix="/usr/gnemul/qemu-%M"
 static="no"
+sysconfdir=""
 sparc_cpu=""
 cross_prefix=""
 cc="gcc"
@@ -453,6 +454,8 @@  for opt do
   ;;
   --static) static="yes"
   ;;
+  --sysconfdir) sysconfdir="$optarg"
+  ;;
   --disable-sdl) sdl="no"
   ;;
   --enable-sdl) sdl="yes"
@@ -686,6 +689,7 @@  echo "  --extra-ldflags=LDFLAGS  append extra linker flags LDFLAGS"
 echo "  --make=MAKE              use specified make [$make]"
 echo "  --install=INSTALL        use specified install [$install]"
 echo "  --static                 enable static build [$static]"
+echo "  --sysconfdir=PATH        install config in PATH"
 echo "  --enable-debug-tcg       enable TCG debugging"
 echo "  --disable-debug-tcg      disable TCG debugging (default)"
 echo "  --enable-debug           enable common debug build options"
@@ -1828,8 +1832,12 @@  if test "$mingw32" = "yes" ; then
   fi
   mansuffix=""
   datasuffix=""
+  confsuffix=""
   docsuffix=""
   binsuffix=""
+  if test -z "$sysconfdir" ; then
+      sysconfdir="${prefix}"
+  fi
 else
   if test -z "$prefix" ; then
       prefix="/usr/local"
@@ -1838,6 +1846,9 @@  else
   datasuffix="/share/qemu"
   docsuffix="/share/doc/qemu"
   binsuffix="/bin"
+  if test -z "$sysconfdir" ; then
+      sysconfdir="${prefix}/etc"
+  fi
 fi
 
 echo "Install prefix    $prefix"
@@ -1914,6 +1925,11 @@  printf " '%s'" "$0" "$@" >> $config_host_mak
 echo >> $config_host_mak
 
 echo "CONFIG_QEMU_SHAREDIR=\"$prefix$datasuffix\"" >> $config_host_mak
+if test "$mingw32" = "yes" ; then
+  echo "CONFIG_QEMU_CONFDIR=\"$sysconfdir\"" >> $config_host_mak
+else
+  echo "CONFIG_QEMU_CONFDIR=\"${sysconfdir}/qemu\"" >> $config_host_mak
+fi
 
 case "$cpu" in
   i386|x86_64|alpha|cris|hppa|ia64|m68k|microblaze|mips|mips64|ppc|ppc64|s390|s390x|sparc|sparc64)
@@ -2159,6 +2175,7 @@  echo "prefix=$prefix" >> $config_host_mak
 echo "bindir=\${prefix}$binsuffix" >> $config_host_mak
 echo "mandir=\${prefix}$mansuffix" >> $config_host_mak
 echo "datadir=\${prefix}$datasuffix" >> $config_host_mak
+echo "sysconfdir=$sysconfdir" >> $config_host_mak
 echo "docdir=\${prefix}$docsuffix" >> $config_host_mak
 echo "MAKE=$make" >> $config_host_mak
 echo "INSTALL=$install" >> $config_host_mak