Skip to contentSkip to conversation

qemu-ga: Make guest-network-get-interfaces Linux only

PATCH In review Michal Privoznik 5 participants 14 messages Mar 20, 2012 – Mar 26, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 qemu-ga: Make guest-network-get-interfaces Linux only

Currently, the implementation of that command is full of Linux specific code. Before any brave man will step into and port it to other OSes, make this function Linux only.

---
 qga/commands-posix.c |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)
qga/commands-posix.c +11 -0
index 7b2be2f..89dde92 100644
@@ -729,6 +729,7 @@ void qmp_guest_suspend_hybrid(Error **err)
     guest_suspend("pm-suspend-hybrid", NULL, err);
 }
 
+#if defined(__linux__)
 static GuestNetworkInterfaceList *
 guest_find_interface(GuestNetworkInterfaceList *head,
                      const char *name)
@@ -904,6 +905,16 @@ error:
     return NULL;
 }
 
+#else /* defined(linux) */
+
+GuestNetworkInterfaceList *qmp_guest_network_get_interfaces(Error **err)
+{
+    error_set(err, QERR_UNSUPPORTED);
+    return NULL;
+}
+
+#endif /* defined(linux) */
+
 /* register init/cleanup routines for stateful command groups */
 void ga_command_state_init(GAState *s, GACommandState *cs)
 {
Signature · 1 line
1.7.8.5
#1 lore raw
Quoted 5 lines · Michal Privoznik

Currently, the implementation of that command is full of Linux specific code. Before any brave man will step into and port it to other OSes, make this function Linux only.

Which aspect is linux-specific? getifaddrs() and getnameinfo() seem to be available on BSD and OpenSolaris, and we're already stubbed for w32. Are you seeing breakage?

Quoted 37 lines
---
 qga/commands-posix.c |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)
qga/commands-posix.c +11 -0
index 7b2be2f..89dde92 100644
@@ -729,6 +729,7 @@ void qmp_guest_suspend_hybrid(Error **err)
     guest_suspend("pm-suspend-hybrid", NULL, err);
 }
 
+#if defined(__linux__)
 static GuestNetworkInterfaceList *
 guest_find_interface(GuestNetworkInterfaceList *head,
                      const char *name)
@@ -904,6 +905,16 @@ error:
     return NULL;
 }
 
+#else /* defined(linux) */
+
+GuestNetworkInterfaceList *qmp_guest_network_get_interfaces(Error **err)
+{
+    error_set(err, QERR_UNSUPPORTED);
+    return NULL;
+}
+
+#endif /* defined(linux) */
+
 /* register init/cleanup routines for stateful command groups */
 void ga_command_state_init(GAState *s, GACommandState *cs)
 {
Signature · 1 line
1.7.8.5
#2 lore raw
Quoted 10 lines · Michael Roth
Quoted 5 lines · Michal Privoznik

Currently, the implementation of that command is full of Linux specific code. Before any brave man will step into and port it to other OSes, make this function Linux only.

Which aspect is linux-specific? getifaddrs() and getnameinfo() seem to be available on BSD and OpenSolaris, and we're already stubbed for w32. Are you seeing breakage?

Personally, I don't; but there has been this report:

http://lists.nongnu.org/archive/html/qemu-devel/2012-03/msg03951.html

which happens on OpenBSD, I suspect.

Michal

#3 lore raw
Quoted 12 lines · Michal Privoznik
Quoted 10 lines · Michael Roth
Quoted 5 lines · Michal Privoznik

Currently, the implementation of that command is full of Linux specific code. Before any brave man will step into and port it to other OSes, make this function Linux only.

Which aspect is linux-specific? getifaddrs() and getnameinfo() seem to be available on BSD and OpenSolaris, and we're already stubbed for w32. Are you seeing breakage?

Quoted 5 lines

Personally, I don't; but there has been this report:

http://lists.nongnu.org/archive/html/qemu-devel/2012-03/msg03951.html

which happens on OpenBSD, I suspect.

Ew, okay, well it looks like guest-suspend has a role as well so this patch wouldn't be sufficient. Let me fire up a FreeBSD image I have laying around and play around with it a bit.

Quoted 3 lines

Michal

#4 lore raw
Quoted 15 lines · Michael Roth
Quoted 14 lines · Michal Privoznik
Quoted 10 lines · Michael Roth
Quoted 5 lines · Michal Privoznik

Currently, the implementation of that command is full of Linux specific code. Before any brave man will step into and port it to other OSes, make this function Linux only.

Which aspect is linux-specific? getifaddrs() and getnameinfo() seem to be available on BSD and OpenSolaris, and we're already stubbed for w32. Are you seeing breakage?

Personally, I don't; but there has been this report:

Quoted 8 lines
Quoted 3 lines

http://lists.nongnu.org/archive/html/qemu-devel/2012-03/msg03951.html

which happens on OpenBSD, I suspect.

Ew, okay, well it looks like guest-suspend has a role as well so this patch wouldn't be sufficient. Let me fire up a FreeBSD image I have laying around and play around with it a bit.

Bleh.. hit a gcc bug on the build then ran out of disk space trying to upgrade to the latest gcc. Let's stub guest-network* and guest-suspend* for now. I'll send a patch for the guest-suspend side and to get rid of the warnings.

Quoted 3 lines
Quoted 3 lines

Michal

#5 lore raw
In reply to Michael Roth

Am 20.03.2012 17:10, schrieb Michael Roth:

Quoted 10 lines · Michal Privoznik
Quoted 5 lines

Currently, the implementation of that command is full of Linux specific code. Before any brave man will step into and port it to other OSes, make this function Linux only.

Which aspect is linux-specific? getifaddrs() and getnameinfo() seem to be available on BSD and OpenSolaris, and we're already stubbed for w32. Are you seeing breakage?

The two OpenBSD buildbots were reporting breakages:

http://buildbot.b1-systems.de/qemu/buildslaves/brad_openbsd_current
http://buildbot.b1-systems.de/qemu/buildslaves/kraxel_openbsd49

Unfortunately they rarely nag the people to blame ;) and the reports on qemu-devel are admittedly a bit brief.

Maybe it might make sense to let the buildbots build your qemu-ga staging branch as well, Michael? That could catch this in advance.

Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#6 lore raw
Quoted 14 lines · Andreas Färber

Am 20.03.2012 17:10, schrieb Michael Roth:

Quoted 10 lines · Michal Privoznik
Quoted 5 lines

Currently, the implementation of that command is full of Linux specific code. Before any brave man will step into and port it to other OSes, make this function Linux only.

Which aspect is linux-specific? getifaddrs() and getnameinfo() seem to be available on BSD and OpenSolaris, and we're already stubbed for w32. Are you seeing breakage?

The two OpenBSD buildbots were reporting breakages:

Quoted 8 lines

http://buildbot.b1-systems.de/qemu/buildslaves/brad_openbsd_current
http://buildbot.b1-systems.de/qemu/buildslaves/kraxel_openbsd49

Unfortunately they rarely nag the people to blame ;) and the reports on qemu-devel are admittedly a bit brief.

Maybe it might make sense to let the buildbots build your qemu-ga staging branch as well, Michael? That could catch this in advance.

That would great! Is there any process in place for having a repo added? I've been staging directly to pull branches, but started a single staging branch at:

git://github.com/mdroth/qemu.git qga

Quoted 7 lines

Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#7 lore raw

PATCH 1/1 qemu-ga: stub out guest-suspend* for non-linux

In reply to Michal Privoznik

This currently breaks the build for BSDs.

---
 qga/commands-posix.c |   22 ++++++++++++++++++++++
 1 files changed, 22 insertions(+), 0 deletions(-)
qga/commands-posix.c +22 -0
index 89dde92..16737d7 100644
@@ -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,
Signature · 1 line
1.7.4.1
#8 lore raw

Re: [Qemu-devel] [PATCH] qemu-ga: stub out guest-suspend* for non-linux

Quoted 25 lines · On Tue, 20 Mar 2012 19:54:09 -0500 Michael Roth <[email protected]>…

This currently breaks the build for BSDs.

---
 qga/commands-posix.c |   22 ++++++++++++++++++++++
 1 files changed, 22 insertions(+), 0 deletions(-)
qga/commands-posix.c +2 -0
index 89dde92..16737d7 100644
@@ -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"

qga/commands-posix.c int64_t qmp_guest_fsfreeze_thaw(Error **err) · line 545

Quoted 2 lines
qga/commands-posix.c +0 -0
@@ -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.

Quoted 19 lines
qga/commands-posix.c +11 -0
+#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);

qga/commands-posix.c void qmp_guest_suspend_hybrid(Error **err) · line 754

Quoted 10 lines
qga/commands-posix.c +9 -0
+}
+
+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)...

Quoted 2 lines
qga/commands-posix.c +0 -0
 static GuestNetworkInterfaceList *
 guest_find_interface(GuestNetworkInterfaceList *head,
#9 lore raw

Re: [Qemu-devel] [PATCH] qemu-ga: stub out guest-suspend* for non-linux

Quoted 25 lines · Luiz Capitulino
Quoted 22 lines · On Tue, 20 Mar 2012 19:54:09 -0500 Michael Roth <[email protected]>…

This currently breaks the build for BSDs.

---
 qga/commands-posix.c |   22 ++++++++++++++++++++++
 1 files changed, 22 insertions(+), 0 deletions(-)
qga/commands-posix.c +2 -0
index 89dde92..16737d7 100644
@@ -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>
Quoted 9 lines

qga/commands-posix.c int64_t qmp_guest_fsfreeze_thaw(Error **err) · line 545

Quoted 5 lines
qga/commands-posix.c +0 -0
 #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.

Quoted 25 lines
Quoted 25 lines
qga/commands-posix.c +17 -0
+#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);
+}
Quoted 9 lines

qga/commands-posix.c void qmp_guest_suspend_hybrid(Error **err) · line 754

Quoted 4 lines
qga/commands-posix.c +3 -0
+
+#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.

Quoted 3 lines
Quoted 2 lines
qga/commands-posix.c +0 -0
 static GuestNetworkInterfaceList *
 guest_find_interface(GuestNetworkInterfaceList *head,
#10 lore raw

Re: [Qemu-devel] [PATCH] qemu-ga: stub out guest-suspend* for non-linux

Quoted 36 lines · On Fri, 23 Mar 2012 14:11:53 -0500 Michael Roth <[email protected]>…
Quoted 25 lines · Luiz Capitulino
Quoted 22 lines · On Tue, 20 Mar 2012 19:54:09 -0500 Michael Roth <[email protected]>…

This currently breaks the build for BSDs.

---
 qga/commands-posix.c |   22 ++++++++++++++++++++++
 1 files changed, 22 insertions(+), 0 deletions(-)
qga/commands-posix.c +2 -0
index 89dde92..16737d7 100644
@@ -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>
Quoted 9 lines

qga/commands-posix.c int64_t qmp_guest_fsfreeze_thaw(Error **err) · line 545

Quoted 5 lines
qga/commands-posix.c +0 -0
 #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.

Quoted 1 line

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

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

Quoted 2 lines

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.

Quoted 2 lines

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!

#11 lore raw

PATCH 1/1 qemu-ga: fix bsd build, and re-org linux-specific implementations

---
 qga/commands-posix.c |  111 +++++++++++++++++++++++++++++--------------------
 1 files changed, 66 insertions(+), 45 deletions(-)
qga/commands-posix.c +66 -45
index 7b2be2f..faf970d 100644
@@ -12,29 +12,30 @@
  */
 
 #include <glib.h>
+#include <sys/types.h>
+#include <sys/ioctl.h>
+#include "qga/guest-agent-core.h"
+#include "qga-qmp-commands.h"
+#include "qerror.h"
+#include "qemu-queue.h"
+#include "host-utils.h"
 
 #if defined(__linux__)
 #include <mntent.h>
 #include <linux/fs.h>
-
-#if defined(__linux__) && defined(FIFREEZE)
-#define CONFIG_FSFREEZE
-#endif
-#endif
-
-#include <sys/types.h>
-#include <sys/ioctl.h>
 #include <ifaddrs.h>
 #include <arpa/inet.h>
 #include <sys/socket.h>
 #include <net/if.h>
 #include <sys/wait.h>
-#include "qga/guest-agent-core.h"
-#include "qga-qmp-commands.h"
-#include "qerror.h"
-#include "qemu-queue.h"
-#include "host-utils.h"
 
+#if defined(__linux__) && defined(FIFREEZE)
+#define CONFIG_FSFREEZE
+#endif
+#endif
+
+#if defined(__linux__)
+/* TODO: use this in place of all post-fork() fclose(std*) callers */
 static void reopen_fd_to_null(int fd)
 {
     int nullfd;
@@ -50,6 +51,7 @@ static void reopen_fd_to_null(int fd)
         close(nullfd);
     }
 }
+#endif /* defined(__linux__) */
 
 void qmp_guest_shutdown(bool has_mode, const char *mode, Error **err)
 {
@@ -309,7 +311,11 @@ static void guest_file_init(void)
     QTAILQ_INIT(&guest_file_state.filehandles);
 }
 
+/* linux-specific implementations. avoid this if at all possible. */
+#if defined(__linux__)
+
 #if defined(CONFIG_FSFREEZE)
+
 static void disable_logging(void)
 {
     ga_disable_logging(ga_state);
@@ -505,38 +511,7 @@ static void guest_fsfreeze_cleanup(void)
         }
     }
 }
-#else
-/*
- * Return status of freeze/thaw
- */
-GuestFsfreezeStatus qmp_guest_fsfreeze_status(Error **err)
-{
-    error_set(err, QERR_UNSUPPORTED);
-
-    return 0;
-}
-
-/*
- * Walk list of mounted file systems in the guest, and freeze the ones which
- * are real local file systems.
- */
-int64_t qmp_guest_fsfreeze_freeze(Error **err)
-{
-    error_set(err, QERR_UNSUPPORTED);
-
-    return 0;
-}
-
-/*
- * Walk list of frozen file systems in the guest, and thaw them.
- */
-int64_t qmp_guest_fsfreeze_thaw(Error **err)
-{
-    error_set(err, QERR_UNSUPPORTED);
-
-    return 0;
-}
-#endif
+#endif /* CONFIG_FSFREEZE */
 
 #define LINUX_SYS_STATE_FILE "/sys/power/state"
 #define SUSPEND_SUPPORTED 0
@@ -904,6 +879,52 @@ error:
     return NULL;
 }
 
+#else /* defined(__linux__) */
+
+GuestFsfreezeStatus qmp_guest_fsfreeze_status(Error **err)
+{
+    error_set(err, QERR_UNSUPPORTED);
+
+    return 0;
+}
+
+int64_t qmp_guest_fsfreeze_freeze(Error **err)
+{
+    error_set(err, QERR_UNSUPPORTED);
+
+    return 0;
+}
+
+int64_t qmp_guest_fsfreeze_thaw(Error **err)
+{
+    error_set(err, QERR_UNSUPPORTED);
+
+    return 0;
+}
+
+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);
+}
+
+GuestNetworkInterfaceList *qmp_guest_network_get_interfaces(Error **errp)
+{
+    error_set(errp, QERR_UNSUPPORTED);
+    return NULL;
+}
+
+#endif
+
 /* register init/cleanup routines for stateful command groups */
 void ga_command_state_init(GAState *s, GACommandState *cs)
 {
Signature · 1 line
1.7.4.1
Reviewed-by on v1 1/1
#12 lore raw

Re: [Qemu-devel] [PATCH] qemu-ga: fix bsd build, and re-org linux-specific implementations

Quoted 5 lines · On Sun, 25 Mar 2012 14:40:30 -0500 Michael Roth <[email protected]>…
---
 qga/commands-posix.c |  111 +++++++++++++++++++++++++++++--------------------
 1 files changed, 66 insertions(+), 45 deletions(-)
Quoted 162 lines
qga/commands-posix.c +66 -45
index 7b2be2f..faf970d 100644
@@ -12,29 +12,30 @@
  */
 
 #include <glib.h>
+#include <sys/types.h>
+#include <sys/ioctl.h>
+#include "qga/guest-agent-core.h"
+#include "qga-qmp-commands.h"
+#include "qerror.h"
+#include "qemu-queue.h"
+#include "host-utils.h"
 
 #if defined(__linux__)
 #include <mntent.h>
 #include <linux/fs.h>
-
-#if defined(__linux__) && defined(FIFREEZE)
-#define CONFIG_FSFREEZE
-#endif
-#endif
-
-#include <sys/types.h>
-#include <sys/ioctl.h>
 #include <ifaddrs.h>
 #include <arpa/inet.h>
 #include <sys/socket.h>
 #include <net/if.h>
 #include <sys/wait.h>
-#include "qga/guest-agent-core.h"
-#include "qga-qmp-commands.h"
-#include "qerror.h"
-#include "qemu-queue.h"
-#include "host-utils.h"
 
+#if defined(__linux__) && defined(FIFREEZE)
+#define CONFIG_FSFREEZE
+#endif
+#endif
+
+#if defined(__linux__)
+/* TODO: use this in place of all post-fork() fclose(std*) callers */
 static void reopen_fd_to_null(int fd)
 {
     int nullfd;
@@ -50,6 +51,7 @@ static void reopen_fd_to_null(int fd)
         close(nullfd);
     }
 }
+#endif /* defined(__linux__) */
 
 void qmp_guest_shutdown(bool has_mode, const char *mode, Error **err)
 {
@@ -309,7 +311,11 @@ static void guest_file_init(void)
     QTAILQ_INIT(&guest_file_state.filehandles);
 }
 
+/* linux-specific implementations. avoid this if at all possible. */
+#if defined(__linux__)
+
 #if defined(CONFIG_FSFREEZE)
+
 static void disable_logging(void)
 {
     ga_disable_logging(ga_state);
@@ -505,38 +511,7 @@ static void guest_fsfreeze_cleanup(void)
         }
     }
 }
-#else
-/*
- * Return status of freeze/thaw
- */
-GuestFsfreezeStatus qmp_guest_fsfreeze_status(Error **err)
-{
-    error_set(err, QERR_UNSUPPORTED);
-
-    return 0;
-}
-
-/*
- * Walk list of mounted file systems in the guest, and freeze the ones which
- * are real local file systems.
- */
-int64_t qmp_guest_fsfreeze_freeze(Error **err)
-{
-    error_set(err, QERR_UNSUPPORTED);
-
-    return 0;
-}
-
-/*
- * Walk list of frozen file systems in the guest, and thaw them.
- */
-int64_t qmp_guest_fsfreeze_thaw(Error **err)
-{
-    error_set(err, QERR_UNSUPPORTED);
-
-    return 0;
-}
-#endif
+#endif /* CONFIG_FSFREEZE */
 
 #define LINUX_SYS_STATE_FILE "/sys/power/state"
 #define SUSPEND_SUPPORTED 0
@@ -904,6 +879,52 @@ error:
     return NULL;
 }
 
+#else /* defined(__linux__) */
+
+GuestFsfreezeStatus qmp_guest_fsfreeze_status(Error **err)
+{
+    error_set(err, QERR_UNSUPPORTED);
+
+    return 0;
+}
+
+int64_t qmp_guest_fsfreeze_freeze(Error **err)
+{
+    error_set(err, QERR_UNSUPPORTED);
+
+    return 0;
+}
+
+int64_t qmp_guest_fsfreeze_thaw(Error **err)
+{
+    error_set(err, QERR_UNSUPPORTED);
+
+    return 0;
+}
+
+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);
+}
+
+GuestNetworkInterfaceList *qmp_guest_network_get_interfaces(Error **errp)
+{
+    error_set(errp, QERR_UNSUPPORTED);
+    return NULL;
+}
+
+#endif
+
 /* register init/cleanup routines for stateful command groups */
 void ga_command_state_init(GAState *s, GACommandState *cs)
 {
#13 lore raw

Re: [Qemu-devel] [PATCH] qemu-ga: fix bsd build, and re-org linux-specific implementations

In reply to Michael Roth
Quoted 157 lines · Michael Roth
---
  qga/commands-posix.c |  111 +++++++++++++++++++++++++++++--------------------
  1 files changed, 66 insertions(+), 45 deletions(-)
qga/commands-posix.c +59 -45
index 7b2be2f..faf970d 100644
@@ -12,29 +12,30 @@
   */
 
  #include<glib.h>
+#include<sys/types.h>
+#include<sys/ioctl.h>
+#include "qga/guest-agent-core.h"
+#include "qga-qmp-commands.h"
+#include "qerror.h"
+#include "qemu-queue.h"
+#include "host-utils.h"
 
  #if defined(__linux__)
  #include<mntent.h>
  #include<linux/fs.h>
-
-#if defined(__linux__)&&  defined(FIFREEZE)
-#define CONFIG_FSFREEZE
-#endif
-#endif
-
-#include<sys/types.h>
-#include<sys/ioctl.h>
  #include<ifaddrs.h>
  #include<arpa/inet.h>
  #include<sys/socket.h>
  #include<net/if.h>
  #include<sys/wait.h>
-#include "qga/guest-agent-core.h"
-#include "qga-qmp-commands.h"
-#include "qerror.h"
-#include "qemu-queue.h"
-#include "host-utils.h"
 
+#if defined(__linux__)&&  defined(FIFREEZE)
+#define CONFIG_FSFREEZE
+#endif
+#endif
+
+#if defined(__linux__)
+/* TODO: use this in place of all post-fork() fclose(std*) callers */
  static void reopen_fd_to_null(int fd)
  {
      int nullfd;
@@ -50,6 +51,7 @@ static void reopen_fd_to_null(int fd)
          close(nullfd);
      }
  }
+#endif /* defined(__linux__) */
 
  void qmp_guest_shutdown(bool has_mode, const char *mode, Error **err)
  {
@@ -309,7 +311,11 @@ static void guest_file_init(void)
      QTAILQ_INIT(&guest_file_state.filehandles);
  }
 
+/* linux-specific implementations. avoid this if at all possible. */
+#if defined(__linux__)
+
  #if defined(CONFIG_FSFREEZE)
+
  static void disable_logging(void)
  {
      ga_disable_logging(ga_state);
@@ -505,38 +511,7 @@ static void guest_fsfreeze_cleanup(void)
          }
      }
  }
-#else
-/*
- * Return status of freeze/thaw
- */
-GuestFsfreezeStatus qmp_guest_fsfreeze_status(Error **err)
-{
-    error_set(err, QERR_UNSUPPORTED);
-
-    return 0;
-}
-
-/*
- * Walk list of mounted file systems in the guest, and freeze the ones which
- * are real local file systems.
- */
-int64_t qmp_guest_fsfreeze_freeze(Error **err)
-{
-    error_set(err, QERR_UNSUPPORTED);
-
-    return 0;
-}
-
-/*
- * Walk list of frozen file systems in the guest, and thaw them.
- */
-int64_t qmp_guest_fsfreeze_thaw(Error **err)
-{
-    error_set(err, QERR_UNSUPPORTED);
-
-    return 0;
-}
-#endif
+#endif /* CONFIG_FSFREEZE */
 
  #define LINUX_SYS_STATE_FILE "/sys/power/state"
  #define SUSPEND_SUPPORTED 0
@@ -904,6 +879,52 @@ error:
      return NULL;
  }
 
+#else /* defined(__linux__) */
+
+GuestFsfreezeStatus qmp_guest_fsfreeze_status(Error **err)
+{
+    error_set(err, QERR_UNSUPPORTED);
+
+    return 0;
+}
+
+int64_t qmp_guest_fsfreeze_freeze(Error **err)
+{
+    error_set(err, QERR_UNSUPPORTED);
+
+    return 0;
+}
+
+int64_t qmp_guest_fsfreeze_thaw(Error **err)
+{
+    error_set(err, QERR_UNSUPPORTED);
+
+    return 0;
+}
+
+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);
+}
+
+GuestNetworkInterfaceList *qmp_guest_network_get_interfaces(Error **errp)

qga/commands-posix.c error: · line 930

Quoted 10 lines
qga/commands-posix.c +7 -0
+{
+    error_set(errp, QERR_UNSUPPORTED);
+    return NULL;
+}
+
+#endif
+
  /* register init/cleanup routines for stateful command groups */
  void ga_command_state_init(GAState *s, GACommandState *cs)
  {

This builds. Thank you.

Signature · 3 lines
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.