diff mbox

[2/2] qemu-ga: use state dir from CONFIG_QEMU_LOCALSTATEDIR

Message ID 1349300158-19113-3-git-send-email-lcapitulino@redhat.com
State New
Headers show

Commit Message

Luiz Capitulino Oct. 3, 2012, 9:35 p.m. UTC
Has the side effect of changing the default directory used to
save the freeze status file from /tmp to ${prefix}/var/run.

This is a beneficial change for two reasons:

  1. FHS states that programs must not assume that files in /tmp will
     still exist between invocations of the program. This defeats
	 the purpose of the freeze status file

  2. FHS dictates that /var/run must be cleaned on boot, this
     ensures that a stale freeze status file will be removed on boot

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
 qemu-ga.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Michael Roth Oct. 4, 2012, 3:47 p.m. UTC | #1
On Wed, Oct 03, 2012 at 06:35:58PM -0300, Luiz Capitulino wrote:
> Has the side effect of changing the default directory used to
> save the freeze status file from /tmp to ${prefix}/var/run.
> 
> This is a beneficial change for two reasons:
> 
>   1. FHS states that programs must not assume that files in /tmp will
>      still exist between invocations of the program. This defeats
> 	 the purpose of the freeze status file
> 
>   2. FHS dictates that /var/run must be cleaned on boot, this
>      ensures that a stale freeze status file will be removed on boot
> 
> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
> ---
>  qemu-ga.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/qemu-ga.c b/qemu-ga.c
> index b747470..daeaea5 100644
> --- a/qemu-ga.c
> +++ b/qemu-ga.c
> @@ -40,8 +40,8 @@
>  #else
>  #define QGA_VIRTIO_PATH_DEFAULT "\\\\.\\Global\\org.qemu.guest_agent.0"
>  #endif
> -#define QGA_PIDFILE_DEFAULT "/var/run/qemu-ga.pid"
> -#define QGA_STATEDIR_DEFAULT "/tmp"
> +#define QGA_STATEDIR_DEFAULT CONFIG_QEMU_LOCALSTATEDIR "/run"
> +#define QGA_PIDFILE_DEFAULT QGA_STATEDIR_DEFAULT "/qemu-ga.pid"

Just to confirm, in configure we have:

echo "qemu_localstatedir=$local_statedir" >> $config_host_mak

Is there some magic that generates a CONFIG_QEMU_LOCALSTATEDIR with the
same value? If so:

Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>

>  #define QGA_SENTINEL_BYTE 0xFF
> 
>  struct GAState {
> -- 
> 1.7.12.315.g682ce8b
>
Luiz Capitulino Oct. 4, 2012, 3:50 p.m. UTC | #2
On Thu, 4 Oct 2012 10:47:06 -0500
Michael Roth <mdroth@linux.vnet.ibm.com> wrote:

> On Wed, Oct 03, 2012 at 06:35:58PM -0300, Luiz Capitulino wrote:
> > Has the side effect of changing the default directory used to
> > save the freeze status file from /tmp to ${prefix}/var/run.
> > 
> > This is a beneficial change for two reasons:
> > 
> >   1. FHS states that programs must not assume that files in /tmp will
> >      still exist between invocations of the program. This defeats
> > 	 the purpose of the freeze status file
> > 
> >   2. FHS dictates that /var/run must be cleaned on boot, this
> >      ensures that a stale freeze status file will be removed on boot
> > 
> > Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
> > ---
> >  qemu-ga.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/qemu-ga.c b/qemu-ga.c
> > index b747470..daeaea5 100644
> > --- a/qemu-ga.c
> > +++ b/qemu-ga.c
> > @@ -40,8 +40,8 @@
> >  #else
> >  #define QGA_VIRTIO_PATH_DEFAULT "\\\\.\\Global\\org.qemu.guest_agent.0"
> >  #endif
> > -#define QGA_PIDFILE_DEFAULT "/var/run/qemu-ga.pid"
> > -#define QGA_STATEDIR_DEFAULT "/tmp"
> > +#define QGA_STATEDIR_DEFAULT CONFIG_QEMU_LOCALSTATEDIR "/run"
> > +#define QGA_PIDFILE_DEFAULT QGA_STATEDIR_DEFAULT "/qemu-ga.pid"
> 
> Just to confirm, in configure we have:
> 
> echo "qemu_localstatedir=$local_statedir" >> $config_host_mak
> 
> Is there some magic that generates a CONFIG_QEMU_LOCALSTATEDIR with the
> same value? If so:

Yes, that's done by scripts/create_config

> Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>

Btw, is this going through your tree?

> 
> >  #define QGA_SENTINEL_BYTE 0xFF
> > 
> >  struct GAState {
> > -- 
> > 1.7.12.315.g682ce8b
> > 
>
Michael Roth Oct. 4, 2012, 5:37 p.m. UTC | #3
On Thu, Oct 04, 2012 at 12:50:15PM -0300, Luiz Capitulino wrote:
> On Thu, 4 Oct 2012 10:47:06 -0500
> Michael Roth <mdroth@linux.vnet.ibm.com> wrote:
> 
> > On Wed, Oct 03, 2012 at 06:35:58PM -0300, Luiz Capitulino wrote:
> > > Has the side effect of changing the default directory used to
> > > save the freeze status file from /tmp to ${prefix}/var/run.
> > > 
> > > This is a beneficial change for two reasons:
> > > 
> > >   1. FHS states that programs must not assume that files in /tmp will
> > >      still exist between invocations of the program. This defeats
> > > 	 the purpose of the freeze status file
> > > 
> > >   2. FHS dictates that /var/run must be cleaned on boot, this
> > >      ensures that a stale freeze status file will be removed on boot
> > > 
> > > Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
> > > ---
> > >  qemu-ga.c | 4 ++--
> > >  1 file changed, 2 insertions(+), 2 deletions(-)
> > > 
> > > diff --git a/qemu-ga.c b/qemu-ga.c
> > > index b747470..daeaea5 100644
> > > --- a/qemu-ga.c
> > > +++ b/qemu-ga.c
> > > @@ -40,8 +40,8 @@
> > >  #else
> > >  #define QGA_VIRTIO_PATH_DEFAULT "\\\\.\\Global\\org.qemu.guest_agent.0"
> > >  #endif
> > > -#define QGA_PIDFILE_DEFAULT "/var/run/qemu-ga.pid"
> > > -#define QGA_STATEDIR_DEFAULT "/tmp"
> > > +#define QGA_STATEDIR_DEFAULT CONFIG_QEMU_LOCALSTATEDIR "/run"
> > > +#define QGA_PIDFILE_DEFAULT QGA_STATEDIR_DEFAULT "/qemu-ga.pid"
> > 
> > Just to confirm, in configure we have:
> > 
> > echo "qemu_localstatedir=$local_statedir" >> $config_host_mak
> > 
> > Is there some magic that generates a CONFIG_QEMU_LOCALSTATEDIR with the
> > same value? If so:
> 
> Yes, that's done by scripts/create_config
> 
> > Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>
> 
> Btw, is this going through your tree?

Yup, was planning on sending a pull tomorrow after some basic testing.
Same for the standalone pidfile fix-up.

> 
> > 
> > >  #define QGA_SENTINEL_BYTE 0xFF
> > > 
> > >  struct GAState {
> > > -- 
> > > 1.7.12.315.g682ce8b
> > > 
> > 
>
Luiz Capitulino Oct. 4, 2012, 5:48 p.m. UTC | #4
On Thu, 4 Oct 2012 12:37:55 -0500
Michael Roth <mdroth@linux.vnet.ibm.com> wrote:

> On Thu, Oct 04, 2012 at 12:50:15PM -0300, Luiz Capitulino wrote:
> > On Thu, 4 Oct 2012 10:47:06 -0500
> > Michael Roth <mdroth@linux.vnet.ibm.com> wrote:
> > 
> > > On Wed, Oct 03, 2012 at 06:35:58PM -0300, Luiz Capitulino wrote:
> > > > Has the side effect of changing the default directory used to
> > > > save the freeze status file from /tmp to ${prefix}/var/run.
> > > > 
> > > > This is a beneficial change for two reasons:
> > > > 
> > > >   1. FHS states that programs must not assume that files in /tmp will
> > > >      still exist between invocations of the program. This defeats
> > > > 	 the purpose of the freeze status file
> > > > 
> > > >   2. FHS dictates that /var/run must be cleaned on boot, this
> > > >      ensures that a stale freeze status file will be removed on boot
> > > > 
> > > > Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
> > > > ---
> > > >  qemu-ga.c | 4 ++--
> > > >  1 file changed, 2 insertions(+), 2 deletions(-)
> > > > 
> > > > diff --git a/qemu-ga.c b/qemu-ga.c
> > > > index b747470..daeaea5 100644
> > > > --- a/qemu-ga.c
> > > > +++ b/qemu-ga.c
> > > > @@ -40,8 +40,8 @@
> > > >  #else
> > > >  #define QGA_VIRTIO_PATH_DEFAULT "\\\\.\\Global\\org.qemu.guest_agent.0"
> > > >  #endif
> > > > -#define QGA_PIDFILE_DEFAULT "/var/run/qemu-ga.pid"
> > > > -#define QGA_STATEDIR_DEFAULT "/tmp"
> > > > +#define QGA_STATEDIR_DEFAULT CONFIG_QEMU_LOCALSTATEDIR "/run"
> > > > +#define QGA_PIDFILE_DEFAULT QGA_STATEDIR_DEFAULT "/qemu-ga.pid"
> > > 
> > > Just to confirm, in configure we have:
> > > 
> > > echo "qemu_localstatedir=$local_statedir" >> $config_host_mak
> > > 
> > > Is there some magic that generates a CONFIG_QEMU_LOCALSTATEDIR with the
> > > same value? If so:
> > 
> > Yes, that's done by scripts/create_config
> > 
> > > Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>
> > 
> > Btw, is this going through your tree?
> 
> Yup, was planning on sending a pull tomorrow after some basic testing.
> Same for the standalone pidfile fix-up.

Ok! Please, I didn't mean to hurry you up, just wanted to check we wouldn't
deadlock waiting for each other :)

> 
> > 
> > > 
> > > >  #define QGA_SENTINEL_BYTE 0xFF
> > > > 
> > > >  struct GAState {
> > > > -- 
> > > > 1.7.12.315.g682ce8b
> > > > 
> > > 
> > 
>
Michael Roth Oct. 4, 2012, 6:01 p.m. UTC | #5
On Thu, Oct 04, 2012 at 02:48:38PM -0300, Luiz Capitulino wrote:
> On Thu, 4 Oct 2012 12:37:55 -0500
> Michael Roth <mdroth@linux.vnet.ibm.com> wrote:
> 
> > On Thu, Oct 04, 2012 at 12:50:15PM -0300, Luiz Capitulino wrote:
> > > On Thu, 4 Oct 2012 10:47:06 -0500
> > > Michael Roth <mdroth@linux.vnet.ibm.com> wrote:
> > > 
> > > > On Wed, Oct 03, 2012 at 06:35:58PM -0300, Luiz Capitulino wrote:
> > > > > Has the side effect of changing the default directory used to
> > > > > save the freeze status file from /tmp to ${prefix}/var/run.
> > > > > 
> > > > > This is a beneficial change for two reasons:
> > > > > 
> > > > >   1. FHS states that programs must not assume that files in /tmp will
> > > > >      still exist between invocations of the program. This defeats
> > > > > 	 the purpose of the freeze status file
> > > > > 
> > > > >   2. FHS dictates that /var/run must be cleaned on boot, this
> > > > >      ensures that a stale freeze status file will be removed on boot
> > > > > 
> > > > > Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
> > > > > ---
> > > > >  qemu-ga.c | 4 ++--
> > > > >  1 file changed, 2 insertions(+), 2 deletions(-)
> > > > > 
> > > > > diff --git a/qemu-ga.c b/qemu-ga.c
> > > > > index b747470..daeaea5 100644
> > > > > --- a/qemu-ga.c
> > > > > +++ b/qemu-ga.c
> > > > > @@ -40,8 +40,8 @@
> > > > >  #else
> > > > >  #define QGA_VIRTIO_PATH_DEFAULT "\\\\.\\Global\\org.qemu.guest_agent.0"
> > > > >  #endif
> > > > > -#define QGA_PIDFILE_DEFAULT "/var/run/qemu-ga.pid"
> > > > > -#define QGA_STATEDIR_DEFAULT "/tmp"
> > > > > +#define QGA_STATEDIR_DEFAULT CONFIG_QEMU_LOCALSTATEDIR "/run"
> > > > > +#define QGA_PIDFILE_DEFAULT QGA_STATEDIR_DEFAULT "/qemu-ga.pid"
> > > > 
> > > > Just to confirm, in configure we have:
> > > > 
> > > > echo "qemu_localstatedir=$local_statedir" >> $config_host_mak
> > > > 
> > > > Is there some magic that generates a CONFIG_QEMU_LOCALSTATEDIR with the
> > > > same value? If so:
> > > 
> > > Yes, that's done by scripts/create_config
> > > 
> > > > Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>
> > > 
> > > Btw, is this going through your tree?
> > 
> > Yup, was planning on sending a pull tomorrow after some basic testing.
> > Same for the standalone pidfile fix-up.
> 
> Ok! Please, I didn't mean to hurry you up, just wanted to check we wouldn't
> deadlock waiting for each other :)

Understood; no worries :) Patches seem pretty straightforward and the qemu-ga queue
isn't exactly overflowing atm so I didn't see any reason to sit on these
for too long.

> 
> > 
> > > 
> > > > 
> > > > >  #define QGA_SENTINEL_BYTE 0xFF
> > > > > 
> > > > >  struct GAState {
> > > > > -- 
> > > > > 1.7.12.315.g682ce8b
> > > > > 
> > > > 
> > > 
> > 
>
diff mbox

Patch

diff --git a/qemu-ga.c b/qemu-ga.c
index b747470..daeaea5 100644
--- a/qemu-ga.c
+++ b/qemu-ga.c
@@ -40,8 +40,8 @@ 
 #else
 #define QGA_VIRTIO_PATH_DEFAULT "\\\\.\\Global\\org.qemu.guest_agent.0"
 #endif
-#define QGA_PIDFILE_DEFAULT "/var/run/qemu-ga.pid"
-#define QGA_STATEDIR_DEFAULT "/tmp"
+#define QGA_STATEDIR_DEFAULT CONFIG_QEMU_LOCALSTATEDIR "/run"
+#define QGA_PIDFILE_DEFAULT QGA_STATEDIR_DEFAULT "/qemu-ga.pid"
 #define QGA_SENTINEL_BYTE 0xFF
 
 struct GAState {