Received: from [140.186.70.92] (port=53009 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PCvtx-0003mw-R9 for qemu-devel@nongnu.org; Mon, 01 Nov 2010 11:02:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PCvtX-0000h6-4q for qemu-devel@nongnu.org; Mon, 01 Nov 2010 11:02:06 -0400 Received: from cantor.suse.de ([195.135.220.2]:60267 helo=mx1.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PCvtW-0000g9-Oz for qemu-devel@nongnu.org; Mon, 01 Nov 2010 11:01:58 -0400 From: Alexander Graf Date: Mon, 1 Nov 2010 16:01:42 +0100 Message-Id: <1288623713-28062-30-git-send-email-agraf@suse.de> In-Reply-To: <1288623713-28062-1-git-send-email-agraf@suse.de> References: <1288623713-28062-1-git-send-email-agraf@suse.de> Subject: [Qemu-devel] [PATCH 29/40] xenner: libxc emu: grant tables List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel Developers Cc: Gerd Hoffmann Xenner emulates parts of libxc, so we can not use the real xen infrastructure when running xen pv guests without xen. This patch adds support for grant tables. Signed-off-by: Alexander Graf --- hw/xenner_libxc_gnttab.c | 91 ++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 91 insertions(+), 0 deletions(-) create mode 100644 hw/xenner_libxc_gnttab.c diff --git a/hw/xenner_libxc_gnttab.c b/hw/xenner_libxc_gnttab.c new file mode 100644 index 0000000..c9f4ce2 --- /dev/null +++ b/hw/xenner_libxc_gnttab.c @@ -0,0 +1,91 @@ +/* + * Copyright (C) Red Hat 2007 + * Copyright (C) Novell Inc. 2010 + * + * Author(s): Gerd Hoffmann + * Alexander Graf + * + * Xenner Emulation -- grant tables + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; under version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, see . + */ + +#include +#include + +#include "hw.h" +#include "xen_interfaces.h" +#include "xenner.h" + +/* ------------------------------------------------------------- */ + +static grant_entry_v1_t *get_grant(uint32_t ref) +{ + grant_entry_v1_t *e; + int page, index; + + page = ref / (PAGE_SIZE / sizeof(grant_entry_v1_t)); + index = ref % (PAGE_SIZE / sizeof(grant_entry_v1_t)); + + e = xenner_get_grant_table(page); + if (!e) { + return NULL; + } + return e + index; +} + +/* ------------------------------------------------------------- */ + +static int _qemu_open(void) +{ + return 42; +} + +static int qemu_close(int xcg_handle) +{ + return 0; +} + +static void *qemu_map_grant_ref(int xcg_handle, uint32_t domid, + uint32_t ref, int prot) +{ + grant_entry_v1_t *e; + + e = get_grant(ref); + if (!e) { + return NULL; + } + + return xenner_mfn_to_ptr(e->frame); +} + +static void *qemu_map_grant_refs(int xcg_handle, uint32_t count, + uint32_t *domids, uint32_t *refs, int prot) +{ + /* Hmm, not so easy ... */ + return NULL; +} + +static int qemu_munmap(int xcg_handle, void *start_address, uint32_t count) +{ + /* nothing as we didn't actually map anything ... */ + return 0; +} + +struct XenGnttabOps xc_gnttab_xenner = { + .open = _qemu_open, + .close = qemu_close, + .map_grant_ref = qemu_map_grant_ref, + .map_grant_refs = qemu_map_grant_refs, + .munmap = qemu_munmap, +}; -- 1.6.0.2