Skip to contentSkip to conversation

guest-agent: fix build with OpenBSD

PATCH In review Anthony Liguori 3 participants 4 messages Jul 22, 2011 – Jul 23, 2011 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 guest-agent: fix build with OpenBSD

FS-Freeze only works with Linux.

---
 Makefile                   |    2 +
 hw/pc.c                    |    3 +-
 qemu-char.c                |   36 +++++++++++++++++++++++++
 qemu-config.c              |    6 ++++
 qga/guest-agent-commands.c |   63 ++++++++++++++++++++++++++++++++++++-------
 5 files changed, 97 insertions(+), 13 deletions(-)
Makefile +2 -0
index f3a03ad..2e3231e 100644
@@ -188,6 +188,8 @@ $(qapi-dir)/qga-qmp-marshal.c: $(SRC_PATH)/qapi-schema-guest.json $(SRC_PATH)/sc
 test-visitor.o: $(addprefix $(qapi-dir)/, test-qapi-types.c test-qapi-types.h test-qapi-visit.c test-qapi-visit.h) $(qapi-obj-y)
 test-visitor: test-visitor.o qfloat.o qint.o qdict.o qstring.o qlist.o qbool.o $(qapi-obj-y) error.o osdep.o qemu-malloc.o $(oslib-obj-y) qjson.o json-streamer.o json-lexer.o json-parser.o qerror.o qemu-error.o qemu-tool.o $(qapi-dir)/test-qapi-visit.o $(qapi-dir)/test-qapi-types.o
 
+test-linux: test-linux.o
+
 test-qmp-commands.o: $(addprefix $(qapi-dir)/, test-qapi-types.c test-qapi-types.h test-qapi-visit.c test-qapi-visit.h test-qmp-marshal.c test-qmp-commands.h) $(qapi-obj-y)
 test-qmp-commands: test-qmp-commands.o qfloat.o qint.o qdict.o qstring.o qlist.o qbool.o $(qapi-obj-y) error.o osdep.o qemu-malloc.o $(oslib-obj-y) qjson.o json-streamer.o json-lexer.o json-parser.o qerror.o qemu-error.o qemu-tool.o $(qapi-dir)/test-qapi-visit.o $(qapi-dir)/test-qapi-types.o $(qapi-dir)/test-qmp-marshal.o module.o
 
hw/pc.c +1 -2
index a3e8539..2539372 100644
@@ -548,8 +548,7 @@ static void bochs_bios_write(void *opaque, uint32_t addr, uint32_t val)
         /* LGPL'ed VGA BIOS messages */
     case 0x501:
     case 0x502:
-        fprintf(stderr, "VGA BIOS panic, line %d\n", val);
-        exit(1);
+        exit(1 | ((val & 0x7F) << 1));
     case 0x500:
     case 0x503:
 #ifdef DEBUG_BIOS
qemu-char.c +36 -0
index fb13b28..8c18653 100644
@@ -634,6 +634,41 @@ static CharDriverState *qemu_chr_open_fd(int fd_in, int fd_out)
     return chr;
 }
 
+static int handle_fd_param(QemuOpts *opts, const char *key)
+{
+    const char *value;
+
+    value = qemu_opt_get(opts, key);
+    if (value == NULL) {
+        return -1;
+    }
+
+    if (qemu_isdigit(value[0])) {
+        return atoi(value);
+    }
+
+    return monitor_get_fd(cur_mon, value);
+}
+
+static CharDriverState *qemu_chr_open_fdname(QemuOpts *opts)
+{
+    CharDriverState *chr;
+    FDCharDriver *s;
+
+    chr = qemu_mallocz(sizeof(CharDriverState));
+    s = qemu_mallocz(sizeof(FDCharDriver));
+    s->fd_in = handle_fd_param(opts, "fdin");
+    s->fd_out = handle_fd_param(opts, "fdout");
+    chr->opaque = s;
+    chr->chr_write = fd_chr_write;
+    chr->chr_update_read_handler = fd_chr_update_read_handler;
+    chr->chr_close = fd_chr_close;
+
+    qemu_chr_generic_open(chr);
+
+    return chr;
+}
+
 static CharDriverState *qemu_chr_open_file_out(QemuOpts *opts)
 {
     int fd_out;
@@ -2483,6 +2518,7 @@ static const struct {
     { .name = "pipe",      .open = qemu_chr_open_pipe },
     { .name = "pty",       .open = qemu_chr_open_pty },
     { .name = "stdio",     .open = qemu_chr_open_stdio },
+    { .name = "fdname",    .open = qemu_chr_open_fdname },
 #endif
 #ifdef CONFIG_BRLAPI
     { .name = "braille",   .open = chr_baum_init },
qemu-config.c +6 -0
index 93d20c6..ff6730d 100644
@@ -157,6 +157,12 @@ static QemuOptsList qemu_chardev_opts = {
         },{
             .name = "debug",
             .type = QEMU_OPT_NUMBER,
+        },{
+            .name = "fdin",
+            .type = QEMU_OPT_STRING,
+        },{
+            .name = "fdout",
+            .type = QEMU_OPT_STRING,
         },
         { /* end of list */ }
     },
qga/guest-agent-commands.c +52 -11

96 lines not on this page · raw message

Signature · 1 line
1.7.4.1
#1 lore raw
Quoted 16 lines · Anthony Liguori

FS-Freeze only works with Linux.

---
  Makefile                   |    2 +
  hw/pc.c                    |    3 +-
  qemu-char.c                |   36 +++++++++++++++++++++++++
  qemu-config.c              |    6 ++++
  qga/guest-agent-commands.c |   63 ++++++++++++++++++++++++++++++++++++-------
  5 files changed, 97 insertions(+), 13 deletions(-)
Makefile +0 -0
index f3a03ad..2e3231e 100644

Makefile $(qapi-dir)/qga-qmp-marshal.c: $(SRC_PATH)/qapi-schema-guest.json $(SRC_PATH)/sc · line 192

Quoted 5 lines
Makefile +2 -0
@@ -188,6 +188,8 @@ $(qapi-dir)/qga-qmp-marshal.c: $(SRC_PATH)/qapi-schema-guest.json $(SRC_PATH)/sc
  test-visitor.o: $(addprefix $(qapi-dir)/, test-qapi-types.c test-qapi-types.h test-qapi-visit.c test-qapi-visit.h) $(qapi-obj-y)
  test-visitor: test-visitor.o qfloat.o qint.o qdict.o qstring.o qlist.o qbool.o $(qapi-obj-y) error.o osdep.o qemu-malloc.o $(oslib-obj-y) qjson.o json-streamer.o json-lexer.o json-parser.o qerror.o qemu-error.o qemu-tool.o $(qapi-dir)/test-qapi-visit.o $(qapi-dir)/test-qapi-types.o
 
+test-linux: test-linux.o
+

This obviously doesn't belong here.

Regards,

Anthony Liguori

#2 lore raw
Quoted 27 lines · Anthony Liguori
Quoted 26 lines · Anthony Liguori

FS-Freeze only works with Linux.

---
Makefile | 2 +
hw/pc.c | 3 +-
qemu-char.c | 36 +++++++++++++++++++++++++
qemu-config.c | 6 ++++
qga/guest-agent-commands.c | 63
++++++++++++++++++++++++++++++++++++-------

5 files changed, 97 insertions(+), 13 deletions(-)
Makefile +0 -0
index f3a03ad..2e3231e 100644
@@ -188,6 +188,8 @@ $(qapi-dir)/qga-qmp-marshal.c:

$(SRC_PATH)/qapi-schema-guest.json $(SRC_PATH)/sc test-visitor.o: $(addprefix $(qapi-dir)/, test-qapi-types.c test-qapi-types.h test-qapi-visit.c test-qapi-visit.h) $(qapi-obj-y)
test-visitor: test-visitor.o qfloat.o qint.o qdict.o qstring.o qlist.o qbool.o $(qapi-obj-y) error.o osdep.o qemu-malloc.o $(oslib-obj-y) qjson.o json-streamer.o json-lexer.o json-parser.o qerror.o qemu-error.o qemu-tool.o $(qapi-dir)/test-qapi-visit.o $(qapi-dir)/test-qapi-types.o

Quoted 4 lines

Makefile $(qapi-dir)/qga-qmp-marshal.c: $(SRC_PATH)/qapi-schema-guest.json $(SRC_PATH)/sc · line 192

Quoted 2 lines
Makefile +2 -0
+test-linux: test-linux.o
+

This obviously doesn't belong here.

Er, this patch was fubar, let me send a new one.

Regards,

Anthony Liguori

Quoted 5 lines

Regards,

Anthony Liguori

#3 lore raw
In reply to Anthony Liguori
Quoted 3 lines · Anthony Liguori

FS-Freeze only works with Linux.

ACK except for the unrelated stuff.

It's strange how the messages arrive several hours out of order.

Quoted 214 lines

---
 Makefile                   |    2 +
 hw/pc.c                    |    3 +-
 qemu-char.c                |   36 +++++++++++++++++++++++++ qemu-config.c              |    6 ++++ qga/guest-agent-commands.c |   63 ++++++++++++++++++++++++++++++++++++-------

 5 files changed, 97 insertions(+), 13 deletions(-)
Makefile +0 -0
index f3a03ad..2e3231e 100644
@@ -188,6 +188,8 @@ $(qapi-dir)/qga-qmp-marshal.c: $(SRC_PATH)/qapi-schema-guest.json $(SRC_PATH)/sc
  test-visitor.o: $(addprefix $(qapi-dir)/, test-qapi-types.c test-qapi-types.h test-qapi-visit.c test-qapi-visit.h) $(qapi-obj-y)

 test-visitor: test-visitor.o qfloat.o qint.o qdict.o qstring.o qlist.o qbool.o $(qapi-obj-y) error.o osdep.o qemu-malloc.o $(oslib-obj-y) qjson.o json-streamer.o json-lexer.o json-parser.o qerror.o qemu-error.o qemu-tool.o $(qapi-dir)/test-qapi-visit.o $(qapi-dir)/test-qapi-types.o

Makefile +2 -0
+test-linux: test-linux.o
+

 test-qmp-commands.o: $(addprefix $(qapi-dir)/, test-qapi-types.c test-qapi-types.h test-qapi-visit.c test-qapi-visit.h test-qmp-marshal.c test-qmp-commands.h) $(qapi-obj-y)
 test-qmp-commands: test-qmp-commands.o qfloat.o qint.o qdict.o qstring.o qlist.o qbool.o $(qapi-obj-y) error.o osdep.o qemu-malloc.o $(oslib-obj-y) qjson.o json-streamer.o json-lexer.o json-parser.o qerror.o qemu-error.o qemu-tool.o $(qapi-dir)/test-qapi-visit.o $(qapi-dir)/test-qapi-types.o $(qapi-dir)/test-qmp-marshal.o module.o

hw/pc.c +0 -0
index a3e8539..2539372 100644
@@ -548,8 +548,7 @@ static void bochs_bios_write(void *opaque, uint32_t addr, uint32_t val)
         /* LGPL'ed VGA BIOS messages */

    case 0x501:
    case 0x502:
-        fprintf(stderr, "VGA BIOS panic, line %d\n", val);
-        exit(1);
+        exit(1 | ((val & 0x7F) << 1));
    case 0x500:
    case 0x503:
 #ifdef DEBUG_BIOS

qemu-char.c +36 -0
index fb13b28..8c18653 100644
@@ -634,6 +634,41 @@ static CharDriverState *qemu_chr_open_fd(int fd_in, int fd_out)
     return chr;
  }
 
+static int handle_fd_param(QemuOpts *opts, const char *key)
+{
+    const char *value;
+
+    value = qemu_opt_get(opts, key);
+    if (value == NULL) {
+        return -1;
+    }
+
+    if (qemu_isdigit(value[0])) {
+        return atoi(value);
+    }
+
+    return monitor_get_fd(cur_mon, value);
+}
+
+static CharDriverState *qemu_chr_open_fdname(QemuOpts *opts)
+{
+    CharDriverState *chr;
+    FDCharDriver *s;
+
+    chr = qemu_mallocz(sizeof(CharDriverState));
+    s = qemu_mallocz(sizeof(FDCharDriver));
+    s->fd_in = handle_fd_param(opts, "fdin");
+    s->fd_out = handle_fd_param(opts, "fdout");
+    chr->opaque = s;
+    chr->chr_write = fd_chr_write;
+    chr->chr_update_read_handler = fd_chr_update_read_handler;
+    chr->chr_close = fd_chr_close;
+
+    qemu_chr_generic_open(chr);
+
+    return chr;
+}
+
  static CharDriverState *qemu_chr_open_file_out(QemuOpts *opts)
  {
     int fd_out;
@@ -2483,6 +2518,7 @@ static const struct {
     { .name = "pipe",      .open = qemu_chr_open_pipe },
     { .name = "pty",       .open = qemu_chr_open_pty },
     { .name = "stdio",     .open = qemu_chr_open_stdio },
+    { .name = "fdname",    .open = qemu_chr_open_fdname },
  #endif
  #ifdef CONFIG_BRLAPI
     { .name = "braille",   .open = chr_baum_init },
qemu-config.c +6 -0
index 93d20c6..ff6730d 100644
@@ -157,6 +157,12 @@ static QemuOptsList qemu_chardev_opts = {
         },{
             .name = "debug",
             .type = QEMU_OPT_NUMBER,
+        },{
+            .name = "fdin",
+            .type = QEMU_OPT_STRING,
+        },{
+            .name = "fdout",
+            .type = QEMU_OPT_STRING,
         },
         { /* end of list */ }
     },
qga/guest-agent-commands.c +52 -12
index 8c0d67e..e215bd3 100644
@@ -10,11 +10,17 @@
  * See the COPYING file in the top-level directory.
  */
 
+#if defined(__linux__)
+#define CONFIG_FSFREEZE
+#endif
+
  #include <glib.h>
+#if defined(CONFIG_FSFREEZE)
  #include <mntent.h>
+#include <linux/fs.h>
+#endif
  #include <sys/types.h>
  #include <sys/ioctl.h>
-#include <linux/fs.h>
  #include "qga/guest-agent-core.h"
  #include "qga-qmp-commands.h"
  #include "qerror.h"
@@ -22,16 +28,6 @@
 
  static GAState *ga_state;
 
-static void disable_logging(void)
-{
-    ga_disable_logging(ga_state);
-}
-
-static void enable_logging(void)
-{
-    ga_enable_logging(ga_state);
-}
-
  /* Note: in some situations, like with the fsfreeze, logging may be
  * temporarilly disabled. if it is necessary that a command be able
  * to log for accounting purposes, check ga_logging_enabled() beforehand,
@@ -323,6 +319,17 @@ static void guest_file_init(void)
     QTAILQ_INIT(&guest_file_state.filehandles);
  }
 
+#if defined(CONFIG_FSFREEZE)
+static void disable_logging(void)
+{
+    ga_disable_logging(ga_state);
+}
+
+static void enable_logging(void)
+{
+    ga_enable_logging(ga_state);
+}
+
  typedef struct GuestFsfreezeMount {
     char *dirname;
     char *devtype;
@@ -508,11 +515,45 @@ static void guest_fsfreeze_cleanup(void)
         }
     }
  }
+#else
+/*
+ * Return status of freeze/thaw
+ */
+GuestFsfreezeStatus qmp_guest_fsfreeze_status(Error **err)
+{
+    error_set(err, QERR_COMMAND_NOT_FOUND, "guest_fsfreeze_status");
+
+    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_COMMAND_NOT_FOUND, "guest_fsfreeze_freeze");
+
+    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_COMMAND_NOT_FOUND, "guest_fsfreeze_thaw");
+
+    return 0;
+}
+#endif
 
  /* register init/cleanup routines for stateful command groups */
  void ga_command_state_init(GAState *s, GACommandState *cs)
  {
     ga_state = s;
+#if defined(CONFIG_FSFREEZE)
     ga_command_state_add(cs, guest_fsfreeze_init, guest_fsfreeze_cleanup);
+#endif
     ga_command_state_add(cs, guest_file_init, NULL);
  }
--

1.7.4.1