Logging cleanups, libxc API change
cover Logging cleanups, libxc API change
In this patch series I do some serious cleanup. In particular:
* Remove all static global variables from libxc
so that the library is fully reentrant.
* Allow all callers of libxs, libxc, libxl to control where log messages to go.
* Assorted other minor fixups.
This involves an incompatible change to the interface to libxc. Instead of simply getting an int representing a file descriptor, callers now get an xc_interface*. Also, there are three new parameters to xc_interface_open for which naive callers may pass 0.
The overall result is that (amongst other things) the stderr output from "xl" is much more sensible.
(This is a resend of the series with the patches numbered in the Subject line as they should have been. Sorry for the inconvenience.)
PATCH 1/14 xl: Combine headers into one header file.
This provides a single place to put declarations of external symbols etc.
--- tools/libxl/xl.c | 3 +- tools/libxl/xl.h | 77 +++++++++++++++++++++++++++++++++++++++++++++ tools/libxl/xl_cmdimpl.c | 2 +- tools/libxl/xl_cmdimpl.h | 66 -------------------------------------- tools/libxl/xl_cmdtable.c | 2 +- tools/libxl/xl_cmdtable.h | 31 ------------------ 6 files changed, 80 insertions(+), 101 deletions(-) create mode 100644 tools/libxl/xl.h delete mode 100644 tools/libxl/xl_cmdimpl.h delete mode 100644 tools/libxl/xl_cmdtable.h
tools/libxl/xl.c +1 -2
@@ -29,8 +29,7 @@#include "libxl.h" #include "libxl_utils.h" -#include "xl_cmdimpl.h" -#include "xl_cmdtable.h" +#include "xl.h" extern struct libxl_ctx ctx;extern int logfile;
tools/libxl/xl.h new file +77 -0
77 lines not on this page · raw message
tools/libxl/xl_cmdimpl.c +1 -1
@@ -38,7 +38,7 @@#include "libxl.h" #include "libxl_utils.h" #include "libxlutil.h" -#include "xl_cmdtable.h" +#include "xl.h" #define UUID_FMT "%02hhx%02hhx%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx"
tools/libxl/xl_cmdimpl.h deleted +0 -66
66 lines not on this page · raw message
tools/libxl/xl_cmdtable.c +1 -1
@@ -12,7 +12,7 @@* GNU Lesser General Public License for more details. */ -#include "xl_cmdtable.h" +#include "xl.h" struct cmd_spec cmd_table[] = { {"create" ,
tools/libxl/xl_cmdtable.h deleted +0 -31
@@ -1,31 +0,0 @@ -/* -* Author Yang Hongyang <[email protected]> -* -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU Lesser General Public License as published -* by the Free Software Foundation; version 2.1 only. with the special -* exception on linking described in file 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 Lesser General Public License for more details. -*/ - -#ifndef XL_CMDTABLE_H -#define XL_CMDTABLE_H - -#include "xl_cmdimpl.h" - -struct cmd_spec { -char *cmd_name; -int (*cmd_impl)(int argc,char **argv); -char *cmd_desc; -char *cmd_usage; -char *cmd_option; -}; - -extern struct cmd_spec cmd_table[]; -extern int cmdtable_len; - -#endif /* XL_CMDTABLE_H */
Signature · 1 line
1.5.6.5
PATCH 2/14 xl: Move "extern" declarations to xl.h
Declarations (as opposed to definitions) of external objects should not appear in .c files.
--- tools/libxl/xl.c | 3 --- tools/libxl/xl.h | 3 +++ 2 files changed, 3 insertions(+), 3 deletions(-)
tools/libxl/xl.c +0 -3
@@ -31,9 +31,6 @@#include "libxl_utils.h" #include "xl.h" -extern struct libxl_ctx ctx; -extern int logfile; -void log_callback (void *userdata,int loglevel,const char *file,int line,const char *func,char *s)
tools/libxl/xl.h +3 -0
@@ -74,4 +74,7 @@ void help(char *command);extern struct cmd_spec cmd_table[];extern int cmdtable_len; +extern struct libxl_ctx ctx; +extern int logfile; +#endif /* XL_H */
Signature · 1 line
1.5.6.5
PATCH 3/14 stubdom/newlib: Provide correct names for time.h timezone variables
Newlib unaccountably defines _daylight, _timezone and _tzname, rather than daylight, timezone and tzname. The latter are specified in SuSv3.
So do a global search and replace as part of our newlib patching :-(.
--- stubdom/Makefile | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
stubdom/Makefile +2 -0
@@ -102,6 +102,8 @@ newlib-$(NEWLIB_VERSION): newlib-$(NEWLIB_VERSION).tar.gz patch -d $@ -p0 < newlib.patch patch -d $@ -p0 < newlib-chk.patch patch -d $@ -p1 < newlib-stdint-size_max-fix-from-1.17.0.patch + find $@ -type f | xargs perl -i.bak \ + -pe 's/\b_(tzname|daylight|timezone)\b/$$1/g' touch $@ NEWLIB_STAMPFILE=$(CROSS_ROOT)/$(GNU_TARGET_ARCH)-xen-elf/lib/libc.a
Signature · 1 line
1.5.6.5
PATCH 4/14 libxc: xc_domain_save.c: rename "write_exact" macro
There is already a "write_exact" function declared in xc_private.h. So rename this macro to to wrexact.
--- tools/libxc/xc_domain_save.c | 32 ++++++++++++++++---------------- 1 files changed, 16 insertions(+), 16 deletions(-)
tools/libxc/xc_domain_save.c +16 -16
@@ -1134,7 +1134,7 @@ int xc_domain_save(int xc_handle, int io_fd, uint32_t dom, uint32_t max_iters, } copypages: -#define write_exact (fd, buf, len) write_buffer(last_iter, &ob, (fd), (buf), (len)) +#define wrexact (fd, buf, len) write_buffer(last_iter, &ob, (fd), (buf), (len))#ifdef ratewrite#undef ratewrite#endif
@@ -1334,7 +1334,7 @@ int xc_domain_save(int xc_handle, int io_fd, uint32_t dom, uint32_t max_iters, } } -if (write_exact (io_fd, &batch,sizeof (unsigned int )) ) +if (wrexact (io_fd, &batch,sizeof (unsigned int )) ) {PERROR ("Error when writing to state file (2)" ); goto out;
@@ -1343,7 +1343,7 @@ int xc_domain_save(int xc_handle, int io_fd, uint32_t dom, uint32_t max_iters,if (sizeof (unsigned long ) <sizeof (*pfn_type) )for ( j =0 ; j < batch; j++ ) ((unsigned long *)pfn_type)[j] = pfn_type[j]; -if (write_exact (io_fd, pfn_type,sizeof (unsigned long )*batch) ) +if (wrexact (io_fd, pfn_type,sizeof (unsigned long )*batch) ) {PERROR ("Error when writing to state file (3)" ); goto out;
@@ -1457,7 +1457,7 @@ int xc_domain_save(int xc_handle, int io_fd, uint32_t dom, uint32_t max_iters,DPRINTF ("Entering debug resend-all mode\n" );/* send "-1" to put receiver into debug mode */ -if (write_exact (io_fd, &minusone,sizeof (int )) ) +if (wrexact (io_fd, &minusone,sizeof (int )) ) {PERROR ("Error when writing to state file (6)" ); goto out;
@@ -1542,7 +1542,7 @@ int xc_domain_save(int xc_handle, int io_fd, uint32_t dom, uint32_t max_iters, } chunk.vcpumap = vcpumap; -if (write_exact (io_fd, &chunk,sizeof (chunk)) ) +if (wrexact (io_fd, &chunk,sizeof (chunk)) ) {PERROR ("Error when writing to state file" ); goto out;
@@ -1562,7 +1562,7 @@ int xc_domain_save(int xc_handle, int io_fd, uint32_t dom, uint32_t max_iters, (unsigned long *)&chunk.data);if ( (chunk.data !=0 ) && -write_exact (io_fd, &chunk,sizeof (chunk)) ) +wrexact (io_fd, &chunk,sizeof (chunk)) ) {PERROR ("Error when writing the ident_pt for EPT guest" ); goto out;
@@ -1573,7 +1573,7 @@ int xc_domain_save(int xc_handle, int io_fd, uint32_t dom, uint32_t max_iters, (unsigned long *)&chunk.data);if ( (chunk.data !=0 ) && -write_exact (io_fd, &chunk,sizeof (chunk)) ) +wrexact (io_fd, &chunk,sizeof (chunk)) ) {PERROR ("Error when writing the vm86 TSS for guest" ); goto out;
@@ -1582,7 +1582,7 @@ int xc_domain_save(int xc_handle, int io_fd, uint32_t dom, uint32_t max_iters,/* Zero terminate */ i =0 ; -if (write_exact (io_fd, &i,sizeof (int )) ) +if (wrexact (io_fd, &i,sizeof (int )) ) {PERROR ("Error when writing to state file (6')" ); goto out;
@@ -1600,7 +1600,7 @@ int xc_domain_save(int xc_handle, int io_fd, uint32_t dom, uint32_t max_iters, (unsigned long *)&magic_pfns[1]);xc_get_hvm_param (xc_handle, dom,HVM_PARAM_STORE_PFN , (unsigned long *)&magic_pfns[2 ]); -if (write_exact (io_fd, magic_pfns,sizeof (magic_pfns)) ) +if (wrexact (io_fd, magic_pfns,sizeof (magic_pfns)) ) {PERROR ("Error when writing to state file (7)" ); goto out;
@@ -1614,13 +1614,13 @@ int xc_domain_save(int xc_handle, int io_fd, uint32_t dom, uint32_t max_iters, goto out; } -if (write_exact (io_fd, &rec_size,sizeof (uint32_t )) ) +if (wrexact (io_fd, &rec_size,sizeof (uint32_t )) ) {PERROR ("error write hvm buffer size" ); goto out; } -if (write_exact (io_fd, hvm_buf, rec_size) ) +if (wrexact (io_fd, hvm_buf, rec_size) ) {PERROR ("write HVM info failed!\n" ); goto out;
@@ -1644,7 +1644,7 @@ int xc_domain_save(int xc_handle, int io_fd, uint32_t dom, uint32_t max_iters, j++; } -if (write_exact (io_fd, &j,sizeof (unsigned int )) ) +if (wrexact (io_fd, &j,sizeof (unsigned int )) ) {PERROR ("Error when writing to state file (6a)" ); goto out;
@@ -1658,7 +1658,7 @@ int xc_domain_save(int xc_handle, int io_fd, uint32_t dom, uint32_t max_iters, i++;if ( (j ==1024 ) || (i == dinfo->p2m_size) ) { -if (write_exact (io_fd, &pfntab,sizeof (unsigned long )*j) ) +if (wrexact (io_fd, &pfntab,sizeof (unsigned long )*j) ) {PERROR ("Error when writing to state file (6b)" ); goto out;
@@ -1729,7 +1729,7 @@ int xc_domain_save(int xc_handle, int io_fd, uint32_t dom, uint32_t max_iters,FOLD_CR3 (mfn_to_pfn (UNFOLD_CR3 (ctxt.x64.ctrlreg[1 ]))); } -if (write_exact (io_fd, &ctxt, ((dinfo->guest_width==8 ) +if (wrexact (io_fd, &ctxt, ((dinfo->guest_width==8 ) ?sizeof (ctxt.x64) :sizeof (ctxt.x32))) ) {
@@ -1745,7 +1745,7 @@ int xc_domain_save(int xc_handle, int io_fd, uint32_t dom, uint32_t max_iters,ERROR ("No extended context for VCPU%d" , i); goto out; } -if (write_exact (io_fd, &domctl.u.ext_vcpucontext,128 ) ) +if (wrexact (io_fd, &domctl.u.ext_vcpucontext,128 ) ) {PERROR ("Error when writing to state file (2)" ); goto out;
@@ -1758,7 +1758,7 @@ int xc_domain_save(int xc_handle, int io_fd, uint32_t dom, uint32_t max_iters,memcpy (page, live_shinfo,PAGE_SIZE );SET_FIELD (((shared_info_any_t *)page), arch.pfn_to_mfn_frame_list_list,0 ); -if (write_exact (io_fd, page,PAGE_SIZE ) ) +if (wrexact (io_fd, page,PAGE_SIZE ) ) {PERROR ("Error when writing to state file (1)" ); goto out;
Signature · 1 line
1.5.6.5
PATCH 5/14 libelf: Tidy up logging and remove dependency on stdio.
libelf now permits callers to specify logging callback functions, rather than a FILE*. libelf's non-Xen callers are all libxc users, so the stdio dependency and the default logging callback function (which calls vfprintf) is now in libxc.
Xen's use of libxc is unaffected in this patch.
--- tools/libxc/xc_dom_elfloader.c | 17 +++++++++++++++-- tools/libxc/xenctrl.h | 5 +++++ tools/xcutils/readnotes.c | 2 +- xen/common/libelf/libelf-loader.c | 22 ++++++++++++++++++++-- xen/common/libelf/libelf-private.h | 15 ++++++++------- xen/common/libelf/libelf-relocate.c | 2 +- xen/include/xen/libelf.h | 13 +++++++++++-- 7 files changed, 61 insertions(+), 15 deletions(-)
tools/libxc/xc_dom_elfloader.c +15 -2
@@ -9,6 +9,7 @@*/ #include <stdio.h> #include <stdlib.h> +#include <stdarg.h> #include <inttypes.h> #include "xg_private.h"
@@ -18,6 +19,17 @@/* ------------------------------------------------------------------------ */ +static void log_callback (struct elf_binary *elf,void *caller_data, +int iserr,const char *fmt,va_list al) { +vfprintf (caller_data,fmt,al); +} + +void xc_elf_set_logfile (struct elf_binary *elf,FILE *f,int verbose) { +elf_set_log (elf, log_callback, f, verbose); +} + +/* ------------------------------------------------------------------------ */ +static char *xc_dom_guest_type (struct xc_dom_image *dom,struct elf_binary *elf) {
@@ -137,8 +149,9 @@ static int xc_dom_load_elf_symtab(struct xc_dom_image *dom, }if (elf_init (&syms, hdr +sizeof (int ), size -sizeof (int )) )return -1 ; +if ( xc_dom_logfile ) -elf_set_logfile (&syms, xc_dom_logfile,1 ); +xc_elf_set_logfile (&syms, xc_dom_logfile,1 ); symtab = dom->bsd_symtab_start +sizeof (int ); maxaddr = elf_round_up(&syms, symtab + elf_size(&syms, syms.ehdr) +
@@ -231,7 +244,7 @@ static int xc_dom_parse_elf_kernel(struct xc_dom_image *dom) dom->private_loader = elf; rc =elf_init (elf, dom->kernel_blob, dom->kernel_size);if ( xc_dom_logfile ) -elf_set_logfile (elf, xc_dom_logfile,1 ); +xc_elf_set_logfile (elf, xc_dom_logfile,1 );if ( rc !=0 ) { xc_dom_panic(XC_INVALID_KERNEL, "%s: corrupted ELF image\n",
tools/libxc/xenctrl.h +5 -0
@@ -19,6 +19,7 @@#include <stddef.h> #include <stdint.h> +#include <stdio.h> #include <xen/xen.h> #include <xen/domctl.h> #include <xen/physdev.h>
@@ -1474,4 +1475,8 @@ int xc_memshr_debug_gref(int xc_handle,uint32_t domid, grant_ref_t gref); +struct elf_binary ; +void xc_elf_set_logfile (struct elf_binary *elf,FILE *f,int verbose); +/* Useful for callers who also use libelf. */ +#endif /* XENCTRL_H */
tools/xcutils/readnotes.c +1 -1
@@ -170,7 +170,7 @@ int main(int argc, char **argv)fprintf (stderr,"File %s is not an ELF image\n" , f);return 1 ; } -elf_set_logfile (&elf, stderr,0 ); +xc_elf_set_logfile (&elf, stderr,0 ); count =elf_phdr_count (&elf);for ( h=0 ; h < count; h++)
xen/common/libelf/libelf-loader.c +20 -2
@@ -2,6 +2,8 @@* parse and load elf binaries */ +#include <stdarg.h> +#include "libelf-private.h" /* ------------------------------------------------------------------------ */
@@ -72,9 +74,25 @@ int elf_init(struct elf_binary *elf, const char *image, size_t size) }#ifndef __XEN__ -void elf_set_logfile (struct elf_binary *elf,FILE * log,int verbose) +void elf_call_log_callback (struct elf_binary *elf,int iserr, +const char *fmt,...) { +va_list al; + +if (!elf->log_callback) +return ; +if (!(iserr || elf->verbose)) +return ; + +va_start (al,fmt); + elf->log_callback (elf, elf->log_caller_data, iserr, fmt, al); +va_end (al); +} + +void elf_set_log (struct elf_binary *elf,elf_log_callback *log_callback, +void *log_caller_data,int verbose) { - elf->log = log; + elf->log_callback = log_callback; + elf->log_caller_data = log_caller_data; elf->verbose = verbose; }#else
xen/common/libelf/libelf-private.h +8 -7
@@ -11,6 +11,8 @@#include <asm/byteorder.h> #include <public/elfnote.h> +/* we would like to use elf->log_callback but we can't because +* there is no vprintk in Xen */ #define elf_msg(elf, fmt, args ... ) \ if (elf->verbose) printk(fmt, ## args ) #define elf_err(elf, fmt, args ... ) \
@@ -54,13 +56,12 @@#include "xenctrl.h" #include "xc_private.h" -#define elf_msg(elf, fmt, args ... ) \ - if (elf->log && elf->verbose) fprintf(elf->log, fmt , ## args ) -#define elf_err(elf, fmt, args ... ) do { \ - if (elf->log) \ - fprintf(elf->log, fmt , ## args ); \ - xc_set_error(XC_INVALID_KERNEL, fmt , ## args ); \ -} while (0) +#define elf_msg(elf, fmt, args ... ) \ + elf_call_log_callback(elf, 0, fmt , ## args ); +#define elf_err(elf, fmt, args ... ) \ + elf_call_log_callback(elf, 1, fmt , ## args ); + +void elf_call_log_callback (struct elf_binary *,int iserr,const char *fmt,...);#define safe_strcpy (d,s) \ do { strncpy((d),(s),sizeof((d))-1); \
xen/common/libelf/libelf-relocate.c +1 -1
@@ -289,7 +289,7 @@ static int elf_reloc_section(struct elf_binary *elf, value =elf_uval (elf, sym, st_value); value += r_addend; -if ( elf->log && (elf->verbose >1 ) ) +if ( elf->log_callback && (elf->verbose >1 ) ) {uint64_t st_name =elf_uval (elf, sym, st_name);const char *name = st_name ? elf->sym_strtab + st_name :"*NONE*" ;
xen/include/xen/libelf.h +11 -2
@@ -37,6 +37,13 @@#else #include <xen/elfnote.h> #include <xen/features.h> + +#include <stdarg.h> + +struct elf_binary ; +typedef void elf_log_callback (struct elf_binary *,void *caller_data, +int iserr,const char *fmt,va_list al); +#endif /* ------------------------------------------------------------------------ */
@@ -99,7 +106,8 @@ struct elf_binary {#ifndef __XEN__/* misc */ -FILE *log; +elf_log_callback *log_callback; +void *log_caller_data;#endif int verbose; };
@@ -183,7 +191,8 @@ int elf_init(struct elf_binary *elf, const char *image, size_t size);#ifdef __XEN__void elf_set_verbose (struct elf_binary *elf);#else -void elf_set_logfile (struct elf_binary *elf,FILE * log,int verbose); +void elf_set_log (struct elf_binary *elf,elf_log_callback *, +void *log_caller_pointer,int verbose);#endif void elf_parse_binary (struct elf_binary *elf);
Signature · 1 line
1.5.6.5
PATCH 6/14 xtl: New xentoollog mini-library.
We provide a new header file "xentoollog.h" which defines an interface that libraries and applications can use for logging. This avoids having to wrap each library's log callbacks up, massage arguments to log callbacks, and so on.
The library's .o files are within libxc to avoid having to create a separate lib*.a, but callers do not need to #include xenctrl.h and it should be regarded as a separate API.
--- tools/libxc/Makefile | 4 +- tools/libxc/xentoollog.h | 114 +++++++++++++++++++++++++++++++++++++ tools/libxc/xtl_core.c | 69 ++++++++++++++++++++++ tools/libxc/xtl_logger_stdio.c | 122 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 308 insertions(+), 1 deletions(-) create mode 100644 tools/libxc/xentoollog.h create mode 100644 tools/libxc/xtl_core.c create mode 100644 tools/libxc/xtl_logger_stdio.c
tools/libxc/Makefile +3 -1
@@ -27,6 +27,8 @@ CTRL_SRCS-y += xc_tmem.c CTRL_SRCS-y += xc_mem_event.c CTRL_SRCS-y += xc_mem_paging.c CTRL_SRCS-y += xc_memshr.c +CTRL_SRCS-y += xtl_core.c +CTRL_SRCS-y += xtl_logger_stdio.c CTRL_SRCS-$(CONFIG_X86) += xc_pagetab.c CTRL_SRCS-$(CONFIG_Linux) += xc_linux.c CTRL_SRCS-$(CONFIG_SunOS) += xc_solaris.c
@@ -105,7 +107,7 @@ install: build $(INSTALL_DATA) libxenctrl.a $(DESTDIR)$(LIBDIR) ln -sf libxenctrl.so.$(MAJOR).$(MINOR) $(DESTDIR)$(LIBDIR)/libxenctrl.so.$(MAJOR) ln -sf libxenctrl.so.$(MAJOR) $(DESTDIR)$(LIBDIR)/libxenctrl.so - $(INSTALL_DATA) xenctrl.h $(DESTDIR)$(INCLUDEDIR) + $(INSTALL_DATA) xenctrl.h xentoollog.h $(DESTDIR)$(INCLUDEDIR) $(INSTALL_PROG) libxenguest.so.$(MAJOR).$(MINOR) $(DESTDIR)$(LIBDIR) $(INSTALL_DATA) libxenguest.a $(DESTDIR)$(LIBDIR)
tools/libxc/xentoollog.h new file +114 -0
114 lines not on this page · raw message
tools/libxc/xtl_core.c new file +69 -0
69 lines not on this page · raw message
tools/libxc/xtl_logger_stdio.c new file +122 -0
122 lines not on this page · raw message
Signature · 1 line
1.5.6.5
PATCH 7/14 libxc: eliminate static variables, use xentoollog; API change
This patch eliminate the global variables in libxenctrl (used for logging and error reporting).
Instead the information which was in the global variables is now in a new xc_interface* opaque structure, which xc_interface open returns instead of the raw file descriptor; furthermore, logging is done via xentoollog.
There are three new parameters to xc_interface_open to control the logging, but existing callers can just pass "0" for all three to get the old behaviour.
All libxc callers have been adjusted accordingly.
Also update QEMU_TAG for corresponding qemu change.
--- Config.mk | 6 +- extras/mini-os/lib/sys.c | 5 +- stubdom/grub/kexec.c | 12 +- tools/console/daemon/io.c | 15 +- tools/console/daemon/utils.c | 8 +- tools/console/daemon/utils.h | 3 +- .../gdb/gdbserver/linux-xen-low.c | 2 +- tools/debugger/xenitp/xenitp.c | 10 +- tools/flask/libflask/flask_op.c | 39 +- tools/flask/libflask/include/libflask.h | 39 +- tools/flask/utils/getenforce.c | 6 +- tools/flask/utils/loadpolicy.c | 6 +- tools/flask/utils/setenforce.c | 6 +- tools/fs-back/fs-backend.c | 21 +- tools/fs-back/fs-backend.h | 1 + tools/fs-back/fs-ops.c | 40 +- tools/libxc/ia64/xc_ia64.h | 4 +- tools/libxc/ia64/xc_ia64_hvm_build.c | 28 +- tools/libxc/ia64/xc_ia64_linux_restore.c | 26 +- tools/libxc/ia64/xc_ia64_linux_save.c | 16 +- tools/libxc/ia64/xc_ia64_stubs.c | 14 +- tools/libxc/xc_acm.c | 4 +- tools/libxc/xc_core.c | 153 +++--- tools/libxc/xc_core.h | 12 +- tools/libxc/xc_core_ia64.c | 24 +- tools/libxc/xc_core_ia64.h | 2 +- tools/libxc/xc_core_x86.c | 26 +- tools/libxc/xc_core_x86.h | 2 +- tools/libxc/xc_cpu_hotplug.c | 8 +- tools/libxc/xc_cpuid_x86.c | 57 ++- tools/libxc/xc_cpupool.c | 32 +- tools/libxc/xc_csched.c | 8 +- tools/libxc/xc_csched2.c | 8 +- tools/libxc/xc_dom.h | 32 +- tools/libxc/xc_dom_binloader.c | 42 +- tools/libxc/xc_dom_boot.c | 81 ++-- tools/libxc/xc_dom_bzimageloader.c | 69 ++-- tools/libxc/xc_dom_compat_linux.c | 31 +- tools/libxc/xc_dom_core.c | 253 +++++----- tools/libxc/xc_dom_elfloader.c | 61 ++- tools/libxc/xc_dom_ia64.c | 18 +- tools/libxc/xc_dom_x86.c | 125 +++--- tools/libxc/xc_domain.c | 222 ++++---- tools/libxc/xc_domain_restore.c | 192 ++++---- tools/libxc/xc_domain_save.c | 195 ++++---- tools/libxc/xc_evtchn.c | 16 +- tools/libxc/xc_flask.c | 4 +- tools/libxc/xc_hvm_build.c | 63 ++-- tools/libxc/xc_linux.c | 124 +++--- tools/libxc/xc_mem_event.c | 12 +- tools/libxc/xc_mem_paging.c | 16 +- tools/libxc/xc_memshr.c | 32 +- tools/libxc/xc_minios.c | 36 +- tools/libxc/xc_misc.c | 72 ++-- tools/libxc/xc_netbsd.c | 40 +- tools/libxc/xc_offline_page.c | 111 +++-- tools/libxc/xc_pagetab.c | 12 +- tools/libxc/xc_physdev.c | 14 +- tools/libxc/xc_pm.c | 88 ++-- tools/libxc/xc_private.c | 241 ++++++---- tools/libxc/xc_private.h | 88 ++-- tools/libxc/xc_ptrace.c | 83 ++-- tools/libxc/xc_ptrace.h | 9 +- tools/libxc/xc_ptrace_core.c | 36 +- tools/libxc/xc_resume.c | 54 +- tools/libxc/xc_sedf.c | 8 +- tools/libxc/xc_solaris.c | 42 +- tools/libxc/xc_suspend.c | 20 +- tools/libxc/xc_tbuf.c | 34 +- tools/libxc/xc_tmem.c | 71 ++-- tools/libxc/xenctrl.h | 525 +++++++++++--------- tools/libxc/xenguest.h | 47 +- tools/libxc/xg_private.c | 12 +- tools/libxc/xg_private.h | 8 +- tools/libxc/xg_save_restore.h | 10 +- tools/libxl/libxl.c | 4 +- tools/libxl/libxl.h | 2 +- tools/libxl/libxl_dom.c | 6 +- tools/libxl/libxl_internal.h | 2 +- tools/libxl/xenguest.c | 2 +- tools/memshr/interface.c | 6 +- tools/misc/xen-hptool.c | 34 +- tools/misc/xen-hvmctx.c | 7 +- tools/misc/xenlockprof.c | 4 +- tools/misc/xenperf.c | 5 +- tools/misc/xenpm.c | 122 +++--- tools/python/xen/lowlevel/acm/acm.c | 26 +- tools/python/xen/lowlevel/checkpoint/checkpoint.h | 2 +- .../python/xen/lowlevel/checkpoint/libcheckpoint.c | 12 +- tools/python/xen/lowlevel/flask/flask.c | 44 +- tools/python/xen/lowlevel/xc/xc.c | 196 ++++---- tools/security/secpol_tool.c | 16 +- tools/xcutils/lsevtchn.c | 11 +- tools/xcutils/readnotes.c | 11 +- tools/xcutils/xc_restore.c | 11 +- tools/xcutils/xc_save.c | 18 +- tools/xenmon/setmask.c | 2 +- tools/xenmon/xenbaked.c | 19 +- tools/xenpaging/file_ops.c | 1 + tools/xenpaging/policy.h | 3 +- tools/xenpaging/policy_default.c | 3 +- tools/xenpaging/xc.c | 9 +- tools/xenpaging/xc.h | 7 +- tools/xenpaging/xenpaging.c | 44 +- tools/xenpaging/xenpaging.h | 2 +- tools/xenstat/libxenstat/src/xenstat.c | 4 +- tools/xenstat/libxenstat/src/xenstat_priv.h | 2 +- tools/xenstore/xenstored_domain.c | 11 +- tools/xentrace/setsize.c | 2 +- tools/xentrace/xenctx.c | 6 +- tools/xentrace/xentrace.c | 14 +- 111 files changed, 2383 insertions(+), 2179 deletions(-) create mode 100644 tools/libxc/INPROGRESS
Config.mk +3 -3
@@ -154,9 +154,9 @@ QEMU_REMOTE=http://xenbits.xensource.com/git-http/qemu-xen-unstable.git # CONFIG_QEMU ?= ../qemu-xen.git CONFIG_QEMU ?= $(QEMU_REMOTE) -QEMU_TAG ?= 805ed3b20492d2f4bb465bfda65cedd286e23209 -# Fri May 21 15:46:55 2010 +0100 -# Wait for frontend state Connected before connecting the backend +QEMU_TAG ?= ffb0cf2ad55e952dae55e6166c4fcea79be6cd30 +# Thu Apr 15 17:01:15 2010 +0100 +# Change callers of libxc to use new libxc API. # Optional components XENSTAT_XENTOP ?= y
extras/mini-os/lib/sys.c +3 -2
@@ -84,7 +84,8 @@#define NOFILE 32extern int xc_evtchn_close (int fd); -extern int xc_interface_close (int fd); +struct xc_interface ; +extern int xc_interface_close_core (struct xc_interface *,int fd);extern int xc_gnttab_close (int fd);pthread_mutex_t fd_lock =PTHREAD_MUTEX_INITIALIZER ;
@@ -413,7 +414,7 @@ int close(int fd) }#endif case FTYPE_XC : -xc_interface_close (fd); +xc_interface_close_core (0 ,fd);return 0 ;case FTYPE_EVTCHN :xc_evtchn_close (fd);
stubdom/grub/kexec.c +6 -6
@@ -50,7 +50,7 @@ static unsigned long *pages;static unsigned long *pages_mfns;static unsigned long allocated; -int pin_table (int xc_handle,unsigned int type,unsigned long mfn, +int pin_table (xc_interface *xc_handle,unsigned int type,unsigned long mfn,domid_t dom);/* We need mfn to appear as target_pfn, so exchange with the MFN there */
@@ -109,7 +109,7 @@ void kexec(void *kernel, long kernel_size, void *module, long module_size, charint rc;domid_t domid =DOMID_SELF ;xen_pfn_t pfn; -int xc_handle; +xc_interface *xc_handle;unsigned long i;void *seg;xen_pfn_t boot_page_mfn =virt_to_mfn (&_boot_page);
@@ -118,9 +118,9 @@ void kexec(void *kernel, long kernel_size, void *module, long module_size, charunsigned long nr_m2p_updates;DEBUG ("booting with cmdline %s\n" , cmdline); - xc_handle =xc_interface_open (); + xc_handle =xc_interface_open (0 ,0 ,0 ); - dom =xc_dom_allocate (cmdline, features); + dom =xc_dom_allocate (xc_handle, cmdline, features); dom->allocate = kexec_allocate; dom->kernel_blob = kernel;
@@ -160,7 +160,7 @@ void kexec(void *kernel, long kernel_size, void *module, long module_size, char#endif /* equivalent of xc_dom_mem_init */ - dom->arch_hooks =xc_dom_find_arch_hooks (dom->guest_type); + dom->arch_hooks =xc_dom_find_arch_hooks (xc_handle, dom->guest_type); dom->total_pages = start_info.nr_pages;/* equivalent of arch_setup_meminit */
@@ -238,7 +238,7 @@ void kexec(void *kernel, long kernel_size, void *module, long module_size, charmunmap ((void *) pages[pfn],PAGE_SIZE );/* Pin the boot page table base */ - if ( (rc = pin_table(dom->guest_xc, + if ( (rc = pin_table(dom->xch, #ifdef __i386__ MMUEXT_PIN_L3_TABLE,#endif
tools/console/daemon/io.c +7 -8
@@ -24,7 +24,6 @@#include "io.h" #include <xs.h> #include <xen/io/console.h> -#include <xenctrl.h> #include <stdlib.h> #include <errno.h>
@@ -68,7 +67,7 @@ static int log_time_hv_needts = 1;static int log_time_guest_needts =1 ;static int log_hv_fd =-1 ;static evtchn_port_or_error_t log_hv_evtchn =-1 ; -static int xc_handle =-1 ; +static xc_interface *xch;/* why does xenconsoled have two xc handles ? */ static int xce_handle =-1 ;struct buffer {
@@ -932,7 +931,7 @@ static void handle_hv_logs(void)if ((port =xc_evtchn_pending (xce_handle)) ==-1 )return ; -if (xc_readconsolering (xc_handle, &bufptr, &size,0 ,1 , &index) ==0 && size >0 ) { +if (xc_readconsolering (xch, &bufptr, &size,0 ,1 , &index) ==0 && size >0 ) {int logret;if (log_time_hv) logret = write_with_timestamp(log_hv_fd, buffer, size,
@@ -972,8 +971,8 @@ void handle_io(void)int ret;if (log_hv) { - xc_handle =xc_interface_open (); -if (xc_handle ==-1 ) { + xch =xc_interface_open (0 ,0 ,0 ); +if (!xch) {dolog (LOG_ERR ,"Failed to open xc handle: %d (%s)" , errno,strerror (errno)); goto out;
@@ -1124,9 +1123,9 @@ void handle_io(void)close (log_hv_fd); log_hv_fd =-1 ; } -if (xc_handle !=-1 ) { -xc_interface_close (xc_handle); - xc_handle =-1 ; +if (xch) { +xc_interface_close (xch); + xch =0 ; }if (xce_handle !=-1 ) {xc_evtchn_close (xce_handle);
tools/console/daemon/utils.c +4 -4
@@ -38,7 +38,7 @@#include "utils.h" struct xs_handle *xs; -int xc; +xc_interface *xc;static void child_exit (int sig) {
@@ -116,8 +116,8 @@ bool xen_setup(void) goto out; } - xc =xc_interface_open (); -if (xc ==-1 ) { + xc =xc_interface_open (0 ,0 ,0 ); +if (!xc) {dolog (LOG_ERR ,"Failed to contact hypervisor (%m)" ); goto out; }
@@ -137,7 +137,7 @@ bool xen_setup(void) out:if (xs)xs_daemon_close (xs); -if (xc !=-1 ) +if (xc)xc_interface_close (xc);return false; }
tools/console/daemon/utils.h +2 -1
@@ -24,6 +24,7 @@#include <stdbool.h> #include <syslog.h> #include <stdio.h> +#include <xenctrl.h> #include "xs.h"
@@ -31,7 +32,7 @@ void daemonize(const char *pidfile);bool xen_setup (void );extern struct xs_handle *xs; -extern int xc; +extern xc_interface *xc;#if 1 #define dolog (val, fmt, ...) do { \
tools/debugger/gdb/gdb-6.2.1-xen-sparse/gdb/gdbserver/linux-xen-low.c +1 -1
@@ -39,7 +39,7 @@#define TRACE_ENTER /* printf("enter %s\n", __FUNCTION__) */ -static int xc_handle; +static xc_interface *xc_handle;static inline int curvcpuid ()
tools/debugger/xenitp/xenitp.c +5 -5
@@ -40,7 +40,7 @@#include <xen/arch-ia64/debug_op.h> #endif -static int xc_handle =0 ; +static xc_interface *xc_handle =0 ;static int domid =0 ;static vcpu_guest_context_t *cur_ctx;static int cur_vcpu;
@@ -59,7 +59,7 @@ static int cur_vcpu;int virt_to_phys (int is_inst,unsigned long vaddr,unsigned long *paddr);/* wrapper for vcpu_gest_context_any_t */ -static int xc_ia64_vcpu_getcontext (int xc_handle, +static int xc_ia64_vcpu_getcontext (xc_interface *xc_handle,uint32_t domid,uint32_t vcpu,vcpu_guest_context_t *ctxt)
@@ -660,10 +660,10 @@ void print_tr (vcpu_guest_context_t *ctx)int lock_pages (void *addr,size_t len);void unlock_pages (void *addr,size_t len); -int do_xen_hypercall (int xc_handle,privcmd_hypercall_t *hypercall); +int do_xen_hypercall (xc_interface *xc_handle,privcmd_hypercall_t *hypercall);#ifdef HAVE_DEBUG_OP -static int do_ia64_debug_op (int xc_handle, +static int do_ia64_debug_op (xc_interface *xc_handle,unsigned long cmd,unsigned long domain,xen_ia64_debug_op_t *op) {
@@ -1663,7 +1663,7 @@ void xenitp (int vcpu) } } -xc_interface_close (xc_handle); + ret =xc_interface_close (xc_handle);if (ret <0 ) {perror ("xc_interface_close" );exit (-1 );
tools/flask/libflask/flask_op.c +19 -20
@@ -20,9 +20,8 @@#include <stdint.h> #include <sys/ioctl.h> #include <libflask.h> -#include <xenctrl.h> -int flask_load (int xc_handle,char *buf,uint32_t size) +int flask_load (xc_interface *xc_handle,char *buf,uint32_t size) {int err;flask_op_t op;
@@ -37,7 +36,7 @@ int flask_load(int xc_handle, char *buf, uint32_t size)return 0 ; } -int flask_context_to_sid (int xc_handle,char *buf,uint32_t size,uint32_t *sid) +int flask_context_to_sid (xc_interface *xc_handle,char *buf,uint32_t size,uint32_t *sid) {int err;flask_op_t op;
@@ -54,7 +53,7 @@ int flask_context_to_sid(int xc_handle, char *buf, uint32_t size, uint32_t *sid)return 0 ; } -int flask_sid_to_context (int xc_handle,int sid,char *buf,uint32_t size) +int flask_sid_to_context (xc_interface *xc_handle,int sid,char *buf,uint32_t size) {int err;flask_op_t op;
@@ -71,7 +70,7 @@ int flask_sid_to_context(int xc_handle, int sid, char *buf, uint32_t size)return 0 ; } -int flask_getenforce (int xc_handle) +int flask_getenforce (xc_interface *xc_handle) {int err;flask_op_t op;
@@ -91,7 +90,7 @@ int flask_getenforce(int xc_handle)return mode; } -int flask_setenforce (int xc_handle,int mode) +int flask_setenforce (xc_interface *xc_handle,int mode) {int err;flask_op_t op;
@@ -110,7 +109,7 @@ int flask_setenforce(int xc_handle, int mode)return 0 ; } -int flask_add_pirq (int xc_handle,unsigned int pirq,char *scontext) +int flask_add_pirq (xc_interface *xc_handle,unsigned int pirq,char *scontext) {int err;flask_op_t op;
@@ -139,7 +138,7 @@ int flask_add_pirq(int xc_handle, unsigned int pirq, char *scontext) } -int flask_add_ioport (int xc_handle,unsigned long low,unsigned long high, +int flask_add_ioport (xc_interface *xc_handle,unsigned long low,unsigned long high,char *scontext) {int err;
@@ -169,7 +168,7 @@ int flask_add_ioport(int xc_handle, unsigned long low, unsigned long high, } -int flask_add_iomem (int xc_handle,unsigned long low,unsigned long high, +int flask_add_iomem (xc_interface *xc_handle,unsigned long low,unsigned long high,char *scontext) {int err;
@@ -199,7 +198,7 @@ int flask_add_iomem(int xc_handle, unsigned long low, unsigned long high, } -int flask_add_device (int xc_handle,unsigned long device,char *scontext) +int flask_add_device (xc_interface *xc_handle,unsigned long device,char *scontext) {int err;flask_op_t op;
@@ -228,7 +227,7 @@ int flask_add_device(int xc_handle, unsigned long device, char *scontext) } -int flask_del_pirq (int xc_handle,unsigned int pirq) +int flask_del_pirq (xc_interface *xc_handle,unsigned int pirq) {int err;flask_op_t op;
@@ -257,7 +256,7 @@ int flask_del_pirq(int xc_handle, unsigned int pirq) } -int flask_del_ioport (int xc_handle,unsigned long low,unsigned long high) +int flask_del_ioport (xc_interface *xc_handle,unsigned long low,unsigned long high) {int err;flask_op_t op;
@@ -286,7 +285,7 @@ int flask_del_ioport(int xc_handle, unsigned long low, unsigned long high) } -int flask_del_iomem (int xc_handle,unsigned long low,unsigned long high) +int flask_del_iomem (xc_interface *xc_handle,unsigned long low,unsigned long high) {int err;flask_op_t op;
@@ -315,7 +314,7 @@ int flask_del_iomem(int xc_handle, unsigned long low, unsigned long high) } -int flask_del_device (int xc_handle,unsigned long device) +int flask_del_device (xc_interface *xc_handle,unsigned long device) {int err;flask_op_t op;
@@ -343,7 +342,7 @@ int flask_del_device(int xc_handle, unsigned long device) } -int flask_access(int xc_handle, const char *scon, const char *tcon, +int flask_access(xc_interface *xc_handle, const char *scon, const char *tcon, u_int16_t tclass, u_int32_t req, u_int32_t *allowed, u_int32_t *decided, u_int32_t *auditallow, u_int32_t *auditdeny,
@@ -407,7 +406,7 @@ int flask_access(int xc_handle, const char *scon, const char *tcon, } -int flask_avc_hashstats (int xc_handle,char *buf,int size) +int flask_avc_hashstats (xc_interface *xc_handle,char *buf,int size) {int err;flask_op_t op;
@@ -425,7 +424,7 @@ int flask_avc_hashstats(int xc_handle, char *buf, int size)return 0 ; } -int flask_avc_cachestats (int xc_handle,char *buf,int size) +int flask_avc_cachestats (xc_interface *xc_handle,char *buf,int size) {int err;flask_op_t op;
@@ -443,7 +442,7 @@ int flask_avc_cachestats(int xc_handle, char *buf, int size)return 0 ; } -int flask_policyvers (int xc_handle,char *buf,int size) +int flask_policyvers (xc_interface *xc_handle,char *buf,int size) {int err;flask_op_t op;
@@ -461,7 +460,7 @@ int flask_policyvers(int xc_handle, char *buf, int size)return 0 ; } -int flask_getavc_threshold (int xc_handle) +int flask_getavc_threshold (xc_interface *xc_handle) {int err;flask_op_t op;
@@ -481,7 +480,7 @@ int flask_getavc_threshold(int xc_handle)return threshold; } -int flask_setavc_threshold (int xc_handle,int threshold) +int flask_setavc_threshold (xc_interface *xc_handle,int threshold) {int err;flask_op_t op;
tools/flask/libflask/include/libflask.h +20 -19
@@ -14,32 +14,33 @@#include <stdint.h> #include <xen/xen.h> #include <xen/xsm/flask_op.h> +#include <xenctrl.h> -int flask_load (int xc_handle,char *buf,uint32_t size); -int flask_context_to_sid (int xc_handle,char *buf,uint32_t size,uint32_t *sid); -int flask_sid_to_context (int xc_handle,int sid,char *buf,uint32_t size); -int flask_getenforce (int xc_handle); -int flask_setenforce (int xc_handle,int mode); -int flask_add_pirq (int xc_handle,unsigned int pirq,char *scontext); -int flask_add_ioport (int xc_handle,unsigned long low,unsigned long high, +int flask_load (xc_interface *xc_handle,char *buf,uint32_t size); +int flask_context_to_sid (xc_interface *xc_handle,char *buf,uint32_t size,uint32_t *sid); +int flask_sid_to_context (xc_interface *xc_handle,int sid,char *buf,uint32_t size); +int flask_getenforce (xc_interface *xc_handle); +int flask_setenforce (xc_interface *xc_handle,int mode); +int flask_add_pirq (xc_interface *xc_handle,unsigned int pirq,char *scontext); +int flask_add_ioport (xc_interface *xc_handle,unsigned long low,unsigned long high,char *scontext); -int flask_add_iomem (int xc_handle,unsigned long low,unsigned long high, +int flask_add_iomem (xc_interface *xc_handle,unsigned long low,unsigned long high,char *scontext); -int flask_add_device (int xc_handle,unsigned long device,char *scontext); -int flask_del_pirq (int xc_handle,unsigned int pirq); -int flask_del_ioport (int xc_handle,unsigned long low,unsigned long high); -int flask_del_iomem (int xc_handle,unsigned long low,unsigned long high); -int flask_del_device (int xc_handle,unsigned long device); -int flask_access (int xc_handle,const char *scon,const char *tcon, +int flask_add_device (xc_interface *xc_handle,unsigned long device,char *scontext); +int flask_del_pirq (xc_interface *xc_handle,unsigned int pirq); +int flask_del_ioport (xc_interface *xc_handle,unsigned long low,unsigned long high); +int flask_del_iomem (xc_interface *xc_handle,unsigned long low,unsigned long high); +int flask_del_device (xc_interface *xc_handle,unsigned long device); +int flask_access (xc_interface *xc_handle,const char *scon,const char *tcon,u_int16_t tclass,u_int32_t req,u_int32_t *allowed,u_int32_t *decided,u_int32_t *auditallow,u_int32_t *auditdeny,u_int32_t *seqno); -int flask_avc_cachestats (int xc_handle,char *buf,int size); -int flask_policyvers (int xc_handle,char *buf,int size); -int flask_avc_hashstats (int xc_handle,char *buf,int size); -int flask_getavc_threshold (int xc_handle); -int flask_setavc_threshold (int xc_handle,int threshold); +int flask_avc_cachestats (xc_interface *xc_handle,char *buf,int size); +int flask_policyvers (xc_interface *xc_handle,char *buf,int size); +int flask_avc_hashstats (xc_interface *xc_handle,char *buf,int size); +int flask_getavc_threshold (xc_interface *xc_handle); +int flask_setavc_threshold (xc_interface *xc_handle,int threshold);#define flask_add_single_ioport (x, l, s) flask_add_ioport(x, l, l, s)#define flask_add_single_iomem (x, l, s) flask_add_iomem(x, l, l, s)#define flask_del_single_ioport (x, l) flask_del_ioport(x, l, l)
tools/flask/utils/getenforce.c +3 -3
@@ -27,13 +27,13 @@ static void usage (int argCnt, const char *args[])int main (int argCnt,const char *args[]) {int ret; -int xch =0 ; +xc_interface *xch =0 ;if (argCnt !=1 )usage (argCnt, args); - xch =xc_interface_open (); -if ( xch <0 ) + xch =xc_interface_open (0 ,0 ,0 ); +if ( !xch ) {fprintf (stderr,"Unable to create interface to xenctrl: %s\n" ,strerror (errno));
tools/flask/utils/loadpolicy.c +3 -3
@@ -35,7 +35,7 @@ int main (int argCnt, const char *args[])void *polMemCp =NULL ;struct stat info;int ret; -int xch =0 ; +xc_interface *xch =0 ;if (argCnt !=2 )usage (argCnt, args);
@@ -70,8 +70,8 @@ int main (int argCnt, const char *args[]) goto cleanup; } - xch =xc_interface_open (); -if ( xch <0 ) + xch =xc_interface_open (0 ,0 ,0 ); +if ( !xch ) {fprintf (stderr,"Unable to create interface to xenctrl: %s\n" ,strerror (errno));
tools/flask/utils/setenforce.c +3 -3
@@ -27,15 +27,15 @@ static void usage (int argCnt, const char *args[])int main (int argCnt,const char *args[]) {int ret =0 ; -int xch =0 ; +xc_interface *xch =0 ;long mode =0 ;char *end;if (argCnt !=2 )usage (argCnt, args); - xch =xc_interface_open (); -if ( xch <0 ) + xch =xc_interface_open (0 ,0 ,0 ); +if ( !xch ) {fprintf (stderr,"Unable to create interface to xenctrl: %s\n" ,strerror (errno));
tools/fs-back/fs-backend.c +14 -7
@@ -168,8 +168,9 @@ void terminate_mount_request(struct fs_mount *mount) }xenbus_write_backend_state (mount,STATE_CLOSED ); -xc_gnttab_munmap (mount->gnth, mount->ring.sring, mount->shared_ring_size); -xc_gnttab_close (mount->gnth); +xc_gnttab_munmap (mount->xch, mount->gnth, + mount->ring.sring, mount->shared_ring_size); +xc_gnttab_close (mount->xch, mount->gnth);xc_evtchn_unbind (mount->evth, mount->local_evtchn);xc_evtchn_close (mount->evth);
@@ -213,6 +214,9 @@ static void handle_connection(int frontend_dom_id, int export_id, char *frontend mount = (struct fs_mount *)malloc (sizeof (struct fs_mount ));memset (mount,0 ,sizeof (struct fs_mount )); + mount->xch =xc_interface_open (0 ,0 ,XC_OPENFLAG_DUMMY ); +if (!mount->xch) goto error; + mount->dom_id = frontend_dom_id; mount->export = export; mount->mount_id = mount_id++;
@@ -239,14 +243,14 @@ static void handle_connection(int frontend_dom_id, int export_id, char *frontend goto error; } mount->gnth =-1 ; - mount->gnth =xc_gnttab_open (); + mount->gnth =xc_gnttab_open (mount->xch);if (mount->gnth <0 ) {FS_DEBUG ("ERROR: Couldn't open gnttab!\n" ); goto error; }for (i=0 ; i<mount->shared_ring_size; i++) dom_ids[i] = mount->dom_id; - sring = xc_gnttab_map_grant_refs(mount->gnth, + sring = xc_gnttab_map_grant_refs(mount->xch, mount->gnth, mount->shared_ring_size, dom_ids, mount->grefs,
@@ -279,13 +283,16 @@ static void handle_connection(int frontend_dom_id, int export_id, char *frontend error:xenbus_write_backend_state (mount,STATE_CLOSED );if (sring) -xc_gnttab_munmap (mount->gnth, mount->ring.sring, mount->shared_ring_size); +xc_gnttab_munmap (mount->xch, mount->gnth, + mount->ring.sring, mount->shared_ring_size);if (mount->gnth >0 ) -xc_gnttab_close (mount->gnth); +xc_gnttab_close (mount->xch, mount->gnth);if (mount->local_evtchn >0 )xc_evtchn_unbind (mount->evth, mount->local_evtchn);if (mount->evth >0 )xc_evtchn_close (mount->evth); +if (mount->xch) +xc_interface_close (mount->xch); }static void await_connections (void )
@@ -472,7 +479,7 @@ int main(void)/* Close the connection to XenStore when we are finished with everything */ xs_daemon_close (xsh);#if 0 -int xc_handle; +xc_interface *xc_handle;char *shared_page;int prot =PROT_READ |PROT_WRITE ;
tools/fs-back/fs-backend.h +1 -0
@@ -44,6 +44,7 @@ struct fs_mountint mount_id;/* = backend id */ grant_ref_t grefs[MAX_RING_SIZE ];evtchn_port_t remote_evtchn; +xc_interface *xch;/* just for error logging, so a dummy */ int evth;/* Handle to the event channel */ evtchn_port_t local_evtchn;int gnth;
tools/fs-back/fs-ops.c +22 -18
@@ -75,7 +75,7 @@ static void dispatch_file_open(struct fs_mount *mount, struct fsif_request *req)FS_DEBUG ("Dispatching file open operation (gref=%d).\n" , req->u.fopen.gref);/* Read the request, and open file */ - file_name =xc_gnttab_map_grant_ref (mount->gnth, + file_name =xc_gnttab_map_grant_ref (mount->xch, mount->gnth, mount->dom_id, req->u.fopen.gref,PROT_READ );
@@ -99,7 +99,7 @@ static void dispatch_file_open(struct fs_mount *mount, struct fsif_request *req) } } out: -if (xc_gnttab_munmap (mount->gnth, file_name,1 ) !=0 ) { +if (xc_gnttab_munmap (mount->xch, mount->gnth, file_name,1 ) !=0 ) {FS_DEBUG ("ERROR: xc_gnttab_munmap failed errno=%d\n" , errno);terminate_mount_request (mount); }
@@ -159,7 +159,7 @@ static void dispatch_file_read(struct fs_mount *mount, struct fsif_request *req)assert (req->u.fread.len >0 ); count = (req->u.fread.len -1 ) /XC_PAGE_SIZE +1 ;assert (count <=FSIF_NR_READ_GNTS ); - buf = xc_gnttab_map_domain_grant_refs(mount->gnth, + buf = xc_gnttab_map_domain_grant_refs(mount->xch, mount->gnth, count, mount->dom_id, req->u.fread.grefs,
@@ -192,7 +192,8 @@ static void dispatch_file_read(struct fs_mount *mount, struct fsif_request *req) priv_req->aiocb.aio_sigevent.sigev_value.sival_ptr = priv_req;if (aio_read (&priv_req->aiocb) <0 ) {FS_DEBUG ("ERROR: aio_read failed errno=%d\n" , errno); -xc_gnttab_munmap (mount->gnth, priv_req->page, priv_req->count); +xc_gnttab_munmap (mount->xch, mount->gnth, + priv_req->page, priv_req->count);terminate_mount_request (mount); }
@@ -208,7 +209,8 @@ static void end_file_read(struct fs_mount *mount, struct fs_request *priv_req)uint16_t req_id;/* Release the grant */ -if (xc_gnttab_munmap (mount->gnth, priv_req->page, priv_req->count) !=0 ) { +if (xc_gnttab_munmap (mount->xch, mount->gnth, + priv_req->page, priv_req->count) !=0 ) {FS_DEBUG ("ERROR: xc_gnttab_munmap failed errno=%d\n" , errno);terminate_mount_request (mount); }
@@ -234,7 +236,7 @@ static void dispatch_file_write(struct fs_mount *mount, struct fsif_request *reqassert (req->u.fwrite.len >0 ); count = (req->u.fwrite.len -1 ) /XC_PAGE_SIZE +1 ;assert (count <=FSIF_NR_WRITE_GNTS ); - buf = xc_gnttab_map_domain_grant_refs(mount->gnth, + buf = xc_gnttab_map_domain_grant_refs(mount->xch, mount->gnth, count, mount->dom_id, req->u.fwrite.grefs,
@@ -267,7 +269,8 @@ static void dispatch_file_write(struct fs_mount *mount, struct fsif_request *req priv_req->aiocb.aio_sigevent.sigev_value.sival_ptr = priv_req;if (aio_write (&priv_req->aiocb) <0 ) {FS_DEBUG ("ERROR: aio_write failed errno=%d\n" , errno); -xc_gnttab_munmap (mount->gnth, priv_req->page, priv_req->count); +xc_gnttab_munmap (mount->xch, mount->gnth, + priv_req->page, priv_req->count);terminate_mount_request (mount); }
@@ -284,7 +287,8 @@ static void end_file_write(struct fs_mount *mount, struct fs_request *priv_req)uint16_t req_id;/* Release the grant */ -if (xc_gnttab_munmap (mount->gnth, priv_req->page, priv_req->count) !=0 ) { +if (xc_gnttab_munmap (mount->xch, mount->gnth, + priv_req->page, priv_req->count) !=0 ) {FS_DEBUG ("ERROR: xc_gnttab_munmap failed errno=%d\n" , errno);terminate_mount_request (mount); }
@@ -391,7 +395,7 @@ static void dispatch_remove(struct fs_mount *mount, struct fsif_request *req)FS_DEBUG ("Dispatching remove operation (gref=%d).\n" , req->u.fremove.gref);/* Read the request, and open file */ - file_name =xc_gnttab_map_grant_ref (mount->gnth, + file_name =xc_gnttab_map_grant_ref (mount->xch, mount->gnth, mount->dom_id, req->u.fremove.gref,PROT_READ );
@@ -405,7 +409,7 @@ static void dispatch_remove(struct fs_mount *mount, struct fsif_request *req) ret =remove (file_name); }FS_DEBUG ("Got ret: %d\n" , ret); -if (xc_gnttab_munmap (mount->gnth, file_name,1 ) !=0 ) { +if (xc_gnttab_munmap (mount->xch, mount->gnth, file_name,1 ) !=0 ) {FS_DEBUG ("ERROR: xc_gnttab_munmap failed errno=%d\n" , errno);terminate_mount_request (mount); }
@@ -433,7 +437,7 @@ static void dispatch_rename(struct fs_mount *mount, struct fsif_request *req)FS_DEBUG ("Dispatching rename operation (gref=%d).\n" , req->u.fremove.gref);/* Read the request, and open file */ - buf =xc_gnttab_map_grant_ref (mount->gnth, + buf =xc_gnttab_map_grant_ref (mount->xch, mount->gnth, mount->dom_id, req->u.frename.gref,PROT_READ );
@@ -451,7 +455,7 @@ static void dispatch_rename(struct fs_mount *mount, struct fsif_request *req) ret =rename (old_file_name, new_file_name); }FS_DEBUG ("Got ret: %d\n" , ret); -if (xc_gnttab_munmap (mount->gnth, buf,1 ) !=0 ) { +if (xc_gnttab_munmap (mount->xch, mount->gnth, buf,1 ) !=0 ) {FS_DEBUG ("ERROR: xc_gnttab_munmap failed errno=%d\n" , errno);terminate_mount_request (mount); }
@@ -483,7 +487,7 @@ static void dispatch_create(struct fs_mount *mount, struct fsif_request *req)/* Read the request, and create file/directory */ mode = req->u.fcreate.mode; directory = req->u.fcreate.directory; - file_name =xc_gnttab_map_grant_ref (mount->gnth, + file_name =xc_gnttab_map_grant_ref (mount->xch, mount->gnth, mount->dom_id, req->u.fcreate.gref,PROT_READ );
@@ -519,7 +523,7 @@ static void dispatch_create(struct fs_mount *mount, struct fsif_request *req) } } out: -if (xc_gnttab_munmap (mount->gnth, file_name,1 ) !=0 ) { +if (xc_gnttab_munmap (mount->xch, mount->gnth, file_name,1 ) !=0 ) {FS_DEBUG ("ERROR: xc_gnttab_munmap failed errno=%d\n" , errno);terminate_mount_request (mount); }
@@ -547,7 +551,7 @@ static void dispatch_list(struct fs_mount *mount, struct fsif_request *req)FS_DEBUG ("Dispatching list operation (gref=%d).\n" , req->u.flist.gref);/* Read the request, and list directory */ offset = req->u.flist.offset; - buf = file_name =xc_gnttab_map_grant_ref (mount->gnth, + buf = file_name =xc_gnttab_map_grant_ref (mount->xch, mount->gnth, mount->dom_id, req->u.flist.gref,PROT_READ |PROT_WRITE );
@@ -595,7 +599,7 @@ error_out: ret_val = ((nr_files <<NR_FILES_SHIFT ) &NR_FILES_MASK ) | ((error_code <<ERROR_SHIFT ) &ERROR_MASK ) | (dirent !=NULL ?HAS_MORE_FLAG :0 ); -if (xc_gnttab_munmap (mount->gnth, file_name,1 ) !=0 ) { +if (xc_gnttab_munmap (mount->xch, mount->gnth, file_name,1 ) !=0 ) {FS_DEBUG ("ERROR: xc_gnttab_munmap failed errno=%d\n" , errno);terminate_mount_request (mount); }
@@ -650,7 +654,7 @@ static void dispatch_fs_space(struct fs_mount *mount, struct fsif_request *req)FS_DEBUG ("Dispatching fs space operation (gref=%d).\n" , req->u.fspace.gref);/* Read the request, and open file */ - file_name =xc_gnttab_map_grant_ref (mount->gnth, + file_name =xc_gnttab_map_grant_ref (mount->xch, mount->gnth, mount->dom_id, req->u.fspace.gref,PROT_READ );
@@ -666,7 +670,7 @@ static void dispatch_fs_space(struct fs_mount *mount, struct fsif_request *req)if (ret >=0 ) ret = stat.f_bsize * stat.f_bfree; -if (xc_gnttab_munmap (mount->gnth, file_name,1 ) !=0 ) { +if (xc_gnttab_munmap (mount->xch, mount->gnth, file_name,1 ) !=0 ) {FS_DEBUG ("ERROR: xc_gnttab_munmap failed errno=%d\n" , errno);terminate_mount_request (mount); }
tools/libxc/INPROGRESS new file +0 -0
tools/libxc/ia64/xc_ia64.h +2 -2
@@ -21,7 +21,7 @@#ifndef _XC_IA64_H_#define _XC_IA64_H_ -int xc_ia64_copy_memmap (int xc_handle,uint32_t domid, +int xc_ia64_copy_memmap (xc_interface *xc_handle,uint32_t domid,shared_info_t *live_shinfo,xen_ia64_memmap_info_t **memmap_info_p,unsigned long *memmap_info_num_pages_p);
@@ -32,7 +32,7 @@ struct xen_ia64_p2m_table { };void xc_ia64_p2m_init (struct xen_ia64_p2m_table *p2m_table); -int xc_ia64_p2m_map (struct xen_ia64_p2m_table *p2m_table,int xc_handle, +int xc_ia64_p2m_map (struct xen_ia64_p2m_table *p2m_table,xc_interface *xc_handle,uint32_t domid,struct xen_ia64_memmap_info *memmap_info,unsigned long flag);void xc_ia64_p2m_unmap (struct xen_ia64_p2m_table *p2m_table);
tools/libxc/ia64/xc_ia64_hvm_build.c +14 -14
@@ -13,7 +13,7 @@#include <xen/hvm/params.h> static int -xc_ia64_copy_to_domain_pages (int xc_handle,uint32_t domid,void * src_page, +xc_ia64_copy_to_domain_pages (xc_interface *xc_handle,uint32_t domid,void * src_page,unsigned long dst_pfn,int nr_pages) {// N.B. gva should be page aligned
@@ -90,10 +90,10 @@ static int add_nvram_hob(void* hob_buf, unsigned long nvram_addr);static int build_hob (void * hob_buf,unsigned long hob_buf_size,unsigned long dom_mem_size,unsigned long vcpus,unsigned long nvram_addr); -static int load_hob (int xc_handle,uint32_t dom,void *hob_buf); +static int load_hob (xc_interface *xc_handle,uint32_t dom,void *hob_buf);static int -xc_ia64_build_hob (int xc_handle,uint32_t dom, +xc_ia64_build_hob (xc_interface *xc_handle,uint32_t dom,unsigned long memsize,unsigned long vcpus,unsigned long nvram_addr) {
@@ -239,7 +239,7 @@ err_out: }static int -load_hob (int xc_handle,uint32_t dom,void *hob_buf) +load_hob (xc_interface *xc_handle,uint32_t dom,void *hob_buf) {// hob_buf should be page aligned int hob_size;
@@ -545,7 +545,7 @@ nvram_init(const char *nvram_path) }static int -copy_from_nvram_to_GFW (int xc_handle,uint32_t dom,int nvram_fd) +copy_from_nvram_to_GFW (xc_interface *xc_handle,uint32_t dom,int nvram_fd) {unsigned int nr_pages =NVRAM_SIZE >>PAGE_SHIFT ;struct stat file_stat;
@@ -597,7 +597,7 @@ static int is_valid_address(void *addr)* can be got. */ static int -copy_from_GFW_to_nvram (int xc_handle,uint32_t dom,int nvram_fd) +copy_from_GFW_to_nvram (xc_interface *xc_handle,uint32_t dom,int nvram_fd) {xen_pfn_t *pfn_list =NULL ;char *tmp_ptr =NULL ;
@@ -686,7 +686,7 @@ copy_from_GFW_to_nvram(int xc_handle, uint32_t dom, int nvram_fd)return 0 ; } -int xc_ia64_save_to_nvram (int xc_handle,uint32_t dom) +int xc_ia64_save_to_nvram (xc_interface *xc_handle,uint32_t dom) {xc_dominfo_t info;uint64_t nvram_fd =0 ;
@@ -717,7 +717,7 @@ int xc_ia64_save_to_nvram(int xc_handle, uint32_t dom)#define NVRAM_DIR "/var/lib/xen/nvram/"#define NVRAM_FILE_PREFIX "nvram_" -int xc_ia64_nvram_init (int xc_handle,char *dom_name,uint32_t dom) +int xc_ia64_nvram_init (xc_interface *xc_handle,char *dom_name,uint32_t dom) {uint64_t nvram_fd;char nvram_path[PATH_MAX ] =NVRAM_DIR ;
@@ -784,7 +784,7 @@ min(unsigned long lhs, unsigned long rhs) } static int -xc_ia64_setup_memmap_info(int xc_handle, uint32_t dom, +xc_ia64_setup_memmap_info(xc_interface *xc_handle, uint32_t dom, unsigned long dom_memsize, /* in bytes */ unsigned long *pfns_special_pages, unsigned long nr_special_pages,
@@ -861,7 +861,7 @@ xc_ia64_setup_memmap_info(int xc_handle, uint32_t dom,/* setup shared_info page */ static int -xc_ia64_setup_shared_info (int xc_handle,uint32_t dom, +xc_ia64_setup_shared_info (xc_interface *xc_handle,uint32_t dom,unsigned long shared_info_pfn,unsigned long memmap_info_pfn,unsigned long memmap_info_num_pages)
@@ -891,7 +891,7 @@ xc_ia64_setup_shared_info(int xc_handle, uint32_t dom,* convenient to allocate discontiguous memory with different size. */ static int -setup_guest (int xc_handle,uint32_t dom,unsigned long memsize, +setup_guest (xc_interface *xc_handle,uint32_t dom,unsigned long memsize,char *image,unsigned long image_size) {xen_pfn_t *pfn_list;
@@ -1055,7 +1055,7 @@ error_out: }int -xc_hvm_build (int xc_handle,uint32_t domid,int memsize,const char *image_name) +xc_hvm_build (xc_interface *xc_handle,uint32_t domid,int memsize,const char *image_name) {vcpu_guest_context_any_t st_ctxt_any;vcpu_guest_context_t *ctxt = &st_ctxt_any.c;
@@ -1105,7 +1105,7 @@ error_out:* memsize pages marked populate-on-demand, and with a PoD cache size * of target. If target == memsize, pages are populated normally. */ -int xc_hvm_build_target_mem(int xc_handle, +int xc_hvm_build_target_mem(xc_interface *xc_handle, uint32_t domid, int memsize, int target,
@@ -1131,7 +1131,7 @@ int xc_hvm_build_target_mem(int xc_handle,#define _PAGE_AR_RW (2 << 9)/* read & write */ int -xc_ia64_set_os_type (int xc_handle,char *guest_os_type,uint32_t dom) +xc_ia64_set_os_type (xc_interface *xc_handle,char *guest_os_type,uint32_t dom) {DECLARE_DOMCTL ;
tools/libxc/ia64/xc_ia64_linux_restore.c +13 -13
@@ -29,7 +29,7 @@ static unsigned long p2m_size;static unsigned long nr_pfns;static int -populate_page_if_necessary (int xc_handle,uint32_t dom,unsigned long gmfn, +populate_page_if_necessary (xc_interface *xc_handle,uint32_t dom,unsigned long gmfn,struct xen_ia64_p2m_table *p2m_table) {if (xc_ia64_p2m_present (p2m_table, gmfn))
@@ -39,7 +39,7 @@ populate_page_if_necessary(int xc_handle, uint32_t dom, unsigned long gmfn, }static int -read_page (int xc_handle,int io_fd,uint32_t dom,unsigned long pfn) +read_page (xc_interface *xc_handle,int io_fd,uint32_t dom,unsigned long pfn) {void *mem;
@@ -65,7 +65,7 @@ read_page(int xc_handle, int io_fd, uint32_t dom, unsigned long pfn)* pages here. */ static int -xc_ia64_recv_unallocated_list (int xc_handle,int io_fd,uint32_t dom, +xc_ia64_recv_unallocated_list (xc_interface *xc_handle,int io_fd,uint32_t dom,struct xen_ia64_p2m_table *p2m_table) {int rc =-1 ;
@@ -116,7 +116,7 @@ xc_ia64_recv_unallocated_list(int xc_handle, int io_fd, uint32_t dom, }static int -xc_ia64_recv_vcpu_context (int xc_handle,int io_fd,uint32_t dom, +xc_ia64_recv_vcpu_context (xc_interface *xc_handle,int io_fd,uint32_t dom,uint32_t vcpu,vcpu_guest_context_any_t *ctxt_any) {vcpu_guest_context_t *ctxt = &ctxt_any->c;
@@ -147,7 +147,7 @@ xc_ia64_recv_vcpu_context(int xc_handle, int io_fd, uint32_t dom,/* Read shared info. */ static int -xc_ia64_recv_shared_info (int xc_handle,int io_fd,uint32_t dom, +xc_ia64_recv_shared_info (xc_interface *xc_handle,int io_fd,uint32_t dom,unsigned long shared_info_frame,unsigned long *start_info_pfn) {
@@ -222,7 +222,7 @@ xc_ia64_recv_vcpumap(const xc_dominfo_t *info, int io_fd, uint64_t **vcpumapp) }static int -xc_ia64_pv_recv_vcpu_context (int xc_handle,int io_fd,int32_t dom, +xc_ia64_pv_recv_vcpu_context (xc_interface *xc_handle,int io_fd,int32_t dom,uint32_t vcpu) {int rc =-1 ;
@@ -254,7 +254,7 @@ xc_ia64_pv_recv_vcpu_context(int xc_handle, int io_fd, int32_t dom, } static int -xc_ia64_pv_recv_shared_info(int xc_handle, int io_fd, int32_t dom, +xc_ia64_pv_recv_shared_info(xc_interface *xc_handle, int io_fd, int32_t dom, unsigned long shared_info_frame, struct xen_ia64_p2m_table *p2m_table, unsigned int store_evtchn,
@@ -296,7 +296,7 @@ xc_ia64_pv_recv_shared_info(int xc_handle, int io_fd, int32_t dom, } static int -xc_ia64_pv_recv_context_ver_one_or_two(int xc_handle, int io_fd, uint32_t dom, +xc_ia64_pv_recv_context_ver_one_or_two(xc_interface *xc_handle, int io_fd, uint32_t dom, unsigned long shared_info_frame, struct xen_ia64_p2m_table *p2m_table, unsigned int store_evtchn,
@@ -320,7 +320,7 @@ xc_ia64_pv_recv_context_ver_one_or_two(int xc_handle, int io_fd, uint32_t dom, } static int -xc_ia64_pv_recv_context_ver_three(int xc_handle, int io_fd, uint32_t dom, +xc_ia64_pv_recv_context_ver_three(xc_interface *xc_handle, int io_fd, uint32_t dom, unsigned long shared_info_frame, struct xen_ia64_p2m_table *p2m_table, unsigned int store_evtchn,
@@ -365,7 +365,7 @@ xc_ia64_pv_recv_context_ver_three(int xc_handle, int io_fd, uint32_t dom, static int xc_ia64_pv_recv_context(unsigned long format_version, - int xc_handle, int io_fd, uint32_t dom, + xc_interface *xc_handle, int io_fd, uint32_t dom, unsigned long shared_info_frame, struct xen_ia64_p2m_table *p2m_table, unsigned int store_evtchn,
@@ -399,7 +399,7 @@ xc_ia64_pv_recv_context(unsigned long format_version, } static int -xc_ia64_hvm_recv_context(int xc_handle, int io_fd, uint32_t dom, +xc_ia64_hvm_recv_context(xc_interface *xc_handle, int io_fd, uint32_t dom, unsigned long shared_info_frame, struct xen_ia64_p2m_table *p2m_table, unsigned int store_evtchn, unsigned long *store_mfn,
@@ -521,7 +521,7 @@ out:* hvm domain requires IO pages allocated when XEN_DOMCTL_arch_setup */ static int -xc_ia64_hvm_domain_setup (int xc_handle,uint32_t dom) +xc_ia64_hvm_domain_setup (xc_interface *xc_handle,uint32_t dom) {int rc;xen_pfn_t pfn_list[] = {
@@ -539,7 +539,7 @@ xc_ia64_hvm_domain_setup(int xc_handle, uint32_t dom) }int -xc_domain_restore (int xc_handle,int io_fd,uint32_t dom, +xc_domain_restore (xc_interface *xc_handle,int io_fd,uint32_t dom,unsigned int store_evtchn,unsigned long *store_mfn,unsigned int console_evtchn,unsigned long *console_mfn,unsigned int hvm,unsigned int pae,int superpages)
tools/libxc/ia64/xc_ia64_linux_save.c +8 -8
@@ -54,7 +54,7 @@ static inline void set_bit(int nr, volatile void * addr)static int suspend_and_state (int (*suspend)(void *),void * data, -int xc_handle,int io_fd, +xc_interface *xc_handle,int io_fd,int dom,xc_dominfo_t *info) {if ( !(*suspend)(data) ) {
@@ -86,7 +86,7 @@ md_is_not_ram(const efi_memory_desc_t *md)* page after pausing the domain. */ static int -xc_ia64_send_unallocated_list (int xc_handle,int io_fd, +xc_ia64_send_unallocated_list (xc_interface *xc_handle,int io_fd,struct xen_ia64_p2m_table *p2m_table,xen_ia64_memmap_info_t *memmap_info,void *memmap_desc_start,void *memmap_desc_end)
@@ -155,7 +155,7 @@ xc_ia64_send_unallocated_list(int xc_handle, int io_fd, }static int -xc_ia64_send_vcpu_context (int xc_handle,int io_fd,uint32_t dom, +xc_ia64_send_vcpu_context (xc_interface *xc_handle,int io_fd,uint32_t dom,uint32_t vcpu,vcpu_guest_context_any_t *ctxt_any) {vcpu_guest_context_t *ctxt = &ctxt_any->c;
@@ -174,7 +174,7 @@ xc_ia64_send_vcpu_context(int xc_handle, int io_fd, uint32_t dom, }static int -xc_ia64_send_shared_info (int xc_handle,int io_fd,shared_info_t *live_shinfo) +xc_ia64_send_shared_info (xc_interface *xc_handle,int io_fd,shared_info_t *live_shinfo) {if (write_exact (io_fd, live_shinfo,PAGE_SIZE )) {ERROR ("Error when writing to state file (1)" );
@@ -184,7 +184,7 @@ xc_ia64_send_shared_info(int xc_handle, int io_fd, shared_info_t *live_shinfo) }static int -xc_ia64_send_vcpumap (int xc_handle,int io_fd,uint32_t dom, +xc_ia64_send_vcpumap (xc_interface *xc_handle,int io_fd,uint32_t dom,const xc_dominfo_t *info,uint64_t max_virt_cpus,uint64_t **vcpumapp) {
@@ -231,7 +231,7 @@ xc_ia64_send_vcpumap(int xc_handle, int io_fd, uint32_t dom,static int -xc_ia64_pv_send_context (int xc_handle,int io_fd,uint32_t dom, +xc_ia64_pv_send_context (xc_interface *xc_handle,int io_fd,uint32_t dom,const xc_dominfo_t *info,shared_info_t *live_shinfo) {int rc =-1 ;
@@ -280,7 +280,7 @@ xc_ia64_pv_send_context(int xc_handle, int io_fd, uint32_t dom, }static int -xc_ia64_hvm_send_context (int xc_handle,int io_fd,uint32_t dom, +xc_ia64_hvm_send_context (xc_interface *xc_handle,int io_fd,uint32_t dom,const xc_dominfo_t *info,shared_info_t *live_shinfo) {int rc =-1 ;
@@ -381,7 +381,7 @@ out: }int -xc_domain_save (int xc_handle,int io_fd,uint32_t dom,uint32_t max_iters, +xc_domain_save (xc_interface *xc_handle,int io_fd,uint32_t dom,uint32_t max_iters,uint32_t max_factor,uint32_t flags,struct save_callbacks * callbacks,int hvm,void (*switch_qemu_logdirty)(int ,unsigned ))
tools/libxc/ia64/xc_ia64_stubs.c +7 -7
@@ -19,7 +19,7 @@ xc_ia64_fpsr_default(void) }static int -xc_ia64_get_pfn_list (int xc_handle,uint32_t domid,xen_pfn_t *pfn_buf, +xc_ia64_get_pfn_list (xc_interface *xc_handle,uint32_t domid,xen_pfn_t *pfn_buf,unsigned int start_page,unsigned int nr_pages) {DECLARE_DOMCTL ;
@@ -43,7 +43,7 @@ xc_ia64_get_pfn_list(int xc_handle, uint32_t domid, xen_pfn_t *pfn_buf, }int -xc_get_pfn_list (int xc_handle,uint32_t domid,uint64_t *pfn_buf, +xc_get_pfn_list (xc_interface *xc_handle,uint32_t domid,uint64_t *pfn_buf,unsigned long max_pfns) { return xc_ia64_get_pfn_list(xc_handle, domid, (xen_pfn_t *)pfn_buf,
@@ -51,7 +51,7 @@ xc_get_pfn_list(int xc_handle, uint32_t domid, uint64_t *pfn_buf, }long -xc_get_max_pages (int xc_handle,uint32_t domid) +xc_get_max_pages (xc_interface *xc_handle,uint32_t domid) {struct xen_domctl domctl; domctl.cmd = XEN_DOMCTL_getdomaininfo;
@@ -63,7 +63,7 @@ xc_get_max_pages(int xc_handle, uint32_t domid)/* It is possible to get memmap_info and memmap by foreign domain page mapping. But it's racy. Use hypercall to avoid race. */ static int -xc_ia64_get_memmap (int xc_handle, +xc_ia64_get_memmap (xc_interface *xc_handle,uint32_t domid,char *buf,unsigned long bufsize) {privcmd_hypercall_t hypercall;
@@ -84,7 +84,7 @@ xc_ia64_get_memmap(int xc_handle, }int -xc_ia64_copy_memmap (int xc_handle,uint32_t domid,shared_info_t *live_shinfo, +xc_ia64_copy_memmap (xc_interface *xc_handle,uint32_t domid,shared_info_t *live_shinfo,xen_ia64_memmap_info_t **memmap_info_p,unsigned long *memmap_info_num_pages_p) {
@@ -163,7 +163,7 @@ xc_ia64_copy_memmap(int xc_handle, uint32_t domid, shared_info_t *live_shinfo,#define PTRS_PER_PTE (1UL << (PAGE_SHIFT - 3))static void * -xc_ia64_map_foreign_p2m (int xc_handle,uint32_t dom, +xc_ia64_map_foreign_p2m (xc_interface *xc_handle,uint32_t dom,struct xen_ia64_memmap_info *memmap_info,unsigned long flags,unsigned long *p2m_size_p) {
@@ -219,7 +219,7 @@ xc_ia64_p2m_init(struct xen_ia64_p2m_table *p2m_table) }int -xc_ia64_p2m_map (struct xen_ia64_p2m_table *p2m_table,int xc_handle, +xc_ia64_p2m_map (struct xen_ia64_p2m_table *p2m_table,xc_interface *xc_handle,uint32_t domid,struct xen_ia64_memmap_info *memmap_info,unsigned long flag) {
tools/libxc/xc_acm.c +2 -2
@@ -14,7 +14,7 @@#include "xc_private.h" -int xc_acm_op (int xc_handle,int cmd,void *arg,unsigned long arg_size) +int xc_acm_op (xc_interface *xch,int cmd,void *arg,unsigned long arg_size) {int ret;DECLARE_HYPERCALL ;
@@ -88,7 +88,7 @@ int xc_acm_op(int xc_handle, int cmd, void *arg, unsigned long arg_size)PERROR ("Could not lock memory for Xen hypercall" );return -EFAULT ; } -if ( (ret =do_xen_hypercall (xc_handle, &hypercall)) <0 ) +if ( (ret =do_xen_hypercall (xch, &hypercall)) <0 ) {if ( errno ==EACCES ) DPRINTF("acmctl operation failed -- need to"
tools/libxc/xc_core.c +79 -74
529 lines not on this page · raw message
tools/libxc/xc_core.h +7 -5
@@ -119,9 +119,11 @@ struct xc_core_strtab;struct xc_core_section_headers ;Elf64_Shdr * -xc_core_shdr_get (struct xc_core_section_headers *sheaders); +xc_core_shdr_get (xc_interface *xch, +struct xc_core_section_headers *sheaders); int -xc_core_shdr_set(Elf64_Shdr *shdr, +xc_core_shdr_set(xc_interface *xch, + Elf64_Shdr *shdr, struct xc_core_strtab *strtab, const char *name, uint32_t type, uint64_t offset, uint64_t size,
@@ -134,16 +136,16 @@ struct xc_core_memory_map {typedef struct xc_core_memory_map xc_core_memory_map_t ;int xc_core_arch_auto_translated_physmap (const xc_dominfo_t *info);struct xc_core_arch_context ; -int xc_core_arch_memory_map_get (int xc_handle, +int xc_core_arch_memory_map_get (xc_interface *xch,struct xc_core_arch_context *arch_ctxt,xc_dominfo_t *info,shared_info_any_t *live_shinfo,xc_core_memory_map_t **mapp,unsigned int *nr_entries); -int xc_core_arch_map_p2m (int xc_handle,unsigned int guest_width, +int xc_core_arch_map_p2m (xc_interface *xch,unsigned int guest_width,xc_dominfo_t *info,shared_info_any_t *live_shinfo,xen_pfn_t **live_p2m,unsigned long *pfnp); -int xc_core_arch_map_p2m_writable (int xc_handle,unsigned int guest_width, +int xc_core_arch_map_p2m_writable (xc_interface *xch,unsigned int guest_width,xc_dominfo_t *info,shared_info_any_t *live_shinfo,xen_pfn_t **live_p2m,unsigned long *pfnp);
tools/libxc/xc_core_ia64.c +12 -12
@@ -67,7 +67,7 @@ xc_core_arch_auto_translated_physmap(const xc_dominfo_t *info)/* see setup_guest() @ xc_linux_build.c */ static int -memory_map_get_old_domu (int xc_handle,xc_dominfo_t *info, +memory_map_get_old_domu (xc_interface *xch,xc_dominfo_t *info,shared_info_any_t *live_shinfo,xc_core_memory_map_t **mapp,unsigned int *nr_entries) {
@@ -95,7 +95,7 @@ out:/* see setup_guest() @ xc_ia64_hvm_build.c */ static int -memory_map_get_old_hvm (int xc_handle,xc_dominfo_t *info, +memory_map_get_old_hvm (xc_interface *xch,xc_dominfo_t *info,shared_info_any_t *live_shinfo,xc_core_memory_map_t **mapp,unsigned int *nr_entries) {
@@ -154,21 +154,21 @@ out: }static int -memory_map_get_old (int xc_handle,xc_dominfo_t *info, +memory_map_get_old (xc_interface *xch,xc_dominfo_t *info,shared_info_any_t *live_shinfo,xc_core_memory_map_t **mapp,unsigned int *nr_entries) {if ( info->hvm ) -return memory_map_get_old_hvm (xc_handle, info, live_shinfo, +return memory_map_get_old_hvm (xch, info, live_shinfo, mapp, nr_entries);if ( live_shinfo ==NULL )return -1 ; -return memory_map_get_old_domu (xc_handle, info, live_shinfo, +return memory_map_get_old_domu (xch, info, live_shinfo, mapp, nr_entries); } int -xc_core_arch_memory_map_get(int xc_handle, +xc_core_arch_memory_map_get(xc_interface *xch, struct xc_core_arch_context *arch_ctxt, xc_dominfo_t *info, shared_info_any_t *live_shinfo,
@@ -191,7 +191,7 @@ xc_core_arch_memory_map_get(int xc_handle, }/* copy before use in case someone updating them */ -if (xc_ia64_copy_memmap (xc_handle, info->domid, &live_shinfo->s, +if (xc_ia64_copy_memmap (xch, info->domid, &live_shinfo->s, &memmap_info,NULL )) { goto old; }
@@ -223,7 +223,7 @@ xc_core_arch_memory_map_get(int xc_handle, } ret =0 ; -xc_ia64_p2m_map (&arch_ctxt->p2m_table, xc_handle, info->domid, +xc_ia64_p2m_map (&arch_ctxt->p2m_table, xch, info->domid, memmap_info,0 );if ( memmap_info !=NULL )free (memmap_info);
@@ -232,11 +232,11 @@ xc_core_arch_memory_map_get(int xc_handle, old:DPRINTF ("Falling back old method.\n" ); -return memory_map_get_old (xc_handle, info, live_shinfo, mapp, nr_entries); +return memory_map_get_old (xch, info, live_shinfo, mapp, nr_entries); }int -xc_core_arch_map_p2m (int xc_handle,unsigned int guest_width,xc_dominfo_t *info, +xc_core_arch_map_p2m (xc_interface *xch,unsigned int guest_width,xc_dominfo_t *info,shared_info_any_t *live_shinfo,xen_pfn_t **live_p2m,unsigned long *pfnp) {
@@ -273,7 +273,7 @@ xc_core_arch_context_free(struct xc_core_arch_context* arch_ctxt)int xc_core_arch_context_get (struct xc_core_arch_context * arch_ctxt,vcpu_guest_context_any_t * ctxt_any, -int xc_handle,uint32_t domid) +xc_interface *xch,uint32_t domid) {vcpu_guest_context_t *ctxt = &ctxt_any->c;mapped_regs_t * mapped_regs;
@@ -302,7 +302,7 @@ xc_core_arch_context_get(struct xc_core_arch_context* arch_ctxt, arch_ctxt->mapped_regs = new; } - mapped_regs =xc_map_foreign_range (xc_handle, domid, + mapped_regs =xc_map_foreign_range (xch, domid, arch_ctxt->mapped_regs_size,PROT_READ , ctxt->privregs_pfn);if ( mapped_regs ==NULL )
tools/libxc/xc_core_ia64.h +1 -1
@@ -41,7 +41,7 @@ xc_core_arch_context_free(struct xc_core_arch_context* arch_ctxt);int xc_core_arch_context_get (struct xc_core_arch_context * arch_ctxt,vcpu_guest_context_any_t * ctxt, -int xc_handle,uint32_t domid); +xc_interface *xch,uint32_t domid); int xc_core_arch_context_get_shdr(struct xc_core_arch_context* arch_ctxt, struct xc_core_section_headers *sheaders,
tools/libxc/xc_core_x86.c +13 -13
@@ -40,9 +40,9 @@ xc_core_arch_gpfn_may_present(struct xc_core_arch_context *arch_ctxt, } -static int nr_gpfns (int xc_handle,domid_t domid) +static int nr_gpfns (xc_interface *xch,domid_t domid) { -return xc_memory_op (xc_handle, XENMEM_maximum_gpfn, &domid) +1 ; +return xc_memory_op (xch, XENMEM_maximum_gpfn, &domid) +1 ; }int
@@ -52,12 +52,12 @@ xc_core_arch_auto_translated_physmap(const xc_dominfo_t *info) }int -xc_core_arch_memory_map_get (int xc_handle,struct xc_core_arch_context *unused, +xc_core_arch_memory_map_get (xc_interface *xch,struct xc_core_arch_context *unused,xc_dominfo_t *info,shared_info_any_t *live_shinfo,xc_core_memory_map_t **mapp,unsigned int *nr_entries) { -unsigned long p2m_size =nr_gpfns (xc_handle, info->domid); +unsigned long p2m_size =nr_gpfns (xch, info->domid);xc_core_memory_map_t *map; map =malloc (sizeof (*map));
@@ -76,7 +76,7 @@ xc_core_arch_memory_map_get(int xc_handle, struct xc_core_arch_context *unused, }static int -xc_core_arch_map_p2m_rw (int xc_handle,struct domain_info_context *dinfo,xc_dominfo_t *info, +xc_core_arch_map_p2m_rw (xc_interface *xch,struct domain_info_context *dinfo,xc_dominfo_t *info,shared_info_any_t *live_shinfo,xen_pfn_t **live_p2m,unsigned long *pfnp,int rw) {
@@ -92,7 +92,7 @@ xc_core_arch_map_p2m_rw(int xc_handle, struct domain_info_context *dinfo, xc_domint err;int i; - dinfo->p2m_size =nr_gpfns (xc_handle, info->domid); + dinfo->p2m_size =nr_gpfns (xch, info->domid);if ( dinfo->p2m_size < info->nr_pages ) {ERROR ("p2m_size < nr_pages -1 (%lx < %lx" , dinfo->p2m_size, info->nr_pages -1 );
@@ -100,7 +100,7 @@ xc_core_arch_map_p2m_rw(int xc_handle, struct domain_info_context *dinfo, xc_dom } live_p2m_frame_list_list = -xc_map_foreign_range (xc_handle, dom,PAGE_SIZE ,PROT_READ , +xc_map_foreign_range (xch, dom,PAGE_SIZE ,PROT_READ ,GET_FIELD (live_shinfo, arch.pfn_to_mfn_frame_list_list));if ( !live_p2m_frame_list_list )
@@ -129,7 +129,7 @@ xc_core_arch_map_p2m_rw(int xc_handle, struct domain_info_context *dinfo, xc_dom p2m_frame_list_list[i] = ((uint32_t *)p2m_frame_list_list)[i]; live_p2m_frame_list = -xc_map_foreign_pages (xc_handle, dom,PROT_READ , +xc_map_foreign_pages (xch, dom,PROT_READ , p2m_frame_list_list,P2M_FLL_ENTRIES );
@@ -156,7 +156,7 @@ xc_core_arch_map_p2m_rw(int xc_handle, struct domain_info_context *dinfo, xc_domfor ( i =P2M_FL_ENTRIES -1 ; i >=0 ; i-- ) p2m_frame_list[i] = ((uint32_t *)p2m_frame_list)[i]; - *live_p2m =xc_map_foreign_pages (xc_handle, dom, + *live_p2m =xc_map_foreign_pages (xch, dom, rw ? (PROT_READ |PROT_WRITE ) :PROT_READ , p2m_frame_list,P2M_FL_ENTRIES );
@@ -191,24 +191,24 @@ out: }int -xc_core_arch_map_p2m (int xc_handle,unsigned int guest_width,xc_dominfo_t *info, +xc_core_arch_map_p2m (xc_interface *xch,unsigned int guest_width,xc_dominfo_t *info,shared_info_any_t *live_shinfo,xen_pfn_t **live_p2m,unsigned long *pfnp) {struct domain_info_context _dinfo = { .guest_width = guest_width };struct domain_info_context *dinfo = &_dinfo; -return xc_core_arch_map_p2m_rw (xc_handle, dinfo, info, +return xc_core_arch_map_p2m_rw (xch, dinfo, info, live_shinfo, live_p2m, pfnp,0 ); }int -xc_core_arch_map_p2m_writable (int xc_handle,unsigned int guest_width,xc_dominfo_t *info, +xc_core_arch_map_p2m_writable (xc_interface *xch,unsigned int guest_width,xc_dominfo_t *info,shared_info_any_t *live_shinfo,xen_pfn_t **live_p2m,unsigned long *pfnp) {struct domain_info_context _dinfo = { .guest_width = guest_width };struct domain_info_context *dinfo = &_dinfo; -return xc_core_arch_map_p2m_rw (xc_handle, dinfo, info, +return xc_core_arch_map_p2m_rw (xch, dinfo, info, live_shinfo, live_p2m, pfnp,1 ); }/*
tools/libxc/xc_core_x86.h +1 -1
@@ -30,7 +30,7 @@ struct xc_core_arch_context {#define xc_core_arch_context_init (arch_ctxt) do {} while (0)#define xc_core_arch_context_free (arch_ctxt) do {} while (0) -#define xc_core_arch_context_get (arch_ctxt, ctxt, xc_handle, domid) \ +#define xc_core_arch_context_get (arch_ctxt, ctxt, xch, domid) \ (0)#define xc_core_arch_context_dump (arch_ctxt, args, dump_rtn) (0)
tools/libxc/xc_cpu_hotplug.c +4 -4
@@ -25,7 +25,7 @@#include "xc_private.h" -int xc_cpu_online (int xc_handle,int cpu) +int xc_cpu_online (xc_interface *xch,int cpu) {DECLARE_SYSCTL ;int ret;
@@ -33,12 +33,12 @@ int xc_cpu_online(int xc_handle, int cpu) sysctl.cmd = XEN_SYSCTL_cpu_hotplug; sysctl.u.cpu_hotplug.cpu = cpu; sysctl.u.cpu_hotplug.op =XEN_SYSCTL_CPU_HOTPLUG_ONLINE ; - ret =xc_sysctl (xc_handle, &sysctl); + ret =xc_sysctl (xch, &sysctl);return ret; } -int xc_cpu_offline (int xc_handle,int cpu) +int xc_cpu_offline (xc_interface *xch,int cpu) {DECLARE_SYSCTL ;int ret;
@@ -46,7 +46,7 @@ int xc_cpu_offline(int xc_handle, int cpu) sysctl.cmd = XEN_SYSCTL_cpu_hotplug; sysctl.u.cpu_hotplug.cpu = cpu; sysctl.u.cpu_hotplug.op =XEN_SYSCTL_CPU_HOTPLUG_OFFLINE ; - ret =xc_sysctl (xc_handle, &sysctl); + ret =xc_sysctl (xch, &sysctl);return ret; }
tools/libxc/xc_cpuid_x86.c +31 -26
182 lines not on this page · raw message
tools/libxc/xc_cpupool.c +16 -16
@@ -9,18 +9,18 @@#include <stdarg.h> #include "xc_private.h" -static int do_sysctl_save (int xc_handle,struct xen_sysctl *sysctl) +static int do_sysctl_save (xc_interface *xch,struct xen_sysctl *sysctl) {int ret;do { - ret =do_sysctl (xc_handle, sysctl); + ret =do_sysctl (xch, sysctl); }while ( (ret <0 ) && (errno ==EAGAIN ) );return ret; } -int xc_cpupool_create (int xc_handle, +int xc_cpupool_create (xc_interface *xch,uint32_t *ppoolid,uint32_t sched_id) {
@@ -32,14 +32,14 @@ int xc_cpupool_create(int xc_handle, sysctl.u.cpupool_op.cpupool_id = (*ppoolid ==0 ) ?XEN_SYSCTL_CPUPOOL_PAR_ANY : *ppoolid; sysctl.u.cpupool_op.sched_id = sched_id; -if ( (err =do_sysctl_save (xc_handle, &sysctl)) !=0 ) +if ( (err =do_sysctl_save (xch, &sysctl)) !=0 )return err; *ppoolid = sysctl.u.cpupool_op.cpupool_id;return 0 ; } -int xc_cpupool_destroy (int xc_handle, +int xc_cpupool_destroy (xc_interface *xch,uint32_t poolid) {DECLARE_SYSCTL ;
@@ -47,10 +47,10 @@ int xc_cpupool_destroy(int xc_handle, sysctl.cmd = XEN_SYSCTL_cpupool_op; sysctl.u.cpupool_op.op =XEN_SYSCTL_CPUPOOL_OP_DESTROY ; sysctl.u.cpupool_op.cpupool_id = poolid; -return do_sysctl_save (xc_handle, &sysctl); +return do_sysctl_save (xch, &sysctl); } -int xc_cpupool_getinfo (int xc_handle, +int xc_cpupool_getinfo (xc_interface *xch,uint32_t first_poolid,uint32_t n_max,xc_cpupoolinfo_t *info)
@@ -76,7 +76,7 @@ int xc_cpupool_getinfo(int xc_handle,PERROR ("Could not lock memory for Xen hypercall" );break ; } - err =do_sysctl_save (xc_handle, &sysctl); + err =do_sysctl_save (xch, &sysctl);unlock_pages (local,sizeof (local));if ( err <0 )
@@ -96,7 +96,7 @@ int xc_cpupool_getinfo(int xc_handle,return p; } -int xc_cpupool_addcpu (int xc_handle, +int xc_cpupool_addcpu (xc_interface *xch,uint32_t poolid,int cpu) {
@@ -106,10 +106,10 @@ int xc_cpupool_addcpu(int xc_handle, sysctl.u.cpupool_op.op =XEN_SYSCTL_CPUPOOL_OP_ADDCPU ; sysctl.u.cpupool_op.cpupool_id = poolid; sysctl.u.cpupool_op.cpu = (cpu <0 ) ?XEN_SYSCTL_CPUPOOL_PAR_ANY : cpu; -return do_sysctl_save (xc_handle, &sysctl); +return do_sysctl_save (xch, &sysctl); } -int xc_cpupool_removecpu (int xc_handle, +int xc_cpupool_removecpu (xc_interface *xch,uint32_t poolid,int cpu) {
@@ -119,10 +119,10 @@ int xc_cpupool_removecpu(int xc_handle, sysctl.u.cpupool_op.op =XEN_SYSCTL_CPUPOOL_OP_RMCPU ; sysctl.u.cpupool_op.cpupool_id = poolid; sysctl.u.cpupool_op.cpu = (cpu <0 ) ?XEN_SYSCTL_CPUPOOL_PAR_ANY : cpu; -return do_sysctl_save (xc_handle, &sysctl); +return do_sysctl_save (xch, &sysctl); } -int xc_cpupool_movedomain (int xc_handle, +int xc_cpupool_movedomain (xc_interface *xch,uint32_t poolid,uint32_t domid) {
@@ -132,10 +132,10 @@ int xc_cpupool_movedomain(int xc_handle, sysctl.u.cpupool_op.op =XEN_SYSCTL_CPUPOOL_OP_MOVEDOMAIN ; sysctl.u.cpupool_op.cpupool_id = poolid; sysctl.u.cpupool_op.domid = domid; -return do_sysctl_save (xc_handle, &sysctl); +return do_sysctl_save (xch, &sysctl); } -int xc_cpupool_freeinfo (int xc_handle, +int xc_cpupool_freeinfo (xc_interface *xch,uint64_t *cpumap) {int err;
@@ -153,7 +153,7 @@ int xc_cpupool_freeinfo(int xc_handle,return err; } - err =do_sysctl_save (xc_handle, &sysctl); + err =do_sysctl_save (xch, &sysctl);unlock_pages (local,sizeof (local));if (err <0 )
tools/libxc/xc_csched.c +4 -4
@@ -13,7 +13,7 @@int xc_sched_credit_domain_set ( -int xc_handle, +xc_interface *xch,uint32_t domid,struct xen_domctl_sched_credit *sdom) {
@@ -25,12 +25,12 @@ xc_sched_credit_domain_set( domctl.u.scheduler_op.cmd = XEN_DOMCTL_SCHEDOP_putinfo; domctl.u.scheduler_op.u.credit = *sdom; -return do_domctl (xc_handle, &domctl); +return do_domctl (xch, &domctl); }int xc_sched_credit_domain_get ( -int xc_handle, +xc_interface *xch,uint32_t domid,struct xen_domctl_sched_credit *sdom) {
@@ -42,7 +42,7 @@ xc_sched_credit_domain_get( domctl.u.scheduler_op.sched_id =XEN_SCHEDULER_CREDIT ; domctl.u.scheduler_op.cmd = XEN_DOMCTL_SCHEDOP_getinfo; - err =do_domctl (xc_handle, &domctl); + err =do_domctl (xch, &domctl);if ( err ==0 ) *sdom = domctl.u.scheduler_op.u.credit;
tools/libxc/xc_csched2.c +4 -4
@@ -13,7 +13,7 @@int xc_sched_credit2_domain_set ( -int xc_handle, +xc_interface *xch,uint32_t domid,struct xen_domctl_sched_credit2 *sdom) {
@@ -25,12 +25,12 @@ xc_sched_credit2_domain_set( domctl.u.scheduler_op.cmd = XEN_DOMCTL_SCHEDOP_putinfo; domctl.u.scheduler_op.u.credit2 = *sdom; -return do_domctl (xc_handle, &domctl); +return do_domctl (xch, &domctl); }int xc_sched_credit2_domain_get ( -int xc_handle, +xc_interface *xch,uint32_t domid,struct xen_domctl_sched_credit2 *sdom) {
@@ -42,7 +42,7 @@ xc_sched_credit2_domain_get( domctl.u.scheduler_op.sched_id =XEN_SCHEDULER_CREDIT2 ; domctl.u.scheduler_op.cmd = XEN_DOMCTL_SCHEDOP_getinfo; - err =do_domctl (xc_handle, &domctl); + err =do_domctl (xch, &domctl);if ( err ==0 ) *sdom = domctl.u.scheduler_op.u.credit2;
tools/libxc/xc_dom.h +19 -13
@@ -93,7 +93,7 @@ struct xc_dom_image {unsigned int xenstore_evtchn;xen_pfn_t shared_info_mfn; -int guest_xc; +xc_interface *xch;domid_t guest_domid;int8_t vhpt_size_log2;/* for IA64 */ int8_t superpages;
@@ -153,13 +153,16 @@ void xc_dom_register_arch_hooks(struct xc_dom_arch *hooks);/* --- main functions ---------------------------------------------- */ -struct xc_dom_image *xc_dom_allocate (const char *cmdline,const char *features); +struct xc_dom_image *xc_dom_allocate (xc_interface *xch, +const char *cmdline,const char *features);void xc_dom_release_phys (struct xc_dom_image *dom);void xc_dom_release (struct xc_dom_image *dom);int xc_dom_mem_init (struct xc_dom_image *dom,unsigned int mem_mb); -size_t xc_dom_check_gzip (void *blob,size_t ziplen); -int xc_dom_do_gunzip (void *src,size_t srclen,void *dst,size_t dstlen); +size_t xc_dom_check_gzip (xc_interface *xch, +void *blob,size_t ziplen); +int xc_dom_do_gunzip (xc_interface *xch, +void *src,size_t srclen,void *dst,size_t dstlen);int xc_dom_try_gunzip (struct xc_dom_image *dom,void **blob,size_t * size);int xc_dom_kernel_file (struct xc_dom_image *dom,const char *filename);
@@ -170,11 +173,12 @@ int xc_dom_ramdisk_mem(struct xc_dom_image *dom, const void *mem, size_t memsize);int xc_dom_parse_image (struct xc_dom_image *dom); -struct xc_dom_arch *xc_dom_find_arch_hooks (char *guest_type); +struct xc_dom_arch *xc_dom_find_arch_hooks (xc_interface *xch,char *guest_type);int xc_dom_build_image (struct xc_dom_image *dom);int xc_dom_update_guest_p2m (struct xc_dom_image *dom); -int xc_dom_boot_xen_init (struct xc_dom_image *dom,int xc,domid_t domid); +int xc_dom_boot_xen_init (struct xc_dom_image *dom,xc_interface *xch, +domid_t domid);int xc_dom_boot_mem_init (struct xc_dom_image *dom);void *xc_dom_boot_domU_map (struct xc_dom_image *dom,xen_pfn_t pfn,xen_pfn_t count);
@@ -183,15 +187,17 @@ int xc_dom_compat_check(struct xc_dom_image *dom);/* --- debugging bits ---------------------------------------------- */ -extern FILE *xc_dom_logfile; +int xc_dom_loginit (xc_interface *xch); -void xc_dom_loginit (void ); -int xc_dom_printf (const char *fmt, ...) __attribute__ ((format (printf,1 ,2 ))); -int xc_dom_panic_func (const char *file,int line,xc_error_code err, +void xc_dom_printf (xc_interface *xch,const char *fmt, ...) + __attribute__ ((format (printf,2 ,3 ))); +void xc_dom_panic_func (xc_interface *xch, +const char *file,int line,xc_error_code err,const char *fmt, ...) - __attribute__ ((format (printf,4 ,5 ))); -#define xc_dom_panic(err, fmt, args...) \ - xc_dom_panic_func(__FILE__, __LINE__, err, fmt, ## args) + __attribute__ ((format (printf,5 ,6 ))); + +#define xc_dom_panic(xch, err, fmt, args...) \ + xc_dom_panic_func(xch, __FILE__, __LINE__, err, fmt, ## args)#define xc_dom_trace (mark) \ xc_dom_printf("%s:%d: trace %s\n", __FILE__, __LINE__, mark)
tools/libxc/xc_dom_binloader.c +21 -21
86 lines not on this page · raw message
tools/libxc/xc_dom_boot.c +41 -40
188 lines not on this page · raw message
tools/libxc/xc_dom_bzimageloader.c +34 -35
193 lines not on this page · raw message
tools/libxc/xc_dom_compat_linux.c +16 -15
@@ -22,7 +22,7 @@/* ------------------------------------------------------------------------ */ static int xc_linux_build_internal(struct xc_dom_image *dom, - int xc_handle, uint32_t domid, + xc_interface *xch, uint32_t domid, unsigned int mem_mb, unsigned long flags, unsigned int store_evtchn,
@@ -36,7 +36,7 @@ static int xc_linux_build_internal(struct xc_dom_image *dom, dom->console_evtchn = console_evtchn; dom->xenstore_evtchn = store_evtchn; -if ( (rc =xc_dom_boot_xen_init (dom, xc_handle, domid)) !=0 ) +if ( (rc =xc_dom_boot_xen_init (dom, xch, domid)) !=0 ) goto out;if ( (rc =xc_dom_parse_image (dom)) !=0 ) goto out;
@@ -56,7 +56,7 @@ static int xc_linux_build_internal(struct xc_dom_image *dom,return rc; } -int xc_linux_build_mem(int xc_handle, uint32_t domid, +int xc_linux_build_mem(xc_interface *xch, uint32_t domid, unsigned int mem_mb, const char *image_buffer, unsigned long image_size,
@@ -73,14 +73,14 @@ int xc_linux_build_mem(int xc_handle, uint32_t domid,struct xc_dom_image *dom;int rc; -xc_dom_loginit (); - dom =xc_dom_allocate (cmdline, features); +xc_dom_loginit (xch); + dom =xc_dom_allocate (xch, cmdline, features);if ( (rc =xc_dom_kernel_mem (dom, image_buffer, image_size)) !=0 ) goto out;if ( initrd && ((rc =xc_dom_ramdisk_mem (dom, initrd, initrd_len)) !=0 ) ) goto out; - rc =xc_linux_build_internal (dom, xc_handle, domid, + rc =xc_linux_build_internal (dom, xch, domid, mem_mb, flags, store_evtchn, store_mfn, console_evtchn, console_mfn);
@@ -90,7 +90,7 @@ int xc_linux_build_mem(int xc_handle, uint32_t domid,return rc; } -int xc_linux_build(int xc_handle, uint32_t domid, +int xc_linux_build(xc_interface *xch, uint32_t domid, unsigned int mem_mb, const char *image_name, const char *initrd_name,
@@ -105,15 +105,15 @@ int xc_linux_build(int xc_handle, uint32_t domid,struct xc_dom_image *dom;int rc; -xc_dom_loginit (); - dom =xc_dom_allocate (cmdline, features); +xc_dom_loginit (xch); + dom =xc_dom_allocate (xch, cmdline, features);if ( (rc =xc_dom_kernel_file (dom, image_name)) !=0 ) goto out;if ( initrd_name &&strlen (initrd_name) && ((rc =xc_dom_ramdisk_file (dom, initrd_name)) !=0 ) ) goto out; - rc =xc_linux_build_internal (dom, xc_handle, domid, + rc =xc_linux_build_internal (dom, xch, domid, mem_mb, flags, store_evtchn, store_mfn, console_evtchn, console_mfn);
@@ -122,13 +122,14 @@ int xc_linux_build(int xc_handle, uint32_t domid,xc_dom_release (dom);return rc; } -int xc_get_bit_size (const char *image_name,const char *cmdline, -const char *features,int *bit_size) +int xc_get_bit_size (xc_interface *xch, +const char *image_name,const char *cmdline, +const char *features,int *bit_size) {struct xc_dom_image *dom;int rc; *bit_size =0 ; - dom =xc_dom_allocate (cmdline, features); + dom =xc_dom_allocate (xch, cmdline, features);if ( (rc =xc_dom_kernel_file (dom, image_name)) !=0 ) goto out;if ( (rc =xc_dom_parse_image (dom)) !=0 )
@@ -145,7 +146,7 @@ out:return rc; } -int xc_dom_linux_build(int xc_handle, +int xc_dom_linux_build(xc_interface *xch, struct xc_dom_image *dom, uint32_t domid, unsigned int mem_mb,
@@ -164,7 +165,7 @@ int xc_dom_linux_build(int xc_handle, ((rc = xc_dom_ramdisk_file(dom, initrd_name)) != 0) )return rc; -return xc_linux_build_internal (dom, xc_handle, domid, +return xc_linux_build_internal (dom, xch, domid, mem_mb, flags, store_evtchn, store_mfn, console_evtchn, console_mfn);
tools/libxc/xc_dom_core.c +133 -120
190 lines not on this page · raw message
tools/libxc/xc_dom_elfloader.c +34 -27
61 lines not on this page · raw message
tools/libxc/xc_dom_x86.c +62 -63
125 lines not on this page · raw message
tools/libxc/xc_domain.c +111 -111
222 lines not on this page · raw message
tools/libxc/xc_domain_restore.c +97 -95
192 lines not on this page · raw message
tools/libxc/xc_domain_save.c +98 -97
195 lines not on this page · raw message
tools/libxc/xc_hvm_build.c +32 -31
63 lines not on this page · raw message
tools/libxc/xc_linux.c +66 -58
124 lines not on this page · raw message
tools/libxc/xc_misc.c +36 -36
72 lines not on this page · raw message
tools/libxc/xc_offline_page.c +57 -54
111 lines not on this page · raw message
tools/libxc/xc_pm.c +44 -44
88 lines not on this page · raw message
tools/libxc/xc_private.c +142 -99
241 lines not on this page · raw message
tools/libxc/xc_private.h +49 -39
88 lines not on this page · raw message
tools/libxc/xc_ptrace.c +42 -41
83 lines not on this page · raw message
tools/libxc/xc_resume.c +27 -27
54 lines not on this page · raw message
tools/libxc/xc_solaris.c +21 -21
42 lines not on this page · raw message
tools/libxc/xc_tmem.c +36 -35
71 lines not on this page · raw message
tools/libxc/xenctrl.h +287 -238
525 lines not on this page · raw message
tools/libxc/xenguest.h +24 -23
47 lines not on this page · raw message
tools/misc/xenpm.c +61 -61
122 lines not on this page · raw message
tools/python/xen/lowlevel/checkpoint/checkpoint.h +1 -1
Lines of this file are not shown. View the raw message.
tools/python/xen/lowlevel/checkpoint/libcheckpoint.c +6 -6
Lines of this file are not shown. View the raw message.
tools/python/xen/lowlevel/flask/flask.c +19 -25
44 lines not on this page · raw message
tools/python/xen/lowlevel/xc/xc.c +100 -96
196 lines not on this page · raw message
tools/xenpaging/xenpaging.c +24 -20
44 lines not on this page · raw message
tools/xenstat/libxenstat/src/xenstat_priv.h +1 -1
Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Signature · 1 line
1.5.6.5
Part of the diff is not shown here. View the raw message.
PATCH 8/14 libxc: Use new DBGPRINTF for a few debugging output messages
oubuf and batch restore write messages should be sent with level XTL_DEBUG so that they don't disturb progress output even with -v.
--- tools/libxc/xc_domain_restore.c | 2 +- tools/libxc/xc_domain_save.c | 2 +- tools/libxc/xc_private.h | 1 + 3 files changed, 3 insertions(+), 2 deletions(-)
tools/libxc/xc_domain_restore.c +1 -1
@@ -1498,7 +1498,7 @@ int xc_domain_restore(xc_interface *xch, int io_fd, uint32_t dom, } j = pagebuf.nr_pages; -DPRINTF ("batch %d\n" ,j); +DBGPRINTF ("batch %d\n" ,j);if ( j ==0 ) {/* catch vcpu updates */
tools/libxc/xc_domain_save.c +1 -1
@@ -172,7 +172,7 @@ static inline int outbuf_write(xc_interface *xch, struct outbuf* ob, void* buf, size_t len) { if ( len > ob->size - ob->pos ) { - DPRINTF("outbuf_write: %zu > %zu@%zu\n", len, ob->size - ob->pos, ob->pos); + DBGPRINTF("outbuf_write: %zu > %zu@%zu\n", len, ob->size - ob->pos, ob->pos);return -1 ; }
tools/libxc/xc_private.h +1 -0
@@ -77,6 +77,7 @@ void xc_report_progress_step(xc_interface *xch, #define IPRINTF(_f, _a...) xc_report(xch, xch->error_handler, XTL_INFO,0, _f , ## _a) #define DPRINTF(_f, _a...) xc_report(xch, xch->error_handler, XTL_DETAIL,0, _f , ## _a) +#define DBGPRINTF(_f, _a...) xc_report(xch, xch->error_handler, XTL_DEBUG,0, _f , ## _a) #define ERROR(_m, _a...) xc_report_error(xch,XC_INTERNAL_ERROR,_m , ## _a ) #define PERROR(_m, _a...) xc_report_error(xch,XC_INTERNAL_ERROR,_m \
Signature · 1 line
1.5.6.5
PATCH 9/14 libxl: Fix up some incorrect printf formats
We need to use PRIu32 for domids, and also to pass arguments in the right order.
--- tools/libxl/libxl.c | 4 ++-- tools/libxl/libxl_dom.c | 2 +- tools/libxl/libxl_xshelp.c | 3 ++- 3 files changed, 5 insertions(+), 4 deletions(-)
tools/libxl/libxl.c +2 -2
@@ -230,7 +230,7 @@ int libxl_domain_rename(struct libxl_ctx *ctx, uint32_t domid, new_name, strlen(new_name))) {XL_LOG (ctx,XL_LOG_ERROR ,"failed to write new name `%s'" " for domain %" PRIu32" previously named `%s'" , - domid, new_name, old_name); + new_name, domid, old_name); goto x_fail; }
@@ -240,7 +240,7 @@ int libxl_domain_rename(struct libxl_ctx *ctx, uint32_t domid,if (errno !=EAGAIN ) {XL_LOG (ctx,XL_LOG_ERROR ,"failed to commit new name `%s'" " for domain %" PRIu32" previously named `%s'" , - domid, new_name, old_name); + new_name, domid, old_name); goto x_fail; } XL_LOG(ctx, XL_LOG_DEBUG, "need to retry rename transaction"
tools/libxl/libxl_dom.c +1 -1
@@ -386,7 +386,7 @@ static const char *userdata_path(struct libxl_ctx *ctx, uint32_t domid, rc =libxl_domain_info (ctx, &info, domid);if (rc) {XL_LOG_ERRNO (ctx,XL_LOG_ERROR ,"unable to find domain info" -" for domain %l" PRIu32, domid); +" for domain %" PRIu32, domid);return 0 ; } uuid_string =string_of_uuid (ctx, info.uuid);
tools/libxl/libxl_xshelp.c +2 -1
@@ -19,6 +19,7 @@#include <stddef.h> #include <stdio.h> #include <stdarg.h> +#include <inttypes.h> #include "libxl.h" #include "libxl_internal.h"
@@ -119,7 +120,7 @@ char *libxl_xs_get_dompath(struct libxl_ctx *ctx, uint32_t domid) {char *s =xs_get_domain_path (ctx->xsh, domid);if (!s) { -XL_LOG_ERRNO (ctx,XL_LOG_ERROR ,"failed to get dompath for %lu" , +XL_LOG_ERRNO (ctx,XL_LOG_ERROR ,"failed to get dompath for %" PRIu32, domid);return NULL ; }
Signature · 1 line
1.5.6.5
PATCH 10/14 libxl: Use the caller's logger (xentoollog)
We now require callers to provide a xentoollog_logger* for libxl_ctx_init, and use that for all our own logging and also for xc_interface_open.
Corresponding change to xl.c.
--- tools/libxl/libxl.c | 12 ++-------- tools/libxl/libxl.h | 10 ++------ tools/libxl/libxl_device.c | 4 +- tools/libxl/libxl_exec.c | 3 +- tools/libxl/libxl_internal.c | 46 +++++++++++++++++------------------------ tools/libxl/libxl_internal.h | 22 +++++++++++++++++-- tools/libxl/libxl_utils.h | 8 +------ tools/libxl/xl.c | 18 ++------------- tools/libxl/xl.h | 4 ++- tools/libxl/xl_cmdimpl.c | 4 +- 10 files changed, 57 insertions(+), 74 deletions(-)
tools/libxl/libxl.c +3 -9
@@ -36,18 +36,19 @@#define PAGE_TO_MEMKB (pages) ((pages) * 4) -int libxl_ctx_init (struct libxl_ctx *ctx,int version) +int libxl_ctx_init (struct libxl_ctx *ctx,int version,xentoollog_logger *lg) {if (version !=LIBXL_VERSION )return ERROR_VERSION ;memset (ctx,0 ,sizeof (struct libxl_ctx )); + ctx->lg = lg; ctx->alloc_maxsize =256 ; ctx->alloc_ptrs =calloc (ctx->alloc_maxsize,sizeof (void *));if (!ctx->alloc_ptrs)return ERROR_NOMEM ;memset (&ctx->version_info,0 ,sizeof (libxl_version_info)); - ctx->xch =xc_interface_open (0 ,0 ,0 ); + ctx->xch =xc_interface_open (lg,lg,0 );if (!ctx->xch) {free (ctx->alloc_ptrs);return ERROR_FAIL ;
@@ -71,13 +72,6 @@ int libxl_ctx_free(struct libxl_ctx *ctx)return 0 ; } -int libxl_ctx_set_log (struct libxl_ctx *ctx,libxl_log_callback log_callback,void *log_data) -{ - ctx->log_callback = log_callback; - ctx->log_userdata = log_data; -return 0 ; -} -/******************************************************************************/ int libxl_domain_make(struct libxl_ctx *ctx, libxl_domain_create_info *info,
tools/libxl/libxl.h +3 -7
@@ -22,8 +22,6 @@#include <xs.h> #include <sys/wait.h> /* for pid_t */ -typedef void (*libxl_log_callback )(void *userdata,int loglevel,const char *file, -int line,const char *func,char *s);struct libxl_dominfo {uint8_t uuid[16 ];uint32_t domid;
@@ -61,11 +59,9 @@ typedef struct { } libxl_version_info;struct libxl_ctx { +xentoollog_logger *lg;xc_interface *xch;struct xs_handle *xsh; -/* errors/debug buf */ -void *log_userdata; -libxl_log_callback log_callback;/* mini-GC */ int alloc_maxsize;
@@ -275,9 +271,9 @@ enum {#define LIBXL_VERSION 0/* context functions */ -int libxl_ctx_init (struct libxl_ctx *ctx,int version); +int libxl_ctx_init (struct libxl_ctx *ctx,int version,xentoollog_logger *);int libxl_ctx_free (struct libxl_ctx *ctx); -int libxl_ctx_set_log (struct libxl_ctx *ctx,libxl_log_callback log_callback,void *log_data); +int libxl_ctx_set_log (struct libxl_ctx *ctx,xentoollog_logger *);int libxl_ctx_postfork (struct libxl_ctx *ctx);/* domain related functions */
tools/libxl/libxl_device.c +2 -2
@@ -291,7 +291,7 @@ int libxl_devices_destroy(struct libxl_ctx *ctx, uint32_t domid, int force)flexarray_t *toremove;struct libxl_ctx clone; -if (libxl_ctx_init (&clone,LIBXL_VERSION )) { +if (libxl_ctx_init (&clone,LIBXL_VERSION , ctx->lg)) {return -1 ; }
@@ -354,7 +354,7 @@ int libxl_device_del(struct libxl_ctx *ctx, libxl_device *dev, int wait)int rc;struct libxl_ctx clone; -if (libxl_ctx_init (&clone,LIBXL_VERSION )) { +if (libxl_ctx_init (&clone,LIBXL_VERSION , ctx->lg)) {return -1 ; }
tools/libxl/libxl_exec.c +2 -1
@@ -57,7 +57,8 @@ void libxl_exec(int stdinfd, int stdoutfd, int stderrfd, char *arg0, char **args_exit (-1 ); } -void libxl_report_child_exitstatus (struct libxl_ctx *ctx,int level, +void libxl_report_child_exitstatus (struct libxl_ctx *ctx, +xentoollog_level level,const char *what,pid_t pid,int status) {
tools/libxl/libxl_internal.c +19 -27
67 lines not on this page · raw message
tools/libxl/libxl_internal.h +19 -3
@@ -23,6 +23,7 @@#include <xs.h> #include <xenctrl.h> +#include "xentoollog.h" #include "flexarray.h" #include "libxl_utils.h"
@@ -50,9 +51,19 @@/* all of these macros preserve errno (saving and restoring) */ /* logging */ -void xl_logv (struct libxl_ctx *ctx,int errnoval,int loglevel,const char *file,int line,const char *func,char *fmt,va_list al); -void xl_log (struct libxl_ctx *ctx,int errnoval,int loglevel,const char *file,int line,const char *func,char *fmt, ...); -/* these functions preserve errno (saving and restoring) */ +void xl_logv (struct libxl_ctx *ctx,xentoollog_level msglevel,int errnoval, +const char *file/* may be 0 */ ,int line/* ignored if !file */ , +const char *func/* may be 0 */ , +char *fmt,va_list al) + __attribute__((format (printf,7 ,0 ))); + +void xl_log (struct libxl_ctx *ctx,xentoollog_level msglevel,int errnoval, +const char *file/* may be 0 */ ,int line/* ignored if !file */ , +const char *func/* may be 0 */ , +char *fmt, ...) + __attribute__((format (printf,7 ,8 ))); + +/* these functions preserve errno (saving and restoring) */ typedef enum {
@@ -215,5 +226,10 @@ const char *libxl_xenfirmwaredir_path(void);const char *libxl_xen_config_dir_path (void );const char *libxl_xen_script_dir_path (void ); +#define XL_LOG_DEBUG XTL_DEBUG +#define XL_LOG_INFO XTL_INFO +#define XL_LOG_WARNING XTL_WARN +#define XL_LOG_ERROR XTL_ERROR +#endif
tools/libxl/libxl_utils.h +1 -7
@@ -50,12 +50,11 @@ pid_t libxl_fork(struct libxl_ctx *ctx);int libxl_pipe (struct libxl_ctx *ctx,int pipes[2 ]);/* Just like fork(2), pipe(2), but log errors. */ -void libxl_report_child_exitstatus (struct libxl_ctx *ctx,int level, +void libxl_report_child_exitstatus (struct libxl_ctx *ctx,xentoollog_level ,const char *what,pid_t pid,int status);/* treats all exit statuses as errors; if that's not what you want, * check status yourself first */ -int libxl_mac_to_device_nic (struct libxl_ctx *ctx,uint32_t domid,const char *mac,libxl_device_nic *nic); int libxl_devid_to_device_nic(struct libxl_ctx *ctx, uint32_t domid,
@@ -64,11 +63,6 @@ int libxl_devid_to_device_nic(struct libxl_ctx *ctx, uint32_t domid,int libxl_devid_to_device_disk (struct libxl_ctx *ctx,uint32_t domid,const char *devid,libxl_device_disk *disk); -/* log levels: */ -#define XL_LOG_DEBUG 3 -#define XL_LOG_INFO 2 -#define XL_LOG_WARNING 1 -#define XL_LOG_ERROR 0#endif
tools/libxl/xl.c +3 -15
@@ -31,16 +31,7 @@#include "libxl_utils.h" #include "xl.h" -void log_callback ( -void *userdata,int loglevel,const char *file, -int line,const char *func,char *s) -{ -char str[1024 ]; - -snprintf (str,sizeof (str),"[%d] %s:%d:%s: %s\n" , - loglevel, file, line, func, s); -libxl_write_exactly (NULL , logfile, str,strlen (str),NULL ,NULL ); -} +xentoollog_logger *logger;int main (int argc,char **argv) {
@@ -51,14 +42,11 @@ int main(int argc, char **argv)exit (1 ); } -if (libxl_ctx_init (&ctx,LIBXL_VERSION )) { + logger =xtl_createlogger_stdiostream (stderr,XTL_PROGRESS ,0 ); +if (libxl_ctx_init (&ctx,LIBXL_VERSION , logger)) {fprintf (stderr,"cannot init xl context\n" );exit (1 ); } -if (libxl_ctx_set_log (&ctx, log_callback,NULL )) { -fprintf (stderr,"cannot set xl log callback\n" ); -exit (-ERROR_FAIL ); - }srand (time (0 ));
tools/libxl/xl.h +3 -1
@@ -15,6 +15,8 @@ #ifndef XL_H #define XL_H +#include "xentoollog.h" + struct cmd_spec { char *cmd_name; int (*cmd_impl)(int argc, char **argv);
@@ -75,6 +77,6 @@ extern struct cmd_spec cmd_table[];extern int cmdtable_len;extern struct libxl_ctx ctx; -extern int logfile; +extern xentoollog_logger *logger;#endif /* XL_H */
tools/libxl/xl_cmdimpl.c +2 -2
@@ -1088,7 +1088,7 @@ start: } }if (status) { -libxl_report_child_exitstatus (&ctx,XL_LOG_ERROR , +libxl_report_child_exitstatus (&ctx,XTL_ERROR ,"daemonizing child" , child1, status); ret =ERROR_FAIL ; goto error_out;
@@ -1804,7 +1804,7 @@ static void migration_child_report(pid_t migration_child, int recv_fd) {if (child == migration_child) {if (status) -libxl_report_child_exitstatus (&ctx,XL_LOG_INFO , +libxl_report_child_exitstatus (&ctx,XTL_INFO ,"migration target process" , migration_child, status);break ;
Signature · 1 line
1.5.6.5
PATCH 11/14 xl: Allow control of logging level.
The -v option, which must come before the xl command, increases the logging level each time it is supplied.
--- tools/libxc/xtl_logger_stdio.c | 5 ++++- tools/libxl/xl.c | 40 ++++++++++++++++++++++++++++------------ tools/libxl/xl.h | 2 +- 3 files changed, 33 insertions(+), 14 deletions(-)
tools/libxc/xtl_logger_stdio.c +4 -1
@@ -36,6 +36,9 @@ static void stdiostream_vmessage(xentoollog_logger *logger_in, va_list al) {xentoollog_logger_stdiostream *lg = (void *)logger_in; +if (level < lg->min_level) +return ; +progress_erase (lg);if (lg->flags &XTL_STDIOSTREAM_SHOW_DATE ) {
@@ -82,7 +85,7 @@ static void stdiostream_progress(struct xentoollog_logger *logger_in, this_level =XTL_PROGRESS ; } -if (lg->min_level < this_level) +if (this_level < lg->min_level)return ;if (lg->progress_erase_len)
tools/libxl/xl.c +28 -12
@@ -31,19 +31,38 @@#include "libxl_utils.h" #include "xl.h" -xentoollog_logger *logger; +xentoollog_logger_stdiostream *logger; + +static xentoollog_level minmsglevel =XTL_PROGRESS ;int main (int argc,char **argv) { -int i; +int opt =0 , i; +char *cmd =0 ; + +while ((opt =getopt (argc, argv,"+v" )) >=0 ) { +switch (opt) { +case 'v' : +if (minmsglevel >0 ) minmsglevel--; +break ; +default : +fprintf (stderr,"unknown global option\n" ); +exit (2 ); + } + } + + cmd = argv[optind++]; -if (argc <2 ) { +if (!cmd) {help (NULL );exit (1 ); } + opterr =0 ; + + logger =xtl_createlogger_stdiostream (stderr, minmsglevel,0 ); +if (!logger)exit (1 ); - logger =xtl_createlogger_stdiostream (stderr,XTL_PROGRESS ,0 ); -if (libxl_ctx_init (&ctx,LIBXL_VERSION , logger)) { +if (libxl_ctx_init (&ctx,LIBXL_VERSION , (xentoollog_logger *)logger)) {fprintf (stderr,"cannot init xl context\n" );exit (1 ); }
@@ -51,16 +70,13 @@ int main(int argc, char **argv)srand (time (0 ));for (i =0 ; i < cmdtable_len; i++) { -if (!strcmp (argv[1 ], cmd_table[i].cmd_name)) - cmd_table[i].cmd_impl (argc -1 , argv +1 ); +if (!strcmp (cmd, cmd_table[i].cmd_name)) + cmd_table[i].cmd_impl (argc, argv); }if (i >= cmdtable_len) { -if (!strcmp (argv[1 ],"help" )) { -if (argc >2 ) -help (argv[2 ]); -else -help (NULL ); +if (!strcmp (cmd,"help" )) { +help (argv[1 ]);exit (0 ); }else {fprintf (stderr,"command not implemented\n" );
tools/libxl/xl.h +1 -1
@@ -77,6 +77,6 @@ extern struct cmd_spec cmd_table[];extern int cmdtable_len;extern struct libxl_ctx ctx; -extern xentoollog_logger *logger; +extern xentoollog_logger_stdiostream *logger;#endif /* XL_H */
Signature · 1 line
1.5.6.5
PATCH 12/14 libxc: save/restore error handling fixes
* Make "read_exact" in libxc always set errno.
* Rename "read_exact" macro in xc_domain_restore.c (which shadows real function) to RDEXACT and change all callers.
* Make RDEXACT anamorphically use xch for error reporting rather than stderr.
* Call PERROR rather than ERROR when appropriate, so that log messages include errno.
* Save errno in noncached_write so that its errno value is always right.
xc fix a newline in PERROR
--- tools/libxc/xc_domain_restore.c | 171 ++++++++++++++++++++------------------- tools/libxc/xc_domain_save.c | 64 ++++++++------- tools/libxc/xc_private.c | 2 + tools/libxc/xc_private.h | 4 +- 4 files changed, 125 insertions(+), 116 deletions(-)
tools/libxc/xc_domain_restore.c +88 -83
@@ -124,7 +124,7 @@ static int break_super_page(xc_interface *xch,if ( ram_base ==NULL ) { -ERROR ("map batch failed\n" ); +PERROR ("map batch failed\n" ); rc =1 ; goto out; }
@@ -136,7 +136,7 @@ static int break_super_page(xc_interface *xch,if (xc_domain_memory_decrease_reservation (xch, dom,1 ,SUPERPAGE_PFN_SHIFT , &start_pfn) !=0 ) { -ERROR ("free 2M page failure @ 0x%ld.\n" , next_pfn); +PERROR ("free 2M page failure @ 0x%ld.\n" , next_pfn); rc =1 ; goto out; }
@@ -153,7 +153,7 @@ static int break_super_page(xc_interface *xch,if (xc_domain_memory_populate_physmap (xch, dom,1 ,0 ,0 , &mfn) !=0 ) { -ERROR ("Failed to allocate physical memory.!\n" ); +PERROR ("Failed to allocate physical memory.!\n" ); errno =ENOMEM ; rc =1 ; goto out;
@@ -171,7 +171,7 @@ static int break_super_page(xc_interface *xch, page_array, tot_pfns);if ( ram_base ==NULL ) { -ERROR ("map batch failed\n" ); +PERROR ("map batch failed\n" ); rc =1 ; goto out; }
@@ -283,7 +283,7 @@ normal_page:if (xc_domain_memory_populate_physmap (xch, dom,1 ,0 ,0 , &mfn) !=0 ) { -ERROR ("Failed to allocate physical memory.! pfn=0x%lx, mfn=0x%lx.\n" , +PERROR ("Failed to allocate physical memory.! pfn=0x%lx, mfn=0x%lx.\n" , pfn, mfn); errno =ENOMEM ;return 1 ;
@@ -448,7 +448,7 @@ static int completed = 0;#define HEARTBEAT_MS 1000#ifndef __MINIOS__ -static ssize_t read_exact_timed (int fd,void * buf,size_t size) +static ssize_t rdexact (struct xc_interface *xch,int fd,void * buf,size_t size) {size_t offset =0 ;ssize_t len;
@@ -465,8 +465,11 @@ static ssize_t read_exact_timed(int fd, void* buf, size_t size)FD_ZERO (&rfds);FD_SET (fd, &rfds); len =select (fd +1 , &rfds,NULL ,NULL , &tv); +if ( len ==-1 && errno ==EINTR ) +continue ;if ( !FD_ISSET (fd, &rfds) ) { -fprintf (stderr,"read_exact_timed failed (select returned %zd)\n" , len); +ERROR ("read_exact_timed failed (select returned %zd)" , len); + errno =ETIMEDOUT ;return -1 ; } }
@@ -474,6 +477,8 @@ static ssize_t read_exact_timed(int fd, void* buf, size_t size) len =read (fd, buf + offset, size - offset);if ( (len ==-1 ) && ((errno ==EINTR ) || (errno ==EAGAIN )) )continue ; +if ( len ==0 ) + errno =0 ;if ( len <=0 )return -1 ; offset += len;
@@ -482,10 +487,9 @@ static ssize_t read_exact_timed(int fd, void* buf, size_t size) return 0; } -#define read_exact read_exact_timed - +#define RDEXACT (fd,buf,size) rdexact(xch, fd, buf, size)#else -#define read_exact_timed read_exact +#define RDEXACT read_exact#endif /* ** In the state file (or during transfer), all page-table pages are
@@ -549,9 +553,9 @@ static xen_pfn_t *load_p2m_frame_list(struct domain_info_context *dinfo = &ctx->dinfo;/* Read first entry of P2M list, or extended-info signature (~0UL). */ -if (read_exact (io_fd, &p2m_fl_zero,sizeof (long )) ) +if (RDEXACT (io_fd, &p2m_fl_zero,sizeof (long )) ) { -ERROR ("read extended-info signature failed" ); +PERROR ("read extended-info signature failed" );return NULL ; }
@@ -560,9 +564,9 @@ static xen_pfn_t *load_p2m_frame_list(uint32_t tot_bytes;/* Next 4 bytes: total size of following extended info. */ -if (read_exact (io_fd, &tot_bytes,sizeof (tot_bytes)) ) +if (RDEXACT (io_fd, &tot_bytes,sizeof (tot_bytes)) ) { -ERROR ("read extended-info size failed" ); +PERROR ("read extended-info size failed" );return NULL ; }
@@ -572,11 +576,11 @@ static xen_pfn_t *load_p2m_frame_list(char chunk_sig[4 ];/* 4-character chunk signature + 4-byte remaining chunk size. */ -if (read_exact (io_fd, chunk_sig,sizeof (chunk_sig)) || -read_exact (io_fd, &chunk_bytes,sizeof (chunk_bytes)) || +if (RDEXACT (io_fd, chunk_sig,sizeof (chunk_sig)) || +RDEXACT (io_fd, &chunk_bytes,sizeof (chunk_bytes)) || (tot_bytes < (chunk_bytes +8 )) ) { -ERROR ("read extended-info chunk signature failed" ); +PERROR ("read extended-info chunk signature failed" );return NULL ; } tot_bytes -=8 ;
@@ -602,9 +606,9 @@ static xen_pfn_t *load_p2m_frame_list(return NULL ; } -if (read_exact (io_fd, &ctxt, chunk_bytes) ) +if (RDEXACT (io_fd, &ctxt, chunk_bytes) ) { -ERROR ("read extended-info vcpu context failed" ); +PERROR ("read extended-info vcpu context failed" );return NULL ; } tot_bytes -= chunk_bytes;
@@ -623,9 +627,9 @@ static xen_pfn_t *load_p2m_frame_list(while ( chunk_bytes ) {unsigned long sz =MIN (chunk_bytes,sizeof (xen_pfn_t)); -if (read_exact (io_fd, &p2m_fl_zero, sz) ) +if (RDEXACT (io_fd, &p2m_fl_zero, sz) ) { -ERROR ("read-and-discard extended-info chunk bytes failed" ); +PERROR ("read-and-discard extended-info chunk bytes failed" );return NULL ; } chunk_bytes -= sz;
@@ -634,9 +638,9 @@ static xen_pfn_t *load_p2m_frame_list( }/* Now read the real first entry of P2M list. */ -if (read_exact (io_fd, &p2m_fl_zero,sizeof (xen_pfn_t)) ) +if (RDEXACT (io_fd, &p2m_fl_zero,sizeof (xen_pfn_t)) ) { -ERROR ("read first entry of p2m_frame_list failed" ); +PERROR ("read first entry of p2m_frame_list failed" );return NULL ; } }
@@ -651,10 +655,10 @@ static xen_pfn_t *load_p2m_frame_list(/* First entry has already been read. */ p2m_frame_list[0 ] = p2m_fl_zero; -if (read_exact (io_fd, &p2m_frame_list[1 ], +if (RDEXACT (io_fd, &p2m_frame_list[1 ], (P2M_FL_ENTRIES -1 ) *sizeof (xen_pfn_t)) ) { -ERROR ("read p2m_frame_list failed" ); +PERROR ("read p2m_frame_list failed" );return NULL ; }
@@ -742,8 +746,8 @@ static int buffer_qemu(xc_interface *xch,uint32_t qlen;uint8_t *tmp; -if (read_exact (fd, &qlen,sizeof (qlen)) ) { -ERROR ("Error reading QEMU header length" ); +if (RDEXACT (fd, &qlen,sizeof (qlen)) ) { +PERROR ("Error reading QEMU header length" );return -1 ; }
@@ -766,8 +770,8 @@ static int buffer_qemu(xc_interface *xch, } buf->qemubufsize = qlen; -if (read_exact (fd, buf->qemubuf, buf->qemubufsize) ) { -ERROR ("Error reading QEMU state" ); +if (RDEXACT (fd, buf->qemubuf, buf->qemubufsize) ) { +PERROR ("Error reading QEMU state" );return -1 ; }
@@ -806,13 +810,13 @@ static int buffer_tail_hvm(xc_interface *xch, struct restore_ctx *ctx,uint8_t *tmp;unsigned char qemusig[21 ]; -if (read_exact (fd, buf->magicpfns,sizeof (buf->magicpfns)) ) { -ERROR ("Error reading magic PFNs" ); +if (RDEXACT (fd, buf->magicpfns,sizeof (buf->magicpfns)) ) { +PERROR ("Error reading magic PFNs" );return -1 ; } -if (read_exact (fd, &buf->reclen,sizeof (buf->reclen)) ) { -ERROR ("Error reading HVM params size" ); +if (RDEXACT (fd, &buf->reclen,sizeof (buf->reclen)) ) { +PERROR ("Error reading HVM params size" );return -1 ; }
@@ -836,13 +840,13 @@ static int buffer_tail_hvm(xc_interface *xch, struct restore_ctx *ctx, } } -if (read_exact (fd, buf->hvmbuf, buf->reclen) ) { -ERROR ("Error reading HVM params" ); +if (RDEXACT (fd, buf->hvmbuf, buf->reclen) ) { +PERROR ("Error reading HVM params" );return -1 ; } -if (read_exact (fd, qemusig,sizeof (qemusig)) ) { -ERROR ("Error reading QEMU signature" ); +if (RDEXACT (fd, qemusig,sizeof (qemusig)) ) { +PERROR ("Error reading QEMU signature" );return -1 ; }
@@ -871,10 +875,10 @@ static int buffer_tail_pv(xc_interface *xch, struct restore_ctx *ctx,/* TODO: handle changing pfntab and vcpu counts */ /* PFN tab */ -if (read_exact (fd, &buf->pfncount,sizeof (buf->pfncount)) || +if (RDEXACT (fd, &buf->pfncount,sizeof (buf->pfncount)) || (buf->pfncount > (1U <<28 )) )/* up to 1TB of address space */ { -ERROR ("Error when reading pfn count" ); +PERROR ("Error when reading pfn count" );return -1 ; } pfnlen =sizeof (unsigned long ) * buf->pfncount;
@@ -885,8 +889,8 @@ static int buffer_tail_pv(xc_interface *xch, struct restore_ctx *ctx, } }// DPRINTF("Reading PFN tab: %d bytes\n", pfnlen); -if (read_exact (fd, buf->pfntab, pfnlen) ) { -ERROR ("Error when reading pfntab" ); +if (RDEXACT (fd, buf->pfntab, pfnlen) ) { +PERROR ("Error when reading pfntab" ); goto free_pfntab; }
@@ -911,15 +915,15 @@ static int buffer_tail_pv(xc_interface *xch, struct restore_ctx *ctx, } }// DPRINTF("Reading VCPUS: %d bytes\n", vcpulen); -if (read_exact (fd, buf->vcpubuf, vcpulen) ) { -ERROR ("Error when reading ctxt" ); +if (RDEXACT (fd, buf->vcpubuf, vcpulen) ) { +PERROR ("Error when reading ctxt" ); goto free_vcpus; }/* load shared_info_page */ // DPRINTF("Reading shared info: %lu bytes\n", PAGE_SIZE); -if (read_exact (fd, buf->shared_info_page,PAGE_SIZE ) ) { -ERROR ("Error when reading shared info page" ); +if (RDEXACT (fd, buf->shared_info_page,PAGE_SIZE ) ) { +PERROR ("Error when reading shared info page" ); goto free_vcpus; }
@@ -1024,9 +1028,9 @@ static int pagebuf_get_one(xc_interface *xch,int count, countpages, oldcount, i;void * ptmp; -if (read_exact (fd, &count,sizeof (count)) ) +if (RDEXACT (fd, &count,sizeof (count)) ) { -ERROR ("Error when reading batch size" ); +PERROR ("Error when reading batch size" );return -1 ; }
@@ -1041,10 +1045,10 @@ static int pagebuf_get_one(xc_interface *xch,return pagebuf_get_one (xch, buf, fd, dom); }else if (count ==-2 ) { buf->new_ctxt_format =1 ; -if (read_exact (fd, &buf->max_vcpu_id,sizeof (buf->max_vcpu_id)) || - buf->max_vcpu_id >=64 ||read_exact (fd, &buf->vcpumap, -sizeof (uint64_t )) ) { -ERROR ("Error when reading max_vcpu_id" ); +if (RDEXACT (fd, &buf->max_vcpu_id,sizeof (buf->max_vcpu_id)) || + buf->max_vcpu_id >=64 ||RDEXACT (fd, &buf->vcpumap, +sizeof (uint64_t )) ) { +PERROR ("Error when reading max_vcpu_id" );return -1 ; }// DPRINTF("Max VCPU ID: %d, vcpumap: %llx\n", buf->max_vcpu_id, buf->vcpumap);
@@ -1054,7 +1058,7 @@ static int pagebuf_get_one(xc_interface *xch,if (read_exact (fd, &buf->identpt,sizeof (uint32_t )) ||read_exact (fd, &buf->identpt,sizeof (uint64_t )) ) { -ERROR ("error read the address of the EPT identity map" ); +PERROR ("error read the address of the EPT identity map" );return -1 ; }// DPRINTF("EPT identity map address: %llx\n", buf->identpt);
@@ -1064,7 +1068,7 @@ static int pagebuf_get_one(xc_interface *xch,if (read_exact (fd, &buf->vm86_tss,sizeof (uint32_t )) ||read_exact (fd, &buf->vm86_tss,sizeof (uint64_t )) ) { -ERROR ("error read the address of the vm86 TSS" ); +PERROR ("error read the address of the vm86 TSS" );return -1 ; }// DPRINTF("VM86 TSS location: %llx\n", buf->vm86_tss);
@@ -1072,14 +1076,14 @@ static int pagebuf_get_one(xc_interface *xch, }else if ( count ==-5 ) {DPRINTF ("xc_domain_restore start tmem\n" );if (xc_tmem_restore (xch, dom, fd) ) { -ERROR ("error reading/restoring tmem" ); +PERROR ("error reading/restoring tmem" );return -1 ; }return pagebuf_get_one (xch, buf, fd, dom); }else if ( count ==-6 ) {if (xc_tmem_restore_extra (xch, dom, fd) ) { -ERROR ("error reading/restoring tmem extra" ); +PERROR ("error reading/restoring tmem extra" );return -1 ; }return pagebuf_get_one (xch, buf, fd, dom);
@@ -1091,12 +1095,13 @@ static int pagebuf_get_one(xc_interface *xch, read_exact(fd, &khz, sizeof(uint32_t)) || read_exact(fd, &incarn, sizeof(uint32_t)) || xc_domain_set_tsc_info(xch, dom, tsc_mode, nsec, khz, incarn) ) { -ERROR ("error reading/restoring tsc info" ); +PERROR ("error reading/restoring tsc info" );return -1 ; }return pagebuf_get_one (xch, buf, fd, dom); }else if ( (count >MAX_BATCH_SIZE ) || (count <0 ) ) {ERROR ("Max batch size exceeded (%d). Giving up." , count); + errno =EMSGSIZE ;return -1 ; }
@@ -1115,7 +1120,7 @@ static int pagebuf_get_one(xc_interface *xch, buf->pfn_types = ptmp; }if (read_exact (fd, buf->pfn_types + oldcount, count *sizeof (*(buf->pfn_types)))) { -ERROR ("Error when reading region pfn types" ); +PERROR ("Error when reading region pfn types" );return -1 ; }
@@ -1142,7 +1147,7 @@ static int pagebuf_get_one(xc_interface *xch, buf->pages = ptmp; }if (read_exact (fd, buf->pages + oldcount *PAGE_SIZE , countpages *PAGE_SIZE ) ) { -ERROR ("Error when reading pages" ); +PERROR ("Error when reading pages" );return -1 ; }
@@ -1202,7 +1207,7 @@ static int apply_batch(xc_interface *xch, uint32_t dom, struct restore_ctx *ctx,if ( region_base ==NULL ) { -ERROR ("map batch failed" ); +PERROR ("map batch failed" );free (pfn_err);return -1 ; }
@@ -1305,7 +1310,7 @@ static int apply_batch(xc_interface *xch, uint32_t dom, struct restore_ctx *ctx, (((unsigned long long)mfn) << PAGE_SHIFT) | MMU_MACHPHYS_UPDATE, pfn) ) { -ERROR ("failed machpys update mfn=%lx pfn=%lx" , mfn, pfn); +PERROR ("failed machpys update mfn=%lx pfn=%lx" , mfn, pfn); goto err_mapped; } }/* end of 'batch' for loop */
@@ -1389,7 +1394,7 @@ int xc_domain_restore(xc_interface *xch, int io_fd, uint32_t dom,if (read_exact (io_fd, &dinfo->p2m_size,sizeof (unsigned long )) ) { -ERROR ("read: p2m_size" ); +PERROR ("read: p2m_size" ); goto out; }DPRINTF ("xc_domain_restore start: p2m_size = %lx\n" , dinfo->p2m_size);
@@ -1423,7 +1428,7 @@ int xc_domain_restore(xc_interface *xch, int io_fd, uint32_t dom, frc =do_domctl (xch, &domctl);if ( frc !=0 ) { -ERROR ("Unable to set guest address size." ); +PERROR ("Unable to set guest address size." ); goto out; } }
@@ -1448,7 +1453,7 @@ int xc_domain_restore(xc_interface *xch, int io_fd, uint32_t dom,if (lock_pages (region_mfn,sizeof (xen_pfn_t) *MAX_BATCH_SIZE ) ) { -ERROR ("Could not lock region_mfn" ); +PERROR ("Could not lock region_mfn" ); goto out; }
@@ -1457,7 +1462,7 @@ int xc_domain_restore(xc_interface *xch, int io_fd, uint32_t dom, domctl.domain = (domid_t )dom;if (xc_domctl (xch, &domctl) <0 ) { -ERROR ("Could not get information on new domain" ); +PERROR ("Could not get information on new domain" ); goto out; } shared_info_frame = domctl.u.getdomaininfo.shared_info_frame;
@@ -1469,7 +1474,7 @@ int xc_domain_restore(xc_interface *xch, int io_fd, uint32_t dom, mmu =xc_alloc_mmu_updates (xch, dom);if ( mmu ==NULL ) { -ERROR ("Could not initialise for MMU updates" ); +PERROR ("Could not initialise for MMU updates" ); goto out; }
@@ -1492,7 +1497,7 @@ int xc_domain_restore(xc_interface *xch, int io_fd, uint32_t dom,if ( !completed ) { pagebuf.nr_physpages = pagebuf.nr_pages =0 ;if (pagebuf_get_one (xch, &pagebuf, io_fd, dom) <0 ) { -ERROR ("Error when reading batch\n" ); +PERROR ("Error when reading batch\n" ); goto out; } }
@@ -1551,7 +1556,7 @@ int xc_domain_restore(xc_interface *xch, int io_fd, uint32_t dom,*/ if ( !hvm &&xc_flush_mmu_updates (xch, mmu) ) { -ERROR ("Error doing flush_mmu_updates()" ); +PERROR ("Error doing flush_mmu_updates()" ); goto out; }
@@ -1575,7 +1580,7 @@ int xc_domain_restore(xc_interface *xch, int io_fd, uint32_t dom,// DPRINTF("Buffered checkpoint\n"); if (pagebuf_get (xch, &pagebuf, io_fd, dom) ) { -ERROR ("error when buffering batch, finishing\n" ); +PERROR ("error when buffering batch, finishing" ); goto finish; }memset (&tmptail,0 ,sizeof (tmptail));
@@ -1633,7 +1638,7 @@ int xc_domain_restore(xc_interface *xch, int io_fd, uint32_t dom, new_mfn =xc_make_page_below_4G (xch, dom, ctx->p2m[i]);if ( !new_mfn ) { -ERROR ("Couldn't get a page below 4GB :-(" ); +PERROR ("Couldn't get a page below 4GB :-(" ); goto out; }
@@ -1643,7 +1648,7 @@ int xc_domain_restore(xc_interface *xch, int io_fd, uint32_t dom, << PAGE_SHIFT) | MMU_MACHPHYS_UPDATE, i) ) { -ERROR ("Couldn't m2p on PAE root pgdir" ); +PERROR ("Couldn't m2p on PAE root pgdir" ); goto out; }
@@ -1676,7 +1681,7 @@ int xc_domain_restore(xc_interface *xch, int io_fd, uint32_t dom, xch, dom, PROT_READ | PROT_WRITE, region_mfn, j);if ( region_base ==NULL ) { -ERROR ("map batch failed" ); +PERROR ("map batch failed" ); goto out; }
@@ -1698,7 +1703,7 @@ int xc_domain_restore(xc_interface *xch, int io_fd, uint32_t dom,if (xc_flush_mmu_updates (xch, mmu) ) { -ERROR ("Error doing xc_flush_mmu_updates()" ); +PERROR ("Error doing xc_flush_mmu_updates()" ); goto out; } }
@@ -1743,7 +1748,7 @@ int xc_domain_restore(xc_interface *xch, int io_fd, uint32_t dom, {if (xc_mmuext_op (xch, pin, nr_pins, dom) <0 ) { -ERROR ("Failed to pin batch of %d page tables" , nr_pins); +PERROR ("Failed to pin batch of %d page tables" , nr_pins); goto out; } nr_pins =0 ;
@@ -1753,7 +1758,7 @@ int xc_domain_restore(xc_interface *xch, int io_fd, uint32_t dom,/* Flush final partial batch. */ if ( (nr_pins !=0 ) && (xc_mmuext_op (xch, pin, nr_pins, dom) <0 ) ) { -ERROR ("Failed to pin batch of %d page tables" , nr_pins); +PERROR ("Failed to pin batch of %d page tables" , nr_pins); goto out; }
@@ -1788,7 +1793,7 @@ int xc_domain_restore(xc_interface *xch, int io_fd, uint32_t dom,if ( (frc =xc_memory_op (xch, XENMEM_decrease_reservation, &reservation)) != nr_frees ) { -ERROR ("Could not decrease reservation : %d" , frc); +PERROR ("Could not decrease reservation : %d" , frc); goto out; }else
@@ -1798,7 +1803,7 @@ int xc_domain_restore(xc_interface *xch, int io_fd, uint32_t dom,if (lock_pages (&ctxt,sizeof (ctxt)) ) { -ERROR ("Unable to lock ctxt" ); +PERROR ("Unable to lock ctxt" );return 1 ; }
@@ -1911,7 +1916,7 @@ int xc_domain_restore(xc_interface *xch, int io_fd, uint32_t dom, frc =xc_domctl (xch, &domctl);if ( frc !=0 ) { -ERROR ("Couldn't build vcpu%d" , i); +PERROR ("Couldn't build vcpu%d" , i); goto out; }
@@ -1924,7 +1929,7 @@ int xc_domain_restore(xc_interface *xch, int io_fd, uint32_t dom, frc =xc_domctl (xch, &domctl);if ( frc !=0 ) { -ERROR ("Couldn't set extended vcpu%d info\n" , i); +PERROR ("Couldn't set extended vcpu%d info\n" , i); goto out; } }
@@ -1968,7 +1973,7 @@ int xc_domain_restore(xc_interface *xch, int io_fd, uint32_t dom,if ( !(ctx->live_p2m =xc_map_foreign_pages (xch, dom,PROT_WRITE , p2m_frame_list,P2M_FL_ENTRIES )) ) { -ERROR ("Couldn't map p2m table" ); +PERROR ("Couldn't map p2m table" ); goto out; }
@@ -1991,7 +1996,7 @@ int xc_domain_restore(xc_interface *xch, int io_fd, uint32_t dom, finish_hvm:/* Dump the QEMU state to a state file for QEMU to load */ if (dump_qemu (xch, dom, &tailbuf.u.hvm) ) { -ERROR ("Error dumping QEMU state to file" ); +PERROR ("Error dumping QEMU state to file" ); goto out; }
@@ -2000,7 +2005,7 @@ int xc_domain_restore(xc_interface *xch, int io_fd, uint32_t dom, xc_clear_domain_page(xch, dom, tailbuf.u.hvm.magicpfns[1]) || xc_clear_domain_page(xch, dom, tailbuf.u.hvm.magicpfns[2]) ) { -ERROR ("error zeroing magic pages" ); +PERROR ("error zeroing magic pages" ); goto out; }
@@ -2016,7 +2021,7 @@ int xc_domain_restore(xc_interface *xch, int io_fd, uint32_t dom, HVM_PARAM_STORE_EVTCHN, store_evtchn)) ) { -ERROR ("error setting HVM params: %i" , frc); +PERROR ("error setting HVM params: %i" , frc); goto out; } *store_mfn = tailbuf.u.hvm.magicpfns[2 ];
@@ -2025,7 +2030,7 @@ int xc_domain_restore(xc_interface *xch, int io_fd, uint32_t dom, tailbuf.u.hvm.reclen);if ( frc ) { -ERROR ("error setting the HVM context" ); +PERROR ("error setting the HVM context" ); goto out; }
tools/libxc/xc_domain_save.c +33 -31
255 lines not on this page · raw message
tools/libxc/xc_private.c +2 -0
@@ -741,6 +741,8 @@ int read_exact(int fd, void *data, size_t size) len =read (fd, (char *)data + offset, size - offset);if ( (len ==-1 ) && (errno ==EINTR ) )continue ; +if ( len ==0 ) + errno =0 ;if ( len <=0 )return -1 ; offset += len;
tools/libxc/xc_private.h +2 -2
@@ -226,8 +226,8 @@ int xc_add_mmu_update(xc_interface *xch, struct xc_mmu *mmu, unsigned long long ptr, unsigned long long val);int xc_flush_mmu_updates (xc_interface *xch,struct xc_mmu *mmu); -/* Return 0 on success; -1 on error. */ -int read_exact (int fd,void *data,size_t size); +/* Return 0 on success; -1 on error setting errno. */ +int read_exact (int fd,void *data,size_t size);/* EOF => -1, errno=0 */ int write_exact (int fd,const void *data,size_t size);int xc_ffs8 (uint8_t x);
Signature · 1 line
1.5.6.5
PATCH 13/14 libxc: remove \n from strings passed to PERROR
Previously, the code was inconsistent: some calls to PERROR passed \n and some did not. With the new logging arrangements, passing \n is definitely incorrect.
--- tools/libxc/ia64/xc_ia64_hvm_build.c | 30 +++++++++++++++--------------- tools/libxc/ia64/xc_ia64_linux_restore.c | 2 +- tools/libxc/xc_domain.c | 2 +- tools/libxc/xc_domain_restore.c | 14 +++++++------- tools/libxc/xc_domain_save.c | 4 ++-- tools/libxc/xc_hvm_build.c | 10 +++++----- tools/libxc/xc_misc.c | 2 +- tools/libxc/xc_resume.c | 2 +- tools/libxc/xc_solaris.c | 2 +- 9 files changed, 34 insertions(+), 34 deletions(-)
tools/libxc/ia64/xc_ia64_hvm_build.c +15 -15
@@ -586,7 +586,7 @@ static int is_valid_address(void *addr)if ( p->signature ==NVRAM_VALID_SIG )return 1 ;else { -PERROR ("Invalid nvram signature. Nvram save failed!\n" ); +PERROR ("Invalid nvram signature. Nvram save failed!" );return 0 ; } }
@@ -613,7 +613,7 @@ copy_from_GFW_to_nvram(xc_interface *xc_handle, uint32_t dom, int nvram_fd) pfn_list = (xen_pfn_t *)malloc (sizeof (xen_pfn_t) * nr_pages);if (NULL == pfn_list ) { -PERROR ("Cannot allocate memory for nvram save!\n" ); +PERROR ("Cannot allocate memory for nvram save!" );close (nvram_fd);return -1 ; }
@@ -630,7 +630,7 @@ copy_from_GFW_to_nvram(xc_interface *xc_handle, uint32_t dom, int nvram_fd)if (NULL == tmp_ptr ) { -PERROR ("Cannot get nvram data from GFW!\n" ); +PERROR ("Cannot get nvram data from GFW!" );free (pfn_list);close (nvram_fd);return -1 ;
@@ -659,7 +659,7 @@ copy_from_GFW_to_nvram(xc_interface *xc_handle, uint32_t dom, int nvram_fd) pfn_list, nr_pages);if (NULL == tmp_ptr ) { -PERROR ("Cannot get nvram data from GFW!\n" ); +PERROR ("Cannot get nvram data from GFW!" );free (pfn_list);close (nvram_fd);return -1 ;
@@ -675,7 +675,7 @@ copy_from_GFW_to_nvram(xc_interface *xc_handle, uint32_t dom, int nvram_fd)lseek (nvram_fd,0 ,SEEK_SET );if (write (nvram_fd, buf,NVRAM_SIZE ) !=NVRAM_SIZE ) { -PERROR ("Save to nvram fail!\n" ); +PERROR ("Save to nvram fail!" );return -1 ; }
@@ -703,7 +703,7 @@ int xc_ia64_save_to_nvram(xc_interface *xc_handle, uint32_t dom)xc_get_hvm_param (xc_handle, dom,HVM_PARAM_NVRAM_FD , &nvram_fd);if ( !IS_VALID_NVRAM_FD (nvram_fd) ) -PERROR ("Nvram not initialized. Nvram save failed!\n" ); +PERROR ("Nvram not initialized. Nvram save failed!" );else copy_from_GFW_to_nvram (xc_handle, dom, (int )nvram_fd);
@@ -744,7 +744,7 @@ int xc_ia64_nvram_init(xc_interface *xc_handle, char *dom_name, uint32_t dom)if (strlen (nvram_path) +strlen (NVRAM_FILE_PREFIX ) +strlen (dom_name) +1 >sizeof (nvram_path) ) { -PERROR ("Nvram file path is too long!\n" ); +PERROR ("Nvram file path is too long!" );return -1 ; }strcat (nvram_path,NVRAM_FILE_PREFIX );
@@ -800,7 +800,7 @@ xc_ia64_setup_memmap_info(xc_interface *xc_handle, uint32_t dom,PROT_READ |PROT_WRITE , memmap_info_pfn);if (memmap_info ==NULL ) { -PERROR ("Could not map memmmap_info page.\n" ); +PERROR ("Could not map memmmap_info page." );return -1 ; }memset (memmap_info,0 ,PAGE_SIZE * memmap_info_num_pages);
@@ -925,7 +925,7 @@ setup_guest(xc_interface *xc_handle, uint32_t dom, unsigned long memsize, pfn_list =malloc (nr_pages *sizeof (xen_pfn_t));if (pfn_list ==NULL ) { -PERROR ("Could not allocate memory.\n" ); +PERROR ("Could not allocate memory." );return -1 ; }
@@ -952,7 +952,7 @@ setup_guest(xc_interface *xc_handle, uint32_t dom, unsigned long memsize, rc =xc_domain_memory_populate_physmap (xc_handle, dom, nr_pages,0 ,0 , &pfn_list[0 ]);if (rc !=0 ) { -PERROR ("Could not allocate normal memory for Vti guest.\n" ); +PERROR ("Could not allocate normal memory for Vti guest." ); goto error_out; }
@@ -965,7 +965,7 @@ setup_guest(xc_interface *xc_handle, uint32_t dom, unsigned long memsize, rc =xc_domain_memory_populate_physmap (xc_handle, dom,GFW_PAGES ,0 ,0 , &pfn_list[0 ]);if (rc !=0 ) { -PERROR ("Could not allocate GFW memory for Vti guest.\n" ); +PERROR ("Could not allocate GFW memory for Vti guest." ); goto error_out; }
@@ -981,7 +981,7 @@ setup_guest(xc_interface *xc_handle, uint32_t dom, unsigned long memsize, rc =xc_domain_memory_populate_physmap (xc_handle, dom, nr_special_pages,0 ,0 , &pfn_list[0 ]);if (rc !=0 ) { -PERROR ("Could not allocate IO page or store page or buffer io page.\n" ); +PERROR ("Could not allocate IO page or store page or buffer io page." ); goto error_out; }
@@ -1013,13 +1013,13 @@ setup_guest(xc_interface *xc_handle, uint32_t dom, unsigned long memsize,if (xc_ia64_setup_memmap_info (xc_handle, dom, dom_memsize, pfn_list, nr_special_pages, memmap_info_pfn, memmap_info_num_pages)) { -PERROR ("Could not build memmap info\n" ); +PERROR ("Could not build memmap info" ); goto error_out; }if (xc_ia64_setup_shared_info (xc_handle, dom, domctl.u.getdomaininfo.shared_info_frame, memmap_info_pfn, memmap_info_num_pages)) { -PERROR ("Could not setup shared_info\n" ); +PERROR ("Could not setup shared_info" ); goto error_out; }
@@ -1035,7 +1035,7 @@ setup_guest(xc_interface *xc_handle, uint32_t dom, unsigned long memsize,// Hand-off state passed to guest firmware if (xc_ia64_build_hob (xc_handle, dom, dom_memsize, vcpus, nvram_start) <0 ) { -PERROR ("Could not build hob\n" ); +PERROR ("Could not build hob" ); goto error_out; }
tools/libxc/ia64/xc_ia64_linux_restore.c +1 -1
@@ -534,7 +534,7 @@ xc_ia64_hvm_domain_setup(xc_interface *xc_handle, uint32_t dom) rc =xc_domain_memory_populate_physmap (xc_handle, dom, nr_pages,0 ,0 , &pfn_list[0 ]);if (rc !=0 ) -PERROR ("Could not allocate IO page or buffer io page.\n" ); +PERROR ("Could not allocate IO page or buffer io page." );return rc; }
tools/libxc/xc_domain.c +1 -1
@@ -948,7 +948,7 @@ int xc_get_device_group(if (lock_pages (sdev_array, max_sdevs *sizeof (*sdev_array)) !=0 ) { -PERROR ("Could not lock memory for xc_get_device_group\n" ); +PERROR ("Could not lock memory for xc_get_device_group" );return -ENOMEM ; } rc =do_domctl (xch, &domctl);
tools/libxc/xc_domain_restore.c +7 -7
@@ -124,7 +124,7 @@ static int break_super_page(xc_interface *xch,if ( ram_base ==NULL ) { -PERROR ("map batch failed\n" ); +PERROR ("map batch failed" ); rc =1 ; goto out; }
@@ -136,7 +136,7 @@ static int break_super_page(xc_interface *xch,if (xc_domain_memory_decrease_reservation (xch, dom,1 ,SUPERPAGE_PFN_SHIFT , &start_pfn) !=0 ) { -PERROR ("free 2M page failure @ 0x%ld.\n" , next_pfn); +PERROR ("free 2M page failure @ 0x%ld." , next_pfn); rc =1 ; goto out; }
@@ -153,7 +153,7 @@ static int break_super_page(xc_interface *xch,if (xc_domain_memory_populate_physmap (xch, dom,1 ,0 ,0 , &mfn) !=0 ) { -PERROR ("Failed to allocate physical memory.!\n" ); +PERROR ("Failed to allocate physical memory.!" ); errno =ENOMEM ; rc =1 ; goto out;
@@ -171,7 +171,7 @@ static int break_super_page(xc_interface *xch, page_array, tot_pfns);if ( ram_base ==NULL ) { -PERROR ("map batch failed\n" ); +PERROR ("map batch failed" ); rc =1 ; goto out; }
@@ -283,7 +283,7 @@ normal_page:if (xc_domain_memory_populate_physmap (xch, dom,1 ,0 ,0 , &mfn) !=0 ) { -PERROR ("Failed to allocate physical memory.! pfn=0x%lx, mfn=0x%lx.\n" , +PERROR ("Failed to allocate physical memory.! pfn=0x%lx, mfn=0x%lx." , pfn, mfn); errno =ENOMEM ;return 1 ;
@@ -1497,7 +1497,7 @@ int xc_domain_restore(xc_interface *xch, int io_fd, uint32_t dom,if ( !completed ) { pagebuf.nr_physpages = pagebuf.nr_pages =0 ;if (pagebuf_get_one (xch, &pagebuf, io_fd, dom) <0 ) { -PERROR ("Error when reading batch\n" ); +PERROR ("Error when reading batch" ); goto out; } }
@@ -1929,7 +1929,7 @@ int xc_domain_restore(xc_interface *xch, int io_fd, uint32_t dom, frc =xc_domctl (xch, &domctl);if ( frc !=0 ) { -PERROR ("Couldn't set extended vcpu%d info\n" , i); +PERROR ("Couldn't set extended vcpu%d info" , i); goto out; } }
tools/libxc/xc_domain_save.c +2 -2
@@ -1625,7 +1625,7 @@ int xc_domain_save(xc_interface *xch, int io_fd, uint32_t dom, uint32_t max_iterif (wrexact (io_fd, hvm_buf, rec_size) ) { -PERROR ("write HVM info failed!\n" ); +PERROR ("write HVM info failed!" ); goto out; }
@@ -1785,7 +1785,7 @@ int xc_domain_save(xc_interface *xch, int io_fd, uint32_t dom, uint32_t max_iter/* Flush last write and discard cache for file. */ if (outbuf_flush (xch, &ob, io_fd) <0 ) { -PERROR ("Error when flushing output buffer\n" ); +PERROR ("Error when flushing output buffer" ); rc =1 ; }
tools/libxc/xc_hvm_build.c +5 -5
@@ -152,13 +152,13 @@ static int setup_guest(xc_interface *xch,if (xc_version (xch, XENVER_capabilities, &caps) !=0 ) { -PERROR ("Could not get Xen capabilities\n" ); +PERROR ("Could not get Xen capabilities" ); goto error_out; }if ( (elf.pstart & (PAGE_SIZE -1 )) !=0 ) { -PERROR ("Guest OS must load to a page boundary.\n" ); +PERROR ("Guest OS must load to a page boundary." ); goto error_out; }
@@ -172,7 +172,7 @@ static int setup_guest(xc_interface *xch,if ( (page_array =malloc (nr_pages *sizeof (xen_pfn_t))) ==NULL ) { -PERROR ("Could not allocate memory.\n" ); +PERROR ("Could not allocate memory." ); goto error_out; }
@@ -317,7 +317,7 @@ static int setup_guest(xc_interface *xch,if ( rc !=0 ) { -PERROR ("Could not allocate memory for HVM guest.\n" ); +PERROR ("Could not allocate memory for HVM guest." ); goto error_out; }
@@ -362,7 +362,7 @@ static int setup_guest(xc_interface *xch, rc =xc_domain_memory_populate_physmap (xch, dom,1 ,0 ,0 , &pfn);if ( rc !=0 ) { -PERROR ("Could not allocate %d'th special page.\n" , i); +PERROR ("Could not allocate %d'th special page." , i); goto error_out; }if (xc_clear_domain_page (xch, dom,special_pfn (i)) )
tools/libxc/xc_misc.c +1 -1
@@ -142,7 +142,7 @@ int xc_mca_op(xc_interface *xch, struct xen_mc *mc) mc->interface_version =XEN_MCA_INTERFACE_VERSION ;if (lock_pages (mc,sizeof (mc)) ) { -PERROR ("Could not lock xen_mc memory\n" ); +PERROR ("Could not lock xen_mc memory" );return -EINVAL ; }
tools/libxc/xc_resume.c +1 -1
@@ -47,7 +47,7 @@ static int modify_returncode(xc_interface *xch, uint32_t domid)/* HVM guests have host address width. */ if (xc_version (xch, XENVER_capabilities, &caps) !=0 ) { -PERROR ("Could not get Xen capabilities\n" ); +PERROR ("Could not get Xen capabilities" );return -1 ; } dinfo->guest_width =strstr (caps,"x86_64" ) ?8 :4 ;
tools/libxc/xc_solaris.c +1 -1
@@ -139,7 +139,7 @@ void *xc_map_foreign_ranges(xc_interface *xch, uint32_t dom, ioctl_failed: rc =munmap (addr, size);if (rc ==-1 ) -PERROR ("%s: error in error path\n" , __FUNCTION__); +PERROR ("%s: error in error path" , __FUNCTION__); mmap_failed:return NULL ;
Signature · 1 line
1.5.6.5
PATCH 14/14 xl/libxtl: Remove glitch in xl migrate log output
* Provide a new XTL_STDIOSTREAM_HIDE_PROGRESS flag in the stdio logger
* Provide a way to adjust the flags after logger setup
* Use these to disable progress output from the migration receiver, as the sender is also sending progress information.
--- tools/libxc/xentoollog.h | 11 +++++++++-- tools/libxc/xtl_logger_stdio.c | 15 +++++++++++++++ tools/libxl/xl_cmdimpl.c | 8 +++++++- 3 files changed, 31 insertions(+), 3 deletions(-)
tools/libxc/xentoollog.h +9 -2
@@ -51,8 +51,9 @@ struct xentoollog_logger {/*---------- facilities for consuming log messages ----------*/ -#define XTL_STDIOSTREAM_SHOW_PID 01u -#define XTL_STDIOSTREAM_SHOW_DATE 02u +#define XTL_STDIOSTREAM_SHOW_PID 01u +#define XTL_STDIOSTREAM_SHOW_DATE 02u +#define XTL_STDIOSTREAM_HIDE_PROGRESS 04utypedef struct xentoollog_logger_stdiostream xentoollog_logger_stdiostream ;
@@ -61,6 +62,12 @@ xentoollog_logger_stdiostream *xtl_createlogger_stdiostream/* may return 0 if malloc fails, in which case error was logged */ /* destroy on this logger does not close the file */ +void xtl_stdiostream_set_minlevel (xentoollog_logger_stdiostream *, +xentoollog_level min_level); +void xtl_stdiostream_adjust_flags (xentoollog_logger_stdiostream *, +unsigned set_flags,unsigned clear_flags); +/* if set_flags and clear_flags overlap, set_flags takes precedence */ +void xtl_logger_destroy (struct xentoollog_logger *logger/* 0 is ok */ );
tools/libxc/xtl_logger_stdio.c +15 -0
@@ -75,6 +75,9 @@ static void stdiostream_progress(struct xentoollog_logger *logger_in,int newpel, extra_erase;xentoollog_level this_level; +if (!(lg->flags &XTL_STDIOSTREAM_HIDE_PROGRESS )) +return ; +if (percent < lg->progress_last_percent) { this_level =XTL_PROGRESS ; }else if (percent == lg->progress_last_percent) {
@@ -108,6 +111,18 @@ static void stdiostream_destroy(struct xentoollog_logger *logger_in) {free (lg); } +void xtl_stdiostream_set_minlevel (xentoollog_logger_stdiostream *lg, +xentoollog_level min_level) { + lg->min_level = min_level; +} + +void xtl_stdiostream_adjust_flags (xentoollog_logger_stdiostream *lg, +unsigned set_flags,unsigned clear_flags) { +unsigned new_flags = (lg->flags & ~clear_flags) | set_flags; +if (new_flags &XTL_STDIOSTREAM_HIDE_PROGRESS ) +progress_erase (lg); + lg->flags = new_flags; +}xentoollog_logger_stdiostream *xtl_createlogger_stdiostream (FILE *f,xentoollog_level min_level,unsigned flags) {
tools/libxl/xl_cmdimpl.c +7 -1
@@ -1917,6 +1917,8 @@ static void migrate_domain(char *domain_spec, const char *rune,save_domain_core_writeconfig (send_fd,"migration stream" , config_data, config_len); +xtl_stdiostream_adjust_flags (logger,XTL_STDIOSTREAM_HIDE_PROGRESS ,0 ); +memset (&suspinfo,0 ,sizeof (suspinfo)); suspinfo.flags |=XL_SUSPEND_LIVE ; rc =libxl_domain_suspend (&ctx, &suspinfo, domid, send_fd);
@@ -1926,13 +1928,17 @@ static void migrate_domain(char *domain_spec, const char *rune, goto failed_resume; } -fprintf (stderr,"migration sender: Transfer complete.\n" ); +//fprintf(stderr, "migration sender: Transfer complete.\n"); +// Should only be printed when debugging as it's a bit messy with +// progress indication. rc =migrate_read_fixedmessage (recv_fd, migrate_receiver_ready,sizeof (migrate_receiver_ready),"ready message" , rune);if (rc) goto failed_resume; +xtl_stdiostream_adjust_flags (logger,0 ,XTL_STDIOSTREAM_HIDE_PROGRESS ); +/* right, at this point we are about give the destination * permission to rename and resume, so we must first rename the * domain away ourselves */
Signature · 1 line
1.5.6.5
Re: [PATCH 11/14] xl: Allow control of logging level.
In reply to Ian JacksonHi Ian,
Quoted 82 lines · Ian Jackson
The -v option, which must come before the xl command, increases the logging level each time it is supplied.
Signed-off-by Ian Jackson <[email protected]>--- tools/libxc/xtl_logger_stdio.c | 5 ++++- tools/libxl/xl.c | 40 ++++++++++++++++++++++++++++------------ tools/libxl/xl.h | 2 +- 3 files changed, 33 insertions(+), 14 deletions(-)tools/libxc/xtl_logger_stdio.c +4
-1@@ -36,6 +36,9 @@ static void stdiostream_vmessage(xentoollog_logger *logger_in, va_list al) {xentoollog_logger_stdiostream *lg = (void *)logger_in; +if (level < lg->min_level) +return ; +progress_erase (lg);if (lg->flags &XTL_STDIOSTREAM_SHOW_DATE ) {@@ -82,7 +85,7 @@ static void stdiostream_progress(struct xentoollog_logger *logger_in, this_level =XTL_PROGRESS ; } -if (lg->min_level < this_level) +if (this_level < lg->min_level)return ;if (lg->progress_erase_len)tools/libxl/xl.c +24
-5@@ -31,19 +31,38 @@#include "libxl_utils.h" #include "xl.h" -xentoollog_logger *logger; +xentoollog_logger_stdiostream *logger; + +static xentoollog_level minmsglevel =XTL_PROGRESS ;int main (int argc,char **argv) { -int i; +int opt =0 , i; +char *cmd =0 ; + +while ((opt =getopt (argc, argv,"+v" )) >=0 ) { +switch (opt) { +case 'v' : +if (minmsglevel >0 ) minmsglevel--; +break ; +default : +fprintf (stderr,"unknown global option\n" ); +exit (2 ); + } + } + + cmd = argv[optind++]; -if (argc <2 ) { +if (!cmd) {help (NULL );exit (1 ); } + opterr =0 ; + + logger =xtl_createlogger_stdiostream (stderr, minmsglevel,0 ); +if (!logger)exit (1 ); - logger =xtl_createlogger_stdiostream (stderr,XTL_PROGRESS ,0 ); -if (libxl_ctx_init (&ctx,LIBXL_VERSION , logger)) { +if (libxl_ctx_init (&ctx,LIBXL_VERSION , (xentoollog_logger *)logger)) {fprintf (stderr,"cannot init xl context\n" );exit (1 ); }
tools/libxl/xl.c int main(int argc, char **argv) · line 74
Quoted 7 lines
tools/libxl/xl.c +2
-2@@ -51,16 +70,13 @@ int main(int argc, char **argv)srand (time (0 ));for (i =0 ; i < cmdtable_len; i++) { -if (!strcmp (argv[1 ], cmd_table[i].cmd_name)) - cmd_table[i].cmd_impl (argc -1 , argv +1 ); +if (!strcmp (cmd, cmd_table[i].cmd_name)) + cmd_table[i].cmd_impl (argc, argv);
Why are you change (argc - 1, argv + 1) to (argc, argv)? this causes many command line parseing problems in current code...Since we've already fix some of the command line parseing problems, I wonder if we could change these back?
Quoted 25 lines
tools/libxl/xl.c +2
-5}if (i >= cmdtable_len) { -if (!strcmp (argv[1 ],"help" )) { -if (argc >2 ) -help (argv[2 ]); -else -help (NULL ); +if (!strcmp (cmd,"help" )) { +help (argv[1 ]);exit (0 ); }else {fprintf (stderr,"command not implemented\n" );tools/libxl/xl.h +1
-1@@ -77,6 +77,6 @@ extern struct cmd_spec cmd_table[];extern int cmdtable_len;extern struct libxl_ctx ctx; -extern xentoollog_logger *logger; +extern xentoollog_logger_stdiostream *logger;#endif /* XL_H */
Signature · 2 lines
Regards Yang Hongyang
Re: [PATCH 11/14] xl: Allow control of logging level.
Yang Hongyang writes ("Re: [Xen-devel] [PATCH 11/14] xl: Allow control of logging level."):
Quoted 4 lines
Why are you change (argc - 1, argv + 1) to (argc, argv)? this causes many command line parseing problems in current code...Since we've already fix some of the command line parseing problems, I wonder if we could change these back?
I mainly tested it with "xl migrate". Perhaps the bug was in "xl migrate" and not in the other functions. There doesn't seem to be much consistency.
I'm happy for it to be fixed either way.
Ian.
Patch 7/14 hasn't made it afaics.
-- Keir
Quoted 29 lines · Ian Jackson
In this patch series I do some serious cleanup. In particular:
* Remove all static global variables from libxc
so that the library is fully reentrant.
* Allow all callers of libxs, libxc, libxl to control where log messages to go.
* Assorted other minor fixups.This involves an incompatible change to the interface to libxc. Instead of simply getting an int representing a file descriptor, callers now get an xc_interface*. Also, there are three new parameters to
xc_interface_openfor which naive callers may pass 0.The overall result is that (amongst other things) the stderr output from "xl" is much more sensible.
(This is a resend of the series with the patches numbered in the Subject line as they should have been. Sorry for the inconvenience.)
Signed-off-by Ian Jackson <[email protected]>_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Keir Fraser writes ("Re: [Xen-devel] [PATCH 00/14] Logging cleanups, libxc API change"):
Quoted 1 line
Patch 7/14 hasn't made it afaics.
Damn. That's the really big one - it's 15000 lines :-/.
For the moment I've put it up here:
http://www.chiark.greenend.org.uk/~ijackson/0007-libxc-eliminate-static-variables-use-xentoollog-A.patch
But really it should be let out onto the list so people can review it. Stephen, you've got access to the list management for xen-devel - can you check whether my message is stuck there and if so release it ?
Ian.