From patchwork Sat Mar 17 08:04:44 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Essen X-Patchwork-Id: 147295 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 8AFC0B6FAA for ; Sat, 17 Mar 2012 19:05:31 +1100 (EST) Received: from localhost ([::1]:38109 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S8odk-0003PO-BS for incoming@patchwork.ozlabs.org; Sat, 17 Mar 2012 04:05:28 -0400 Received: from eggs.gnu.org ([208.118.235.92]:49474) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S8odZ-0003KN-2r for qemu-devel@nongnu.org; Sat, 17 Mar 2012 04:05:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S8odT-0002pU-S8 for qemu-devel@nongnu.org; Sat, 17 Mar 2012 04:05:16 -0400 Received: from 204.146.238.178.in-addr.arpa ([178.238.146.204]:48113 helo=mail.local) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S8odT-0002nw-HF for qemu-devel@nongnu.org; Sat, 17 Mar 2012 04:05:11 -0400 Received: from cartman.owlsbarn.local (172.146.238.178.in-addr.arpa [178.238.146.172]) by mail.local (Postfix) with ESMTPSA id E81F84FA1; Sat, 17 Mar 2012 08:05:04 +0000 (UTC) From: Lee Essen Date: Sat, 17 Mar 2012 08:04:44 +0000 Message-Id: <10309083-5E08-4C90-A985-79B76344867E@nowonline.co.uk> To: qemu-devel@nongnu.org Mime-Version: 1.0 (Apple Message framework v1251.1) X-Mailer: Apple Mail (2.1251.1) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 178.238.146.204 Cc: =?iso-8859-1?Q?Andreas_F=E4rber?= Subject: [Qemu-devel] [PATCH v2] Basic Illumos support X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org (third email attempt, apologies if you get duplicates) This patch adds some basic constructs to better support Illumos/Solaris. I've kept away from kvm, configure etc. This just covers making sure the right libs are used, and the code is Solaris/Illumos compatible. In qemu-timer.c there are lots of __linux__ || __sun__ constructs, I wanted to make sure I didn't alter the linux behaviour and this seemed the safest way to do it. Signed-off-by: Lee Essen --- configure | 1 + cpus.c | 4 +++- qemu-timer.c | 14 +++++++++----- qga/channel-posix.c | 16 ++++++++++++++++ qga/commands-posix.c | 9 +++++++++ 5 files changed, 38 insertions(+), 6 deletions(-) diff --git a/configure b/configure index afe7395..68cc3a7 100755 --- a/configure +++ b/configure @@ -471,6 +471,7 @@ SunOS) QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS" QEMU_CFLAGS="-std=gnu99 $QEMU_CFLAGS" LIBS="-lsocket -lnsl -lresolv $LIBS" + libs_qga="-lsocket -lxnet $lib_qga" ;; AIX) aix="yes" diff --git a/cpus.c b/cpus.c index 25ba621..6550f22 100644 --- a/cpus.c +++ b/cpus.c @@ -455,7 +455,7 @@ static void cpu_signal(int sig) exit_request = 1; } -#ifdef CONFIG_LINUX +#if defined(CONFIG_LINUX) || defined(CONFIG_SOLARIS) static void sigbus_reraise(void) { sigset_t set; @@ -491,7 +491,9 @@ static void qemu_init_sigbus(void) action.sa_sigaction = (void (*)(int, siginfo_t*, void*))sigbus_handler; sigaction(SIGBUS, &action, NULL); +#if defined(CONFIG_LINUX) prctl(PR_MCE_KILL, PR_MCE_KILL_SET, PR_MCE_KILL_EARLY, 0, 0); +#endif } static void qemu_kvm_eat_signals(CPUArchState *env) diff --git a/qemu-timer.c b/qemu-timer.c index d7f56e5..48817c9 100644 --- a/qemu-timer.c +++ b/qemu-timer.c @@ -77,7 +77,7 @@ struct qemu_alarm_timer { int (*start)(struct qemu_alarm_timer *t); void (*stop)(struct qemu_alarm_timer *t); void (*rearm)(struct qemu_alarm_timer *t, int64_t nearest_delta_ns); -#if defined(__linux__) +#if defined(__linux__) || defined(__sun__) int fd; timer_t timer; #elif defined(_WIN32) @@ -165,7 +165,7 @@ static int unix_start_timer(struct qemu_alarm_timer *t); static void unix_stop_timer(struct qemu_alarm_timer *t); static void unix_rearm_timer(struct qemu_alarm_timer *t, int64_t delta); -#ifdef __linux__ +#if defined(__linux__) || defined(__sun__) static int dynticks_start_timer(struct qemu_alarm_timer *t); static void dynticks_stop_timer(struct qemu_alarm_timer *t); @@ -177,7 +177,7 @@ static void dynticks_rearm_timer(struct qemu_alarm_timer *t, int64_t delta static struct qemu_alarm_timer alarm_timers[] = { #ifndef _WIN32 -#ifdef __linux__ +#if defined(__linux__) || defined(__sun__) {"dynticks", dynticks_start_timer, dynticks_stop_timer, dynticks_rearm_timer}, #endif @@ -502,7 +502,7 @@ static void host_alarm_handler(int host_signum) } } -#if defined(__linux__) +#if defined(__linux__) || defined(__sun__) #include "compatfd.h" @@ -533,7 +533,11 @@ static int dynticks_start_timer(struct qemu_alarm_timer *t) #endif /* SIGEV_THREAD_ID */ ev.sigev_signo = SIGALRM; +#if defined(__sun__) + if (timer_create(CLOCK_HIGHRES, &ev, &host_timer)) { +#else if (timer_create(CLOCK_REALTIME, &ev, &host_timer)) { +#endif perror("timer_create"); /* disable dynticks */ @@ -585,7 +589,7 @@ static void dynticks_rearm_timer(struct qemu_alarm_timer *t, } } -#endif /* defined(__linux__) */ +#endif /* defined(__linux__) || defined(__sun__) */ #if !defined(_WIN32) diff --git a/qga/channel-posix.c b/qga/channel-posix.c index 40f7658..86245c1 100644 --- a/qga/channel-posix.c +++ b/qga/channel-posix.c @@ -3,6 +3,10 @@ #include "qemu_socket.h" #include "qga/channel.h" +#ifdef CONFIG_SOLARIS +#include +#endif + #define GA_CHANNEL_BAUDRATE_DEFAULT B38400 /* for isa-serial channels */ struct GAChannel { @@ -123,7 +127,19 @@ static gboolean ga_channel_open(GAChannel *c, const gchar *path, GAChanne switch (c->method) { case GA_CHANNEL_VIRTIO_SERIAL: { +#ifdef CONFIG_SOLARIS + int fd = qemu_open(path, O_RDWR | O_NONBLOCK); + if (fd == -1) { + g_critical("error opening channel: %s", strerror(errno)); + exit(EXIT_FAILURE); + } + if (ioctl(fd, I_SETSIG, S_OUTPUT | S_INPUT | S_HIPRI) < 0) { + g_critical("error with setsig on channel: %s", strerror(errno)); + exit(EXIT_FAILURE); + } +#else int fd = qemu_open(path, O_RDWR | O_NONBLOCK | O_ASYNC); +#endif if (fd == -1) { g_critical("error opening channel: %s", strerror(errno)); exit(EXIT_FAILURE); diff --git a/qga/commands-posix.c b/qga/commands-posix.c index 7b2be2f..67531aa 100644 --- a/qga/commands-posix.c +++ b/qga/commands-posix.c @@ -35,6 +35,11 @@ #include "qemu-queue.h" #include "host-utils.h" +#if defined(__sun__) +#include +extern char **environ; +#endif + static void reopen_fd_to_null(int fd) { int nullfd; @@ -807,7 +812,11 @@ GuestNetworkInterfaceList *qmp_guest_network_get_interfaces(Error **errp) goto error; } +#if defined(__sun__) + mac_addr = (unsigned char *) &ifr.ifr_enaddr; +#else mac_addr = (unsigned char *) &ifr.ifr_hwaddr.sa_data; +#endif if (asprintf(&info->value->hardware_address, "%02x:%02x:%02x:%02x:%02x:%02x",