From 5cc436c1d2b3b0be3f42104582f53eec3969b43a Mon Sep 17 00:00:00 2001 From: Keir Fraser Date: Fri, 28 May 2010 09:30:19 +0100 Subject: 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. Signed-off-by: Ian Jackson --- tools/xcutils/lsevtchn.c | 11 ++++++----- tools/xcutils/readnotes.c | 11 ++++++++--- tools/xcutils/xc_restore.c | 11 ++++++----- tools/xcutils/xc_save.c | 18 +++++++++--------- 4 files changed, 29 insertions(+), 22 deletions(-) (limited to 'tools/xcutils') diff --git a/tools/xcutils/lsevtchn.c b/tools/xcutils/lsevtchn.c index 7e7bcbeff7..e79fe0990a 100644 --- a/tools/xcutils/lsevtchn.c +++ b/tools/xcutils/lsevtchn.c @@ -10,20 +10,21 @@ int main(int argc, char **argv) { - int xc_fd, domid, port, rc; + xc_interface *xch; + int domid, port, rc; xc_evtchn_status_t status; domid = (argc > 1) ? strtol(argv[1], NULL, 10) : 0; - xc_fd = xc_interface_open(); - if ( xc_fd < 0 ) + xch = xc_interface_open(0,0,0); + if ( !xch ) errx(1, "failed to open control interface"); for ( port = 0; ; port++ ) { status.dom = domid; status.port = port; - rc = xc_evtchn_status(xc_fd, &status); + rc = xc_evtchn_status(xch, &status); if ( rc < 0 ) break; @@ -59,7 +60,7 @@ int main(int argc, char **argv) printf("\n"); } - xc_interface_close(xc_fd); + xc_interface_close(xch); return 0; } diff --git a/tools/xcutils/readnotes.c b/tools/xcutils/readnotes.c index 270c48b017..26376854b2 100644 --- a/tools/xcutils/readnotes.c +++ b/tools/xcutils/readnotes.c @@ -5,6 +5,7 @@ #include #include #include +#include #include #include @@ -15,6 +16,8 @@ #include +static xc_interface *xch; + static void print_string_note(const char *prefix, struct elf_binary *elf, const elf_note *note) { @@ -135,6 +138,8 @@ int main(int argc, char **argv) } f = argv[1]; + xch = xc_interface_open(0,0,XC_OPENFLAG_DUMMY); + fd = open(f, O_RDONLY); if (fd == -1) { @@ -156,11 +161,11 @@ int main(int argc, char **argv) } size = st.st_size; - usize = xc_dom_check_gzip(image, st.st_size); + usize = xc_dom_check_gzip(xch, image, st.st_size); if (usize) { tmp = malloc(usize); - xc_dom_do_gunzip(image, st.st_size, tmp, usize); + xc_dom_do_gunzip(xch, image, st.st_size, tmp, usize); image = tmp; size = usize; } @@ -170,7 +175,7 @@ int main(int argc, char **argv) fprintf(stderr, "File %s is not an ELF image\n", f); return 1; } - xc_elf_set_logfile(&elf, stderr, 0); + xc_elf_set_logfile(xch, &elf, 0); count = elf_phdr_count(&elf); for ( h=0; h < count; h++) diff --git a/tools/xcutils/xc_restore.c b/tools/xcutils/xc_restore.c index da4aa98b78..ea069ac8f5 100644 --- a/tools/xcutils/xc_restore.c +++ b/tools/xcutils/xc_restore.c @@ -20,7 +20,8 @@ main(int argc, char **argv) { unsigned int domid, store_evtchn, console_evtchn; unsigned int hvm, pae, apic; - int xc_fd, io_fd, ret; + xc_interface *xch; + int io_fd, ret; int superpages; unsigned long store_mfn, console_mfn; @@ -28,8 +29,8 @@ main(int argc, char **argv) errx(1, "usage: %s iofd domid store_evtchn " "console_evtchn hvm pae apic [superpages]", argv[0]); - xc_fd = xc_interface_open(); - if ( xc_fd < 0 ) + xch = xc_interface_open(0,0,0); + if ( !xch ) errx(1, "failed to open control interface"); io_fd = atoi(argv[1]); @@ -44,7 +45,7 @@ main(int argc, char **argv) else superpages = 0; - ret = xc_domain_restore(xc_fd, io_fd, domid, store_evtchn, &store_mfn, + ret = xc_domain_restore(xch, io_fd, domid, store_evtchn, &store_mfn, console_evtchn, &console_mfn, hvm, pae, superpages); if ( ret == 0 ) @@ -55,7 +56,7 @@ main(int argc, char **argv) fflush(stdout); } - xc_interface_close(xc_fd); + xc_interface_close(xch); return ret; } diff --git a/tools/xcutils/xc_save.c b/tools/xcutils/xc_save.c index 02570bda45..cdf62afba6 100644 --- a/tools/xcutils/xc_save.c +++ b/tools/xcutils/xc_save.c @@ -24,7 +24,7 @@ #include static struct suspendinfo { - int xc_fd; /* libxc handle */ + xc_interface *xch; int xce; /* event channel handle */ int suspend_evtchn; int domid; @@ -59,7 +59,7 @@ static int evtchn_suspend(void) return 0; } - if (xc_await_suspend(si.xce, si.suspend_evtchn) < 0) { + if (xc_await_suspend(si.xch, si.xce, si.suspend_evtchn) < 0) { warnx("suspend failed"); return 0; } @@ -77,7 +77,7 @@ static int suspend(void* data) /* Cannot notify guest to shut itself down if it's in ACPI sleep state. */ if (si.flags & XCFLAGS_HVM) - xc_get_hvm_param(si.xc_fd, si.domid, + xc_get_hvm_param(si.xch, si.domid, HVM_PARAM_ACPI_S_STATE, &sx_state); if ((sx_state == 0) && (si.suspend_evtchn >= 0)) @@ -171,8 +171,8 @@ main(int argc, char **argv) if (argc != 6) errx(1, "usage: %s iofd domid maxit maxf flags", argv[0]); - si.xc_fd = xc_interface_open(); - if (si.xc_fd < 0) + si.xch = xc_interface_open(0,0,0); + if (!si.xch) errx(1, "failed to open control interface"); io_fd = atoi(argv[1]); @@ -196,7 +196,7 @@ main(int argc, char **argv) else { si.suspend_evtchn = - xc_suspend_evtchn_init(si.xc_fd, si.xce, si.domid, port); + xc_suspend_evtchn_init(si.xch, si.xce, si.domid, port); if (si.suspend_evtchn < 0) warnx("suspend event channel initialization failed" @@ -205,17 +205,17 @@ main(int argc, char **argv) } memset(&callbacks, 0, sizeof(callbacks)); callbacks.suspend = suspend; - ret = xc_domain_save(si.xc_fd, io_fd, si.domid, maxit, max_f, si.flags, + ret = xc_domain_save(si.xch, io_fd, si.domid, maxit, max_f, si.flags, &callbacks, !!(si.flags & XCFLAGS_HVM), &switch_qemu_logdirty); if (si.suspend_evtchn > 0) - xc_suspend_evtchn_release(si.xce, si.domid, si.suspend_evtchn); + xc_suspend_evtchn_release(si.xch, si.xce, si.domid, si.suspend_evtchn); if (si.xce > 0) xc_evtchn_close(si.xce); - xc_interface_close(si.xc_fd); + xc_interface_close(si.xch); return ret; } -- cgit v1.2.3