Patchwork qemu-ga: stub out guest-suspend* for non-linux

login
register
mail settings
Submitter Michael Roth
Date March 21, 2012, 12:54 a.m.
Message ID <1332291249-18212-1-git-send-email-mdroth@linux.vnet.ibm.com>
Download mbox | patch
Permalink /patch/147888/
State New
Headers show

Comments

Michael Roth - March 21, 2012, 12:54 a.m.
This currently breaks the build for BSDs.

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
---
 qga/commands-posix.c |   22 ++++++++++++++++++++++
 1 files changed, 22 insertions(+), 0 deletions(-)
Luiz Capitulino - March 23, 2012, 6:20 p.m.
On Tue, 20 Mar 2012 19:54:09 -0500
Michael Roth <mdroth@linux.vnet.ibm.com> wrote:

> This currently breaks the build for BSDs.
> 
> Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
> ---
>  qga/commands-posix.c |   22 ++++++++++++++++++++++
>  1 files changed, 22 insertions(+), 0 deletions(-)
> 
> diff --git a/qga/commands-posix.c b/qga/commands-posix.c
> index 89dde92..16737d7 100644
> --- a/qga/commands-posix.c
> +++ b/qga/commands-posix.c
> @@ -24,10 +24,12 @@
>  
>  #include <sys/types.h>
>  #include <sys/ioctl.h>
> +#if defined(__linux__)
>  #include <ifaddrs.h>
>  #include <arpa/inet.h>
>  #include <sys/socket.h>
>  #include <net/if.h>
> +#endif
>  #include <sys/wait.h>
>  #include "qga/guest-agent-core.h"
>  #include "qga-qmp-commands.h"
> @@ -542,6 +544,7 @@ int64_t qmp_guest_fsfreeze_thaw(Error **err)
>  #define SUSPEND_SUPPORTED 0
>  #define SUSPEND_NOT_SUPPORTED 1

Missing the macros and I think reopen_fd_to_null() is missing too, also
doesn't apply to latest master.

>  
> +#if defined(__linux__)
>  /**
>   * This function forks twice and the information about the mode support
>   * status is passed to the qemu-ga process via a pipe.
> @@ -729,6 +732,25 @@ void qmp_guest_suspend_hybrid(Error **err)
>      guest_suspend("pm-suspend-hybrid", NULL, err);
>  }
>  
> +#else /* defined(linux) */
> +
> +void qmp_guest_suspend_disk(Error **err)
> +{
> +    error_set(err, QERR_UNSUPPORTED);
> +}
> +
> +void qmp_guest_suspend_ram(Error **err)
> +{
> +    error_set(err, QERR_UNSUPPORTED);
> +}
> +
> +void qmp_guest_suspend_hybrid(Error **err)
> +{
> +    error_set(err, QERR_UNSUPPORTED);
> +}
> +
> +#endif
> +
>  #if defined(__linux__)

I think it would be nice to reorganize the functions in this file so that
we could have only one #if defined(__linux__) (or even split this into two
files)...

>  static GuestNetworkInterfaceList *
>  guest_find_interface(GuestNetworkInterfaceList *head,
Michael Roth - March 23, 2012, 7:11 p.m.
On Fri, Mar 23, 2012 at 03:20:22PM -0300, Luiz Capitulino wrote:
> On Tue, 20 Mar 2012 19:54:09 -0500
> Michael Roth <mdroth@linux.vnet.ibm.com> wrote:
> 
> > This currently breaks the build for BSDs.
> > 
> > Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
> > ---
> >  qga/commands-posix.c |   22 ++++++++++++++++++++++
> >  1 files changed, 22 insertions(+), 0 deletions(-)
> > 
> > diff --git a/qga/commands-posix.c b/qga/commands-posix.c
> > index 89dde92..16737d7 100644
> > --- a/qga/commands-posix.c
> > +++ b/qga/commands-posix.c
> > @@ -24,10 +24,12 @@
> >  
> >  #include <sys/types.h>
> >  #include <sys/ioctl.h>
> > +#if defined(__linux__)
> >  #include <ifaddrs.h>
> >  #include <arpa/inet.h>
> >  #include <sys/socket.h>
> >  #include <net/if.h>
> > +#endif
> >  #include <sys/wait.h>
> >  #include "qga/guest-agent-core.h"
> >  #include "qga-qmp-commands.h"
> > @@ -542,6 +544,7 @@ int64_t qmp_guest_fsfreeze_thaw(Error **err)
> >  #define SUSPEND_SUPPORTED 0
> >  #define SUSPEND_NOT_SUPPORTED 1
> 
> Missing the macros and I think reopen_fd_to_null() is missing too, also
> doesn't apply to latest master.
> 

Shouldn't hurt, but yah, leaving them in is a bit sloppy.

Don't see why this wouldn't apply though... are you applying on top of
Michal's patch? This patch was meant to be the guest-suspend counterpart
rather than a standalone fix.

> >  
> > +#if defined(__linux__)
> >  /**
> >   * This function forks twice and the information about the mode support
> >   * status is passed to the qemu-ga process via a pipe.
> > @@ -729,6 +732,25 @@ void qmp_guest_suspend_hybrid(Error **err)
> >      guest_suspend("pm-suspend-hybrid", NULL, err);
> >  }
> >  
> > +#else /* defined(linux) */
> > +
> > +void qmp_guest_suspend_disk(Error **err)
> > +{
> > +    error_set(err, QERR_UNSUPPORTED);
> > +}
> > +
> > +void qmp_guest_suspend_ram(Error **err)
> > +{
> > +    error_set(err, QERR_UNSUPPORTED);
> > +}
> > +
> > +void qmp_guest_suspend_hybrid(Error **err)
> > +{
> > +    error_set(err, QERR_UNSUPPORTED);
> > +}
> > +
> > +#endif
> > +
> >  #if defined(__linux__)
> 
> I think it would be nice to reorganize the functions in this file so that
> we could have only one #if defined(__linux__) (or even split this into two
> files)...
> 

Yah..that's a good idea, since atm we have suspend, network-get-interface, and
fsfreeze. I'll post a standalone patch to move all the linux-only stuff
into a contiguous chunk. Seperate files I think is a bit extreme, since
AFAICT there's no major reason we shouldn't be able to get the first 2 ported,
and I'd prefer that we avoid doing linux-specific implementations in the
future. Script-deployment via guest-file-write/guest-exec is where we wanna go
long-term for stuff like that.

> >  static GuestNetworkInterfaceList *
> >  guest_find_interface(GuestNetworkInterfaceList *head,
>
Luiz Capitulino - March 23, 2012, 8:37 p.m.
On Fri, 23 Mar 2012 14:11:53 -0500
Michael Roth <mdroth@linux.vnet.ibm.com> wrote:

> On Fri, Mar 23, 2012 at 03:20:22PM -0300, Luiz Capitulino wrote:
> > On Tue, 20 Mar 2012 19:54:09 -0500
> > Michael Roth <mdroth@linux.vnet.ibm.com> wrote:
> > 
> > > This currently breaks the build for BSDs.
> > > 
> > > Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
> > > ---
> > >  qga/commands-posix.c |   22 ++++++++++++++++++++++
> > >  1 files changed, 22 insertions(+), 0 deletions(-)
> > > 
> > > diff --git a/qga/commands-posix.c b/qga/commands-posix.c
> > > index 89dde92..16737d7 100644
> > > --- a/qga/commands-posix.c
> > > +++ b/qga/commands-posix.c
> > > @@ -24,10 +24,12 @@
> > >  
> > >  #include <sys/types.h>
> > >  #include <sys/ioctl.h>
> > > +#if defined(__linux__)
> > >  #include <ifaddrs.h>
> > >  #include <arpa/inet.h>
> > >  #include <sys/socket.h>
> > >  #include <net/if.h>
> > > +#endif
> > >  #include <sys/wait.h>
> > >  #include "qga/guest-agent-core.h"
> > >  #include "qga-qmp-commands.h"
> > > @@ -542,6 +544,7 @@ int64_t qmp_guest_fsfreeze_thaw(Error **err)
> > >  #define SUSPEND_SUPPORTED 0
> > >  #define SUSPEND_NOT_SUPPORTED 1
> > 
> > Missing the macros and I think reopen_fd_to_null() is missing too, also
> > doesn't apply to latest master.
> > 
> 
> Shouldn't hurt, but yah, leaving them in is a bit sloppy.

I think letting reopen_fd_to_null() out won't actually build.

> Don't see why this wouldn't apply though... are you applying on top of
> Michal's patch?

Oh, no, I was trying to apply on master to test it... If Michal's patch
is not applied yet, then I think you should post a version that applies
on master and Michal should rebase on top of your patch.

> This patch was meant to be the guest-suspend counterpart
> rather than a standalone fix.

Yeah, I missed it. I'm sorry for that and thanks for fixing it!

Patch

diff --git a/qga/commands-posix.c b/qga/commands-posix.c
index 89dde92..16737d7 100644
--- a/qga/commands-posix.c
+++ b/qga/commands-posix.c
@@ -24,10 +24,12 @@ 
 
 #include <sys/types.h>
 #include <sys/ioctl.h>
+#if defined(__linux__)
 #include <ifaddrs.h>
 #include <arpa/inet.h>
 #include <sys/socket.h>
 #include <net/if.h>
+#endif
 #include <sys/wait.h>
 #include "qga/guest-agent-core.h"
 #include "qga-qmp-commands.h"
@@ -542,6 +544,7 @@  int64_t qmp_guest_fsfreeze_thaw(Error **err)
 #define SUSPEND_SUPPORTED 0
 #define SUSPEND_NOT_SUPPORTED 1
 
+#if defined(__linux__)
 /**
  * This function forks twice and the information about the mode support
  * status is passed to the qemu-ga process via a pipe.
@@ -729,6 +732,25 @@  void qmp_guest_suspend_hybrid(Error **err)
     guest_suspend("pm-suspend-hybrid", NULL, err);
 }
 
+#else /* defined(linux) */
+
+void qmp_guest_suspend_disk(Error **err)
+{
+    error_set(err, QERR_UNSUPPORTED);
+}
+
+void qmp_guest_suspend_ram(Error **err)
+{
+    error_set(err, QERR_UNSUPPORTED);
+}
+
+void qmp_guest_suspend_hybrid(Error **err)
+{
+    error_set(err, QERR_UNSUPPORTED);
+}
+
+#endif
+
 #if defined(__linux__)
 static GuestNetworkInterfaceList *
 guest_find_interface(GuestNetworkInterfaceList *head,